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

flesh out SV_CullPrimitive support (#2373)

* flesh out SV_CullPrimitive support (and fill in some missing SV_ShadingRate entries)

* fix build breakl

* moved #defines and added comment

* removed depenency on adding new entries to OS header d3dcommon.h

* test fixes
amarpMSFT 6 жил өмнө
parent
commit
f9c973536e

+ 1 - 0
include/dxc/DxilContainer/DxilContainer.h

@@ -156,6 +156,7 @@ enum class DxilProgramSigSemantic : uint32_t {
   FinalLineDensityTessfactor = 16,
   Barycentrics = 23,
   ShadingRate = 24,
+  CullPrimitive = 25,
   Target = 64,
   Depth = 65,
   Coverage = 66,

+ 1 - 0
lib/DxilContainer/DxilContainerAssembler.cpp

@@ -57,6 +57,7 @@ static DxilProgramSigSemantic KindToSystemValue(Semantic::Kind kind, DXIL::Tesse
   case Semantic::Kind::CullDistance: return DxilProgramSigSemantic::CullDistance;
   case Semantic::Kind::Barycentrics: return DxilProgramSigSemantic::Barycentrics;
   case Semantic::Kind::ShadingRate: return DxilProgramSigSemantic::ShadingRate;
+  case Semantic::Kind::CullPrimitive: return DxilProgramSigSemantic::CullPrimitive;
   case Semantic::Kind::TessFactor: {
     switch (domain) {
     case DXIL::TessellatorDomain::IsoLine:

+ 4 - 0
lib/HLSL/DxilContainerReflection.cpp

@@ -1721,6 +1721,10 @@ D3D_NAME SemanticToSystemValueType(const Semantic *S, DXIL::TessellatorDomain do
     default:
     return D3D_NAME_UNDEFINED;
     }
+  case Semantic::Kind::ShadingRate:
+    return (D3D_NAME)DxilProgramSigSemantic::ShadingRate;
+  case Semantic::Kind::CullPrimitive:
+    return (D3D_NAME)DxilProgramSigSemantic::CullPrimitive;
   }
   case Semantic::Kind::InsideTessFactor:
     switch (domain) {

+ 6 - 0
lib/HLSL/DxilValidation.cpp

@@ -4407,6 +4407,12 @@ static void ValidateSignatureElement(DxilSignatureElement &SE,
                              {SE.GetSemantic()->GetName(), "uint"});
     }
     break;
+  case DXIL::SemanticKind::CullPrimitive: {
+    if (!(compBool && compWidth == 1) || SE.GetCols() != 1) {
+      ValCtx.EmitFormatError(ValidationRule::MetaSemanticCompType,
+                             {SE.GetSemantic()->GetName(), "bool"});
+    }
+  } break;
   case DXIL::SemanticKind::TessFactor:
   case DXIL::SemanticKind::InsideTessFactor:
     // NOTE: the size check is at CheckPatchConstantSemantic.

+ 1 - 1
tools/clang/test/CodeGenHLSL/batch/declarations/functions/entrypoints/semantics/misc/shadingrate1.hlsl

@@ -3,7 +3,7 @@
 // CHECK:       ; Note: shader requires additional functionality:
 // CHECK-NEXT:  ;       Shading Rate
 // CHECK:       ; Input signature:
-// CHECK:       ; SV_ShadingRate           0   x           1     NONE    uint
+// CHECK:       ; SV_ShadingRate           0   x           1SHDINGRATE    uint
 // CHECK:       ; Output signature:
 // CHECK:       ; Input signature:
 // CHECK:       ; SV_ShadingRate           0        nointerpolation

+ 1 - 1
tools/clang/test/CodeGenHLSL/batch/declarations/functions/entrypoints/semantics/misc/shadingrate2.hlsl

@@ -4,7 +4,7 @@
 // CHECK-NEXT:  ;       Shading Rate
 // CHECK:       ; Input signature:
 // CHECK:       ; Output signature:
-// CHECK:       ; SV_ShadingRate           0   x           1     NONE    uint
+// CHECK:       ; SV_ShadingRate           0   x           1SHDINGRATE    uint
 // CHECK:       ; Input signature:
 // CHECK:       ; Output signature:
 // CHECK:       ; SV_ShadingRate           0        nointerpolation

+ 3 - 0
tools/clang/test/CodeGenHLSL/mesh/mesh.hlsl

@@ -5,6 +5,7 @@
 // CHECK: dx.op.emitIndices
 // CHECK: dx.op.storeVertexOutput
 // CHECK: dx.op.storePrimitiveOutput
+// CHECK: !"cullPrimitive", i32 3, i32 100, i32 4, !"SV_CullPrimitive", i32 7, i32 1}
 
 #define MAX_VERT 32
 #define MAX_PRIM 16
@@ -20,6 +21,7 @@ struct MeshPerPrimitive {
     float alnorm : ALNORM;
     float ormaln : ORMALN;
     int layer[6] : LAYER;
+    bool cullPrimitive : SV_CullPrimitive;
 };
 
 struct MeshPayload {
@@ -71,6 +73,7 @@ void main(
       op.layer[3] = mpl.layer[3];
       op.layer[4] = mpl.layer[4];
       op.layer[5] = mpl.layer[5];
+      op.cullPrimitive = false;
       gsMem[tig / 3] = op.normal;
       prims[tig / 3] = op;
     }

+ 6 - 0
tools/clang/tools/dxcompiler/dxcdisassembler.cpp

@@ -192,6 +192,12 @@ void PrintSignature(LPCSTR pName, const DxilProgramSignature *pSignature,
     case DxilProgramSigSemantic::Barycentrics:
       pSysValue = "BARYCEN";
       break;
+    case DxilProgramSigSemantic::ShadingRate:
+      pSysValue = "SHDINGRATE";
+      break;
+    case DxilProgramSigSemantic::CullPrimitive:
+      pSysValue = "CULLPRIM";
+      break;
     case DxilProgramSigSemantic::Undefined:
       break;
     }