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

Support line and lineadj for GS. (#57)

Xiang Li 8 жил өмнө
parent
commit
54ab549807

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

@@ -1443,6 +1443,14 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
       funcProps->ShaderProps.GS.inputPrimitive = DXIL::InputPrimitive::Point;
       dxilInputQ = DxilParamInputQual::InputPrimitive;
       primitiveCount++;
+    } else if (parmDecl->hasAttr<HLSLLineAdjAttr>()) {
+      funcProps->ShaderProps.GS.inputPrimitive = DXIL::InputPrimitive::LineWithAdjacency;
+      dxilInputQ = DxilParamInputQual::InputPrimitive;
+      primitiveCount++;
+    } else if (parmDecl->hasAttr<HLSLLineAttr>()) {
+      funcProps->ShaderProps.GS.inputPrimitive = DXIL::InputPrimitive::Line;
+      dxilInputQ = DxilParamInputQual::InputPrimitive;
+      primitiveCount++;
     }
 
     paramAnnotation.SetParamInputQual(dxilInputQ);

+ 23 - 0
tools/clang/test/CodeGenHLSL/SimpleGS6.hlsl

@@ -0,0 +1,23 @@
+// RUN: %dxc -E main -T gs_6_0 %s | FileCheck %s
+
+// CHECK: InputPrimitive=lineadj
+
+
+struct Out
+{
+  float4 pos : SV_Position;
+  float4 a[2] : A;
+};
+
+struct Empty{};
+int i;
+
+[maxvertexcount(3)]
+void main(lineadj Empty e[4], inout PointStream<Out> OutputStream0)
+{
+  Out output = (Out)0;
+  output.a[i] = 3;
+
+  OutputStream0.Append(output);
+  OutputStream0.RestartStrip();
+}

+ 23 - 0
tools/clang/test/CodeGenHLSL/SimpleGS7.hlsl

@@ -0,0 +1,23 @@
+// RUN: %dxc -E main -T gs_6_0 %s | FileCheck %s
+
+// CHECK: InputPrimitive=line
+
+
+struct Out
+{
+  float4 pos : SV_Position;
+  float4 a[2] : A;
+};
+
+struct Empty{};
+int i;
+
+[maxvertexcount(3)]
+void main(line Empty e[4], inout PointStream<Out> OutputStream0)
+{
+  Out output = (Out)0;
+  output.a[i] = 3;
+
+  OutputStream0.Append(output);
+  OutputStream0.RestartStrip();
+}

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

@@ -466,6 +466,8 @@ public:
   TEST_METHOD(CodeGenSimpleGS3)
   TEST_METHOD(CodeGenSimpleGS4)
   TEST_METHOD(CodeGenSimpleGS5)
+  TEST_METHOD(CodeGenSimpleGS6)
+  TEST_METHOD(CodeGenSimpleGS7)
   TEST_METHOD(CodeGenSimpleHS1)
   TEST_METHOD(CodeGenSimpleHS2)
   TEST_METHOD(CodeGenSimpleHS3)
@@ -2368,6 +2370,14 @@ TEST_F(CompilerTest, CodeGenSimpleGS5) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS5.hlsl");
 }
 
+TEST_F(CompilerTest, CodeGenSimpleGS6) {
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS6.hlsl");
+}
+
+TEST_F(CompilerTest, CodeGenSimpleGS7) {
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS7.hlsl");
+}
+
 TEST_F(CompilerTest, CodeGenSimpleHS1) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS1.hlsl");
 }