Mesa (master): glsl/linker: produce gl_shader_program Geom.Invocations
Jordan Justen
jljusten at kemper.freedesktop.org
Thu Feb 20 19:19:39 UTC 2014
Module: Mesa
Branch: master
Commit: 313402048fdad05d3401340129b9e412878d8957
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=313402048fdad05d3401340129b9e412878d8957
Author: Jordan Justen <jordan.l.justen at intel.com>
Date: Sat Jan 25 02:17:21 2014 -0800
glsl/linker: produce gl_shader_program Geom.Invocations
Grab the parsed invocation count, check for consistency
during linking, and finally save the result in
gl_shader_program Geom.Invocations.
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/glsl/glsl_parser_extras.cpp | 4 ++++
src/glsl/linker.cpp | 18 ++++++++++++++++++
src/mesa/main/mtypes.h | 9 +++++++++
3 files changed, 31 insertions(+)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index f102b11..416acb9 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1374,6 +1374,10 @@ set_shader_inout_layout(struct gl_shader *shader,
} else {
shader->Geom.OutputType = PRIM_UNKNOWN;
}
+
+ shader->Geom.Invocations = 0;
+ if (state->in_qualifier->flags.q.invocations)
+ shader->Geom.Invocations = state->in_qualifier->invocations;
break;
case MESA_SHADER_COMPUTE:
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 7d605d7..f6b2661 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1206,6 +1206,7 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
unsigned num_shaders)
{
linked_shader->Geom.VerticesOut = 0;
+ linked_shader->Geom.Invocations = 0;
linked_shader->Geom.InputType = PRIM_UNKNOWN;
linked_shader->Geom.OutputType = PRIM_UNKNOWN;
@@ -1259,6 +1260,18 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
}
linked_shader->Geom.VerticesOut = shader->Geom.VerticesOut;
}
+
+ if (shader->Geom.Invocations != 0) {
+ if (linked_shader->Geom.Invocations != 0 &&
+ linked_shader->Geom.Invocations != shader->Geom.Invocations) {
+ linker_error(prog, "geometry shader defined with conflicting "
+ "invocation count (%d and %d)\n",
+ linked_shader->Geom.Invocations,
+ shader->Geom.Invocations);
+ return;
+ }
+ linked_shader->Geom.Invocations = shader->Geom.Invocations;
+ }
}
/* Just do the intrastage -> interstage propagation right now,
@@ -1285,6 +1298,11 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
return;
}
prog->Geom.VerticesOut = linked_shader->Geom.VerticesOut;
+
+ if (linked_shader->Geom.Invocations == 0)
+ linked_shader->Geom.Invocations = 1;
+
+ prog->Geom.Invocations = linked_shader->Geom.Invocations;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 34b9e6d..e7e39ee 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2419,6 +2419,11 @@ struct gl_shader
struct {
GLint VerticesOut;
/**
+ * 0 - Invocations count not declared in shader, or
+ * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
+ */
+ GLint Invocations;
+ /**
* GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
* GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
* shader.
@@ -2627,6 +2632,10 @@ struct gl_shader_program
struct {
GLint VerticesIn;
GLint VerticesOut;
+ /**
+ * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
+ */
+ GLint Invocations;
GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,
GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
More information about the mesa-commit
mailing list