Skip to content

[SPIR-V] OpAccessChain result type (OpTypeStruct) does not match the type that results from indexing into the base <id> (OpTypeStruct) #7849

@Narvin-Chana

Description

@Narvin-Chana

Description
When compiling my shader I get an error, the error originates from a struct I pass in as a constant buffer:
The uniform struct:

struct View
{
    row_major matrix view;
    row_major matrix projection;
    row_major matrix viewProjection;
    row_major matrix invView;
    row_major matrix invProjection;
    row_major matrix invViewProjection;
    float3 cameraPosition;
    float time;
    uint2 screenSize;
    uint punctualLightsCount; // Number of punctual lights
    uint padding;
    DirectionalLight dirLight;
};

With:

struct DirectionalLight
{
    float3 color;
    float intensity;
    float3 direction;
};

I've tried with various spv options but have had no real success. The same shader code works when compiling to DXIL.

Steps to Reproduce
Compile out.txt with this command line: dxc -spirv -T cs_6_8 -E DeferredShadingCS out.txt

Actual Behavior

Error: fatal error: generated SPIR-V is invalid: OpAccessChain result type (OpTypeStruct) does not match the type that results from indexing into the base <id> (OpTypeStruct).
  %169 = OpAccessChain %_ptr_Uniform_DirectionalLight_0 %160 %uint_11

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Environment

  • DXC version: dxcompiler.dll: 1.9 - 1.8.0.4973 (8f5595872)
  • Host Operating System:
Edition	Windows 11 Pro
Version	24H2
Installed on	‎2025-‎03-‎18
OS build	26100.6899
Experience	Windows Feature Experience Pack 1000.26100.253.0

out.txt

Metadata

Metadata

Assignees

Labels

bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

Type

No type

Projects

Status

New

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions