From aee75043883900a4952767398201066e62e68724 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 20 May 2017 13:12:04 -0700 Subject: Merging Updates from dev branch --- .../GraphicsEngineD3D12/include/BufferD3D12Impl.h | 2 +- .../include/BufferViewD3D12Impl.h | 2 +- .../GraphicsEngineD3D12/include/CommandContext.h | 2 +- .../include/CommandListD3D12Impl.h | 2 +- .../include/CommandListManager.h | 2 +- .../include/D3D12ResourceBase.h | 2 +- .../include/D3D12TypeConversions.h | 2 +- .../include/D3D12TypeDefinitions.h | 2 +- Graphics/GraphicsEngineD3D12/include/D3D12Utils.h | 2 +- .../GraphicsEngineD3D12/include/DescriptorHeap.h | 186 +++------------------ .../include/DeviceContextD3D12Impl.h | 2 +- .../include/DynamicUploadHeap.h | 2 +- .../GraphicsEngineD3D12/include/GenerateMips.h | 2 +- .../include/PipelineStateD3D12Impl.h | 2 +- .../include/RenderDeviceD3D12Impl.h | 2 +- .../GraphicsEngineD3D12/include/RootSignature.h | 2 +- .../GraphicsEngineD3D12/include/SamplerD3D12Impl.h | 2 +- .../GraphicsEngineD3D12/include/ShaderD3D12Impl.h | 2 +- .../include/ShaderResourceBindingD3D12Impl.h | 2 +- .../include/ShaderResourceCacheD3D12.h | 2 +- .../include/ShaderResourceLayoutD3D12.h | 2 +- .../include/ShaderResourcesD3D12.h | 2 +- .../include/SwapChainD3D12Impl.h | 2 +- .../GraphicsEngineD3D12/include/TextureD3D12Impl.h | 2 +- .../include/TextureViewD3D12Impl.h | 2 +- Graphics/GraphicsEngineD3D12/include/pch.h | 2 +- .../GraphicsEngineD3D12/interface/BufferD3D12.h | 2 +- .../interface/BufferViewD3D12.h | 2 +- .../interface/PipelineStateD3D12.h | 2 +- .../interface/RenderDeviceD3D12.h | 2 +- .../interface/RenderDeviceFactoryD3D12.h | 2 +- .../GraphicsEngineD3D12/interface/SamplerD3D12.h | 2 +- .../GraphicsEngineD3D12/interface/ShaderD3D12.h | 2 +- .../interface/ShaderResourceBindingD3D12.h | 2 +- .../GraphicsEngineD3D12/interface/SwapChainD3D12.h | 2 +- .../GraphicsEngineD3D12/interface/TextureD3D12.h | 2 +- .../interface/TextureViewD3D12.h | 2 +- .../GraphicsEngineD3D12/src/BufferD3D12Impl.cpp | 2 +- .../src/BufferViewD3D12Impl.cpp | 2 +- .../GraphicsEngineD3D12/src/CommandContext.cpp | 2 +- .../GraphicsEngineD3D12/src/CommandListManager.cpp | 2 +- .../GraphicsEngineD3D12/src/D3D12ResourceBase.cpp | 2 +- .../src/D3D12TypeConversions.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/DLLMain.cpp | 2 +- .../GraphicsEngineD3D12/src/DescriptorHeap.cpp | 69 ++------ .../src/DeviceContextD3D12Impl.cpp | 2 +- .../GraphicsEngineD3D12/src/DynamicUploadHeap.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp | 2 +- .../src/PipelineStateD3D12Impl.cpp | 2 +- .../src/RenderDeviceD3D12Impl.cpp | 2 +- .../src/RenderDeviceFactoryD3D12.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/RootSignature.cpp | 2 +- .../GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp | 2 +- .../GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp | 2 +- .../src/ShaderResourceBindingD3D12Impl.cpp | 2 +- .../src/ShaderResourceCacheD3D12.cpp | 2 +- .../src/ShaderResourceLayoutD3D12.cpp | 2 +- .../src/ShaderResourcesD3D12.cpp | 2 +- .../GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 2 +- .../GraphicsEngineD3D12/src/TextureD3D12Impl.cpp | 2 +- .../src/TextureViewD3D12Impl.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/pch.cpp | 2 +- 63 files changed, 98 insertions(+), 279 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h index 15406bc8..9ee4e25d 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h index 743be25c..f5aff0ab 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.h b/Graphics/GraphicsEngineD3D12/include/CommandContext.h index d1512b62..755e8076 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandContext.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h index e73e36d1..00e5fcaa 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListManager.h b/Graphics/GraphicsEngineD3D12/include/CommandListManager.h index 9b0faa4f..a9b79650 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandListManager.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandListManager.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/D3D12ResourceBase.h b/Graphics/GraphicsEngineD3D12/include/D3D12ResourceBase.h index 84629c48..e8faa4a3 100644 --- a/Graphics/GraphicsEngineD3D12/include/D3D12ResourceBase.h +++ b/Graphics/GraphicsEngineD3D12/include/D3D12ResourceBase.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/D3D12TypeConversions.h b/Graphics/GraphicsEngineD3D12/include/D3D12TypeConversions.h index d8741573..d909bd42 100644 --- a/Graphics/GraphicsEngineD3D12/include/D3D12TypeConversions.h +++ b/Graphics/GraphicsEngineD3D12/include/D3D12TypeConversions.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/D3D12TypeDefinitions.h b/Graphics/GraphicsEngineD3D12/include/D3D12TypeDefinitions.h index 761f750b..892de4aa 100644 --- a/Graphics/GraphicsEngineD3D12/include/D3D12TypeDefinitions.h +++ b/Graphics/GraphicsEngineD3D12/include/D3D12TypeDefinitions.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/D3D12Utils.h b/Graphics/GraphicsEngineD3D12/include/D3D12Utils.h index 13dbd204..64ee7c40 100644 --- a/Graphics/GraphicsEngineD3D12/include/D3D12Utils.h +++ b/Graphics/GraphicsEngineD3D12/include/D3D12Utils.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h b/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h index 91c27495..4c4400ca 100644 --- a/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h +++ b/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,18 +47,9 @@ public: virtual Uint32 GetDescriptorSize()const = 0; }; -// The class represents descriptor heap allocation (continuous descriptor range in a descriptor heap) -// -// m_FirstCpuHandle -// | -// | ~ ~ ~ ~ ~ X X X X X X X ~ ~ ~ ~ ~ ~ | D3D12 Descriptor Heap -// | -// m_FirstGpuHandle -// class DescriptorHeapAllocation { public: - // Creates null allocation DescriptorHeapAllocation() : m_NumHandles(1), // One null descriptor handle m_pDescriptorHeap(nullptr), @@ -68,13 +59,20 @@ public: m_FirstGpuHandle.ptr = 0; } - // Initializes non-null allocation - DescriptorHeapAllocation( IDescriptorAllocator *pAllocator, - ID3D12DescriptorHeap *pHeap, - D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle, - D3D12_GPU_DESCRIPTOR_HANDLE GpuHandle, - Uint32 NHandles, - Uint16 AllocationManagerId = static_cast(-1) ) : + DescriptorHeapAllocation( IDescriptorAllocator *pAllocator, ID3D12DescriptorHeap *pHeap, D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle, Uint32 NHandles ) : + m_FirstCpuHandle(CpuHandle), + m_pAllocator(pAllocator), + m_pDescriptorHeap(pHeap), + m_NumHandles(NHandles) + { + m_FirstGpuHandle.ptr = 0; + VERIFY_EXPR(m_pAllocator != nullptr && m_pDescriptorHeap != nullptr); + auto DescriptorSize = m_pAllocator->GetDescriptorSize(); + VERIFY(DescriptorSize < std::numeric_limits::max(), "DescriptorSize exceeds allowed limit") + m_DescriptorSize = static_cast( DescriptorSize ); + } + + DescriptorHeapAllocation( IDescriptorAllocator *pAllocator, ID3D12DescriptorHeap *pHeap, D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE GpuHandle, Uint32 NHandles, Uint16 AllocationManagerId = static_cast(-1) ) : m_FirstCpuHandle(CpuHandle), m_FirstGpuHandle(GpuHandle), m_pAllocator(pAllocator), @@ -88,7 +86,6 @@ public: m_DescriptorSize = static_cast( DescriptorSize ); } - // Move constructor (copy is not allowed) DescriptorHeapAllocation(DescriptorHeapAllocation &&Allocation) : m_FirstCpuHandle(Allocation.m_FirstCpuHandle), m_FirstGpuHandle(Allocation.m_FirstGpuHandle), @@ -107,7 +104,6 @@ public: Allocation.m_AllocationManagerId = static_cast(-1); } - // Move assignment (assignment is not allowed) DescriptorHeapAllocation& operator = (DescriptorHeapAllocation &&Allocation) { m_FirstCpuHandle = Allocation.m_FirstCpuHandle; @@ -129,16 +125,12 @@ public: return *this; } - // Destructor automatically releases this allocation through the allocator ~DescriptorHeapAllocation() { if(!IsNull() && m_pAllocator) m_pAllocator->Free(std::move(*this)); - // Allocation must be disposed by the allocator - VERIFY(IsNull(), "Non-null descriptor is being destroyed") } - // Returns CPU descriptor handle at the specified offset D3D12_CPU_DESCRIPTOR_HANDLE GetCpuHandle(Uint32 Offset = 0) const { VERIFY_EXPR(Offset >= 0 && Offset < m_NumHandles); @@ -151,7 +143,6 @@ public: return CPUHandle; } - // Returns GPU descriptor handle at the specified offset D3D12_GPU_DESCRIPTOR_HANDLE GetGpuHandle(Uint32 Offset = 0) const { VERIFY_EXPR(Offset >= 0 && Offset < m_NumHandles); @@ -163,10 +154,9 @@ public: return GPUHandle; } - // Returns pointer to the descriptor heap that contains this allocation ID3D12DescriptorHeap *GetDescriptorHeap(){return m_pDescriptorHeap;} - size_t GetNumHandles()const{return m_NumHandles;} + size_t GetNumHandles(){return m_NumHandles;} bool IsNull() const { return m_FirstCpuHandle.ptr == 0; } bool IsShaderVisible() const { return m_FirstGpuHandle.ptr != 0; } @@ -174,59 +164,29 @@ public: UINT GetDescriptorSize()const{return m_DescriptorSize;} private: - // No copies, only moves are allowed DescriptorHeapAllocation(const DescriptorHeapAllocation&) = delete; DescriptorHeapAllocation& operator= (const DescriptorHeapAllocation&) = delete; - // First CPU descriptor handle in this allocation D3D12_CPU_DESCRIPTOR_HANDLE m_FirstCpuHandle = {0}; - - // First GPU descriptor handle in this allocation D3D12_GPU_DESCRIPTOR_HANDLE m_FirstGpuHandle = {0}; - // Keep strong reference to the parent heap to make sure it is alive while allocation is alive - TOO EXPENSIVE //RefCntAutoPtr m_pAllocator; - - // Pointer to the descriptor heap allocator that created this allocation IDescriptorAllocator* m_pAllocator = nullptr; - - // Pointer to the D3D12 descriptor heap that contains descriptors in this allocation ID3D12DescriptorHeap* m_pDescriptorHeap = nullptr; - - // Number of descriptors in the allocation Uint32 m_NumHandles = 0; - - // Allocation manager ID. One allocator may support several - // allocation managers. This field is required to identify - // the manager within the allocator that was used to create - // this allocation Uint16 m_AllocationManagerId = static_cast(-1); - - // Descriptor size Uint16 m_DescriptorSize = 0; }; -// The class performs suballocations within one D3D12 descriptor heap. -// It uses VariableSizeGPUAllocationsManager to manage free space in the heap -// -// | X X X X O O O X X O O X O O O O | D3D12 descriptor heap -// -// X - used descriptor -// O - available descriptor -// class DescriptorHeapAllocationManager { public: - // Creates a new D3D12 descriptor heap DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, IDescriptorAllocator *pParentAllocator, size_t ThisManagerId, const D3D12_DESCRIPTOR_HEAP_DESC &HeapDesc); - - // Uses subrange of descriptors in the existing D3D12 descriptor heap - // that starts at offset FirstDescriptor and uses NumDescriptors descriptors DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, IDescriptorAllocator *pParentAllocator, @@ -261,78 +221,36 @@ public: rhs.m_ThisManagerId = static_cast(-1); } - // No copies or move-assignments DescriptorHeapAllocationManager& operator = (DescriptorHeapAllocationManager&& rhs) = delete; DescriptorHeapAllocationManager(const DescriptorHeapAllocationManager&) = delete; DescriptorHeapAllocationManager& operator = (const DescriptorHeapAllocationManager&) = delete; ~DescriptorHeapAllocationManager(); - // Allocates Count descriptors DescriptorHeapAllocation Allocate( uint32_t Count ); - - // Releases descriptor heap allocation. - // Note that the allocation is not released immediately, but - // added to the release queue in the allocations manager void Free(DescriptorHeapAllocation&& Allocation); - - // Releases all stale allocation from completed frames void ReleaseStaleAllocations(Uint64 NumCompletedFrames); - size_t GetNumAvailableDescriptors()const{return m_FreeBlockManager.GetFreeSize();} private: - // Allocations manager used to handle descriptor allocations within the heap VariableSizeGPUAllocationsManager m_FreeBlockManager; - - // Heap description D3D12_DESCRIPTOR_HEAP_DESC m_HeapDesc; - - // Strong reference to D3D12 descriptor heap object CComPtr m_pd3d12DescriptorHeap; - - // First CPU descriptor handle in the available descriptor range D3D12_CPU_DESCRIPTOR_HANDLE m_FirstCPUHandle = {0}; - - // First GPU descriptor handle in the available descriptor range D3D12_GPU_DESCRIPTOR_HANDLE m_FirstGPUHandle = {0}; - UINT m_DescriptorSize = 0; - - // Number of descriptors in the allocation. - // If this manager was initialized as a subrange in the existing heap, - // this value may be different from m_HeapDesc.NumDescriptors Uint32 m_NumDescriptorsInAllocation = 0; - std::mutex m_AllocationMutex; RenderDeviceD3D12Impl *m_pDeviceD3D12Impl = nullptr; IDescriptorAllocator *m_pParentAllocator = nullptr; - - // External ID assigned to this descriptor allocations manager size_t m_ThisManagerId = static_cast(-1); }; -// CPU descriptor heap is intended to provide storage for resource view descriptor handles -// It contains a pool of DescriptorHeapAllocationManager object instances, where every instance manages -// its own CPU-only D3D12 descriptor heap: -// -// m_AvailableHeaps[0] m_AvailableHeaps[1] m_AvailableHeaps[2] -// | X X X X X X X X |, | X X X O O X X O |, | X O O O O O O O | -// -// X - used descriptor -// O - available descriptor -// -// Allocation routine goes through the list of managers that have available descriptors and tries to process -// the request using every manager. If there are no available managers or no manager was able to handle the request, -// the function creates a new descriptor heap manager and lets it handle the request -// -// Render device contains four CPUDescriptorHeap object instances (one for each D3D12 heap type). The heaps are accessed -// when a texture or a buffer view is created. -// +// This is an unbounded resource descriptor heap. It is intended to provide space for CPU-visible resource descriptors +// as resources are created as well as for static and mutable shader descriptor tables. class CPUDescriptorHeap : public IDescriptorAllocator { public: - // Initializes the heap CPUDescriptorHeap(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, Uint32 NumDescriptorsInHeap, @@ -354,9 +272,7 @@ public: protected: - // Pool of descriptor heap managers std::vector > m_HeapPool; - // Indices of available descriptor heap managers std::set, STDAllocatorRawMem > m_AvailableHeaps; IMemoryAllocator &m_MemAllocator; @@ -365,51 +281,11 @@ protected: D3D12_DESCRIPTOR_HEAP_DESC m_HeapDesc; UINT m_DescriptorSize; RenderDeviceD3D12Impl *m_pDeviceD3D12Impl; - - // Maximum heap size during the application lifetime - for statistic purposes - Uint32 m_MaxHeapSize = 0; + Uint32 m_MaxHeapSize = 0; Uint32 m_CurrentSize = 0; // This size does not count stale allocation }; -// GPU descriptor heap provides storage for shader-visible descriptors -// The heap contains single D3D12 descriptor heap that is broken into two parts. -// The first part stores static and mutable resource descriptor handles. -// The second part is intended to provide temporary storage for dynamic resources -// Space for dynamic resources is allocated in chunks, and then descriptors are suballocated within every -// chunk. DynamicSuballocationsManager facilitates this process -// -// -// static and mutable handles || dynamic space -// || chunk 0 chunk 1 chunk 2 unused -// | X O O X X O X O O O O X X X X O || | X X X O | | X X O O | | O O O O | O O O O || -// | | -// suballocation suballocation -// within chunk 0 within chunk 1 -// -// Render device contains two GPUDescriptorHeap instances (CBV_SRV_UAV and SAMPLER). The heaps -// are used to allocate GPU-visible descriptors for shader resource binding objects. The heaps -// are also used by command contexts (through DynamicSuballocationsManager to allocated dynamic descriptors) -// -// _______________________________________________________________________________________________________________________________ -// | Render Device | -// | | -// | m_CPUDescriptorHeaps[CBV_SRV_UAV] | X X X X X X X X |, | X X X X X X X X |, | X O O X O O O O | | -// | m_CPUDescriptorHeaps[SAMPLER] | X X X X O O O X |, | X O O X O O O O | | -// | m_CPUDescriptorHeaps[RTV] | X X X O O O O O |, | O O O O O O O O | | -// | m_CPUDescriptorHeaps[DSV] | X X X O X O X O | | -// | ctx1 ctx2 | -// | m_GPUDescriptorHeaps[CBV_SRV_UAV] | X O O X X O X O O O O X X X X O || | X X X O | | X X O O | | O O O O | O O O O || | -// | m_GPUDescriptorHeaps[SAMPLER] | X X O O X O X X X O O X O O O O || | X X O O | | X O O O | | O O O O | O O O O || | -// | | -// |_______________________________________________________________________________________________________________________________| -// -// ________________________________________________ ________________________________________________ -// |Device Context 1 | |Device Context 2 | -// | | | | -// | m_DynamicGPUDescriptorAllocator[CBV_SRV_UAV] | | m_DynamicGPUDescriptorAllocator[CBV_SRV_UAV] | -// | m_DynamicGPUDescriptorAllocator[SAMPLER] | | m_DynamicGPUDescriptorAllocator[SAMPLER] | -// |________________________________________________| |________________________________________________| -// + class GPUDescriptorHeap : public IDescriptorAllocator { public: @@ -435,42 +311,29 @@ public: void ReleaseStaleAllocations(Uint64 NumCompletedFrames); - const D3D12_DESCRIPTOR_HEAP_DESC &GetHeapDesc()const{return m_HeapDesc;} + D3D12_DESCRIPTOR_HEAP_DESC &GetHeapDesc(){return m_HeapDesc;} protected: D3D12_DESCRIPTOR_HEAP_DESC m_HeapDesc; CComPtr m_pd3d12DescriptorHeap; + UINT m_DescriptorSize = 0; - std::mutex m_AllocMutex, m_DynAllocMutex; - // Allocation manager for static/mutable part + std::mutex m_Mutex; DescriptorHeapAllocationManager m_HeapAllocationManager; - - // Allocation manager for dynamic part DescriptorHeapAllocationManager m_DynamicAllocationsManager; RenderDeviceD3D12Impl *m_pDeviceD3D12; Uint32 m_CurrentSize = 0; - // Maximum static/mutable part size during the application lifetime - for statistic purposes Uint32 m_MaxHeapSize = 0; Uint32 m_CurrentDynamicSize = 0; - // Maximum dynamic part size during the application lifetime - for statistic purposes Uint32 m_MaxDynamicSize = 0; }; -// The class facilitates allocation of dynamic descriptor handles. It requests a chunk of heap -// from the master GPU descriptor heap and then performs linear suballocation within the chunk -// At the end of the frame all allocations are disposed. -// static and mutable handles || dynamic space -// || chunk 0 chunk 2 -// | || | X X X O | | O O O O | || GPU Descriptor Heap -// | | -// m_Suballocations[0] m_Suballocations[1] -// class DynamicSuballocationsManager : public IDescriptorAllocator { public: @@ -489,14 +352,11 @@ public: virtual Uint32 GetDescriptorSize()const override{return m_ParentGPUHeap.GetDescriptorSize();} private: - // List of chunks allocated from the master GPU descriptor heap. All chunks are disposed at the end - // of the frame std::vector > m_Suballocations; Uint32 m_CurrentSuballocationOffset = 0; Uint32 m_DynamicChunkSize = 0; - // Parent GPU descriptor heap that is used to allocate chunks GPUDescriptorHeap &m_ParentGPUHeap; }; diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index 14555715..ffe8598a 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h b/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h index 56b17284..6adefccf 100644 --- a/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h +++ b/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h index 109858a9..22e81589 100644 --- a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h +++ b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h index 84e2fb09..1ac6564f 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h index db601579..0294a8b8 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.h b/Graphics/GraphicsEngineD3D12/include/RootSignature.h index eb2a20ba..750b2b9d 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootSignature.h +++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h index fc920441..11226b64 100644 --- a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h index 79ef7fec..b39c70d6 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h index b5824b17..025db186 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h index 601e28e1..aed6d32e 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h index b29e7ea4..90d1ba27 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h index 940a1350..f58ce20d 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h index 197ccd68..e7e8f312 100644 --- a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h index 3bee0851..039de70f 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h index e07446a5..6256ca0a 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/include/pch.h b/Graphics/GraphicsEngineD3D12/include/pch.h index 225f72b4..f2f0b7f4 100644 --- a/Graphics/GraphicsEngineD3D12/include/pch.h +++ b/Graphics/GraphicsEngineD3D12/include/pch.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h b/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h index 823965a9..f3e69a13 100644 --- a/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h b/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h index a388e4c6..7d9e45c9 100644 --- a/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h b/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h index e978c014..c31ea4cc 100644 --- a/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h index 3d37c0a8..309d355e 100644 --- a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h index 2a81cf76..f3aa45f4 100644 --- a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h b/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h index f8d98e69..4359fdc5 100644 --- a/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h b/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h index c8bca697..50aa22aa 100644 --- a/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h b/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h index 27162053..6038b88b 100644 --- a/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h index ab936019..eacc0ef4 100644 --- a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h b/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h index 449f2692..2fe585ce 100644 --- a/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h b/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h index f9c83a61..967d28a1 100644 --- a/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index 4d9ef799..1a516ad3 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp index f0f7b2d7..e27c91ea 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp index 72531286..932eb333 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/CommandListManager.cpp b/Graphics/GraphicsEngineD3D12/src/CommandListManager.cpp index 77c72d08..8ffc64ce 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandListManager.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandListManager.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12ResourceBase.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12ResourceBase.cpp index 0744fda7..b2e9f431 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12ResourceBase.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12ResourceBase.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp index 68082795..738fbc98 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp index c2428e16..a1f82e1c 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/DLLMain.cpp b/Graphics/GraphicsEngineD3D12/src/DLLMain.cpp index 94065164..fff890c0 100644 --- a/Graphics/GraphicsEngineD3D12/src/DLLMain.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DLLMain.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp index 7ba3d2bc..a8ea6756 100644 --- a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ namespace Diligent { -// Creates a new descriptor heap and reference the entire heap + DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, IDescriptorAllocator *pParentAllocator, @@ -54,8 +54,6 @@ DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocato m_FirstGPUHandle = m_pd3d12DescriptorHeap->GetGPUDescriptorHandleForHeapStart(); } -// Uses subrange of descriptors in the existing D3D12 descriptor heap -// that starts at offset FirstDescriptor and uses NumDescriptors descriptors DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, IDescriptorAllocator *pParentAllocator, @@ -92,47 +90,39 @@ DescriptorHeapAllocationManager::~DescriptorHeapAllocationManager() DescriptorHeapAllocation DescriptorHeapAllocationManager::Allocate(uint32_t Count) { std::lock_guard LockGuard(m_AllocationMutex); - // Methods of VariableSizeGPUAllocationsManager class are not thread safe! - // Use variable-size GPU allocations manager to allocate the requested number of descriptors auto DescriptorHandleOffset = m_FreeBlockManager.Allocate(Count); if (DescriptorHandleOffset == VariableSizeGPUAllocationsManager::InvalidOffset) { return DescriptorHeapAllocation(); } - // 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; - auto GPUHandle = m_FirstGPUHandle; // Will be null if the heap is not GPU-visible + auto GPUHandle = m_FirstGPUHandle; if(m_HeapDesc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE) GPUHandle.ptr += DescriptorHandleOffset * m_DescriptorSize; - VERIFY(m_ThisManagerId < std::numeric_limits::max(), "ManagerID exceeds 16-bit range"); - return DescriptorHeapAllocation( m_pParentAllocator, m_pd3d12DescriptorHeap, CPUHandle, GPUHandle, Count, static_cast(m_ThisManagerId)); + VERIFY(m_ThisManagerId < std::numeric_limits::max(), "ManagerID exceed allowed limit"); + DescriptorHeapAllocation Allocation( m_pParentAllocator, m_pd3d12DescriptorHeap, CPUHandle, GPUHandle, Count, static_cast(m_ThisManagerId)); + + return Allocation; } void DescriptorHeapAllocationManager::Free(DescriptorHeapAllocation&& Allocation) { std::lock_guard LockGuard(m_AllocationMutex); - // Methods of VariableSizeGPUAllocationsManager class are not thread safe! VERIFY(Allocation.GetAllocationManagerId() == m_ThisManagerId, "Invalid descriptor heap manager Id") auto DescriptorOffset = (Allocation.GetCpuHandle().ptr - m_FirstCPUHandle.ptr) / m_DescriptorSize; - // Note that the allocation is not released immediately, but added to the release queue in the allocations manager m_FreeBlockManager.Free(DescriptorOffset, Allocation.GetNumHandles(), m_pDeviceD3D12Impl->GetCurrentFrame()); - // Clear the allocation Allocation = DescriptorHeapAllocation(); } void DescriptorHeapAllocationManager::ReleaseStaleAllocations(Uint64 NumCompletedFrames) { - std::lock_guard LockGuard(m_AllocationMutex); - // Methods of VariableSizeGPUAllocationsManager class are not thread safe! - m_FreeBlockManager.ReleaseCompletedFrames(NumCompletedFrames); } @@ -173,37 +163,21 @@ DescriptorHeapAllocation CPUDescriptorHeap::Allocate( uint32_t Count ) { std::lock_guard LockGuard(m_AllocationMutex); DescriptorHeapAllocation Allocation; - // Go through all descriptor heap managers that have free descriptors for (auto AvailableHeapIt = m_AvailableHeaps.begin(); AvailableHeapIt != m_AvailableHeaps.end(); ++AvailableHeapIt) { - // Try to allocate descriptor using the current descriptor heap manager Allocation = m_HeapPool[*AvailableHeapIt].Allocate(Count); - // Remove the manager from the pool if it has no more available descriptors if(m_HeapPool[*AvailableHeapIt].GetNumAvailableDescriptors() == 0) m_AvailableHeaps.erase(*AvailableHeapIt); - // Terminate the loop if descriptor was successfully allocated, otherwise - // go to the next manager if(Allocation.GetCpuHandle().ptr != 0) break; } - // If there were no available descriptor heap managers or no manager was able - // to suffice the allocation request, create a new manager if(Allocation.GetCpuHandle().ptr == 0) { - // Make sure the heap is large enough to accomodate the requested number of descriptors - if(Count > m_HeapDesc.NumDescriptors) - { - LOG_WARNING_MESSAGE("Number of requested descriptors exceeds the descriptor heap size. Increasing the number of descriptors in the heap") - } - m_HeapDesc.NumDescriptors = std::max(m_HeapDesc.NumDescriptors, static_cast(Count)); - // Create a new descriptor heap manager. Note that this constructor creates a new D3D12 descriptor - // heap and references the entire heap. Pool index is used as manager ID m_HeapPool.emplace_back(m_MemAllocator, m_pDeviceD3D12Impl, this, m_HeapPool.size(), m_HeapDesc); auto NewHeapIt = m_AvailableHeaps.insert(m_HeapPool.size()-1); - // Use the new manager to allocate descriptor handles Allocation = m_HeapPool[*NewHeapIt.first].Allocate(Count); } @@ -227,7 +201,6 @@ void CPUDescriptorHeap::ReleaseStaleAllocations(Uint64 NumCompletedFrames) for (size_t HeapManagerInd = 0; HeapManagerInd < m_HeapPool.size(); ++HeapManagerInd) { m_HeapPool[HeapManagerInd].ReleaseStaleAllocations(NumCompletedFrames); - // Return the manager to the pool of available managers if it has available descriptors if(m_HeapPool[HeapManagerInd].GetNumAvailableDescriptors() > 0) m_AvailableHeaps.insert(HeapManagerInd); } @@ -268,7 +241,7 @@ GPUDescriptorHeap::~GPUDescriptorHeap() DescriptorHeapAllocation GPUDescriptorHeap::Allocate(uint32_t Count) { - std::lock_guard LockGuard(m_AllocMutex); + std::lock_guard LockGuard(m_Mutex); DescriptorHeapAllocation Allocation = m_HeapAllocationManager.Allocate(Count); m_CurrentSize += (Allocation.GetCpuHandle().ptr != 0) ? Count : 0; @@ -279,7 +252,7 @@ DescriptorHeapAllocation GPUDescriptorHeap::Allocate(uint32_t Count) DescriptorHeapAllocation GPUDescriptorHeap::AllocateDynamic(uint32_t Count) { - std::lock_guard LockGuard(m_DynAllocMutex); + std::lock_guard LockGuard(m_Mutex); DescriptorHeapAllocation Allocation = m_DynamicAllocationsManager.Allocate(Count); m_CurrentDynamicSize += (Allocation.GetCpuHandle().ptr != 0) ? Count : 0; @@ -293,15 +266,15 @@ void GPUDescriptorHeap::Free(DescriptorHeapAllocation&& Allocation) auto MgrId = Allocation.GetAllocationManagerId(); VERIFY(MgrId == 0 || MgrId == 1, "Unexpected allocation manager ID"); + std::lock_guard LockGuard(m_Mutex); + if(MgrId == 0) { - std::lock_guard LockGuard(m_AllocMutex); m_CurrentSize -= static_cast(Allocation.GetNumHandles()); m_HeapAllocationManager.Free(std::move(Allocation)); } else { - std::lock_guard LockGuard(m_DynAllocMutex); m_CurrentDynamicSize -= static_cast(Allocation.GetNumHandles()); m_DynamicAllocationsManager.Free(std::move(Allocation)); } @@ -309,15 +282,8 @@ void GPUDescriptorHeap::Free(DescriptorHeapAllocation&& Allocation) void GPUDescriptorHeap::ReleaseStaleAllocations(Uint64 NumCompletedFrames) { - { - std::lock_guard LockGuard(m_AllocMutex); - m_HeapAllocationManager.ReleaseStaleAllocations(NumCompletedFrames); - } - - { - std::lock_guard LockGuard(m_DynAllocMutex); - m_DynamicAllocationsManager.ReleaseStaleAllocations(NumCompletedFrames); - } + m_HeapAllocationManager.ReleaseStaleAllocations(NumCompletedFrames); + m_DynamicAllocationsManager.ReleaseStaleAllocations(NumCompletedFrames); } @@ -333,20 +299,14 @@ DynamicSuballocationsManager::DynamicSuballocationsManager(IMemoryAllocator &All void DynamicSuballocationsManager::DiscardAllocations(Uint64 FrameNumber) { - // Clear the list and dispose all allocated chunks of GPU descriptor heap. m_Suballocations.clear(); } DescriptorHeapAllocation DynamicSuballocationsManager::Allocate(Uint32 Count) { - // This method is intentionally lock-free as it is expected to - // be called through device context from single thread only - - // Check if there are no chunks or the last chunk does not have enough space if( m_Suballocations.empty() || m_CurrentSuballocationOffset + Count > m_Suballocations.back().GetNumHandles() ) { - // Request a new chunk from the GPU descriptor heap auto SuballocationSize = std::max(m_DynamicChunkSize, Count); auto NewDynamicSubAllocation = m_ParentGPUHeap.AllocateDynamic(SuballocationSize); if (NewDynamicSubAllocation.GetCpuHandle().ptr == 0) @@ -358,7 +318,6 @@ DescriptorHeapAllocation DynamicSuballocationsManager::Allocate(Uint32 Count) m_CurrentSuballocationOffset = 0; } - // Perform suballocation from the last chunk auto &CurrentSuballocation = m_Suballocations.back(); auto ManagerId = CurrentSuballocation.GetAllocationManagerId(); @@ -376,7 +335,7 @@ DescriptorHeapAllocation DynamicSuballocationsManager::Allocate(Uint32 Count) void DynamicSuballocationsManager::Free(DescriptorHeapAllocation&& Allocation) { - // Do nothing. Dynamic allocations are not disposed individually, but as whole chunks at the end of the frame + // Do nothing Allocation = DescriptorHeapAllocation(); } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 258e6ebf..5ebfb4b4 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp b/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp index 292957cb..c747a731 100644 --- a/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp index 5ef672d4..1784a89c 100644 --- a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp +++ b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp index d52c3383..c2ed2d83 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index c2576e8f..51c89306 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp index 17ce22ae..762e8a03 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp index 3fc4f814..2cecfdac 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp index 0d443e85..e6e95bac 100644 --- a/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index 84a4df8e..fd43fa49 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp index 6287695e..118707a2 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp index 25eefe9e..700b49b5 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp index c870b5f0..924131e4 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp index c42f663e..e7543ce6 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 2e42ca44..dad6639f 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 8361421f..d5ce27d7 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp index 57749298..0b93926b 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsEngineD3D12/src/pch.cpp b/Graphics/GraphicsEngineD3D12/src/pch.cpp index d5f45c6a..997e0f4a 100644 --- a/Graphics/GraphicsEngineD3D12/src/pch.cpp +++ b/Graphics/GraphicsEngineD3D12/src/pch.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3