[Piglit] [PATCH 07/15] arb_direct_state_access: Testing glClearNamedBufferData.

Laura Ekstrand laura at jlekstrand.net
Fri Jan 23 11:03:31 PST 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../clearnamedbufferdata-invalid-internal-format.c | 165 +++++++++++++++++++++
 3 files changed, 167 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c

diff --git a/tests/all.py b/tests/all.py
index 69a7cd7..7fbadea 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4424,6 +4424,7 @@ spec['ARB_direct_state_access']['texture-buffer'] = PiglitGLTest(['arb_direct_st
 spec['ARB_direct_state_access']['texture-buffer-range'] = PiglitGLTest(['arb_direct_state_access-texture-buffer-range'], run_concurrent=True)
 spec['ARB_direct_state_access']['namedbufferstorage-persistent'] = PiglitGLTest(['arb_direct_state_access-namedbufferstorage-persistent'], run_concurrent=True)
 spec['ARB_direct_state_access']['namedbuffersubdata-vbo-sync'] = PiglitGLTest(['arb_direct_state_access-namedbuffersubdata-vbo-sync'], run_concurrent=True)
+spec['ARB_direct_state_access']['clearnamedbufferdata-invalid-internal-format'] = PiglitGLTest(['arb_direct_state_access-clearnamedbufferdata-invalid-internal-format'], 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 eedd60d..6bdedbe 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -11,6 +11,7 @@ link_libraries (
 
 piglit_add_executable (arb_direct_state_access-namedbufferstorage-persistent namedbufferstorage.c)
 piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync namedbuffersubdata-vbo-sync.c)
+piglit_add_executable (arb_direct_state_access-clearnamedbufferdata-invalid-internal-format clearnamedbufferdata-invalid-internal-format.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/clearnamedbufferdata-invalid-internal-format.c b/tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c
new file mode 100644
index 0000000..535c48b
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/clearnamedbufferdata-invalid-internal-format.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright © 2014, 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.
+ */
+
+/**
+ * \file clearnamedbufferdata-invalid-internal-format.c
+ *
+ * From the GL_ARB_clear_buffer_object spec:
+ * "<internalformat> must be set to one of the format tokens listed in
+ *  Table 3.15, "Internal formats for buffer textures"."
+ *
+ * This table only includes a subset of available internal formats. In
+ * particular, the table does not include:
+ * -- unsized formats (e.g.: GL_RGBA)
+ * -- depth or stencil formats
+ * -- compressed formats
+ * -- formats with a component with a bitwidth that is not a multiple of 8
+ *    (e.g.: GL_RGB5_A1).
+ * -- formats with a total bitwidth that is not a multiple of 32
+ *    (e.g.: GL_RGB8).
+ *
+ * Test that the required GL_INVALID_ENUM error is generated for these formats.
+ *
+ * Adapted to test glClearNamedBufferData by Laura Ekstrand
+ * <laura at jlekstrand.net>, January 2015.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 15;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const struct {
+	GLenum internal_format;
+	GLenum format;
+	GLenum type;
+} formats[] = {
+	/* legacy OpenGL 1.0 "formats" */
+	{1, GL_ALPHA, GL_UNSIGNED_BYTE},
+	{2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
+	{3, GL_RGB, GL_UNSIGNED_BYTE},
+	{4, GL_RGBA, GL_UNSIGNED_BYTE},
+
+	/* unsized formats */
+	{GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
+	{GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE},
+	{GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
+	{GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
+	{GL_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE},
+	{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
+	{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
+
+	/* depth formats */
+	{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
+	{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
+	{GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
+
+	/* component not multiple of 8 bit wide */
+	{GL_ALPHA4, GL_ALPHA, GL_UNSIGNED_BYTE},
+	{GL_ALPHA12, GL_ALPHA, GL_UNSIGNED_SHORT},
+	{GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE},
+	{GL_LUMINANCE12, GL_LUMINANCE, GL_UNSIGNED_SHORT},
+	{GL_LUMINANCE12_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT},
+	{GL_LUMINANCE12_ALPHA12, GL_LUMINANCE_ALPHA, GL_UNSIGNED_INT},
+	{GL_INTENSITY4, GL_INTENSITY, GL_UNSIGNED_BYTE},
+	{GL_INTENSITY12, GL_INTENSITY, GL_UNSIGNED_SHORT},
+	{GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2},
+	{GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4},
+	{GL_RGB5, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1},
+	{GL_RGB10, GL_RGB, GL_UNSIGNED_INT_10_10_10_2},
+	{GL_RGB12, GL_RGB, GL_UNSIGNED_SHORT},
+	{GL_RGBA2, GL_RGBA, GL_UNSIGNED_BYTE},
+	{GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
+	{GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
+	{GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_10_10_10_2},
+	{GL_RGBA12, GL_RGBA, GL_UNSIGNED_SHORT},
+
+	/* format not multiple of 32 bit wide */
+	{GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE},
+
+	/* compressed formats */
+	{GL_COMPRESSED_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
+	{GL_COMPRESSED_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
+	{GL_COMPRESSED_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
+	{GL_COMPRESSED_INTENSITY, GL_INTENSITY, GL_UNSIGNED_BYTE},
+	{GL_COMPRESSED_RGB, GL_RGB, GL_UNSIGNED_BYTE},
+	{GL_COMPRESSED_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
+};
+
+static GLuint buffer;
+
+static bool
+test_format(const int i)
+{
+	printf("Testing %s...\t",
+			piglit_get_gl_enum_name(formats[i].internal_format));
+
+	glClearNamedBufferData(buffer, formats[i].internal_format,
+			       formats[i].format, formats[i].type, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
+		printf("Failed!\n");
+		return false;
+	}
+	printf("Passed.\n");
+	return true;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	int i;
+	const int buffer_size = 3<<20;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+	piglit_require_extension("GL_ARB_direct_state_access");
+
+	glCreateBuffers(1, &buffer);
+	glNamedBufferData(buffer, buffer_size, NULL, GL_STREAM_READ);
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	/* Notice that I never bind the buffer. */
+	for (i = 0; i < ARRAY_SIZE(formats); ++i)
+		test_format(i);
+
+	glDeleteBuffers(1, &buffer);
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_PASS;
+}
+
-- 
2.1.0



More information about the Piglit mailing list