st/mesa: Fix GL_MAP_COLOR with glDrawPixels GL_COLOR_INDEX

Documentation for glDrawPixels with GL_COLOR_INDEX says:
 "If the GL is in color index mode, and if GL_MAP_COLOR is true,
  the index is replaced with the value that it references in
  lookup table GL_PIXEL_MAP_I_TO_I"

We are always in RGBA mode and there is nothing in documentation
about GL_MAP_COLOR in RGBA mode for GL_COLOR_INDEX.

Scale and bias are also only applicable for RGBA format and not
mentioned for GL_COLOR_INDEX.

Thus the behaviour will be on par with i965.

Fixes: gl-1.0-drawpixels-color-index
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Danylo Piliaiev 2019-04-03 18:09:24 +03:00 committed by Marek Olšák
parent f6ceed205c
commit 3fdfface3e

View file

@ -1144,6 +1144,35 @@ get_color_fp_variant(struct st_context *st)
return fpv;
}
/**
* Get fragment program variant for a glDrawPixels command
* for COLOR_INDEX data
*/
static struct st_fp_variant *
get_color_index_fp_variant(struct st_context *st)
{
struct gl_context *ctx = st->ctx;
struct st_fp_variant_key key;
struct st_fp_variant *fpv;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
key.drawpixels = 1;
/* Since GL is always in RGBA mode MapColorFlag does not
* affect GL_COLOR_INDEX format.
* Scale and bias also never affect GL_COLOR_INDEX format.
*/
key.scaleAndBias = 0;
key.pixelMaps = 0;
key.clamp_color = st->clamp_frag_color_in_shader &&
ctx->Color._ClampFragmentColor;
fpv = st_get_fp_variant(st, st->fp, &key);
return fpv;
}
/**
* Clamp glDrawPixels width and height to the maximum texture size.
@ -1299,11 +1328,12 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
write_stencil);
}
else {
fpv = get_color_fp_variant(st);
fpv = (format != GL_COLOR_INDEX) ? get_color_fp_variant(st) :
get_color_index_fp_variant(st);
driver_fp = fpv->driver_shader;
if (ctx->Pixel.MapColorFlag) {
if (ctx->Pixel.MapColorFlag && format != GL_COLOR_INDEX) {
pipe_sampler_view_reference(&sv[1],
st->pixel_xfer.pixelmap_sampler_view);
num_sampler_view++;