[Piglit] [PATCH V2 1/2] ARB_clear_buffer_object: Add bunch of tests
Pi Tabred
servuswiegehtz at yahoo.de
Sat Dec 14 09:02:41 PST 2013
- 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-format: test if <format> parameter is valid
- 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-bad-type: test if <type> 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 | 167 +++++++++++++
tests/spec/arb_clear_buffer_object/clear-buffer.c | 78 ++++++
tests/spec/arb_clear_buffer_object/common.h | 72 ++++++
.../negative-already-mapped.c | 91 +++++++
.../negative-bad-format-type.c | 70 ++++++
.../arb_clear_buffer_object/negative-bad-format.c | 111 +++++++++
.../negative-bad-internalformat-format.c | 83 +++++++
.../negative-bad-internalformat.c | 272 +++++++++++++++++++++
.../negative-bad-offset-size.c | 116 +++++++++
.../arb_clear_buffer_object/negative-bad-target.c | 111 +++++++++
.../arb_clear_buffer_object/negative-bad-type.c | 85 +++++++
.../arb_clear_buffer_object/negative-no-target.c | 58 +++++
12 files changed, 1314 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-format.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-bad-type.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..f15013b
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/clear-buffer-sub.c
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+#include "common.h"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ int i;
+ GLuint buf;
+ unsigned char* initData8UI;
+ float* initData32F;
+ float* testF;
+ unsigned char* testUI;
+ GLsizeiptr bufferSize = 100;
+ unsigned char defaultData8UI = 5;
+ float defaultData32F = 1.0f;
+
+ float data1[] = {10.0f, 100.0f, 1000.0f, 10000.0f};
+
+ unsigned char data2[] = {13, 37, 23, 42};
+ size_t data2Size = sizeof(data2);
+ unsigned char data3[] = {16, 32, 64, 128};
+ size_t data3Size = sizeof(data3);
+
+ piglit_require_extension("GL_ARB_clear_buffer_object");
+
+ glGenBuffers(1, &buf);
+ glBindBuffer(GL_ARRAY_BUFFER, buf);
+ initData32F = (float*) malloc(bufferSize * sizeof(float));
+ for (i = 0; i < bufferSize; ++i)
+ {
+ initData32F[i] = defaultData32F;
+ }
+ glBufferData(GL_ARRAY_BUFFER, bufferSize * sizeof(float),
+ initData32F, GL_STATIC_DRAW);
+ free(initData32F);
+ initData32F = NULL;
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA32F, 20*sizeof(float),
+ 40*sizeof(float), GL_RGBA, GL_FLOAT, data1);
+
+ testF = (float*) glMapBuffer(GL_ARRAY_BUFFER,
+ GL_READ_WRITE);
+ compareDataf(&defaultData32F, testF, 0, 10, 1);
+ compareDataf(data1, testF, 20, 60, 4);
+ compareDataf(&defaultData32F, testF, 60, 100, 1);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+
+
+ initData8UI = (unsigned char*) malloc(bufferSize);
+ for (i = 0; i < bufferSize; ++i)
+ {
+ initData8UI[i] = defaultData8UI;
+ }
+ glBufferData(GL_ARRAY_BUFFER, bufferSize * sizeof(unsigned char),
+ initData8UI, GL_STATIC_DRAW);
+ free(initData8UI);
+ initData8UI = NULL;
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 40, 40, GL_RGBA,
+ GL_UNSIGNED_BYTE, data2);
+
+ testUI = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+ compareData(&defaultData8UI, testUI, 0, 40, 1);
+ compareData(data2, testUI, 40, 80, data2Size);
+ compareData(&defaultData8UI, testUI, 80, 100, 1);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 12, 20, GL_RGBA,
+ GL_UNSIGNED_BYTE, data2);
+
+ testUI = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+ compareData(&defaultData8UI, testUI, 0, 12, 1);
+ compareData(data2, testUI, 12, 32, data2Size);
+ compareData(&defaultData8UI, testUI, 32, 40, 1);
+ compareData(data2, testUI, 40, 80, data2Size);
+ compareData(&defaultData8UI, testUI, 80, 100, 1);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 20, 32, GL_RGBA,
+ GL_UNSIGNED_BYTE, data3);
+
+ testUI = (unsigned char*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
+ compareData(&defaultData8UI, testUI, 0, 12, 1);
+ compareData(data2, testUI, 12, 20, data2Size);
+ compareData(data3, testUI, 20, 52, data3Size);
+ compareData(data2, testUI, 52, 80, data2Size);
+ compareData(&defaultData8UI, testUI, 80, 100, 1);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+
+ 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, data3);
+
+ 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);
+
+ testUI = (unsigned char*) glMapBufferRange(GL_ARRAY_BUFFER,
+ 0, 96,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_READ_BIT);
+ compareData(&defaultData8UI, testUI, 0, 12, 1);
+ compareData(data2, testUI, 12, 20, data2Size);
+ compareData(data3, testUI, 20, 52, data3Size);
+ compareData(data2, testUI, 52, 60, data2Size);
+ compareData(data3, testUI, 60, 92, data3Size);
+ compareData(&defaultData8UI, testUI, 92, 96, 1);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+
+ glBufferData(GL_ARRAY_BUFFER,
+ bufferSize * sizeof(unsigned char),
+ 0, GL_STATIC_DRAW);
+ }
+
+ 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..5a40acb
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/clear-buffer.c
@@ -0,0 +1,78 @@
+/*
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint buf;
+ GLsizeiptr bufferSize = 100;
+ unsigned char* test;
+ 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);
+
+
+ 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);
+
+
+
+ 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..9301a33
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/common.h
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+ config.window_width = 32;
+ config.window_height = 32;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+void compareData(unsigned char* expected, unsigned char* 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);
+ }
+ }
+}
+
+
+void compareDataf(float* expected, float* 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 * sizeof(float));
+ 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..28fccff
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-already-mapped.c
@@ -0,0 +1,91 @@
+/*
+ * 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_OPERATION is generated by ClearBufferSubData if any part of the
+ * specified range of the buffer bound to <target> is currently mapped."
+ */
+
+#include "common.h"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint buf;
+ float* data;
+
+ 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);
+ data = (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"))
+ {
+ float* 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..abc1bb1
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-format-type.c
@@ -0,0 +1,70 @@
+/*
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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);
+
+ if (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-format.c b/tests/spec/arb_clear_buffer_object/negative-bad-format.c
new file mode 100644
index 0000000..eeb596c
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-format.c
@@ -0,0 +1,111 @@
+/*
+ * 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"
+ *
+ */
+
+#include "common.h"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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_RGBA8,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+
+ glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+ GL_R8, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_R8, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+
+ glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+ GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+
+ glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+ GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+
+ glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+ GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_STENCIL_INDEX, 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-bad-internalformat-format.c b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c
new file mode 100644
index 0000000..51e3fcd
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat-format.c
@@ -0,0 +1,83 @@
+/*
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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..c90bd3b
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-internalformat.c
@@ -0,0 +1,272 @@
+/*
+ * 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
+ *
+ */
+
+#include "common.h"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+static void
+checkFormat(GLenum 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 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)
+{
+ GLenum validFormats[] = {
+ GL_RGBA8, GL_RGBA16
+ };
+
+ GLenum validFormatsFloat[] = {
+ GL_RGBA32F
+ };
+
+ GLenum validFormatsHalfFloat[] = {
+ GL_RGBA16F
+ };
+
+ GLenum validFormatsRG[] = {
+ GL_R8, GL_R16, GL_RG8, GL_RG16
+ };
+
+ GLenum validFormatsRGFloat[] = {
+ GL_R16F, GL_RG16F
+ };
+
+ GLenum validFormatsRGHalfFloat[] = {
+ GL_R32F, GL_RG32F
+ };
+
+ GLenum validFormatsTexInt[] = {
+ GL_RGBA8I, GL_RGBA16I, GL_RGBA32I,
+ GL_RGBA8UI, GL_RGBA16UI, GL_RGBA32UI
+ };
+
+ 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,
+ };
+
+ GLenum validFormatsRGB32TexInt[] = {
+ GL_RGB32I, GL_RGB32UI
+ };
+
+ GLenum validFormatsRGB32Float[] = {
+ GL_RGB32F
+ };
+
+ 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;
+
+ 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);
+
+
+ checkFormat(validFormats, ARRAY_SIZE(validFormats), GL_NO_ERROR);
+
+ if (piglit_is_extension_supported("GL_ARB_texture_rg"))
+ {
+ checkFormat(validFormatsRG, ARRAY_SIZE(validFormatsRG),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormat(validFormatsRG, ARRAY_SIZE(validFormatsRG),
+ GL_INVALID_ENUM);
+ }
+
+
+ if (piglit_is_extension_supported("GL_ARB_half_float_pixel"))
+ {
+ checkFormat(validFormatsHalfFloat,
+ ARRAY_SIZE(validFormatsHalfFloat), GL_NO_ERROR);
+
+ if (piglit_is_extension_supported("GL_ARB_texture_rg"))
+ {
+ checkFormat(validFormatsRGHalfFloat,
+ ARRAY_SIZE(validFormatsRGHalfFloat),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormat(validFormatsRGHalfFloat,
+ ARRAY_SIZE(validFormatsRGHalfFloat),
+ GL_INVALID_ENUM);
+ }
+ }
+ else
+ {
+ checkFormat(validFormatsHalfFloat,
+ ARRAY_SIZE(validFormatsHalfFloat),
+ GL_INVALID_ENUM);
+ }
+
+
+ if (piglit_is_extension_supported("GL_ARB_texture_float"))
+ {
+ checkFormat(validFormatsFloat, ARRAY_SIZE(validFormatsFloat),
+ GL_NO_ERROR);
+
+ if (piglit_is_extension_supported("GL_ARB_texture_rg"))
+ {
+ checkFormat(validFormatsRGFloat,
+ ARRAY_SIZE(validFormatsRGFloat),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormat(validFormatsRGFloat,
+ ARRAY_SIZE(validFormatsRGFloat),
+ GL_INVALID_ENUM);
+ }
+
+ if (piglit_is_extension_supported("GL_ARB_texture_buffer_object_rgb32"))
+ {
+ checkFormat(validFormatsRGB32Float,
+ ARRAY_SIZE(validFormatsRGB32Float),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormat(validFormatsRGB32Float,
+ ARRAY_SIZE(validFormatsRGB32Float),
+ GL_INVALID_ENUM);
+ }
+ }
+ else
+ {
+ checkFormat(validFormatsFloat,
+ ARRAY_SIZE(validFormatsFloat),
+ GL_INVALID_ENUM);
+ }
+
+ if (piglit_is_extension_supported("GL_EXT_texture_integer"))
+ {
+ checkFormatInt(validFormatsTexInt,
+ ARRAY_SIZE(validFormatsTexInt),
+ GL_NO_ERROR);
+
+ if (piglit_is_extension_supported("GL_ARB_texture_rg"))
+ {
+ checkFormatInt(validFormatsRGTexInt,
+ ARRAY_SIZE(validFormatsRGTexInt),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormatInt(validFormatsRGTexInt,
+ ARRAY_SIZE(validFormatsRGTexInt),
+ GL_INVALID_ENUM);
+ }
+
+ if (piglit_is_extension_supported("GL_ARB_texture_buffer_object_rgb32"))
+ {
+ checkFormatInt(validFormatsRGB32TexInt,
+ ARRAY_SIZE(validFormatsRGB32TexInt),
+ GL_NO_ERROR);
+ }
+ else
+ {
+ checkFormatInt(validFormatsRGB32TexInt,
+ ARRAY_SIZE(validFormatsRGB32TexInt),
+ GL_INVALID_ENUM);
+ }
+ }
+ else
+ {
+ checkFormatInt(validFormatsTexInt,
+ ARRAY_SIZE(validFormatsTexInt),
+ GL_INVALID_ENUM);
+ }
+
+ checkFormat(invalidFormats, ARRAY_SIZE(invalidFormats),
+ GL_INVALID_ENUM);
+
+ 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..3eaea29
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-offset-size.c
@@ -0,0 +1,116 @@
+/*
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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);
+
+ 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);
+
+
+ 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);
+
+
+ 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..8146cda
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-target.c
@@ -0,0 +1,111 @@
+/*
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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-bad-type.c b/tests/spec/arb_clear_buffer_object/negative-bad-type.c
new file mode 100644
index 0000000..bbbb433
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-bad-type.c
@@ -0,0 +1,85 @@
+/*
+ * 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 <type> is not a valid token, e.g. if it is not a
+ * token for a color format
+ */
+
+#include "common.h"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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_RGBA8,
+ GL_RGBA, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_RGBA, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
+ NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+
+ if (!piglit_is_extension_supported("GL_ARB_texture_float"))
+ {
+ glClearBufferData(GL_ARRAY_BUFFER, GL_RGBA8,
+ GL_RGBA, GL_FLOAT, NULL);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM))
+ piglit_report_result(PIGLIT_FAIL);
+
+ glClearBufferSubData(GL_ARRAY_BUFFER, GL_RGBA8, 100, 200,
+ GL_RGBA, 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-no-target.c b/tests/spec/arb_clear_buffer_object/negative-no-target.c
new file mode 100644
index 0000000..8cd41d3
--- /dev/null
+++ b/tests/spec/arb_clear_buffer_object/negative-no-target.c
@@ -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
+ *
+ * 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"
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL; /* UNREACHED */
+}
+
+
+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