Skip to content

[SPIRV] OpAccessChain storage class mismatch when accessing resource member in struct array #8384

@bob80905

Description

@bob80905

When compiling HLSL that creates an array of structs with resource members and accesses them via constant indexing, DXC's SPIRV backend generates invalid SPIR-V:

fatal error: generated SPIR-V is invalid: The result pointer storage class and base pointer storage class in OpAccessChain do not match. %13 = OpAccessChain %_ptr_Uniform_uint %gBuf %uint_0 %uint_0

Repro:

RWByteAddressBuffer gBuf : register(u0);

struct BufStruct { RWByteAddressBuffer buf; };

[numthreads(1,1,1)] 
void main() {  
BufStruct s[2];  
s[0].buf = gBuf;
s[0].buf.Store(0, 42); 
}

Command:

dxc.exe -spirv -fspv-target-env=vulkan1.3 -T cs_6_0 -Fo out.spv repro.hlsl

DXC DXIL compiles and runs this correctly. DXC version: main (built from source).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions