2
0
Эх сурвалжийг харах

Allow nested struct in UAV. (#472)

Xiang Li 8 жил өмнө
parent
commit
516a70ad4c

+ 0 - 2
lib/HLSL/HLOperationLower.cpp

@@ -5884,8 +5884,6 @@ void TranslateStructBufSubscriptUser(Instruction *user, Value *handle,
     // should only used by GEP
     GetElementPtrInst *GEP = cast<GetElementPtrInst>(user);
     Type *Ty = GEP->getType()->getPointerElementType();
-    DXASSERT_LOCALVAR(Ty, !Ty->isStructTy() || HLMatrixLower::IsMatrixType(Ty),
-             "should be flattened");
 
     Value *offset = GEPIdxToOffset(GEP, Builder, OP, DL);
     DXASSERT(offset->getType() == Type::getInt32Ty(Ty->getContext()),

+ 27 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/nest_struct_uav.hlsl

@@ -0,0 +1,27 @@
+// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+
+// Make sure nest struct type works for UAV.
+// CHECK: @dx.op.bufferLoad.i32
+// CHECK: dx.op.bufferStore.i32
+
+struct Foo
+{
+  uint a;
+};
+
+struct Bar {
+  Foo f;
+  float b;
+};
+
+StructuredBuffer<Bar> buf1;
+RWStructuredBuffer<Bar> buf2;
+
+
+float4 main(float idx1 : Idx1, float idx2 : Idx2, int2 c : C) : SV_Target
+{
+  Foo f = buf1.Load(idx1).f;
+  buf2[idx1*3].f = f;
+
+  return 1;
+}