nir/lower_blend: Don't handle gl_FragColor

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 <alyssa@collabora.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20836>
This commit is contained in:
Alyssa Rosenzweig 2023-02-15 10:27:48 -05:00 committed by Marge Bot
parent b3f229c510
commit acfda67b4f

View file

@ -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;
}
/*