From facea8d019b25f027a2080f83b34a669b3c7ef2a Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 2 Nov 2014 21:19:48 +0000 Subject: [PATCH] Fix issues with float inaccuracy on 'clipping' overlay * There was a problem where a value of 1.0 would show up as 'clipping' if the range meant that it was transformed to something like 1.0000000432f so we use FLT_EPSILON as a slight fudge factor. --- renderdoc/data/hlsl/debugcbuffers.h | 3 +++ renderdoc/data/hlsl/debugdisplay.hlsl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/renderdoc/data/hlsl/debugcbuffers.h b/renderdoc/data/hlsl/debugcbuffers.h index 73eb0a1b7..c1e0af1f4 100644 --- a/renderdoc/data/hlsl/debugcbuffers.h +++ b/renderdoc/data/hlsl/debugcbuffers.h @@ -139,6 +139,9 @@ cbuffer HistogramCBufferData REG(b0) #define TEXDISPLAY_SINT_TEX 0x0800 #define TEXDISPLAY_GAMMA_CURVE 0x1000 +#ifndef FLT_EPSILON +#define FLT_EPSILON 1.192092896e-07f +#endif // histogram/minmax is calculated in blocks of NxN each with MxM tiles. // e.g. a tile is 32x32 pixels, then this is arranged in blocks of 32x32 tiles. diff --git a/renderdoc/data/hlsl/debugdisplay.hlsl b/renderdoc/data/hlsl/debugdisplay.hlsl index 81e3c6e0a..ac8ea5786 100644 --- a/renderdoc/data/hlsl/debugdisplay.hlsl +++ b/renderdoc/data/hlsl/debugdisplay.hlsl @@ -137,7 +137,7 @@ float4 RENDERDOC_TexDisplayPS(v2f IN) : SV_Target0 if(col.r < 0 || col.g < 0 || col.b < 0 || col.a < 0) return float4(1, 0, 0, 1); - if(col.r > 1 || col.g > 1 || col.b > 1 || col.a > 1) + if(col.r > (1+FLT_EPSILON) || col.g > (1+FLT_EPSILON) || col.b > (1+FLT_EPSILON) || col.a > (1+FLT_EPSILON)) return float4(0, 1, 0, 1); col = float4(dot(col.xyz, float3(0.2126, 0.7152, 0.0722)).xxx, 1);