[Piglit] [PATCH 02/17] ext_framebuffer_multisample: Clamp UNORM only to [0, 1.0]

Topi Pohjolainen topi.pohjolainen at gmail.com
Tue Jul 18 19:16:27 UTC 2017


preparing for source blending with GL_RGBA16F and GL_RGBA32F.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 .../draw-buffers-common.cpp                          | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
index 9f92abdd1..8f0088c97 100644
--- a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp
@@ -443,8 +443,14 @@ compute_blend_color(float *frag_color, int rect_count,
 		bg_color[j] *
 		dst_blend_factor;
 
-		frag_color[rect_count * num_components + j] =
-			(blend_color > 1) ? 1.0 : blend_color;
+		/* Clamp to [0, 1.0] for UNORM */
+		if (resolve_fbo.config.color_internalformat == GL_RGBA) {
+			frag_color[rect_count * num_components + j] =
+				(blend_color > 1) ? 1.0 : blend_color;
+		} else {
+			frag_color[rect_count * num_components + j] =
+				blend_color;
+		}
 	}
 }
 
@@ -573,7 +579,15 @@ compute_expected(bool sample_alpha_to_coverage,
 			 * the fragment alpha values of draw buffer zero
 			 */
 			float frag_alpha = color[i * num_components + 3];
-			coverage[i] = (frag_alpha < 1.0) ? frag_alpha : 1.0;
+
+			/* Clamp to [0, 1.0] for UNORM */
+			if (resolve_fbo.config.color_internalformat ==
+			    GL_RGBA) {
+				coverage[i] = (frag_alpha < 1.0) ?
+					      frag_alpha : 1.0;
+			} else {
+				coverage[i] = frag_alpha;
+			}
 		}
 	}
 	else {
-- 
2.11.0



More information about the Piglit mailing list