<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 9, 2015 at 5:04 PM, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@intel.com" target="_blank">chad.versace@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri 28 Aug 2015, 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 run through every ASTC configuration, comparing the<br>
> render of a compressed texture against a render of the decompressed<br>
> version of that compressed texture. The compressed and decompressed<br>
> texture was generated with a reference codec.<br>
><br>
> Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<br>
<br>
</span><span class="">> diff --git a/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt<br>
> new file mode 100644<br>
> index 0000000..a47c7d3<br>
> --- /dev/null<br>
> +++ b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt<br>
> @@ -0,0 +1,14 @@<br>
> +include_directories(<br>
> +     ${GLEXT_INCLUDE_DIR}<br>
> +     ${OPENGL_INCLUDE_PATH}<br>
> +)<br>
<br>
</span>I think you can drop the call to include_directories. And If you can,<br>
you should. Please try rebuilding without it.<br>
<span class=""><br></span></blockquote><div>Done. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +link_libraries (<br>
> +     piglitutil_${piglit_target_api}<br>
> +     ${OPENGL_gl_LIBRARY}<br>
> +     ${OPENGL_glu_LIBRARY}<br>
> +)<br>
<br>
</span>As above, I think you can drop the explicit linking to<br>
OPENGL_gl_LIBRARY. And you can definitiely drop the explicit linking to<br>
OPENGL_glu_LIBRARY.<br>
<span class=""><br></span></blockquote>Done.<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +piglit_add_executable(khr_compressed_astc-miptree_${piglit_target_api} khr_compressed_astc-miptree.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>
> new file mode 100644<br>
> index 0000000..047b8ac<br>
> --- /dev/null<br>
> +++ b/tests/spec/khr_texture_compression_astc/CMakeLists.gles2.txt<br>
> @@ -0,0 +1,8 @@<br>
> +include_directories(<br>
> +     ${GLEXT_INCLUDE_DIR}<br>
> +     ${OPENGL_INCLUDE_PATH}<br>
> +)<br>
<br>
</span>As for CMakeLists.gl.txt, I think you should drop this call<br>
include_directories if Piglit can build without it.<br>
<span class=""><br></span></blockquote><div>Done. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +link_libraries(piglitutil_${piglit_target_api})<br>
> +piglit_add_executable(khr_compressed_astc-miptree_${piglit_target_api} khr_compressed_astc-miptree.c)<br>
> +<br>
> +# vim: ft=cmake:<br>
<br>
<br>
</span><span class="">> diff --git a/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c<br>
> new file mode 100644<br>
> index 0000000..a804b9b<br>
> --- /dev/null<br>
> +++ b/tests/spec/khr_texture_compression_astc/khr_compressed_astc-miptree.c<br>
<br>
</span><span class="">> +/**<br>
> + * \file<br>
> + * \brief Test texturing from an ASTC miptree of a real image.<br>
> + *<br>
> + * This test is an adaptation of the oes_compressed_etc1_rgb8_textures test.<br>
> + *<br>
> + * This test uses eighty-four data files. The files under compressed/ contain<br>
</span>                     ^^^^^^^^^^^<br>
Remove "eighty-four" from the comment. It puts the comment at high risk<br>
of becoming stale.<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> + * full miptrees, in the GL_*_ASTC_* formats, of a 2D texture of waffles and<br>
> + * fruit [1].  The base level size was shrunken to 160x106 pixels. The files<br>
> + * under the decompressed directory contain the same miptree in GL_RGBA<br>
> + * format. Each miplevel was obtained by decompressing the corresponding ASTC<br>
> + * texture with astcenc [2].<br>
> + *<br>
> + * This test draws miplevels of the compressed textures according to the<br>
> + * MIPLAYOUT_BELOW organization scheme. It does the same when drawing<br>
</span>      ^^^^^^^^^^^^^^^<br>
<br>
MIPLAYOUT_BELOW is a term specific to Intel hardware that no one but<br>
Intel miptree ninjas like yourself will recognize. (In several more years,<br>
perhaps *no one* will recognize it, because<br>
MIPLAYOUT_BELOW/MIPLAYOUT_THE_OTHER_ONE was configurable only on legacy<br>
hardware). If you want to describe the test's image layout, draw<br>
a little ASCII diagram instead.<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> + * the decompressed texture on the right. Each miplevel of both images are<br>
> + * compared for equality after each level is drawn.<br>
</span>                                                ^^^^^<br>
                                                drawn<br></blockquote><div>I'm assuming you were meaning to say that "each level"  is redundant, so I modified the sentence accordingly. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">> + *<br>
> + * [1] The reference image is located at <a href="http://people.freedesktop.org/~chadversary/permalink/2012-07-09/1574cff2-d091-4421-a3cf-b56c7943d060.jpg" rel="noreferrer" target="_blank">http://people.freedesktop.org/~chadversary/permalink/2012-07-09/1574cff2-d091-4421-a3cf-b56c7943d060.jpg</a>.<br>
> + * [2] astcenc is the reference ASTC compression tool, available at <a href="http://malideveloper.arm.com/develop-for-mali/tools/software-tools/astc-evaluation-codec/" rel="noreferrer" target="_blank">http://malideveloper.arm.com/develop-for-mali/tools/software-tools/astc-evaluation-codec/</a>.<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl.h"<br>
> +#include "piglit_ktx.h"<br>
> +<br>
> +#define num_levels 8<br>
> +#define level0_width 160<br>
> +#define level0_height 106<br>
> +<br>
> +#define num_vertices 4<br>
<br>
</span>To comply with Piglit's code style, the macros above should ALL_CAPS.<br>
<span class=""><br></span></blockquote><div>Done. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +static GLuint prog;<br>
> +<br>
> +static struct piglit_gl_test_config *piglit_config;<br>
> +<br>
> +typedef struct _test_data<br>
<br>
</span>The struct tag '_test_data' is nowhere used, and so should be removed.<br>
<span class=""><br>
> +{<br>
> +     bool hdr_test;<br>
> +     bool srgb_test;<br>
</span>> +} test_data;<br>
<br>
More importantly, this struct should be converted to an enum.<br>
Each field of the struct is already pairwise mutually exclusive. And the<br>
struct contains an implicit 3rd field, ldr_test, which occurs when<br>
!(hdr_test || sgrb_test). Therefore this enum is a good replacement:<br>
<br>
    enum test_type {<br>
        TEST_TYPE_LDR,<br>
        TEST_TYPE_HDR,<br>
        TEST_TYPE_SRGB,<br>
<div><div class="h5">    };<br>
<br></div></div></blockquote>Fixed.<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> +<br>
> +<br>
> +/**<br>
> + * The \a filename is relative to the current test's source directory.<br>
> + *<br>
> + * A new texture is created and returned in \a tex_name.<br>
> + */<br>
> +static void<br>
> +load_texture(const char *dir1, const char *dir2,<br>
> +     const char *filename, GLuint *tex_name)<br>
> +{<br>
> +     struct piglit_ktx *ktx;<br>
> +     const struct piglit_ktx_info *info;<br>
> +     char filepath[4096];<br>
> +     bool ok = true;<br>
> +<br>
> +     piglit_join_paths(filepath, sizeof(filepath), 7,<br>
> +                       piglit_source_dir(),<br>
> +                       "tests",<br>
> +                       "spec",<br>
> +                       "khr_texture_compression_astc",<br>
> +                       dir1,<br>
> +                       dir2,<br>
> +                       filename);<br>
> +<br>
> +     ktx = piglit_ktx_read_file(filepath);<br>
> +     if (ktx == NULL)<br>
> +             piglit_report_result(PIGLIT_FAIL);<br>
> +<br>
> +     info = piglit_ktx_get_info(ktx);<br>
> +     assert(info->num_miplevels == num_levels);<br>
> +     assert(info->target == GL_TEXTURE_2D);<br>
> +     assert(info->pixel_width == level0_width);<br>
> +     assert(info->pixel_height== level0_height);<br>
</div></div>                              ^^^^^<br>
                              Missing space.<br></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">> +<br>
> +     *tex_name = 0;<br>
> +     ok = piglit_ktx_load_texture(ktx, tex_name, NULL);<br>
> +     if (!ok)<br>
> +             piglit_report_result(PIGLIT_FAIL);<br>
> +<br>
> +     piglit_ktx_destroy(ktx);<br>
> +}<br>
> +<br>
> +/** Compares the compressed texture against the decompressed texture */<br>
> +bool draw_compare_levels(bool check_error, bool check_srgb,<br>
> +                     GLint level_pixel_size_loc, GLint pixel_offset_loc,<br>
> +                     GLuint compressed_tex, GLuint decompressed_tex)<br>
> +{<br>
> +     /* Fully-saturated magenta */<br>
> +     static const float error_color[4] = {1.0, 0.0, 1.0, 1.0};<br>
> +<br>
> +     unsigned y = 0;<br>
> +     unsigned x = 0;<br>
> +     bool pass = true;<br>
> +     int level = 0;<br>
> +<br>
> +     for (; level < num_levels; ++level) {<br>
> +             int w = level0_width >> level;<br>
> +             int h = level0_height >> level;<br>
> +             glUniform2f(level_pixel_size_loc, (float) w, (float) h);<br>
> +<br>
> +<br>
> +             /* Draw miplevel of compressed texture. */<br>
> +             glBindTexture(GL_TEXTURE_2D, compressed_tex);<br>
> +             if (!check_srgb)<br>
> +                     glTexParameteri(GL_TEXTURE_2D,<br>
> +                                     GL_TEXTURE_SRGB_DECODE_EXT,<br>
> +                                     GL_SKIP_DECODE_EXT);<br>
> +             glUniform2f(pixel_offset_loc, x, y);<br>
> +             glDrawArrays(GL_TRIANGLE_FAN, 0, num_vertices);<br>
> +<br>
> +             /* Draw miplevel of decompressed texture. */<br>
> +             if (!check_error) {<br>
> +                     glBindTexture(GL_TEXTURE_2D, decompressed_tex);<br>
> +                     if (!check_srgb)<br>
> +                             glTexParameteri(GL_TEXTURE_2D,<br>
> +                                             GL_TEXTURE_SRGB_DECODE_EXT,<br>
> +                                             GL_SKIP_DECODE_EXT);<br>
> +                     glUniform2f(pixel_offset_loc, level0_width + x, y);<br>
> +                     glDrawArrays(GL_TRIANGLE_FAN, 0, num_vertices);<br>
> +             }<br>
> +<br>
> +             /* Check the textures (or error-colors) for equivalence. */<br>
> +             if (pass) {<br>
> +                     if (check_error) {<br>
> +                             pass = piglit_probe_rect_rgba(x, y, w, h,<br>
> +                                                             error_color);<br>
> +                     } else {<br>
> +                             pass = piglit_probe_rects_equal(x, y,<br>
> +                                                     level0_width + x, y,<br>
> +                                                      w, h, GL_RGBA);<br>
> +                     }<br>
> +<br>
> +                     if (!pass)<br>
> +                             piglit_loge("Miplevel %d", level);<br>
> +             }<br>
> +<br>
> +             /* Update the next miplevel arrangement */<br>
> +             if (level == 1)<br>
> +                     x += w;<br>
> +             else<br>
> +                     y += h;<br>
> +     }<br>
> +<br>
> +     /* Delete bound textures */<br>
> +     glDeleteTextures(1, &compressed_tex);<br>
> +     glDeleteTextures(1, &decompressed_tex);<br>
> +<br>
> +     piglit_present_results();<br>
> +     return pass;<br>
> +}<br>
> +<br>
> +enum piglit_result<br>
> +test_miptrees(void* input_data)<br>
> +{<br>
> +     int subtest =  0;<br>
> +     test_data * data = (test_data*) input_data;<br>
> +<br>
> +     static const char * tests[3] = {"hdr", "ldrl", "ldrs"};<br>
> +     static const char * block_dim_str[14] = {<br>
> +             "4x4",<br>
> +             "5x4",<br>
> +             "5x5",<br>
> +             "6x5",<br>
> +             "6x6",<br>
> +             "8x5",<br>
> +             "8x6",<br>
> +             "8x8",<br>
> +             "10x5",<br>
> +             "10x6",<br>
> +             "10x8",<br>
> +             "10x10",<br>
> +             "12x10",<br>
> +             "12x12"<br>
> +     };<br>
> +<br>
> +     static const char * hdr_str = "GL_KHR_texture_compression_astc_hdr";<br>
<br>
</div></div>Variable 'hdr_str' should be removed, and the string simply inlined in<br>
the call to piglit_is_extension_supported().<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +     bool hdr_sys = piglit_is_extension_supported(hdr_str);<br>
<br>
</span>Please rename 'hdr_sys' to a name that looks like a boolean. Something<br>
like 'has_hdr', 'is_hdr_supported', or similar.<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +     /* If testing sRGB mode, fast-forward to the srgb test. */<br>
> +     if (data->srgb_test)<br>
> +             subtest =  2;<br>
<br>
</span>Being a multiline 'if' statement, the 'if' clause should have braces.<br>
<div><div class="h5"><br></div></div></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> +     else {<br>
> +             /* Skip if on an HDR system not running the HDR test<br>
> +              * or if on an LDR system running the HDR test.<br>
> +              */<br>
> +             if (hdr_sys != data->hdr_test)<br>
> +                     return PIGLIT_SKIP;<br>
> +             piglit_require_extension("GL_EXT_texture_sRGB_decode");<br>
> +<br>
> +     }<br>
> +<br>
> +     GLint pixel_offset_loc = glGetUniformLocation(prog, "pixel_offset");<br>
> +     GLint level_pixel_size_loc = glGetUniformLocation(prog,<br>
> +                                                     "level_pixel_size");<br>
> +<br>
> +     /* Test each submode */<br>
> +     for (; subtest < ARRAY_SIZE(tests); ++subtest) {<br>
> +<br>
> +             /*  Check for error color if an LDR-only sys reading an HDR<br>
> +              *  texture. No need to draw a reference mipmap in this case.<br>
> +              */<br>
> +             int check_error = !hdr_sys && subtest == 0; // 0 == hdr<br>
> +             int block_dims = 0;<br>
> +             for (; block_dims < ARRAY_SIZE(block_dim_str); ++block_dims) {<br>
> +                     /* Texture objects. */<br>
> +                     GLuint tex_cd[2];<br>
</div></div>                               ^^^^^^<br>
Please explain the cryptin meaning of 'cd'.<br>
<span class=""><br></span></blockquote><div>Fixed.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +                     /* Generate filename for compressed texture */<br>
> +                     char cur_file[20];<br>
> +                     snprintf(cur_file, sizeof(cur_file), "waffles-%s.ktx",<br>
> +                                             block_dim_str[block_dims]);<br>
<br>
</span>The full filename is partially constructed here, and partially<br>
constructed in load_texture(). The code would be more understandable if<br>
the full filename was fully constructed in a single place.<br>
<span class=""><br></span></blockquote><div>Done.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +                     /* Load texture for current submode and block size */<br>
> +                     glGenTextures(2, tex_cd);<br>
> +                     load_texture("compressed", tests[subtest], cur_file,<br>
> +                                     &tex_cd[0]);<br>
<br>
> +                     if (!check_error)<br>
> +                             load_texture("decompressed", tests[subtest],<br>
> +                                             cur_file, &tex_cd[1]);<br>
<br>
</span>The above 'if' statement is multiline. Please use braces to prevent<br>
future bugs.<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +                     /* Draw and compare each level of the two textures */<br>
> +                     glClear(GL_COLOR_BUFFER_BIT);<br>
> +                     if (!draw_compare_levels(check_error, data->srgb_test,<br>
> +                                             level_pixel_size_loc,<br>
> +                                             pixel_offset_loc,<br>
> +                                             tex_cd[0], tex_cd[1])) {<br>
> +                             piglit_loge("Mode %s Block %s.",<br>
> +                                     tests[subtest],<br>
> +                                     block_dim_str[block_dims]);<br>
> +                             return PIGLIT_FAIL;<br>
> +                     }<br>
> +             }<br>
> +     }<br>
> +     return PIGLIT_PASS;<br>
> +}<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
</span>The config block should occur as early as possible in the source file.<br>
Preferably, the config block should occur above all functions.<br>
<span class=""><br></span></blockquote><div>Fixed. I had to include a function prototype before this block to get this to work. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> +     piglit_config = &config;<br>
> +     config.supports_gl_compat_version = 11;<br>
> +     config.supports_gl_es_version = 10;<br>
> +<br>
> +     config.window_width = 2 * level0_width;<br>
> +     config.window_height = level0_height + (level0_height >> 1);<br>
> +     config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
> +<br>
> +     /* struct initialization: {hdr_test, srgb_test} */<br>
> +     static test_data ldr_test  = {false, false};<br>
> +     static test_data hdr_test  = {true , false};<br>
> +     static test_data srgb_test = {false, true };<br>
<br>
> +     config.subtests = (struct piglit_subtest[]) {<br>
<br>
</span>C99's compound expression syntax is illegal in C89. To remove the<br>
compound expression, declare the array of subtests as<br>
<br>
    static const struct piglit_subtest subtests[] = {<br>
        ...<br>
    };<br>
<span class=""><br></span></blockquote><div>Fixed. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +             {<br>
> +                     "LDR Profile",<br>
> +                     "ldr",<br>
> +                     test_miptrees,<br>
> +                     &ldr_test,<br>
> +             },<br>
> +             {<br>
> +                     "HDR Profile",<br>
> +                     "hdr",<br>
> +                     test_miptrees,<br>
> +                     &hdr_test,<br>
> +             },<br>
> +             {<br>
> +                     "sRGB decode",<br>
> +                     "srgb",<br>
> +                     test_miptrees,<br>
> +                     &srgb_test,<br>
> +             },<br>
> +             {NULL},<br>
> +     };<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_END<br>
<br>
</span>[snip]<br>
</blockquote></div><br></div></div>