-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Changes: add: generic compute pipeline add: compute pass support Modules: D3D12RenderSystem
- Loading branch information
1 parent
68e1612
commit b314aab
Showing
33 changed files
with
2,422 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#pragma once | ||
#include "Generic/ComputePool.h" | ||
#include "Log/Log.h" | ||
|
||
#include "D3D12/D3D12Core.h" | ||
#include "D3D12/D3D12ScopedPipeline.h" | ||
#include "D3D12/D3D12Drawable.h" | ||
#include "D3D12/D3D12ScopedBuffer.h" | ||
#include "D3D12/D3D12ScopedCommandBuffer.h" | ||
#include "D3D12/D3D12ScopedImage.h" | ||
#include "D3D12/D3D12ScopedSampler.h" | ||
#include "D3D12/D3D12ScopedComputePass.h" | ||
|
||
|
||
namespace Azura { | ||
namespace D3D12 { | ||
|
||
struct D3D12ComputePassRecordEntry | ||
{ | ||
ID3D12PipelineState* m_pso; | ||
ID3D12GraphicsCommandList* m_bundle; | ||
U32 m_poolIdx; | ||
}; | ||
|
||
class D3D12ComputePool : public ComputePool { | ||
|
||
public: | ||
D3D12ComputePool(const Microsoft::WRL::ComPtr<ID3D12Device>& device, | ||
const ComputePoolCreateInfo& createInfo, | ||
const DescriptorCount& descriptorCount, | ||
const Containers::Vector<DescriptorSlot>& descriptorSlots, | ||
const Containers::Vector<D3D12ScopedShader>& shaders, | ||
const Containers::Vector<D3D12ScopedComputePass>& renderPasses, | ||
Microsoft::WRL::ComPtr<ID3D12CommandQueue> commandQueue, | ||
Memory::Allocator& mainAllocator, | ||
Memory::Allocator& initAllocator, | ||
Log log); | ||
|
||
void AddShader(U32 shaderId) override; | ||
void BindTextureData(SlotID slot, const TextureDesc& desc, const U8* buffer) override; | ||
void BindSampler(SlotID slot, const SamplerDesc& desc) override; | ||
void BindUniformData(SlotID slot, const U8* buffer, U32 size) override; | ||
void Submit() override; | ||
void Record(); | ||
|
||
void BeginUpdates() override; | ||
void UpdateUniformData(SlotID slot, const U8* buffer, U32 size) override; | ||
void UpdateTextureData(SlotID slot, const U8* buffer) override; | ||
void SubmitUpdates() override; | ||
|
||
const Containers::Vector<ID3D12DescriptorHeap*>& GetAllDescriptorHeaps() const; | ||
ID3D12PipelineState* GetPipelineState(U32 renderPassId) const; | ||
|
||
void GetRecordEntries(Containers::Vector<std::pair<U32, D3D12ComputePassRecordEntry>>& recordList) const; | ||
|
||
ID3D12GraphicsCommandList* GetSecondaryCommandList(U32 renderPassId) const; | ||
|
||
private: | ||
void CreateRenderPassReferences(const ComputePoolCreateInfo& createInfo, const Containers::Vector<D3D12ScopedComputePass>& renderPasses); | ||
void CreateDescriptorHeap(); | ||
|
||
void SetTextureData(ID3D12GraphicsCommandList* oneTimeCommandList); | ||
void SetSamplerData(); | ||
|
||
void CreateComputePassInputTargetSRV(const Containers::Vector<std::reference_wrapper<D3D12ScopedImage>>& renderPassInputs, U32 offsetTillThis) const; | ||
void CreateComputePassInputTargetUAV( | ||
const Containers::Vector<std::reference_wrapper<D3D12ScopedImage>>& computePassOutputs, | ||
U32 offsetTillThis) const; | ||
|
||
Log log_D3D12RenderSystem; | ||
|
||
const Microsoft::WRL::ComPtr<ID3D12Device>& m_device; | ||
const Containers::Vector<DescriptorSlot>& m_globalDescriptorSlots; | ||
const Containers::Vector<D3D12ScopedShader>& m_shaders; | ||
|
||
Containers::Vector<D3D12ScopedPipeline> m_pipelines; | ||
|
||
Containers::Vector<std::reference_wrapper<D3D12ScopedComputePass>> m_computePasses; | ||
|
||
Microsoft::WRL::ComPtr<ID3D12CommandQueue> m_graphicsCommandQueue; | ||
|
||
D3D12PipelineFactory m_pipelineFactory; | ||
D3D12ScopedBuffer m_updateBuffer; | ||
D3D12ScopedBuffer m_stagingBuffer; | ||
D3D12ScopedBuffer m_mainBuffer; | ||
|
||
U32 m_cbvSrvDescriptorElementSize{0}; | ||
U32 m_samplerDescriptorElementSize{0}; | ||
U32 m_offsetToConstantBuffers{0}; | ||
U32 m_offsetToComputePassInputs{0}; | ||
U32 m_offsetToComputePassOutputs{0}; | ||
|
||
Containers::Vector<D3D12ScopedImage> m_images; | ||
Containers::Vector<D3D12ScopedSampler> m_samplers; | ||
Containers::Vector<D3D12ScopedCommandBuffer> m_secondaryCommandBuffers; | ||
|
||
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_descriptorComputeHeap; | ||
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_descriptorSamplerHeap; | ||
|
||
Containers::Vector<ID3D12DescriptorHeap*> m_allHeaps; | ||
}; | ||
|
||
} // namespace D3D12 | ||
} // namespace Azura |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
Source/Azura/RenderSystem/Inc/D3D12/D3D12ScopedComputePass.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
#include "Types.h" | ||
|
||
#include "Log/Log.h" | ||
#include "D3D12/D3D12Core.h" | ||
#include "D3D12/D3D12ScopedImage.h" | ||
#include "D3D12/D3D12ScopedShader.h" | ||
#include "D3D12/D3D12ScopedCommandBuffer.h" | ||
#include "D3D12/D3D12ScopedSwapChain.h" | ||
|
||
namespace Azura { | ||
namespace Memory { | ||
class Allocator; | ||
} | ||
} | ||
|
||
namespace Azura { | ||
namespace D3D12 { | ||
|
||
class D3D12ScopedComputePass { | ||
public: | ||
D3D12ScopedComputePass(U32 idx, U32 internalId, Memory::Allocator& mainAllocator, Log logger); | ||
|
||
void Create(const Microsoft::WRL::ComPtr<ID3D12Device>& device, | ||
const PipelinePassCreateInfo& createInfo, | ||
const Containers::Vector<RenderTargetCreateInfo>& pipelineBuffers, | ||
const Containers::Vector<D3D12ScopedImage>& pipelineBufferImages, | ||
const Containers::Vector<DescriptorSlot>& descriptorSlots, | ||
const Containers::Vector<DescriptorTableEntry>& descriptorSetTable, | ||
const Containers::Vector<D3D12ScopedShader>& allShaders); | ||
|
||
U32 GetId() const; | ||
U32 GetInternalId() const; | ||
|
||
ID3D12GraphicsCommandList* GetPrimaryComputeCommandList(U32 idx) const; | ||
|
||
const DescriptorCount& GetDescriptorCount() const; | ||
|
||
ID3D12RootSignature* GetRootSignature() const; | ||
|
||
const Containers::Vector<std::reference_wrapper<const D3D12ScopedShader>>& GetShaders() const; | ||
const Containers::Vector<std::reference_wrapper<D3D12ScopedImage>>& GetInputImages() const; | ||
const Containers::Vector<std::reference_wrapper<D3D12ScopedImage>>& GetOutputImages() const; | ||
|
||
const Containers::Vector<DescriptorTableEntry>& GetRootSignatureTable() const; | ||
|
||
void RecordResourceBarriersForOutputsStart(ID3D12GraphicsCommandList* commandList) const; | ||
void RecordResourceBarriersForOutputsEnd(ID3D12GraphicsCommandList* commandList) const; | ||
void RecordResourceBarriersForInputsStart(ID3D12GraphicsCommandList* commandList) const; | ||
void RecordResourceBarriersForInputsEnd(ID3D12GraphicsCommandList* commandList) const; | ||
|
||
void WaitForGPU(ID3D12CommandQueue* commandQueue); | ||
|
||
U32 GetCommandBufferCount() const; | ||
|
||
U32 GetInputRootDescriptorTableId() const; | ||
U32 GetOutputRootDescriptorTableId() const; | ||
|
||
private: | ||
void CreateBase( | ||
const Microsoft::WRL::ComPtr<ID3D12Device>& device, | ||
const PipelinePassCreateInfo& createInfo, | ||
const Containers::Vector<DescriptorSlot>& descriptorSlots, | ||
const Containers::Vector<DescriptorTableEntry>& descriptorSetTable, | ||
const Containers::Vector<RenderTargetCreateInfo>& pipelineBuffers, | ||
const Containers::Vector<D3D12ScopedImage>& pipelineBufferImages, | ||
const Containers::Vector<D3D12ScopedShader>& allShaders); | ||
|
||
const Log log_D3D12RenderSystem; | ||
U32 m_id; | ||
U32 m_internalId; | ||
|
||
U32 m_computeOutputTableIdx{ 0 }; | ||
U32 m_computeInputTableIdx{ 0 }; | ||
|
||
Containers::Vector<DescriptorTableEntry> m_rootSignatureTable; | ||
|
||
Containers::Vector<std::reference_wrapper<const D3D12ScopedShader>> m_passShaders; | ||
|
||
SmallVector<D3D12ScopedCommandBuffer, DEFAULT_FRAMES_IN_FLIGHT> m_commandBuffers; | ||
|
||
Containers::Vector<std::reference_wrapper<D3D12ScopedImage>> m_computeOutputs; | ||
|
||
Containers::Vector<std::reference_wrapper<D3D12ScopedImage>> m_computeInputs; | ||
Containers::Vector<std::reference_wrapper<D3D12ScopedImage>> m_computeDepthInputs; | ||
Containers::Vector<std::reference_wrapper<D3D12ScopedImage>> m_allComputeInputs; | ||
|
||
Microsoft::WRL::ComPtr<ID3D12RootSignature> m_rootSignature; | ||
|
||
DescriptorCount m_descriptorCount{}; | ||
|
||
U32 m_fenceValue{1}; | ||
HANDLE m_fenceEvent{}; | ||
Microsoft::WRL::ComPtr<ID3D12Fence> m_signalFence; | ||
SmallVector<Microsoft::WRL::ComPtr<ID3D12Fence>, MAX_RENDER_PASS_INPUTS> m_waitFences; | ||
}; | ||
|
||
} // namespace D3D12 | ||
} // namespace Azura |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.