Skip to content

Commit f98cb2f

Browse files
Firestar99LegNeato
authored andcommitted
workaround naga failing by using spirv-passthrough for now
1 parent 7b7dc75 commit f98cb2f

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ members = ["shaders", "shared"]
2929

3030
[patch.crates-io]
3131
#spirv-builder = { path = "../rust-gpu/crates/spirv-builder" }
32-
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6e2c84d4fe64e32df4c060c5a7f3e35a32e45421" }
33-
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6e2c84d4fe64e32df4c060c5a7f3e35a32e45421" }
32+
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "3417d2487f0b0066764ca74bbec2556e12c7d4fb" }
33+
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "3417d2487f0b0066764ca74bbec2556e12c7d4fb" }
3434

3535

3636
# Compile build-dependencies in release mode with

src/main.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use futures::executor::block_on;
22
use ouroboros::self_referencing;
3-
use std::borrow::Cow;
43
use std::error::Error;
54
use std::time::Instant;
65
use wgpu;
6+
use wgpu::{include_spirv, include_spirv_raw};
77
use winit::application::ApplicationHandler;
88
use winit::dpi::LogicalSize;
99
use winit::event::{ElementState, MouseButton, WindowEvent};
@@ -62,6 +62,8 @@ impl Default for ShaderToyApp {
6262
}
6363
}
6464

65+
pub const USE_SPIRV_PASSTHROUGH: bool = true;
66+
6567
impl ShaderToyApp {
6668
async fn init(&mut self, event_loop: &dyn ActiveEventLoop) -> Result<(), Box<dyn Error>> {
6769
let window_attributes = WindowAttributes::default()
@@ -91,7 +93,10 @@ impl ShaderToyApp {
9193
})
9294
.await
9395
.ok_or("No adapter found")?;
94-
let required_features = wgpu::Features::PUSH_CONSTANTS;
96+
let mut required_features = wgpu::Features::PUSH_CONSTANTS;
97+
if USE_SPIRV_PASSTHROUGH {
98+
required_features |= wgpu::Features::SPIRV_SHADER_PASSTHROUGH;
99+
}
95100
let required_limits = wgpu::Limits {
96101
max_push_constant_size: 256,
97102
..Default::default()
@@ -107,12 +112,14 @@ impl ShaderToyApp {
107112
None,
108113
)
109114
.await?;
110-
let shader_bytes = include_bytes!(env!("shadertoys_shaders.spv"));
111-
let shader_spirv: &[u32] = bytemuck::cast_slice(shader_bytes);
112-
let shader_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
113-
label: Some("Shader Module"),
114-
source: wgpu::ShaderSource::SpirV(Cow::Borrowed(shader_spirv)),
115-
});
115+
let shader_module = if USE_SPIRV_PASSTHROUGH {
116+
unsafe {
117+
device
118+
.create_shader_module_spirv(&include_spirv_raw!(env!("shadertoys_shaders.spv")))
119+
}
120+
} else {
121+
device.create_shader_module(include_spirv!(env!("shadertoys_shaders.spv")))
122+
};
116123
let swapchain_format = surface.get_capabilities(&adapter).formats[0];
117124
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
118125
label: None,

0 commit comments

Comments
 (0)