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

Fix Typed UAV Load flag collection (#418) (#422)

Young Kim 8 жил өмнө
parent
commit
eac5665cfe

+ 4 - 2
lib/HLSL/DxilModule.cpp

@@ -440,8 +440,10 @@ void DxilModule::CollectShaderFlags(ShaderFlags &Flags) {
                   ConstantInt *rangeID = GetArbitraryConstantRangeID(handleCall);
                   if (rangeID) {
                       DxilResource resource = GetUAV(rangeID->getLimitedValue());
-                      if (!IsResourceSingleComponent(resource.GetRetType())) {
-                          hasMulticomponentUAVLoads = true;
+                      if ((resource.IsTypedBuffer() ||
+                           resource.IsAnyTexture()) &&
+                          !IsResourceSingleComponent(resource.GetRetType())) {
+                        hasMulticomponentUAVLoads = true;
                       }
                   }
                 }

+ 15 - 0
tools/clang/test/CodeGenHLSL/multiUAVLoad7.hlsl

@@ -0,0 +1,15 @@
+// RUN: %dxc -E main -T cs_6_0 %s | FileCheck %s
+
+// CHECK-NOT: Typed UAV Load Additional Formats
+
+struct SUnaryFPOp {
+    float input;
+    float output;
+};
+RWStructuredBuffer<SUnaryFPOp> g_buf : register(u0);
+[numthreads(8,8,1)]
+void main(uint GI : SV_GroupIndex) {
+    SUnaryFPOp l = g_buf[GI];
+    l.output = sin(l.input);
+    g_buf[GI] = l;
+}

+ 6 - 0
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -550,6 +550,7 @@ public:
   TEST_METHOD(CodeGenMultiUAVLoad4)
   TEST_METHOD(CodeGenMultiUAVLoad5)
   TEST_METHOD(CodeGenMultiUAVLoad6)
+  TEST_METHOD(CodeGenMultiUAVLoad7)
   TEST_METHOD(CodeGenMultiStream)
   TEST_METHOD(CodeGenMultiStream2)
   TEST_METHOD(CodeGenNeg1)
@@ -2953,6 +2954,11 @@ TEST_F(CompilerTest, CodeGenMultiUAVLoad6) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad6.hlsl");
 }
 
+TEST_F(CompilerTest, CodeGenMultiUAVLoad7) {
+    if (m_ver.SkipDxil_1_1_Test()) return;
+    CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad7.hlsl");
+}
+
 TEST_F(CompilerTest, CodeGenMultiStream) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\multiStreamGS.hlsl");
 }