<div dir="ltr">A patch is coming out that fixes these.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 8, 2015 at 4:30 PM, Vinson Lee <span dir="ltr"><<a href="mailto:vlee@freedesktop.org" target="_blank">vlee@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Nov 25, 2014 at 11:19 AM, Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>> wrote:<br>
> ---<br>
> tests/all.py | 1 +<br>
> tests/spec/gl-2.1/CMakeLists.gl.txt | 1 +<br>
> tests/spec/gl-2.1/pbo.c | 1056 +++++++++++++++++++++++++++++++++++<br>
> 3 files changed, 1058 insertions(+)<br>
> create mode 100644 tests/spec/gl-2.1/pbo.c<br>
><br>
> diff --git a/tests/all.py b/tests/all.py<br>
> index de32fe7..dc3e938 100644<br>
> --- a/tests/all.py<br>
> +++ b/tests/all.py<br>
> @@ -913,6 +913,7 @@ add_concurrent_test(gl20, "gl-2.0-active-sampler-conflict")<br>
> gl21 = {}<br>
> spec['!OpenGL 2.1'] = gl21<br>
> gl21['minmax'] = PiglitGLTest('gl-2.1-minmax', run_concurrent=True)<br>
> +gl21['pbo'] = PiglitGLTest('gl-2.1-pbo', run_concurrent=True)<br>
><br>
> gl30 = {}<br>
> spec['!OpenGL 3.0'] = gl30<br>
> diff --git a/tests/spec/gl-2.1/CMakeLists.gl.txt b/tests/spec/gl-2.1/CMakeLists.gl.txt<br>
> index 7e60f1d..f395e32 100644<br>
> --- a/tests/spec/gl-2.1/CMakeLists.gl.txt<br>
> +++ b/tests/spec/gl-2.1/CMakeLists.gl.txt<br>
> @@ -11,3 +11,4 @@ link_libraries (<br>
> )<br>
><br>
> piglit_add_executable (gl-2.1-minmax minmax.c)<br>
> +piglit_add_executable (gl-2.1-pbo pbo.c)<br>
> diff --git a/tests/spec/gl-2.1/pbo.c b/tests/spec/gl-2.1/pbo.c<br>
> new file mode 100644<br>
> index 0000000..b6c51e9<br>
> --- /dev/null<br>
> +++ b/tests/spec/gl-2.1/pbo.c<br>
> @@ -0,0 +1,1056 @@<br>
> +/* BEGIN_COPYRIGHT -*- glean -*-<br>
> + *<br>
> + * Copyright (C) 2007, 2014 Intel Corporation<br>
> + * Copyright (C) 1999 Allen Akin All Rights Reserved.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person<br>
> + * obtaining a copy of this software and associated documentation<br>
> + * files (the "Software"), to deal in the Software without<br>
> + * restriction, including without limitation the rights to use,<br>
> + * copy, modify, merge, publish, distribute, sublicense, and/or<br>
> + * sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following<br>
> + * conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be<br>
> + * included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY<br>
> + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE<br>
> + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR<br>
> + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT<br>
> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN<br>
> + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF<br>
> + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> + * DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * END_COPYRIGHT<br>
> + */<br>
> +<br>
> +/** @file pbo.c<br>
> + *<br>
> + * Test OpenGL Extension GL_ARB_pixel_buffer_object<br>
> + *<br>
> + * Authors:<br>
> + * Shuang He <<a href="mailto:shuang.he@intel.com">shuang.he@intel.com</a>><br>
> + * Adapted to Piglit by Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>>, November 2014.<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl.h"<br>
> +<br>
> +#define WINSIZE 100<br>
> +#define BUFFER_OFFSET(i) ((char *)NULL + (i))<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_BEGIN<br>
> +<br>
> + config.supports_gl_compat_version = 10;<br>
> +<br>
> + config.window_visual = PIGLIT_GL_VISUAL_RGBA |<br>
> + PIGLIT_GL_VISUAL_DOUBLE;<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_END<br>
> +<br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> + piglit_require_extension("GL_ARB_pixel_buffer_object");<br>
> +<br>
> + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
> +}<br>
> +<br>
> +static void<br>
> +report_failure(const char *msg, const int line)<br>
> +{<br>
> + printf("FAILURE: %s (at pbo.c: %d)\n", msg, line);<br>
> +}<br>
> +<br>
> +#define REPORT_FAILURE(MSG) report_failure(MSG, __LINE__)<br>
> +<br>
> +#define TEXSIZE 64<br>
> +<br>
> +enum piglit_result<br>
> +test_sanity(void)<br>
> +{<br>
> + GLuint pbs[1];<br>
> + GLuint pb_binding;<br>
> +<br>
> + glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING_ARB,<br>
> + (GLint *) & pb_binding);<br>
> + if (pb_binding != 0) {<br>
> + REPORT_FAILURE("Failed to bind unpack pixel buffer object");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING_ARB,<br>
> + (GLint *) & pb_binding);<br>
> + if (pb_binding != 0) {<br>
> + REPORT_FAILURE("Failed to bind pack pixel buffer object");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + glGenBuffersARB(1, pbs);<br>
> +<br>
> + if (glIsBufferARB(pbs[0]) != GL_FALSE) {<br>
> + REPORT_FAILURE("glIsBufferARB failed");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbs[0]);<br>
> + glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING_ARB,<br>
> + (GLint *) & pb_binding);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + if (pb_binding != pbs[0]) {<br>
> + REPORT_FAILURE("Failed to bind unpack pixel buffer object");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbs[0]);<br>
> + glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING_ARB,<br>
> + (GLint *) & pb_binding);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> + if (pb_binding != pbs[0]) {<br>
> + REPORT_FAILURE("Failed to bind unpack pixel buffer object");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + glDeleteBuffersARB(1, pbs);<br>
> +<br>
> + if (glIsBufferARB(pbs[0]) == GL_TRUE) {<br>
> + REPORT_FAILURE("glIsBufferARB failed");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> +<br>
> + return PIGLIT_PASS;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_draw_pixels(void)<br>
> +{<br>
> + int use_unpack;<br>
> + int use_pack;<br>
> + GLuint pb_pack[1];<br>
> + GLuint pb_unpack[1];<br>
> + GLubyte buf[WINSIZE * WINSIZE * 4];<br>
> + GLubyte t[TEXSIZE * TEXSIZE * 4];<br>
> + int i, j;<br>
> + GLubyte * pbo_pack_mem = NULL;<br>
> + GLubyte black[4] = { 0, 0, 0, 255 };<br>
> + bool pass = true;<br>
> + GLubyte expected[WINSIZE * WINSIZE * 4];<br>
> +<br>
> + glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + for (use_unpack = 0; use_unpack < 2; use_unpack++) {<br>
> + for (use_pack = 0; use_pack < 2; use_pack++) {<br>
> + GLubyte *pbo_mem = NULL;<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, pb_unpack);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + pb_unpack[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + TEXSIZE * TEXSIZE * 4 *<br>
> + sizeof(GLubyte), NULL,<br>
> + GL_STREAM_DRAW);<br>
> + }<br>
> + if (use_unpack) {<br>
> + pbo_mem = (GLubyte *) glMapBufferARB(<br>
> + GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = t;<br>
> + }<br>
> +<br>
> + /* Fill the buffer */<br>
> + for (i = 0; i < TEXSIZE; i++)<br>
> + for (j = 0; j < TEXSIZE; j++) {<br>
> + int idx = 4 * (i * TEXSIZE + j);<br>
> + pbo_mem[idx + 0] = i % 256;<br>
> + pbo_mem[idx + 1] = i % 256;<br>
> + pbo_mem[idx + 2] = i % 256;<br>
> + pbo_mem[idx + 3] = 0;<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 0);<br>
> + }<br>
> +<br>
> + /* Draw the buffer */<br>
> + if (use_unpack) {<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + pb_unpack[0]);<br>
> + glDrawPixels(TEXSIZE, TEXSIZE, GL_BGRA,<br>
> + GL_UNSIGNED_BYTE, NULL);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 0);<br>
> + }<br>
> + else {<br>
> + glDrawPixels(TEXSIZE, TEXSIZE, GL_BGRA,<br>
> + GL_UNSIGNED_BYTE, pbo_mem);<br>
> + }<br>
> +<br>
> + if (!piglit_automatic)<br>
> + piglit_present_results();<br>
> +<br>
> + /* Check the result */<br>
> + if (use_pack) {<br>
> + glGenBuffersARB(1, pb_pack);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + pb_pack[0]);<br>
> + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + WINSIZE * WINSIZE * 4 *<br>
> + sizeof(GL_UNSIGNED_BYTE),<br>
> + NULL, GL_STREAM_DRAW);<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE,<br>
> + GL_BGRA, GL_UNSIGNED_BYTE, NULL);<br>
> + pbo_pack_mem = (GLubyte *) glMapBufferARB(<br>
> + GL_PIXEL_PACK_BUFFER_ARB,<br>
> + GL_READ_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_pack_mem = buf;<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE,<br>
> + GL_BGRA,<br>
> + GL_UNSIGNED_BYTE, pbo_pack_mem);<br>
> + }<br>
> +<br>
> + /* Make expected. */<br>
> + for (j = 0; j < WINSIZE; j++) {<br>
> + for (i = 0; i < WINSIZE; i++) {<br>
> + int idx = (j * WINSIZE + i) * 4;<br>
> + if (i < TEXSIZE && j < TEXSIZE) {<br>
> + expected[idx + 0] = j % 256;<br>
> + expected[idx + 1] = j % 256;<br>
> + expected[idx + 2] = j % 256;<br>
> + expected[idx + 3] = 0;<br>
> + }<br>
> + else {<br>
> + expected[idx + 0] = black[0];<br>
> + expected[idx + 1] = black[1];<br>
> + expected[idx + 2] = black[2];<br>
> + expected[idx + 3] = black[3];<br>
> + }<br>
> + }<br>
> + }<br>
> +<br>
> + pass &= piglit_compare_images_ubyte(0, 0, WINSIZE,<br>
> + WINSIZE,<br>
> + expected,<br>
> + pbo_pack_mem);<br>
> +<br>
> + if (use_pack) {<br>
> + glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pb_pack);<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pb_unpack);<br>
> + }<br>
> +<br>
> + }<br>
> + }<br>
> +<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> +<br>
> +<br>
> +enum piglit_result<br>
> +test_pixel_map(void)<br>
> +{<br>
> + int use_unpack;<br>
> + int use_pack;<br>
> + GLuint pb_pack[1];<br>
> + GLuint pb_unpack[1];<br>
> + int i;<br>
> + int size;<br>
> + int max;<br>
> + GLushort *pbo_mem;<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + glGetIntegerv(GL_MAX_PIXEL_MAP_TABLE, &max);<br>
> +<br>
> + for (use_pack = 0; use_pack < 2; use_pack++) {<br>
> + for (use_unpack = 0; use_unpack < 2;<br>
> + use_unpack++) {<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, pb_unpack);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + pb_unpack[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + max * sizeof(GLushort), NULL,<br>
> + GL_STREAM_DRAW);<br>
> + }<br>
> + pbo_mem = NULL;<br>
> + if (use_unpack) {<br>
> + pbo_mem = (GLushort *) glMapBufferARB(<br>
> + GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = (GLushort *)<br>
> + malloc(sizeof(GLushort) * max);<br>
> + }<br>
> + for (i = 0; i < max; i++)<br>
> + pbo_mem[i] = max - i - 1;<br>
> +<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);<br>
> + glPixelMapusv(GL_PIXEL_MAP_R_TO_R, max, NULL);<br>
> + glPixelMapusv(GL_PIXEL_MAP_G_TO_G, max, NULL);<br>
> + glPixelMapusv(GL_PIXEL_MAP_B_TO_B, max, NULL);<br>
> + glPixelMapusv(GL_PIXEL_MAP_A_TO_A, max, NULL);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 0);<br>
> + }<br>
> + else {<br>
> + glPixelMapusv(GL_PIXEL_MAP_R_TO_R, max,<br>
> + pbo_mem);<br>
> + glPixelMapusv(GL_PIXEL_MAP_G_TO_G, max,<br>
> + pbo_mem);<br>
> + glPixelMapusv(GL_PIXEL_MAP_B_TO_B, max,<br>
> + pbo_mem);<br>
> + glPixelMapusv(GL_PIXEL_MAP_A_TO_A, max,<br>
> + pbo_mem);<br>
> + free(pbo_mem);<br>
> + }<br>
> +<br>
> +<br>
> + glGetIntegerv(GL_PIXEL_MAP_R_TO_R_SIZE, &size);<br>
> + if (size != max) {<br>
> + REPORT_FAILURE("glPixelMap failed");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> + glPixelTransferi(GL_MAP_COLOR, GL_FALSE);<br>
> +<br>
> + /* Read back pixel map */<br>
> + if (use_pack) {<br>
> + glGenBuffersARB(1, pb_pack);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + pb_pack[0]);<br>
> + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + max * sizeof(GLushort),<br>
> + NULL, GL_STREAM_DRAW);<br>
> + glGetPixelMapusv(GL_PIXEL_MAP_R_TO_R, NULL);<br>
> + pbo_mem = (GLushort *) glMapBufferARB(<br>
> + GL_PIXEL_PACK_BUFFER_ARB,<br>
> + GL_READ_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = (GLushort *)<br>
> + malloc(sizeof(GLushort) * max);<br>
> + glGetPixelMapusv(GL_PIXEL_MAP_R_TO_R, pbo_mem);<br>
> + }<br>
> +<br>
> + for (i = 0; i < max; i++) {<br>
> + if (pbo_mem[i] != (255 - i)) {<br>
> + REPORT_FAILURE("get PixelMap failed");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> + }<br>
> +<br>
> +<br>
> + if (use_pack) {<br>
> + glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pb_pack);<br>
> + }<br>
> + else {<br>
> + free(pbo_mem);<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 0);<br>
> + glDeleteBuffersARB(1, pb_unpack);<br>
> + }<br>
> +<br>
> + if (!piglit_automatic)<br>
> + piglit_present_results();<br>
> +<br>
> + }<br>
> + }<br>
> +<br>
> + return PIGLIT_PASS;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_bitmap(void)<br>
> +{<br>
> + GLuint pb_unpack[1];<br>
> + GLuint pb_pack[1];<br>
> + int use_unpack = 1;<br>
> + int use_pack = 0;<br>
> + GLubyte bitmap[TEXSIZE * TEXSIZE / 8];<br>
> + GLfloat buf[WINSIZE * WINSIZE * 3];<br>
> + GLfloat white[3] = { 1.0, 1.0, 1.0 };<br>
> + GLfloat black[3] = { 0.0, 0.0, 0.0 };<br>
> + int i, j;<br>
> + GLubyte *pbo_unpack_mem = NULL;<br>
> + GLfloat *pbo_pack_mem = NULL;<br>
> + GLfloat expected[WINSIZE * WINSIZE * 3];<br>
> + float tolerance[4];<br>
> + bool pass = true;<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + for (use_pack = 0; use_pack < 2; use_pack++) {<br>
> + for (use_unpack = 0; use_unpack < 2;<br>
> + use_unpack++) {<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> +<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, pb_unpack);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + pb_unpack[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + TEXSIZE * TEXSIZE,<br>
> + NULL, GL_STREAM_DRAW);<br>
> + pbo_unpack_mem = (GLubyte *) glMapBufferARB(<br>
> + GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_unpack_mem = bitmap;<br>
> + }<br>
> +<br>
> + for (i = 0; i < TEXSIZE * TEXSIZE / 8; i++) {<br>
> + pbo_unpack_mem[i] = 0xAA; /* Binary 10101010 */<br>
> + }<br>
> +<br>
> +<br>
> + glColor4f(1.0, 1.0, 1.0, 0.0);<br>
> + glRasterPos2f(0.0, 0.0);<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);<br>
> + /* Draw white into every other pixel,<br>
> + * for a white/black checkerboard. */<br>
> + glBitmap(TEXSIZE, TEXSIZE, 0, 0, 0, 0, NULL);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 0);<br>
> + }<br>
> + else {<br>
> + glBitmap(TEXSIZE, TEXSIZE, 0, 0, 0, 0,<br>
> + pbo_unpack_mem);<br>
> + }<br>
> +<br>
> + if (!piglit_automatic)<br>
> + piglit_present_results();<br>
> +<br>
> + /* Check the result */<br>
> + if (use_pack) {<br>
> + glGenBuffersARB(1, pb_pack);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + pb_pack[0]);<br>
> + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + WINSIZE * WINSIZE *<br>
> + 4 * sizeof(GLfloat), NULL,<br>
> + GL_STREAM_DRAW);<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE,<br>
> + GL_RGB, GL_FLOAT,<br>
> + NULL);<br>
> + pbo_pack_mem =<br>
> + (GLfloat *) glMapBufferARB(<br>
> + GL_PIXEL_PACK_BUFFER_ARB,<br>
> + GL_READ_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_pack_mem = buf;<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE,<br>
> + GL_RGB, GL_FLOAT, pbo_pack_mem);<br>
> + }<br>
> +<br>
> + /* Compute expected and compare it to the result. */<br>
> + for (j = 0; j < WINSIZE; j++) {<br>
> + for (i = 0; i < WINSIZE; i++) {<br>
> + int idx = (j * WINSIZE + i) * 3;<br>
> + if ((i & 1) || (i >= TEXSIZE) ||<br>
> + (j >= TEXSIZE)) {<br>
> + expected[idx + 0] = black[0];<br>
> + expected[idx + 1] = black[1];<br>
> + expected[idx + 2] = black[2];<br>
> + expected[idx + 3] = black[3];<br>
> + }<br>
> + else {<br>
> + expected[idx + 0] = white[0];<br>
> + expected[idx + 1] = white[1];<br>
> + expected[idx + 2] = white[2];<br>
> + expected[idx + 3] = white[3];<br>
> + }<br>
> + }<br>
> + }<br>
> + piglit_compute_probe_tolerance(GL_RGB, &tolerance[0]);<br>
> + pass &= piglit_compare_images_color(0, 0, WINSIZE,<br>
> + WINSIZE, 3,<br>
> + tolerance,<br>
> + expected,<br>
> + pbo_pack_mem);<br>
> +<br>
> + if (use_pack) {<br>
> + glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);<br>
> + glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pb_pack);<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pb_unpack);<br>
> + }<br>
> + }<br>
> + }<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> +<br>
> +<br>
> +enum piglit_result<br>
> +test_tex_image(void)<br>
> +{<br>
> + bool pass = true;<br>
> +<br>
> + int break_pbo_cow, break_tex_cow; /* cow = copy on write */<br>
> + int use_unpack, use_pack;<br>
> + GLuint unpack_pb[1];<br>
> + GLuint pack_pb[1];<br>
> + GLenum pack = GL_PIXEL_PACK_BUFFER_ARB;<br>
> + GLenum unpack = GL_PIXEL_UNPACK_BUFFER_ARB;<br>
> + int texture_size = TEXSIZE * TEXSIZE * 3;<br>
> + GLfloat t1[texture_size];<br>
> + GLfloat t2[texture_size];<br>
> + GLfloat *pbo_mem = NULL;<br>
> + int i, j;<br>
> + GLfloat green[3] = { 1.0, 1.0, 0.0 };<br>
> + GLfloat black[3] = { 0.0, 0.0, 0.0 };<br>
> + int window_size = WINSIZE * WINSIZE * 3;<br>
> + GLfloat buf[window_size];<br>
> + GLfloat exp_tex[texture_size];<br>
> + GLfloat exp_win[window_size];<br>
> + GLfloat tolerance[4];<br>
> +<br>
> + piglit_compute_probe_tolerance(GL_RGB, tolerance);<br>
> +<br>
> + glBindBufferARB(unpack, 0);<br>
> + glBindBufferARB(pack, 0);<br>
> +<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> +<br>
> + for (use_pack = 0; use_pack < 2; use_pack++) {<br>
> + for (use_unpack = 0; use_unpack < 2;<br>
> + use_unpack++) {<br>
> + for (break_pbo_cow = 0; break_pbo_cow < use_unpack + 1;<br>
> + break_pbo_cow++) {<br>
> + for (break_tex_cow = 0;<br>
> + break_tex_cow < use_unpack + 1;<br>
> + break_tex_cow++) {<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, unpack_pb);<br>
> + glBindBufferARB(unpack,<br>
> + unpack_pb[0]);<br>
> + glBufferDataARB(unpack,<br>
> + texture_size *<br>
> + sizeof(GLfloat),<br>
> + NULL, GL_STREAM_DRAW);<br>
> + }<br>
> +<br>
> + glTexParameteri(GL_TEXTURE_2D,<br>
> + GL_TEXTURE_MIN_FILTER,<br>
> + GL_NEAREST);<br>
> + glTexParameteri(GL_TEXTURE_2D,<br>
> + GL_TEXTURE_MAG_FILTER,<br>
> + GL_NEAREST);<br>
> +<br>
> + if (use_unpack) {<br>
> + pbo_mem = (GLfloat *)<br>
> + glMapBufferARB(unpack,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = t1;<br>
> + }<br>
> +<br>
> + for (i = 0; i < texture_size/3; i++) {<br>
> + pbo_mem[3 * i] = 1.0;<br>
> + pbo_mem[3 * i + 1] = 1.0;<br>
> + pbo_mem[3 * i + 2] = 0.0;<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(unpack);<br>
> + glTexImage2D(GL_TEXTURE_2D, 0,<br>
> + GL_RGB, TEXSIZE,<br>
> + TEXSIZE, 0,<br>
> + GL_RGB, GL_FLOAT,<br>
> + NULL);<br>
> + glBindBufferARB(unpack, 0);<br>
> + }<br>
> + else<br>
> + glTexImage2D(GL_TEXTURE_2D, 0,<br>
> + GL_RGB, TEXSIZE,<br>
> + TEXSIZE, 0,<br>
> + GL_RGB, GL_FLOAT,<br>
> + pbo_mem);<br>
> +<br>
> + if (use_unpack && break_pbo_cow) {<br>
> + glBindBufferARB(unpack,<br>
> + unpack_pb[0]);<br>
> + pbo_mem = (GLfloat *)<br>
> + glMapBufferARB(<br>
> + unpack,<br>
> + GL_WRITE_ONLY);<br>
> + for (i = 0; i < texture_size; i++)<br>
> + pbo_mem[i] = 0.2;<br>
> + glUnmapBufferARB(unpack);<br>
> + glBindBufferARB(unpack, 0);<br>
> + }<br>
> +<br>
> + if (use_unpack && break_tex_cow) {<br>
> + GLfloat temp[3];<br>
> + for (i = 0; i < 3; i++)<br>
> + temp[i] = 0.8;<br>
> + glTexSubImage2D(GL_TEXTURE_2D,<br>
> + 0, 0, 0, 1, 1,<br>
> + GL_RGB,<br>
> + GL_FLOAT,<br>
> + temp);<br>
> + }<br>
> +<br>
> + /* Check PBO's content */<br>
> + if (use_unpack) {<br>
> + glBindBufferARB(unpack,<br>
> + unpack_pb[0]);<br>
> + pbo_mem = (GLfloat *)<br>
> + glMapBuffer(unpack,<br>
> + GL_READ_ONLY);<br>
> + if (break_pbo_cow) {<br>
> + for (i = 0; i < texture_size; i++)<br>
> + if (fabsf(pbo_mem[i] - 0.2) > tolerance[0]) {<br>
> + REPORT_FAILURE<br>
> + ("PBO modified by someone else, "<br>
> + "there must be something wrong");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> + }<br>
> + glUnmapBufferARB(unpack);<br>
> + glBindBufferARB(unpack, 0);<br>
> + }<br>
> +<br>
> +<br>
> + /* Read texture back */<br>
> + if (use_pack) {<br>
> + glGenBuffersARB(1, pack_pb);<br>
> + glBindBufferARB(pack, pack_pb[0]);<br>
> + glBufferDataARB(pack,<br>
> + texture_size *<br>
> + sizeof(GLfloat),<br>
> + NULL, GL_STREAM_DRAW);<br>
> + glGetTexImage(GL_TEXTURE_2D,<br>
> + 0, GL_RGB,<br>
> + GL_FLOAT, NULL);<br>
> + pbo_mem = (GLfloat *)<br>
> + glMapBufferARB(pack,<br>
> + GL_READ_ONLY);<br>
> + }<br>
> + else {<br>
> + glGetTexImage(GL_TEXTURE_2D,<br>
> + 0, GL_RGB,<br>
> + GL_FLOAT, t2);<br>
> + pbo_mem = t2;<br>
> + }<br>
> +<br>
> + /* Check texture image */<br>
> + for (i = 0; i < texture_size/3; i++) {<br>
> + int idx = i * 3;<br>
> + if (i == 0 && break_tex_cow<br>
> + && use_unpack) {<br>
> + exp_tex[idx + 0] = 0.8;<br>
> + exp_tex[idx + 1] = 0.8;<br>
> + exp_tex[idx + 2] = 0.8;<br>
> + }<br>
> + else {<br>
> + exp_tex[idx + 0] = 1.0;<br>
> + exp_tex[idx + 1] = 1.0;<br>
> + exp_tex[idx + 2] = 0.0;<br>
> + }<br>
> + }<br>
> + pass &= piglit_compare_images_color(0,<br>
> + 0, TEXSIZE,<br>
> + TEXSIZE, 3,<br>
> + tolerance, exp_tex,<br>
> + pbo_mem);<br>
> +<br>
> + if (use_pack) {<br>
> + glUnmapBufferARB(pack);<br>
> + glBindBufferARB(pack, 0);<br>
> + glDeleteBuffersARB(1, pack_pb);<br>
> + }<br>
> + if (use_unpack) {<br>
> + glDeleteBuffersARB(1, unpack_pb);<br>
> + }<br>
> +<br>
> + glEnable(GL_TEXTURE_2D);<br>
> + glBegin(GL_POLYGON);<br>
> + glTexCoord2f(0, 0);<br>
> + glVertex2f(0, 0);<br>
> + glTexCoord2f(1, 0);<br>
> + glVertex2f(TEXSIZE, 0);<br>
> + glTexCoord2f(1, 1);<br>
> + glVertex2f(TEXSIZE, TEXSIZE);<br>
> + glTexCoord2f(0, 1);<br>
> + glVertex2f(0, TEXSIZE);<br>
> + glEnd();<br>
> + glDisable(GL_TEXTURE_2D);<br>
> +<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE,<br>
> + GL_RGB, GL_FLOAT,<br>
> + buf);<br>
> +<br>
> + for (j = 0; j < WINSIZE; j++) {<br>
> + for (i = 0; i < WINSIZE; i++) {<br>
> + int idx = (j * WINSIZE + i) * 3;<br>
> + if (i == 0 && j == 0<br>
> + && break_tex_cow<br>
> + && use_unpack) {<br>
> + exp_win[idx + 0] = 0.8;<br>
> + exp_win[idx + 1] = 0.8;<br>
> + exp_win[idx + 2] = 0.8;<br>
> + }<br>
> + else if (i < TEXSIZE && j < TEXSIZE) {<br>
> + exp_win[idx + 0] = green[0];<br>
> + exp_win[idx + 1] = green[1];<br>
> + exp_win[idx + 2] = green[2];<br>
> + }<br>
> + else {<br>
> + exp_win[idx + 0] = black[0];<br>
> + exp_win[idx + 1] = black[1];<br>
> + exp_win[idx + 2] = black[2];<br>
> + }<br>
> + }<br>
> + }<br>
> + pass &= piglit_compare_images_color(0,<br>
> + 0, WINSIZE,<br>
> + WINSIZE, 3,<br>
> + tolerance, exp_win,<br>
> + buf);<br>
> + }<br>
> + }<br>
> + }<br>
> + }<br>
> +<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_tex_sub_image(void)<br>
> +{<br>
> + GLuint pbs[1];<br>
> + GLfloat t[TEXSIZE * TEXSIZE * 3];<br>
> + int i, j;<br>
> + int use_unpack = 0;<br>
> + GLfloat green[3] = { 0.0, 1.0, 0.0 };<br>
> + GLfloat black[3] = { 0.0, 0.0, 0.0 };<br>
> + GLfloat *pbo_mem = NULL;<br>
> + GLfloat buf[WINSIZE * WINSIZE * 3];<br>
> + bool pass = true;<br>
> + GLfloat expected[WINSIZE * WINSIZE * 3];<br>
> + GLfloat tolerance[4];<br>
> + piglit_compute_probe_tolerance(GL_RGB, &tolerance[0]);<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + for (use_unpack = 0; use_unpack < 2; use_unpack++) {<br>
> + pbo_mem = NULL;<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> +<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, pbs);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbs[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + TEXSIZE * TEXSIZE * 3 *<br>
> + sizeof(GLfloat), NULL, GL_STREAM_DRAW);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + }<br>
> +<br>
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TEXSIZE, TEXSIZE, 0, GL_RGB,<br>
> + GL_FLOAT, NULL);<br>
> +<br>
> + if (use_unpack) {<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbs[0]);<br>
> + pbo_mem = (GLfloat *) glMapBufferARB(<br>
> + GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = t;<br>
> + }<br>
> +<br>
> + for (i = 0; i < TEXSIZE * TEXSIZE; i++) {<br>
> + pbo_mem[3 * i] = 0.0;<br>
> + pbo_mem[3 * i + 1] = 1.0;<br>
> + pbo_mem[3 * i + 2] = 0.0;<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);<br>
> + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE,<br>
> + TEXSIZE, GL_RGB, GL_FLOAT, NULL);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + }<br>
> + else<br>
> + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE,<br>
> + TEXSIZE, GL_RGB, GL_FLOAT, pbo_mem);<br>
> +<br>
> + glEnable(GL_TEXTURE_2D);<br>
> + glBegin(GL_POLYGON);<br>
> + glTexCoord2f(0, 0);<br>
> + glVertex2f(0, 0);<br>
> + glTexCoord2f(1, 0);<br>
> + glVertex2f(10, 0);<br>
> + glTexCoord2f(1, 1);<br>
> + glVertex2f(10, 10);<br>
> + glTexCoord2f(0, 1);<br>
> + glVertex2f(0, 10);<br>
> + glEnd();<br>
> + glDisable(GL_TEXTURE_2D);<br>
> +<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE, GL_RGB, GL_FLOAT, buf);<br>
> +<br>
> + for (j = 0; j < WINSIZE; j++) {<br>
> + for (i = 0; i < WINSIZE; i++) {<br>
> + int idx = (j * WINSIZE + i) * 3;<br>
> + if (i < 10 && j < 10) {<br>
> + expected[idx + 0] = green[0];<br>
> + expected[idx + 1] = green[1];<br>
> + expected[idx + 2] = green[2];<br>
> + }<br>
> + else {<br>
> + expected[idx + 0] = black[0];<br>
> + expected[idx + 1] = black[1];<br>
> + expected[idx + 2] = black[2];<br>
> + }<br>
> + }<br>
> + }<br>
> + pass &= piglit_compare_images_color(0, 0, WINSIZE,<br>
> + WINSIZE, 3, tolerance,<br>
> + expected, buf);<br>
> + }<br>
> +<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_polygon_stip(void)<br>
> +{<br>
> + int use_unpack = 0;<br>
> + int use_pack = 0;<br>
> + GLuint unpack_pb[1];<br>
> + GLuint pack_pb[1];<br>
> + GLubyte t1[32 * 32 / 8];<br>
> + GLubyte t2[32 * 32 / 8];<br>
> + GLubyte *pbo_mem = NULL;<br>
> + int i, j;<br>
> + GLfloat white[3] = { 1.0, 1.0, 1.0 };<br>
> + GLfloat black[3] = { 0.0, 0.0, 0.0 };<br>
> + GLfloat buf[WINSIZE * WINSIZE * 3];<br>
> + bool pass = true;<br>
> + GLfloat expected[WINSIZE * WINSIZE * 3];<br>
> + GLfloat tolerance[4];<br>
> +<br>
> + piglit_compute_probe_tolerance(GL_RGB, &tolerance[0]);<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + for (use_unpack = 0; use_unpack < 2; use_unpack++) {<br>
> + for (use_pack = 0; use_pack < 2; use_pack++) {<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glClear(GL_COLOR_BUFFER_BIT);<br>
> +<br>
> + if (use_unpack) {<br>
> + glGenBuffersARB(1, unpack_pb);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + unpack_pb[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + 32 * 32 / 8, NULL,<br>
> + GL_STREAM_DRAW);<br>
> + pbo_mem = (GLubyte *) glMapBufferARB(<br>
> + GL_PIXEL_UNPACK_BUFFER_ARB,<br>
> + GL_WRITE_ONLY);<br>
> + }<br>
> + else {<br>
> + pbo_mem = t1;<br>
> + }<br>
> +<br>
> + /* Fill in the stipple pattern */<br>
> + for (i = 0; i < 32 * 32 / 8; i++) {<br>
> + pbo_mem[i] = 0xAA; /* Checkerboard */<br>
> + }<br>
> +<br>
> + if (use_unpack) {<br>
> + glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);<br>
> + glPolygonStipple(NULL);<br>
> + }<br>
> + else {<br>
> + glPolygonStipple(pbo_mem);<br>
> + }<br>
> +<br>
> + /* Read back the stipple pattern */<br>
> + if (use_pack) {<br>
> + glGenBuffersARB(1, pack_pb);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + pack_pb[0]);<br>
> + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,<br>
> + 32 * 32 / 8, NULL,<br>
> + GL_STREAM_DRAW);<br>
> + glGetPolygonStipple(NULL);<br>
> + pbo_mem = (GLubyte *) glMapBufferARB(<br>
> + GL_PIXEL_PACK_BUFFER_ARB,<br>
> + GL_READ_ONLY);<br>
> + }<br>
> + else {<br>
> + glGetPolygonStipple(t2);<br>
> + pbo_mem = t2;<br>
> + }<br>
> +<br>
> + for (i = 0; i < 32 * 32 / 8; i++) {<br>
> + if (pbo_mem[i] != 0xAA) {<br>
> + REPORT_FAILURE("glGetPolygonStipple failed");<br>
> + return PIGLIT_FAIL;<br>
> + }<br>
> + }<br>
> +<br>
> +<br>
> + if (use_unpack) {<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, unpack_pb);<br>
> + }<br>
> + if (use_pack) {<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> + glDeleteBuffersARB(1, pack_pb);<br>
> + }<br>
> +<br>
> + glEnable(GL_POLYGON_STIPPLE);<br>
> + glColor4f(1.0, 1.0, 1.0, 0.0);<br>
> + glBegin(GL_POLYGON);<br>
> + glVertex2f(0, 0);<br>
> + glVertex2f(10, 0);<br>
> + glVertex2f(10, 10);<br>
> + glVertex2f(0, 10);<br>
> + glEnd();<br>
> +<br>
> + glDisable(GL_POLYGON_STIPPLE);<br>
> +<br>
> + /* Check the result */<br>
> + glReadPixels(0, 0, WINSIZE, WINSIZE, GL_RGB, GL_FLOAT, buf);<br>
> +<br>
> + for (j = 0; j < WINSIZE; j++) {<br>
> + for (i = 0; i < WINSIZE; i++) {<br>
> + int idx = (j * WINSIZE + i) * 3;<br>
> + if (!(i & 1) && i < 10 && j < 10) {<br>
> + expected[idx + 0] = white[0];<br>
> + expected[idx + 1] = white[1];<br>
> + expected[idx + 2] = white[2];<br>
> + }<br>
> + else {<br>
> + expected[idx + 0] = black[0];<br>
> + expected[idx + 1] = black[1];<br>
> + expected[idx + 2] = black[2];<br>
> + }<br>
> + }<br>
> + }<br>
> + pass &= piglit_compare_images_color(0, 0, WINSIZE,<br>
> + WINSIZE, 3,<br>
> + tolerance,<br>
> + expected, buf);<br>
> +<br>
> + }<br>
> + }<br>
> +<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_error_handling(void)<br>
> +{<br>
> + GLuint fbs[1];<br>
> +<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);<br>
> +<br>
> + /* glDrawPixels raises an error when the buffer is too small */<br>
> + glGenBuffersARB(1, fbs);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, fbs[0]);<br>
> + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 32 * 32 * 4, NULL,<br>
> + GL_STREAM_DRAW);<br>
> + glDrawPixels(32, 32 + 1, GL_BGRA, GL_UNSIGNED_BYTE, NULL);<br>
> + if (glGetError() != GL_INVALID_OPERATION)<br>
> + return PIGLIT_FAIL;<br>
> +<br>
> + glDeleteBuffersARB(1, fbs);<br>
> + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);<br>
> +<br>
> + /* test that glReadPixels into too small of buffer raises error */<br>
> + glGenBuffersARB(1, fbs);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER, fbs[0]);<br>
> + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, 32 * 32 * 4, NULL,<br>
> + GL_STREAM_DRAW);<br>
> + glReadPixels(0, 0, 32, 32 + 1, GL_BGRA, GL_UNSIGNED_BYTE, NULL);<br>
> + if (glGetError() != GL_INVALID_OPERATION)<br>
> + return PIGLIT_FAIL;<br>
> +<br>
> + glDeleteBuffersARB(1, fbs);<br>
> + glBindBufferARB(GL_PIXEL_PACK_BUFFER, 0);<br>
> +<br>
> + return PIGLIT_PASS;<br>
> +}<br>
> +<br>
> +struct test_func {<br>
> + enum piglit_result (*func) (void);<br>
> + char *name;<br>
> +};<br>
> +<br>
> +enum piglit_result<br>
> +piglit_display(void)<br>
> +{<br>
> + int i = 0;<br>
> + enum piglit_result result = PIGLIT_PASS;<br>
> + enum piglit_result subtest;<br>
> + static struct test_func funcs[] = {<br>
> + {test_sanity, "test_sanity"},<br>
> + {test_draw_pixels, "test_draw_pixels"},<br>
> + {test_pixel_map, "test_pixel_map"},<br>
> + {test_bitmap, "test_bitmap"},<br>
> + {test_tex_image, "test_tex_image"},<br>
> + {test_tex_sub_image, "test_tex_sub_image"},<br>
> + {test_polygon_stip, "test_polygon_stip"},<br>
> + {test_error_handling, "test_error_handling"},<br>
> + {NULL, ""} /* End of list sentinal */<br>
> + };<br>
> +<br>
> + while (funcs[i].func)<br>
> + {<br>
> + subtest = funcs[i].func();<br>
> + piglit_report_subtest_result(subtest, "%s",<br>
> + funcs[i].name);<br>
> + if (subtest == PIGLIT_FAIL)<br>
> + result = PIGLIT_FAIL;<br>
> + i++;<br>
> + }<br>
> +<br>
> + return result;<br>
> +}<br>
> --<br>
> 2.1.0<br>
><br>
</div></div>> _______________________________________________<br>
> Piglit mailing list<br>
> <a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
<br>
<br>
This patch introduced several compiler warnings with GCC and Clang.<br>
<br>
pbo.c:484:27: warning: array index 3 is past the end of the array<br>
(which contains 3 elements) [-Warray-bounds]<br>
<span class=""> expected[idx + 3] = black[3];<br>
</span> ^ ~<br>
pbo.c:397:2: note: array 'black' declared here<br>
<span class=""> GLfloat black[3] = { 0.0, 0.0, 0.0 };<br>
</span> ^<br>
pbo.c:490:27: warning: array index 3 is past the end of the array<br>
(which contains 3 elements) [-Warray-bounds]<br>
<span class=""> expected[idx + 3] = white[3];<br>
</span> ^ ~<br>
pbo.c:396:2: note: array 'white' declared here<br>
<span class=""> GLfloat white[3] = { 1.0, 1.0, 1.0 };<br>
</span> ^<br>
pbo.c:529:12: warning: variable length array used [-Wvla]<br>
GLfloat t1[texture_size];<br>
^<br>
pbo.c:530:12: warning: variable length array used [-Wvla]<br>
GLfloat t2[texture_size];<br>
^<br>
pbo.c:536:13: warning: variable length array used [-Wvla]<br>
GLfloat buf[window_size];<br>
^<br>
pbo.c:537:17: warning: variable length array used [-Wvla]<br>
GLfloat exp_tex[texture_size];<br>
^<br>
pbo.c:538:17: warning: variable length array used [-Wvla]<br>
GLfloat exp_win[window_size];<br>
^<br>
pbo.c:638:13: warning: absolute value function 'fabsf' given an<br>
argument of type 'double' but has parameter of type 'float' which may<br>
cause truncation of value [-Wabsolute-value]<br>
<span class=""> if<br>
(fabsf(pbo_mem[i] - 0.2) > tolerance[0]) {<br>
</span> ^<br>
pbo.c:638:13: note: use function 'fabs' instead<br>
<span class=""> if<br>
(fabsf(pbo_mem[i] - 0.2) > tolerance[0]) {<br>
</span> ^~~~~<br>
fabs<br>
</blockquote></div><br></div>