This repository demonstrates a bug in wgpu/Naga's DX12/HLSL backend on windows.
When running a simple compute shader that:
- Has 64 threads in a workgroup
- Each thread writes its index+1 to shared memory
- Synchronizes with
workgroupBarrier()
- Thread 0 sums all values
The expected result is 2080 (sum of 1 through 64), but on Windows with DX12 backend, the result is 3.
- ✅ Linux (Vulkan): 2080 (correct)
- ✅ macOS (Metal): 2080 (correct)
- ❌ Windows (DX12): 3 (incorrect)
The value 3 (which is 1 + 2) suggests that only threads 0 and 1 are properly synchronized or that the workgroup size is incorrectly set to 2 instead of 64.
The test requires cargo-gpu
to compile the Rust shader to SPIR-V. The script will
install it automatically if not present.
./run_test.sh
This script will:
- Install cargo-gpu if needed
- Compile the rust-gpu shader to SPIR-V
- Run the wgpu test program
- Report whether the test passes or fails
- Output logs
./run_test.sh --clean
Check the GitHub Actions results to see the test failing on Windows but passing on Linux and macOS. The HLSL should be uploaded as an artifact and it is also echoed in the logs.
When the same shader runs through Vulkan on Windows (e.g., using SwiftShader), it produces the correct result, confirming the issue is in the DX12/HLSL path.