Skip to content

Commit 595f8e7

Browse files
authored
Remove SPIRV_SHADER_PASSTHROUGH for wgpu example on Mac (#854)
1 parent 5a27455 commit 595f8e7

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

examples/runners/wgpu/src/compute.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn start(options: &Options) {
2222

2323
pub async fn start_internal(
2424
_options: &Options,
25-
shader_binary: wgpu::ShaderModuleDescriptorSpirV<'static>,
25+
shader_binary: wgpu::ShaderModuleDescriptor<'static>,
2626
) {
2727
let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
2828
let adapter = instance
@@ -38,8 +38,7 @@ pub async fn start_internal(
3838
.request_device(
3939
&wgpu::DeviceDescriptor {
4040
label: None,
41-
features: wgpu::Features::TIMESTAMP_QUERY
42-
| wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
41+
features: wgpu::Features::TIMESTAMP_QUERY,
4342
limits: wgpu::Limits::default(),
4443
},
4544
None,
@@ -52,7 +51,7 @@ pub async fn start_internal(
5251
let timestamp_period = queue.get_timestamp_period();
5352

5453
// Load the shaders from disk
55-
let module = unsafe { device.create_shader_module_spirv(&shader_binary) };
54+
let module = device.create_shader_module(&shader_binary);
5655

5756
let top = 2u32.pow(20);
5857
let src_range = 1..top;

examples/runners/wgpu/src/graphics.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ fn mouse_button_index(button: MouseButton) -> usize {
3333
}
3434

3535
async fn run(
36-
event_loop: EventLoop<wgpu::ShaderModuleDescriptorSpirV<'static>>,
36+
event_loop: EventLoop<wgpu::ShaderModuleDescriptor<'static>>,
3737
window: Window,
38-
shader_binary: wgpu::ShaderModuleDescriptorSpirV<'static>,
38+
shader_binary: wgpu::ShaderModuleDescriptor<'static>,
3939
) {
4040
let instance = wgpu::Instance::new(wgpu::Backends::VULKAN | wgpu::Backends::METAL);
4141

@@ -57,7 +57,7 @@ async fn run(
5757
.await
5858
.expect("Failed to find an appropriate adapter");
5959

60-
let features = wgpu::Features::PUSH_CONSTANTS | wgpu::Features::SPIRV_SHADER_PASSTHROUGH;
60+
let features = wgpu::Features::PUSH_CONSTANTS;
6161
let limits = wgpu::Limits {
6262
max_push_constant_size: 256,
6363
..Default::default()
@@ -82,7 +82,7 @@ async fn run(
8282
label: None,
8383
bind_group_layouts: &[],
8484
push_constant_ranges: &[wgpu::PushConstantRange {
85-
stages: wgpu::ShaderStages::all(),
85+
stages: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
8686
range: 0..std::mem::size_of::<ShaderConstants>() as u32,
8787
}],
8888
});
@@ -214,7 +214,7 @@ async fn run(
214214

215215
rpass.set_pipeline(render_pipeline);
216216
rpass.set_push_constants(
217-
wgpu::ShaderStages::all(),
217+
wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT,
218218
0,
219219
bytemuck::bytes_of(&push_constants),
220220
);
@@ -284,9 +284,9 @@ fn create_pipeline(
284284
device: &wgpu::Device,
285285
pipeline_layout: &wgpu::PipelineLayout,
286286
surface_format: wgpu::TextureFormat,
287-
shader_binary: wgpu::ShaderModuleDescriptorSpirV<'_>,
287+
shader_binary: wgpu::ShaderModuleDescriptor<'_>,
288288
) -> wgpu::RenderPipeline {
289-
let module = unsafe { device.create_shader_module_spirv(&shader_binary) };
289+
let module = device.create_shader_module(&shader_binary);
290290
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
291291
label: None,
292292
layout: Some(pipeline_layout),

examples/runners/wgpu/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ pub enum RustGPUShader {
8686

8787
fn maybe_watch(
8888
shader: RustGPUShader,
89-
on_watch: Option<Box<dyn FnMut(wgpu::ShaderModuleDescriptorSpirV<'static>) + Send + 'static>>,
90-
) -> wgpu::ShaderModuleDescriptorSpirV<'static> {
89+
on_watch: Option<Box<dyn FnMut(wgpu::ShaderModuleDescriptor<'static>) + Send + 'static>>,
90+
) -> wgpu::ShaderModuleDescriptor<'static> {
9191
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
9292
{
9393
use spirv_builder::{CompileResult, MetadataPrintout, SpirvBuilder};
@@ -123,24 +123,24 @@ fn maybe_watch(
123123
};
124124
fn handle_compile_result(
125125
compile_result: CompileResult,
126-
) -> wgpu::ShaderModuleDescriptorSpirV<'static> {
126+
) -> wgpu::ShaderModuleDescriptor<'static> {
127127
let module_path = compile_result.module.unwrap_single();
128128
let data = std::fs::read(module_path).unwrap();
129129
let spirv = Cow::Owned(wgpu::util::make_spirv_raw(&data).into_owned());
130-
wgpu::ShaderModuleDescriptorSpirV {
130+
wgpu::ShaderModuleDescriptor {
131131
label: None,
132-
source: spirv,
132+
source: wgpu::ShaderSource::SpirV(spirv),
133133
}
134134
}
135135
handle_compile_result(initial_result)
136136
}
137137
#[cfg(any(target_os = "android", target_arch = "wasm32"))]
138138
{
139139
match shader {
140-
RustGPUShader::Simplest => wgpu::include_spirv_raw!(env!("simplest_shader.spv")),
141-
RustGPUShader::Sky => wgpu::include_spirv_raw!(env!("sky_shader.spv")),
142-
RustGPUShader::Compute => wgpu::include_spirv_raw!(env!("compute_shader.spv")),
143-
RustGPUShader::Mouse => wgpu::include_spirv_raw!(env!("mouse_shader.spv")),
140+
RustGPUShader::Simplest => wgpu::include_spirv!(env!("simplest_shader.spv")),
141+
RustGPUShader::Sky => wgpu::include_spirv!(env!("sky_shader.spv")),
142+
RustGPUShader::Compute => wgpu::include_spirv!(env!("compute_shader.spv")),
143+
RustGPUShader::Mouse => wgpu::include_spirv!(env!("mouse_shader.spv")),
144144
}
145145
}
146146
}

0 commit comments

Comments
 (0)