Fix OpenGL integration tests for new SwapChain API
- triangle/quad/sphere tests: Update to use new Initialize signature with OpenGLDevice* - triangle/quad/sphere tests: Use GetGLContext() for RenderDoc SetDevice - triangle/quad/sphere tests: Add wglMakeCurrent in render loop - triangle/quad/sphere tests: Update capture timing to frame 25-35 - unit test fixture: Add GetDevice() method - unit test swap_chain: Update to use new Initialize signature
This commit is contained in:
@@ -169,12 +169,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
RenderDocCapture::Get().SetCaptureFilePath(".\\sphere_frame30");
|
||||
|
||||
OpenGLDevice device;
|
||||
if (!device.InitializeWithExistingWindow(hwnd)) {
|
||||
RHIDeviceDesc desc = {};
|
||||
desc.windowHandle = hwnd;
|
||||
desc.width = gWidth;
|
||||
desc.height = gHeight;
|
||||
desc.appName = L"OpenGL_Sphere_Test";
|
||||
desc.enableDebugLayer = true;
|
||||
if (!device.Initialize(desc)) {
|
||||
Log("[ERROR] Failed to initialize OpenGL device");
|
||||
return -1;
|
||||
}
|
||||
|
||||
RenderDocCapture::Get().SetDevice(device.GetContext());
|
||||
RenderDocCapture::Get().SetDevice(device.GetGLContext());
|
||||
|
||||
ShowWindow(hwnd, nShowCmd);
|
||||
UpdateWindow(hwnd);
|
||||
@@ -183,7 +189,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
Log("[INFO] OpenGL Version: %S", device.GetDeviceInfo().version.c_str());
|
||||
|
||||
OpenGLSwapChain swapChain;
|
||||
swapChain.Initialize(hwnd, gWidth, gHeight);
|
||||
swapChain.Initialize(&device, hwnd, gWidth, gHeight);
|
||||
|
||||
OpenGLCommandList commandList;
|
||||
|
||||
@@ -299,10 +305,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
MSG msg = {};
|
||||
int frameCount = 0;
|
||||
const int targetFrameCount = 30;
|
||||
const int captureStartFrame = 25;
|
||||
const int captureEndFrame = 35;
|
||||
|
||||
int renderCount = 0;
|
||||
while (frameCount < targetFrameCount) {
|
||||
while (frameCount < captureEndFrame) {
|
||||
if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if (msg.message == WM_QUIT) {
|
||||
break;
|
||||
@@ -310,6 +317,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
} else {
|
||||
wglMakeCurrent(device.GetPresentationDC(), device.GetGLContext());
|
||||
|
||||
renderCount++;
|
||||
GLenum err = glGetError();
|
||||
if (err != GL_NO_ERROR) Log("[DEBUG] GL error before clear: 0x%x", err);
|
||||
@@ -336,25 +345,24 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
commandList.DrawIndexed(PrimitiveType::Triangles, (uint32_t)indices.size(), 0, 0);
|
||||
|
||||
if (frameCount >= targetFrameCount - 1) {
|
||||
if (RenderDocCapture::Get().BeginCapture("OpenGL_Sphere_Test")) {
|
||||
Log("[INFO] RenderDoc capture started");
|
||||
}
|
||||
}
|
||||
|
||||
swapChain.Present(0, 0);
|
||||
frameCount++;
|
||||
|
||||
if (frameCount >= targetFrameCount) {
|
||||
if (RenderDocCapture::Get().EndCapture()) {
|
||||
Log("[INFO] RenderDoc capture ended");
|
||||
}
|
||||
if (frameCount == captureStartFrame) {
|
||||
RenderDocCapture::Get().BeginCapture("OpenGL_Sphere_Test");
|
||||
Log("[INFO] RenderDoc capture started at frame %d", frameCount);
|
||||
}
|
||||
|
||||
if (frameCount == captureEndFrame) {
|
||||
RenderDocCapture::Get().EndCapture();
|
||||
Log("[INFO] RenderDoc capture ended at frame %d", frameCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log("[INFO] Rendered %d frames (target was %d)", renderCount, targetFrameCount);
|
||||
Log("[INFO] Reached target frame count %d - taking screenshot!", targetFrameCount);
|
||||
Log("[INFO] Rendered %d frames (capture was %d-%d)", renderCount, captureStartFrame, captureEndFrame);
|
||||
Log("[INFO] Capture complete - taking screenshot!");
|
||||
|
||||
char exePath[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, exePath, MAX_PATH);
|
||||
|
||||
Reference in New Issue
Block a user