[Mesa-dev] [PATCH 0/2] Patches to try to fix draw-pixel-with-textures in swrast
Yuanhan Liu
yuanhan.liu at linux.intel.com
Thu Nov 17 23:52:37 PST 2011
On Fri, Nov 18, 2011 at 03:38:46PM +0800, Yuanhan Liu wrote:
>
> The two patches tries to fix an issue that happened while calling glDrawPixels
> with texture enabled.
>
> Here I attached a piglit testcase for this issue.
>
>
>
>
> Yuanhan Liu (2):
> swrast: simplify the prototype of function texture_combine
> swrast: fix unmatched span->array->ChanType
>
> src/mesa/swrast/s_texcombine.c | 24 ++++++++++++++----------
> 1 files changed, 14 insertions(+), 10 deletions(-)
>
> --
> 1.7.4.4
>
>
> Here is the piglit testcase:
> --
> >From c199828cddae5bd0f8e96d586b91be6ad423dbce Mon Sep 17 00:00:00 2001
> From: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> Date: Fri, 18 Nov 2011 15:37:33 +0800
> Subject: [PATCH] Add a draw-pixel-with-texture testcase
>
> Add a draw-pixel-with-texture testcase to check if sampling is happened
> while drawing pixels by glDrawPixels.
>
> Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> ---
[snip..]
> +#include "piglit-util.h"
> +
> +int piglit_width = 100, piglit_height = 100;
> +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + GLboolean pass = GL_TRUE;
> + GLfloat tex_data[2 * 2 * 4] = {
> + 1, 0, 0, 1, 1, 0, 0, 1,
> + 1, 0, 0, 1, 1, 0, 0, 1,
> + };
> + GLfloat pixels[20 * 20 * 4];
> + GLfloat expected[4] = {0.2, 0, 0, 1};
> + int i;
> +
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_FLOAT, tex_data);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
If GL_MODULATE was changed to GL_REPLACE, then the two patches does fix
this issue.
if GL_TEXTURE_ENV_MODE was set to GL_MODULATE, then the final color
should be pixels_color(as GL_PRIMARY_COLOR) * texture_color. But the
result is black. Since the current code did:
1. combine->SourceRGB[1] was set to GL_PREVIOUS but not GL_PRIMARY_COLOR.
2. Do not use primary_rgba, as swrast->_TextureCombinePrimary was set FALSE.
Actually, the two are of the same issue. 2 was caused by 1. And we have
no previous texture, thus got a final color equal to "texture_color *
(0, 0, 0, 0) = (0, 0, 0, 0).
I made a _quite_ dirty(too dirty that myself doesn't accept it) patch to fix
this issue. I may need to dig this issue furthre. But before that, comments
and ideas are welcome.
Thanks,
Yuanhan Liu
> +
> + glTexCoord2f(0.5, 0.5);
> + glEnable(GL_TEXTURE_2D);
> +
> + for (i = 0; i < 20 * 20 * 4; i += 4) {
> + pixels[i + 0] = 0.2;
> + pixels[i + 1] = 1;
> + pixels[i + 2] = 0;
> + pixels[i + 3] = 1;
> + }
> +
> + glClear(GL_COLOR_BUFFER_BIT);
> +
> + glDrawPixels(20, 20, GL_RGBA, GL_FLOAT, pixels);
> +
> + /* Here just sample a small set of pixels */
> + pass &= piglit_probe_pixel_rgba(5, 5, expected);
> + pass &= piglit_probe_pixel_rgba(7, 12, expected);
> + pass &= piglit_probe_pixel_rgba(10, 10, expected);
> + pass &= piglit_probe_pixel_rgba(18, 18, expected);
> +
> + glutSwapBuffers();
> +
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + glClearColor(0.0, 0.0, 0.0, 1.0);
> +}
> --
> 1.7.4.4
More information about the mesa-dev
mailing list