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

We could make it early return, but instead we just assert, so that
drivers know to only call it when appropriate.

(A previous version of this patch, which early returned instead of
asserting, was Reviewed-by: Emma Anholt <emma@anholt.net> as well.)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12839>

src/compiler/glsl/lower_blend_equation_advanced.cpp

index cd2a83f..9060e83 100644 (file)
@@ -463,6 +463,8 @@ get_main(gl_linked_shader *sh)
 bool
 lower_blend_equation_advanced(struct gl_linked_shader *sh, bool coherent)
 {
+   assert(sh->Stage == MESA_SHADER_FRAGMENT);
+
    if (sh->Program->info.fs.advanced_blend_modes == 0)
       return false;