Skip to content

Commit

Permalink
gs: Verify consistency checking of geometry shader input layouts.
Browse files Browse the repository at this point in the history
These tests verify that the implementation properly detects mismatches
between geometry shader input layout declarations, whether they occur
within the same compilation unit or within multiple compilation units.

Mismatches that occur within the same compilation unit should produce
a compile error.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
  • Loading branch information
stereotype441 committed Aug 16, 2013
1 parent 4bbc756 commit 61122ec
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
// includes the following examples of compile-time errors:
//
// // code sequence within one shader...
// in vec4 Color1[]; // size unknown
// ...Color1.length()...// illegal, length() unknown
// in vec4 Color2[2]; // size is 2
// ...Color1.length()...// illegal, Color1 still has no size
// in vec4 Color3[3]; // illegal, input sizes are inconsistent
// layout(lines) in; // legal, input size is 2, matching
// in vec4 Color4[3]; // illegal, contradicts layout
// ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
// layout(lines) in; // legal, matches other layout() declaration (*)
// layout(triangles) in;// illegal, does not match earlier layout() declaration
//
// This test verifies the case marked with (*), namely that no error
// results from declaring a geometry shader input layout that is
// consistent with a previously declared geometry shader input layout.
//
// [config]
// expect_result: pass
// glsl_version: 1.50
// check_link: false
// [end config]

#version 150

layout(lines) in;
layout(lines) in;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
// includes the following examples of compile-time errors:
//
// // code sequence within one shader...
// in vec4 Color1[]; // size unknown
// ...Color1.length()...// illegal, length() unknown
// in vec4 Color2[2]; // size is 2
// ...Color1.length()...// illegal, Color1 still has no size
// in vec4 Color3[3]; // illegal, input sizes are inconsistent
// layout(lines) in; // legal, input size is 2, matching
// in vec4 Color4[3]; // illegal, contradicts layout
// ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
// layout(lines) in; // legal, matches other layout() declaration
// layout(triangles) in;// illegal, does not match earlier layout() declaration (*)
//
// This test verifies the case marked with (*), namely that an error
// results from declaring a geometry shader input layout that is
// inconsistent with a previously declared geometry shader input
// layout.
//
// [config]
// expect_result: fail
// glsl_version: 1.50
// check_link: false
// [end config]

#version 150

layout(lines) in;
layout(triangles) in;
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
#
# At least one geometry shader (compilation unit) in a program must
# declare an input layout, and all geometry shader input layout
# declarations in a program must declare the same layout. It is not
# required that all geometry shaders in a program declare an input
# layout.
#
# This test verifies that a link error occurs if two compilation units
# declare conflicting layouts.

[require]
GLSL >= 1.50

[vertex shader]
#version 150

in vec4 vertex;
out vec4 vertex_to_gs;

void main()
{
vertex_to_gs = vertex;
}

[geometry shader]
#version 150

layout(lines) in;
layout(triangle_strip, max_vertices = 3) out;

void do_vertex(int i);

void main()
{
for (int i = 0; i < 2; i++)
do_vertex(i);
}

[geometry shader]
#version 150

layout(triangles) in;

in vec4 vertex_to_gs[3];

void do_vertex(int i)
{
gl_Position = vertex_to_gs[i];
EmitVertex();
}

[fragment shader]
#version 150

out vec4 color;

void main()
{
color = vec4(0.0, 1.0, 0.0, 1.0);
}

[test]
link error

0 comments on commit 61122ec

Please sign in to comment.