add pbobench: a benchmark for pbo functions
[piglit.git] / tests / texturing / texrect-many.c
blobc72c5f64d50228e3caa1942c6456a34463f82bcf
1 /**
2 * @file texrect-many.c
4 * Tests whether the driver can support a full set of rectangle textures.
6 * (Prompted by a bug in R300 where the driver ran out of indirections).
7 */
9 #include "piglit-util-gl.h"
11 PIGLIT_GL_TEST_CONFIG_BEGIN
13 config.supports_gl_compat_version = 10;
15 config.window_width = 16*16;
16 config.window_height = 11*16;
17 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
18 config.khr_no_error_support = PIGLIT_NO_ERRORS;
20 PIGLIT_GL_TEST_CONFIG_END
22 static int NumTextures = 16;
23 static GLuint Textures[16];
25 static const GLubyte colors[7][4] = {
26 { 0, 0, 0, 255 },
27 { 255, 0, 0, 255 },
28 { 0, 255, 0, 255 },
29 { 0, 0, 255, 255 },
30 { 128, 0, 0, 128 },
31 { 0, 128, 0, 128 },
32 { 0, 0, 128, 128 }
35 static void ActiveTexture(int i)
37 glActiveTexture(GL_TEXTURE0+i);
38 glClientActiveTexture(GL_TEXTURE0+i);
41 static void DoFrame(void)
43 int i;
45 glClearColor(0.5, 0.5, 0.0, 0.0);
46 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
48 glColor4f(1,1,1,1);
49 glBegin(GL_QUADS);
50 for(i = 0; i < NumTextures; ++i)
51 glMultiTexCoord2f(GL_TEXTURE0+i, 0, 0);
52 glVertex2f(0, 0);
53 for(i = 0; i < NumTextures; ++i)
54 glMultiTexCoord2f(GL_TEXTURE0+i, 16, 0);
55 glVertex2f(1, 0);
56 for(i = 0; i < NumTextures; ++i)
57 glMultiTexCoord2f(GL_TEXTURE0+i, 16, 11);
58 glVertex2f(1, 1);
59 for(i = 0; i < NumTextures; ++i)
60 glMultiTexCoord2f(GL_TEXTURE0+i, 0, 11);
61 glVertex2f(0, 1);
62 glEnd();
65 static bool
66 DoTest(void)
68 int x, y;
69 bool pass = true;
71 for(x = 0; x < NumTextures; ++x) {
72 for(y = 0; y < 11; ++y) {
73 float expected[4];
74 int clr;
75 int probe_x = (2*x+1) * piglit_width / 32;
76 int probe_y = (2*y+1) * piglit_height / 22;
78 clr = (x+y)%7;
80 expected[0] = colors[clr][0] / 255.0;
81 expected[1] = colors[clr][1] / 255.0;
82 expected[2] = colors[clr][2] / 255.0;
83 expected[3] = colors[clr][3] / 255.0;
85 pass = pass && piglit_probe_pixel_rgba(probe_x, probe_y,
86 expected);
90 return pass;
94 enum piglit_result
95 piglit_display(void)
97 int pass;
99 DoFrame();
100 pass = DoTest();
102 piglit_present_results();
104 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
107 void piglit_init(int argc, char **argv)
109 int i;
110 int maxtextures;
112 piglit_require_gl_version(13);
114 piglit_require_extension("GL_ARB_texture_rectangle");
116 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxtextures);
117 if (maxtextures < NumTextures)
118 NumTextures = maxtextures;
120 glGenTextures(NumTextures, Textures);
121 for(i = 0; i < NumTextures; ++i) {
122 GLubyte tex[11*16*4];
123 GLubyte* p;
124 int x, y;
126 ActiveTexture(i);
127 glEnable(GL_TEXTURE_RECTANGLE_ARB);
128 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, Textures[i]);
130 p = tex;
131 for(y = 0; y < 11; ++y) {
132 for(x = 0; x < 16; ++x, p += 4) {
133 if (x != i) {
134 p[0] = p[1] = p[2] = p[3] = 255;
135 } else {
136 int clr = (x+y)%7;
137 p[0] = colors[clr][0];
138 p[1] = colors[clr][1];
139 p[2] = colors[clr][2];
140 p[3] = colors[clr][3];
145 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 16, 11, 0,
146 GL_RGBA, GL_UNSIGNED_BYTE, tex);
147 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
148 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
151 piglit_ortho_projection(1.0, 1.0, GL_FALSE);