From 477d5b65579be147705c6003b13a80c678716353 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 2 Feb 2018 22:07:31 +0000 Subject: [PATCH] Use absolute dimensions of viewport to calculate aspect ratio. Refs #856 * On vulkan the viewport height could be negative to flip the NDC, but we don't care about its sign only its magnitude to calculate the aspect ratio. --- renderdocui/Windows/BufferViewer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index ac93c7aea..ebb6aed87 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -3131,8 +3131,13 @@ namespace renderdocui.Windows m_MeshDisplay.aspect = 1.0f; + Viewport vp = m_Core.CurPipelineState.GetViewport(0); + + float vpWidth = Math.Abs(vp.width); + float vpHeight = Math.Abs(vp.height); + // take a guess for the aspect ratio, for if the user hasn't overridden it - m_MeshDisplay.aspect = m_Core.CurPipelineState.GetViewport(0).width / m_Core.CurPipelineState.GetViewport(0).height; + m_MeshDisplay.aspect = (vpWidth > 0.0f && vpHeight > 0.0f) ? (vpWidth / vpHeight) : 1.0f; if (aspectGuess.Text.Length > 0 && float.TryParse(aspectGuess.Text, out m_MeshDisplay.aspect)) aspectGuess.Text = m_MeshDisplay.aspect.ToString("G");