- Fix Chinese character encoding issues causing MSVC C4819 warnings - Add m_rootSignature member to D3D12PipelineState for PSO creation - All integration tests pass: OpenGL 4/4, D3D12 4/4 - All RHI unit tests pass: 158/158
84 lines
2.9 KiB
C++
84 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <Windows.h>
|
|
|
|
#include "../RHIDevice.h"
|
|
#include "../RHICapabilities.h"
|
|
|
|
struct HDC__;
|
|
struct HGLRC__;
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
using HWND = HWND__*;
|
|
using HGLRC = HGLRC__*;
|
|
|
|
class OpenGLSwapChain;
|
|
class OpenGLTextureUnitAllocator;
|
|
class OpenGLUniformBufferManager;
|
|
|
|
class OpenGLDevice : public RHIDevice {
|
|
public:
|
|
OpenGLDevice();
|
|
~OpenGLDevice() override;
|
|
|
|
bool Initialize(const RHIDeviceDesc& desc) override;
|
|
void Shutdown() override;
|
|
|
|
bool InitializeWithExistingWindow(HWND hwnd);
|
|
bool CreateRenderWindow(int width, int height, const char* title, bool enableDebug = false);
|
|
HWND GetWindow() const { return m_hwnd; }
|
|
HDC GetPresentationDC() const { return m_hdc; }
|
|
HGLRC GetGLContext() const { return m_hglrc; }
|
|
const RHIDeviceInfo& GetDeviceInfoImpl() const { return m_deviceInfo; }
|
|
|
|
OpenGLTextureUnitAllocator* GetTextureUnitAllocator() { return m_textureUnitAllocator.get(); }
|
|
OpenGLUniformBufferManager* GetUniformBufferManager() { return m_uniformBufferManager.get(); }
|
|
|
|
void SwapBuffers();
|
|
bool PollEvents();
|
|
void SetShouldClose(bool shouldClose);
|
|
bool ShouldClose() const;
|
|
|
|
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
|
|
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
|
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override;
|
|
RHICommandList* CreateCommandList(const CommandListDesc& desc) override;
|
|
RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override;
|
|
RHIShader* CompileShader(const ShaderCompileDesc& desc) override;
|
|
RHIPipelineState* CreatePipelineState(const GraphicsPipelineDesc& desc) override;
|
|
RHIFence* CreateFence(const FenceDesc& desc) override;
|
|
RHISampler* CreateSampler(const SamplerDesc& desc) override;
|
|
|
|
RHIResourceView* CreateRenderTargetView(RHITexture* texture, const ResourceViewDesc& desc) override;
|
|
RHIResourceView* CreateDepthStencilView(RHITexture* texture, const ResourceViewDesc& desc) override;
|
|
RHIResourceView* CreateShaderResourceView(RHITexture* texture, const ResourceViewDesc& desc) override;
|
|
RHIResourceView* CreateUnorderedAccessView(RHITexture* texture, const ResourceViewDesc& desc) override;
|
|
|
|
const RHICapabilities& GetCapabilities() const override;
|
|
const RHIDeviceInfo& GetDeviceInfo() const override;
|
|
|
|
void* GetNativeDevice() override;
|
|
void* GetNativeHandle() const;
|
|
|
|
private:
|
|
friend class OpenGLSwapChain;
|
|
|
|
HWND m_hwnd = nullptr;
|
|
HDC m_hdc = nullptr;
|
|
HGLRC m_hglrc = nullptr;
|
|
RHIDeviceInfo m_deviceInfo;
|
|
RHICapabilities m_capabilities;
|
|
bool m_initialized = false;
|
|
bool m_ownsWindow = false;
|
|
bool m_shouldClose = false;
|
|
|
|
std::unique_ptr<OpenGLTextureUnitAllocator> m_textureUnitAllocator;
|
|
std::unique_ptr<OpenGLUniformBufferManager> m_uniformBufferManager;
|
|
};
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|