فهرست منبع

Better support for D3D12_SHADER_DESC reflection. (#1704)

Implemented filling out fields related to shader stage properties.
Tristan Labelle 6 سال پیش
والد
کامیت
02260b1a8b
2فایلهای تغییر یافته به همراه29 افزوده شده و 11 حذف شده
  1. 7 3
      include/dxc/DXIL/DxilConstants.h
  2. 22 8
      lib/HLSL/DxilContainerReflection.cpp

+ 7 - 3
include/dxc/DXIL/DxilConstants.h

@@ -92,6 +92,7 @@ namespace DXIL {
     SNormF16, UNormF16, SNormF32, UNormF32, SNormF64, UNormF64,
     SNormF16, UNormF16, SNormF32, UNormF32, SNormF64, UNormF64,
     LastEntry };
     LastEntry };
 
 
+  // Must match D3D_INTERPOLATION_MODE
   enum class InterpolationMode : uint8_t {
   enum class InterpolationMode : uint8_t {
     Undefined                   = 0,
     Undefined                   = 0,
     Constant                    = 1,
     Constant                    = 1,
@@ -118,6 +119,7 @@ namespace DXIL {
     PatchConstant,
     PatchConstant,
   };
   };
 
 
+  // Must match D3D11_SHADER_VERSION_TYPE
   enum class ShaderKind {
   enum class ShaderKind {
     Pixel = 0,
     Pixel = 0,
     Vertex,
     Vertex,
@@ -935,7 +937,7 @@ namespace DXIL {
   const unsigned kGenericPointerAddrSpace = 4;
   const unsigned kGenericPointerAddrSpace = 4;
   const unsigned kImmediateCBufferAddrSpace = 5;
   const unsigned kImmediateCBufferAddrSpace = 5;
 
 
-  // Input primitive.
+  // Input primitive, must match D3D_PRIMITIVE
   enum class InputPrimitive : unsigned {
   enum class InputPrimitive : unsigned {
     Undefined = 0,
     Undefined = 0,
     Point = 1,
     Point = 1,
@@ -981,7 +983,7 @@ namespace DXIL {
     LastEntry,
     LastEntry,
   };
   };
 
 
-  // Primitive topology.
+  // Primitive topology, must match D3D_PRIMITIVE_TOPOLOGY
   enum class PrimitiveTopology : unsigned {
   enum class PrimitiveTopology : unsigned {
     Undefined = 0,
     Undefined = 0,
     PointList = 1,
     PointList = 1,
@@ -993,6 +995,7 @@ namespace DXIL {
     LastEntry,
     LastEntry,
   };
   };
 
 
+  // Must match D3D_TESSELLATOR_DOMAIN
   enum class TessellatorDomain
   enum class TessellatorDomain
   {
   {
     Undefined = 0,
     Undefined = 0,
@@ -1003,6 +1006,7 @@ namespace DXIL {
     LastEntry,
     LastEntry,
   };
   };
 
 
+  // Must match D3D_TESSELLATOR_OUTPUT_PRIMITIVE
   enum class TessellatorOutputPrimitive
   enum class TessellatorOutputPrimitive
   {
   {
     Undefined = 0,
     Undefined = 0,
@@ -1014,7 +1018,7 @@ namespace DXIL {
     LastEntry,
     LastEntry,
   };
   };
 
 
-  // Tessellator partitioning.
+  // Tessellator partitioning, must match D3D_TESSELLATOR_PARTITIONING
   enum class TessellatorPartitioning : unsigned {
   enum class TessellatorPartitioning : unsigned {
     Undefined = 0,
     Undefined = 0,
     Integer,
     Integer,

+ 22 - 8
lib/HLSL/DxilContainerReflection.cpp

@@ -1785,6 +1785,7 @@ HRESULT DxilShaderReflection::GetDesc(D3D12_SHADER_DESC *pDesc) {
   const ShaderModel *pSM = M.GetShaderModel();
   const ShaderModel *pSM = M.GetShaderModel();
 
 
   pDesc->Version = EncodeVersion(pSM->GetKind(), pSM->GetMajor(), pSM->GetMinor());
   pDesc->Version = EncodeVersion(pSM->GetKind(), pSM->GetMajor(), pSM->GetMinor());
+
   // Unset:  LPCSTR                  Creator;                     // Creator string
   // Unset:  LPCSTR                  Creator;                     // Creator string
   // Unset:  UINT                    Flags;                       // Shader compilation/parse flags
   // Unset:  UINT                    Flags;                       // Shader compilation/parse flags
 
 
@@ -1813,18 +1814,31 @@ HRESULT DxilShaderReflection::GetDesc(D3D12_SHADER_DESC *pDesc) {
   // Unset:  UINT                    ArrayInstructionCount;       // Number of array instructions used
   // Unset:  UINT                    ArrayInstructionCount;       // Number of array instructions used
   // Unset:  UINT                    CutInstructionCount;         // Number of cut instructions used
   // Unset:  UINT                    CutInstructionCount;         // Number of cut instructions used
   // Unset:  UINT                    EmitInstructionCount;        // Number of emit instructions used
   // Unset:  UINT                    EmitInstructionCount;        // Number of emit instructions used
-  // Unset:  D3D_PRIMITIVE_TOPOLOGY  GSOutputTopology;            // Geometry shader output topology
-  // Unset:  UINT                    GSMaxOutputVertexCount;      // Geometry shader maximum output vertex count
-  // Unset:  D3D_PRIMITIVE           InputPrimitive;              // GS/HS input primitive
-  // Unset:  UINT                    cGSInstanceCount;            // Number of Geometry shader instances
-  // Unset:  UINT                    cControlPoints;              // Number of control points in the HS->DS stage
-  // Unset:  D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive;  // Primitive output by the tessellator
-  // Unset:  D3D_TESSELLATOR_PARTITIONING HSPartitioning;         // Partitioning mode of the tessellator
-  // Unset:  D3D_TESSELLATOR_DOMAIN  TessellatorDomain;           // Domain of the tessellator (quad, tri, isoline)
+
+  pDesc->GSOutputTopology = (D3D_PRIMITIVE_TOPOLOGY)M.GetStreamPrimitiveTopology();
+  pDesc->GSMaxOutputVertexCount = M.GetMaxVertexCount();
+
+  if (pSM->IsHS())
+    pDesc->InputPrimitive = (D3D_PRIMITIVE)(D3D_PRIMITIVE_1_CONTROL_POINT_PATCH + M.GetInputControlPointCount() - 1);
+  else
+    pDesc->InputPrimitive = (D3D_PRIMITIVE)M.GetInputPrimitive();
+
+  pDesc->cGSInstanceCount = M.GetGSInstanceCount();
+
+  if (pSM->IsHS())
+    pDesc->cControlPoints = M.GetOutputControlPointCount();
+  else if (pSM->IsDS())
+    pDesc->cControlPoints = M.GetInputControlPointCount();
+
+  pDesc->HSOutputPrimitive = (D3D_TESSELLATOR_OUTPUT_PRIMITIVE)M.GetTessellatorOutputPrimitive();
+  pDesc->HSPartitioning = (D3D_TESSELLATOR_PARTITIONING)M.GetTessellatorPartitioning();
+  pDesc->TessellatorDomain = (D3D_TESSELLATOR_DOMAIN)M.GetTessellatorDomain();
+
   // instruction counts
   // instruction counts
   // Unset:  UINT cBarrierInstructions;                           // Number of barrier instructions in a compute shader
   // Unset:  UINT cBarrierInstructions;                           // Number of barrier instructions in a compute shader
   // Unset:  UINT cInterlockedInstructions;                       // Number of interlocked instructions
   // Unset:  UINT cInterlockedInstructions;                       // Number of interlocked instructions
   // Unset:  UINT cTextureStoreInstructions;                      // Number of texture writes
   // Unset:  UINT cTextureStoreInstructions;                      // Number of texture writes
+
   return S_OK;
   return S_OK;
 }
 }