[Piglit] [PATCH V3 1/2] ARB_clear_buffer_object: Add bunch of tests

Pi Tabred servuswiegehtz at yahoo.de
Mon Dec 30 05:25:55 PST 2013


From: abred <abred at home.de>

 - clear-buffer-sub: test if buffer subregions are correctly cleared
 - clear-buffer: test if entire buffer is correctly cleared
 - negative-already-mapped: test if buffer or buffer range is already mapped
 - negative-bad-format-type: test <format> - <type> combination
 - negative-bad-internalformat-format: test <internalformat> - <format>
                                       combination
 - negative-bad-internalformat: test if <internalformat> parameter is valid
 - negative-bad-offset-size: test if <offset> and <size> parameters are valid
 - negative-bad-target: test if <target> parameter is valid
 - negative-no-target: test if buffer is bound to <target>

 - common.h: common data/functions for tests
---
 .../arb_clear_buffer_object/clear-buffer-sub.c     | 134 ++++++++++
 tests/spec/arb_clear_buffer_object/clear-buffer.c  |  71 ++++++
 tests/spec/arb_clear_buffer_object/common.h        |  58 +++++
 .../negative-already-mapped.c                      |  86 +++++++
 .../negative-bad-format-type.c                     | 152 ++++++++++++
 .../negative-bad-internalformat-format.c           |  77 ++++++
 .../negative-bad-internalformat.c                  | 271 +++++++++++++++++++++
 .../negative-bad-offset-size.c                     | 109 +++++++++
 .../arb_clear_buffer_object/negative-bad-target.c  | 105 ++++++++
 .../arb_clear_buffer_object/negative-no-target.c   |  52 ++++
 10 files changed, 1115 insertions(+)
 create mode 100644 tests/spec/arb_clear_buffer_object/clear-buffer-sub.c
 create mode 100644 tests/spec/arb_clear_buffer_object/clear-buffer.c
 create mode 100644 tests/spec/arb_clear_buffer_object/common.h
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-already-mapped.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-bad-format-type.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-bad-internalformat.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-bad-offset-size.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-bad-target.c
 create mode 100644 tests/spec/arb_clear_buffer_object/negative-no-target.c

