refactor(new_editor/app): reorganize host structure and add smoke test

This commit is contained in:
2026-04-15 08:24:06 +08:00
parent 3617b4840b
commit 9e5954cf0a
235 changed files with 11157 additions and 10028 deletions

View File

@@ -0,0 +1,100 @@
#include "D3D12WindowSwapChainPresenter.h"
#include <sstream>
namespace XCEngine::UI::Editor::Host {
using ::XCEngine::RHI::D3D12SwapChain;
using ::XCEngine::RHI::D3D12Texture;
bool D3D12WindowSwapChainPresenter::Resize(int width, int height) {
if (width <= 0 || height <= 0 || m_swapChain == nullptr || m_hostDevice == nullptr) {
return false;
}
if (m_width == width && m_height == height) {
m_lastError.clear();
return true;
}
m_hostDevice->WaitForGpuIdle();
ReleaseBackBufferCommandReferences();
ReleaseBackBufferViews();
D3D12SwapChain* d3d12SwapChain = GetD3D12SwapChain();
if (d3d12SwapChain == nullptr) {
m_lastError = "Resize could not resolve the native D3D12 swap chain.";
return false;
}
d3d12SwapChain->Resize(
static_cast<std::uint32_t>(width),
static_cast<std::uint32_t>(height));
const HRESULT resizeHr = d3d12SwapChain->GetLastResizeResult();
if (FAILED(resizeHr)) {
if (RecreateSwapChain(width, height)) {
m_lastError.clear();
return true;
}
std::ostringstream error = {};
error << "ResizeBuffers failed. requested="
<< width
<< 'x'
<< height
<< " hr=0x"
<< std::uppercase
<< std::hex
<< static_cast<unsigned long>(resizeHr);
m_lastError = error.str();
return false;
}
const D3D12Texture* backBufferTexture = GetBackBufferTexture(0u);
if (backBufferTexture == nullptr) {
if (RecreateSwapChain(width, height)) {
m_lastError.clear();
return true;
}
m_lastError = "Resize failed to restore swap chain back buffers after ResizeBuffers.";
return false;
}
m_width = static_cast<int>(backBufferTexture->GetWidth());
m_height = static_cast<int>(backBufferTexture->GetHeight());
m_hostDevice->ResetFrameTracking();
if (!RecreateBackBufferViews()) {
if (RecreateSwapChain(width, height)) {
m_lastError.clear();
return true;
}
m_lastError = "Resize failed to recreate swap chain back buffer views.";
return false;
}
if (m_width != width || m_height != height) {
if (RecreateSwapChain(width, height)) {
m_lastError.clear();
return true;
}
std::ostringstream error = {};
error << "Resize ended with an unexpected swap chain size. requested="
<< width
<< 'x'
<< height
<< " actual="
<< m_width
<< 'x'
<< m_height;
m_lastError = error.str();
return false;
}
m_lastError.clear();
return true;
}
} // namespace XCEngine::UI::Editor::Host