Use a simple if/else to organize the ES vs desktop GL code paths.
---
 tests/util/piglit-util-gl.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 3a41a5e..f851f82 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -1017,27 +1017,27 @@ static GLfloat *
 read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei height,
                  GLenum format, GLfloat *pixels)
 {
-       GLubyte *pixels_b;
-       unsigned i, j, k;
        int comps = piglit_num_components(format);
 
        if (!pixels)
                pixels = malloc(width * height * comps * sizeof(GLfloat));
 
-       if (!piglit_is_gles()) {
+       if (piglit_is_gles()) {
+               unsigned i, j, k;
+               GLubyte *pixels_b = malloc(width * height * 4 * 
sizeof(GLubyte));
+               glReadPixels(x, y, width, height,
+                            GL_RGBA, GL_UNSIGNED_BYTE, pixels_b);
+               k = 0;
+               for (i = 0; i < width * height; i++) {
+                       for (j = 0; j < comps; j++) {
+                               pixels[k++] = pixels_b[i*4+j] / 255.0f;
+                       }
+               }
+               free(pixels_b);
+       } else {
                glReadPixels(x, y, width, height, format, GL_FLOAT, pixels);
-               return pixels;
        }
 
-       pixels_b = malloc(width * height * 4 * sizeof(GLubyte));
-       glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_b);
-       k = 0;
-       for (i = 0; i < width * height; i++) {
-               for (j = 0; j < comps; j++) {
-                       pixels[k++] = pixels_b[i*4+j] / 255.0f;
-               }
-       }
-       free(pixels_b);
        return pixels;
 }
 
-- 
2.7.4

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to