Commit 88b714a2 authored by Ian Romanick's avatar Ian Romanick

Add test for GLSL linker handling of initializers

All of these except glsl-link-initializer-05 pass on Nvidia
close-source drivers.
parent a8b9c1f8
......@@ -396,6 +396,12 @@ add_plain_test(shaders, 'vp-ignore-input')
add_plain_test(shaders, 'glsl-empty-vs-no-fs')
add_plain_test(shaders, 'glsl-useprogram-displaylist')
add_plain_test(shaders, 'glsl-vs-point-size')
add_plain_test(shaders, 'glsl-link-initializer-01')
add_plain_test(shaders, 'glsl-link-initializer-02')
add_plain_test(shaders, 'glsl-link-initializer-03')
add_plain_test(shaders, 'glsl-link-initializer-04')
add_plain_test(shaders, 'glsl-link-initializer-05')
add_plain_test(shaders, 'glsl-link-initializer-06')
fpgeneric = Group()
def add_fpgeneric(name):
......
......@@ -80,6 +80,12 @@ IF (NOT MSVC)
add_executable (glsl-vs-raytrace-bug26691 glsl-vs-raytrace-bug26691.c)
ENDIF (NOT MSVC)
add_executable (glsl-vs-sqrt-zero glsl-vs-sqrt-zero.c)
add_executable (glsl-link-initializer-01 glsl-link-initializer-01.c)
add_executable (glsl-link-initializer-02 glsl-link-initializer-02.c)
add_executable (glsl-link-initializer-03 glsl-link-initializer-03.c)
add_executable (glsl-link-initializer-04 glsl-link-initializer-04.c)
add_executable (glsl-link-initializer-05 glsl-link-initializer-05.c)
add_executable (glsl-link-initializer-06 glsl-link-initializer-06.c)
add_executable (vp-address-01 vp-address-01.c)
add_executable (vp-address-02 vp-address-02.c)
add_executable (vp-address-03 vp-address-03.c)
......
/*
* 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.
*/
/**
* \file glsl-link-initializer-01.c
* Test conflicting variable initializers.
*
* Each of the 3 shaders involved in this test have a global variable called
* \c global_variable. Two of the shaders have (differing) initializers for
* this variable, and the other lacks an initalizer. The test verifies that
* linking the 3 shaders together results in an error due to the conflicting
* initializer.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[3];
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01b.vert");
vert[2] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01c.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glAttachShader(prog, vert[2]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (ok)
fprintf(stderr,
"Program should have failed linking, but "
"it was (incorrectly) successful.\n");
piglit_report_result((!ok) ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
float global_variable;
void main()
{
gl_Position = gl_Vertex;
}
float global_variable = 1.0;
/* This works around a bug in Apple's GLSL compiler. Their compiler won't allow
* a shader doesn't have any executable code.
*/
void apple_work_around1() {}
float global_variable = 2.0;
/* This works around a bug in Apple's GLSL compiler. Their compiler won't allow
* a shader doesn't have any executable code.
*/
void apple_work_around2() {}
/*
* 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.
*/
/**
* \file glsl-link-initializer-02.c
* Test conflicting constant initializers.
*
* Each of the 2 shaders involved in this test have a global constant called
* \c global_const. Each has a different initializer for the constant. The
* test verifies that linking the shaders together results in an error due to
* the conflicting initializer.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[2];
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-02a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-02b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (ok)
fprintf(stderr,
"Program should have failed linking, but "
"it was (incorrectly) successful.\n");
piglit_report_result((!ok) ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
const float global_constant = 1.0;
void main()
{
gl_Position = gl_Vertex;
}
const float global_constant = 2.0;
/* This works around a bug in Apple's GLSL compiler. Their compiler won't allow
* a shader doesn't have any executable code.
*/
void apple_work_around2() {}
/*
* 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.
*/
/**
* \file glsl-link-initializer-03.c
* Test linking a single shader into two programs.
*
* Each of the 3 shaders involved in this test have a global variable called
* \c global_variable. Two of the shaders have (differing) initializers for
* this variable, and the other lacks an initalizer. The test verifies that
* the shader lacking an initializer can successfully be linked with each of
* the shaders that have initalizers.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[3];
GLint prog_a;
GLint prog_b;
GLint a;
GLint b;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01b.vert");
vert[2] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-01c.vert");
prog_a = piglit_link_simple_program(vert[0], vert[1]);
prog_b = piglit_link_simple_program(vert[0], vert[2]);
glGetProgramiv(prog_a, GL_LINK_STATUS, &a);
glGetProgramiv(prog_b, GL_LINK_STATUS, &b);
piglit_report_result((a && b) ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
/*
* 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.
*/
/**
* \file glsl-link-initializer-04.c
* Test non-conflicting variable initializers.
*
* Each of the 2 shaders involved in this test have a global variable called
* \c global_variable. Each has the same initializer for the variable. The
* test verifies that linking the shaders together is successful.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[3];
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-04a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-04b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
piglit_report_result(ok ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
float global_variable = 1.0;
/* This works around a bug in Apple's GLSL compiler. Their compiler won't allow
* a shader doesn't have any executable code.
*/
void apple_work_around1() {}
float global_variable = 1.0;
void main()
{
gl_Position = gl_Vertex;
}
/*
* 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.
*/
/**
* \file glsl-link-initializer-05.c
* Test variables with complex non-conflicting initializers.
*
* Each of the 2 shaders involved in this test have a global variable called
* \c global_variable. Each has the same initializer for the variable. The
* test verifies that linking the shaders together is successful.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[3];
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-05a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-05b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
piglit_report_result(ok ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
uniform float angle;
uniform float scale;
float global_variable = sin(angle) * scale;
/* This works around a bug in Apple's GLSL compiler. Their compiler won't allow
* a shader doesn't have any executable code.
*/
void apple_work_around1() {}
uniform float angle;
uniform float scale;
float global_variable = sin(angle) * scale;
void main()
{
gl_Position = gl_Vertex;
}
/*
* 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.
*/
/**
* \file glsl-link-initializer-05.c
* Test variables with complex non-conflicting initializers.
*
* Each of the 2 shaders involved in this test have a global variable called
* \c global_variable. Each has the same initializer for the variable. The
* test verifies that linking the shaders together is successful.
*
* \author Ian Romanick
*/
#include "piglit-util.h"
int piglit_width = 100, piglit_height = 100;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAILURE;
}
void piglit_init(int argc, char **argv)
{
GLint vert[3];
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-06a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-link-initializer-06b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (ok)
fprintf(stderr,
"Program should have failed linking, but "
"it was (incorrectly) successful.\n");
piglit_report_result((!ok) ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
uniform float angle;
uniform float scale;
float global_variable = cos(angle) * scale;
float function(void)
{
return global_variable;
}
\ No newline at end of file
uniform float angle;
uniform float scale;
float global_variable = scale * sin(angle);
float function(void);
void main()
{
gl_Position = gl_Vertex * global_variable * function();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment