From 16101933e56109bd9d1b590bc4f85133afca58d6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 21 Apr 2015 13:44:43 +1000 Subject: shader_subroutine: hacking get.c test more get.c --- tests/spec/arb_shader_subroutine/CMakeLists.txt | 1 + .../execution/CMakeLists.gl.txt | 12 ++ .../arb_shader_subroutine/execution/CMakeLists.txt | 1 + tests/spec/arb_shader_subroutine/execution/get.c | 196 +++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 tests/spec/arb_shader_subroutine/execution/CMakeLists.gl.txt create mode 100644 tests/spec/arb_shader_subroutine/execution/CMakeLists.txt create mode 100644 tests/spec/arb_shader_subroutine/execution/get.c diff --git a/tests/spec/arb_shader_subroutine/CMakeLists.txt b/tests/spec/arb_shader_subroutine/CMakeLists.txt index 144a306f4..e4126fc2d 100644 --- a/tests/spec/arb_shader_subroutine/CMakeLists.txt +++ b/tests/spec/arb_shader_subroutine/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory (execution) piglit_include_target_api() diff --git a/tests/spec/arb_shader_subroutine/execution/CMakeLists.gl.txt b/tests/spec/arb_shader_subroutine/execution/CMakeLists.gl.txt new file mode 100644 index 000000000..3efcada66 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/CMakeLists.gl.txt @@ -0,0 +1,12 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (arb_shader_subroutine-get get.c) diff --git a/tests/spec/arb_shader_subroutine/execution/CMakeLists.txt b/tests/spec/arb_shader_subroutine/execution/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_shader_subroutine/execution/get.c b/tests/spec/arb_shader_subroutine/execution/get.c new file mode 100644 index 000000000..261fb9c5c --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/get.c @@ -0,0 +1,196 @@ +/* + * Copyright © 2015 Red Hat + * + * 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.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 32; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + config.window_width = 256 + 3; + config.window_height = 256 * 2 + 3; + + +PIGLIT_GL_TEST_CONFIG_END + +GLuint vao; + +GLuint prog; + +static const char *vs_text = + "#version 130\n" + "in vec4 piglit_vertex;\n" + "void main()\n" + "{\n" + " gl_Position = piglit_vertex;\n" + "}\n"; + +static const char *vs_sub_one = + "#version 130\n" + "#extension GL_ARB_shader_subroutine : require\n" + "in vec4 piglit_vertex;\n" + "void main()\n" + "{\n" + " gl_Position = piglit_vertex;\n" + "}\n"; + +static const char *fs_sub_one = + "#version 130\n" + "#extension GL_ARB_shader_subroutine : require\n" + "out vec4 color;\n" + "subroutine vec4 getcolor();\n" + "subroutine uniform getcolor GetColor;\n" + "subroutine(getcolor) vec4 color_red()\n" + "{\n" + " return vec4(1.0, 0.0, 0.0, 1.0);\n" + "}\n" + "subroutine(getcolor) vec4 color_green()\n" + "{\n" + " return vec4(0.0, 1.0, 0.0, 1.0);\n" + "}\n" + "void main()\n" + "{\n" + " color = GetColor();\n" + "}\n"; + +static const char *fs_sub_array = + "#version 130\n" + "#extension GL_ARB_shader_subroutine : require\n" + "out vec4 color;\n" + "out vec4 color2;\n" + "subroutine vec4 getcolor();\n" + "subroutine vec4 getcolor_longer();\n" + "subroutine float getchan();\n" + "subroutine uniform getcolor GetColor[2];\n" + "subroutine uniform getcolor_longer GetColorLonger[6];\n" + "subroutine uniform getchan GetChan;\n" + "subroutine(getcolor,getcolor_longer) vec4 color_red()\n" + "{\n" + " return vec4(1.0, 0.0, 0.0, 1.0);\n" + "}\n" + "subroutine(getcolor,getcolor_longer) vec4 color_green()\n" + "{\n" + " return vec4(0.0, 1.0, 0.0, 1.0);\n" + "}\n" + "subroutine(getchan) float chan_full()\n" + "{\n" + " return 1.0;\n" + "}\n" + "subroutine(getchan) float chan_empty()\n" + "{\n" + " return 1.0;\n" + "}\n" + "void main()\n" + "{\n" + " color = vec4(vec2(GetColor[0]()), GetChan(), 1.0);\n" + " color2 = vec4(vec2(GetColorLonger[3]()), GetChan(), 1.0);\n" + "}\n"; + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} + +void +piglit_init(int argc, char **argv) +{ + GLint value = -1; + piglit_require_extension("GL_ARB_shader_subroutine"); + char buf[255]; + int len, i, j; + int active_subroutines; + int active_subroutine_uniform_locations; + int active_subroutine_uniforms; + GLint val_array[1024]; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + prog = piglit_build_simple_program(vs_text, fs_sub_array); + + glUseProgram(prog); + + glGetProgramStageiv(prog, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINES, + &value); + + active_subroutines = value; + fprintf(stderr, "active subroutines is %d\n", value); + + glGetProgramStageiv(prog, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORMS, + &value); + + active_subroutine_uniforms = value; + fprintf(stderr, "active subroutine uniforms is %d\n", value); + + glGetProgramStageiv(prog, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, + &value); + active_subroutine_uniform_locations = value; + fprintf(stderr, "active subroutine uniform locations is %d\n", value); + + glGetProgramStageiv(prog, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_MAX_LENGTH, + &value); + + fprintf(stderr, "active subroutine max length is %d\n", value); + + glGetProgramStageiv(prog, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH, + &value); + + fprintf(stderr, "active subroutine uniform max length is %d\n", value); + + for (i = 0; i < active_subroutine_uniforms; i++) { + + glGetActiveSubroutineUniformName(prog, GL_FRAGMENT_SHADER, + i, 255, &len, buf); + glGetActiveSubroutineUniformiv(prog, GL_FRAGMENT_SHADER, + i, GL_NUM_COMPATIBLE_SUBROUTINES, &value); + fprintf(stderr, "%d: compat %s is %d: ", i, buf, value); + glGetActiveSubroutineUniformiv(prog, GL_FRAGMENT_SHADER, + i, GL_COMPATIBLE_SUBROUTINES, val_array); + for (j = 0; j < value; j++) { + fprintf(stderr, "%d ", val_array[j]); + } + fprintf(stderr, "\n"); + + glGetActiveSubroutineUniformiv(prog, GL_FRAGMENT_SHADER, + i, GL_UNIFORM_SIZE, &value); + fprintf(stderr, "uniform %s size is %d\n", buf, value); + + glGetActiveSubroutineUniformiv(prog, GL_FRAGMENT_SHADER, + i, GL_UNIFORM_NAME_LENGTH, &value); + fprintf(stderr, "uniform %s name length is %d\n", buf, value); + + } + + for (i = 0; i < active_subroutines; i++) { + glGetActiveSubroutineName(prog, GL_FRAGMENT_SHADER, + i, 255, &len, buf); + fprintf(stderr, "%d: %d: %s\n", i, len, buf); + } + + for (i = 0; i < active_subroutine_uniform_locations; i++) { + glGetUniformSubroutineuiv(GL_FRAGMENT_SHADER, i, &value); + fprintf(stderr, "loc %d: value %d\n", i, value); + } + glUseProgram(0); + glDeleteProgram(prog); +} -- cgit v1.2.3