瀏覽代碼

Minor bug fixes. (#463)

1. Support in out as inout.
2. Support function call on extern functions which don't need to flatten.
Xiang Li 8 年之前
父節點
當前提交
71774913f6

+ 4 - 2
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -5849,8 +5849,10 @@ void SROA_Parameter_HLSL::createFlattenedFunction(Function *F) {
         }
         }
       }
       }
     }
     }
-    // Support store to input and load from output.
-    LegalizeDxilInputOutputs(F, funcAnnotation, typeSys);
+    if (!F->isDeclaration()) {
+      // Support store to input and load from output.
+      LegalizeDxilInputOutputs(F, funcAnnotation, typeSys);
+    }
     return;
     return;
   }
   }
 
 

+ 2 - 0
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -1437,6 +1437,8 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
       dxilInputQ = DxilParamInputQual::Inout;
       dxilInputQ = DxilParamInputQual::Inout;
     else if (parmDecl->hasAttr<HLSLOutAttr>())
     else if (parmDecl->hasAttr<HLSLOutAttr>())
       dxilInputQ = DxilParamInputQual::Out;
       dxilInputQ = DxilParamInputQual::Out;
+    if (parmDecl->hasAttr<HLSLOutAttr>() && parmDecl->hasAttr<HLSLInAttr>())
+      dxilInputQ = DxilParamInputQual::Inout;
 
 
     DXIL::InputPrimitive inputPrimitive = DXIL::InputPrimitive::Undefined;
     DXIL::InputPrimitive inputPrimitive = DXIL::InputPrimitive::Undefined;
 
 

+ 15 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/in_out.hlsl

@@ -0,0 +1,15 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// Make sure in out is take as inout.
+// CHECK: Input signature:
+// CHECK: Name
+// CHECK: A
+// CHECK: Output signature:
+// CHECK: Name
+// CHECK: A
+// CHECK: SV_Position
+// CHECK: loadInput
+
+float4 main(in out float4 a: A) : SV_Position {
+  return 1.2;
+}

+ 12 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/lib_no_flat_extern_func.hlsl

@@ -0,0 +1,12 @@
+// RUN: %dxc -T lib_6_1 %s | FileCheck %s
+
+// Make sure extern function don't need to flat is called.
+// CHECK: call void @"\01?test@@YAXMAIAM@Z"
+
+void test(float a, out float b);
+
+float test2(float a) {
+  float b;
+  test(a, b);
+  return b;
+}