Commit c8aa5747 authored by Andres Gomez's avatar Andres Gomez

arb_separate_shader_objects: add gl_PerVertex tests

From the ARB_separate_shader_objects spec v.25:

  " To use any built-in input or output in the gl_PerVertex and
    gl_PerFragment blocks in separable program objects, shader code
    must redeclare those blocks prior to use.  A separable program
    will fail to link if:

      * it contains multiple shaders of a single type with different
        redeclarations of these built-in input and output blocks; or

      * any shader uses a built-in block member not found in the
        redeclaration of that block."

Additionally, added the "SEPARABLE PROGRAM ENABLED" directive to the
shader_runner
Signed-off-by: Andres Gomez's avatarAndres Gomez <agomez@igalia.com>
Acked-by: 's avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: 's avatarIan Romanick <ian.d.romanick@intel.com>
parent a845f469
......@@ -152,6 +152,7 @@ static bool vbo_present = false;
static bool link_ok = false;
static bool prog_in_use = false;
static bool sso_in_use = false;
static bool separable_program = false;
static bool glsl_in_use = false;
static bool force_glsl = false;
static bool spirv_in_use = false;
......@@ -1175,6 +1176,11 @@ process_requirement(const char *line)
piglit_set_rlimit(lim);
} else if (parse_str(line, "SSO", &line) &&
parse_str(line, "ENABLED", NULL)) {
if (separable_program) {
printf("SSO and SEPARABLE PROGRAM directives are incompatible.\n");
return PIGLIT_FAIL;
}
const char *const ext_name = gl_version.es
? "GL_EXT_separate_shader_objects"
: "GL_ARB_separate_shader_objects";
......@@ -1186,6 +1192,23 @@ process_requirement(const char *line)
sso_in_use = true;
glGenProgramPipelines(1, &pipeline);
} else if (parse_str(line, "SEPARABLE PROGRAM", &line) &&
parse_str(line, "ENABLED", NULL)) {
if (sso_in_use) {
printf("SSO and SEPARABLE PROGRAM directives are incompatible.\n");
return PIGLIT_FAIL;
}
const char *const ext_name = gl_version.es
? "GL_EXT_separate_shader_objects"
: "GL_ARB_separate_shader_objects";
const unsigned min_version = gl_version.es
? 31 : 41;
if (gl_version.num < min_version)
piglit_require_extension(ext_name);
separable_program = true;
} else if (parse_str(line, "SPIRV", &line)) {
spirv_replaces_glsl = !force_glsl;
......@@ -1454,8 +1477,12 @@ link_and_use_shaders(void)
if (result != PIGLIT_PASS)
goto cleanup;
if (!sso_in_use)
if (!sso_in_use) {
if (separable_program)
glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
glLinkProgram(prog);
}
if (!sso_in_use) {
if (!program_binary_save_restore(false))
......@@ -4694,6 +4721,7 @@ piglit_init(int argc, char **argv)
link_ok = false;
prog_in_use = false;
sso_in_use = false;
separable_program = false;
prog_err_info = NULL;
vao = 0;
......
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;
void main() {
gl_out[gl_InvocationID].gl_ClipDistance[0] = float(1.0);
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(triangles) in;
out vec4 tes_color;
void main()
{
tes_color = vec4(gl_in[0].gl_ClipDistance[0]);
}
[fragment shader]
#version 150
in vec4 tes_color;
out vec4 color;
void main()
{
color = tes_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;
void main() {
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(triangles) in;
void main()
{
gl_ClipDistance[0] = float(1.0);
}
[geometry shader]
#version 150
layout (points) in;
layout (points, max_vertices = 1) out;
out vec4 g_color;
void main()
{
g_color = vec4(gl_in[0].gl_ClipDistance[0]);
EmitVertex();
}
[fragment shader]
#version 150
in vec4 g_color;
out vec4 color;
void main()
{
color = g_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
gl_ClipDistance[0] = float(1.0);
}
[geometry shader]
#version 150
layout (points) in;
layout (points, max_vertices = 1) out;
out vec4 g_color;
void main()
{
g_color = vec4(gl_in[0].gl_ClipDistance[0]);
EmitVertex();
}
[fragment shader]
#version 150
in vec4 g_color;
out vec4 color;
void main()
{
color = g_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
gl_ClipDistance[0] = float(1.0);
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;
void main() {
if (gl_in[0].gl_ClipDistance[0] == 1.0) {
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
} else {
gl_TessLevelOuter = float[4](0.0, 0.0, 0.0, 0.0);
gl_TessLevelInner = float[2](0.0, 0.0);
}
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(triangles) in;
out vec4 tes_color;
void main()
{
tes_color = vec4(gl_TessLevelOuter[0]);
}
[fragment shader]
#version 150
in vec4 tes_color;
out vec4 color;
void main()
{
color = tes_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
GL_ARB_cull_distance
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
#extension GL_ARB_cull_distance: enable
layout(vertices = 3) out;
void main() {
gl_out[gl_InvocationID].gl_CullDistance[0] = float(1.0);
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
#extension GL_ARB_cull_distance: enable
layout(triangles) in;
out vec4 tes_color;
void main()
{
tes_color = vec4(gl_in[0].gl_CullDistance[0]);
}
[fragment shader]
#version 150
in vec4 tes_color;
out vec4 color;
void main()
{
color = tes_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
GL_ARB_cull_distance
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;
void main() {
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
#extension GL_ARB_cull_distance: enable
layout(triangles) in;
void main()
{
gl_CullDistance[0] = float(1.0);
}
[geometry shader]
#version 150
#extension GL_ARB_cull_distance: enable
layout (points) in;
layout (points, max_vertices = 1) out;
out vec4 g_color;
void main()
{
g_color = vec4(gl_in[0].gl_CullDistance[0]);
EmitVertex();
}
[fragment shader]
#version 150
in vec4 g_color;
out vec4 color;
void main()
{
color = g_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_cull_distance
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
#extension GL_ARB_cull_distance: enable
void main()
{
gl_CullDistance[0] = float(1.0);
}
[geometry shader]
#version 150
#extension GL_ARB_cull_distance: enable
layout (points) in;
layout (points, max_vertices = 1) out;
out vec4 g_color;
void main()
{
g_color = vec4(gl_in[0].gl_CullDistance[0]);
EmitVertex();
}
[fragment shader]
#version 150
in vec4 g_color;
out vec4 color;
void main()
{
color = g_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
GL_ARB_cull_distance
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
#extension GL_ARB_cull_distance: enable
void main()
{
gl_CullDistance[0] = float(1.0);
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
#extension GL_ARB_cull_distance: enable
layout(vertices = 3) out;
void main() {
if (gl_in[0].gl_CullDistance[0] == 1.0) {
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
} else {
gl_TessLevelOuter = float[4](0.0, 0.0, 0.0, 0.0);
gl_TessLevelInner = float[2](0.0, 0.0);
}
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(triangles) in;
out vec4 tes_color;
void main()
{
tes_color = vec4(gl_TessLevelOuter[0]);
}
[fragment shader]
#version 150
in vec4 tes_color;
out vec4 color;
void main()
{
color = tes_color;
}
[test]
link error
// From the ARB_separate_shader_objects spec v.25:
//
// "To use any built-in input or output in the gl_PerVertex and
// gl_PerFragment blocks in separable program objects, shader code
// must redeclare those blocks prior to use. A separable program
// will fail to link if:
//
// * it contains multiple shaders of a single type with different
// redeclarations of these built-in input and output blocks; or
//
// * any shader uses a built-in block member not found in the
// redeclaration of that block."
[require]
GLSL >= 1.50
GL_ARB_separate_shader_objects
GL_ARB_tessellation_shader
SEPARABLE PROGRAM ENABLED
[vertex shader]
#version 150
void main()
{
}
[tessellation control shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;
void main() {
gl_out[gl_InvocationID].gl_PointSize = float(1.0);
gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
gl_TessLevelInner = float[2](1.0, 1.0);
}
[tessellation evaluation shader]
#version 150
#extension GL_ARB_tessellation_shader: require
layout(triangles) in;
out vec4 tes_color;
void main()
{
tes_color = vec4(gl_in[0].gl_PointSize);
}
[fragment shader]
#version 150
in vec4 tes_color;
out vec4 color;
void main()
{
color = tes_color;
}