Skip to content

Commit

Permalink
fix metal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed May 27, 2024
1 parent 16262d3 commit e0bd41a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/tests/dispatch_workgroups_indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ async fn run_test(
) -> [u32; 3] {
const SHADER_SRC: &str = "
@group(0) @binding(0)
var<storage, read_write> out: vec3<u32>;
var<storage, read_write> out: array<u32, 3>;
@compute @workgroup_size(1)
fn main(@builtin(num_workgroups) num_workgroups: vec3<u32>, @builtin(workgroup_id) workgroup_id: vec3<u32>) {
if (all(workgroup_id == vec3<u32>())) {
out = num_workgroups;
out[0] = num_workgroups.x;
out[1] = num_workgroups.y;
out[2] = num_workgroups.z;
}
}
";
Expand Down
7 changes: 5 additions & 2 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,13 +1799,16 @@ impl Global {
@group(0) @binding(0)
var<storage, read> src: array<u32>;
@group(0) @binding(1)
var<storage, read_write> dst: vec3<u32>;
var<storage, read_write> dst: array<u32, 3>;
@compute @workgroup_size(1)
fn main() {{
let len = arrayLength(&src);
let src = vec3(src[len - 3], src[len - 2], src[len - 1]);
dst = select(src, vec3<u32>(), src > vec3({max_compute_workgroups_per_dimension}u));
let res = select(src, vec3<u32>(), src > vec3({max_compute_workgroups_per_dimension}u));
dst[0] = res.x;
dst[1] = res.y;
dst[2] = res.z;
}}
");

Expand Down

0 comments on commit e0bd41a

Please sign in to comment.