refactor(new_editor): tighten app dependency boundaries

This commit is contained in:
2026-04-19 02:48:41 +08:00
parent 7429f22fb1
commit c59cd83c38
86 changed files with 1754 additions and 1077 deletions

View File

@@ -1,5 +1,8 @@
#include "ViewportHostService.h"
#include "Host/ViewportRenderHost.h"
#include <Rendering/D3D12/D3D12ShaderResourceDescriptorAllocator.h>
#include <XCEngine/Components/CameraComponent.h>
#include <XCEngine/RHI/RHICommandList.h>
#include <XCEngine/Rendering/Execution/SceneRenderer.h>
@@ -22,16 +25,20 @@ void SetViewportStatusIfEmpty(
} // namespace
ViewportHostService::ViewportHostService() = default;
ViewportHostService::ViewportHostService()
: m_textureDescriptorAllocator(
std::make_unique<Host::D3D12ShaderResourceDescriptorAllocator>()) {
}
ViewportHostService::~ViewportHostService() = default;
void ViewportHostService::AttachWindowRenderer(
Host::D3D12WindowRenderer& windowRenderer) {
Host::ViewportRenderHost& windowRenderer) {
if (m_windowRenderer == &windowRenderer) {
m_device = windowRenderer.GetRHIDevice();
if (m_device != nullptr && !m_textureDescriptorAllocator.IsInitialized()) {
m_textureDescriptorAllocator.Initialize(*m_device);
if (m_device != nullptr &&
!m_textureDescriptorAllocator->IsInitialized()) {
m_textureDescriptorAllocator->Initialize(*m_device);
}
return;
}
@@ -40,7 +47,7 @@ void ViewportHostService::AttachWindowRenderer(
m_windowRenderer = &windowRenderer;
m_device = windowRenderer.GetRHIDevice();
if (m_device != nullptr) {
m_textureDescriptorAllocator.Initialize(*m_device);
m_textureDescriptorAllocator->Initialize(*m_device);
}
}
@@ -63,7 +70,7 @@ void ViewportHostService::Shutdown() {
}
m_sceneViewportRenderPassBundle.Shutdown();
m_textureDescriptorAllocator.Shutdown();
m_textureDescriptorAllocator->Shutdown();
m_windowRenderer = nullptr;
m_device = nullptr;
m_surfacePresentationEnabled = false;
@@ -97,7 +104,9 @@ const ViewportHostService::ViewportEntry& ViewportHostService::GetEntry(
}
void ViewportHostService::DestroyViewportEntry(ViewportEntry& entry) {
m_renderTargetManager.DestroyTargets(&m_textureDescriptorAllocator, entry.renderTargets);
m_renderTargetManager.DestroyTargets(
m_textureDescriptorAllocator.get(),
entry.renderTargets);
entry = {};
}
@@ -202,7 +211,7 @@ bool ViewportHostService::EnsureViewportResources(ViewportEntry& entry) {
entry.requestedWidth,
entry.requestedHeight,
*m_device,
m_textureDescriptorAllocator,
*m_textureDescriptorAllocator,
entry.renderTargets);
}