Skip to content

Commit 9c35c5d

Browse files
committed
Fix hardcoded compute
1 parent f4408a8 commit 9c35c5d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@group(0) @binding(0)
2-
var<storage, read_write> data: array<u32>;
2+
var<storage, read_write> output: array<u32>;
33

4-
@compute @workgroup_size(64)
5-
fn main_cs(@builtin(global_invocation_id) id: vec3<u32>) {
6-
data[id.x] = id.x;
4+
@compute @workgroup_size(1)
5+
fn main_cs() {
6+
output[0] = 42u;
77
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#![no_std]
2-
use spirv_std::glam;
32
use spirv_std::spirv;
43

54
#[spirv(compute(threads(64)))]
65
pub fn main_cs(
7-
#[spirv(global_invocation_id)] id: glam::UVec3,
86
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] data: &mut [u32],
97
) {
10-
data[id.x as usize] = id.x;
8+
data[0] = 42;
119
}

tests/difftests/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,20 @@ mod runners {
548548
compilation_options: Default::default(),
549549
});
550550
let buffer_size = config.compute_output.buffer_size();
551+
let initial_data = vec![0u8; buffer_size as usize];
551552
let buffer = device.create_buffer(&wgpu::BufferDescriptor {
552553
label: Some("Result Buffer"),
553554
size: buffer_size,
554-
usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_SRC,
555-
mapped_at_creation: false,
555+
usage: wgpu::BufferUsages::STORAGE
556+
| wgpu::BufferUsages::COPY_SRC
557+
| wgpu::BufferUsages::COPY_DST,
558+
mapped_at_creation: true,
556559
});
560+
{
561+
let mut mapping = buffer.slice(..).get_mapped_range_mut();
562+
mapping.copy_from_slice(&initial_data);
563+
}
564+
buffer.unmap();
557565
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
558566
layout: &pipeline.get_bind_group_layout(0),
559567
entries: &[wgpu::BindGroupEntry {

0 commit comments

Comments
 (0)