diff --git a/Common/System/Display.cpp b/Common/System/Display.cpp index 31e911f333..096595e360 100644 --- a/Common/System/Display.cpp +++ b/Common/System/Display.cpp @@ -116,28 +116,18 @@ void DisplayProperties::Print() { rot_matrix.print(); } -Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention, bool compensateYFlip) { +// Y-flip compensation is done elsewhere now. +Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention) { using namespace Lin; - // TODO: Should be able to share the y-flip logic here with the one in postprocessing/presentation, for example. Matrix4x4 ortho; switch (coordConvention) { case CoordConvention::Vulkan: - ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); - break; case CoordConvention::Direct3D11: - if (compensateYFlip) { - ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); - } else { - ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); - } + ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); break; case CoordConvention::OpenGL: default: - if (compensateYFlip) { - ortho.setOrthoGL(0.0f, xres, 0, yres, -1.0f, 1.0f); - } else { - ortho.setOrthoGL(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); - } + ortho.setOrthoGL(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); break; } // Compensate for rotated display if needed. diff --git a/Common/System/Display.h b/Common/System/Display.h index 096a378186..edf15c6320 100644 --- a/Common/System/Display.h +++ b/Common/System/Display.h @@ -61,7 +61,7 @@ struct DisplayRect { void RotateRectToDisplay(DisplayRect &rect, float rtWidth, float rtHeight); void RotateRectToDisplay(DisplayRect &rect, int rtWidth, int rtHeight); -Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention, bool compensateYFlip); +Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention); // Take this and run through translation. Returns "Portrait", "Landscape" or later "Square" (the latter being the square shape you get when you open a foldable phone). std::string_view DeviceOrientationToString(DeviceOrientation orientation); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index ab3b410d3d..25e77246d2 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1072,8 +1072,8 @@ void NativeFrame(GraphicsContext *graphicsContext) { g_breakpoints.Frame(); // Apply the UIContext bounds as a 2D transformation matrix. - // NOTE: We compensate for the Y convention in the shaders, so we can use the same matrices in all backends. - Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, g_draw->GetDeviceCaps().coordConvention, false); + // NOTE: We compensate for the Y and Z conventions in the shaders, so we can use the same matrices in all backends. + Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, g_draw->GetDeviceCaps().coordConvention); // Can be overridden by sceDisplay which may pass true for the second argument. g_frameTiming.ComputePresentMode(g_draw, false); diff --git a/ext/imgui/imgui_impl_thin3d.cpp b/ext/imgui/imgui_impl_thin3d.cpp index 757f0ef494..4bef970ed8 100644 --- a/ext/imgui/imgui_impl_thin3d.cpp +++ b/ext/imgui/imgui_impl_thin3d.cpp @@ -73,7 +73,7 @@ void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *d viewport.MaxDepth = 1.0f; draw->SetViewport(viewport); - Lin::Matrix4x4 mtx = ComputeOrthoMatrix(draw_data->DisplaySize.x, draw_data->DisplaySize.y, draw->GetDeviceCaps().coordConvention, true); + Lin::Matrix4x4 mtx = ComputeOrthoMatrix(draw_data->DisplaySize.x, draw_data->DisplaySize.y, draw->GetDeviceCaps().coordConvention); Draw::VsTexColUB ub{}; memcpy(ub.WorldViewProj, mtx.getReadPtr(), sizeof(Lin::Matrix4x4));