Unit test for glReadPixels specifically for OpenGL ES 2.0. Covers a variety of formats and types, both valid and invalid.
A few variations are commented out due to results that are incorrect and need to be followed up with Mesa, such as modifying the buffer even tho the format is invalid. There are cases where the returned data is incorrectly formated. These can best be addressed in time and I thought it best to include the variations but in their commented out form. Signed-off-by: Tom Gall <tom.g...@linaro.org> --- tests/all.tests | 1 + tests/spec/gles-2.0/CMakeLists.gles2.txt | 1 + tests/spec/gles-2.0/gles2_unit_glReadPixels.c | 643 +++++++++++++++++++++++++ 3 files changed, 645 insertions(+) create mode 100644 tests/spec/gles-2.0/gles2_unit_glReadPixels.c diff --git a/tests/all.tests b/tests/all.tests index b5d23e2..ce72d12 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -2684,6 +2684,7 @@ egl_khr_create_context['verify GL flavor'] = plain_test('egl-create-context-veri gles20 = Group() spec['!OpenGL ES 2.0'] = gles20 add_plain_test(gles20, 'sanity-test_gles2') +add_plain_test(gles20, 'unit-glReadPixels_gles2') gles30 = Group() spec['!OpenGL ES 3.0'] = gles30 diff --git a/tests/spec/gles-2.0/CMakeLists.gles2.txt b/tests/spec/gles-2.0/CMakeLists.gles2.txt index df3d26c..af0ee4b 100644 --- a/tests/spec/gles-2.0/CMakeLists.gles2.txt +++ b/tests/spec/gles-2.0/CMakeLists.gles2.txt @@ -4,5 +4,6 @@ link_libraries( piglit_add_executable(sanity-test_${piglit_target_api} gles2_sanity_test.c) piglit_add_executable(invalid-es3-queries_${piglit_target_api} invalid-es3-queries.c) +piglit_add_executable(unit-glReadPixels_${piglit_target_api} gles2_unit_glReadPixels.c) # vim: ft=cmake: diff --git a/tests/spec/gles-2.0/gles2_unit_glReadPixels.c b/tests/spec/gles-2.0/gles2_unit_glReadPixels.c new file mode 100644 index 0000000..fa7e672 --- /dev/null +++ b/tests/spec/gles-2.0/gles2_unit_glReadPixels.c @@ -0,0 +1,643 @@ +/* + * Copyright © 2012 Linaro Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * This is a unit test to exercise glReadPixels + * as specified by the OpenGL ES 2.0 spec. + * + * Todo: GL_PACK_ALIGNMENT via glPixelStorei isn't tested + * reading from GL_COLOR_ATTACHMENT0 when the default framebuffer + * isn't bound is not tested + * combo of GL_IMPLEMENTATION_COLOR_READ_FORMAT + * GL_IMPLEMENTATION_COLOR_READ_TYPE is not tested + * + * \author Tom Gall <tom.g...@linaro.org> + */ + +#define _GNU_SOURCE + +#include <stdlib.h> +#include <stdio.h> +#include "piglit-util-gl-common.h" + +#define WIDTH 320 +#define HEIGHT 200 +#define TEST_PATTERN_BYTE 0xA5 + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_es_version = 20; + + config.window_width = 320; + config.window_height = 200; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH; + +PIGLIT_GL_TEST_CONFIG_END + +GLuint prog; +GLuint frag; +GLuint vert; +/* pad a bit so we can do a request larger than the viewport */ +GLubyte buffer[HEIGHT+50][WIDTH][4]; + +char vertex_shader [] = + "attribute vec4 vPosition;\n" + "void main()\n" + "{\n" + " gl_Position = vPosition;\n" + "}"; + +char fragment_shader [] = + "precision mediump float;\n" + "void main()\n" + "{\n" + " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" + "}"; + +/* various pixel formats */ +typedef struct { + unsigned short red:5; + unsigned short green:6; + unsigned short blue:5; +} pixel_f565; +typedef struct { + unsigned short red:5; + unsigned short green:5; + unsigned short blue:5; + unsigned short alpha:1; +} pixel_f5551; +typedef struct { + unsigned short red:4; + unsigned short green:4; + unsigned short blue:4; + unsigned short alpha:4; +} pixel_f4444; +typedef struct { + unsigned char red; + unsigned char green; + unsigned char blue; +} pixel_f888; + +GLenum +check_for_glError_and_warn(GLenum expect, char *message) +{ + GLenum err; + + err = glGetError(); + if (expect && !err) { + fprintf(stderr, "Expected %x but was not returned: %s\n", expect, message); + } else if (err && expect!=0 && expect!=err) { + fprintf(stderr, "%s: 0x%04x\n",message, err); + } + return err; +} + +void +clear_buffer(void) +{ + memset(&buffer, TEST_PATTERN_BYTE, piglit_width*(piglit_height+50)*4); +} + +enum piglit_result +check_buffer_RGB(void) +{ + pixel_f888 *p888; + int i,j; + + /* check that the rectangle was rendered correctly */ + for (i=piglit_height/4; i<piglit_height/4*3; i++) { + for (j=piglit_width/4; j<piglit_width/4*3; j++) { + p888=(pixel_f888 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*3)); + if (p888->red!=0xff && p888->green!=0x00 && p888->blue!=0x00) + return PIGLIT_FAIL; + } + } + + /* check that the remaining area is black */ + for(i=0; i<piglit_height/4; i++) { + for(j=0; j<piglit_width; j++) { + p888=(pixel_f888 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*3)); + if (p888->red!=0x00 && p888->green!=0x00 && p888->blue!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4*3; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + p888=(pixel_f888 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*3)); + if (p888->red!=0x00 && p888->green!=0x00 && p888->blue!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=0; j<piglit_width/4; j++) { + p888=(pixel_f888 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*3)); + if (p888->red!=0x00 && p888->green!=0x00 && p888->blue!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=piglit_width/4*3; j<piglit_width; j++) { + p888=(pixel_f888 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*3)); + if (p888->red!=0x00 && p888->green!=0x00 && p888->blue!=0x00) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_RGBA(void) +{ + int i,j; + + /* check that the rectangle was rendered correctly */ + for (i=piglit_height/4; i<piglit_height/4*3; i++) { + for (j=piglit_width/4; j<piglit_width/4*3; j++) { + if (buffer[i][j][0]!=0xff && buffer[i][j][1]!=0x00 && + buffer[i][j][2]!=0x00 && buffer[i][j][3]!=0xff) + return PIGLIT_FAIL; + } + } + /* check that the remaining area is black */ + for(i=0; i<piglit_height/4; i++) { + for(j=0; j<piglit_width; j++) { + if (buffer[i][j][0]!=0x00 && buffer[i][j][1]!=0x00 && + buffer[i][j][2]!=0x00 && buffer[i][j][3]!=0xff) + return PIGLIT_FAIL; + } + } + for(i=(piglit_height/4)*3; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + if (buffer[i][j][0]!=0x00 && buffer[i][j][1]!=0x00 && + buffer[i][j][2]!=0x00 && buffer[i][j][3]!=0xff) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=0; j<piglit_width/4; j++) { + if (buffer[i][j][0]!=0x00 && buffer[i][j][1]!=0x00 && + buffer[i][j][2]!=0x00 && buffer[i][j][3]!=0xff) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=240; j<piglit_width; j++) { + if (buffer[i][j][0]!=0x00 && buffer[i][j][1]!=0x00 && + buffer[i][j][2]!=0x00 && buffer[i][j][3]!=0xff) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_ALPHA(void) +{ + GLubyte *alpha=(GLubyte *)buffer; + int i,j; + + for(i=0; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + if (*(alpha+(i*piglit_height)+j)!=0xff) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_is_not_changed(void) +{ + GLubyte *px=(GLubyte *)buffer; + int i,j; + + for(i=0; i<piglit_height; i++) { + for(j=0; j<(piglit_width+50); j++) { + if (*(px+(i*piglit_height)+j)!=TEST_PATTERN_BYTE) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_RGB_565(void) +{ + pixel_f565 *p565; + int i,j; + + /* check that the rectangle was rendered correctly */ + for (i=piglit_height/4; i<piglit_height/4*3; i++) { + for (j=piglit_width/4; j<piglit_width/4*3; j++) { + p565=(pixel_f565 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p565->red!=0x1f && p565->blue!=0x00 && + p565->green!=0x00) + return PIGLIT_FAIL; + } + } + /* check that the remaining area is black */ + for(i=0; i<piglit_height/4; i++) { + for(j=0; j<piglit_width; j++) { + p565=(pixel_f565 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p565->red!=0x00 && p565->blue!=0x00 && + p565->green!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4*3; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + p565=(pixel_f565 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p565->red!=0x00 && p565->blue!=0x00 && + p565->green!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=0; j<piglit_width/4; j++) { + p565=(pixel_f565 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p565->red!=0x00 && p565->green!=0x00 && + p565->blue!=0x00) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=piglit_width/4*3; j<piglit_width; j++) { + p565=(pixel_f565 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p565->red!=0x00 && p565->green!=0x00 && + p565->blue!=0x00) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_RGBA_5551(void) +{ + pixel_f5551 *p5551; + int i,j; + + /* check that the rectangle was rendered correctly */ + for (i=piglit_height/4; i<piglit_height/4*3; i++) { + for (j=piglit_width/4; j<piglit_width/4*3; j++) { + p5551=(pixel_f5551 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p5551->red!=0x1f && p5551->blue!=0x00 && + p5551->green!=0x00 && p5551->alpha!=0x1) + return PIGLIT_FAIL; + } + } + /* check that the remaining area is black */ + for(i=0; i<piglit_height/4; i++) { + for(j=0; j<piglit_width; j++) { + p5551=(pixel_f5551 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p5551->red!=0x00 && p5551->green!=0x00 && + p5551->blue!=0x00 && p5551->alpha!=0x1) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4*3; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + p5551=(pixel_f5551 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p5551->red!=0x00 && p5551->green!=0x00 && + p5551->blue!=0x00 && p5551->alpha!=0x1) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=0; j<piglit_width/4; j++) { + p5551=(pixel_f5551 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p5551->red!=0x00 && p5551->green!=0x00 && + p5551->blue!=0x00 && p5551->alpha!=0x1) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=piglit_width/4*3; j<piglit_width; j++) { + p5551=(pixel_f5551 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p5551->red!=0x00 && p5551->green!=0x00 && + p5551->blue!=0x00 && p5551->alpha!=0x1) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +enum piglit_result +check_buffer_RGBA_4444(void) +{ + pixel_f4444 *p4444; + int i,j; + + /* check that the rectangle was rendered correctly */ + for (i=piglit_height/4; i<piglit_height/4*3; i++) { + for (j=piglit_width/4; j<piglit_width/4*3; j++) { + p4444=(pixel_f4444 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p4444->red!=0xf && p4444->green!=0x00 && + p4444->blue!=0x00 && p4444->alpha!=0xf) + return PIGLIT_FAIL; + } + } + /* check that the remaining area is black */ + for(i=0; i<piglit_height/4; i++) { + for(j=0; j<piglit_width; j++) { + p4444=(pixel_f4444 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p4444->red!=0x00 && p4444->green!=0x00 && + p4444->blue!=0x00 && p4444->alpha!=0xf) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4*3; i<piglit_height; i++) { + for(j=0; j<piglit_width; j++) { + p4444=(pixel_f4444 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p4444->red!=0x00 && p4444->green!=0x00 && + p4444->blue!=0x00 && p4444->alpha!=0xf) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=0; j<piglit_width/4; j++) { + p4444=(pixel_f4444 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p4444->red!=0x00 && p4444->green!=0x00 && + p4444->blue!=0x00 && p4444->alpha!=0xf) + return PIGLIT_FAIL; + } + } + for(i=piglit_height/4; i<piglit_height/4*3; i++) { + for(j=piglit_width/4*3; j<piglit_width; j++) { + p4444=(pixel_f4444 *)(((GLubyte *)buffer)+(((i*piglit_width)+j)*2)); + if (p4444->red!=0x00 && p4444->green!=0x00 && + p4444->blue!=0x00 && p4444->alpha!=0xf) + return PIGLIT_FAIL; + } + } + + return PIGLIT_PASS; +} + +/* Tests glReadPixels using the following variations + * GL_RGBA GL_UNSIGNED_BYTE (different coords) + * GL_LUMINANCE GL_UNSIGNED_BYTE + * GL_LUMINANCE_ALPHA GL_UNSIGNED_BYTE + * GL_DEPTH_COMPONENT GL_UNSIGNED_BYTE + * 0x1800 (invalid) GL_UNSIGNED_BYTE + * GL_RGBA GL_UNSIGNED_BYTE + * GL_RGBA GL_UNSIGNED_SHORT_5_6_5 + * GL_RGBA GL_UNSIGNED_SHORT_5_5_5_1 (commented out) + * GL_RGBA GL_UNSIGNED_SHORT_4_4_4_4 + * GL_ALPHA GL_UNSIGNED_BYTE + * GL_ALPHA GL_UNSIGNED_SHORT_5_6_5 (commented out) + * GL_ALPHA GL_UNSIGNED_SHORT_5_5_5_1 (commented out) + * GL_ALPHA GL_UNSIGNED_SHORT_4_4_4_4 (commented out) + * GL_RGB GL_UNSIGNED_BYTE + * GL_RGB GL_UNSIGNED_SHORT_5_6_5 + * GL_RGB GL_UNSIGNED_SHORT_5_5_5_1 + * GL_RGB GL_UNSIGNED_SHORT_4_4_4_4 (commented out) + */ + +enum piglit_result +validate_results() +{ + /* first make sure glError has no issues */ + if (!piglit_check_gl_error(0)) + return PIGLIT_FAIL; + + clear_buffer(); + + glReadPixels(-10, -10, 10, 10, + GL_RGBA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(0,"Reading from -10 -10 failed"); + if (check_buffer_is_not_changed()==PIGLIT_FAIL) { + fprintf(stderr,"Reading from -10 -10 for 10x10 should not copy data\n"); + } + + clear_buffer(); + glReadPixels(0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(0,"Reading from 0 0 for 0x0 should not copy data"); + if (check_buffer_is_not_changed()==PIGLIT_FAIL) { + fprintf(stderr, "Reading from 0 0 for 0x0 should not copy data\n"); + } + + glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + check_for_glError_and_warn(0,"Reading from 0 0 for 1x1 to NULL failed"); + + clear_buffer(); + glReadPixels(0, 0, -10, -10, GL_RGBA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(GL_INVALID_VALUE,"neg width/height should gen GL_INVALID_VALUE"); + if (check_buffer_is_not_changed()==PIGLIT_FAIL) { + fprintf(stderr, "Reading from 0 0 for -10x-10 should not copy data\n"); + } + + /* according to + * http://www.khronos.org/opengles/sdk/docs/man/ glReadPixels + * only GL_RGBA, GL_RGB and GL_ALPHA are valid format parameters + * GL_LUMINANCE, GL_LUMINANCE_ALPHA and GL_DEPTH_COMPONENT + * should fail and return an error + */ + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(GL_INVALID_OPERATION,"GL_LUMINANCE should gen GL_INVALID_OPERATION"); + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(GL_INVALID_OPERATION,"GL_LUMINANCE_ALPHA should gen GL_INVALID_OPERATION"); + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(GL_INVALID_OPERATION,"GL_DEPTH_COMPONENT should gen GL_INVALID_OPERATION"); + + /* on mesa currently it incorrectly returns GL_INVALID_VALUE */ + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + 0x1800, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(GL_INVALID_OPERATION,"MISC format 0x1800 should gen GL_INVALID_OPERATION"); + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGBA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(0,"RGBA & GL_UNSIGNED_BTYE glReadPixels failed"); + if (check_buffer_RGBA() == PIGLIT_FAIL) { + fprintf(stderr, "RGBA GL_UNSIGNED_BYTE incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &buffer); + check_for_glError_and_warn(GL_INVALID_OPERATION,"GL_RGBA and 565 should gen GL_INVALID_OPERATION"); + +/* data is returned by this variation but it's goofed up + commenting out for now, will take issue upstream. + clear_buffer(); + glReadPixels(0,0,piglit_width,piglit_height,GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, &buffer); + check_for_glError_and_warn(0,"RGBA & GL_UNSIGNED_SHORT 5551 glReadPixels failed"); + if (check_buffer_RGBA_5551()==PIGLIT_FAIL) { + fprintf(stderr, "RGBA GL_UNSIGNED_SHORT 5551 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } +*/ + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, &buffer); + check_for_glError_and_warn(0,"RGBA & GL_UNSIGNED_SHORT 4444 glReadPixels failed"); + if (check_buffer_RGBA_4444()==PIGLIT_FAIL) { + fprintf(stderr, "RGBA GL_UNSIGNED_SHORT 4444 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_ALPHA, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(0,"ALPHA & GL_UNSIGNED_BTYE glReadPixels failed"); + if (check_buffer_ALPHA()==PIGLIT_FAIL) { + fprintf(stderr, "ALPHA GL_UNSIGNED_BYTE incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + /* data is returned by this variation but it's completely goofed up + will take issue upstream. + clear_buffer(); + glReadPixels(0,0,piglit_width,piglit_height,GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &buffer); + check_for_glError_and_warn(0,"ALPHA & GL_UNSIGNED_SHORT 565 glReadPixels failed"); + if (check_buffer_ALPHA()==PIGLIT_FAIL) { + fprintf(stderr, "ALPHA GL_UNSIGNED_BYTE incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0,0,piglit_width,piglit_height,GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &buffer); + check_for_glError_and_warn(0,"ALPHA & GL_UNSIGNED_SHORT 5551 glReadPixels failed"); + if (check_buffer_ALPHA()==PIGLIT_FAIL) { + fprintf(stderr, "ALPHA GL_UNSIGNED_SHORT 5551 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0,0,piglit_width,piglit_height,GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &buffer); + check_for_glError_and_warn(0,"ALPHA & GL_UNSIGNED_SHORT 4444 glReadPixels failed"); + if (check_buffer_ALPHA()==PIGLIT_FAIL) { + fprintf(stderr, "ALPHA GL_UNSIGNED_SHORT 4444 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } */ + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGB, GL_UNSIGNED_BYTE, &buffer); + check_for_glError_and_warn(0,"RGB & GL_UNSIGNED_BTYE glReadPixels failed"); + if (check_buffer_RGB() == PIGLIT_FAIL) { + fprintf(stderr, "RGB GL_UNSIGNED_BYTE incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0, 0, piglit_width, piglit_height, + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, &buffer); + check_for_glError_and_warn(0,"RGB & GL_UNSIGNED_BTYE glReadPixels failed"); + if (check_buffer_RGB_565()==PIGLIT_FAIL) { + fprintf(stderr, "RGB GL_UNSIGNED_SHORT 565 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + + clear_buffer(); + glReadPixels(0, 0, piglit_width,piglit_height, + GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &buffer); + check_for_glError_and_warn(0,"RGB & GL_UNSIGNED_SHORT 5551 glReadPixels failed"); + if (check_buffer_RGBA_5551() == PIGLIT_FAIL) { + fprintf(stderr, "RGB GL_UNSIGNED_SHORT 5551 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } + +/* this silently fails and doesn't modify the buffer + clear_buffer(); + glReadPixels(0,0,piglit_width,piglit_height,GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &buffer); + check_for_glError_and_warn(0,"RGB & GL_UNSIGNED_SHORT 4444 glReadPixels failed"); + if (check_buffer_RGB_4444() == PIGLIT_FAIL) { + fprintf(stderr, "RGB GL_UNSIGNED_SHORT 4444 incorrect results\n"); + piglit_report_result(PIGLIT_WARN); + } +*/ + + piglit_report_result(PIGLIT_PASS); + + return PIGLIT_PASS; +} + +void +link_and_use_shaders(void) +{ + prog = glCreateProgram(); + + vert = piglit_compile_shader_text(GL_VERTEX_SHADER, vertex_shader); + frag = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fragment_shader); + + glAttachShader(prog, vert); + glAttachShader(prog, frag); + + glLinkProgram(prog); + if (!(piglit_link_check_status(prog))) { + piglit_report_result(PIGLIT_FAIL); + return; + } + + glDeleteShader(vert); + glDeleteShader(frag); + + glUseProgram(prog); + if (!piglit_check_gl_error(0)) { + piglit_report_result(PIGLIT_FAIL); + return; + } +} + +enum piglit_result +piglit_display(void) +{ + GLfloat vertices[] = { + 0.5, -0.5, 0.0, + 0.5, 0.5, 0.0, + -0.5, 0.5, 0.0, + -0.5, -0.5, 0.0 }; + + glClear(GL_COLOR_BUFFER_BIT); + + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices); + glEnableVertexAttribArray(0); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + piglit_swap_buffers(); + + return validate_results(); +} + +void +piglit_init(int argc, char *argv[]) +{ + link_and_use_shaders(); +} -- 1.7.10.4 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit