[Piglit] [PATCH] glsl-resource-not-bound: test rendering with unbound resources
Marek Olšák
maraeo at gmail.com
Thu Feb 6 21:24:47 CET 2014
From: Marek Olšák <marek.olsak at amd.com>
---
tests/all.py | 13 +++
tests/spec/gl-3.2/CMakeLists.gl.txt | 1 +
tests/spec/gl-3.2/glsl-resource-not-bound.c | 152 ++++++++++++++++++++++++++++
3 files changed, 166 insertions(+)
create mode 100644 tests/spec/gl-3.2/glsl-resource-not-bound.c
diff --git a/tests/all.py b/tests/all.py
index 4efa72b..8ed3e54 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1070,6 +1070,18 @@ gl31['required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-requi
gl31['required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 31')
gl31['required-texture-attachment-formats'] = concurrent_test('gl-3.0-required-texture-attachment-formats 31')
+gl32 = Group()
+spec['!OpenGL 3.2'] = gl32
+add_concurrent_test(gl32, 'glsl-resource-not-bound 1D')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 2D')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 3D')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 2DRect')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 1DArray')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 2DArray')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 2DMS')
+add_concurrent_test(gl32, 'glsl-resource-not-bound 2DMSArray')
+add_concurrent_test(gl32, 'glsl-resource-not-bound Buffer')
+add_concurrent_test(gl32, 'glsl-resource-not-bound Cube')
spec['!OpenGL 3.2/minmax'] = concurrent_test('gl-3.2-minmax')
spec['!OpenGL 3.2/clear-no-buffers'] = concurrent_test('gl-3.2-clear-no-buffers')
spec['!OpenGL 3.2/depth-tex-sampling'] = concurrent_test('gl-3.2-depth-tex-sampling')
@@ -2551,6 +2563,7 @@ add_plain_test(arb_texture_cube_map_array, 'arb_texture_cube_map_array-cubemap-l
add_plain_test(arb_texture_cube_map_array, 'arb_texture_cube_map_array-fbo-cubemap-array')
add_plain_test(arb_texture_cube_map_array, 'arb_texture_cube_map_array-sampler-cube-array-shadow')
add_concurrent_test(arb_texture_cube_map_array, 'getteximage-targets CUBE_ARRAY')
+add_concurrent_test(arb_texture_cube_map_array, 'glsl-resource-not-bound CubeArray')
textureSize_samplers_atcma = ['samplerCubeArray', 'isamplerCubeArray', 'usamplerCubeArray', 'samplerCubeArrayShadow' ];
import_glsl_parser_tests(arb_texture_cube_map_array,
diff --git a/tests/spec/gl-3.2/CMakeLists.gl.txt b/tests/spec/gl-3.2/CMakeLists.gl.txt
index 595cc10..ac4499f 100644
--- a/tests/spec/gl-3.2/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/CMakeLists.gl.txt
@@ -16,6 +16,7 @@ piglit_add_executable (gl-3.2-get-buffer-parameter-i64v get-buffer-parameter-i64
piglit_add_executable (gl-3.2-get-integer-64iv get-integer-64iv.c)
piglit_add_executable (gl-3.2-get-integer-64v get-integer-64v.c)
piglit_add_executable (gl-3.2-texture-border-deprecated texture-border-deprecated.c)
+piglit_add_executable (glsl-resource-not-bound glsl-resource-not-bound.c)
piglit_add_executable (gl-coord-replace-doesnt-eliminate-frag-tex-coords gl-coord-replace-doesnt-eliminate-frag-tex-coords)
piglit_add_executable (gl-get-active-attrib-returns-all-inputs get-active-attrib-returns-all-inputs.c)
# vim: ft=cmake:
diff --git a/tests/spec/gl-3.2/glsl-resource-not-bound.c b/tests/spec/gl-3.2/glsl-resource-not-bound.c
new file mode 100644
index 0000000..dc08bdb
--- /dev/null
+++ b/tests/spec/gl-3.2/glsl-resource-not-bound.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2014 Advanced Micro Devices, Inc.
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_core_version = 32;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static GLuint
+get_program(const char *target)
+{
+ char fs_text[1024];
+ static const char *fs_templ =
+ "#version 150\n%s"
+ "uniform sampler%s s;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = %s;\n"
+ "}\n";
+ static const char *vs_text =
+ "#version 150\n"
+ "#extension GL_ARB_explicit_attrib_location : require\n"
+ "layout(location=0) in vec4 pos;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = pos;\n"
+ "}\n";
+
+ if (!strcmp(target, "1D"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, 0, 0)");
+ else if (!strcmp(target, "2D"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec2(0), 0)");
+ else if (!strcmp(target, "3D"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec3(0), 0)");
+ else if (!strcmp(target, "2DRect"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec2(0))");
+ else if (!strcmp(target, "1DArray"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec2(0), 0)");
+ else if (!strcmp(target, "2DArray"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec3(0), 0)");
+ else if (!strcmp(target, "2DMS"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec2(0), 0)");
+ else if (!strcmp(target, "2DMSArray"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, ivec3(0), 0)");
+ else if (!strcmp(target, "Buffer"))
+ sprintf(fs_text, fs_templ, "", target, "texelFetch(s, 0)");
+ else if (!strcmp(target, "Cube"))
+ sprintf(fs_text, fs_templ, "", target, "texture(s, vec3(0.0))");
+ else if (!strcmp(target, "CubeArray")) {
+ piglit_require_extension("GL_ARB_texture_cube_map_array");
+ sprintf(fs_text, fs_templ,
+ "#extension GL_ARB_texture_cube_map_array : require\n",
+ target, "texture(s, vec4(0.0))");
+ }
+ else {
+ printf("Unknown target = %s\n", target);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ return piglit_build_simple_program_multiple_shaders(GL_VERTEX_SHADER, vs_text,
+ GL_FRAGMENT_SHADER, fs_text,
+ 0);
+}
+
+static void
+draw_rect_core(int x, int y, int w, int h)
+{
+ float verts[4][4];
+
+ verts[0][0] = x;
+ verts[0][1] = y;
+ verts[0][2] = 0.0;
+ verts[0][3] = 1.0;
+ verts[1][0] = x + w;
+ verts[1][1] = y;
+ verts[1][2] = 0.0;
+ verts[1][3] = 1.0;
+ verts[2][0] = x + w;
+ verts[2][1] = y + h;
+ verts[2][2] = 0.0;
+ verts[2][3] = 1.0;
+ verts[3][0] = x;
+ verts[3][1] = y + h;
+ verts[3][2] = 0.0;
+ verts[3][3] = 1.0;
+
+ glBufferData(GL_ARRAY_BUFFER, 4 * 4 * sizeof(float),
+ verts, GL_STATIC_DRAW);
+ glVertexAttribPointer(0, 4, GL_FLOAT, false, 0, 0);
+ glEnableVertexAttribArray(0);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* This shouldn't crash, but the result is undefined unless
+ * the context was created with robust buffer access. */
+ draw_rect_core(-1, -1, 1, 1);
+
+ piglit_present_results();
+ return PIGLIT_PASS;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint vao, bo;
+
+ if (argc != 2) {
+ puts("Wrong parameters.");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ piglit_require_extension("GL_ARB_explicit_attrib_location");
+
+ glUseProgram(get_program(argv[1]));
+
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+
+ glGenBuffers(1, &bo);
+ glBindBuffer(GL_ARRAY_BUFFER, bo);
+}
--
1.8.3.2
More information about the Piglit
mailing list