diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-02-25 05:27:09 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:11 +0000 |
| commit | 52c6fcdfa91f0dd50419c25cf6e6754a6229a441 (patch) | |
| tree | d339360a8e6ca380a487c056bf12ba35c17d2a6f /Graphics/GraphicsEngineD3D12 | |
| parent | PipelineResourceSignatureD3D12Impl: added bound buffer view mode validation (diff) | |
| download | DiligentCore-52c6fcdfa91f0dd50419c25cf6e6754a6229a441.tar.gz DiligentCore-52c6fcdfa91f0dd50419c25cf6e6754a6229a441.zip | |
Few updated to RootParamsManager, RootSignatureD3D12, and ShaderResourceCacheD3D12
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
7 files changed, 122 insertions, 47 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp b/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp index 5842db87..33e547bd 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp @@ -109,6 +109,21 @@ static_assert(sizeof(RootParameter) == sizeof(D3D12_ROOT_PARAMETER) + sizeof(Uin /// Container for root parameters + +/// RootParamsManager keeps root parameters of a single pipeline resource signature. +/// When resource signatures are combined into a single d3d12 root signature, +/// root indices and shader spaces are biased based on earlier signatures. + +// Note that root index is NOT the same as the index of +// the root table or index of the root view, e.g. +// +// Root Index | Root Table Index | Root View Index +// 0 | 0 | +// 1 | | 0 +// 2 | 1 | +// 3 | 2 | +// 4 | | 1 +// class RootParamsManager { public: @@ -137,9 +152,10 @@ public: return m_pRootViews[ViewInd]; } - Uint32 GetTotalTableSlots(D3D12_DESCRIPTOR_HEAP_TYPE d3d12HeapType, ROOT_PARAMETER_GROUP Group) const + // Returns the total number of resources in a given parameter group and descriptor heap type + Uint32 GetParameterGroupSize(D3D12_DESCRIPTOR_HEAP_TYPE d3d12HeapType, ROOT_PARAMETER_GROUP Group) const { - return m_TotalTableSlots[d3d12HeapType][Group]; + return m_ParameterGroupSizes[d3d12HeapType][Group]; } bool operator==(const RootParamsManager& RootParams) const; @@ -160,7 +176,7 @@ private: const RootParameter* m_pRootViews = nullptr; // The total number of resources placed in descriptor tables for each heap type and parameter group type - std::array<std::array<Uint32, ROOT_PARAMETER_GROUP_COUNT>, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + 1> m_TotalTableSlots{}; + std::array<std::array<Uint32, ROOT_PARAMETER_GROUP_COUNT>, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + 1> m_ParameterGroupSizes{}; }; class RootParamsBuilder diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp index 51295859..497cf11d 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp @@ -30,13 +30,27 @@ /// \file /// Declaration of Diligent::RootSignatureD3D12 class -#include <array> +// Root signature object combines multiple pipeline resource signatures into a single +// d3d12 root signature. The signatures "stack" on top of each other. Their "local" +// root indices and register spaces are biased by the root indices and spaces of +// previous signatures. +// +// __________________________________________________________ +// | | +// | Pipeline Resource Signature 2 (NRootIndices2, NSpaces2) | BaseRootIndex2 = BaseRootIndex1 + NRootIndices1 +// |__________________________________________________________| BaseSpace2 = BaseSpace1 + NSpaces1 +// | | +// | Pipeline Resource Signature 1 (NRootIndices1, NSpaces1) | BaseRootIndex1 = BaseRootIndex0 + NRootIndices0 +// |__________________________________________________________| BaseSpace1 = BaseSpace0 + NSpaces0 +// | | +// | Pipeline Resource Signature 0 (NRootIndices0, NSpaces0) | BaseRootIndex0 = 0 +// |__________________________________________________________| BaseSpace0 = 0 +// + #include <mutex> #include <unordered_map> #include <memory> -#include "D3D12TypeConversions.hpp" -#include "ShaderResourceCacheD3D12.hpp" #include "PipelineResourceSignatureD3D12Impl.hpp" #include "PrivateConstants.h" #include "ShaderResources.hpp" @@ -52,11 +66,11 @@ class RootSignatureCacheD3D12; class RootSignatureD3D12 final : public ObjectBase<IObject> { public: - RootSignatureD3D12(IReferenceCounters* pRefCounters, - RenderDeviceD3D12Impl* pDeviceD3D12Impl, - const RefCntAutoPtr<PipelineResourceSignatureD3D12Impl>* ppSignatures, - Uint32 SignatureCount, - size_t Hash); + RootSignatureD3D12(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + const RefCntAutoPtr<PipelineResourceSignatureD3D12Impl> ppSignatures[], + Uint32 SignatureCount, + size_t Hash); ~RootSignatureD3D12(); size_t GetHash() const { return m_Hash; } @@ -87,6 +101,7 @@ public: return m_ResourceSignatures[BindingIndex].BaseRegisterSpace; } + /// Returns the total number of register spaces used by all resource signatures Uint32 GetTotalSpaces() const { return m_TotalSpacesUsed; @@ -148,7 +163,7 @@ private: }; - +/// Root signature cache that deduplicates RootSignatureD3D12 objects. class RootSignatureCacheD3D12 { public: diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp index 4be8fdbe..95cdc81f 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp @@ -38,7 +38,7 @@ // m_pMemory | m_pResources, m_NumResources == m | // | | | // V | V -// | RootTable[0] | .... | RootTable[Nrt-1] | Res[0] | ... | Res[n-1] | .... | Res[0] | ... | Res[m-1] | +// | RootTable[0] | .... | RootTable[Nrt-1] | Res[0] | ... | Res[n-1] | .... | Res[0] | ... | Res[m-1] | DescriptorHeapAllocation[0] | ... // | A \ // | | \ // |________________________________________________| \RefCntAutoPtr @@ -49,7 +49,10 @@ // Nrt = m_NumTables // // -// The cache is also assigned decriptor heap space to store shader visible descriptor handles (for non-dynamic resources). +// The cache is also assigned decriptor heap space to store descriptor handles. +// Static and mutable table resources are stored in shader-visible heap. +// Dynamic table resources are stored in CPU-only heap. +// Root views are not assigned descriptor space. // // // DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV @@ -70,7 +73,6 @@ // // The allocation is inexed by the offset from the beginning of the root table. // Each root table is assigned the space to store exactly m_NumResources resources. -// Dynamic resources are not assigned space in the descriptor heap allocation. // // // @@ -81,6 +83,24 @@ // V // ..... | DescrptHndl[0] ... DescrptHndl[n-1] | .... // +// +// +// The cache stores resources for both root tables and root views. +// Resources of root views are treated as single-descriptor tables +// Example: +// +// Root Index | Is Root View | Num Resources +// 0 | No | 1+ +// 1 | Yes | 1 +// 2 | Yes | 1 +// 3 | No | 1+ +// 4 | Yes | 1+ +// 5 | Yes | 1+ +// 6 | No | 1 +// 7 | No | 1 +// 8 | Yes | 1+ +// Note that resource cache that is used by signature may contain empty tables. + #include <array> #include <memory> @@ -112,10 +132,10 @@ public: } // clang-format off - ShaderResourceCacheD3D12 (const ShaderResourceCacheD3D12&) = delete; - ShaderResourceCacheD3D12 (ShaderResourceCacheD3D12&&) = delete; - ShaderResourceCacheD3D12& operator = (const ShaderResourceCacheD3D12&) = delete; - ShaderResourceCacheD3D12& operator = (ShaderResourceCacheD3D12&&) = delete; + ShaderResourceCacheD3D12 (const ShaderResourceCacheD3D12&) = delete; + ShaderResourceCacheD3D12 ( ShaderResourceCacheD3D12&&) = delete; + ShaderResourceCacheD3D12& operator = (const ShaderResourceCacheD3D12&) = delete; + ShaderResourceCacheD3D12& operator = ( ShaderResourceCacheD3D12&&) = delete; // clang-format on ~ShaderResourceCacheD3D12(); @@ -129,10 +149,14 @@ public: }; static MemoryRequirements GetMemoryRequirements(const RootParamsManager& RootParams); + // Initializes resource cache to hold the given number of root tables, no descriptor space + // is allocated (this is used to initialize the cache for a pipeline resource signature). void Initialize(IMemoryAllocator& MemAllocator, Uint32 NumTables, const Uint32 TableSizes[]); + // Initializes resource cache to hold the resources of a root parameters manager + // (this is used to initialize the cache for an SRB). void Initialize(IMemoryAllocator& MemAllocator, RenderDeviceD3D12Impl* pDevice, const RootParamsManager& RootParams); @@ -145,14 +169,16 @@ public: SHADER_RESOURCE_TYPE Type = SHADER_RESOURCE_TYPE_UNKNOWN; // CPU descriptor handle of a cached resource in CPU-only descriptor heap. - // Note that for dynamic resources, this is the only available CPU descriptor handle. - D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle = {0}; + D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle = {}; RefCntAutoPtr<IDeviceObject> pObject; bool IsNull() const { return pObject == nullptr; } + // Transitions resource to the shader resource state required by Type member. __forceinline void TransitionResource(CommandContext& Ctx); + #ifdef DILIGENT_DEVELOPMENT + // Verifies that resource is in correct shader resource state required by Type member. void DvpVerifyResourceState(); #endif }; @@ -207,13 +233,14 @@ public: Resource* const m_pResources; }; - + // Sets the resource at the given root index and offset from the table start const Resource& SetResource(Uint32 RootIndex, Uint32 OffsetFromTableStart, SHADER_RESOURCE_TYPE Type, D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHandle, RefCntAutoPtr<IDeviceObject>&& pObject); + // Copies the resource to the given root index and offset from the table start const Resource& CopyResource(Uint32 RootIndex, Uint32 OffsetFromTableStart, const Resource& SrcRes) @@ -221,6 +248,7 @@ public: return SetResource(RootIndex, OffsetFromTableStart, SrcRes.Type, SrcRes.CPUDescriptorHandle, RefCntAutoPtr<IDeviceObject>{SrcRes.pObject}); } + // Resets the resource at the given root index and offset from the table start to default state const Resource& ResetResource(Uint32 RootIndex, Uint32 OffsetFromTableStart) { @@ -274,11 +302,15 @@ public: Transition, Verify }; + // Transitions all resources in the cache void TransitionResourceStates(CommandContext& Ctx, StateTransitionMode Mode); CacheContentType GetContentType() const { return m_ContentType; } + // Returns the bitmask indicating root views with bound dynamic buffers Uint64 GetDynamicRootBuffersMask() const { return m_DynamicRootBuffersMask; } + + // Returns the bitmask indicating root views with bound non-dynamic buffers Uint64 GetNonDynamicRootBuffersMask() const { return m_NonDynamicRootBuffersMask; } #ifdef DILIGENT_DEBUG @@ -308,7 +340,7 @@ private: // Descriptor heap allocations, indexed by m_AllocationIndex DescriptorHeapAllocation* m_DescriptorAllocations = nullptr; - // The total number of resources in the cache + // The total number of resources in all descriptor tables Uint32 m_TotalResourceCount = 0; // The number of descriptor tables in the cache @@ -321,7 +353,7 @@ private: const CacheContentType m_ContentType; // Descriptor allocation index in m_DescriptorAllocations array for every descriptor heap type - // (CBV_SRV_UAV, SAMPLER) and GPU visibility. + // (CBV_SRV_UAV, SAMPLER) and GPU visibility (false, true). // -1 indicates no allocation. std::array<std::array<Int8, ROOT_PARAMETER_GROUP_COUNT>, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + 1> m_AllocationIndex{}; diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp index 65633f4a..f5404d1a 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp @@ -606,7 +606,7 @@ void PipelineResourceSignatureD3D12Impl::CommitRootTables(const CommitCacheResou { const auto d3d12HeapType = static_cast<D3D12_DESCRIPTOR_HEAP_TYPE>(heap_type); - auto NumDynamicDescriptors = m_RootParams.GetTotalTableSlots(d3d12HeapType, ROOT_PARAMETER_GROUP_DYNAMIC); + auto NumDynamicDescriptors = m_RootParams.GetParameterGroupSize(d3d12HeapType, ROOT_PARAMETER_GROUP_DYNAMIC); if (NumDynamicDescriptors > 0) { auto& pAllocation = pDynamicDescriptorAllocations[d3d12HeapType]; diff --git a/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp b/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp index b1ac2fcd..f52127b1 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp @@ -181,7 +181,7 @@ void RootParamsManager::Validate() const for (Uint32 group = 0; group < ROOT_PARAMETER_GROUP_COUNT; ++group) { const auto Group = static_cast<ROOT_PARAMETER_GROUP>(group); - DescriptorSlots[d3d12HeapType][Group].resize(GetTotalTableSlots(d3d12HeapType, Group)); + DescriptorSlots[d3d12HeapType][Group].resize(GetParameterGroupSize(d3d12HeapType, Group)); } } @@ -251,7 +251,9 @@ RootParameter& RootParamsBuilder::AddRootView(D3D12_ROOT_PARAMETER_TYPE Paramete ROOT_PARAMETER_GROUP Group) { #ifdef DILIGENT_DEBUG - VERIFY(ParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV || ParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV || ParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV, + VERIFY((ParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV || + ParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV || + ParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV), "Unexpected parameter type SBV, SRV or UAV is expected"); for (const auto& RootTbl : m_RootTables) @@ -453,7 +455,7 @@ void RootParamsBuilder::InitializeMgr(IMemoryAllocator& MemAllocator, RootParams const auto d3d12HeapType = D3D12DescriptorRangeTypeToD3D12HeapType(d3d12SrcTbl.pDescriptorRanges[0].RangeType); - auto& TableOffsetInGroupAllocation = ParamsMgr.m_TotalTableSlots[d3d12HeapType][SrcTbl.Group]; + auto& TableOffsetInGroupAllocation = ParamsMgr.m_ParameterGroupSizes[d3d12HeapType][SrcTbl.Group]; auto* pTbl = new (pRootTables + rt) RootParameter{ SrcTbl.RootIndex, SrcTbl.Group, diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp index 1cd3400c..44105f16 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp @@ -36,11 +36,11 @@ namespace Diligent { -RootSignatureD3D12::RootSignatureD3D12(IReferenceCounters* pRefCounters, - RenderDeviceD3D12Impl* pDeviceD3D12Impl, - const RefCntAutoPtr<PipelineResourceSignatureD3D12Impl>* ppSignatures, - Uint32 SignatureCount, - size_t Hash) : +RootSignatureD3D12::RootSignatureD3D12(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + const RefCntAutoPtr<PipelineResourceSignatureD3D12Impl> ppSignatures[], + Uint32 SignatureCount, + size_t Hash) : ObjectBase<IObject>{pRefCounters}, m_SignatureCount{SignatureCount}, m_Hash{Hash}, @@ -94,7 +94,7 @@ RootSignatureD3D12::RootSignatureD3D12(IReferenceCounters* } } - // Reserve space for all root parameters + // Reserve space for all d3d12 root parameters std::vector<D3D12_ROOT_PARAMETER, STDAllocatorRawMem<D3D12_ROOT_PARAMETER>> d3d12Parameters( TotalParams, D3D12_ROOT_PARAMETER{static_cast<D3D12_ROOT_PARAMETER_TYPE>(-1)}, @@ -262,19 +262,18 @@ bool LocalRootSignatureD3D12::Create(ID3D12Device* pDevice, Uint32 RegisterSpace if (m_ShaderRecordSize == 0) return false; - VERIFY(m_RegisterSpace == ~0u || m_pd3d12RootSignature == nullptr, "This root signature is already created"); + VERIFY(m_RegisterSpace == ~0u || m_pd3d12RootSignature == nullptr, "This root signature has already been initialized."); m_RegisterSpace = RegisterSpace; - D3D12_ROOT_SIGNATURE_DESC d3d12RootSignatureDesc = {}; - D3D12_ROOT_PARAMETER d3d12Params = {}; - + D3D12_ROOT_PARAMETER d3d12Params{}; d3d12Params.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; d3d12Params.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; d3d12Params.Constants.Num32BitValues = m_ShaderRecordSize / 4; d3d12Params.Constants.RegisterSpace = m_RegisterSpace; d3d12Params.Constants.ShaderRegister = GetShaderRegister(); + D3D12_ROOT_SIGNATURE_DESC d3d12RootSignatureDesc{}; d3d12RootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE; d3d12RootSignatureDesc.NumParameters = 1; d3d12RootSignatureDesc.pParameters = &d3d12Params; @@ -328,14 +327,14 @@ RootSignatureCacheD3D12::~RootSignatureCacheD3D12() RefCntAutoPtr<RootSignatureD3D12> RootSignatureCacheD3D12::GetRootSig(const RefCntAutoPtr<PipelineResourceSignatureD3D12Impl>* ppSignatures, Uint32 SignatureCount) { size_t Hash = 0; - if (SignatureCount) + if (SignatureCount > 0) { HashCombine(Hash, SignatureCount); for (Uint32 i = 0; i < SignatureCount; ++i) { if (ppSignatures[i] != nullptr) { - VERIFY(ppSignatures[i]->GetDesc().BindingIndex == i, "Signature placed to another binding index"); + VERIFY(ppSignatures[i]->GetDesc().BindingIndex == i, "Signature placed at another binding index"); HashCombine(Hash, ppSignatures[i]->GetHash()); } else diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp index 82b3aa30..caaaa322 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp @@ -52,7 +52,7 @@ ShaderResourceCacheD3D12::MemoryRequirements ShaderResourceCacheD3D12::GetMemory { auto GroupType = static_cast<ROOT_PARAMETER_GROUP>(group); - auto TotalTableResources = RootParams.GetTotalTableSlots(d3d12HeapType, GroupType); + auto TotalTableResources = RootParams.GetParameterGroupSize(d3d12HeapType, GroupType); MemReqs.TotalResources += TotalTableResources; if (TotalTableResources != 0) { @@ -82,7 +82,7 @@ ShaderResourceCacheD3D12::MemoryRequirements ShaderResourceCacheD3D12::GetMemory // m_pMemory | m_pResources, m_NumResources | // | | | // V | V -// | RootTable[0] | .... | RootTable[Nrt-1] | Res[0] | ... | Res[n-1] | .... | Res[0] | ... | Res[m-1] | +// | RootTable[0] | .... | RootTable[Nrt-1] | Res[0] | ... | Res[n-1] | .... | Res[0] | ... | Res[m-1] | DescriptorHeapAllocation[0] | ... // | A // | | // |________________________________________________| @@ -123,7 +123,10 @@ void ShaderResourceCacheD3D12::Initialize(IMemoryAllocator& MemAllocator, Uint32 NumTables, const Uint32 TableSizes[]) { - DEV_CHECK_ERR(NumTables < MaxRootTables, "The number of root tables (", NumTables, ") exceeds maximum allowed value (", MaxRootTables, ")."); + VERIFY(GetContentType() == CacheContentType::Signature, + "This method should be called to initialize the cache to store resources of a pipeline resource signature"); + + DEV_CHECK_ERR(NumTables <= MaxRootTables, "The number of root tables (", NumTables, ") exceeds maximum allowed value (", MaxRootTables, ")."); m_NumTables = static_cast<decltype(m_NumTables)>(NumTables); VERIFY_EXPR(m_NumTables == NumTables); @@ -149,9 +152,12 @@ void ShaderResourceCacheD3D12::Initialize(IMemoryAllocator& MemAllocator, RenderDeviceD3D12Impl* pDevice, const RootParamsManager& RootParams) { + VERIFY(GetContentType() == CacheContentType::SRB, + "This method should be called to initialize the cache to store resources of an SRB"); + const auto MemReq = GetMemoryRequirements(RootParams); - DEV_CHECK_ERR(MemReq.NumTables < MaxRootTables, "The number of root tables (", MemReq.NumTables, ") exceeds maximum allowed value (", MaxRootTables, ")."); + DEV_CHECK_ERR(MemReq.NumTables <= MaxRootTables, "The number of root tables (", MemReq.NumTables, ") exceeds maximum allowed value (", MaxRootTables, ")."); m_NumTables = static_cast<decltype(m_NumTables)>(MemReq.NumTables); VERIFY_EXPR(m_NumTables == MemReq.NumTables); @@ -230,10 +236,11 @@ void ShaderResourceCacheD3D12::Initialize(IMemoryAllocator& MemAllocator, { auto GroupType = static_cast<ROOT_PARAMETER_GROUP>(group); - auto TotalTableResources = RootParams.GetTotalTableSlots(d3d12HeapType, GroupType); + auto TotalTableResources = RootParams.GetParameterGroupSize(d3d12HeapType, GroupType); auto& AllocationIndex = m_AllocationIndex[d3d12HeapType][GroupType]; if (TotalTableResources != 0) { + VERIFY_EXPR(AllocationIndex == -1); AllocationIndex = static_cast<Int8>(AllocationCount++); auto& Allocation = m_DescriptorAllocations[AllocationIndex]; VERIFY_EXPR(Allocation.IsNull()); @@ -404,8 +411,8 @@ void ShaderResourceCacheD3D12::DbgValidateDynamicBuffersMask() const } else { - VERIFY((m_DynamicRootBuffersMask & DynamicBufferBit) == 0, "Bit must not be set when there are no buffer."); - VERIFY((m_NonDynamicRootBuffersMask & DynamicBufferBit) == 0, "Bit must not be set when there are no buffer."); + VERIFY((m_DynamicRootBuffersMask & DynamicBufferBit) == 0, "Bit must not be set when there is no buffer."); + VERIFY((m_NonDynamicRootBuffersMask & DynamicBufferBit) == 0, "Bit must not be set when there is no buffer."); } } else @@ -484,7 +491,11 @@ void ShaderResourceCacheD3D12::Resource::TransitionResource(CommandContext& Ctx) { auto* pTlasD3D12 = pObject.RawPtr<TopLevelASD3D12Impl>(); if (pTlasD3D12->IsInKnownState()) + { + // We must always call TransitionResource() even when the state is already + // RESOURCE_STATE_RAY_TRACING because it is treated as UAV Ctx.TransitionResource(*pTlasD3D12, RESOURCE_STATE_RAY_TRACING); + } } break; |
