gfx-rs / wgpu

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

Support non 32 bit integers (8, 16, 64) #4424

Open averyanalex opened 1 year ago

averyanalex commented 1 year ago

I tried to load SPIRV compute shader compiled by rust-gpu with u64 integers and got validation error:

thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_shader_module
      note: label = `REDACTED/target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/shader.spv`

Shader validation error:
  ┌─ REDACTED/target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/shader.spv:1:1
  │
1 │
  │   naga::Constant [6]

    Constant [6] '' is invalid
    The type doesn't match the constant

', REDACTED/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs:2403:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Adding wgpu::Features::SHADER_FLOAT64 to features didn't help.

teoxoy commented 1 year ago

We don't currently support non 32 bit integers. SHADER_FLOAT64 enables only 64 bit floats.

JMS55 commented 9 months ago

Would love both u64 support in shaders, as well as R64Uint textures.

tombh commented 3 days ago

I think u8 support is needed to allow rust-gpu's enums to work? I can compile Rust's dataless enums into SPIR-V without issue, I just need to add the Int8 capability to the rust-gpu compiler. But then when I try to load the shader into wgpu, I get: Shader '' parsing error: InvalidTypeWidth(1). Does that seem right?

Is there an issue to track for this?