From 527c662fb295609d51b7a46eec2f37c9144f3540 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 1 Mar 2021 11:38:29 +0000 Subject: [PATCH] Only flip Y co-ordinates in texture viewer when clip origin is default --- qrenderdoc/Windows/TextureViewer.cpp | 21 ++++++++++++++++----- qrenderdoc/Windows/TextureViewer.h | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 36e21654c..1ca072078 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -974,7 +974,7 @@ void TextureViewer::UI_UpdateStatusText() uint32_t mipWidth = qMax(1U, tex.width >> (int)m_TexDisplay.subresource.mip); uint32_t mipHeight = qMax(1U, tex.height >> (int)m_TexDisplay.subresource.mip); - if(m_Ctx.APIProps().pipelineType == GraphicsAPI::OpenGL) + if(ShouldFlipForGL()) y = (int)(mipHeight - 1) - y; if(m_TexDisplay.flipY) y = (int)(mipHeight - 1) - y; @@ -1010,7 +1010,7 @@ void TextureViewer::UI_UpdateStatusText() { x = m_PickedPoint.x() >> (int)m_TexDisplay.subresource.mip; y = m_PickedPoint.y() >> (int)m_TexDisplay.subresource.mip; - if(m_Ctx.APIProps().pipelineType == GraphicsAPI::OpenGL) + if(ShouldFlipForGL()) y = (int)(mipHeight - 1) - y; if(m_TexDisplay.flipY) y = (int)(mipHeight - 1) - y; @@ -2158,10 +2158,10 @@ void TextureViewer::GotoLocation(uint32_t x, uint32_t y) m_PickedPoint = QPoint(x, y); - if(m_Ctx.APIProps().pipelineType == GraphicsAPI::OpenGL) + if(ShouldFlipForGL()) m_PickedPoint.setY((int)(tex->height - 1) - m_PickedPoint.y()); if(m_TexDisplay.flipY) - m_PickedPoint.setY((int)(tex->height - 1) - m_PickedPoint.x()); + m_PickedPoint.setY((int)(tex->height - 1) - m_PickedPoint.y()); // centre the picked point. QPoint scrollPos; @@ -3831,7 +3831,7 @@ void TextureViewer::ShowGotoPopup() uint32_t mipHeight = qMax(1U, texptr->height >> (int)m_TexDisplay.subresource.mip); - if(m_Ctx.APIProps().pipelineType == GraphicsAPI::OpenGL) + if(ShouldFlipForGL()) p.setY((int)(mipHeight - 1) - p.y()); if(m_TexDisplay.flipY) p.setY((int)(mipHeight - 1) - p.y()); @@ -3840,6 +3840,17 @@ void TextureViewer::ShowGotoPopup() } } +bool TextureViewer::ShouldFlipForGL() +{ + if(m_Ctx.APIProps().pipelineType == GraphicsAPI::OpenGL) + { + // lower left is the default clip origin, which needs the Y flip + return m_Ctx.CurGLPipelineState()->vertexProcessing.clipOriginLowerLeft; + } + + return false; +} + void TextureViewer::on_viewTexBuffer_clicked() { TextureDescription *texptr = GetCurrentTexture(); diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index 20d7c083c..e4e8bf21f 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -307,6 +307,8 @@ private: void ShowGotoPopup(); + bool ShouldFlipForGL(); + void UI_UpdateFittedScale(); void UI_SetScale(float s); void UI_SetScale(float s, int x, int y);