st/mesa: Fix grabbing the wrong variant if glDrawPixels is called
authorMatias N. Goldberg <dark_sylinc@yahoo.com.ar>
Wed, 5 Jul 2017 17:02:50 +0000 (14:02 -0300)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 7 Jul 2017 23:44:51 +0000 (01:44 +0200)
commitf728435e1f872af3efcd6b9215e8d722d35090cc
treea92d966688cb6655afb8971bca596f0c515b40fc
parent753a7bbc8454a0cf957f17c88d2b4677b1cf36f0
st/mesa: Fix grabbing the wrong variant if glDrawPixels is called

By design pixel shaders can have up to 3 variants:
* The standard one.
* glDrawPixels variant.
* glBitmap variant.
However "shader_has_one_variant" ignores this fact, and therefore
st_update_fp would select the wrong variant if glDrawPixels or glBitmap
was ever called.

This patch fixes the problem. If the standard variant has been created,
calling glDrawPixels or glBitmap will append the variant to the second
entry of the linked list, so that st_update_fp still selects the right
one if shader_has_one_variant is set.

If the standard variant hasn't been created yet and glDrawPixel/Bitmap
has been called, st_update_fp will will see this and take the slow path
instead. The standard variant will then be added at the front of the
linked list, so that the next time the fast path is taken.

Blender in particular is hit by this bug.

v2: Marek - cosmetic changes

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=101596

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_program.c