From acfda67b4f87b0138c753f8f0bdc9bf8118a2aa1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 15 Feb 2023 10:27:48 -0500 Subject: [PATCH] nir/lower_blend: Don't handle gl_FragColor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In OpenGL, FRAG_RESULT_COLOR implicitly broadcasts to every render target. Our existing lower_blend code (somewhat arbitrarily) aliases to the the first render target's format and blend settings. That said, I don't think that works if different render targets have different settings -- or blend with their different destinations -- though I don't have relevant spec text right now. The actual reason this works is that all users of this pass either call nir_lower_fragcolor first (panfrost, asahi) or don't have FRAG_RESULT_COLOR as part of their API (panvk, soon agxv). Unless/until we actually have a use case for nir_lower_blend with gl_FragColor, assert that gl_FragColor is lowered first so we don't need to worry about this imaginary case. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Timur Kristóf Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir_lower_blend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/nir/nir_lower_blend.c b/src/compiler/nir/nir_lower_blend.c index 1e80a451001..d57fb754649 100644 --- a/src/compiler/nir/nir_lower_blend.c +++ b/src/compiler/nir/nir_lower_blend.c @@ -433,12 +433,13 @@ nir_blend( static int color_index_for_var(const nir_variable *var) { - if (var->data.location != FRAG_RESULT_COLOR && - var->data.location < FRAG_RESULT_DATA0) - return -1; + assert(var->data.location != FRAG_RESULT_COLOR && + "gl_FragColor must be lowered before nir_lower_blend"); - return (var->data.location == FRAG_RESULT_COLOR) ? 0 : - (var->data.location - FRAG_RESULT_DATA0); + if (var->data.location < FRAG_RESULT_DATA0) + return -1; + else + return var->data.location - FRAG_RESULT_DATA0; } /*