瀏覽代碼

Update dxexp for newer shader models and features (#1762)

Tex Riddell 6 年之前
父節點
當前提交
e89886ae03
共有 1 個文件被更改,包括 72 次插入15 次删除
  1. 72 15
      tools/dxexp/dxexp.cpp

+ 72 - 15
tools/dxexp/dxexp.cpp

@@ -97,7 +97,47 @@ typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4
     _Out_ D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier;
     _Out_ BOOL Native16BitShaderOpsSupported;
 } D3D12_FEATURE_DATA_D3D12_OPTIONS4;
+#endif
+
+#ifndef NTDDI_WIN10_RS4
+#define NTDDI_WIN10_RS4 0x0A000005
+#endif
+
+#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS4
+#define D3D_SHADER_MODEL_6_3 ((D3D_SHADER_MODEL)0x63)
+#define D3D12_FEATURE_D3D12_OPTIONS5 ((D3D12_FEATURE)27)
+typedef enum D3D12_RENDER_PASS_TIER
+{
+    D3D12_RENDER_PASS_TIER_0  = 0,
+    D3D12_RENDER_PASS_TIER_1  = 1,
+    D3D12_RENDER_PASS_TIER_2  = 2
+}   D3D12_RENDER_PASS_TIER;
+
+typedef enum D3D12_RAYTRACING_TIER
+{
+    D3D12_RAYTRACING_TIER_NOT_SUPPORTED = 0,
+    D3D12_RAYTRACING_TIER_1_0 = 10
+}   D3D12_RAYTRACING_TIER;
+
+typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS5
+{
+    _Out_  BOOL SRVOnlyTiledResourceTier3;
+    _Out_  D3D12_RENDER_PASS_TIER RenderPassesTier;
+    _Out_  D3D12_RAYTRACING_TIER RaytracingTier;
+}   D3D12_FEATURE_DATA_D3D12_OPTIONS5;
+#endif
+
+#ifndef NTDDI_WIN10_RS5
+#define NTDDI_WIN10_RS5 0x0A000006
+#endif
 
+#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS5
+#define D3D_SHADER_MODEL_6_4 ((D3D_SHADER_MODEL)0x64)
+#endif
+
+// TODO: Place under new version once available
+#if WDK_NTDDI_VERSION <= NTDDI_WIN10_RS5
+#define D3D_SHADER_MODEL_6_5 ((D3D_SHADER_MODEL)0x65)
 #endif
 
 static char *BoolToStrJson(bool value) {
@@ -120,6 +160,9 @@ static char *ShaderModelToStr(D3D_SHADER_MODEL SM) {
   case D3D_SHADER_MODEL_6_0: return "6.0";
   case D3D_SHADER_MODEL_6_1: return "6.1";
   case D3D_SHADER_MODEL_6_2: return "6.2";
+  case D3D_SHADER_MODEL_6_3: return "6.3";
+  case D3D_SHADER_MODEL_6_4: return "6.4";
+  case D3D_SHADER_MODEL_6_5: return "6.5";
   default: return "ERROR";
   }
 }
@@ -134,6 +177,25 @@ static char *ViewInstancingTierToStr(D3D12_VIEW_INSTANCING_TIER Tier) {
   }
 }
 
