<p dir="ltr">Add to all.py?</p>
<div class="gmail_quote">On Nov 2, 2015 4:25 PM, "Dave Airlie" <<a href="mailto:airlied@gmail.com">airlied@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
<br>
for every supported target for all the depth/stencil formats<br>
this creates a texture, and then uses glGetTexImage<br>
to read it back.<br>
---<br>
tests/texturing/CMakeLists.gl.txt | 1 +<br>
tests/texturing/getteximage-depth.c | 628 ++++++++++++++++++++++++++++++++++++<br>
2 files changed, 629 insertions(+)<br>
create mode 100644 tests/texturing/getteximage-depth.c<br>
<br>
diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt<br>
index 68afa16..704ea6d 100644<br>
--- a/tests/texturing/CMakeLists.gl.txt<br>
+++ b/tests/texturing/CMakeLists.gl.txt<br>
@@ -34,6 +34,7 @@ piglit_add_executable (getteximage-formats getteximage-formats.c)<br>
piglit_add_executable (getteximage-simple getteximage-simple.c)<br>
piglit_add_executable (getteximage-luminance getteximage-luminance.c)<br>
piglit_add_executable (getteximage-targets getteximage-targets.c)<br>
+piglit_add_executable (getteximage-depth getteximage-depth.c)<br>
piglit_add_executable (incomplete-texture incomplete-texture.c)<br>
piglit_add_executable (generatemipmap-cubemap generatemipmap-cubemap.c)<br>
piglit_add_executable (fragment-and-vertex-texturing fragment-and-vertex-texturing.c)<br>
diff --git a/tests/texturing/getteximage-depth.c b/tests/texturing/getteximage-depth.c<br>
new file mode 100644<br>
index 0000000..71311bc<br>
--- /dev/null<br>
+++ b/tests/texturing/getteximage-depth.c<br>
@@ -0,0 +1,628 @@<br>
+/*<br>
+ * Copyright (c) 2015 Red Hat<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * on the rights to use, copy, modify, merge, publish, distribute, sub<br>
+ * license, and/or sell copies of the Software, and to permit persons to whom<br>
+ * the Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br>
+ * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS<br>
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br>
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br>
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
+ * SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * @file getteximage-depth<br>
+ *<br>
+ * Test glGetTexImage for depth/stencil format/target combinations in a roundtrip.<br>
+ * i.e. don't draw the textures, just create and readback.<br>
+ * this was due to a bug in mesa's handling of 1D array depth textures.<br>
+ */<br>
+<br>
+#include "piglit-util-gl.h"<br>
+#include "../fbo/fbo-formats.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+ config.supports_gl_compat_version = 10;<br>
+<br>
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ /* UNREACHABLE */<br>
+ return PIGLIT_FAIL;<br>
+}<br>
+<br>
+#define IMAGE_WIDTH 32<br>
+#define IMAGE_HEIGHT 32<br>
+<br>
+static GLenum target_list[] = { GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY };<br>
+<br>
+static int test_target_bitmap;<br>
+<br>
+static int get_test_height(GLenum target)<br>
+{<br>
+ switch (target) {<br>
+ case GL_TEXTURE_1D:<br>
+ case GL_TEXTURE_1D_ARRAY:<br>
+ return 1;<br>
+ default:<br>
+ return IMAGE_HEIGHT;<br>
+ }<br>
+}<br>
+<br>
+static int get_test_depth(GLenum target)<br>
+{<br>
+ switch (target) {<br>
+ case GL_TEXTURE_3D:<br>
+ return 16;<br>
+ case GL_TEXTURE_1D_ARRAY:<br>
+ case GL_TEXTURE_2D_ARRAY:<br>
+ return 7;<br>
+ case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
+ return 12;<br>
+ case GL_TEXTURE_CUBE_MAP:<br>
+ return 6;<br>
+ default:<br>
+ return 1;<br>
+ }<br>
+}<br>
+<br>
+static float get_depth_value(int w, int x)<br>
+{<br>
+ if (w == 1)<br>
+ return 1.0;<br>
+ else<br>
+ return (float)(x) / (w - 1);<br>
+}<br>
+<br>
+static int get_stencil_value(int w, int x)<br>
+{<br>
+ if (w == 1)<br>
+ return 255;<br>
+ else<br>
+ return (x * 255) / (w - 1);<br>
+}<br>
+<br>
+static GLuint<br>
+get_depth_texture(const struct format_desc *format, GLenum target, int w, int h, int d, GLboolean mip)<br>
+{<br>
+ void *data;<br>
+ float *f = NULL;<br>
+ unsigned int *i = NULL;<br>
+ int size, x, y, level, layer;<br>
+ GLuint tex;<br>
+ GLuint extra = 0;<br>
+ GLenum datatype, dataformat;<br>
+ int mul = 1;<br>
+<br>
+ glGenTextures(1, &tex);<br>
+ glBindTexture(target, tex);<br>
+ glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);<br>
+ glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);<br>
+ if (mip) {<br>
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER,<br>
+ GL_LINEAR);<br>
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER,<br>
+ GL_LINEAR_MIPMAP_NEAREST);<br>
+ } else {<br>
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER,<br>
+ GL_NEAREST);<br>
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER,<br>
+ GL_NEAREST);<br>
+ }<br>
+ if (format->internalformat == GL_DEPTH32F_STENCIL8) {<br>
+ mul = 2;<br>
+ }<br>
+ extra = d * sizeof(GLfloat) * mul;<br>
+<br>
+ data = calloc(1, w * h * sizeof(GLfloat) * mul + extra);<br>
+<br>
+ if (format->internalformat == GL_DEPTH_STENCIL_EXT ||<br>
+ format->internalformat == GL_DEPTH24_STENCIL8_EXT) {<br>
+ dataformat = GL_DEPTH_STENCIL_EXT;<br>
+ datatype = GL_UNSIGNED_INT_24_8_EXT;<br>
+ i = data;<br>
+ } else if (format->internalformat == GL_DEPTH32F_STENCIL8) {<br>
+ dataformat = GL_DEPTH_STENCIL;<br>
+ datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;<br>
+ f = data;<br>
+ } else {<br>
+ dataformat = GL_DEPTH_COMPONENT;<br>
+ datatype = GL_FLOAT;<br>
+ f = data;<br>
+ }<br>
+<br>
+ for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {<br>
+ for (y = 0; y < h; y++) {<br>
+ for (x = 0; x < w; x++) {<br>
+ float val = get_depth_value(w, x);<br>
+<br>
+ if (f)<br>
+ f[(y * w + x)*mul] = val;<br>
+ else<br>
+ i[y * w + x] = 0xffffff00 * val;<br>
+ }<br>
+ }<br>
+<br>
+ for (x = 0; x < d; x++) {<br>
+ float val = get_depth_value(w, x % w);<br>
+<br>
+ if (f)<br>
+ f[(h * w + x)*mul] = val;<br>
+ else<br>
+ i[h * w + x] = 0xffffff00 * val;<br>
+ }<br>
+<br>
+ switch (target) {<br>
+ case GL_TEXTURE_1D:<br>
+ glTexImage1D(target, level,<br>
+ format->internalformat,<br>
+ w, 0,<br>
+ dataformat, datatype, data);<br>
+ break;<br>
+ case GL_TEXTURE_2D:<br>
+ case GL_TEXTURE_RECTANGLE:<br>
+ glTexImage2D(target, level,<br>
+ format->internalformat,<br>
+ w, h, 0,<br>
+ dataformat, datatype, data);<br>
+ break;<br>
+ case GL_TEXTURE_CUBE_MAP:<br>
+ assert(d == 6);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer * 4 * mul;<br>
+ glTexImage2D(cube_face_targets[layer],<br>
+ level, format->internalformat,<br>
+ w, h, 0,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+ case GL_TEXTURE_1D_ARRAY:<br>
+ glTexImage2D(target, level,<br>
+ format->internalformat,<br>
+ w, d, 0,<br>
+ dataformat, datatype, NULL);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer * (4 * mul);<br>
+ glTexSubImage2D(target, level,<br>
+ 0, layer, w, 1,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+ case GL_TEXTURE_2D_ARRAY:<br>
+ case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
+ glTexImage3D(target, level,<br>
+ format->internalformat,<br>
+ w, h, d, 0,<br>
+ dataformat, datatype, NULL);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer * (4 * mul);<br>
+ glTexSubImage3D(target, level,<br>
+ 0, 0, layer, w, h, 1,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+<br>
+ default:<br>
+ assert(0);<br>
+ }<br>
+<br>
+ if (!mip)<br>
+ break;<br>
+<br>
+ if (w > 1)<br>
+ w >>= 1;<br>
+ if (target != GL_TEXTURE_1D &&<br>
+ target != GL_TEXTURE_1D_ARRAY &&<br>
+ h > 1)<br>
+ h >>= 1;<br>
+ }<br>
+ free(data);<br>
+ return tex;<br>
+}<br>
+<br>
+static GLuint<br>
+get_stencil_texture(const struct format_desc *format, GLenum target, int w, int h, int d, GLboolean mip)<br>
+{<br>
+ void *data;<br>
+ unsigned char *u;<br>
+ int size, x, y, level, layer;<br>
+ GLuint tex;<br>
+ GLenum datatype, dataformat;<br>
+<br>
+ glGenTextures(1, &tex);<br>
+ glBindTexture(target, tex);<br>
+ glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);<br>
+ glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);<br>
+ if (mip) {<br>
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER,<br>
+ GL_LINEAR);<br>
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER,<br>
+ GL_LINEAR_MIPMAP_NEAREST);<br>
+ } else {<br>
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER,<br>
+ GL_NEAREST);<br>
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER,<br>
+ GL_NEAREST);<br>
+ }<br>
+ data = malloc(w * h * sizeof(GLubyte) + d * sizeof(GLubyte));<br>
+<br>
+ dataformat = GL_STENCIL_INDEX;<br>
+ datatype = GL_UNSIGNED_BYTE;<br>
+ u = data;<br>
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);<br>
+ for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {<br>
+ for (y = 0; y < h; y++) {<br>
+ for (x = 0; x < w; x++) {<br>
+ GLuint val = get_stencil_value(w, x);<br>
+<br>
+ u[y * w + x] = val;<br>
+ }<br>
+ }<br>
+<br>
+ for (x = 0; x < d; x++) {<br>
+ GLuint val = get_stencil_value(w, x % w);<br>
+ u[h * w + x] = val;<br>
+ }<br>
+<br>
+ switch (target) {<br>
+ case GL_TEXTURE_1D:<br>
+ glTexImage1D(target, level,<br>
+ format->internalformat,<br>
+ w, 0,<br>
+ dataformat, datatype, data);<br>
+ break;<br>
+<br>
+ case GL_TEXTURE_2D:<br>
+ case GL_TEXTURE_RECTANGLE:<br>
+ glTexImage2D(target, level,<br>
+ format->internalformat,<br>
+ w, h, 0,<br>
+ dataformat, datatype, data);<br>
+ break;<br>
+ case GL_TEXTURE_CUBE_MAP:<br>
+ assert(d == 6);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer;<br>
+ glTexImage2D(cube_face_targets[layer],<br>
+ level, format->internalformat,<br>
+ w, h, 0,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+ case GL_TEXTURE_1D_ARRAY:<br>
+ glTexImage2D(target, level,<br>
+ format->internalformat,<br>
+ w, d, 0,<br>
+ dataformat, datatype, NULL);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer;<br>
+ glTexSubImage2D(target, level,<br>
+ 0, layer, w, 1,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+ case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
+ case GL_TEXTURE_2D_ARRAY:<br>
+ glTexImage3D(target, level,<br>
+ format->internalformat,<br>
+ w, h, d, 0,<br>
+ dataformat, datatype, NULL);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ char *ptr = data;<br>
+ ptr += layer;<br>
+ glTexSubImage3D(target, level,<br>
+ 0, 0, layer, w, h, 1,<br>
+ dataformat, datatype, ptr);<br>
+ }<br>
+ break;<br>
+<br>
+ default:<br>
+ assert(0);<br>
+ }<br>
+<br>
+ if (!mip)<br>
+ break;<br>
+<br>
+ if (w > 1)<br>
+ w >>= 1;<br>
+ if (target != GL_TEXTURE_1D &&<br>
+ target != GL_TEXTURE_1D_ARRAY &&<br>
+ h > 1)<br>
+ h >>= 1;<br>
+ }<br>
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);<br>
+ free(data);<br>
+ return tex;<br>
+}<br>
+<br>
+static bool<br>
+verify_depth_data(const struct format_desc *format, GLenum target,<br>
+ int w, int h, int d, GLboolean mip)<br>
+{<br>
+ int x, y, layer, level;<br>
+ GLfloat *f;<br>
+ unsigned *i = NULL;<br>
+ int size;<br>
+ GLenum datatype = format->base_internal_format;<br>
+ GLenum dataformat;<br>
+ int layer_size;<br>
+ int mul = 1;<br>
+ void *data, *ptr;<br>
+ if (format->internalformat == GL_DEPTH32F_STENCIL8) {<br>
+ dataformat = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;<br>
+ mul = 2;<br>
+ }<br>
+ else if (format->base_internal_format == GL_DEPTH_STENCIL)<br>
+ dataformat = GL_UNSIGNED_INT_24_8_EXT;<br>
+ else<br>
+ dataformat = GL_FLOAT;<br>
+<br>
+ ptr = calloc(mul * 4, w * h * d);<br>
+ if (!ptr)<br>
+ return false;<br>
+<br>
+ for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {<br>
+ data = ptr;<br>
+ layer_size = w * h * 4 * mul;<br>
+<br>
+ if (target == GL_TEXTURE_CUBE_MAP) {<br>
+ int idx;<br>
+ for (idx = 0; idx < 6; idx++)<br>
+ glGetTexImage(cube_face_targets[idx], level, datatype, dataformat,<br>
+ (char *)data + layer_size * idx);<br>
+ } else<br>
+ glGetTexImage(target, level, datatype, dataformat,<br>
+ data);<br>
+<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ f = data;<br>
+ if (format->internalformat == GL_DEPTH_STENCIL_EXT ||<br>
+ format->internalformat == GL_DEPTH24_STENCIL8_EXT)<br>
+ i = data;<br>
+<br>
+ for (y = 0; y < h; y++) {<br>
+ for (x = 0; x < w; x++) {<br>
+ int offset = (x + layer) % w;<br>
+ float exp_val = get_depth_value(w, offset);<br>
+ float got_val;<br>
+<br>
+ if (i)<br>
+ got_val = (float)(i[y * w + x] >> 8) / (float)0xffffff;<br>
+ else<br>
+ got_val = f[(y * w + x) * mul];<br>
+ if (fabs(got_val - exp_val) >= 1e-4) {<br>
+ fprintf(stderr, "mismatch at %d %d %d %d %g vs %g: %d %dx%d\n", level, x, y, layer, got_val, exp_val, layer_size, w, h);<br>
+ if (0){<br>
+ uint32_t *myptr = data;<br>
+ int myx;<br>
+ for (myx = 0; myx < w * h; myx++){<br>
+ fprintf(stderr, "%08x ", myptr[myx]);<br>
+ }<br>
+ fprintf(stderr, "\n");<br>
+ }<br>
+ free(ptr);<br>
+ return false;<br>
+ }<br>
+ }<br>
+ }<br>
+ data = (char *)data + layer_size;<br>
+ }<br>
+<br>
+ if (!mip)<br>
+ break;<br>
+ if (w > 1)<br>
+ w >>= 1;<br>
+ if (target != GL_TEXTURE_1D &&<br>
+ target != GL_TEXTURE_1D_ARRAY &&<br>
+ h > 1)<br>
+ h >>= 1;<br>
+ }<br>
+ free(ptr);<br>
+ return true;<br>
+}<br>
+<br>
+static bool<br>
+verify_stencil_data(const struct format_desc *format,<br>
+ GLenum target, int w, int h, int d, GLboolean mip)<br>
+{<br>
+ int x, y, layer, level, size;<br>
+ GLubyte *ub;<br>
+ GLenum datatype = format->base_internal_format;<br>
+ GLenum dataformat = GL_UNSIGNED_BYTE;<br>
+ void *data, *ptr;<br>
+ int layer_size;<br>
+<br>
+ ptr = calloc(1, w * h * d);<br>
+ if (!ptr)<br>
+ return false;<br>
+<br>
+ for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {<br>
+ data = ptr;<br>
+ layer_size = w * h;<br>
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);<br>
+ if (target == GL_TEXTURE_CUBE_MAP) {<br>
+ int idx;<br>
+ for (idx = 0; idx < 6; idx++)<br>
+ glGetTexImage(cube_face_targets[idx], level, datatype, dataformat,<br>
+ (char *)data + layer_size * idx);<br>
+ } else<br>
+ glGetTexImage(target, level, datatype, dataformat,<br>
+ data);<br>
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);<br>
+ for (layer = 0; layer < d; layer++) {<br>
+ ub = data;<br>
+<br>
+ for (y = 0; y < h; y++) {<br>
+ for (x = 0; x < w; x++) {<br>
+ int offset = (x + layer) % w;<br>
+ GLubyte got_val;<br>
+ GLubyte exp_val = get_stencil_value(w, offset);<br>
+<br>
+ got_val = ub[y * w + x];<br>
+ if (exp_val != got_val) {<br>
+ fprintf(stderr, "mismatch at %d %d %d %d %d vs %d: %d %dx%d\n", level, x, y, layer, got_val, exp_val, layer_size, w, h);<br>
+ free(ptr);<br>
+ return false;<br>
+ }<br>
+ }<br>
+ }<br>
+ data = (char *)data + layer_size;<br>
+ }<br>
+<br>
+ if (!mip)<br>
+ break;<br>
+ if (w > 1)<br>
+ w >>= 1;<br>
+ if (target != GL_TEXTURE_1D &&<br>
+ target != GL_TEXTURE_1D_ARRAY &&<br>
+ h > 1)<br>
+ h >>= 1;<br>
+ }<br>
+ free(ptr);<br>
+ return true;<br>
+}<br>
+<br>
+bool test_depth_format(GLenum target, const struct format_desc *format)<br>
+{<br>
+ GLuint tex;<br>
+ int height, num_layers;<br>
+ bool ret;<br>
+<br>
+ /* 3D depth textures don't occur */<br>
+ if (target == GL_TEXTURE_3D)<br>
+ return true;<br>
+<br>
+ height = get_test_height(target);<br>
+ num_layers = get_test_depth(target);<br>
+<br>
+ tex = get_depth_texture(format, target, IMAGE_WIDTH, height, num_layers,<br>
+ target == GL_TEXTURE_RECTANGLE ? false : true);<br>
+<br>
+ ret = verify_depth_data(format, target, IMAGE_WIDTH, height, num_layers,<br>
+ target == GL_TEXTURE_RECTANGLE ? false : true);<br>
+<br>
+ piglit_report_subtest_result(ret ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+ "%s-%s",<br>
+ piglit_get_gl_enum_name(target),<br>
+ piglit_get_gl_enum_name(format->internalformat));<br>
+ glDeleteTextures(1, &tex);<br>
+ return ret;<br>
+}<br>
+<br>
+bool test_stencil_format(GLenum target, const struct format_desc *format)<br>
+{<br>
+ GLuint tex;<br>
+ int height, num_layers;<br>
+ bool ret;<br>
+ /* 3D depth textures don't occur */<br>
+ if (target == GL_TEXTURE_3D)<br>
+ return true;<br>
+<br>
+ height = get_test_height(target);<br>
+ num_layers = get_test_depth(target);<br>
+<br>
+ tex = get_stencil_texture(format, target, IMAGE_WIDTH, height, num_layers,<br>
+ target == GL_TEXTURE_RECTANGLE ? false : true);<br>
+<br>
+ ret = verify_stencil_data(format, target, IMAGE_WIDTH, height, num_layers,<br>
+ target == GL_TEXTURE_RECTANGLE ? false : true);<br>
+ piglit_report_subtest_result(ret ? PIGLIT_PASS : PIGLIT_FAIL,<br>
+ "%s-%s",<br>
+ piglit_get_gl_enum_name(target),<br>
+ piglit_get_gl_enum_name(format->internalformat));<br>
+ glDeleteTextures(1, &tex);<br>
+ return ret;<br>
+}<br>
+<br>
+bool test_target_format(GLenum target, const struct format_desc *format)<br>
+{<br>
+ if (format->base_internal_format == GL_DEPTH_COMPONENT ||<br>
+ format->base_internal_format == GL_DEPTH_STENCIL) {<br>
+ return test_depth_format(target, format);<br>
+ } else if (format->base_internal_format == GL_STENCIL_INDEX) {<br>
+ return test_stencil_format(target, format);<br>
+ }<br>
+ return true;<br>
+}<br>
+<br>
+bool test_target(GLenum target)<br>
+{<br>
+ int fmt_idx;<br>
+ int set_idx;<br>
+ int ext_idx;<br>
+ bool do_test_set;<br>
+ bool result = true, ret;<br>
+<br>
+ for (set_idx = 0; set_idx < ARRAY_SIZE(test_sets); set_idx++) {<br>
+ do_test_set = true;<br>
+ for (ext_idx = 0; ext_idx < 3; ext_idx++) {<br>
+ if (test_sets[set_idx].ext[ext_idx])<br>
+ if (!piglit_is_extension_supported(test_sets[set_idx].ext[ext_idx])) {<br>
+ do_test_set = false;<br>
+ break;<br>
+ }<br>
+ }<br>
+ if (!do_test_set)<br>
+ continue;<br>
+<br>
+ for (fmt_idx = 0; fmt_idx < test_sets[set_idx].num_formats; fmt_idx++) {<br>
+ ret = test_target_format(target, &test_sets[set_idx].format[fmt_idx]);<br>
+ if (ret == false)<br>
+ result = false;<br>
+ }<br>
+ }<br>
+ return result;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ int i;<br>
+ enum piglit_result status = PIGLIT_PASS;<br>
+ bool ret;<br>
+<br>
+ for (i = 0; i < 3; i++)<br>
+ test_target_bitmap |= (1 << i);<br>
+ if (piglit_is_extension_supported("GL_ARB_texture_rectangle"))<br>
+ test_target_bitmap |= (1 << 3);<br>
+ if (piglit_is_extension_supported("GL_ARB_texture_cube_map"))<br>
+ test_target_bitmap |= (1 << 4);<br>
+ if (piglit_is_extension_supported("GL_EXT_texture_array"))<br>
+ test_target_bitmap |= (1 << 5) | (1 << 6);<br>
+ if (piglit_is_extension_supported("GL_ARB_texture_cube_map_array"))<br>
+ test_target_bitmap |= (1 << 7);<br>
+<br>
+ for (i = 0; i < ARRAY_SIZE(target_list); i++) {<br>
+ if (!(test_target_bitmap & (1 << i)))<br>
+ continue;<br>
+<br>
+ ret = test_target(target_list[i]);<br>
+ if (ret == false)<br>
+ status = PIGLIT_FAIL;<br>
+ }<br>
+<br>
+ piglit_report_result(status);<br>
+ (void)fbo_formats_display;<br>
+}<br>
--<br>
2.4.3<br>
<br>
_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</blockquote></div>