refactor(RHI): 将窗口职责从RHI移到Platform层
- RHIDeviceDesc 删除 windowHandle/width/height/appName - SwapChainDesc 添加 windowHandle 字段 - RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口 - OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow - 更新所有集成测试使用新API - 273个单元测试 + 8个集成测试全部通过
This commit is contained in:
@@ -29,24 +29,15 @@ public:
|
||||
const D3D12Texture& GetBackBuffer(uint32_t index) const;
|
||||
void Present(uint32_t syncInterval = 1, uint32_t flags = 0) override;
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
bool IsFullscreen() const override;
|
||||
void* GetNativeHandle() override;
|
||||
|
||||
bool ShouldClose() const override;
|
||||
void SetShouldClose(bool shouldClose) override;
|
||||
void PollEvents() override;
|
||||
|
||||
private:
|
||||
ComPtr<IDXGISwapChain3> m_swapChain;
|
||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
||||
HWND m_windowHandle;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_bufferCount;
|
||||
std::vector<D3D12Texture> m_backBuffers;
|
||||
bool m_shouldClose = false;
|
||||
bool m_fullscreen = false;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
|
||||
@@ -29,8 +29,6 @@ public:
|
||||
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; }
|
||||
@@ -39,9 +37,6 @@ public:
|
||||
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;
|
||||
@@ -74,8 +69,6 @@ private:
|
||||
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;
|
||||
|
||||
@@ -37,39 +37,19 @@ public:
|
||||
void Present(uint32_t syncInterval = 1, uint32_t flags = 0) override;
|
||||
void SwapBuffers();
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
void SetVSync(bool enabled);
|
||||
bool IsVSync() const { return m_vsync; }
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
bool IsFullscreen() const override;
|
||||
|
||||
void SetFramebufferSize(int width, int height);
|
||||
int GetWidth() const { return m_width; }
|
||||
int GetHeight() const { return m_height; }
|
||||
int GetFramebufferWidth() const { return m_framebufferWidth; }
|
||||
int GetFramebufferHeight() const { return m_framebufferHeight; }
|
||||
|
||||
HWND GetWindow() const { return m_hwnd; }
|
||||
HDC GetDC() const { return m_device ? m_device->GetPresentationDC() : nullptr; }
|
||||
|
||||
bool ShouldClose() const override;
|
||||
void SetShouldClose(bool shouldClose) override;
|
||||
void PollEvents() override;
|
||||
|
||||
uint32_t GetCurrentBackBufferIndex() const override;
|
||||
RHITexture* GetCurrentBackBuffer() override;
|
||||
void* GetNativeHandle() override;
|
||||
|
||||
int GetWidth() const { return m_width; }
|
||||
int GetHeight() const { return m_height; }
|
||||
|
||||
private:
|
||||
OpenGLDevice* m_device = nullptr;
|
||||
HWND m_hwnd = nullptr;
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
int m_framebufferWidth = 0;
|
||||
int m_framebufferHeight = 0;
|
||||
bool m_vsync = true;
|
||||
bool m_shouldClose = false;
|
||||
bool m_fullscreen = false;
|
||||
PresentMode m_presentMode = PresentMode::VSync;
|
||||
OpenGLTexture* m_backBufferTexture = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,12 +17,6 @@ public:
|
||||
virtual RHITexture* GetCurrentBackBuffer() = 0;
|
||||
virtual void Present(uint32_t syncInterval = 1, uint32_t flags = 0) = 0;
|
||||
virtual void Resize(uint32_t width, uint32_t height) = 0;
|
||||
virtual void SetFullscreen(bool fullscreen) = 0;
|
||||
virtual bool IsFullscreen() const = 0;
|
||||
|
||||
virtual bool ShouldClose() const = 0;
|
||||
virtual void SetShouldClose(bool shouldClose) = 0;
|
||||
virtual void PollEvents() = 0;
|
||||
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
};
|
||||
|
||||
@@ -184,15 +184,17 @@ struct SamplerDesc {
|
||||
};
|
||||
|
||||
struct SwapChainDesc {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t bufferCount;
|
||||
uint32_t format;
|
||||
uint32_t refreshRate;
|
||||
uint32_t sampleCount;
|
||||
uint32_t sampleQuality;
|
||||
uint32_t swapEffect;
|
||||
uint32_t flags;
|
||||
void* windowHandle = nullptr;
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t bufferCount = 2;
|
||||
Format format = Format::R8G8B8A8_UNorm;
|
||||
uint32_t refreshRateNumerator = 60;
|
||||
uint32_t refreshRateDenominator = 1;
|
||||
uint32_t sampleCount = 1;
|
||||
uint32_t sampleQuality = 0;
|
||||
uint32_t swapEffect = 0;
|
||||
uint32_t flags = 0;
|
||||
};
|
||||
|
||||
struct RenderTargetViewDesc {
|
||||
@@ -317,10 +319,6 @@ struct RHIDeviceDesc {
|
||||
bool enableDebugLayer = false;
|
||||
bool enableGPUValidation = false;
|
||||
uint32_t adapterIndex = 0;
|
||||
void* windowHandle = nullptr;
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
std::wstring appName = L"XCEngine";
|
||||
};
|
||||
|
||||
struct RHIDeviceInfo {
|
||||
|
||||
Reference in New Issue
Block a user