#pragma once #ifndef NOMINMAX #define NOMINMAX #endif #include #include #include #include #include #include #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Host { class D3D12HostDevice { public: static constexpr std::uint32_t kFrameContextCount = 3u; bool Initialize(); void Shutdown(); bool BeginFrame(std::uint32_t frameIndex); bool SubmitFrame(std::uint32_t frameIndex); bool SignalFrameCompletion(std::uint32_t frameIndex); void WaitForFrame(std::uint32_t frameIndex); void WaitForGpuIdle(); void ResetFrameTracking(); ID3D12Device* GetDevice() const; ID3D12CommandQueue* GetCommandQueue() const; const std::string& GetLastError() const; ::XCEngine::RHI::RHIDevice* GetRHIDevice() const; ::XCEngine::RHI::RHICommandQueue* GetRHICommandQueue() const; ::XCEngine::RHI::RHICommandList* GetCommandList(std::uint32_t frameIndex) const; ::XCEngine::Rendering::RenderContext GetRenderContext(std::uint32_t frameIndex) const; private: ::XCEngine::RHI::D3D12Device* GetD3D12Device() const; ::XCEngine::RHI::D3D12CommandQueue* GetD3D12CommandQueue() const; ::XCEngine::RHI::D3D12CommandList* GetD3D12CommandList(std::uint32_t frameIndex) const; bool InitializeFrameCompletionFence(); void ReleaseFrameCompletionFence(); ::XCEngine::RHI::RHIDevice* m_device = nullptr; ::XCEngine::RHI::RHICommandQueue* m_commandQueue = nullptr; std::array<::XCEngine::RHI::RHICommandList*, kFrameContextCount> m_commandLists = {}; Microsoft::WRL::ComPtr m_frameCompletionFence = {}; HANDLE m_frameCompletionEvent = nullptr; std::array m_frameFenceValues = {}; std::uint64_t m_lastSubmittedFrameValue = 0u; std::string m_lastError = {}; }; } // namespace XCEngine::UI::Editor::Host