+static char *RaytracingTierToStr(D3D12_RAYTRACING_TIER Tier) {
+  switch (Tier) {
+  case D3D12_RAYTRACING_TIER_NOT_SUPPORTED: return "NO";
+  case D3D12_RAYTRACING_TIER_1_0: return "1.0";
+  default: return "ERROR";
+  }
+}
+
+static HRESULT GetHighestShaderModel(ID3D12Device *pDevice, D3D12_FEATURE_DATA_SHADER_MODEL &DeviceSM) {
+  HRESULT hr = E_INVALIDARG;
+  D3D_SHADER_MODEL SM = D3D_SHADER_MODEL_6_5;
+  while (hr == E_INVALIDARG && SM >= D3D_SHADER_MODEL_6_0) {
+    DeviceSM.HighestShaderModel = SM;
+    hr = pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &DeviceSM, sizeof(DeviceSM));
+    SM = (D3D_SHADER_MODEL)((UINT32)SM - 1);
+  }
+  return hr;
+}
+
 static HRESULT PrintAdapters() {
   HRESULT hr = S_OK;
   char comma = ' ';
@@ -153,28 +215,22 @@ static HRESULT PrintAdapters() {
       D3D12_FEATURE_DATA_D3D12_OPTIONS1 DeviceOptions;
       D3D12_FEATURE_DATA_D3D12_OPTIONS3 DeviceOptions3;
       D3D12_FEATURE_DATA_D3D12_OPTIONS4 DeviceOptions4;
+      D3D12_FEATURE_DATA_D3D12_OPTIONS5 DeviceOptions5;
       memset(&DeviceOptions, 0, sizeof(DeviceOptions));
       memset(&DeviceOptions3, 0, sizeof(DeviceOptions3));
       memset(&DeviceOptions4, 0, sizeof(DeviceOptions4));
+      memset(&DeviceOptions5, 0, sizeof(DeviceOptions5));
       D3D12_FEATURE_DATA_SHADER_MODEL DeviceSM;
       AtlCheck(pAdapter->GetDesc1(&AdapterDesc));
       AtlCheck(D3D12CreateDevice(pAdapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&pDevice)));
       AtlCheck(pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &DeviceOptions, sizeof(DeviceOptions)));
-      DeviceSM.HighestShaderModel = D3D_SHADER_MODEL_6_0;
-      // CheckFeatureSupport with D3D12_FEATURE_D3D12_OPTIONS3 will fail on Creators Update,
-      // but succeed on newer versions of Windows.  Use this to control the initial value
-      // for highest shader model.
-      if (SUCCEEDED(pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &DeviceOptions3, sizeof(DeviceOptions3))))
-        DeviceSM.HighestShaderModel = D3D_SHADER_MODEL_6_1;
-      // CheckFeatureSupport with D3D12_FEATURE_D3D12_OPTIONS3 will fail on Fall Creators Update,
-      // but succeed on newer versions of Windows.  Use this to control the initial value
-      // for highest shader model.
-      if (SUCCEEDED(pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &DeviceOptions4, sizeof(DeviceOptions4))))
-        DeviceSM.HighestShaderModel = D3D_SHADER_MODEL_6_2;
-      AtlCheck(pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &DeviceSM, sizeof(DeviceSM)));
+      pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &DeviceOptions3, sizeof(DeviceOptions3));
+      pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &DeviceOptions4, sizeof(DeviceOptions4));
+      pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &DeviceOptions5, sizeof(DeviceOptions5));
+      AtlCheck(GetHighestShaderModel(pDevice, DeviceSM));
       const char *Format = IsOutputJson ?
-        "%c { \"name\": \"%S\", \"sm\": \"%s\", \"wave\": %s, \"i64\": %s, \"bary\": %s, \"view-inst\": \"%s\" }\n" :
-        "%c %S - Highest SM [%s] Wave [%s] I64 [%s] Barycentrics [%s] View Instancing [%s] 16bit Support [%s]\n";
+        "%c { \"name\": \"%S\", \"sm\": \"%s\", \"wave\": %s, \"i64\": %s, \"bary\": %s, \"view-inst\": \"%s\", \"16bit\": %s, \"raytracing\": \"%s\" }\n" :
+        "%c %S - Highest SM [%s] Wave [%s] I64 [%s] Barycentrics [%s] View Instancing [%s] 16bit Support [%s] Raytracing [%s]\n";
       printf(Format,
              comma,
              AdapterDesc.Description,
@@ -183,7 +239,8 @@ static HRESULT PrintAdapters() {
              BoolToStr(DeviceOptions.Int64ShaderOps),
              BoolToStr(DeviceOptions3.BarycentricsSupported),
              ViewInstancingTierToStr(DeviceOptions3.ViewInstancingTier),
-             BoolToStr(DeviceOptions4.Native16BitShaderOpsSupported)
+             BoolToStr(DeviceOptions4.Native16BitShaderOpsSupported),
+             RaytracingTierToStr(DeviceOptions5.RaytracingTier)
             );
       AdapterIndex++;
       comma = IsOutputJson ? ',' : ' ';