Skip to content

[SPIR-V] Invalid spirv: ResourceDescriptorHeap, ConstantBuffer, vk::RawBufferLoad #8373

Open

Description

Description
Invalid spirv generated with this simple shader:

Steps to Reproduce

struct Constants
{
	uint info;
};

[[vk::push_constant]] Constants g_constants;

struct Info
{
	uint64_t address;
};

void pixel_main(out uint target0 : SV_Target0)
{
    ConstantBuffer< Info > info = ResourceDescriptorHeap[g_constants.info];
    target0 = vk::RawBufferLoad< uint >(info.address);
}

Compiler explorer

Actual Behavior

fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-None-10684] Invalid explicit layout decorations on type for operand '18[%_ptr_Function_type_ConstantBuffer_Info]', the Function storage class has a explicit layout from the Block decoration.
  %24 = OpVariable %_ptr_Function_type_ConstantBuffer_Info Function

Environment
DXC trunk on compiler explorer

Activity

  1. added
    bug
    spirv
    needs-triage
    on Apr 14, 2026
  2. vntec commented on Apr 22, 2026

    @vntec

    I encountered this today as well.
    It seems like the mere presence of a vk::BufferPointer is enough to trigger the wrong constant buffer layout. Weird...

    https://godbolt.org/z/5GGb9fejc

    [[vk::push_constant]]
    struct Pc {
    	uint heapIndex;
        vk::BufferPointer<float4> unusedPtr; // Causes error, even if not used. Try commenting this line.
    } pc;
    
    
    struct CbData {
    	float4 foo;
    };
    
    float4 main() : SV_Target {
        ConstantBuffer<CbData> cb = ResourceDescriptorHeap[pc.heapIndex];
        // The following works:
        // CbData cb = (ConstantBuffer<CbData>) ResourceDescriptorHeap[pc.heapIndex]; 
        return cb.foo;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugneeds-triagespirv

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions