[Piglit] [PATCH] Fix piglit_probe_pixel_rgb on GLES2
Brian Paul
brianp at vmware.com
Mon Mar 26 14:42:02 UTC 2018
On 03/25/2018 01:49 PM, Rhys Perry wrote:
> GLES2 requires GL_RGBA to be used with GL_UNSIGNED_BYTE in glReadPixels
> ---
> tests/util/piglit-util-gl.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
> index df39c1c87..be060aae5 100644
> --- a/tests/util/piglit-util-gl.c
> +++ b/tests/util/piglit-util-gl.c
> @@ -1017,7 +1017,7 @@ static GLfloat *
> read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei height,
> GLenum format, GLfloat *pixels)
> {
> - GLubyte *pixels_b;
> + uint8_t pixels_b[4];
> unsigned i, ncomponents;
>
> ncomponents = width * height * piglit_num_components(format);
> @@ -1029,11 +1029,9 @@ read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei height,
> return pixels;
> }
>
> - pixels_b = malloc(ncomponents * sizeof(GLubyte));
> - glReadPixels(x, y, width, height, format, GL_UNSIGNED_BYTE, pixels_b);
> + glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_b);
> for (i = 0; i < ncomponents; i++)
> pixels[i] = pixels_b[i] / 255.0;
> - free(pixels_b);
> return pixels;
> }
>
>
This doesn't look right. The pixels_b buffer must be large enough to
hold 'ncomponents' values, not 4.
Also, I'd prefer to keep read GL_RGB on non-ES. Reading GL_RGB vs.
GL_RGBA probably hits different code paths in the driver, which is a
good thing.
-Brian
More information about the Piglit
mailing list