Separate viewport target and descriptor ownership

This commit is contained in:
2026-04-13 19:57:25 +08:00
parent f3fc34898a
commit 5b89c2bb76
10 changed files with 534 additions and 433 deletions

View File

@@ -8,7 +8,6 @@
#include <XCEngine/Rendering/RenderSurface.h>
#include <XCEngine/RHI/D3D12/D3D12CommandList.h>
#include <XCEngine/RHI/D3D12/D3D12CommandQueue.h>
#include <XCEngine/RHI/D3D12/D3D12DescriptorHeap.h>
#include <XCEngine/RHI/D3D12/D3D12Device.h>
#include <XCEngine/RHI/D3D12/D3D12SwapChain.h>
#include <XCEngine/RHI/D3D12/D3D12Texture.h>
@@ -32,7 +31,6 @@ namespace XCEngine::UI::Editor::Host {
class D3D12WindowRenderer {
public:
static constexpr UINT kSrvDescriptorCount = 64;
static constexpr std::uint32_t kSwapChainBufferCount = 3;
bool Initialize(HWND hwnd, int width, int height);
@@ -45,22 +43,8 @@ public:
bool PresentFrame();
ID3D12Device* GetDevice() const;
ID3D12DescriptorHeap* GetSrvHeap() const;
ID3D12CommandQueue* GetCommandQueue() const;
const std::string& GetLastError() const;
void AllocateShaderResourceDescriptor(
D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle,
D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle);
bool CreateShaderResourceTextureDescriptor(
::XCEngine::RHI::RHIDevice* device,
::XCEngine::RHI::RHITexture* texture,
D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle,
D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle);
void FreeShaderResourceDescriptor(
D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle,
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle);
UINT GetSrvDescriptorSize() const;
UINT GetSrvDescriptorCount() const;
::XCEngine::RHI::RHIDevice* GetRHIDevice() const;
::XCEngine::RHI::RHISwapChain* GetSwapChain() const;
const ::XCEngine::Rendering::RenderSurface* GetCurrentRenderSurface() const;
@@ -75,12 +59,6 @@ private:
::XCEngine::RHI::D3D12CommandList* GetD3D12CommandList() const;
::XCEngine::RHI::D3D12SwapChain* GetD3D12SwapChain() const;
::XCEngine::RHI::RHICommandList* GetCurrentCommandList() const;
void AllocateShaderResourceDescriptorInternal(
D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle,
D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle);
void FreeShaderResourceDescriptorInternal(
D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle,
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle);
bool InitializeFrameCompletionFence();
void ReleaseFrameCompletionFence();
void WaitForBackBufferFrame(std::uint32_t backBufferIndex);
@@ -97,9 +75,6 @@ private:
::XCEngine::RHI::RHICommandQueue* m_commandQueue = nullptr;
std::array<::XCEngine::RHI::RHICommandList*, kSwapChainBufferCount> m_commandLists = {};
::XCEngine::RHI::RHISwapChain* m_swapChain = nullptr;
::XCEngine::RHI::RHIDescriptorPool* m_srvPool = nullptr;
::XCEngine::RHI::D3D12DescriptorHeap* m_srvHeap = nullptr;
std::vector<bool> m_srvUsage = {};
std::vector<::XCEngine::RHI::RHIResourceView*> m_backBufferViews = {};
std::vector<::XCEngine::Rendering::RenderSurface> m_backBufferSurfaces = {};
Microsoft::WRL::ComPtr<ID3D12Fence> m_frameCompletionFence = {};
@@ -108,7 +83,6 @@ private:
std::uint32_t m_activeBackBufferIndex = 0u;
std::uint64_t m_lastSubmittedFrameValue = 0;
std::string m_lastError = {};
UINT m_srvDescriptorSize = 0;
};
} // namespace XCEngine::UI::Editor::Host