Commit 2ef00f96 authored by Ian Romanick's avatar Ian Romanick

Add several tests for GL_ARB_explicit_attrib_location

parent 2f0a38ed
......@@ -570,6 +570,11 @@ add_plain_test(shaders, 'glsl-fwidth')
add_plain_test(shaders, 'glsl-lod-bias')
add_plain_test(shaders, 'vp-ignore-input')
add_plain_test(shaders, 'glsl-empty-vs-no-fs')
add_plain_test(shaders, 'glsl-explicit-location-01')
add_plain_test(shaders, 'glsl-explicit-location-02')
add_plain_test(shaders, 'glsl-explicit-location-03')
add_plain_test(shaders, 'glsl-explicit-location-04')
add_plain_test(shaders, 'glsl-explicit-location-05')
add_plain_test(shaders, 'glsl-useprogram-displaylist')
add_plain_test(shaders, 'glsl-vs-point-size')
add_plain_test(shaders, 'glsl-light-model')
......
......@@ -50,6 +50,11 @@ add_executable (glsl-arb-fragment-coord-conventions-define glsl-arb-fragment-coo
add_executable (glsl-bindattriblocation glsl-bindattriblocation.c)
add_executable (glsl-bug-22603 glsl-bug-22603.c)
add_executable (glsl-dlist-getattriblocation glsl-dlist-getattriblocation.c)
add_executable (glsl-explicit-location-01 glsl-explicit-location-01.c)
add_executable (glsl-explicit-location-02 glsl-explicit-location-02.c)
add_executable (glsl-explicit-location-03 glsl-explicit-location-03.c)
add_executable (glsl-explicit-location-04 glsl-explicit-location-04.c)
add_executable (glsl-explicit-location-05 glsl-explicit-location-05.c)
add_executable (glsl-getattriblocation glsl-getattriblocation.c)
add_executable (glsl-getactiveuniform-array-size glsl-getactiveuniform-array-size.c)
add_executable (glsl-getactiveuniform-count glsl-getactiveuniform-count.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-explicit-attrib-location-01.c
* Basic test of GL_ARB_explicit_attrib_location
*
* Load a shader that uses the location layout qualifier on an attribute.
* Verify that the attribute is assigned that location.
*
* \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;
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
piglit_require_extension("GL_ARB_explicit_attrib_location");
vert = piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-01.vert");
prog = glCreateProgram();
glAttachShader(prog, vert);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (ok) {
GLint loc = glGetAttribLocation(prog, "vertex");
if (loc != 0) {
fprintf(stderr,
"Expected location of 'vertex' to be 0, got "
"%d instead.\n", loc);
ok = GL_FALSE;
}
}
piglit_report_result(ok ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
#extension GL_ARB_explicit_attrib_location: require
#ifdef GL_ARB_explicit_attrib_location
layout(location = 0) attribute vec4 vertex;
void main()
{
gl_Position = vertex;
}
#endif
/*
* 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-explicit-attrib-location-02.c
* Test GL_ARB_explicit_attrib_location with glBindAttribLocation
*
* Load a shader that uses the location layout qualifier on an attribute.
* Set the attribute to a different location by calling \c glBindAttribLocation.
* Verify that the attribute is assigned to the location specified in the
* shader.
*
* \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;
GLint prog;
GLint loc;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
piglit_require_extension("GL_ARB_explicit_attrib_location");
vert = piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-01.vert");
prog = glCreateProgram();
glAttachShader(prog, vert);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (!ok)
piglit_report_result(PIGLIT_FAILURE);
glBindAttribLocation(prog, 3, "vertex");
ok = piglit_link_check_status(prog);
if (!ok)
piglit_report_result(PIGLIT_FAILURE);
loc = glGetAttribLocation(prog, "vertex");
if (loc != 0) {
fprintf(stderr,
"Expected location of 'vertex' to be 0, got "
"%d instead.\n", loc);
piglit_report_result(PIGLIT_FAILURE);
}
piglit_report_result(PIGLIT_SUCCESS);
}
/*
* 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-explicit-attrib-location-03.c
* Test GL_ARB_explicit_attrib_location with conflicting locations
*
* Link two vertex shaders that specify differing explicit locations for the
* same attribute. Verify that a link error is generated.
*
* \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;
}
/**
* Don't use piglit_link_check_status because it will log a message to stderr
* when the link fails. Since this test wants the link to fail, logging an
* error message will cause the test to be listed as "warn" instead of "pass".
*/
GLboolean
link_check_status(GLint prog)
{
GLint ok;
glGetProgramiv(prog, GL_LINK_STATUS, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size);
glGetProgramInfoLog(prog, size, NULL, info);
printf("Failed to link: %s\n", info);
free(info);
}
return ok;
}
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);
}
piglit_require_extension("GL_ARB_explicit_attrib_location");
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-03a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-03b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = link_check_status(prog);
if (ok)
fprintf(stderr,
"Linking with conflicting explicit locations "
"succeeded when it should have failed.\n");
piglit_report_result(!ok ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
#extension GL_ARB_explicit_attrib_location: require
layout(location = 0) attribute vec4 vertex;
layout(location = 1) attribute vec3 color;
vec3 function(void);
void main()
{
gl_Position = vertex;
gl_FrontColor = vec4(color + function(), 1.0);
}
#extension GL_ARB_explicit_attrib_location: require
layout(location = 2) attribute vec3 color;
vec3 function(void)
{
return color * 3.0;
}
/*
* 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-explicit-location-04.c
* Test GL_ARB_explicit_attrib_location with an invalid location
*
* \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;
}
/**
* Don't use piglit_link_check_status because it will log a message to stderr
* when the link fails. Since this test wants the link to fail, logging an
* error message will cause the test to be listed as "warn" instead of "pass".
*/
GLboolean
link_check_status(GLint prog)
{
GLint ok;
glGetProgramiv(prog, GL_LINK_STATUS, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size);
glGetProgramInfoLog(prog, size, NULL, info);
printf("Failed to link: %s\n", info);
free(info);
}
return ok;
}
void piglit_init(int argc, char **argv)
{
GLint vert;
GLint prog;
GLboolean ok;
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
}
piglit_require_extension("GL_ARB_explicit_attrib_location");
vert = piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-04.vert");
prog = glCreateProgram();
glAttachShader(prog, vert);
glLinkProgram(prog);
ok = link_check_status(prog);
if (ok)
fprintf(stderr,
"Linking with invalid explicit attribute location "
"succeeded when it should have failed.\n");
piglit_report_result(!ok ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
}
#extension GL_ARB_explicit_attrib_location: require
layout(location = 1000) attribute vec4 vertex;
void main()
{
gl_Position = 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-explicit-attrib-location-03.c
* Test GL_ARB_explicit_attrib_location with conflicting locations
*
* Link two vertex shaders that specify differing explicit locations for the
* same attribute. Verify that a link error is generated.
*
* \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);
}
piglit_require_extension("GL_ARB_explicit_attrib_location");
vert[0] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-05a.vert");
vert[1] =
piglit_compile_shader(GL_VERTEX_SHADER,
"shaders/glsl-explicit-location-05b.vert");
prog = glCreateProgram();
glAttachShader(prog, vert[0]);
glAttachShader(prog, vert[1]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (!ok)
piglit_report_result(PIGLIT_FAILURE);
glDeleteProgram(prog);
prog = glCreateProgram();
glAttachShader(prog, vert[1]);
glAttachShader(prog, vert[0]);
glLinkProgram(prog);
ok = piglit_link_check_status(prog);
if (!ok)
piglit_report_result(PIGLIT_FAILURE);
piglit_report_result(PIGLIT_SUCCESS);
}
attribute vec4 vertex;
void main()
{
gl_Position = vertex;
}
#extension GL_ARB_explicit_attrib_location: require
layout(location = 0) attribute vec4 vertex;
vec4 function(void)
{
return vec4(1.0);
}
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