glsl: Assert that lower_blend_equation_advanced is only called for FS

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>
This commit is contained in:
Kenneth Graunke
2021-09-13 15:05:09 -07:00
committed by Marge Bot
parent bec8f8fde8
commit d3b72d49cb

View 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;