Skip to content

[spirv] spirv-tools crash during CopyPropagateArrays #2423

@moarmand

Description

@moarmand

Hello,

The following code cause a crash in CopyPropagateArrays::CanUpdateUses:

struct MyConstantBuffer
{
    float4 myParam1[8];
};

cbuffer myConstantBuffer : register(b0) { MyConstantBuffer myConstantBuffer; }

struct MyConstantBufferWrapper
{
    MyConstantBuffer constants;

    float4 GetParam1(uint index) { return constants.myParam1[index]; }
};

MyConstantBufferWrapper CreateWrapper()
{
    MyConstantBufferWrapper wrapper;
    wrapper.constants = myConstantBuffer;
    return wrapper;
};

struct VS_OUTPUT
{
    float4  m_ScreenPos  : VS_OUT_POSITION;
};

struct MyStruct
{
    uint myIndex;
};

static MyConstantBufferWrapper myWrapper = CreateWrapper();

float4 PS_ShadePixel(VS_OUTPUT In) : SV_Target
{
    MyStruct myStruct = (MyStruct)0;

    float4 myParam = myWrapper.GetParam1(myStruct.myIndex);
    //float4 myParam = myConstantBuffer.myParam1[myStruct.myIndex];

    return myParam;
}

Note that accessing directly the field does not cause the issue ( see the commented line ).
Also using an uint directly instead of the struct does not cause the issue.

Thanks

Metadata

Metadata

Assignees

Labels

spirvWork related to SPIR-V

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions