From bd5a6752e2d6b543272e20477789b6c3876ccbc5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 27 Nov 2015 15:05:42 +0100 Subject: [PATCH] Use viewport for guessing aspect ratio, not dimensions of depth/colour --- renderdocui/Code/CommonPipelineState.cs | 59 +++++++++++++++++++++++++ renderdocui/Windows/BufferViewer.cs | 20 +-------- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/renderdocui/Code/CommonPipelineState.cs b/renderdocui/Code/CommonPipelineState.cs index cd96b1a87..e86b157b0 100644 --- a/renderdocui/Code/CommonPipelineState.cs +++ b/renderdocui/Code/CommonPipelineState.cs @@ -61,6 +61,11 @@ namespace renderdocui.Code public bool Used; }; + public struct Viewport + { + public float x, y, width, height; + }; + public class CommonPipelineState { private D3D11PipelineState m_D3D11 = null; @@ -150,6 +155,24 @@ namespace renderdocui.Code } } + // whether or not the PostVS data is aligned in the typical fashion + // ie. vectors not crossing float4 boundaries). APIs that use stream-out + // or transform feedback have tightly packed data, but APIs that rewrite + // shaders to dump data might have these alignment requirements + public bool HasAlignedPostVSData + { + get + { + if (LogLoaded) + { + if (IsLogVK) + return true; + } + + return false; + } + } + public string Abbrev(ShaderStageType stage) { if (IsLogD3D11 || (!LogLoaded && DefaultType == APIPipelineStateType.D3D11)) @@ -194,6 +217,42 @@ namespace renderdocui.Code // there's a lot of redundancy in these functions + public Viewport GetViewport(int index) + { + Viewport ret = new Viewport(); + + // default to a 1x1 viewport just to avoid having to check for 0s all over + ret.x = ret.y = 0.0f; + ret.width = ret.height = 1.0f; + + if (LogLoaded) + { + if (IsLogD3D11 && m_D3D11.m_RS.Viewports.Length > 0) + { + ret.x = m_D3D11.m_RS.Viewports[0].TopLeft[0]; + ret.y = m_D3D11.m_RS.Viewports[0].TopLeft[1]; + ret.width = m_D3D11.m_RS.Viewports[0].Width; + ret.height = m_D3D11.m_RS.Viewports[0].Height; + } + else if (IsLogGL && m_GL.m_RS.Viewports.Length > 0) + { + ret.x = m_GL.m_RS.Viewports[0].Left; + ret.y = m_GL.m_RS.Viewports[0].Bottom; + ret.width = m_GL.m_RS.Viewports[0].Width; + ret.height = m_GL.m_RS.Viewports[0].Height; + } + else if (IsLogVK && m_Vulkan.VP.viewportScissors.Length > 0) + { + ret.x = m_Vulkan.VP.viewportScissors[0].vp.x; + ret.y = m_Vulkan.VP.viewportScissors[0].vp.y; + ret.width = m_Vulkan.VP.viewportScissors[0].vp.Width; + ret.height = m_Vulkan.VP.viewportScissors[0].vp.Height; + } + } + + return ret; + } + public ShaderBindpointMapping GetBindpointMapping(ShaderStageType stage) { if (LogLoaded) diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index a2d30567e..7e770d1ae 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -2698,25 +2698,7 @@ namespace renderdocui.Windows m_MeshDisplay.aspect = 1.0f; // take a guess for the aspect ratio, for if the user hasn't overridden it - BoundResource depth = m_Core.CurPipelineState.GetDepthTarget(); - BoundResource[] targets = m_Core.CurPipelineState.GetOutputTargets(); - - if (depth.Id != ResourceId.Null || (targets != null && targets.Length > 0)) - { - foreach (var t in m_Core.CurTextures) - { - if (depth.Id != ResourceId.Null && t.ID == depth.Id) - { - m_MeshDisplay.aspect = (float)t.width / (float)t.height; - break; - } - if (depth.Id == ResourceId.Null && targets != null && targets.Length > 0 && t.ID == targets[0].Id) - { - m_MeshDisplay.aspect = (float)t.width / (float)t.height; - break; - } - } - } + m_MeshDisplay.aspect = m_Core.CurPipelineState.GetViewport(0).width / m_Core.CurPipelineState.GetViewport(0).height; if (aspectGuess.Text.Length > 0 && float.TryParse(aspectGuess.Text, out m_MeshDisplay.aspect)) aspectGuess.Text = m_MeshDisplay.aspect.ToString("G");