glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Invalid BufferBlock operand gets emitted when compiling HLSL code to SPIR-V 1.5

Open Ryp opened this issue 4 years ago • 1 comments

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.

Ryp avatar Oct 03 '20 15:10 Ryp

Hit the same error for HLSL StructuredBuffer: 2nd operand of Decorate: operand BufferBlock(3) requires SPIR-V version 1.3 or earlier.

StarsX avatar Aug 30 '22 03:08 StarsX

Also hit the same error, submitted a fix here: https://github.com/KhronosGroup/glslang/pull/3121

FoggyMist avatar Jan 23 '23 13:01 FoggyMist

I'm not seeing the compile error anymore

Ryp avatar Aug 04 '23 13:08 Ryp

This was fixed by #3121

arcady-lunarg avatar Aug 04 '23 16:08 arcady-lunarg