Skip to content

Invalid type description generated in DXIL IR for StructuredBuffer #114131

@coopp

Description

@coopp

An invalid form of a type was being generated in the DXIL IR for the StructuredBuffer type. This form was causing 'opt' to fail with a syntax error while parsing the IR.

godbolt: https://godbolt.org/z/zf7TTWa5q

Shader compiled with -T cs_6_6

struct mystruct
{
    float4 Color;
};

StructuredBuffer<mystruct> my_buffer : register(t2, space4);

export float4 test()
{
    return my_buffer[0].Color;
}

[numthreads(1,1,1)]
void main() {}

See %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct = type { <4 x float> }, 0, 0), %struct.mystruct }

Type section for IR

%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct = type { <4 x float> }, 0, 0), %struct.mystruct }
%struct.mystruct = type { <4 x float> }
%dx.types.Handle = type { ptr }
%dx.types.ResBind = type { i32, i32, i32, i8 }
%dx.types.ResourceProperties = type { i32, i32 }

The part "%struct.mystruct = type" is causing the parsing error.

I believe the expected form is:

%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", { <4 x float> }, 0, 0), %struct.mystruct }

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions