From cb58bc214d2cac1c482098fc30496fb17806469b Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 21 Feb 2021 11:49:48 -0500 Subject: [PATCH] [rs] Update naga to gfx-12 --- wgpu/Cargo.toml | 16 +++++++++++----- wgpu/src/backend/web.rs | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 188696a1ef..d5cae0f802 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -26,20 +26,20 @@ webgl = ["wgc"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f" +rev = "2d0142a2e784ee46c7922ea759bb05128e8ba957" features = ["raw-window-handle", "cross"] [target.'cfg(target_arch = "wasm32")'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f" +rev = "2d0142a2e784ee46c7922ea759bb05128e8ba957" features = ["raw-window-handle", "cross"] optional = true [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "53bab9d68f91d6802d6913ed2dde9cad8537ed2f" +rev = "2d0142a2e784ee46c7922ea759bb05128e8ba957" [dependencies] arrayvec = "0.5" @@ -54,7 +54,6 @@ bytemuck = { version = "1.4", features = ["derive"] } cgmath = "0.18" ddsfile = "0.4" log = "0.4" -naga = { git = "https://github.com/gfx-rs/naga", tag = "gfx-11", features = ["wgsl-in"] } noise = "0.7" obj = "0.10" png = "0.16" @@ -66,9 +65,16 @@ async-executor = "1.0" pollster = "0.2" wgpu-subscriber = "0.1" +# used to test all the example shaders +[dev-dependencies.naga] +git = "https://github.com/gfx-rs/naga" +tag = "gfx-12" +features = ["wgsl-in"] + +# used to generate SPIR-V for the Web target [target.'cfg(target_arch = "wasm32")'.dependencies.naga] git = "https://github.com/gfx-rs/naga" -tag = "gfx-11" +tag = "gfx-12" features = ["wgsl-in", "spv-out"] [[example]] diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 92b12c167f..dd205d0569 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1046,7 +1046,7 @@ impl crate::Context for Context { web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&**spv)) } crate::ShaderSource::Wgsl(ref code) => { - use naga::{back::spv, front::wgsl}; + use naga::{back::spv, front::wgsl, proc::Validator}; let module = wgsl::parse_str(code).unwrap(); let mut capabilities = HashSet::default(); capabilities.insert(spv::Capability::Shader); @@ -1055,7 +1055,8 @@ impl crate::Context for Context { flags: spv::WriterFlags::empty(), capabilities, }; - let words = spv::write_vec(&module, &options).unwrap(); + let analysis = Validator::new().validate(&module).unwrap(); + let words = spv::write_vec(&module, &analysis, &options).unwrap(); web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&words[..])) } };