[Mesa-dev] [PATCH] glsl: Modify glsl-max-varyings to test varying packing
--- tests/shaders/CMakeLists.gl.txt |1 + tests/shaders/glsl-max-varyings-2.c | 413 +++ 2 files changed, 414 insertions(+), 0 deletions(-) create mode 100644 tests/shaders/glsl-max-varyings-2.c diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt index 9d72260..b00219e 100644 --- a/tests/shaders/CMakeLists.gl.txt +++ b/tests/shaders/CMakeLists.gl.txt @@ -143,6 +143,7 @@ add_executable (vp-ignore-input vp-ignore-input.c) add_executable (glsl-empty-vs-no-fs glsl-empty-vs-no-fs.c) add_executable (glsl-mat-attribute glsl-mat-attribute.c) add_executable (glsl-max-varyings glsl-max-varyings.c) +add_executable (glsl-max-varyings-2 glsl-max-varyings-2.c) add_executable (glsl-useprogram-displaylist glsl-useprogram-displaylist.c) add_executable (glsl-routing glsl-routing.c) add_executable (shader_runner shader_runner.c) diff --git a/tests/shaders/glsl-max-varyings-2.c b/tests/shaders/glsl-max-varyings-2.c new file mode 100644 index 000..ce2767a --- /dev/null +++ b/tests/shaders/glsl-max-varyings-2.c @@ -0,0 +1,413 @@ +/* + * Copyright © 2010 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. + * + * Authors: + *Eric Anholt e...@anholt.net + * + */ + +/** @file glsl-max-varyings.c + * + * Tests whether GL_MAX_VARYING_FLOATS varying components can be used when packed + * as vec4, vec3, vec2, or float. Drivers have to pack varyings to pass this test. + */ + +#include piglit-util.h + +#define MAX_VARYING 128 + +/* 10x10 rectangles with 2 pixels of pad. Deal with up to 32 varyings. */ +int piglit_width = (2 + MAX_VARYING * 12), piglit_height = (2 + MAX_VARYING * 12); +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + + +enum varyings_type { + FLT = 0, + V2 = 1, + V3 = 2, + V4 = 3 +}; + +const unsigned increments[] = { 4, 2, 2, 1 }; + +/* Generate a VS that writes to num_varyings vec4s, and put + * interesting data in data_varying with 0.0 everywhere else. + */ +static GLint get_vs(int num_varyings, int data_varying, enum varyings_type type) +{ + + const char * varying_decl[] = { + varying float v%d;\n, + varying vec2 v%d;\n, + varying vec3 v%d;\n, + varying vec4 v%d;\n, + }; + + GLuint shader; + unsigned i; + char *code; + char temp[2048]; + + code = malloc(2048 * 4); + code[0] = 0; + for (i = 0; i num_varyings; i++) { +sprintf(temp, varying_decl[type], i); + strcat(code, temp); + } + + sprintf(temp, + attribute vec4 green;\n + attribute float v_zero;\n + void main()\n + {\n + gl_Position = (gl_ModelViewProjectionMatrix * \n + gl_Vertex);\n + ); + strcat(code, temp); + i = 0; + while (i + increments[type] num_varyings) { + if (i == data_varying) { + switch (type) { + case FLT: + sprintf(temp, + v%d = green.x;\n + v%d = green.y;\n + v%d = green.z;\n + v%d = green.w;\n, + i, + i + 1, + i + 2, + i + 3); + break; + case V2: + sprintf(temp, + v%d = green.xy;\n + v%d = green.zw;\n, + i, + i + 1); + break; + case V3: + sprintf(temp, + v%d = green.xyz;\n + v%d.x = green.w;\n, + i, + i + 1); + break; +
[Mesa-dev] [PATCH] glsl: Modify glsl-max-varyings to test varying packing
--- tests/shaders/CMakeLists.gl.txt |1 + tests/shaders/glsl-max-varyings-2.c | 413 +++ 2 files changed, 414 insertions(+), 0 deletions(-) create mode 100644 tests/shaders/glsl-max-varyings-2.c diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt index 9d72260..b00219e 100644 --- a/tests/shaders/CMakeLists.gl.txt +++ b/tests/shaders/CMakeLists.gl.txt @@ -143,6 +143,7 @@ add_executable (vp-ignore-input vp-ignore-input.c) add_executable (glsl-empty-vs-no-fs glsl-empty-vs-no-fs.c) add_executable (glsl-mat-attribute glsl-mat-attribute.c) add_executable (glsl-max-varyings glsl-max-varyings.c) +add_executable (glsl-max-varyings-2 glsl-max-varyings-2.c) add_executable (glsl-useprogram-displaylist glsl-useprogram-displaylist.c) add_executable (glsl-routing glsl-routing.c) add_executable (shader_runner shader_runner.c) diff --git a/tests/shaders/glsl-max-varyings-2.c b/tests/shaders/glsl-max-varyings-2.c new file mode 100644 index 000..b020d6c --- /dev/null +++ b/tests/shaders/glsl-max-varyings-2.c @@ -0,0 +1,413 @@ +/* + * Copyright © 2010 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. + * + * Authors: + *Eric Anholt e...@anholt.net + * + */ + +/** @file glsl-max-varyings.c + * + * Tests whether GL_MAX_VARYING_FLOATS varying components can be used when packed + * as vec4, vec3, vec2, or float. Drivers have to pack varyings to pass this test. + */ + +#include piglit-util.h + +#define MAX_VARYING 128 + +/* 10x10 rectangles with 2 pixels of pad. Deal with up to 32 varyings. */ +int piglit_width = (2 + MAX_VARYING * 12), piglit_height = (2 + MAX_VARYING * 12); +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + + +enum varyings_type { + FLT = 0, + V2 = 1, + V3 = 2, + V4 = 3 +}; + +const unsigned increments[] = { 4, 2, 2, 1 }; + +/* Generate a VS that writes to num_varyings vec4s, and put + * interesting data in data_varying with 0.0 everywhere else. + */ +static GLint get_vs(int num_varyings, int data_varying, enum varyings_type type) +{ + + const char * varying_decl[] = { + varying float v%d;\n, + varying vec2 v%d;\n, + varying vec3 v%d;\n, + varying vec4 v%d;\n, + }; + + GLuint shader; + unsigned i; + char *code; + char temp[2048]; + + code = malloc(2048 * 4); + code[0] = 0; + for (i = 0; i num_varyings; i++) { +sprintf(temp, varying_decl[type], i); + strcat(code, temp); + } + + sprintf(temp, + attribute vec4 green;\n + attribute float v_zero;\n + void main()\n + {\n + gl_Position = (gl_ModelViewProjectionMatrix * \n + gl_Vertex);\n + ); + strcat(code, temp); + i = 0; + while (i + increments[type] num_varyings) { + if (i == data_varying) { + switch (type) { + case FLT: + sprintf(temp, + v%d = green.x;\n + v%d = green.y;\n + v%d = green.z;\n + v%d = green.w;\n, + i, + i + 1, + i + 2, + i + 3); + break; + case V2: + sprintf(temp, + v%d = green.xy;\n + v%d = green.zw;\n, + i, + i + 1); + break; + case V3: + sprintf(temp, + v%d = green.xyz;\n + v%d.x = green.w;\n, + i, + i + 1); + break; +