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

@@ -91,7 +91,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return -1;
}
RenderDocCapture::Get().SetDevice(device.GetGLContext());
RenderDocCapture::Get().SetDevice(device.GetNativeContext());
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
@@ -117,7 +117,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessageW(&msg);
} else {
wglMakeCurrent(device.GetPresentationDC(), device.GetGLContext());
device.MakeContextCurrent();
commandList.SetViewport(0, 0, gWidth, gHeight);
commandList.Clear(1.0f, 0.0f, 0.0f, 1.0f, 1 | 2);

View File

@@ -95,7 +95,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return -1;
}
RenderDocCapture::Get().SetDevice(device.GetGLContext());
RenderDocCapture::Get().SetDevice(device.GetNativeContext());
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
@@ -202,7 +202,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessageW(&msg);
} else {
wglMakeCurrent(device.GetPresentationDC(), device.GetGLContext());
device.MakeContextCurrent();
commandList.SetViewport(0, 0, gWidth, gHeight);
commandList.Clear(0.0f, 0.0f, 1.0f, 1.0f, 1);

View File

@@ -174,7 +174,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return -1;
}
RenderDocCapture::Get().SetDevice(device.GetGLContext());
RenderDocCapture::Get().SetDevice(device.GetNativeContext());
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
@@ -312,7 +312,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessageW(&msg);
} else {
wglMakeCurrent(device.GetPresentationDC(), device.GetGLContext());
device.MakeContextCurrent();
renderCount++;
GLenum err = glGetError();

View File

@@ -91,7 +91,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return -1;
}
RenderDocCapture::Get().SetDevice(device.GetGLContext());
RenderDocCapture::Get().SetDevice(device.GetNativeContext());
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
@@ -179,7 +179,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessageW(&msg);
} else {
wglMakeCurrent(device.GetPresentationDC(), device.GetGLContext());
device.MakeContextCurrent();
commandList.SetViewport(0, 0, gWidth, gHeight);
commandList.Clear(0.0f, 0.0f, 1.0f, 1.0f, 1);

View File

@@ -22,14 +22,4 @@ TEST_F(OpenGLTestFixture, Device_GetDeviceInfo_ReturnsValid) {
EXPECT_FALSE(info.renderer.empty());
EXPECT_GE(info.majorVersion, 3);
EXPECT_GE(info.minorVersion, 0);
}
TEST_F(OpenGLTestFixture, Device_SwapBuffers_NoErrors) {
OpenGLDevice device;
device.InitializeWithExistingWindow(GetWindow());
device.SwapBuffers();
GLenum error = glGetError();
EXPECT_EQ(error, GL_NO_ERROR);
}