From 8b83210ab3f1e5eaa47ca2b8b19e5b8fb08d648d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 25 Nov 2022 21:40:42 -0500 Subject: [PATCH] nir/lower_blend: Don't do logic ops on pure float Per the spec. Fixes arb_color_buffer_float-render on both Panfrost and Asahi (before/after reproduced on Mali-T860 and AGX G13 respectively). Without that patch, that test fails the assertion: arb_color_buffer_float-render: ../src/compiler/nir/nir_lower_blend.c:259: nir_blend_logicop: Assertion `util_format_is_pure_integer(format)' failed. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Gert Wollny Part-of: --- src/compiler/nir/nir_lower_blend.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/compiler/nir/nir_lower_blend.c b/src/compiler/nir/nir_lower_blend.c index 9f394d96c12..02b7fee85cb 100644 --- a/src/compiler/nir/nir_lower_blend.c +++ b/src/compiler/nir/nir_lower_blend.c @@ -278,6 +278,17 @@ nir_blend_logicop( const struct util_format_description *format_desc = util_format_description(format); + /* From section 17.3.9 ("Logical Operation") of the OpenGL 4.6 core spec: + * + * Logical operation has no effect on a floating-point destination color + * buffer, or when FRAMEBUFFER_SRGB is enabled and the value of + * FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment + * corresponding to the destination buffer is SRGB (see section 9.2.3). + * However, if logical operation is enabled, blending is still disabled. + */ + if (util_format_is_float(format) || util_format_is_srgb(format)) + return src; + if (bit_size != 32) { src = nir_f2f32(b, src); dst = nir_f2f32(b, dst);