glslang
glslang copied to clipboard
Invalid BufferBlock operand gets emitted when compiling HLSL code to SPIR-V 1.5
I have this shader (shader playground mirror)
#include "lib/base.hlsl"
#include "lib/indirect_command.hlsl"
#include "share/compaction.hlsl"
VK_BINDING(0, 0) ByteAddressBuffer DrawCount;
VK_BINDING(1, 0) RWByteAddressBuffer IndirectDispatchOut;
VK_BINDING(2, 0) RWByteAddressBuffer DrawCountOut;
[numthreads(1, 1, 1)]
void main()
{
const uint command_count = DrawCount.Load(0);
IndirectDispatchCommand dispatchCommand;
dispatchCommand.x = div_round_up(command_count, CompactionGroupSize);
dispatchCommand.y = 1;
dispatchCommand.z = 1;
// Write indirect dispatch command
IndirectDispatchOut.Store(0, dispatchCommand.x);
IndirectDispatchOut.Store(4, dispatchCommand.y);
IndirectDispatchOut.Store(8, dispatchCommand.z);
// Reset draw count for the next pass
DrawCountOut.Store(0, 0);
}
That compiles with this command line:
glslangValidator --target-env vulkan1.2 -g -e main -V -D compaction_prepare_indirect_dispatch.comp.hlsl -o compaction_prepare_indirect_dispatch.comp.spv
I get this error when I try to legalize the HLSL:
error: line 50: 2nd operand of Decorate: operand BufferBlock(3) requires SPIR-V version 1.3 or earlier
OpDecorate %DrawCount BufferBlock
I'm only seeing this error now, as I'm trying to compile all my shaders for SPIR-V 1.5. I was using SPIR'V 1.3 previously.
Hit the same error for HLSL StructuredBuffer: 2nd operand of Decorate: operand BufferBlock(3) requires SPIR-V version 1.3 or earlier.
Also hit the same error, submitted a fix here: https://github.com/KhronosGroup/glslang/pull/3121
I'm not seeing the compile error anymore
This was fixed by #3121