vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.52k stars 435 forks source link

vulkano-shaders breaks when trying to use SPIR-V shader generated by rust-gpu #1493

Closed p0lunin closed 2 years ago

p0lunin commented 3 years ago

Repository with bug: https://github.com/p0lunin/vulkano-rust-gpu-bug

Error from proc-macro:

error: proc macro panicked
 --> src\main.rs:3:9
  |
3 | /         vulkano_shaders::shader! {
4 | |             ty: "compute",
5 | |             bytes: "target/spirv-builder/spirv-unknown-unknown/release/shader.spv"
6 | |         }
  | |_________^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: ParseError(UnknownConstant("Capability", 5345))

I think rust-gpu sets the constant Capability to 5345 which denotes the Vulkan memory model.

Arc-blroth commented 3 years ago

One quick fix around this is just to patch vulkano-shaders/src/enums.rs to include MemoryModelVulkan and VulkanMemoryModel. Another workaround is to tell SPIR-V builder to use MemoryModel::GLSL450 (though this might make the shaders slower). For my own usecase, I just patched vulkano to ignore unknown capabilities and added MemoryModelVulkan: see this commit and this commit.

However, since #1500 would update vulkano's older SPIR-V headers anyway, these workarounds hopefully might not be needed soon :)

Rua commented 2 years ago

I'm going to assume this is no longer an issue, now that the SPIR-V parser is auto-generated.