Make sure NaNs in non-displayed channels don't make preview blow up

This commit is contained in:
baldurk
2015-07-15 18:53:19 +02:00
parent b8c340b1fa
commit d6abdb2d2e
4 changed files with 19 additions and 6 deletions
+5 -3
View File
@@ -100,9 +100,11 @@ void main(void)
vec4 pre_range_col = col;
col = ((col - RangeMinimum)*InverseRangeSize);
col = mix(vec4(0,0,0,1), col, Channels);
pre_range_col = mix(vec4(0,0,0,1), pre_range_col, Channels);
if(Channels.x < 0.5f) col.x = pre_range_col.x = 0.0f;
if(Channels.y < 0.5f) col.y = pre_range_col.y = 0.0f;
if(Channels.z < 0.5f) col.z = pre_range_col.z = 0.0f;
if(Channels.w < 0.5f) col.w = pre_range_col.w = 1.0f;
// show nans, infs and negatives
if((OutputDisplayFormat & TEXDISPLAY_NANS) > 0)
+1 -1
View File
@@ -87,7 +87,7 @@ cbuffer DebugPixelCBufferData REG(b0)
float Slice;
float ScalePS;
int SampleIdx;
int Padding;
float AlwaysZero;
int RawOutput;
float3 TextureResolutionPS;
+7 -2
View File
@@ -120,8 +120,13 @@ float4 RENDERDOC_TexDisplayPS(v2f IN) : SV_Target0
col = ((col - RangeMinimum)*InverseRangeSize);
col = lerp(float4(0,0,0,1), col, Channels);
pre_range_col = lerp(float4(0,0,0,1), pre_range_col, Channels);
// workaround for D3DCompiler bug. For some reason it assumes texture samples can
// never come back as NaN, so involving a cbuffer value like this here ensures
// the below isnan()s don't get optimised out.
if(Channels.x < 0.5f) col.x = pre_range_col.x = AlwaysZero;
if(Channels.y < 0.5f) col.y = pre_range_col.y = AlwaysZero;
if(Channels.z < 0.5f) col.z = pre_range_col.z = AlwaysZero;
if(Channels.w < 0.5f) col.w = pre_range_col.w = 1.0f-AlwaysZero;
// show nans, infs and negatives
if(OutputDisplayFormat & TEXDISPLAY_NANS)
+6
View File
@@ -3301,6 +3301,8 @@ bool D3D11DebugManager::RenderTexture(TextureDisplay cfg, bool blendAlpha)
DebugVertexCBuffer vertexData;
DebugPixelCBufferData pixelData;
pixelData.AlwaysZero = 0.0f;
float x = cfg.offx;
float y = cfg.offy;
@@ -3690,6 +3692,8 @@ void D3D11DebugManager::RenderCheckerboard(Vec3f light, Vec3f dark)
DebugPixelCBufferData pixelData;
pixelData.AlwaysZero = 0.0f;
pixelData.Channels = Vec4f(light.x, light.y, light.z, 0.0f);
pixelData.WireframeColour = dark;
@@ -4597,6 +4601,8 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
DebugPixelCBufferData pixelData;
pixelData.AlwaysZero = 0.0f;
pixelData.OutputDisplayFormat = MESHDISPLAY_SOLID;
pixelData.WireframeColour = Vec3f(0.0f, 0.0f, 0.0f);
FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData));