瀏覽代碼

Windows 11 - fixed D3D12 ERROR: ID3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart: GetGPUDescriptorHandleForHeapStart is invalid to call on a descriptor heap that does not have DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE set. If the heap is not supposed to be shader visible, then GetCPUDescriptorHandleForHeapStart would be the appropriate method to call. That call is valid both for shader visible and non shader visible descriptor heaps. [ STATE_GETTING ERROR #1315: DESCRIPTOR_HEAP_NOT_SHADER_VISIBLE]

Jorrit Rouwe 3 年之前
父節點
當前提交
2b11f2bfb3
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      TestFramework/Renderer/DescriptorHeap.h

+ 4 - 2
TestFramework/Renderer/DescriptorHeap.h

@@ -25,7 +25,8 @@ public:
 		mDescriptorSize = inDevice->GetDescriptorHandleIncrementSize(heap_desc.Type);
 
 		// Delta between the CPU and GPU heap
-		mGPUOffset = mHeap->GetGPUDescriptorHandleForHeapStart().ptr - mHeap->GetCPUDescriptorHandleForHeapStart().ptr;
+		if (inFlags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE)
+			mGPUOffset = mHeap->GetGPUDescriptorHandleForHeapStart().ptr - mHeap->GetCPUDescriptorHandleForHeapStart().ptr;
 
 		// Populate the freelist
 		mFreeList.reserve(inNumber);
@@ -58,6 +59,7 @@ public:
 	/// Convert from a CPU to a GPU handle
 	D3D12_GPU_DESCRIPTOR_HANDLE			ConvertToGPUHandle(D3D12_CPU_DESCRIPTOR_HANDLE inHandle)
 	{
+		JPH_ASSERT(mGPUOffset != -1);
 		return { inHandle.ptr + mGPUOffset };
 	}
 
@@ -71,5 +73,5 @@ private:
 	ComPtr<ID3D12DescriptorHeap>		mHeap;
 	uint								mDescriptorSize;				///< The size (in bytes) of a single heap descriptor
 	vector<uint>						mFreeList;						///< List of indices in the heap that are still free
-	INT64								mGPUOffset;						///< Offset between CPU and GPU handles
+	INT64								mGPUOffset = -1;				///< Offset between CPU and GPU handles
 };