mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
[rs] Merge #909
909: Update naga to gfx-25 r=kvark a=kvark Gets us arrayLength() in MSL Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
commit
2a7e07d94f
@ -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]]
|
||||
|
@ -1,6 +1,3 @@
|
||||
// This should match `NUM_PARTICLES` on the Rust side.
|
||||
let NUM_PARTICLES: u32 = 1500u;
|
||||
|
||||
struct Particle {
|
||||
pos : vec2<f32>;
|
||||
vel : vec2<f32>;
|
||||
@ -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<u32>) {
|
||||
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<u32>) {
|
||||
var vel : vec2<f32>;
|
||||
var i : u32 = 0u;
|
||||
loop {
|
||||
if (i >= NUM_PARTICLES) {
|
||||
if (i >= total) {
|
||||
break;
|
||||
}
|
||||
if (i == index) {
|
||||
|
@ -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,
|
||||
|
@ -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[..]))
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user