Replace mip selection with sample idx when viewing Tex2DMS. Refs #79

* Also for float/unorm texture add an additional "resolved" option that
  just does an unweighted average of all samples, which is the behaviour
  from before (assuming that's what ResolveSubresource does).
This commit is contained in:
baldurk
2014-08-29 01:54:14 +01:00
parent d17314536a
commit 89e90f8c36
23 changed files with 220 additions and 108 deletions
+1
View File
@@ -419,6 +419,7 @@ namespace renderdoc
public ResourceId CustomShader = ResourceId.Null;
public UInt32 mip = 0;
public UInt32 sliceFace = 0;
public UInt32 sampleIdx = 0;
public bool rawoutput = false;
public float offx = 0.0f, offy = 0.0f;
+9 -9
View File
@@ -92,7 +92,7 @@ namespace renderdoc
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool ReplayOutput_PickPixel(IntPtr real, ResourceId texID, bool customShader,
UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip, IntPtr outval);
UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip, UInt32 sample, IntPtr outval);
private IntPtr m_Real = IntPtr.Zero;
@@ -138,11 +138,11 @@ namespace renderdoc
ReplayOutput_DisablePixelContext(m_Real);
}
public PixelValue PickPixel(ResourceId texID, bool customShader, UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip)
public PixelValue PickPixel(ResourceId texID, bool customShader, UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip, UInt32 sample)
{
IntPtr mem = CustomMarshal.Alloc(typeof(PixelValue));
bool success = ReplayOutput_PickPixel(m_Real, texID, customShader, x, y, sliceFace, mip, mem);
bool success = ReplayOutput_PickPixel(m_Real, texID, customShader, x, y, sliceFace, mip, sample, mem);
PixelValue ret = null;
@@ -232,9 +232,9 @@ namespace renderdoc
private static extern bool ReplayRenderer_GetPostVSData(IntPtr real, MeshDataStage stage, IntPtr outdata);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool ReplayRenderer_GetMinMax(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, IntPtr outminval, IntPtr outmaxval);
private static extern bool ReplayRenderer_GetMinMax(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, IntPtr outminval, IntPtr outmaxval);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool ReplayRenderer_GetHistogram(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, float minval, float maxval, bool[] channels, IntPtr outhistogram);
private static extern bool ReplayRenderer_GetHistogram(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, float minval, float maxval, bool[] channels, IntPtr outhistogram);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool ReplayRenderer_GetBufferData(IntPtr real, ResourceId buff, UInt32 offset, UInt32 len, IntPtr outdata);
@@ -605,12 +605,12 @@ namespace renderdoc
return ret;
}
public bool GetMinMax(ResourceId tex, UInt32 sliceFace, UInt32 mip, out PixelValue minval, out PixelValue maxval)
public bool GetMinMax(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, out PixelValue minval, out PixelValue maxval)
{
IntPtr mem1 = CustomMarshal.Alloc(typeof(PixelValue));
IntPtr mem2 = CustomMarshal.Alloc(typeof(PixelValue));
bool success = ReplayRenderer_GetMinMax(m_Real, tex, sliceFace, mip, mem1, mem2);
bool success = ReplayRenderer_GetMinMax(m_Real, tex, sliceFace, mip, sample, mem1, mem2);
if (success)
{
@@ -629,7 +629,7 @@ namespace renderdoc
return success;
}
public bool GetHistogram(ResourceId tex, UInt32 sliceFace, UInt32 mip, float minval, float maxval,
public bool GetHistogram(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, float minval, float maxval,
bool Red, bool Green, bool Blue, bool Alpha,
out UInt32[] histogram)
{
@@ -637,7 +637,7 @@ namespace renderdoc
bool[] channels = new bool[] { Red, Green, Blue, Alpha };
bool success = ReplayRenderer_GetHistogram(m_Real, tex, sliceFace, mip, minval, maxval, channels, mem);
bool success = ReplayRenderer_GetHistogram(m_Real, tex, sliceFace, mip, sample, minval, maxval, channels, mem);
histogram = null;
+64 -11
View File
@@ -1089,14 +1089,34 @@ namespace renderdocui.Windows
mipLevel.Items.Clear();
sliceFace.Items.Clear();
for (int i = 0; i < tex.mips; i++)
mipLevel.Items.Add(i + " - " + Math.Max(1, tex.width >> i) + "x" + Math.Max(1, tex.height >> i));
if (tex.msSamp > 1)
{
for (int i = 0; i < tex.msSamp; i++)
mipLevel.Items.Add(String.Format("Sample {0}", i));
// add an option to display unweighted average resolved value,
// to get an idea of how the samples average
if(tex.format.compType != FormatComponentType.UInt &&
tex.format.compType != FormatComponentType.SInt &&
tex.format.compType != FormatComponentType.Depth &&
(tex.creationFlags & TextureCreationFlags.DSV) == 0)
mipLevel.Items.Add("Average val");
mipLevelLabel.Text = "Sample";
}
else
{
for (int i = 0; i < tex.mips; i++)
mipLevel.Items.Add(i + " - " + Math.Max(1, tex.width >> i) + "x" + Math.Max(1, tex.height >> i));
mipLevelLabel.Text = "Mip";
}
mipLevel.SelectedIndex = 0;
m_TexDisplay.mip = 0;
m_TexDisplay.sliceFace = 0;
if (tex.mips == 1)
if (tex.mips == 1 && tex.msSamp <= 1)
{
mipLevel.Enabled = false;
}
@@ -1924,11 +1944,11 @@ namespace renderdocui.Windows
y = (int)tex.height - y;
var pickValue = m_Output.PickPixel(m_TexDisplay.texid, true, (UInt32)x, (UInt32)y,
m_TexDisplay.sliceFace, m_TexDisplay.mip);
m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx);
PixelValue realValue = null;
if (m_TexDisplay.CustomShader != ResourceId.Null)
realValue = m_Output.PickPixel(m_TexDisplay.texid, false, (UInt32)x, (UInt32)y,
m_TexDisplay.sliceFace, m_TexDisplay.mip);
m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx);
RT_UpdatePixelColour(pickValue, realValue, false);
}
@@ -2060,7 +2080,7 @@ namespace renderdocui.Windows
if (m_TexDisplay.FlipY)
y = tex.height - y;
RT_UpdateHoverColour(m_Output.PickPixel(m_TexDisplay.texid, true, (UInt32)m_CurHoverPixel.X, y,
m_TexDisplay.sliceFace, m_TexDisplay.mip));
m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx));
}
});
}
@@ -2265,10 +2285,33 @@ namespace renderdocui.Windows
}
private void mipLevel_SelectedIndexChanged(object sender, EventArgs e)
{
m_TexDisplay.mip = (UInt32)mipLevel.SelectedIndex;
if (CurrentTexture == null) return;
if (CurrentTexture.mips > 1)
{
m_TexDisplay.mip = (UInt32)mipLevel.SelectedIndex;
m_TexDisplay.sampleIdx = 0;
}
else
{
m_TexDisplay.mip = 0;
m_TexDisplay.sampleIdx = (UInt32)mipLevel.SelectedIndex;
if (mipLevel.SelectedIndex == CurrentTexture.msSamp)
m_TexDisplay.sampleIdx = ~0U;
}
m_Core.Renderer.BeginInvoke(RT_UpdateVisualRange);
if (m_Output != null && m_PickedPoint != null && m_PickedPoint.X > 0 && m_PickedPoint.Y > 0)
{
m_Core.Renderer.BeginInvoke((ReplayRenderer r) =>
{
if (m_Output != null)
RT_PickPixelsAndUpdate(m_PickedPoint.X, m_PickedPoint.Y, true);
});
}
m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay);
m_Core.Renderer.BeginInvoke(RT_UpdateVisualRange);
}
private void overlay_SelectedIndexChanged(object sender, EventArgs e)
@@ -2285,8 +2328,18 @@ namespace renderdocui.Windows
{
m_TexDisplay.sliceFace = (UInt32)sliceFace.SelectedIndex;
m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay);
m_Core.Renderer.BeginInvoke(RT_UpdateVisualRange);
if (m_Output != null && m_PickedPoint != null && m_PickedPoint.X > 0 && m_PickedPoint.Y > 0)
{
m_Core.Renderer.BeginInvoke((ReplayRenderer r) =>
{
if (m_Output != null)
RT_PickPixelsAndUpdate(m_PickedPoint.X, m_PickedPoint.Y, true);
});
}
m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay);
}
private void updateChannelsHandler(object sender, EventArgs e)
@@ -2392,7 +2445,7 @@ namespace renderdocui.Windows
m_Core.Renderer.BeginInvoke((ReplayRenderer r) =>
{
PixelValue min, max;
bool success = r.GetMinMax(m_TexDisplay.texid, m_TexDisplay.sliceFace, m_TexDisplay.mip, out min, out max);
bool success = r.GetMinMax(m_TexDisplay.texid, m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx, out min, out max);
if (success)
{
@@ -2483,7 +2536,7 @@ namespace renderdocui.Windows
bool success = true;
uint[] histogram;
success = r.GetHistogram(m_TexDisplay.texid, m_TexDisplay.sliceFace, m_TexDisplay.mip,
success = r.GetHistogram(m_TexDisplay.texid, m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx,
rangeHistogram.BlackPoint, rangeHistogram.WhitePoint,
m_TexDisplay.Red,
m_TexDisplay.Green && fmt.compCount > 1,