refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "D3D12WindowSwapChainPresenter.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace XCEngine::UI::Editor::Host {
|
||||
|
||||
bool D3D12WindowSwapChainPresenter::PreparePresentSurface(
|
||||
const ::XCEngine::Rendering::RenderContext& renderContext) {
|
||||
if (!renderContext.IsValid() || renderContext.commandList == nullptr) {
|
||||
m_lastError = "PreparePresentSurface requires a valid render context.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_swapChain == nullptr) {
|
||||
m_lastError = "PreparePresentSurface requires an initialized swap chain.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::uint32_t backBufferIndex = m_swapChain->GetCurrentBackBufferIndex();
|
||||
if (backBufferIndex >= m_backBufferViews.size() ||
|
||||
m_backBufferViews[backBufferIndex] == nullptr) {
|
||||
std::ostringstream error = {};
|
||||
error << "PreparePresentSurface could not find the current swap chain RTV. index="
|
||||
<< backBufferIndex
|
||||
<< " rtvCount="
|
||||
<< m_backBufferViews.size();
|
||||
m_lastError = error.str();
|
||||
return false;
|
||||
}
|
||||
|
||||
renderContext.commandList->TransitionBarrier(
|
||||
m_backBufferViews[backBufferIndex],
|
||||
::XCEngine::RHI::ResourceStates::Present,
|
||||
::XCEngine::RHI::ResourceStates::RenderTarget);
|
||||
m_lastError.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D3D12WindowSwapChainPresenter::PresentFrame() {
|
||||
if (m_swapChain == nullptr) {
|
||||
m_lastError = "PresentFrame requires an initialized swap chain.";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_swapChain->Present(0, 0);
|
||||
m_lastError.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Host
|
||||
Reference in New Issue
Block a user