Skip to content

Commit

Permalink
enable shader bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
molikto committed Dec 29, 2021
1 parent 683458b commit 1417327
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_render/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Default for WgpuOptions {
device_label: Default::default(),
backends,
power_preference: PowerPreference::HighPerformance,
features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES | wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
limits,
}
}
Expand Down
14 changes: 12 additions & 2 deletions crates/bevy_render/src/renderer/render_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::render_resource::{
};
use futures_lite::future;
use std::sync::Arc;
use wgpu::util::DeviceExt;
use wgpu::{util::DeviceExt, ShaderModuleDescriptorSpirV};

/// This GPU device is responsible for the creation of most rendering and compute resources.
#[derive(Clone)]
Expand Down Expand Up @@ -38,7 +38,17 @@ impl RenderDevice {
/// Creates a [ShaderModule](wgpu::ShaderModule) from either SPIR-V or WGSL source code.
#[inline]
pub fn create_shader_module(&self, desc: &wgpu::ShaderModuleDescriptor) -> wgpu::ShaderModule {
self.device.create_shader_module(desc)
match &desc.source {
wgpu::ShaderSource::SpirV(source) => unsafe {
println!("shader bypass");
self.device
.create_shader_module_spirv(&ShaderModuleDescriptorSpirV {
label: desc.label,
source: source.clone(),
})
},
_ => self.device.create_shader_module(desc),
}
}

/// Check for resource cleanups and mapping callbacks.
Expand Down

0 comments on commit 1417327

Please sign in to comment.