diff --git a/src/backend/d3d12/BufferD3D12.cpp b/src/backend/d3d12/BufferD3D12.cpp index 23af1b262a..aa580df577 100644 --- a/src/backend/d3d12/BufferD3D12.cpp +++ b/src/backend/d3d12/BufferD3D12.cpp @@ -16,6 +16,7 @@ #include "D3D12Backend.h" #include "ResourceAllocator.h" +#include "ResourceUploader.h" namespace backend { namespace d3d12 { diff --git a/src/backend/d3d12/D3D12Backend.cpp b/src/backend/d3d12/D3D12Backend.cpp index c0da29ed9e..9447d710a7 100644 --- a/src/backend/d3d12/D3D12Backend.cpp +++ b/src/backend/d3d12/D3D12Backend.cpp @@ -22,6 +22,10 @@ #include "QueueD3D12.h" #include "ShaderModuleD3D12.h" +#include "CommandAllocatorManager.h" +#include "ResourceAllocator.h" +#include "ResourceUploader.h" + namespace backend { namespace d3d12 { @@ -75,10 +79,10 @@ namespace d3d12 { Device::Device(ComPtr d3d12Device) : d3d12Device(d3d12Device), - commandAllocatorManager(this), - resourceAllocator(this), - resourceUploader(this), - pendingCommands{ commandAllocatorManager.ReserveCommandAllocator() } { + commandAllocatorManager(new CommandAllocatorManager(this)), + resourceAllocator(new ResourceAllocator(this)), + resourceUploader(new ResourceUploader(this)), + pendingCommands{ commandAllocatorManager->ReserveCommandAllocator() } { D3D12_COMMAND_QUEUE_DESC queueDesc = {}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; @@ -111,21 +115,21 @@ namespace d3d12 { } CommandAllocatorManager* Device::GetCommandAllocatorManager() { - return &commandAllocatorManager; + return commandAllocatorManager; } ResourceAllocator* Device::GetResourceAllocator() { - return &resourceAllocator; + return resourceAllocator; } ResourceUploader* Device::GetResourceUploader() { - return &resourceUploader; + return resourceUploader; } ComPtr Device::GetPendingCommandList() { // Callers of GetPendingCommandList do so to record commands. Only reserve a command allocator when it is needed so we don't submit empty command lists if (!pendingCommands.open) { - pendingCommands.commandAllocator = commandAllocatorManager.ReserveCommandAllocator(); + pendingCommands.commandAllocator = commandAllocatorManager->ReserveCommandAllocator(); ASSERT_SUCCESS(pendingCommands.commandList->Reset(pendingCommands.commandAllocator.Get(), nullptr)); pendingCommands.open = true; } @@ -143,8 +147,8 @@ namespace d3d12 { void Device::TickImpl() { // Perform cleanup operations to free unused objects const uint64_t lastCompletedSerial = fence->GetCompletedValue(); - resourceAllocator.FreeUnusedResources(lastCompletedSerial); - commandAllocatorManager.ResetCompletedAllocators(lastCompletedSerial); + resourceAllocator->FreeUnusedResources(lastCompletedSerial); + commandAllocatorManager->ResetCompletedAllocators(lastCompletedSerial); } uint64_t Device::GetSerial() const { diff --git a/src/backend/d3d12/D3D12Backend.h b/src/backend/d3d12/D3D12Backend.h index 0bdf442f07..6d3fb3e4bc 100644 --- a/src/backend/d3d12/D3D12Backend.h +++ b/src/backend/d3d12/D3D12Backend.h @@ -32,9 +32,6 @@ #include "common/ToBackend.h" #include "d3d12_platform.h" -#include "CommandAllocatorManager.h" -#include "ResourceAllocator.h" -#include "ResourceUploader.h" namespace backend { namespace d3d12 { @@ -57,6 +54,10 @@ namespace d3d12 { class Framebuffer; class RenderPass; + class CommandAllocatorManager; + class ResourceAllocator; + class ResourceUploader; + struct D3D12BackendTraits { using BindGroupType = BindGroup; using BindGroupLayoutType = BindGroupLayout; @@ -139,9 +140,9 @@ namespace d3d12 { ComPtr d3d12Device; ComPtr commandQueue; - CommandAllocatorManager commandAllocatorManager; - ResourceAllocator resourceAllocator; - ResourceUploader resourceUploader; + CommandAllocatorManager* commandAllocatorManager; + ResourceAllocator* resourceAllocator; + ResourceUploader* resourceUploader; struct PendingCommandList { ComPtr commandAllocator; diff --git a/src/backend/d3d12/QueueD3D12.cpp b/src/backend/d3d12/QueueD3D12.cpp index 361e7c4fe1..1e2de58c9d 100644 --- a/src/backend/d3d12/QueueD3D12.cpp +++ b/src/backend/d3d12/QueueD3D12.cpp @@ -15,6 +15,7 @@ #include "QueueD3D12.h" #include "D3D12Backend.h" +#include "CommandAllocatorManager.h" #include "CommandBufferD3D12.h" namespace backend { diff --git a/src/backend/d3d12/ResourceUploader.cpp b/src/backend/d3d12/ResourceUploader.cpp index bbe6f888fe..fde5ac4ae7 100644 --- a/src/backend/d3d12/ResourceUploader.cpp +++ b/src/backend/d3d12/ResourceUploader.cpp @@ -15,6 +15,7 @@ #include "ResourceUploader.h" #include "D3D12Backend.h" +#include "ResourceAllocator.h" namespace backend { namespace d3d12 {