From 2a0ea1d94b92836c41494a0f67a728d15903c11f Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 14 May 2021 00:15:11 -0400 Subject: [PATCH] [rs] Update naga to gfx-25 --- wgpu/Cargo.toml | 10 +++++----- wgpu/examples/boids/compute.wgsl | 10 ++++------ wgpu/src/backend/direct.rs | 4 ++-- wgpu/src/backend/web.rs | 10 ++++++---- wgpu/tests/example-wgsl.rs | 9 ++++++--- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 826b35a77..c95da15e8 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -26,20 +26,20 @@ cross = ["wgc/cross"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "e5ddb94be0221b0f53a8f43adfb15458daebfd7c" +rev = "53eab747a32414232be45d47cae8a43a369395d0" features = ["raw-window-handle"] [target.'cfg(target_arch = "wasm32")'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "e5ddb94be0221b0f53a8f43adfb15458daebfd7c" +rev = "53eab747a32414232be45d47cae8a43a369395d0" features = ["raw-window-handle"] optional = true [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "e5ddb94be0221b0f53a8f43adfb15458daebfd7c" +rev = "53eab747a32414232be45d47cae8a43a369395d0" [dependencies] arrayvec = "0.5" @@ -68,13 +68,13 @@ env_logger = "0.8" # used to test all the example shaders [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -tag = "gfx-23" +tag = "gfx-25" 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-23" +tag = "gfx-25" features = ["wgsl-in", "spv-out"] [[example]] diff --git a/wgpu/examples/boids/compute.wgsl b/wgpu/examples/boids/compute.wgsl index f5d1b67c0..bddb260a2 100644 --- a/wgpu/examples/boids/compute.wgsl +++ b/wgpu/examples/boids/compute.wgsl @@ -1,6 +1,3 @@ -// This should match `NUM_PARTICLES` on the Rust side. -let NUM_PARTICLES: u32 = 1500u; - struct Particle { pos : vec2; vel : vec2; @@ -29,8 +26,9 @@ struct Particles { // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp [[stage(compute), workgroup_size(64)]] fn main([[builtin(global_invocation_id)]] global_invocation_id: vec3) { - let index : u32 = global_invocation_id.x; - if (index >= NUM_PARTICLES) { + let total = arrayLength(&particlesSrc.particles); + let index = global_invocation_id.x; + if (index >= total) { return; } @@ -47,7 +45,7 @@ fn main([[builtin(global_invocation_id)]] global_invocation_id: vec3) { var vel : vec2; var i : u32 = 0u; loop { - if (i >= NUM_PARTICLES) { + if (i >= total) { break; } if (i == index) { diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 943cf6ec7..329f13762 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -487,7 +487,7 @@ mod pass_impl { indirect_buffer: &super::Buffer, indirect_offset: wgt::BufferAddress, ) { - wgpu_render_pass_bundle_indexed_indirect(self, indirect_buffer.id, indirect_offset) + wgpu_render_bundle_draw_indexed_indirect(self, indirect_buffer.id, indirect_offset) } fn multi_draw_indirect( &mut self, @@ -1352,7 +1352,7 @@ impl crate::Context for Context { match wgc::gfx_select!(buffer.id => global.buffer_get_mapped_range( buffer.id, sub_range.start, - wgt::BufferSize::new(size) + Some(size) )) { Ok((ptr, size)) => BufferMappedRange { ptr, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 27ec21b47..fbb3193af 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1,5 +1,4 @@ use std::{ - collections::HashSet, fmt, future::Future, ops::Range, @@ -1149,9 +1148,12 @@ impl crate::Context for Context { flags: spv::WriterFlags::empty(), capabilities: None, }; - let analysis = Validator::new(naga::valid::ValidationFlags::all()) - .validate(&module) - .unwrap(); + let analysis = Validator::new( + naga::valid::ValidationFlags::empty(), + naga::valid::Capabilities::all(), + ) + .validate(&module) + .unwrap(); let words = spv::write_vec(&module, &analysis, &options).unwrap(); web_sys::GpuShaderModuleDescriptor::new(&js_sys::Uint32Array::from(&words[..])) } diff --git a/wgpu/tests/example-wgsl.rs b/wgpu/tests/example-wgsl.rs index a9da3bd2d..481eeb919 100644 --- a/wgpu/tests/example-wgsl.rs +++ b/wgpu/tests/example-wgsl.rs @@ -41,9 +41,12 @@ fn parse_example_wgsl() { let module = wgsl::parse_str(&shader).unwrap(); //TODO: re-use the validator - Validator::new(naga::valid::ValidationFlags::all()) - .validate(&module) - .unwrap(); + Validator::new( + naga::valid::ValidationFlags::all(), + naga::valid::Capabilities::all(), + ) + .validate(&module) + .unwrap(); } } }