Skip to content

[DirectX] Direct stores to array allocas cause validation error: Explicit load/store type does not match pointee type of pointer operand #147114

Open
@Icohedron

Description

@Icohedron

The Problem

This shader fails to validate due to the validation error: Explicit load/store type does not match pointee type of pointer operand

Surprisingly, no DML shaders are failing to validate due to this error.

uint2 Foo(uint2 a[2], uint i) {
  return a[i];
}
RWStructuredBuffer<uint2> output;
[numthreads(1, 1, 1)]
void CSMain(uint3 Tid : SV_DispatchThreadID) {
  uint2 arr[2] = {Tid.xy, Tid.yx};
  output[0] = Foo(arr, Tid.z);
}

https://godbolt.org/z/PdW9d7brE

Using lldb, I have found that the validation error is due to direct scalar stores into array allocas:

  %1 = alloca [4 x i32], align 8
  %4 = call i32 @dx.op.threadId.i32(i32 93, i32 0) #3, !dbg !86
  store i32 %4, ptr %1, align 8, !dbg !105

returning this error https://github.com/microsoft/DirectXShaderCompiler/blob/4fcf67f78f7d6ffd286316112694a3ae000860e2/lib/Bitcode/Reader/BitcodeReader.cpp#L3693

Solution

The dxil-legalize pass DXILLegalizePass.cpp should insert a GEP for store and load instructions on array allocas.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions