[Piglit] [PATCH v3] arb_clear_texture: add a trivial test
Ilia Mirkin
imirkin at alum.mit.edu
Mon Mar 17 06:48:35 PDT 2014
1-week ping
On Sat, Mar 8, 2014 at 12:40 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> Fabian, since the test has changed a bunch I'm dropping your R-b. Feel free to
> take another look.
>
> Eric, I hope that this is all in order. I tried using the shader approach, but
> it didn't work (at least in part due to a missing piglit_present_results
> call), and I didn't try to go back to using it. Not sure that it's worth it.
>
> Amusing side-note, while adding the second glClearTexSubImage call I
> discovered 2 bugs(!), one in the core impl not returning on the invalid bounds
> error, and one in the driver impl of offsets (the width/height were assumed to
> be of the whole image, and not of the clear area).
>
> v2 -> v3:
>
> - reintroduce draw step for easier visual debugging,
> using piglit_draw_rect_tex
> - add a use of glClearTexSubImage
>
> v1 -> v2:
>
> - clear-simple -> simple
> - free the colors array
> - remove unnecessary texparameter settings
> - switch to probing the texels directly, avoiding the fbo dance
>
> glapi/gl.spec | 41 ++++++++
> tests/all.py | 4 +
> tests/spec/CMakeLists.txt | 1 +
> tests/spec/arb_clear_texture/CMakeLists.gl.txt | 13 +++
> tests/spec/arb_clear_texture/CMakeLists.txt | 1 +
> tests/spec/arb_clear_texture/simple.c | 139 +++++++++++++++++++++++++
> 6 files changed, 199 insertions(+)
> create mode 100644 tests/spec/arb_clear_texture/CMakeLists.gl.txt
> create mode 100644 tests/spec/arb_clear_texture/CMakeLists.txt
> create mode 100644 tests/spec/arb_clear_texture/simple.c
>
> diff --git a/glapi/gl.spec b/glapi/gl.spec
> index a8fcc44..6a24f83 100644
> --- a/glapi/gl.spec
> +++ b/glapi/gl.spec
> @@ -16410,6 +16410,47 @@ TextureStorage3DMultisampleEXT(texture, target, samples, internalformat, width,
> glxflags ignore
> offset ?
>
> +###############################################################################
> +#
> +# Extension #ARB145
> +# ARB_clear_texture commands
> +#
> +###############################################################################
> +
> +ClearTexImage(texture, level, format, type, data)
> + return void
> + param texture UInt32 in value
> + param level Int32 in value
> + param format GLenum in value
> + param type GLenum in value
> + param data Void in array [COMPSIZE(format/type)]
> + category ARB_clear_texture
> + version 4.4
> + extension
> + glxropcode ?
> + glxflags ignore
> + offset ?
> +
> +ClearTexSubImage(texture, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data)
> + return void
> + param texture UInt32 in value
> + param level Int32 in value
> + param xoffset Int32 in value
> + param yoffset Int32 in value
> + param zoffset Int32 in value
> + param width Int32 in value
> + param height Int32 in value
> + param depth Int32 in value
> + param format GLenum in value
> + param type GLenum in value
> + param data Void in array [COMPSIZE(format/type)]
> + category ARB_clear_texture
> + version 4.4
> + extension
> + glxropcode ?
> + glxflags ignore
> + offset ?
> +
>
> ###############################################################################
> ###############################################################################
> diff --git a/tests/all.py b/tests/all.py
> index d6daed2..490aafa 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -3075,6 +3075,10 @@ add_concurrent_test(arb_clear_buffer_object, 'arb_clear_buffer_object-sub-overla
> add_concurrent_test(arb_clear_buffer_object, 'arb_clear_buffer_object-sub-simple')
> add_concurrent_test(arb_clear_buffer_object, 'arb_clear_buffer_object-zero-size')
>
> +arb_clear_texture = Group()
> +spec['ARB_clear_texture'] = arb_clear_texture
> +add_concurrent_test(arb_clear_texture, 'arb_clear_texture-simple')
> +
> arb_copy_buffer = Group()
> spec['ARB_copy_buffer'] = arb_copy_buffer
> add_plain_test(arb_copy_buffer, 'copy_buffer_coherency')
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 0a513c1..3ea6c1e 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -2,6 +2,7 @@ add_subdirectory (amd_performance_monitor)
> add_subdirectory (arb_base_instance)
> add_subdirectory (arb_buffer_storage)
> add_subdirectory (arb_clear_buffer_object)
> +add_subdirectory (arb_clear_texture)
> add_subdirectory (arb_color_buffer_float)
> add_subdirectory (arb_compute_shader)
> add_subdirectory (arb_debug_output)
> diff --git a/tests/spec/arb_clear_texture/CMakeLists.gl.txt b/tests/spec/arb_clear_texture/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..c77fd79
> --- /dev/null
> +++ b/tests/spec/arb_clear_texture/CMakeLists.gl.txt
> @@ -0,0 +1,13 @@
> +include_directories(
> + ${GLEXT_INCLUDE_DIR}
> + ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> + piglitutil_${piglit_target_api}
> + ${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_clear_texture-simple simple.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/arb_clear_texture/CMakeLists.txt b/tests/spec/arb_clear_texture/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_clear_texture/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_clear_texture/simple.c b/tests/spec/arb_clear_texture/simple.c
> new file mode 100644
> index 0000000..7e42a34
> --- /dev/null
> +++ b/tests/spec/arb_clear_texture/simple.c
> @@ -0,0 +1,139 @@
> +/*
> + * Copyright 2014 Ilia Mirkin
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +/** @file simple.c
> + *
> + * A very simple test of basic ClearTexImage and ClearTexSubImage
> + * functionality. Clears 2 textures, and puts them up side-by-side for
> + * display.
> + *
> + * The output should look like
> + *
> + * +-----+--+--+
> + * | | | |
> + * | | | |
> + * +-----+--+--+
> + *
> + * With the boxes from left to right being green, blue, and yellow.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 13;
> +
> + config.window_width = 128;
> + config.window_height = 64;
> + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static GLuint texture[2];
> +static const float green[3] = {0.0, 1.0, 0.0};
> +static const float red[3] = {1.0, 0.0, 0.0};
> +static const float blue[3] = {0.0, 0.0, 1.0};
> +static const float yellow[3] = {1.0, 1.0, 0.0};
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + int i;
> + float *color = malloc(sizeof(float) * 64 * 64 * 3);
> +
> + piglit_require_extension("GL_ARB_clear_texture");
> + piglit_require_extension("GL_EXT_framebuffer_object");
> +
> + /* Create color data for texture */
> + for (i = 0; i < 64 * 64; i++) {
> + memcpy(&color[i*3], &red[0], sizeof(red));
> + }
> +
> + glGenTextures(2, texture);
> +
> + /* Initialize textures to all red. */
> + glBindTexture(GL_TEXTURE_2D, texture[0]);
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64,
> + 0, GL_RGB, GL_FLOAT, color);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +
> + glBindTexture(GL_TEXTURE_2D, texture[1]);
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64,
> + 0, GL_RGB, GL_FLOAT, color);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +
> + free(color);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + bool pass = true;
> +
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + piglit_report_result(PIGLIT_FAIL);
> +
> + /* Clear the whole first texture with green */
> + glClearTexImage(texture[0], 0, GL_RGB, GL_FLOAT, green);
> + pass &= piglit_check_gl_error(GL_NO_ERROR);
> +
> + /* Clear the left half of the second texture with blue */
> + glClearTexSubImage(texture[1], 0,
> + 0, 0, 0,
> + 32, 64, 1,
> + GL_RGB, GL_FLOAT, blue);
> + pass &= piglit_check_gl_error(GL_NO_ERROR);
> + /* And the right half with yellow */
> + glClearTexSubImage(texture[1], 0,
> + 32, 0, 0,
> + 32, 64, 1,
> + GL_RGB, GL_FLOAT, yellow);
> + pass &= piglit_check_gl_error(GL_NO_ERROR);
> +
> + /* Render both textures to the screen */
> + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
> + glEnable(GL_TEXTURE_2D);
> + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
> +
> + glBindTexture(GL_TEXTURE_2D, texture[0]);
> + piglit_draw_rect_tex(0, 0, 64, 64, 0, 0, 1, 1);
> +
> + glBindTexture(GL_TEXTURE_2D, texture[1]);
> + piglit_draw_rect_tex(64, 0, 64, 64, 0, 0, 1, 1);
> +
> + glDisable(GL_TEXTURE_2D);
> + glDeleteTextures(2, texture);
> +
> + /* Check for the 3 separate regions */
> + pass &= piglit_probe_rect_rgb(0, 0, 64, 64, green);
> + pass &= piglit_probe_rect_rgb(64, 0, 32, 64, blue);
> + pass &= piglit_probe_rect_rgb(96, 0, 32, 64, yellow);
> +
> + piglit_present_results();
> +
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> --
> 1.8.3.2
>
More information about the Piglit
mailing list