KhronosGroup / KhronosGroup/SPIRV-Tools
Validator should check that push constants, uniforms, ssbos are structs
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
In the Vulkan spec Chapter 14 it states that push constants, uniform blocks and storage blocks should all be OpTypeStruct. Or an array of structs for uniform/storage blocks.
Currently though this isn't checked, e.g. as in this shader:
```
OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint Vertex %main "main" %gl_Position
OpName %main "main"
OpDecorate %gl_Position BuiltIn Position
OpDecorate %uniform_var Binding 0
OpDecorate %uniform_var DescriptorSet 0
%void = OpTypeVoid
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_ptr_Output_v4float = OpTypePointer Output %v4float
%gl_Position = OpVariable %_ptr_Output_v4float Output
; this definition
%uniform_var = OpVariable %_ptr_Uniform_v4float Uniform
%25 = OpTypeFunction %void
%main = OpFunction %void None %25
%83 = OpLabel
%51 = OpLoad %v4float %uniform_var
OpStore %gl_Position %51
OpReturn
OpFunctionEnd
```
Contributor guide
Research direction
No files, tests, or entry points are named. Start by locating the Vulkan validator checks for OpVariable declarations in the SPIR-V Tools source, then compare their behavior with the Chapter 14 type rules. Done means invalid non-struct push constants, uniform blocks, and storage blocks are rejected, while permitted arrays of structs remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100