yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// d3d12-transient-heap.h 2#pragma once 3 4#include "d3d12-base.h" 5 6namespace gfx 7{ 8namespace d3d12 9{ 10 11using namespace Slang ; 12 13class TransientResourceHeapImpl 14 :public TransientResourceHeapBaseImpl < DeviceImpl ,BufferResourceImpl > , 15public ITransientResourceHeapD3D12 16{ 17private : 18typedef TransientResourceHeapBaseImpl < DeviceImpl ,BufferResourceImpl > Super ; 19 20public : 21ComPtr < ID3D12CommandAllocator > m_commandAllocator ; 22List < ComPtr < ID3D12GraphicsCommandList >>m_d3dCommandListPool ; 23List < RefPtr < RefObject >>m_commandBufferPool ; 24uint32_t m_commandListAllocId = 0 ; 25// Wait values for each command queue. 26struct QueueWaitInfo 27 { 28uint64_t waitValue ; 29HANDLE fenceEvent ; 30ComPtr < ID3D12CommandQueue > queue ; 31ComPtr < ID3D12Fence > fence = nullptr; 32 }; 33ShortList < QueueWaitInfo ,4 > m_waitInfos ; 34ShortList < HANDLE ,4 > m_waitHandles ; 35 36QueueWaitInfo & getQueueWaitInfo (uint32_t queueIndex ); 37// During command submission, we need all the descriptor tables that get 38// used to come from a single heap (for each descriptor heap type). 39// 40// We will thus keep a single heap of each type that we hope will hold 41// all the descriptors that actually get needed in a frame. 42ShortList < D3D12DescriptorHeap ,4 > m_viewHeaps ;// Cbv, Srv, Uav 43ShortList < D3D12DescriptorHeap ,4 > m_samplerHeaps ;// Heap for samplers 44int32_t m_currentViewHeapIndex = -1 ; 45int32_t m_currentSamplerHeapIndex = -1 ; 46bool m_canResize = false; 47 48uint32_t m_viewHeapSize ; 49uint32_t m_samplerHeapSize ; 50 51D3D12DescriptorHeap & getCurrentViewHeap (); 52D3D12DescriptorHeap & getCurrentSamplerHeap (); 53 54D3D12LinearExpandingDescriptorHeap m_stagingCpuViewHeap ; 55D3D12LinearExpandingDescriptorHeap m_stagingCpuSamplerHeap ; 56 57virtual SLANG_NO_THROW Result SLANG_MCALL 58queryInterface (SlangUUID const & uuid ,void ** outObject )override ; 59 60virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef ()override {return Super ::addRef (); } 61virtual SLANG_NO_THROW uint32_t SLANG_MCALL release ()override {return Super ::release (); } 62 63virtual SLANG_NO_THROW Result SLANG_MCALL allocateTransientDescriptorTable ( 64DescriptorType type , 65GfxCount count , 66Offset & outDescriptorOffset , 67void ** outD3DDescriptorHeapHandle )override ; 68 69 ~TransientResourceHeapImpl (); 70 71bool canResize () {return m_canResize ; } 72 73Result init ( 74const ITransientResourceHeap ::Desc & desc , 75DeviceImpl * device , 76uint32_t viewHeapSize , 77uint32_t samplerHeapSize ); 78 79Result allocateNewViewDescriptorHeap (DeviceImpl * device ); 80 81Result allocateNewSamplerDescriptorHeap (DeviceImpl * device ); 82 83virtual SLANG_NO_THROW Result SLANG_MCALL 84createCommandBuffer (ICommandBuffer ** outCommandBuffer )override ; 85 86Result synchronize (); 87 88virtual SLANG_NO_THROW Result SLANG_MCALL synchronizeAndReset ()override ; 89 90virtual SLANG_NO_THROW Result SLANG_MCALL finish () override; 91}; 92 93} // namespace d3d12 94} // namespace gfx