fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / general / pbo-teximage-tiling.c
bloba95f25b457d3515aa5ffdfc1ff7b29b94ea7a454
1 /*
2 * Copyright © 2009,2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file pbo-teximage-tiling.c
30 * Tests that using a PBO as the unpack buffer for glTexImage works correctly
31 * when the stride is conveniently chosen to match what a tiled texture would
32 * be on Intel.
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
41 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
43 PIGLIT_GL_TEST_CONFIG_END
45 enum piglit_result
46 piglit_display(void)
48 GLboolean pass = GL_TRUE;
49 static float red[] = {1.0, 0.0, 0.0, 0.0};
50 static float green[] = {0.0, 1.0, 0.0, 0.0};
51 static float blue[] = {0.0, 0.0, 1.0, 0.0};
52 static float white[] = {1.0, 1.0, 1.0, 0.0};
53 uint32_t red_packed = 0x00ff0000;
54 uint32_t green_packed = 0x0000ff00;
55 uint32_t blue_packed = 0x000000ff;
56 uint32_t white_packed = 0x00ffffff;
57 uint32_t *pixels;
58 GLuint pbo, tex;
60 glClearColor(0.5, 0.5, 0.5, 0.0);
61 glClear(GL_COLOR_BUFFER_BIT);
63 glGenBuffersARB(1, &pbo);
64 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, pbo);
65 glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, 128 * 2 * sizeof(uint32_t),
66 NULL, GL_STREAM_DRAW_ARB);
67 glPixelStorei(GL_UNPACK_ROW_LENGTH, 128);
69 pixels = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB);
70 pixels[0] = red_packed;
71 pixels[1] = green_packed;
72 pixels[128] = blue_packed;
73 pixels[129] = white_packed;
74 glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER);
76 glGenTextures(1, &tex);
77 glBindTexture(GL_TEXTURE_2D, tex);
78 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
79 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
80 glTexImage2D(GL_TEXTURE_2D, 0,
81 GL_RGBA,
82 2, 2, 0,
83 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
84 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
85 glDeleteBuffersARB(1, &pbo);
87 glEnable(GL_TEXTURE_2D);
88 glBegin(GL_TRIANGLE_FAN);
89 glTexCoord2f(0.0, 0.0); glVertex2f(10, 10);
90 glTexCoord2f(1.0, 0.0); glVertex2f(20, 10);
91 glTexCoord2f(1.0, 1.0); glVertex2f(20, 20);
92 glTexCoord2f(0.0, 1.0); glVertex2f(10, 20);
93 glEnd();
95 glDeleteTextures(1, &tex);
97 pass &= piglit_probe_pixel_rgb(12, 12, red);
98 pass &= piglit_probe_pixel_rgb(18, 12, green);
99 pass &= piglit_probe_pixel_rgb(12, 18, blue);
100 pass &= piglit_probe_pixel_rgb(18, 18, white);
102 piglit_present_results();
104 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
108 static void reshape(int width, int height)
110 piglit_width = width;
111 piglit_height = height;
113 piglit_ortho_projection(width, height, GL_FALSE);
116 void
117 piglit_init(int argc, char **argv)
119 reshape(piglit_width, piglit_height);
120 piglit_require_extension("GL_ARB_pixel_buffer_object");