Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build only needed shaders with --cpu #383

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cpu_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum TypedBufGuard<'a, T: ?Sized> {
}

pub enum TypedBufGuardMut<'a, T: ?Sized> {
#[allow(dead_code)]
Slice(&'a mut T),
Interior(RefMut<'a, T>),
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{

pub type Error = Box<dyn std::error::Error>;

#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct ShaderId(pub usize);

#[derive(Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
14 changes: 4 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ pub struct RendererOptions {
impl Renderer {
/// Creates a new renderer for the specified device.
pub fn new(device: &Device, render_options: &RendererOptions) -> Result<Self> {
let mut engine = WgpuEngine::new();
let mut shaders = shaders::full_shaders(device, &mut engine)?;
if render_options.use_cpu {
shaders.install_cpu_shaders(&mut engine);
}
let mut engine = WgpuEngine::new(render_options.use_cpu);
let shaders = shaders::full_shaders(device, &mut engine)?;
let blit = render_options
.surface_format
.map(|surface_format| BlitPipeline::new(device, surface_format));
Expand Down Expand Up @@ -240,11 +237,8 @@ impl Renderer {
#[cfg(feature = "hot_reload")]
pub async fn reload_shaders(&mut self, device: &Device) -> Result<()> {
device.push_error_scope(wgpu::ErrorFilter::Validation);
let mut engine = WgpuEngine::new();
let mut shaders = shaders::full_shaders(device, &mut engine)?;
if self.use_cpu {
shaders.install_cpu_shaders(&mut engine);
}
let mut engine = WgpuEngine::new(self.use_cpu);
let shaders = shaders::full_shaders(device, &mut engine)?;
let error = device.pop_error_scope().await;
if let Some(error) = error {
return Err(error.into());
Expand Down
Loading