i965: Only call lower_blend_equation_advanced for fragment shaders
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 13 Sep 2021 22:47:47 +0000 (15:47 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 14 Sep 2021 03:55:05 +0000 (03:55 +0000)
i965 called this pass unconditionally, while st/mesa only calls it for
fragment shaders.  It only makes sense to run for fragment shaders, and
the first thing the pass does is read a FS-specific field out of a
union.  This isn't safe for other stages.

Fixes about 20,630 test failures on i965 since 91dc863921a, which moved
the advanced_blend_modes field.  The field had previously been in a
union with no other fields, so it never aliased anything, and thus
worked, even if it was wrong.  That commit moved it to a union that had
fields for other stages, so it started reading garbage and trying to
lower advanced blending for other stages on i965.

Fixes: 91dc863921a ("mesa: Move the advanced blend bitmask to shader_info.")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12839>

src/mesa/drivers/dri/i965/brw_link.cpp

index 77b4c14..396ee4d 100644 (file)
@@ -102,8 +102,10 @@ process_glsl_ir(struct brw_context *brw,
 
    ralloc_adopt(mem_ctx, shader->ir);
 
-   lower_blend_equation_advanced(
-      shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
+   if (shader->Stage == MESA_SHADER_FRAGMENT) {
+      lower_blend_equation_advanced(
+         shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
+   }
 
    /* lower_packing_builtins() inserts arithmetic instructions, so it
     * must precede lower_instructions().