diff --git a/tests/spec/arb_clear_buffer_object/clear-buffer-sub.c b/tests/spec/arb_clear_buffer_object/clear-buffer-sub.c
new file mode 100644
index 0000000..7e7f108
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/clear-buffer-sub.c
@@ -0,0 +1,134 @@
+/*
+ * 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
+ *
+ * Clear subregions of a buffer and check if the data was set to the correct
+ * value.
+ * Clear subregions of a buffer while a different range of the buffer is
+ * mapped and check if the data was set to the correct value.
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	int i;
+	GLuint buf;
+	unsigned char* initData;
+	unsigned char* test;
+	GLsizeiptr bufferSize = 100;
+	unsigned char defaultData = 5;
+
+	static const unsigned char data1[] = {13, 37, 23, 42};
+	size_t data1Size = sizeof(data1);
+	static const unsigned char data2[] = {16, 32, 64, 128};
+	size_t data2Size = sizeof(data2);
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+
+	initData = (unsigned char*) malloc(bufferSize);
+	for (i = 0; i < bufferSize; ++i) {
+		initData[i] = defaultData;
+	}
+	glBufferData(GL_ARRAY_BUFFER, bufferSize * sizeof(unsigned char),
+	             initData, GL_STATIC_DRAW);
+	free(initData);
+	initData = NULL;
+
+/* Test non-overlapping clear with glClearbufferSubData */
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 40, 40, GL_RGBA,
+	                     GL_UNSIGNED_BYTE, data1);
+
+	test = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+	compareData(&defaultData, test,  0,  40, 1);
+	compareData(data1,        test, 40,  80, data1Size);
+	compareData(&defaultData, test, 80, 100, 1);
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+/* Test overlapping clear with glClearbufferSubData */
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 12, 20, GL_RGBA,
+	                     GL_UNSIGNED_BYTE, data1);
+
+	test = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+	compareData(&defaultData, test,  0,  12, 1);
+	compareData(data1,        test, 12,  32, data1Size);
+	compareData(&defaultData, test, 32,  40, 1);
+	compareData(data1,        test, 40,  80, data1Size);
+	compareData(&defaultData, test, 80, 100, 1);
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 20, 32, GL_RGBA,
+	                     GL_UNSIGNED_BYTE, data2);
+
+	test = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+	compareData(&defaultData, test,  0,  12, 1);
+	compareData(data1,        test, 12,  20, data1Size);
+	compareData(data2,        test, 20,  52, data2Size);
+	compareData(data1,        test, 52,  80, data1Size);
+	compareData(&defaultData, test, 80, 100, 1);
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+/* Test overlapping clear while a different range of the buffer is mapped */
+	if (piglit_is_extension_supported("GL_ARB_map_buffer_range")) {
+		float* map = (float*) glMapBufferRange(GL_ARRAY_BUFFER,
+		                                        0, 40,
+		                                        GL_MAP_WRITE_BIT |
+		                                        GL_MAP_READ_BIT);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 60, 32,
+		                     GL_RGBA, GL_UNSIGNED_BYTE, data2);
+
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glUnmapBuffer(GL_ARRAY_BUFFER);
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			piglit_report_result(PIGLIT_FAIL);
+
+		test = (unsigned char*) glMapBufferRange(GL_ARRAY_BUFFER,
+		                                           0, 96,
+		                                           GL_MAP_WRITE_BIT |
+		                                           GL_MAP_READ_BIT);
+		compareData(&defaultData, test,  0,  12, 1);
+		compareData(data1,        test, 12,  20, data1Size);
+		compareData(data2,        test, 20,  52, data2Size);
+		compareData(data1,        test, 52,  60, data1Size);
+		compareData(data2,        test, 60,  92, data2Size);
+		compareData(&defaultData, test, 92, 96, 1);
+
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			piglit_report_result(PIGLIT_FAIL);
+		glUnmapBuffer(GL_ARRAY_BUFFER);
+	}
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/clear-buffer.c b/tests/spec/arb_clear_buffer_object/clear-buffer.c
new file mode 100644
index 0000000..699031d
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/clear-buffer.c
@@ -0,0 +1,71 @@
+/*
+ * 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
+ *
+ * Clear entire buffer and check if the data was set to the correct value.
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buf;
+	GLsizeiptr bufferSize = 100;
+	unsigned char* test;
+	static const unsigned char data[] = {13, 37, 23, 42};
+	size_t dataSize = sizeof(data);
+	unsigned char dataNull = 0;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, bufferSize, NULL, GL_STATIC_DRAW);
+
+
+/* Clear to predefined value */
+	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+	                  GL_RGBA, GL_UNSIGNED_BYTE, data);
+
+	test = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+
+	compareData(data, test, 0, bufferSize, dataSize);
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+
+/* Clear to 0 by passing NULL */
+	glClearBufferData(GL_ARRAY_BUFFER, GL_R8, GL_RED, GL_UNSIGNED_BYTE,
+	                  NULL);
+
+	test = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+
+	compareData(&dataNull, test, 0, bufferSize, 1);
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/common.h b/tests/spec/arb_clear_buffer_object/common.h
new file mode 100644
index 0000000..2171e73
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/common.h
@@ -0,0 +1,58 @@
+/*
+ * 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
+ *
+ * Common test framework for GL_ARB_clear_buffer_object
+ *
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 15;
+	config.supports_gl_core_version = 43;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+void
+compareData(unsigned char const* expected, unsigned char const* observed,
+            int begin, int end, int step)
+{
+	int i;
+	int result = 0;
+	for (i = begin; i < end; i += step) {
+		result = memcmp(expected, &observed[i], step);
+		if (result != 0) {
+			piglit_report_result(PIGLIT_FAIL);
+		}
+	}
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-already-mapped.c b/tests/spec/arb_clear_buffer_object/negative-already-mapped.c
new file mode 100644
index 0000000..c9b3e8b
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-already-mapped.c
@@ -0,0 +1,86 @@
+/*
+ * 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
+ *
+ * Test the following error condition:
+ *
+ *    "INVALID_OPERATION is generated by ClearBufferSubData if any part of
+ *     the specified range of the buffer bound to <target> is currently
+ *     mapped."
+ *    (GL_ARB_clear_buffer_object spec)
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buf;
+	float* map;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
+	map = (float*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+
+	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+		          GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glUnmapBuffer(GL_ARRAY_BUFFER);
+
+	if (piglit_is_extension_supported("GL_ARB_map_buffer_range")) {
+		map = (float*) glMapBufferRange(GL_ARRAY_BUFFER,
+		                                100, 200,
+		                                GL_MAP_WRITE_BIT);
+
+		glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+		                  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+		if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+			piglit_report_result(PIGLIT_FAIL);
+
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 60, 100,
+		                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+		if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glUnmapBuffer(GL_ARRAY_BUFFER);
+	}
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-bad-format-type.c b/tests/spec/arb_clear_buffer_object/negative-bad-format-type.c
new file mode 100644
index 0000000..11276be
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-format-type.c
@@ -0,0 +1,152 @@
+/*
+ * 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
+ *
+ * From the GL_ARB_clear_buffer_object spec:
+ *
+ *     "INVALID_ENUM is generated by ClearBufferSubData if <format> or <type>
+ *      is not one of the supported format or type tokens"
+ *
+ * INVALID_ENUM is generated if <format> is an integer format and type is a
+ * float type
+ */
+
+#include "common.h"
+
+static void
+checkFormat(GLenum const format[], int n, GLenum error)
+{
+	int i;
+	for (i = 0; i < n; ++i) {
+		glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+		                  format[i], GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100,
+		                     200, format[i], GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
+static void
+checkFormatInt(GLenum const format[], int n, GLenum error)
+{
+	int i;
+	for (i = 0; i < n; ++i) {
+		glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8UI,
+		                  format[i], GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8UI, 100,
+		                     200, format[i], GL_UNSIGNED_INT, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
+static void
+checkType(GLenum const type[], int n, GLenum error)
+{
+	int i;
+	for (i = 0; i < n; ++i) {
+		glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+		                  GL_RGBA, type[i], NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100,
+		                     200, GL_RGBA, type[i], NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buf;
+	GLenum expectedError;
+	static const GLenum validFormats[] = {
+		GL_RGBA, GL_RED
+	};
+	static const GLenum validFormatsInt[] = {
+		GL_RGBA_INTEGER, GL_RED_INTEGER
+	};
+	static const GLenum invalidFormats[] = {
+		GL_R8, GL_DEPTH_STENCIL, GL_DEPTH_COMPONENT,
+		GL_STENCIL_INDEX, GL_COMPRESSED_RGBA, GL_SRGB
+	};
+
+	static const GLenum validTypes[] = {
+		GL_UNSIGNED_BYTE, GL_INT, GL_SHORT, GL_FLOAT
+	};
+	static const GLenum invalidTypes[] = {
+		GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_RGB, GL_RGB8,
+		GL_DEPTH_COMPONENT
+	};
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
+
+
+/* Test if format is valid */
+	checkFormat(validFormats, ARRAY_SIZE(validFormats),
+	            GL_NO_ERROR);
+	checkFormat(invalidFormats, ARRAY_SIZE(invalidFormats),
+	            GL_INVALID_ENUM);
+
+	expectedError = piglit_is_extension_supported("GL_EXT_texture_integer")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormatInt(validFormatsInt, ARRAY_SIZE(validFormatsInt),
+	            expectedError);
+
+
+/* Test if type is valid */
+	checkType(validTypes, ARRAY_SIZE(validTypes), GL_NO_ERROR);
+	checkType(invalidTypes, ARRAY_SIZE(invalidTypes), GL_INVALID_ENUM);
+
+
+/* Test if format/type combination is valid */
+	if (piglit_is_extension_supported("GL_EXT_texture_integer") &&
+	    piglit_is_extension_supported("GL_ARB_texture_float")) {
+		glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA32UI,
+		                  GL_RGBA_INTEGER, GL_FLOAT, NULL);
+
+		if (!piglit_check_gl_error(GL_INVALID_ENUM))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA32UI, 100, 200,
+		                     GL_RGBA_INTEGER, GL_FLOAT, NULL);
+
+		if (!piglit_check_gl_error(GL_INVALID_ENUM))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c
new file mode 100644
index 0000000..2c85a68
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c
@@ -0,0 +1,77 @@
+/*
+ * 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
+ *
+ * From the GL_EXT_texture_integer spec:
+ *
+ *     "INVALID_OPERATION is generated by TexImage* and SubTexImage* if
+ *      the texture internalformat is an integer format as described in
+ *      table 3.16 and <format> is not one of the integer component
+ *      formats described in table 3.6, or if the internalformat is not an
+ *      integer format and <format> is an integer format."
+ *
+ * This should be conferrable to ClearBufferData and ClearBufferSubData.
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buf;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
+
+	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA32F,
+	                  GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA32F, 100, 200,
+	                     GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA32UI,
+	                  GL_RGBA, GL_UNSIGNED_INT, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA32UI, 100, 200,
+	                     GL_RGBA, GL_UNSIGNED_INT, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-bad-internalformat.c b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat.c
new file mode 100644
index 0000000..1747f1f
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat.c
@@ -0,0 +1,271 @@
+/*
+ * 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
+ *
+ * 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""
+ *
+ * The formats listed in Table 3.15 of the OpenGL Core Spec 4.2 are:
+ *
+ * GL_R8, GL_R16, GL_R16F, GL_R32F, GL_R8I, GL_R16I, GL_R32I,
+ * GL_R8UI, GL_R16UI, GL_R32UI,
+ * GL_RG8, GL_RG16, GL_RG16F, GL_RG32F, GL_RG8I, GL_RG16I, GL_RG32I,
+ * GL_RG8UI, GL_RG16UI, GL_RG32UI,
+ * GL_RGB32F, GL_RGB32I, GL_RGB32UI,
+ * GL_RGBA8, GL_RGBA16, GL_RGBA16F, GL_RGBA32F,
+ * GL_RGBA8I, GL_RGBA16I, GL_RGBA32I, GL_RGBA8UI, GL_RGBA16UI, GL_RGBA32UI
+ *
+ *
+ * The Compatibility Spec adds:
+ * GL_ALPHA8, GL_ALPHA16,
+ * GL_ALPHA16F_ARB, GL_ALPHA32F_ARB,
+ * GL_ALPHA8I_EXT, GL_ALPHA16I_EXT, GL_ALPHA32I_EXT,
+ * GL_ALPHA8UI_EXT, GL_ALPHA16UI_EXT, GL_ALPHA32UI_EXT,
+ * GL_LUMINANCE8, GL_LUMINANCE16,
+ * GL_LUMINANCE16F_ARB, GL_LUMINANCE32F_ARB,
+ * GL_LUMINANCE8I_EXT, GL_LUMINANCE16I_EXT, GL_LUMINANCE32I_EXT,
+ * GL_LUMINANCE8UI_EXT, GL_LUMINANCE16UI_EXT, GL_LUMINANCE32UI_EXT,
+ * GL_LUMINANCE8_ALPHA8, GL_LUMINANCE16_ALPHA16,
+ * GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE_ALPHA32F_ARB,
+ * GL_LUMINANCE_ALPHA8I_EXT, GL_LUMINANCE_ALPHA16I_EXT,
+   GL_LUMINANCE_ALPHA32I_EXT,
+ * GL_LUMINANCE_ALPHA8UI_EXT, GL_LUMINANCE_ALPHA16UI_EXT,
+   GL_LUMINANCE_ALPHA32UI_EXT,
+ * GL_INTENSITY8, GL_INTENSITY16,
+ * GL_INTENSITY16F_ARB, GL_INTENSITY32F_ARB,
+ * GL_INTENSITY8I_EXT, GL_INTENSITY16I_EXT, GL_INTENSITY32I_EXT,
+ * GL_INTENSITY8UI_EXT, GL_INTENSITY16UI_EXT, GL_INTENSITY32UI_EXT
+ */
+
+
+
+#include "common.h"
+
+
+static void
+checkFormat(GLenum const internalformat[], int n, GLenum error)
+{
+	int i;
+	for (i = 0; i < n; ++i) {
+		glClearBufferData(GL_ARRAY_BUFFER, internalformat[i],
+		                  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, internalformat[i], 192,
+		                     384, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
+static void
+checkFormatInt(GLenum const internalformat[], int n, GLenum error)
+{
+	int i;
+	for (i = 0; i < n; ++i) {
+		glClearBufferData(GL_ARRAY_BUFFER, internalformat[i],
+		                  GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(GL_ARRAY_BUFFER, internalformat[i], 192,
+		                     384, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE,
+		                     NULL);
+		if (!piglit_check_gl_error(error))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	static const GLenum validFormats[] = {
+		GL_RGBA8, GL_RGBA16
+	};
+
+	static const GLenum validFormatsFloat[] = {
+		GL_RGBA32F
+	};
+
+	static const GLenum validFormatsHalfFloat[] = {
+		GL_RGBA16F
+	};
+
+	static const GLenum validFormatsRG[] = {
+		GL_R8, GL_R16, GL_RG8, GL_RG16
+	};
+
+	static const GLenum validFormatsRGHalfFloat[] = {
+		GL_R16F, GL_RG16F
+	};
+
+	static const GLenum validFormatsRGFloat[] = {
+		GL_R32F, GL_RG32F
+	};
+
+	static const GLenum validFormatsTexInt[] = {
+		GL_RGBA8I, GL_RGBA16I, GL_RGBA32I,
+		GL_RGBA8UI, GL_RGBA16UI, GL_RGBA32UI
+	};
+
+	static const GLenum validFormatsRGTexInt[] = {
+		GL_R8I, GL_R16I, GL_R32I, GL_RG8I, GL_RG16I, GL_RG32I,
+		GL_R8UI, GL_R16UI, GL_R32UI, GL_RG8UI, GL_RG16UI, GL_RG32UI,
+	};
+
+	static const GLenum validFormatsRGB32TexInt[] = {
+		GL_RGB32I, GL_RGB32UI
+	};
+
+	static const GLenum validFormatsRGB32Float[] = {
+		GL_RGB32F
+	};
+
+	static const GLenum validFormatsCompat[] = {
+		GL_ALPHA8, GL_ALPHA16,
+		GL_INTENSITY8, GL_INTENSITY16,
+		GL_LUMINANCE8, GL_LUMINANCE16,
+		GL_LUMINANCE8_ALPHA8, GL_LUMINANCE16_ALPHA16
+	};
+
+	static const GLenum validFormatsFloatCompat[] = {
+		GL_ALPHA16F_ARB, GL_INTENSITY32F_ARB,
+		GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE_ALPHA32F_ARB,
+	};
+
+	static const GLenum validFormatsTexIntCompat[] = {
+		GL_LUMINANCE8I_EXT, GL_ALPHA16I_EXT,
+		GL_INTENSITY32UI_EXT, GL_LUMINANCE_ALPHA32UI_EXT,
+	};
+
+	static const GLenum invalidFormats[] = {
+		0,
+		GL_TEXTURE_2D,
+		GL_R11F_G11F_B10F,
+		GL_SRGB,
+		GL_COMPRESSED_SRGB,
+		GL_RGB565,
+		GL_RGB8UI,
+		GL_RED_INTEGER,
+		GL_RGB,
+		GL_RGBA
+	};
+	GLuint buf;
+	GLenum expectedError;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 960, NULL, GL_STATIC_DRAW);
+
+/* invalid formats */
+	checkFormat(invalidFormats, ARRAY_SIZE(invalidFormats),
+	            GL_INVALID_ENUM);
+
+
+/* core formats */
+	checkFormat(validFormats, ARRAY_SIZE(validFormats), GL_NO_ERROR);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_rg")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsRG, ARRAY_SIZE(validFormatsRG),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_half_float_pixel")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsHalfFloat, ARRAY_SIZE(validFormatsHalfFloat),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_rg") &&
+	                piglit_is_extension_supported("GL_ARB_half_float_pixel")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsRGHalfFloat,
+	            ARRAY_SIZE(validFormatsRGHalfFloat),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_float")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsFloat, ARRAY_SIZE(validFormatsFloat),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_rg") &&
+	                piglit_is_extension_supported("GL_ARB_texture_float")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsRGFloat,
+	            ARRAY_SIZE(validFormatsRGFloat),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_buffer_object_rgb32") &&
+	                piglit_is_extension_supported("GL_ARB_texture_float")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsRGB32Float,
+	            ARRAY_SIZE(validFormatsRGB32Float),
+	            expectedError);
+
+
+	expectedError = piglit_is_extension_supported("GL_EXT_texture_integer")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormatInt(validFormatsTexInt, ARRAY_SIZE(validFormatsTexInt),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_rg") &&
+	                piglit_is_extension_supported("GL_EXT_texture_integer")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormatInt(validFormatsRGTexInt,
+	            ARRAY_SIZE(validFormatsRGTexInt),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_buffer_object_rgb32") &&
+	                piglit_is_extension_supported("GL_EXT_texture_integer")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormatInt(validFormatsRGB32TexInt,
+	            ARRAY_SIZE(validFormatsRGB32TexInt),
+	            expectedError);
+
+
+/* compat formats */
+	if (piglit_is_core_profile) {
+		piglit_report_result(PIGLIT_PASS);
+	}
+
+	checkFormat(validFormatsCompat, ARRAY_SIZE(validFormatsCompat),
+	            GL_NO_ERROR);
+
+	expectedError = piglit_is_extension_supported("GL_ARB_texture_float")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormat(validFormatsFloatCompat,
+	            ARRAY_SIZE(validFormatsFloatCompat),
+	            expectedError);
+
+	expectedError = piglit_is_extension_supported("GL_EXT_texture_integer")
+	                ? GL_NO_ERROR : GL_INVALID_ENUM;
+	checkFormatInt(validFormatsTexIntCompat,
+	            ARRAY_SIZE(validFormatsTexIntCompat),
+	            expectedError);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-bad-offset-size.c b/tests/spec/arb_clear_buffer_object/negative-bad-offset-size.c
new file mode 100644
index 0000000..075edb9
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-offset-size.c
@@ -0,0 +1,109 @@
+/*
+ * 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
+ *
+ * From the GL_ARB_clear_buffer_object spec:
+ *
+ *     "INVALID_VALUE is generated by ClearBufferSubData if <offset>
+ *      or <size> is less than zero."
+ *
+ *     "INVALID_VALUE is generated by ClearBufferSubData if <offset> +
+ *      <size> is greater than the value of BUFFER_SIZE for the buffer bound
+ *      to <target>."
+ *
+ *     "INVALID_VALUE is generated by ClearBufferSubData if <offset> or
+ *      <size> is not an integer multiple of the element size indicated by
+ *      <internalformat>. The element size is the number of components for
+ *      <internalformat> from table 3.15 multiplied by the size of the base
+ *      type for <internalformat> in that table."
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buf;
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
+
+/* negative offset or size */
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, -100, 200,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, -200,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+/* offset + size greater than buffer size */
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 0, 2000,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 500, 1000,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 1000, 1,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+
+/* offset and/or size not a multiple of element size indicated by
+<internalformat> */
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 110, 200,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 210,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 110, 210,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-bad-target.c b/tests/spec/arb_clear_buffer_object/negative-bad-target.c
new file mode 100644
index 0000000..582051c
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-target.c
@@ -0,0 +1,105 @@
+/*
+ * 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
+ *
+ * From the GL_ARB_clear_buffer_object spec:
+ *
+ *     "<target> must be one of the targets listed in Table 2.8."
+ *
+ * The targets listed in Table 2.8 of the OpenGL Core Spec 4.2 are:
+ *
+ *  - GL_ARRAY_BUFFER
+ *  - GL_ATOMIC_COUNTER_BUFFER
+ *  - GL_COPY_READ_BUFFER
+ *  - GL_COPY_WRITE_BUFFER
+ *  - GL_DRAW_INDIRECT_BUFFER
+ *  - GL_DISPATCH_INDIRECT_BUFFER
+ *  - GL_ELEMENT_ARRAY_BUFFER
+ *  - GL_PIXEL_PACK_BUFFER
+ *  - GL_PIXEL_UNPACK_BUFFER
+ *  - GL_SHADER_STORAGE_BUFFER
+ *  - GL_TEXTURE_BUFFER
+ *  - GL_TRANSFORM_FEEDBACK_BUFFER
+ *  - GL_UNIFORM_BUFFER
+ *
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLenum validTargets[] = {
+		GL_ARRAY_BUFFER,
+		GL_ELEMENT_ARRAY_BUFFER
+	};
+
+	GLenum invalidTargets[] = {
+		0,
+		GL_TEXTURE_2D,
+		GL_ARRAY_BUFFER_BINDING,
+		GL_FRAMEBUFFER,
+		GL_RENDERBUFFER
+	};
+	GLuint buf;
+	int i;
+
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+	glGenBuffers(1, &buf);
+	glBindBuffer(GL_ARRAY_BUFFER, buf);
+	glBufferData(GL_ARRAY_BUFFER, 1000, NULL, GL_STATIC_DRAW);
+
+	for (i = 0; i < ARRAY_SIZE(validTargets); ++i) {
+		glBindBuffer(validTargets[i], buf);
+
+		glClearBufferData(validTargets[i], GL_RGBA8,
+		                  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(validTargets[i], GL_RGBA8, 100, 200,
+		                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(invalidTargets); ++i) {
+		glBindBuffer(invalidTargets[i], buf);
+
+		piglit_reset_gl_error();
+
+		glClearBufferData(invalidTargets[i], GL_RGBA8,
+		                  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(GL_INVALID_ENUM))
+			piglit_report_result(PIGLIT_FAIL);
+
+		glClearBufferSubData(invalidTargets[i], GL_RGBA8, 100, 200,
+		                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+		if (!piglit_check_gl_error(GL_INVALID_ENUM))
+			piglit_report_result(PIGLIT_FAIL);
+	}
+
+	piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_clear_buffer_object/negative-no-target.c b/tests/spec/arb_clear_buffer_object/negative-no-target.c
new file mode 100644
index 0000000..d0efd14
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-no-target.c
@@ -0,0 +1,52 @@
+/*
+ * 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
+ *
+ * From the GL_ARB_clear_buffer_object spec:
+ *
+ *     "INVALID_VALUE is generated by ClearBufferSubData if no buffer is
+ *      bound to the binding point indicated by <target>."
+ *
+ */
+
+#include "common.h"
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_clear_buffer_object");
+
+
+	glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+	                  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+	                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+	if (!piglit_check_gl_error(GL_INVALID_VALUE))
+		piglit_report_result(PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.8.3.1



More information about the Piglit mailing list