From 41c249a537f8f793ec7193c0d70c5e58599d63d7 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 6 Oct 2018 16:03:25 -0700 Subject: Added VariableSizeAllocationsManager::Allocation::IsValid() method for clearer implementation --- Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp index c7bd6272..d17e88a0 100644 --- a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp @@ -98,22 +98,19 @@ DescriptorHeapAllocation DescriptorHeapAllocationManager::Allocate(uint32_t Coun // Use variable-size GPU allocations manager to allocate the requested number of descriptors auto Allocation = m_FreeBlockManager.Allocate(Count, 1); - auto DescriptorHandleOffset = Allocation.UnalignedOffset; - if (DescriptorHandleOffset == VariableSizeAllocationsManager::InvalidOffset) - { + if (!Allocation.IsValid()) return DescriptorHeapAllocation{}; - } VERIFY_EXPR(Allocation.Size == Count); // Compute the first CPU and GPU descriptor handles in the allocation by // offseting the first CPU and GPU descriptor handle in the range auto CPUHandle = m_FirstCPUHandle; - CPUHandle.ptr += DescriptorHandleOffset * m_DescriptorSize; + CPUHandle.ptr += Allocation.UnalignedOffset * m_DescriptorSize; auto GPUHandle = m_FirstGPUHandle; // Will be null if the heap is not GPU-visible if (m_HeapDesc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE) - GPUHandle.ptr += DescriptorHandleOffset * m_DescriptorSize; + GPUHandle.ptr += Allocation.UnalignedOffset * m_DescriptorSize; m_MaxAllocatedSize = std::max(m_MaxAllocatedSize, m_FreeBlockManager.GetUsedSize()); -- cgit v1.2.3