Commit b31ebc8b authored by Eric Anholt's avatar Eric Anholt

pbo-drawpixels, pbo-teximage: Two new tests for tracking down a PBO issue.

parent fd4dbea9
......@@ -81,6 +81,8 @@ general['dlist-clear'] = PlainExecTest([testBinDir + 'dlist-clear', '-auto'])
general['draw-elements-base-vertex'] = PlainExecTest([testBinDir + 'draw-elements-base-vertex', '-auto'])
general['linestipple'] = PlainExecTest([testBinDir + 'linestipple', '-auto'])
general['occlusion_query'] = PlainExecTest([testBinDir + 'occlusion_query', '-auto'])
general['pbo-drawpixels'] = PlainExecTest([testBinDir + 'pbo-drawpixels', '-auto'])
general['pbo-teximage'] = PlainExecTest([testBinDir + 'pbo-teximage', '-auto'])
general['provoking-vertex'] = PlainExecTest([testBinDir + 'provoking-vertex', '-auto'])
general['read-front'] = PlainExecTest([testBinDir + 'read-front', '-auto'])
general['scissor-copypixels'] = PlainExecTest([testBinDir + 'scissor-copypixels', '-auto'])
......
......@@ -27,6 +27,8 @@ add_executable (depth_clamp depth_clamp.c)
add_executable (depthrange-clear depthrange-clear.c)
add_executable (draw-elements-base-vertex draw-elements-base-vertex.c)
add_executable (linestipple linestipple.c)
add_executable (pbo-drawpixels pbo-drawpixels.c)
add_executable (pbo-teximage pbo-teximage.c)
add_executable (provoking-vertex provoking-vertex.c)
add_executable (read-front read-front.c)
add_executable (scissor-copypixels scissor-copypixels.c)
......
/*
* Copyright © 2009 Intel Corporation
*
* 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.
*
* Authors:
* Eric Anholt <eric@anholt.net>
*
*/
/** @file pbo-drawpixels.c
*
* Tests that using a PBO as the unpack buffer for glDrawPixels works correctly.
* Caught a bug with the Intel driver with the metaops drawpixels code.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glew.h>
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include "GL/glut.h"
#endif
#include "piglit-util.h"
#define WIN_WIDTH 100
#define WIN_HEIGHT 100
static GLboolean Automatic = GL_FALSE;
static int win_width, win_height;
static void display(void)
{
GLboolean pass = GL_TRUE;
static float red[] = {1.0, 0.0, 0.0, 0.0};
static float green[] = {0.0, 1.0, 0.0, 0.0};
static float blue[] = {0.0, 0.0, 1.0, 0.0};
float *pixels;
GLuint pbo;
glClearColor(0.5, 0.5, 0.5, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glGenBuffersARB(1, &pbo);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, 4 * 4 * sizeof(float),
NULL, GL_STREAM_DRAW_ARB);
pixels = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB);
memcpy(pixels + 0, red, sizeof(red));
memcpy(pixels + 4, green, sizeof(green));
memcpy(pixels + 8, blue, sizeof(blue));
memcpy(pixels + 12, red, sizeof(red));
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER);
glRasterPos2i(10, 10);
glDrawPixels(2, 2, GL_RGBA, GL_FLOAT, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffersARB(1, &pbo);
pass &= piglit_probe_pixel_rgb(10, 10, red);
pass &= piglit_probe_pixel_rgb(11, 10, green);
pass &= piglit_probe_pixel_rgb(10, 11, blue);
pass &= piglit_probe_pixel_rgb(11, 11, red);
glutSwapBuffers();
if (Automatic)
piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
static void reshape(int width, int height)
{
win_width = width;
win_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
init(void)
{
reshape(WIN_WIDTH, WIN_HEIGHT);
piglit_require_extension("GL_ARB_pixel_buffer_object");
glewInit();
}
int main(int argc, char**argv)
{
int i;
glutInit(&argc, argv);
for(i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "-auto"))
Automatic = 1;
else
printf("Unknown option: %s\n", argv[i]);
}
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
glutInitWindowPosition(100, 100);
glutCreateWindow("pbo-drawpixels");
glutKeyboardFunc(piglit_escape_exit_key);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
/*
* Copyright © 2009 Intel Corporation
*
* 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.
*
* Authors:
* Eric Anholt <eric@anholt.net>
*
*/
/** @file pbo-teximage.c
*
* Tests that using a PBO as the unpack buffer for glTexImage works correctly.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glew.h>
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include "GL/glut.h"
#endif
#include "piglit-util.h"
#define WIN_WIDTH 100
#define WIN_HEIGHT 100
static GLboolean Automatic = GL_FALSE;
static int win_width, win_height;
static void display(void)
{
GLboolean pass = GL_TRUE;
static float red[] = {1.0, 0.0, 0.0, 0.0};
static float green[] = {0.0, 1.0, 0.0, 0.0};
static float blue[] = {0.0, 0.0, 1.0, 0.0};
float *pixels;
GLuint pbo, tex;
glClearColor(0.5, 0.5, 0.5, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glGenBuffersARB(1, &pbo);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, 4 * 4 * sizeof(float),
NULL, GL_STREAM_DRAW_ARB);
pixels = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB);
memcpy(pixels + 0, red, sizeof(red));
memcpy(pixels + 4, green, sizeof(green));
memcpy(pixels + 8, blue, sizeof(blue));
memcpy(pixels + 12, red, sizeof(red));
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER);
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA,
2, 2, 0,
GL_RGBA, GL_FLOAT, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffersARB(1, &pbo);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0.0, 0.0); glVertex2f(10, 10);
glTexCoord2f(1.0, 0.0); glVertex2f(20, 10);
glTexCoord2f(1.0, 1.0); glVertex2f(20, 20);
glTexCoord2f(0.0, 1.0); glVertex2f(10, 20);
glEnd();
glDeleteTextures(1, &tex);
pass &= piglit_probe_pixel_rgb(12, 12, red);
pass &= piglit_probe_pixel_rgb(18, 12, green);
pass &= piglit_probe_pixel_rgb(12, 18, blue);
pass &= piglit_probe_pixel_rgb(18, 18, red);
glutSwapBuffers();
if (Automatic)
piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
static void reshape(int width, int height)
{
win_width = width;
win_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
init(void)
{
reshape(WIN_WIDTH, WIN_HEIGHT);
piglit_require_extension("GL_ARB_pixel_buffer_object");
glewInit();
}
int main(int argc, char**argv)
{
int i;
glutInit(&argc, argv);
for(i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "-auto"))
Automatic = 1;
else
printf("Unknown option: %s\n", argv[i]);
}
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
glutInitWindowPosition(100, 100);
glutCreateWindow("pbo-teximage");
glutKeyboardFunc(piglit_escape_exit_key);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment