RHI: Internalize OpenGL-specific methods in OpenGLDevice

- Remove GetTextureUnitAllocator/GetUniformBufferManager from public interface
- Remove SwapBuffers from public interface (friend OpenGLSwapChain can still access)
- Add MakeContextCurrent() and GetNativeContext() public methods
- Update integration tests to use MakeContextCurrent() instead of wglMakeCurrent
- Update RenderDoc calls to use GetNativeContext() instead of GetGLContext()
- Remove Device_SwapBuffers_NoErrors test (SwapBuffers no longer public)
- Mark Priority 7 as completed in RHI_Design_Issues.md
This commit is contained in:
2026-03-25 01:20:38 +08:00
parent 6328ac8d37
commit dc970d215b
8 changed files with 56 additions and 27 deletions

View File

@@ -29,14 +29,10 @@ public:
void Shutdown() override;
bool InitializeWithExistingWindow(HWND 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 MakeContextCurrent();
void* GetNativeContext() const { return m_hglrc; }
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
RHITexture* CreateTexture(const TextureDesc& desc) override;
@@ -66,6 +62,11 @@ public:
private:
friend class OpenGLSwapChain;
HDC GetPresentationDC() const { return m_hdc; }
OpenGLTextureUnitAllocator* GetTextureUnitAllocator() { return m_textureUnitAllocator.get(); }
OpenGLUniformBufferManager* GetUniformBufferManager() { return m_uniformBufferManager.get(); }
void SwapBuffers();
HWND m_hwnd = nullptr;
HDC m_hdc = nullptr;
HGLRC m_hglrc = nullptr;

View File

@@ -259,6 +259,13 @@ void OpenGLDevice::Shutdown() {
m_initialized = false;
}
bool OpenGLDevice::MakeContextCurrent() {
if (m_hdc && m_hglrc) {
return ::wglMakeCurrent(m_hdc, m_hglrc) == TRUE;
}
return false;
}
void OpenGLDevice::SwapBuffers() {
if (m_hdc) {
::SwapBuffers(m_hdc);