gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.03k stars 873 forks source link

Support for OpSpecConstantComposite [SPIR-V] #4462

Closed genbattle closed 4 months ago

genbattle commented 2 years ago

Is your feature request related to a problem? Please describe.

I've been trying to compile and run some OpenCL C kernels in wgpu as SPIR-V modules and have run into the following validation error within wgpu:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnsupportedInstruction(Type, SpecConstantComposite)', /Users/nicksarten/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:1022:45

I've had a quick search around to see if anyone else has run into a similar issue, but the closest I found was this issue in naga which seems to suggest that OpConstantComposite is supported by naga at least, but there's no mention of OpSpecConstantComposite.

clspv seems to be using this instruction to define the workgroup size variable, which is a v3uint.

Describe the solution you'd like I'd like to be able to run this kernel with validation turned on and not get an UnsupportedInstruction error for SpecConstantComposite.

Describe alternatives you've considered I'm going to attempt to run the kernel using SPIRV-passthrough.

I've attempted tweaking my clspv invocation to change how the work group size is specified. Using --vec3-to-vec4 to force lowering of vec3 to vec4 didn't seem to have any effect on the SPIR-V at all.

Additional context I've attached the SPIRV disassembly for the relevant kernel. resize.txt

kvark commented 2 years ago

This is basically gfx-rs/wgpu#4324 ?

genbattle commented 2 years ago

Yep that seems to be the same family of Ops.

genbattle commented 2 years ago

I just realised I can't use SPIR-V passthrough because I'm on MacOS 😅