[Piglit] [PATCH 2/2] ext_memory_object: add some basic api error checks

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Aug 4 08:56:05 UTC 2017


1/2 got lost?

On 08/04/2017 03:43 AM, Timothy Arceri wrote:
> This only tests for errors when <memory> is 0, but its a start.
> ---
>   tests/all.py                                   |   6 +
>   tests/spec/CMakeLists.txt                      |   1 +
>   tests/spec/ext_memory_object/CMakeLists.gl.txt |  14 ++
>   tests/spec/ext_memory_object/CMakeLists.txt    |   1 +
>   tests/spec/ext_memory_object/api-errors.c      | 241 +++++++++++++++++++++++++
>   5 files changed, 263 insertions(+)
>   create mode 100644 tests/spec/ext_memory_object/CMakeLists.gl.txt
>   create mode 100644 tests/spec/ext_memory_object/CMakeLists.txt
>   create mode 100644 tests/spec/ext_memory_object/api-errors.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index 177957b0b..521a0fc50 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -2361,20 +2361,26 @@ with profile.test_list.group_manager(
>       g(['khr_debug-push-pop-group_gles2'], 'push-pop-group_gles2')
>       g(['khr_debug-push-pop-group_gles3'], 'push-pop-group_gles3')
>   
>   # Group ARB_occlusion_query2
>   with profile.test_list.group_manager(
>           PiglitGLTest,
>           grouptools.join('spec', 'ARB_occlusion_query2')) as g:
>       g(['arb_occlusion_query2-api'], 'api')
>       g(['arb_occlusion_query2-render'], 'render')
>   
> +# Group EXT_memory_object tests
> +with profile.test_list.group_manager(
> +        PiglitGLTest,
> +        grouptools.join('spec', 'EXT_memory_object')) as g:
> +    g(['ext_memory_object-api-errors'], 'api-errors')
> +
>   # Group EXT_texture_format_BGRA8888 tests
>   with profile.test_list.group_manager(
>           PiglitGLTest,
>           grouptools.join('spec', 'EXT_texture_format_BGRA8888')) as g:
>       g(['ext_texture_format_bgra8888-api-errors'], 'api-errors')
>   
>   with profile.test_list.group_manager(
>           PiglitGLTest,
>           grouptools.join('spec', 'ARB_pixel_buffer_object')) as g:
>       g(['cubemap', 'pbo'])
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index fea256163..28d2bb26e 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -78,20 +78,21 @@ add_subdirectory (arb_timer_query)
>   add_subdirectory (arb_transform_feedback2)
>   add_subdirectory (arb_transform_feedback3)
>   add_subdirectory (arb_transform_feedback_overflow_query)
>   add_subdirectory (arb_viewport_array)
>   add_subdirectory (ati_envmap_bumpmap)
>   add_subdirectory (ext_depth_bounds_test)
>   add_subdirectory (ext_frag_depth)
>   add_subdirectory (ext_fog_coord)
>   add_subdirectory (ext_framebuffer_multisample)
>   add_subdirectory (ext_framebuffer_multisample_blit_scaled)
> +add_subdirectory (ext_memory_object)
>   add_subdirectory (ext_packed_depth_stencil)
>   add_subdirectory (ext_packed_float)
>   add_subdirectory (ext_shader_samples_identical)
>   add_subdirectory (ext_texture_swizzle)
>   add_subdirectory (ext_timer_query)
>   add_subdirectory (ext_transform_feedback)
>   add_subdirectory (nv_conditional_render)
>   add_subdirectory (nv_fill_rectangle)
>   add_subdirectory (nv_image_formats)
>   add_subdirectory (nv_texture_barrier)
> diff --git a/tests/spec/ext_memory_object/CMakeLists.gl.txt b/tests/spec/ext_memory_object/CMakeLists.gl.txt
> new file mode 100644
> index 000000000..3a714e6af
> --- /dev/null
> +++ b/tests/spec/ext_memory_object/CMakeLists.gl.txt
> @@ -0,0 +1,14 @@
> +include_directories(
> +	${GLEXT_INCLUDE_DIR}
> +	${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> +	piglitutil_${piglit_target_api}
> +	${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable (ext_memory_object-api-errors api-errors.c)
> +
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/ext_memory_object/CMakeLists.txt b/tests/spec/ext_memory_object/CMakeLists.txt
> new file mode 100644
> index 000000000..144a306f4
> --- /dev/null
> +++ b/tests/spec/ext_memory_object/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/ext_memory_object/api-errors.c b/tests/spec/ext_memory_object/api-errors.c
> new file mode 100644
> index 000000000..58694b9fa
> --- /dev/null
> +++ b/tests/spec/ext_memory_object/api-errors.c
> @@ -0,0 +1,241 @@
> +/*
> + * Copyright (c) 2017 Timothy Arceri
> + *
> + * 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
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, 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
> + * NON-INFRINGEMENT.  IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
> + * 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.
> + */
> +
> +/**
> + * Tests that api errors are thrown where expected for the
> + * GL_EXT_memory_object extension.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 20; /* Need 2.0 for DSA tests */
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +	config.khr_no_error_support = PIGLIT_HAS_ERRORS;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +static bool
> +test_tex_storage_errors(GLenum target, bool dsa)
> +{
> +	const GLint width = 64, height = 4, depth = 8;
> +	GLuint tex;
> +
> +	assert(target == GL_TEXTURE_1D ||
> +	       target == GL_TEXTURE_2D ||
> +	       target == GL_TEXTURE_3D);
> +
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +
> +	/* Test that passing 0 for <memory> results in an error. */
> +	if (target == GL_TEXTURE_1D) {
> +		if (dsa) {
> +			glTextureStorageMem1DEXT(tex, 1, GL_RGBA8, width, 0,
> +						 0);
> +		} else {
> +			glTexStorageMem1DEXT(target, 1, GL_RGBA8, width, 0,
> +					     0);
> +		}
> +	}
> +	else if (target == GL_TEXTURE_2D) {
> +		if (dsa) {
> +			glTextureStorageMem2DEXT(tex, 1, GL_RGBA8, width,
> +						 height, 0, 0);
> +		} else {
> +			glTexStorageMem2DEXT(target, 1, GL_RGBA8, width,
> +					     height, 0, 0);
> +		}
> +	}
> +	else if (target == GL_TEXTURE_3D) {
> +		if (dsa) {
> +			glTextureStorageMem3DEXT(tex, 1, GL_RGBA8, width,
> +						 height, depth, 0, 0);
> +		} else {
> +			glTexStorageMem3DEXT(target, 1, GL_RGBA8, width,
> +					     height, depth, 0, 0);
> +		}
> +	}
> +
> +	/* From the EXT_external_objects spec:
> +	 *
> +	 *    "An INVALID_VALUE error is generated if <memory> is 0, or if
> +	 *    the memory object is not large enough to contain the specified
> +	 *    texture's image data."
> +	 */
> +	if (glGetError() != GL_INVALID_VALUE) {
> +		printf("Fail: GL_INVALID_VALUE expected\n");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +static bool
> +test_tex_storage_ms_errors(GLenum target, bool dsa)
> +{
> +	const GLint width = 64, height = 4, depth = 8;
> +	GLuint tex;
> +
> +	assert(target == GL_TEXTURE_2D_MULTISAMPLE ||
> +	       target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
> +
> +	glGenTextures(1, &tex);
> +	glBindTexture(target, tex);
> +
> +	/* Test that passing 0 for <memory> results in an error. */
> +	if (target == GL_TEXTURE_2D_MULTISAMPLE) {
> +		if (dsa) {
> +			glTextureStorageMem2DMultisampleEXT(tex, 1, GL_RGBA8,
> +							    width, height,
> +							    GL_FALSE, 0, 0);
> +		} else {
> +			glTexStorageMem2DMultisampleEXT(target, 1, GL_RGBA8,
> +							width, height,
> +							GL_FALSE, 0, 0);
> +		}
> +	}
> +	else if (target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
> +		if (dsa) {
> +			glTextureStorageMem3DMultisampleEXT(tex, 1, GL_RGBA8,
> +							    width, height,
> +							    depth, GL_FALSE,
> +							    0, 0);
> +		} else {
> +			glTexStorageMem3DMultisampleEXT(target, 1, GL_RGBA8,
> +							width, height,
> +							depth, GL_FALSE,
> +							0, 0);
> +		}
> +	}
> +
> +	/* From the EXT_external_objects spec:
> +	 *
> +	 *    "An INVALID_VALUE error is generated if <memory> is 0, or if
> +	 *    the memory object is not large enough to contain the specified
> +	 *    texture's image data."
> +	 */
> +	if (glGetError() != GL_INVALID_VALUE) {
> +		printf("Fail: GL_INVALID_VALUE expected\n");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +#define BUF_SIZE (12 * 4 * sizeof(float))
> +
> +static bool
> +test_buffer_storage_errors(bool dsa)
> +{
> +	GLuint buffer;
> +
> +	glGenBuffers(1, &buffer);
> +	glBindBuffer(GL_ARRAY_BUFFER, buffer);
> +
> +	/* Test that passing 0 for <memory> results in an error. */
> +	if (dsa) {
> +		glNamedBufferStorageMemEXT(buffer, BUF_SIZE, 0, 0);
> +	} else {
> +		glBufferStorageMemEXT(GL_ARRAY_BUFFER, BUF_SIZE, 0, 0);
> +	}
> +
> +	/* From the EXT_external_objects spec:
> +	 *
> +	 *    "An INVALID_VALUE error is generated if <memory> is 0, or if
> +	 *    the memory object is not large enough to contain the specified
> +	 *    texture's image data."
> +	 */
> +	if (glGetError() != GL_INVALID_VALUE) {
> +		printf("Fail: GL_INVALID_VALUE expected\n");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +#define X(f, desc)					     	\
> +	do {							\
> +		const bool subtest_pass = (f);			\
> +		piglit_report_subtest_result(subtest_pass	\
> +					     ? PIGLIT_PASS : PIGLIT_FAIL, \
> +					     (desc));		\
> +		pass = pass && subtest_pass;			\
> +	} while (0)
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	/* TODO: currently this test only tests for errors when we pass 0 for
> +	 * <memory>. We need to test for other errors.
> +	 */
> +
> +	bool pass = true;
> +	bool dsa = piglit_is_extension_supported("GL_ARB_direct_state_access");
> +
> +	X(test_tex_storage_errors(GL_TEXTURE_1D, false), "1D texture");
> +	X(test_tex_storage_errors(GL_TEXTURE_2D, false), "2D texture");
> +	X(test_tex_storage_errors(GL_TEXTURE_3D, false), "3D texture");
> +
> +	if (dsa) {
> +		X(test_tex_storage_errors(GL_TEXTURE_1D, true), "1D texture direct state access");
> +		X(test_tex_storage_errors(GL_TEXTURE_2D, true), "2D texture direct state access");
> +		X(test_tex_storage_errors(GL_TEXTURE_3D, true), "3D texture direct state access");
> +	}
> +
> +	if (piglit_is_extension_supported("GL_ARB_texture_storage_multisample")) {
> +		X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE, false), "2D texture ms");
> +		X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, false), "3D texture ms");
> +
> +		if (dsa) {
> +			X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE, true), "2D texture ms direct state access");
> +			X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, true), "3D texture ms direct state access");
> +		}
> +	}
> +
> +	if (piglit_is_extension_supported("GL_ARB_buffer_storage")) {
> +		X(test_buffer_storage_errors(false), "buffer storage");
> +
> +		if (dsa) {
> +			X(test_buffer_storage_errors(true), "buffer storage direct state access");
> +		}
> +	}
> +
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	/* From the EXT_external_objects spec:
> +	 *
> +	 *   "GL_EXT_memory_object requires ARB_texture_storage or a
> +	 *   version of OpenGL or OpenGL ES that incorporates it."
> +	 */
> +	piglit_require_extension("GL_ARB_texture_storage");
> +	piglit_require_extension("GL_EXT_memory_object");
> +}
> 


More information about the Piglit mailing list