summaryrefslogtreecommitdiff
path: root/tests/spec/arb_uniform_buffer_object/minmax.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2012-05-02 14:58:17 -0700
committerEric Anholt <eric@anholt.net>2012-05-22 16:31:38 -0700
commit19923825808c7067a3acfe6f6f64136b1ae332fe (patch)
tree489d0219795262d5cc8d25e3b447ec1fd8b3ecc0 /tests/spec/arb_uniform_buffer_object/minmax.c
parent3e48bc4fe0fc0e2d8fce8201e91decf84aee2762 (diff)
GL_ARB_ubo: Add a test for the minimum maximums.
This is closely related to the tests in gl-3.1/minmax, but I included the logic for geometry shaders that isn't in the 3.1 spec.
Diffstat (limited to 'tests/spec/arb_uniform_buffer_object/minmax.c')
-rw-r--r--tests/spec/arb_uniform_buffer_object/minmax.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/spec/arb_uniform_buffer_object/minmax.c b/tests/spec/arb_uniform_buffer_object/minmax.c
new file mode 100644
index 000000000..b004b70d2
--- /dev/null
+++ b/tests/spec/arb_uniform_buffer_object/minmax.c
@@ -0,0 +1,99 @@
+/* Copyright © 2012 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 minmax.c
+ *
+ * Test for the minimum maximum values in section 6.2 "State Tables"
+ * of the GL 3.1 spec.
+ */
+
+#include "piglit-util.h"
+#include "minmax-test.h"
+
+int piglit_width = 32;
+int piglit_height = 32;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+enum piglit_result
+piglit_display(void)
+{
+ /* UNREACHED */
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ int vuniforms = 0, vblocks = 0;
+ int guniforms = 0, gblocks = 0;
+ int funiforms = 0, fblocks = 0;
+ int blocksize = 0;
+ bool gs = piglit_is_extension_supported("GL_ARB_geometry_shader4");
+
+ piglit_require_extension("GL_ARB_uniform_buffer_object");
+
+ piglit_print_minmax_header();
+
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 1024);
+
+ piglit_test_min_int(GL_MAX_VERTEX_UNIFORM_BLOCKS, 12);
+ piglit_test_min_int(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12);
+ if (gs)
+ piglit_test_min_int(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, 12);
+
+ piglit_test_min_int(GL_MAX_COMBINED_UNIFORM_BLOCKS, gs ? 36 : 24);
+ piglit_test_min_int(GL_MAX_UNIFORM_BUFFER_BINDINGS, gs ? 36 : 24);
+ piglit_test_min_int(GL_MAX_UNIFORM_BLOCK_SIZE, 16384);
+
+ /* Minimum value for OpenGL 3.1 is
+ * (MAX_<stage>_UNIFORM_BLOCKS * MAX_UNIFORM_BLOCK_SIZE) +
+ * MAX_<stage>_UNIFORM_COMPONENTS. Minimum value prior to
+ * OpenGL 3.1 is MAX_<stage>_UNIFORM_COMPONENTS.
+ */
+ if (piglit_get_gl_version() >= 31) {
+ glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &vblocks);
+ glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &fblocks);
+ }
+ glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &vuniforms);
+ glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &funiforms);
+ glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &blocksize);
+ piglit_test_min_int(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS,
+ vblocks * blocksize + vuniforms);
+ piglit_test_min_int(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS,
+ fblocks * blocksize + funiforms);
+ if (gs) {
+ if (piglit_get_gl_version() >= 31) {
+ glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gblocks);
+ }
+ glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, &guniforms);
+
+ piglit_test_min_int(GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS,
+ gblocks * blocksize + guniforms);
+ }
+
+ piglit_test_min_int(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 1);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(piglit_minmax_pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}