ext_direct_state_access: test glTextureImage* with GL_PROXY_TEXTURE_* targets
[piglit.git] / tests / spec / ext_direct_state_access / textures.c
blobf2421aadf09fcbc8f52bdcc923faea249d093104
1 /*
2 * Copyright © 2019 Advanced Micro Devices, Inc.
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.
24 #include "piglit-util-gl.h"
26 PIGLIT_GL_TEST_CONFIG_BEGIN
28 config.supports_gl_compat_version = 12;
30 config.window_visual = PIGLIT_GL_VISUAL_RGBA |
31 PIGLIT_GL_VISUAL_DOUBLE;
32 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
34 PIGLIT_GL_TEST_CONFIG_END
36 void
37 piglit_init(int argc, char **argv)
39 piglit_require_extension("GL_EXT_direct_state_access");
43 static GLuint
44 init_texture(GLenum target, int* image_size, float** expected_pixels)
46 GLuint tex;
48 const int height = (target == GL_TEXTURE_1D) ? 1 : piglit_height;
49 const int depth = (target == GL_TEXTURE_3D) ? 2 : 1;
50 float* image = piglit_rgbw_image(GL_RGBA, piglit_width, height * depth,
51 false, GL_UNSIGNED_NORMALIZED);
52 *image_size = piglit_width * height * depth * 4 * sizeof(float);
54 glGenTextures(1, &tex);
55 glTextureParameteriEXT(tex, target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
56 glTextureParameteriEXT(tex, target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
57 glTextureParameteriEXT(tex, target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
58 glTextureParameteriEXT(tex, target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
59 glTextureParameteriEXT(tex, target, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
60 if (target == GL_TEXTURE_1D) {
61 glTextureImage1DEXT(tex, target, 0, GL_RGBA,
62 piglit_width, 0,
63 GL_RGBA, GL_FLOAT, image);
64 } else if (target == GL_TEXTURE_2D) {
65 glTextureImage2DEXT(tex, target, 0, GL_RGBA,
66 piglit_width, height, 0,
67 GL_RGBA, GL_FLOAT, image);
68 } else {
69 /* 2 layers 3D image */
70 glTextureImage3DEXT(tex, target, 0, GL_RGBA,
71 piglit_width, height, depth, 0,
72 GL_RGBA, GL_FLOAT, image);
75 if (expected_pixels != NULL) {
76 *expected_pixels = image;
77 } else {
78 free(image);
81 return tex;
84 static GLenum
85 dimension_to_target(int n)
87 assert(n == 1 || n == 2 || n == 3);
88 switch (n) {
89 case 1: return GL_TEXTURE_1D;
90 case 2: return GL_TEXTURE_2D;
91 case 3:
92 default:
93 return GL_TEXTURE_3D;
97 static GLenum use_display_list = GL_NONE;
98 static GLuint list;
100 static enum piglit_result
101 test_TextureImageNDEXT(void* data)
103 bool pass = true;
104 const int n = (int)(intptr_t) data;
105 const GLenum target = dimension_to_target(n);
106 int image_size;
107 float* expected_pixels, *got_pixels;
108 GLuint tex;
110 if (use_display_list != GL_NONE)
111 glNewList(list, use_display_list);
113 tex = init_texture(target, &image_size, &expected_pixels);
115 if (use_display_list != GL_NONE)
116 glEndList(list);
118 if (use_display_list == GL_COMPILE) {
119 /* Texture shouldn't have been initialized yet */
120 pass = !glIsTexture(tex);
121 glCallList(list);
124 got_pixels = (float*) malloc(image_size);
125 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
127 pass = memcmp(expected_pixels, got_pixels, image_size) == 0 && pass;
129 free(expected_pixels);
130 free(got_pixels);
132 /* The GL_EXT_direct_state_access spec says:
134 * INVALID_OPERATION is generated [...] if the target parameter does
135 * not match the target type of the texture object named by the texture
136 * parameter.
138 if (n == 2) {
139 glTextureImage2DEXT(tex, GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA,
140 piglit_width, piglit_height, 0,
141 GL_RGBA, GL_FLOAT, got_pixels);
142 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
145 glDeleteTextures(1, &tex);
147 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
150 static enum piglit_result
151 test_TextureSubImageNDEXT(void* data)
153 bool pass = true;
154 int i;
155 const int n = (int)(intptr_t) data;
156 const GLenum target = dimension_to_target(n);
157 int image_size;
158 float* original_pixels, *modified_pixels, *got_pixels;
159 GLuint tex = init_texture(target, &image_size, &original_pixels);
160 int len = image_size / sizeof(float);
162 if (use_display_list != GL_NONE)
163 glNewList(list, use_display_list);
165 /* Replace the whole texture using glTextureSubImageNDEXT, line by line */
166 modified_pixels = (float*) malloc(image_size);
167 for (i = 0; i < len; i++) {
168 modified_pixels[i] = original_pixels[(i + 1) % len];
171 if (n == 1) {
172 glTextureSubImage1DEXT(tex, target, 0,
173 0, piglit_width,
174 GL_RGBA, GL_FLOAT,
175 modified_pixels);
176 } else {
177 for (i = 0; i < piglit_height; i++) {
178 if (n == 2) {
179 glTextureSubImage2DEXT(tex,
180 target, 0,
181 0, i, piglit_width, 1,
182 GL_RGBA, GL_FLOAT,
183 &modified_pixels[piglit_width * 4 * i]);
184 } else {
185 /* Update the 1st layer of the 3D image */
186 glTextureSubImage3DEXT(tex,
187 target, 0,
188 0, i, 0, piglit_width, 1, 1,
189 GL_RGBA, GL_FLOAT,
190 &modified_pixels[piglit_width * 4 * i]);
191 /* And the 2nd layer */
192 glTextureSubImage3DEXT(tex,
193 target, 0,
194 0, i, 1, piglit_width, 1, 1,
195 GL_RGBA, GL_FLOAT,
196 &modified_pixels[piglit_width * 4 * (i + piglit_height)]);
201 if (use_display_list != GL_NONE)
202 glEndList(list);
204 got_pixels = (float*) malloc(image_size);
205 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
207 if (use_display_list == GL_COMPILE) {
208 /* Texture shouldn't have been modified yet */
209 pass = memcmp(original_pixels, got_pixels, image_size) == 0 && pass;
210 glCallList(list);
211 /* Re-read */
212 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
215 pass = memcmp(modified_pixels, got_pixels, image_size) == 0 && pass;
217 /* Verify error added by the extension:
218 "INVALID_OPERATION is generated [...] if the target parameter does
219 not match the target type of the texture object named by the texture
220 parameter."
222 if (n == 2) {
223 glTextureSubImage2DEXT(tex,
224 GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,
225 0, 0, 4, 1,
226 GL_RGBA, GL_FLOAT,
227 modified_pixels);
228 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
231 glDeleteTextures(1, &tex);
232 free(modified_pixels);
233 free(original_pixels);
235 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
238 static enum piglit_result
239 test_CopyTextureImageNDEXT(void* data)
241 bool pass = true;
242 const int n = (int)(intptr_t) data;
243 assert(n == 1 || n == 2);
244 const GLenum target = dimension_to_target(n);
245 int image_size;
246 float* original_pixels;
247 GLuint tex = init_texture(target, &image_size, &original_pixels);
248 const int height = (target == GL_TEXTURE_1D) ? 1 : piglit_height;
249 float* got_pixels;
251 glClearColor(0.25, 0.5, 0.75, 1);
252 glClear(GL_COLOR_BUFFER_BIT);
254 if (use_display_list != GL_NONE)
255 glNewList(list, use_display_list);
257 switch (target) {
258 case GL_TEXTURE_1D:
259 glCopyTextureImage1DEXT(tex, target, 0, GL_RGBA, 0, 0, piglit_width, 0);
260 break;
261 case GL_TEXTURE_2D:
262 glCopyTextureImage2DEXT(tex, target, 0, GL_RGBA, 0, 0, piglit_width, piglit_height, 0);
263 break;
266 if (use_display_list != GL_NONE)
267 glEndList(list);
269 got_pixels = (float*) malloc(piglit_width * height * 4 * sizeof(float));
271 /* Compare glGetTextureImageEXT and on screen pixels */
272 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
274 if (use_display_list == GL_COMPILE) {
275 /* Texture shouldn't have been modified yet */
276 pass = memcmp(got_pixels, original_pixels, image_size) == 0;
277 glCallList(list);
278 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
281 pass = piglit_probe_rect_rgba(0, 0, piglit_width, height, got_pixels) && pass;
283 free(got_pixels);
284 free(original_pixels);
286 glDeleteTextures(1, &tex);
288 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
291 static enum piglit_result
292 test_CopyTextureSubImageNDEXT(void* data)
294 bool pass = true;
295 const int n = (int)(intptr_t) data;
296 const GLenum target = dimension_to_target(n);
297 int image_size;
298 float* original_pixels;
299 GLuint tex = init_texture(target, &image_size, &original_pixels);
300 const int height = (target == GL_TEXTURE_1D) ? 1 : piglit_height;
301 float* got_pixels;
303 glClearColor(0.25, 0.5, 0.75, 1);
304 glClear(GL_COLOR_BUFFER_BIT);
306 if (use_display_list != GL_NONE)
307 glNewList(list, use_display_list);
309 switch (target) {
310 case GL_TEXTURE_1D:
311 glCopyTextureSubImage1DEXT(tex, target, 0, 0, 0, 0, piglit_width);
312 break;
313 case GL_TEXTURE_2D:
314 glCopyTextureSubImage2DEXT(tex, target, 0, 0, 0, 0, 0, piglit_width, piglit_height);
315 break;
316 case GL_TEXTURE_3D:
317 glCopyTextureSubImage3DEXT(tex, target, 0, 0, 0, 0, 0, 0, piglit_width, piglit_height);
318 break;
321 if (use_display_list != GL_NONE)
322 glEndList(list);
324 got_pixels = (float*) malloc(image_size);
326 /* Compare glGetTextureImageEXT and on screen pixels */
327 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
329 if (use_display_list == GL_COMPILE) {
330 /* Texture shouldn't have been modified yet */
331 pass = memcmp(got_pixels, original_pixels, image_size) == 0;
332 glCallList(list);
333 glGetTextureImageEXT(tex, target, 0, GL_RGBA, GL_FLOAT, got_pixels);
336 pass = piglit_probe_rect_rgba(0, 0, piglit_width, height, got_pixels) && pass;
338 free(got_pixels);
339 free(original_pixels);
341 glDeleteTextures(1, &tex);
343 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
346 static enum piglit_result
347 test_TextureParameteriEXT(void* data)
349 GLuint tex[2];
350 static const GLenum targets[] = {
351 GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
352 GL_TEXTURE_CUBE_MAP,
354 int i, j, k, l, value;
355 bool pass = true;
357 const struct pname_value {
358 GLenum pname;
359 int value_count;
360 int values[8];
361 } tested[] = {
363 GL_TEXTURE_WRAP_S,
366 GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT,
367 GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT
371 GL_TEXTURE_WRAP_R,
374 GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT,
375 GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT
379 GL_TEXTURE_WRAP_T,
382 GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT,
383 GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT
387 GL_TEXTURE_MIN_FILTER,
390 GL_NEAREST, GL_LINEAR,
391 GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST,
392 GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST
396 GL_TEXTURE_MAG_FILTER,
399 GL_NEAREST, GL_LINEAR
403 GL_TEXTURE_BASE_LEVEL,
404 1, { rand() }
407 GL_TEXTURE_MAX_LEVEL,
408 1, { rand() }
411 GL_DEPTH_TEXTURE_MODE,
414 GL_RED, GL_LUMINANCE, GL_INTENSITY, GL_ALPHA
418 GL_TEXTURE_COMPARE_MODE,
421 GL_NONE, GL_COMPARE_REF_TO_TEXTURE
425 GL_TEXTURE_COMPARE_FUNC,
428 GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER,
429 GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER
433 GL_GENERATE_MIPMAP,
436 GL_TRUE, GL_FALSE
442 for (i = 0; i < ARRAY_SIZE(targets); i++) {
443 GLenum target = targets[i];
445 glGenTextures(ARRAY_SIZE(tex), tex);
447 for (j = 0; j < ARRAY_SIZE(tested); j++) {
448 for (k = 0; k < tested[j].value_count; k++) {
449 int original_values[2];
450 if (use_display_list != GL_NONE)
451 glNewList(list, use_display_list);
453 for (l = 0; l < 2; l++) {
454 glGetTextureParameterivEXT(tex[l], target,
455 tested[j].pname, &original_values[l]);
458 glTextureParameteriEXT(
459 tex[0], target,
460 tested[j].pname,
461 tested[j].values[k]);
463 glTextureParameterivEXT(
464 tex[1], target,
465 tested[j].pname,
466 &tested[j].values[k]);
468 if (use_display_list != GL_NONE)
469 glEndList(list);
471 if (use_display_list == GL_COMPILE) {
472 for (l = 0; l < 2; l++) {
473 int v;
474 glGetTextureParameterivEXT(tex[l], target,
475 tested[j].pname, &v);
476 pass = v == original_values[l] && pass;
478 glCallList(list);
481 for (l = 0; l < 2; l++) {
482 glGetTextureParameterivEXT(tex[l], target, tested[j].pname, &value);
484 if (value != tested[j].values[k]) {
485 piglit_loge("%s(%s, %s, ...) failed. Expected %d but got %d\n",
486 l == 0 ? "glTextureParameteriEXT" : "glTextureParameterivEXT",
487 piglit_get_gl_enum_name(target),
488 piglit_get_gl_enum_name(tested[j].pname),
489 tested[j].values[k],
490 value);
491 return PIGLIT_FAIL;
493 if (!piglit_check_gl_error(GL_NO_ERROR)) {
494 piglit_loge("%s(%s, %s, ...) failed.\n",
495 l == 0 ? "glTextureParameteriEXT" : "glTextureParameterivEXT",
496 piglit_get_gl_enum_name(target),
497 piglit_get_gl_enum_name(tested[j].pname));
498 return PIGLIT_FAIL;
503 glDeleteTextures(ARRAY_SIZE(tex), tex);
505 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
508 static enum piglit_result
509 test_TextureParameterfEXT(void* data)
511 GLuint tex[2];
512 static const GLenum targets[] = {
513 GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
514 GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY,
515 GL_TEXTURE_CUBE_MAP,
517 int i, j, k, l;
518 bool pass = true;
519 float value;
521 const struct pname_value {
522 GLenum pname;
523 int value_count;
524 float values[8];
525 } tested[] = {
527 GL_TEXTURE_PRIORITY,
528 1, { (float) rand() / RAND_MAX }
531 GL_TEXTURE_MIN_LOD,
532 1, { (float)rand() }
535 GL_TEXTURE_MAX_LOD,
536 1, { (float)rand() }
539 GL_TEXTURE_LOD_BIAS,
540 1, { (float)rand() }
544 for (i = 0; i < ARRAY_SIZE(targets); i++) {
545 GLenum target = targets[i];
547 glGenTextures(ARRAY_SIZE(tex), tex);
549 for (j = 0; j < ARRAY_SIZE(tested); j++) {
550 for (k = 0; k < tested[j].value_count; k++) {
551 float original_values[2];
553 if (use_display_list != GL_NONE)
554 glNewList(list, use_display_list);
556 for (l = 0; l < 2; l++) {
557 glGetTextureParameterfvEXT(tex[l], target,
558 tested[j].pname, &original_values[l]);
561 glTextureParameterfEXT(
562 tex[0], target,
563 tested[j].pname,
564 tested[j].values[k]);
566 glTextureParameterfvEXT(
567 tex[1], target,
568 tested[j].pname,
569 &tested[j].values[k]);
571 if (use_display_list != GL_NONE)
572 glEndList(list);
574 if (use_display_list == GL_COMPILE) {
575 for (l = 0; l < 2; l++) {
576 float v;
577 glGetTextureParameterfvEXT(tex[l], target,
578 tested[j].pname, &v);
579 pass = v == original_values[l] && pass;
581 glCallList(list);
584 for (l = 0; l < 2; l++) {
585 glGetTextureParameterfvEXT(tex[l], target, tested[j].pname, &value);
587 if (value != tested[j].values[k]) {
588 piglit_loge("%s(%s, %s, ...) failed. Expected %f but got %f\n",
589 l == 0 ? "glTextureParameterfEXT" : "glTextureParameterfvEXT",
590 piglit_get_gl_enum_name(target),
591 piglit_get_gl_enum_name(tested[j].pname),
592 tested[j].values[k],
593 value);
594 return PIGLIT_FAIL;
596 if (!piglit_check_gl_error(GL_NO_ERROR)) {
597 piglit_loge("%s(%s, %s, ...) failed.\n",
598 l == 0 ? "glTextureParameterfEXT" : "glTextureParameterfvEXT",
599 piglit_get_gl_enum_name(target),
600 piglit_get_gl_enum_name(tested[j].pname));
601 return PIGLIT_FAIL;
606 glDeleteTextures(ARRAY_SIZE(tex), tex);
608 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
611 enum piglit_result
612 test_EnableDisableEXT(void* data)
614 /* The GL_EXT_direct_state_access spec says:
616 * The following commands (introduced by EXT_draw_buffers2):
618 * void EnableIndexedEXT(enum cap, uint index);
619 * void DisableIndexedEXT(enum cap, uint index);
621 * are equivalent (assuming no errors) to the following:
623 * ActiveTexture(TEXTURE0+index);
624 * XXX(cap);
626 * [...] when the cap parameter is one of the texture-related
627 * enable token depending on the active texture state, namely
628 * TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP,
629 * TEXTURE_RECTANGLE_ARB, TEXTURE_GEN_S, TEXTURE_GEN_T,
630 * TEXTURE_GEN_R, or TEXTURE_GEN_Q.
632 static const GLenum caps[] = {
633 GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP,
634 GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R,
635 GL_TEXTURE_GEN_Q
638 int i, max_texture_units;
639 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_units);
641 for (i = 0; i < ARRAY_SIZE(caps); i++) {
642 const GLenum cap = caps[i];
644 const int index = rand() % max_texture_units;
645 const bool value = rand() % 2;
646 GLboolean got;
647 int got_i;
649 glActiveTexture(GL_TEXTURE0 + (index + 1) % max_texture_units);
651 if (use_display_list != GL_NONE)
652 glNewList(list, use_display_list);
654 if (value) {
655 glEnableIndexedEXT(cap, index);
656 } else {
657 glDisableIndexedEXT(cap, index);
660 if (use_display_list != GL_NONE)
661 glEndList(list);
663 if (use_display_list == GL_COMPILE)
664 glCallList(list);
666 /* Read back with glIsEnabledIndexedEXT */
667 if (value != glIsEnabledIndexedEXT(cap, index)) {
668 piglit_loge("gl%sIndexedEXT(%s, %d) / glIsEnabledIndexedEXT failed.\n",
669 value ? "Enable" : "Disable",
670 piglit_get_gl_enum_name(cap),
671 index);
672 return PIGLIT_FAIL;
675 /* Read back with glGetBooleanIndexedvEXT */
676 glGetBooleanIndexedvEXT(cap, index, &got);
677 if (value != got) {
678 piglit_loge("gl%sIndexedEXT(%s, %d) / glGetBooleanIndexedvEXT failed.\n",
679 value ? "Enable" : "Disable",
680 piglit_get_gl_enum_name(cap),
681 index);
682 return PIGLIT_FAIL;
685 /* Read back with glGetBooleanIndexedvEXT */
686 glGetIntegerIndexedvEXT(cap, index, &got_i);
687 if (value != got_i) {
688 piglit_loge("gl%sIndexedEXT(%s, %d) / glGetIntegerIndexedvEXT failed.\n",
689 value ? "Enable" : "Disable",
690 piglit_get_gl_enum_name(cap),
691 index);
692 return PIGLIT_FAIL;
695 return PIGLIT_PASS;
699 static enum piglit_result
700 test_TextureProxyTarget(void* data)
702 bool pass = true;
703 GLint width;
704 GLfloat height;
705 const int n = (int)(intptr_t) data;
706 const GLenum target = dimension_to_target(n);
708 GLenum proxy_target = (target == GL_TEXTURE_1D) ? GL_PROXY_TEXTURE_1D :
709 (target == GL_TEXTURE_2D ? GL_PROXY_TEXTURE_2D : GL_PROXY_TEXTURE_3D);
711 GLuint tex;
712 glGenTextures(1, &tex);
714 /* The GL_EXT_direct_state_access says:
716 * Proxy targets work with the glTex* (glTexImage*)
717 * and glGetTex* (glGetTexLevelParameter*) commands that support
718 * proxy textures BUT the texture name must be 0 to avoid a
719 * GL_INVALID_OPERATION error.
721 if (n == 1) {
722 glTextureImage1DEXT(tex, proxy_target, 0, GL_RGBA,
723 piglit_width, 0,
724 GL_RGBA, GL_FLOAT, NULL);
725 } else if (n == 2) {
726 glTextureImage2DEXT(tex, proxy_target, 0, GL_RGBA,
727 piglit_width, piglit_height, 0,
728 GL_RGBA, GL_FLOAT, NULL);
729 } else if (n == 3) {
730 glTextureImage3DEXT(tex, proxy_target, 0, GL_RGBA,
731 piglit_width, piglit_height, 1, 0,
732 GL_RGBA, GL_FLOAT, NULL);
734 pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
736 if (n == 1) {
737 glTextureImage1DEXT(0, proxy_target, 0, GL_RGBA,
738 piglit_width, 0,
739 GL_RGBA, GL_FLOAT, NULL);
740 } else if (n == 2) {
741 glTextureImage2DEXT(0, proxy_target, 0, GL_RGBA,
742 piglit_width, piglit_height, 0,
743 GL_RGBA, GL_FLOAT, NULL);
744 } else if (n == 3) {
745 glTextureImage3DEXT(0, proxy_target, 0, GL_RGBA,
746 piglit_width, piglit_height, 1, 0,
747 GL_RGBA, GL_FLOAT, NULL);
749 glGetTextureLevelParameterivEXT(0, proxy_target, 0,
750 GL_TEXTURE_WIDTH, &width);
751 glGetTextureLevelParameterfvEXT(0, proxy_target, 0,
752 GL_TEXTURE_HEIGHT, &height);
753 pass = width == piglit_width && pass;
754 pass = (int)height == (n > 1 ? piglit_height : 1) && pass;
756 glDeleteTextures(1, &tex);
758 return pass && piglit_check_gl_error(GL_NO_ERROR) ? PIGLIT_PASS : PIGLIT_FAIL;
762 enum piglit_result
763 piglit_display(void)
765 int i;
766 struct piglit_subtest tests[] = {
768 "TextureParameteriEXT",
769 NULL,
770 test_TextureParameteriEXT,
771 NULL
774 "TextureParameterfEXT",
775 NULL,
776 test_TextureParameterfEXT,
777 NULL
780 "TextureImage1DEXT",
781 NULL,
782 test_TextureImageNDEXT,
783 (void*) 1
786 "TextureImage2DEXT",
787 NULL,
788 test_TextureImageNDEXT,
789 (void*) 2
792 "TextureImage3DEXT",
793 NULL,
794 test_TextureImageNDEXT,
795 (void*) 3
798 "TextureSubImage1DEXT",
799 NULL,
800 test_TextureSubImageNDEXT,
801 (void*) 1
804 "TextureSubImage2DEXT",
805 NULL,
806 test_TextureSubImageNDEXT,
807 (void*) 2
810 "TextureSubImage3DEXT",
811 NULL,
812 test_TextureSubImageNDEXT,
813 (void*) 3
816 "CopyTextureImage1DEXT",
817 NULL,
818 test_CopyTextureImageNDEXT,
819 (void*) 1
822 "CopyTextureImage2DEXT",
823 NULL,
824 test_CopyTextureImageNDEXT,
825 (void*) 2
828 "CopyTextureSubImage1DEXT",
829 NULL,
830 test_CopyTextureSubImageNDEXT,
831 (void*) 1
834 "CopyTextureSubImage2DEXT",
835 NULL,
836 test_CopyTextureSubImageNDEXT,
837 (void*) 2
840 "CopyTextureSubImage3DEXT",
841 NULL,
842 test_CopyTextureSubImageNDEXT,
843 (void*) 3
846 "EnableDisableEXT",
847 NULL,
848 test_EnableDisableEXT
851 "GL_PROXY_TEXTURE_1D + glTex*",
852 NULL,
853 test_TextureProxyTarget,
854 (void*) 1
857 "GL_PROXY_TEXTURE_2D + glTex*",
858 NULL,
859 test_TextureProxyTarget,
860 (void*) 2
863 "GL_PROXY_TEXTURE_3D + glTex*",
864 NULL,
865 test_TextureProxyTarget,
866 (void*) 3
869 NULL
873 enum piglit_result result = piglit_run_selected_subtests(tests, NULL, 0, PIGLIT_PASS);
874 list = glGenLists(1);
876 /* Re-run the same test but using display list GL_COMPILE */
877 for (i = 0; tests[i].name; i++) {
878 char* test_name_display_list;
879 asprintf(&test_name_display_list, "%s + display list GL_COMPILE", tests[i].name);
880 tests[i].name = test_name_display_list;
882 use_display_list = GL_COMPILE;
883 result = piglit_run_selected_subtests(tests, NULL, 0, result);
885 /* Re-run the same test but using display list GL_COMPILE_AND_EXECUTE */
886 for (i = 0; tests[i].name; i++) {
887 char* test_name_display_list;
888 asprintf(&test_name_display_list, "%s_AND_EXECUTE", tests[i].name);
889 tests[i].name = test_name_display_list;
891 use_display_list = GL_COMPILE_AND_EXECUTE;
892 result = piglit_run_selected_subtests(tests, NULL, 0, result);
894 glDeleteLists(list, 1);
896 return result;