[Piglit] [PATCH 13/15] arb_direct_state_access: Testing glGetNamedBufferParameteri[64]v.

Martin Peres martin.peres at linux.intel.com
Thu Apr 2 00:24:57 PDT 2015



On 23/01/15 21:03, Laura Ekstrand wrote:
> ---
>   tests/all.py                                       |   1 +
>   .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>   .../getnamedbufferparameter.c                      | 215 +++++++++++++++++++++
>   3 files changed, 217 insertions(+)
>   create mode 100644 tests/spec/arb_direct_state_access/getnamedbufferparameter.c
>
> diff --git a/tests/all.py b/tests/all.py
> index c146bff..3d41046 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4429,6 +4429,7 @@ spec['ARB_direct_state_access']['clearnamedbuffersubdata-invalid-size'] = Piglit
>   spec['ARB_direct_state_access']['mapnamedbuffer-pbo-readpixels'] = PiglitGLTest(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], run_concurrent=True)
>   spec['ARB_direct_state_access']['unmapnamedbuffer-vbo'] = PiglitGLTest(['arb_direct_state_access-unmapnamedbuffer-vbo'], run_concurrent=True)
>   spec['ARB_direct_state_access']['flushmappednamedbufferrange'] = PiglitGLTest(['arb_direct_state_access-flushmappednamedbufferrange'], run_concurrent=True)
> +spec['ARB_direct_state_access']['getnamedbufferparameter'] = PiglitGLTest(['arb_direct_state_access-getnamedbufferparameter'], run_concurrent=True)
>   
>   profile.tests['hiz'] = hiz
>   profile.tests['fast_color_clear'] = fast_color_clear
> diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> index 3523e5d..cd14397 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -16,6 +16,7 @@ piglit_add_executable (arb_direct_state_access-clearnamedbuffersubdata-invalid-s
>   piglit_add_executable (arb_direct_state_access-mapnamedbuffer-pbo-readpixels mapnamedbuffer-pbo-readpixels.c)
>   piglit_add_executable (arb_direct_state_access-unmapnamedbuffer-vbo unmapnamedbuffer-vbo.c)
>   piglit_add_executable (arb_direct_state_access-flushmappednamedbufferrange flushmappednamedbufferrange.c)
> +piglit_add_executable (arb_direct_state_access-getnamedbufferparameter getnamedbufferparameter.c)
>   piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
>   piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
>   piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
> diff --git a/tests/spec/arb_direct_state_access/getnamedbufferparameter.c b/tests/spec/arb_direct_state_access/getnamedbufferparameter.c
> new file mode 100644
> index 0000000..82bbfe2
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/getnamedbufferparameter.c
> @@ -0,0 +1,215 @@
> +/**
> + * Copyright © 2013, 2015 Intel Corporation
> + *
> + * 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.
> + */
> +
> +/**
> + * Adapted to test glGetNamedBufferParameteri[64]v by Laura Ekstrand
> + * <laura at jlekstrand.net>.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 10;
Here too :)
> +
> +	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	piglit_require_extension("GL_ARB_direct_state_access");
> +	piglit_require_extension("GL_ARB_map_buffer_range");
Again, the above extension would not be needed with gl_core_compat = 32;
> +}
> +
> +static bool
> +storage_test(void)
> +{
> +	GLuint buffer;
> +	bool pass = true;
> +	GLint64 data = -2;
> +
> +	glCreateBuffers(1, &buffer);
> +
> +	/* Is it mutable? */
> +	glGetNamedBufferParameteri64v(buffer, GL_BUFFER_IMMUTABLE_STORAGE,
> +				      &data);
> +	if (data == GL_TRUE) {
> +		printf("GL_BUFFER_IMMUTABLE_STORAGE: expected mutable, "
> +		       "got immutable.\n");
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	glNamedBufferStorage(buffer, 12 * 4 * sizeof(float), NULL,
> +			     GL_MAP_READ_BIT |
> +			     GL_MAP_PERSISTENT_BIT |
> +			     GL_MAP_COHERENT_BIT);
> +
> +	/* Is it immutable? */
> +	glGetNamedBufferParameteri64v(buffer, GL_BUFFER_IMMUTABLE_STORAGE,
> +				      &data);
> +	if (data == GL_FALSE) {
> +		printf("GL_BUFFER_IMMUTABLE_STORAGE: expected immutable, "
> +		       "got mutable.\n");
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* What are the storage flags? */
> +	glGetNamedBufferParameteri64v(buffer, GL_BUFFER_STORAGE_FLAGS,
> +				      &data);
> +	if (!(data & GL_MAP_READ_BIT)) {
> +		printf("GL_BUFFER_STORAGE_FLAGS: No map read bit.\n");
> +		pass = false;
> +	}
> +	if (!(data & GL_MAP_PERSISTENT_BIT)) {
> +		printf("GL_BUFFER_STORAGE_FLAGS: No map persistent bit.\n");
> +		pass = false;
> +	}
> +	if (!(data & GL_MAP_COHERENT_BIT)) {
> +		printf("GL_BUFFER_STORAGE_FLAGS: No map coherent bit.\n");
> +		pass = false;
> +	}
> +
> +	if (data & ~(GL_MAP_READ_BIT |
> +		     GL_MAP_PERSISTENT_BIT |
> +		     GL_MAP_COHERENT_BIT)) {
> +		printf("GL_BUFFER_STORAGE_FLAGS: Extra bits set.\n");
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	return pass;
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	bool pass = true;
> +	GLuint bufname;
> +	GLint64 data = -2;
> +	GLint dataint = -2;
> +
> +	int stuff[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
> +	int size = sizeof(stuff);
> +	int offset = 1;
> +	int range = 5;
> +
> +	glCreateBuffers(1, &bufname);

Maybe test all the default values here?

> +	glNamedBufferData(bufname, size, stuff, GL_STATIC_READ);
> +
> +	/* What size is it? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_SIZE, &data);
> +	if (data != size) {
> +		printf("GL_BUFFER_SIZE: expected %d, got %d.\n",
> +		       size, (int) data);
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* What is the usage? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_USAGE, &data);
> +	if (data != GL_STATIC_READ) {
> +		printf("GL_BUFFER_USAGE: expected GL_STATIC_READ, got %s.\n",
> +		       piglit_get_gl_enum_name((int) data));
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +
> +	glMapNamedBufferRange(bufname, offset, range,
> +			      GL_MAP_READ_BIT);
> +
> +	/* What is the access? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_ACCESS, &data);
> +	if (data != GL_READ_ONLY) {
> +		printf("GL_BUFFER_ACCESS: expected GL_READ_ONLY, got %s.\n",
> +		       piglit_get_gl_enum_name((int) data));
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* What are the access flags? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_ACCESS_FLAGS, &data);
> +	if (!(data & GL_MAP_READ_BIT)) { /* Map read bit not set */
> +		printf("GL_BUFFER_ACCESS_FLAGS: expected GL_MAP_READ_BIT, "
> +		       "but it was not set.\n");
> +		pass = false;
> +	}
> +	if (data & ~GL_MAP_READ_BIT) {  /* Other bits set */
> +		printf("GL_BUFFER_ACCESS: expected only GL_MAP_READ_BIT, "
> +		       "but other flags were set.\n");
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* Is it mapped? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAPPED, &data);
> +	if (data != GL_TRUE)
> +	{
> +		printf("GL_BUFFER_MAPPED: expected GL_TRUE, got GL_FALSE.\n");
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +
> +	/* What is the offset? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAP_OFFSET,
> +				      &data);
> +	if (data != offset) {
> +		printf("GL_BUFFER_MAP_OFFSET: expected %d, got %d.\n",
> +			offset, (int) data);
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* What is the length? */
> +	glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAP_LENGTH,
> +				      &data);
> +	if (data != range) {
> +		printf("GL_BUFFER_MAP_LENGTH: expected %d, got %d.\n",
> +			range, (int) data);
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	glUnmapNamedBuffer(bufname);
> +
> +	if (piglit_is_extension_supported("GL_ARB_buffer_storage"))
> +		pass = storage_test() && pass;
> +
> +
> +	/* Make sure 32-bit version works. */
> +	glGetNamedBufferParameteriv(bufname, GL_BUFFER_SIZE, &dataint);
> +	if (dataint != size) {
> +		printf("GL_BUFFER_SIZE: expected %d, got %d.\n",
> +		       size, (int) dataint);
> +		pass = false;
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

Maybe make a macro that would test both the 32 bit and the 64 bit 
versions at the same time?
> +
> +
> +	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}



More information about the Piglit mailing list