Issue 239857
Summary [HLSL][DirectX] Lowering fails for struct with resources
Labels backend:DirectX, HLSL
Assignees
Reporter hekota
    Shader using structs with resources as local arguments fails lowering to DXIL.

```
struct A {
  RWBuffer<int> Buf;
};

[[vk::binding(5)]]
A a1 : register(u5);

A a2; // will bind to register u0

int foo(A LocalA, uint Index) {
  return LocalA.Buf[Index];
}

int bar(A LocalA, uint Index) {
  A TmpA = LocalA;
  RWBuffer<int> LocalBuf = TmpA.Buf;
  return LocalBuf[Index];
}

[numthreads(8, 1, 1)]
void main(uint3 ID : SV_GroupThreadID) {
  a2.Buf[ID.x] = foo(a1, ID.x) + bar(a2, ID.x);
}

```
https://godbolt.org/z/YEaffv5En

```
error: Load of "byval-temp.i.sroa.0" is not a global resource handle
error: Load of "TmpA.i.i.sroa.0" is not a global resource handle
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to