shader-slang / slang

Making it easier to work with shaders
MIT License
1.81k stars 161 forks source link

Duplicate SPIR-V decorated blocks #4290

Closed spencer-lunarg closed 1 month ago

spencer-lunarg commented 1 month ago

Using v2024.1.21 slangc

Taking the simple hlsl

struct Particle {
    float4 _m0;
};

[[vk::binding(0)]]
RWStructuredBuffer<Particle> particleOut;

float4 main() : SV_TARGET {
    return particleOut[0]._m0;
}

running slangc in.hlsl -o out.spv -emit-spirv-directly -target spirv -enable-effect-annotations -entry main -stage fragment

will produce

OpDecorate %RWStructuredBuffer Block
OpDecorate %RWStructuredBuffer Block

which is invalid and with the latest 1.3.283.0 Vulkan SDK, the spirv-val out.spv --target-env vulkan1.3 --skip-block-layout will produce the error

error: line 34: ID '14' decorated with Block multiple times is not allowed.
  %RWStructuredBuffer = OpTypeStruct %_runtimearr_Particle_std430