65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#ifndef NOMINMAX
|
|
#define NOMINMAX
|
|
#endif
|
|
|
|
#include <XCEngine/Rendering/RenderContext.h>
|
|
#include <XCEngine/RHI/D3D12/D3D12CommandList.h>
|
|
#include <XCEngine/RHI/D3D12/D3D12CommandQueue.h>
|
|
#include <XCEngine/RHI/D3D12/D3D12Device.h>
|
|
#include <XCEngine/RHI/RHICommandList.h>
|
|
#include <XCEngine/RHI/RHICommandQueue.h>
|
|
#include <XCEngine/RHI/RHIDevice.h>
|
|
|
|
#include <d3d12.h>
|
|
#include <windows.h>
|
|
#include <wrl/client.h>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
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<ID3D12Fence> m_frameCompletionFence = {};
|
|
HANDLE m_frameCompletionEvent = nullptr;
|
|
std::array<std::uint64_t, kFrameContextCount> m_frameFenceValues = {};
|
|
std::uint64_t m_lastSubmittedFrameValue = 0u;
|
|
std::string m_lastError = {};
|
|
};
|
|
|
|
} // namespace XCEngine::UI::Editor::Host
|