[Migrated] Declaring RuntimeArray without `Capability::RuntimeDescriptorArray` set on `SpirvBuilder` emits an unintuitive error message.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/879
Old labels: t: enhancement
Originally creatd by SiebenCorgie on 2022-06-07T13:28:24Z
When trying to compile a shader with a runtime array descriptor without having Capability::RuntimeDescriptorArray enabled on SpirvBuilder emits an unintuitive error.
For instance the following main function:
#[spirv(fragment)]
pub fn main_fs(
...,
#[spirv(push_constant)] push: &PushConst,
#[spirv(descriptor_set = 0, binding = 0)] sampled_images: &RuntimeArray<SampledImage<Image!(2D, type=f32, sampled)>>,
...
) {
//...
let img = unsafe { sampled_images.index(push.texture_indices[0] as usize) };
//...
}
emits this error:
error: OpVariable, <id> '19[%sampled_images]', is attempting to create memory for an illegal type, OpTypeRuntimeArray.
For Vulkan OpTypeRuntimeArray can only appear as the final member of an OpTypeStruct, thus cannot be instantiated via OpVariable
%sampled_images = OpVariable %_ptr_UniformConstant__runtimearr_40 UniformConstant
While the error is correct without the capability, the use of RuntimeArray probably indicates that RuntimeDescriptorArrays is assumed to be present.
A small hint like: "Do you need to enabled the RuntimeDescriptorArray capability?" would be appropriate,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported shader entry point, main_fs, with a RuntimeArray while SpirvBuilder lacks Capability::RuntimeDescriptorArray, and inspect where that diagnostic is produced. Done means the unsupported capability is identified with a clear hint to enable RuntimeDescriptorArray, while the existing invalid-type context remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100