<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 1, 2015 at 11:56 AM, Dylan Baker <span dir="ltr"><<a href="mailto:baker.dylan.c@gmail.com" target="_blank">baker.dylan.c@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I assume this should be added to all.py as well?<br>
<div><div class="h5"><br></div></div></blockquote><div>Yes. I've fixed this locally.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
On Fri, Aug 28, 2015 at 09:44:38AM -0700, Nanley Chery wrote:<br>
> From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
><br>
> These tests check that the GL error returned by valid and invalid API calls<br>
> are as defined by the spec.<br>
><br>
> Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> ---<br>
> .../khr_texture_compression_astc/CMakeLists.gl.txt | 1 +<br>
> .../CMakeLists.gles2.txt | 1 +<br>
> .../khr_compressed_astc-basic.c | 366 +++++++++++++++++++++<br>
> 3 files changed, 368 insertions(+)<br>
> create mode 100644 tests/spec/khr_texture_compression_astc/khr_compressed_astc-basic.c<br>
><br>
> diff --git a/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt<br>
> index a47c7d3..79500f7 100644<br>
> --- a/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt<br>
> +++ b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt<br>
> @@ -10,5 +10,6 @@ link_libraries (<br>
> )<br>
><br>
> piglit_add_executable(khr_compressed_astc-miptree_${piglit_target_api} khr_compressed_astc-miptree.c)<br>
> +piglit_add_executable(khr_compressed_astc-basic_${piglit_target_api} khr_compressed_astc-basic.c)<br>
><br>
> # vim: ft=cmake:<br>
> diff --git a/tests/spec/khr_texture_compression_astc/CMakeLists.gles2.txt b/tests/spec/khr_texture_compression_astc/CMakeLists.gles2.txt<br>
> index 047b8ac..3fb6fa5 100644<br>
> --- a/tests/spec/khr_texture_compression_astc/CMakeLists.gles2.txt<br>
> +++ b/tests/spec/khr_texture_compression_astc/CMakeLists.gles2.txt<br>
> @@ -4,5 +4,6 @@ include_directories(<br>
> )<br>
> link_libraries(piglitutil_${piglit_target_api})<br>
> piglit_add_executable(khr_compressed_astc-miptree_${piglit_target_api} khr_compressed_astc-miptree.c)<br>
> +piglit_add_executable(khr_compressed_astc-basic_${piglit_target_api} khr_compressed_astc-basic.c)<br>
><br>
> # vim: ft=cmake:<br>
> diff --git a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-basic.c b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-basic.c<br>
> new file mode 100644<br>
> index 0000000..d83ad5e<br>
> --- /dev/null<br>
> +++ b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-basic.c<br>
> @@ -0,0 +1,366 @@<br>
> +/*<br>
> + * Copyright © 2011 Intel Corporation<br>
<br>
</div></div>2014 or 2015 I assume?<br>
<div><div class="h5"><br></div></div></blockquote><div>Good find. I'll update the date.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> + *<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>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * 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, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> + * DEALINGS IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl.h"<br>
> +<br>
> +static const GLenum cube_map_face_targets[] = {<br>
> + GL_TEXTURE_CUBE_MAP_POSITIVE_X,<br>
> + GL_TEXTURE_CUBE_MAP_NEGATIVE_X,<br>
> + GL_TEXTURE_CUBE_MAP_POSITIVE_Y,<br>
> + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,<br>
> + GL_TEXTURE_CUBE_MAP_POSITIVE_Z,<br>
> + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z<br>
> +};<br>
> +<br>
> +static const GLenum good_targets[] = {<br>
> + GL_TEXTURE_2D_ARRAY,<br>
> + GL_TEXTURE_CUBE_MAP_ARRAY_EXT,<br>
> + GL_TEXTURE_3D,<br>
> +};<br>
> +<br>
> +typedef struct _astc_fmt {<br>
> + GLenum fmt;<br>
> + int bw;<br>
> + int bh;<br>
> + int bb;<br>
> +} astc_fmt;<br>
> +<br>
> +static const astc_fmt formats[] = {<br>
> + {GL_COMPRESSED_RGBA_ASTC_4x4_KHR , 4, 4, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_5x4_KHR , 5, 4, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_5x5_KHR , 5, 5, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_6x5_KHR , 6, 5, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_6x6_KHR , 6, 6, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_8x5_KHR , 8, 5, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_8x6_KHR , 8, 6, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_8x8_KHR , 8, 8, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_10x5_KHR , 10, 5, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_10x6_KHR , 10, 6, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_10x8_KHR , 10, 8, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_10x10_KHR , 10, 10, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_12x10_KHR , 12, 10, 16},<br>
> + {GL_COMPRESSED_RGBA_ASTC_12x12_KHR , 12, 12, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR , 4, 4, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR , 5, 4, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR , 5, 5, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR , 6, 5, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR , 6, 6, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR , 8, 5, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR , 8, 6, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR , 8, 8, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR , 10, 5, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR , 10, 6, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR , 10, 8, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 10, 10, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 16},<br>
> + {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 16}<br>
> +};<br>
> +<br>
> +<br>
> +#define REQUIRE_ERROR(expected_error) \<br>
> +do {\<br>
> + if (!piglit_check_gl_error(expected_error))\<br>
> + piglit_report_result(PIGLIT_FAIL);\<br>
> +} while (0)<br>
> +<br>
> +<br>
> +/*<br>
> + * The KHR_texture_compression_astc_ldr spec says:<br>
> + * * An INVALID_OPERATION error is generated by CompressedTexImage3D if<br>
> + * <internalformat> is one of the the formats in table 8.19 and <target><br>
> + * is not TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, or TEXTURE_3D.<br>
> + *<br>
> + * * An INVALID_OPERATION error is generated by CompressedTexImage3D if<br>
> + * <internalformat> is TEXTURE_CUBE_MAP_ARRAY and the "Cube Map Array"<br>
> + * column of table 8.19 is *not* checked, or if <internalformat> is<br>
> + * TEXTURE_3D and the "3D Tex." column of table 8.19 is *not* checked"<br>
> + *<br>
> + * Discussion:<br>
> + * * Since this extension only increases the allowed targets, the<br>
> + * existing errors are assumed to be already handled, and the allowed<br>
> + * targets are tested to be free of errors.<br>
> + *<br>
> + * * Since all ASTC formats have the "Cube Map Array" column checked,<br>
> + * test that no error is generated from calling CompressedTexImage3D with<br>
> + * the TEXTURE_CUBE_MAP_ARRAY target.<br>
> + *<br>
> + */<br>
> +void test_compressed_teximg_3d(int fi, bool have_cube_map_ext)<br>
> +{<br>
> + int j;<br>
> + GLuint tex3D;<br>
> + char fake_tex_data[6*16];<br>
> + bool have_hdr = piglit_is_extension_supported(<br>
> + "GL_KHR_texture_compression_astc_hdr");<br>
> +<br>
> + for (j = 0; j < ARRAY_SIZE(good_targets); ++j) {<br>
> +<br>
> + /* Skip the cube_map target if there's no support */<br>
> + if (good_targets[j] == GL_TEXTURE_CUBE_MAP_ARRAY_EXT &&<br>
> + !have_cube_map_ext)<br>
> + continue;<br>
> +<br>
> + /* Run the command */<br>
> + glGenTextures(1, &tex3D);<br>
> + glBindTexture(good_targets[j], tex3D);<br>
> + glCompressedTexImage3D(good_targets[j], 0, formats[fi].fmt,<br>
> + 4, 4, 6, 0, 6*formats[fi].bb, fake_tex_data);<br>
> +<br>
> + /* Test expected GL errors */<br>
> + if (good_targets[j] == GL_TEXTURE_3D && !have_hdr) {<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> + } else {<br>
> + REQUIRE_ERROR(GL_NO_ERROR);<br>
> + }<br>
> +<br>
> + glDeleteTextures(1, &tex3D);<br>
> + }<br>
> +}<br>
> +<br>
> +/*<br>
> + * The KHR_texture_compression_astc_ldr spec says:<br>
> + * "An INVALID_VALUE error is generated by<br>
> + *<br>
> + * * CompressedTexImage2D if <target> is<br>
> + * one of the cube map face targets from table 8.21, and<br>
> + * * CompressedTexImage3D if <target> is TEXTURE_CUBE_MAP_ARRAY,<br>
> + *<br>
> + * and <width> and <height> are not equal."<br>
> + */<br>
> +void test_non_square_img(int fi)<br>
> +{<br>
> + int j;<br>
> + char fake_tex_data[6*16];<br>
> + GLuint cube_tex;<br>
> +<br>
> + glGenTextures(1, &cube_tex);<br>
> + glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY_EXT, cube_tex);<br>
> +<br>
> + /* Test CompressedTexImage2D */<br>
> + for (j = 0; j < ARRAY_SIZE(cube_map_face_targets); ++j) {<br>
> + glCompressedTexImage2D(cube_map_face_targets[j], 0,<br>
> + formats[fi].fmt, 4, 3, 0,<br>
> + formats[fi].bb, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_INVALID_VALUE);<br>
> + }<br>
> +<br>
> + /* Test CompressedTexImage3D */<br>
> + glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_EXT, 0,<br>
> + formats[fi].fmt, 4, 3, 6, 0, 6*formats[fi].bb, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_INVALID_VALUE);<br>
> +<br>
> + glDeleteTextures(1, &cube_tex);<br>
> +<br>
> +}<br>
> +<br>
> +int get_expected_size(int width, int height, int bw, int bh, int bb)<br>
> +{<br>
> + int nbw = (width + bw - 1) / bw;<br>
> + int nbh = (height + bh - 1) / bh;<br>
> + return nbw * nbh * bb;<br>
> +}<br>
> +<br>
> +<br>
> +/*<br>
> + * The KHR_texture_compression_astc_ldr spec says:<br>
> + * * "An INVALID_OPERATION error is generated if format is one of the formats<br>
> + * in table 8.19 and any of the following conditions occurs. The block<br>
> + * width and height refer to the values in the corresponding column of the<br>
> + * table.<br>
> + *<br>
> + * * <width> is not a multiple of the format's block width, and <width> +<br>
> + * <xoffset> is not equal to the value of TEXTURE_WIDTH.<br>
> + * * height is not a multiple of the format's block height, and <height><br>
> + * + <yoffset> is not equal to the value of TEXTURE_HEIGHT.<br>
> + * * <xoffset> or <yoffset> is not a multiple of the block width or<br>
> + * height, respectively."<br>
> + *<br>
> + * [...]<br>
> + *<br>
> + * ASTC texture formats are supported by immutable-format textures only if<br>
> + * such textures are supported by the underlying implementation (e.g.<br>
> + * OpenGL 4.1 or later, OpenGL ES 3.0 or later, or earlier versions<br>
> + * supporting the GL_EXT_texture_storage extension). Otherwise, remove all<br>
> + * references to the Tex*Storage* commands from this specification.<br>
> + */<br>
> +void test_sub_img(int fi)<br>
> +{<br>
> + GLuint tex;<br>
> + char fake_tex_data[4*16];<br>
> + int width = 7;<br>
> + int height = 7;<br>
> + int expectedSizeGood = get_expected_size(4, 4,<br>
> + formats[fi].bw,<br>
> + formats[fi].bh, formats[fi].bb);<br>
> + int expectedSizeBad = get_expected_size(width, height,<br>
> + formats[fi].bw,<br>
> + formats[fi].bh, formats[fi].bb);<br>
> +<br>
> + /* Allocate enough to hold the larger case */<br>
> + glGenTextures(1, &tex);<br>
> + glBindTexture(GL_TEXTURE_2D, tex);<br>
> + glTexStorage2D(GL_TEXTURE_2D, 1, formats[fi].fmt, 14, 14);<br>
> + REQUIRE_ERROR(GL_NO_ERROR);<br>
> +<br>
> + /* Check for No Error */<br>
> + glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,<br>
> + formats[fi].bw, formats[fi].bh,<br>
> + formats[fi].fmt, expectedSizeGood, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_NO_ERROR);<br>
> +<br>
> + /* Check for expected Error */<br>
> + glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,<br>
> + formats[fi].fmt, expectedSizeBad, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> +<br>
> + glDeleteTextures(1, &tex);<br>
> +<br>
> + if (piglit_is_extension_supported("GL_EXT_texture_storage")) {<br>
> + /* Check for expected Error */<br>
> + glGenTextures(1, &tex);<br>
> + glTextureStorage3DEXT(tex, GL_TEXTURE_3D, 1, formats[fi].fmt,<br>
> + 14, 14, 1);<br>
> + glCompressedTexImage3D(GL_TEXTURE_3D, 0, formats[fi].fmt,<br>
> + 7, 7, 1, 0, expectedSizeBad, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> + glDeleteTextures(1, &tex);<br>
> + }<br>
> +}<br>
> +<br>
> +/*<br>
> + * The KHR_texture_compression_astc_ldr spec says:<br>
> + * [...] the ASTC format specifiers will not be added to<br>
> + * Table 3.14, and thus will not be accepted by the TexImage*D<br>
> + * functions, and will not be returned by the (already deprecated)<br>
> + * COMPRESSED_TEXTURE_FORMATS query.<br>
> + *<br>
> + * Discussion:<br>
> + * The deprecated query is handled by:<br>
> + * tests/spec/arb_texture_compression/invalid-formats.c<br>
> + * In TexImage*D, the format should be automatically<br>
> + * converted to the base internal format of GL_RGBA.<br>
> + */<br>
> +void test_tex_img(int fi, bool have_mipmap)<br>
> +{<br>
> + GLuint tex;<br>
> + char fake_tex_data[16];<br>
> + glGenTextures(1, &tex);<br>
> + glBindTexture(GL_TEXTURE_2D, tex);<br>
> +<br>
> + /* Allocate for an ASTC texture for following texsubimage calls<br>
> + * Since TexImage*D must fail, then the corresponding TexSubImage<br>
> + * calls must fail as well.<br>
> + */<br>
> + glCompressedTexImage2D(GL_TEXTURE_2D, 0,<br>
> + formats[fi].fmt, 4, 4, 0, formats[fi].bb, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_NO_ERROR);<br>
> +<br>
> + /* Check for expected error from Tex*Image*D family of functions */<br>
> + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,<br>
> + 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, fake_tex_data);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> +<br>
> + glTexImage2D(GL_TEXTURE_2D, 0,<br>
> + formats[fi].fmt, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> +<br>
> + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> +<br>
> + glCopyTexImage2D(GL_TEXTURE_2D, 0, formats[fi].fmt, 0, 0, 4, 4, 0);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> +<br>
> + /* Check for expected error from the online compression resulting from<br>
> + * calling GenerateMipmap.<br>
> + */<br>
> + if (have_mipmap) {<br>
> + glGenerateMipmap(GL_TEXTURE_2D);<br>
> + REQUIRE_ERROR(GL_INVALID_OPERATION);<br>
> + }<br>
> +<br>
> + glDeleteTextures(1, &tex);<br>
> +<br>
> +}<br>
> +<br>
> +bool static inline<br>
> +have_tex_storage_support()<br>
> +{<br>
> +#if defined (PIGLIT_USE_OPENGL)<br>
> + return piglit_get_gl_version() >= 42 ||<br>
> + piglit_is_extension_supported("GL_ARB_texture_storage");<br>
> +#else<br>
> + return piglit_get_gl_version() >= 30 ||<br>
> + piglit_is_extension_supported("GL_EXT_texture_storage");<br>
> +#endif<br>
> +}<br>
> +<br>
> +<br>
> +bool static inline<br>
> +have_cube_map_array_support()<br>
> +{<br>
> +#if defined (PIGLIT_USE_OPENGL_ES3)<br>
> + return piglit_is_extension_supported("GL_EXT_texture_cube_map_array");<br>
> +#elif defined (PIGLIT_USE_OPENGL)<br>
> + return piglit_get_gl_version() >= 40 ||<br>
> + piglit_is_extension_supported("GL_ARB_texture_cube_map_array");<br>
> +#endif<br>
> + return false;<br>
> +}<br>
> +<br>
> +<br>
> +enum piglit_result<br>
> +piglit_display(void)<br>
> +{<br>
> + unsigned i;<br>
> + bool have_cube_map_ext = have_cube_map_array_support();<br>
> + bool have_tex_stor_ext = have_tex_storage_support();<br>
> + bool have_mipmap = piglit_is_extension_supported("GL_ARB_framebuffer_object");<br>
> +<br>
> + for (i = 0; i < ARRAY_SIZE(formats); i++) {<br>
> + if (have_cube_map_ext)<br>
> + test_non_square_img(i);<br>
> + if (have_tex_stor_ext)<br>
> + test_sub_img(i);<br>
> + test_compressed_teximg_3d(i, have_cube_map_ext);<br>
> + test_tex_img(i, have_mipmap);<br>
> + }<br>
> +<br>
> + piglit_report_result(PIGLIT_PASS);<br>
> +}<br>
> +<br>
> +<br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> + piglit_require_extension("GL_KHR_texture_compression_astc_ldr");<br>
> +}<br>
> +<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_BEGIN<br>
> +<br>
> + config.supports_gl_compat_version = 11;<br>
> + config.supports_gl_es_version = 10;<br>
> +<br>
> + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_END<br>
> --<br>
> 2.5.0<br>
><br>
</div></div>> _______________________________________________<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><br></div></div>