Files
XCEngine/engine/include/XCEngine/Rendering/RenderContext.h

55 lines
1.6 KiB
C++

#pragma once
#include <RHI\IRHIDevice.h>
#include <RHI\IRHIResources.h>
#include <Rendering\RenderTarget.h>
namespace XCEngine {
namespace RHI {
class D3D12DescriptorHeap;
class RenderContext {
public:
RenderContext(D3D12Device* device);
~RenderContext();
bool Initialize(uint32_t width, uint32_t height);
void Shutdown();
void BeginFrame();
void EndFrame();
ICommandList* GetCommandList() { return m_commandList; }
ICommandAllocator* GetCommandAllocator() { return m_commandAllocator; }
ISwapChain* GetSwapChain() { return m_swapChain; }
IRenderTarget* GetCurrentRenderTarget() { return m_currentRenderTarget; }
IDepthStencil* GetDepthStencil() { return m_depthStencil; }
IFence* GetFence() { return m_fence; }
uint64_t GetFenceValue() { return m_fenceValue; }
void IncrementFenceValue() { m_fenceValue++; }
void WaitForCompletionOfCommandList() { m_fence->Wait(m_fenceValue); }
void SetViewport(float width, float height);
void SetScissor(int32_t width, int32_t height);
void ClearRenderTarget(const float color[4]);
void ClearDepthStencil();
void Present();
private:
D3D12Device* m_device = nullptr;
ICommandAllocator* m_commandAllocator = nullptr;
ICommandList* m_commandList = nullptr;
IFence* m_fence = nullptr;
ISwapChain* m_swapChain = nullptr;
IRenderTarget* m_currentRenderTarget = nullptr;
IDepthStencil* m_depthStencil = nullptr;
D3D12DescriptorHeap* m_dsvHeap = nullptr;
uint64_t m_fenceValue = 0;
uint32_t m_width = 0;
uint32_t m_height = 0;
};
} // namespace RHI
} // namespace XCEngine