Signed-off-by: Tapani Pälli <[email protected]>
---
 tests/all.py                                       |   1 +
 .../CMakeLists.gl.txt                              |   1 +
 .../array-outofspace.c                             | 107 +++++++++++++++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 tests/spec/arb_explicit_uniform_location/array-outofspace.c

diff --git a/tests/all.py b/tests/all.py
index f4e867c..57d4d18 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1929,6 +1929,7 @@ add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-bou
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-array-elements')
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-array-toobig')
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-array-overlap')
+add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-array-outofspace')
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-loc-overlap')
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-loc-2different')
 add_plain_test(arb_explicit_uniform_location, 
'arb_explicit_uniform_location-loc-setonce')
diff --git a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt 
b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
index 933ddee..3e60776 100644
--- a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
+++ b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ piglit_add_executable 
(arb_explicit_uniform_location-boundaries loc-boundaries.c
 piglit_add_executable (arb_explicit_uniform_location-array-elements 
array-elements.c)
 piglit_add_executable (arb_explicit_uniform_location-array-toobig 
array-toobig.c)
 piglit_add_executable (arb_explicit_uniform_location-array-overlap 
array-overlap.c)
+piglit_add_executable (arb_explicit_uniform_location-array-outofspace 
array-outofspace.c)
 piglit_add_executable (arb_explicit_uniform_location-loc-overlap loc-overlap.c)
 piglit_add_executable (arb_explicit_uniform_location-loc-2different 
loc-2different.c)
 piglit_add_executable (arb_explicit_uniform_location-loc-setonce loc-setonce.c)
diff --git a/tests/spec/arb_explicit_uniform_location/array-outofspace.c 
b/tests/spec/arb_explicit_uniform_location/array-outofspace.c
new file mode 100644
index 0000000..d37cba9
--- /dev/null
+++ b/tests/spec/arb_explicit_uniform_location/array-outofspace.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2014 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 array-outofspace.c
+ *
+ *  Tests situation where explicit locations cause fragmentation so that
+ *  there is not enough space for all uniforms to fit. There are 3 arrays where
+ *  2 of them have explicit locations and consume available space so that
+ *  third one won't fit.
+ *
+ *  https://www.opengl.org/registry/specs/ARB/explicit_uniform_location.txt
+ *
+ */
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_compat_version = 20;
+       config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       return PIGLIT_FAIL;
+}
+
+const char v_sha[] =
+       "vec4 vertex;\n"
+       "void main() {\n"
+               "gl_Position = vertex;\n"
+       "}";
+
+const char fshader_main[] =
+       "#extension GL_ARB_explicit_uniform_location: require\n"
+       "layout(location = %d) uniform float a[%d];\n"
+       "layout(location = %d) uniform float b[%d];\n"
+       "uniform float c[%d];\n"
+       "void main() {\n"
+               "gl_FragColor = vec4(a[%d], b[%d], c[%d], 1.0);\n"
+       "}";
+
+void
+piglit_init(int argc, char **argv)
+{
+       GLuint prog;
+       GLint link_status;
+       int maxloc;
+       char *f_sha;
+       unsigned i, ab_size, c_size;
+
+       piglit_require_extension("GL_ARB_explicit_uniform_location");
+
+       glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);
+
+       if (!piglit_check_gl_error(GL_NO_ERROR))
+               return false;
+
+       /* a and b consume almost everything but leave some empty space */
+       ab_size = (maxloc / 2) - 8;
+
+       /* c would need third of available space but does not fit */
+       c_size = maxloc / 3;
+
+       if (asprintf(&f_sha, fshader_main,
+               0,                              /* a loc*/
+               ab_size,
+               ab_size + 1,                    /* b loc*/
+               ab_size,
+               ab_size + 1 + ab_size + 1,      /* c loc */
+               ab_size - 1,
+               ab_size - 1,
+               c_size - 1) == -1)
+               piglit_report_result(PIGLIT_FAIL);
+
+       prog = piglit_build_simple_program_unlinked(v_sha, f_sha);
+       free(f_sha);
+
+       glLinkProgram(prog);
+       glGetProgramiv(prog, GL_LINK_STATUS, &link_status);
+       glDeleteProgram(prog);
+
+       /* link_status is expected to be GL_FALSE */
+       piglit_report_result(link_status ? PIGLIT_FAIL : PIGLIT_PASS);
+}
-- 
1.8.3.1

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to