Browse Source

Skip gpudescriptorhandles where there is no RTV (#3329)

Where there's no render target, the runtime throws errors if you try to
retrieve the gpu descriptor handle.
Greg Roth 4 years ago
parent
commit
645bb78d13
1 changed files with 7 additions and 3 deletions
  1. 7 3
      tools/clang/unittests/HLSL/ShaderOpTest.cpp

+ 7 - 3
tools/clang/unittests/HLSL/ShaderOpTest.cpp

@@ -297,7 +297,9 @@ void ShaderOpTest::CreateDescriptorHeaps() {
 
     const UINT descriptorSize = m_pDevice->GetDescriptorHandleIncrementSize(H.Desc.Type);
     CD3DX12_CPU_DESCRIPTOR_HANDLE cpuHandle(pHeap->GetCPUDescriptorHandleForHeapStart());
-    CD3DX12_GPU_DESCRIPTOR_HANDLE gpuHandle(pHeap->GetGPUDescriptorHandleForHeapStart());
+    CD3DX12_GPU_DESCRIPTOR_HANDLE gpuHandle;
+    if (H.Desc.Type != D3D12_DESCRIPTOR_HEAP_TYPE_RTV)
+        gpuHandle = CD3DX12_GPU_DESCRIPTOR_HANDLE(pHeap->GetGPUDescriptorHandleForHeapStart());
     for (ShaderOpDescriptor &D : H.Descriptors) {
       ShaderOpResource *R = m_pShaderOp->GetResourceByName(D.ResName);
       if (R == nullptr) {
@@ -336,11 +338,13 @@ void ShaderOpTest::CreateDescriptorHeaps() {
         m_pDevice->CreateConstantBufferView(&cbvDesc, cpuHandle);
       }
 
-      DData.GPUHandle = gpuHandle;
       DData.CPUHandle = cpuHandle;
       m_DescriptorData[R->Name] = DData;
       cpuHandle = cpuHandle.Offset(descriptorSize);
-      gpuHandle = gpuHandle.Offset(descriptorSize);
+      if (H.Desc.Type != D3D12_DESCRIPTOR_HEAP_TYPE_RTV) {
+        DData.GPUHandle = gpuHandle;
+        gpuHandle = gpuHandle.Offset(descriptorSize);
+      }
     }
   }