summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-09-17 09:42:02 -0700
committerPaul Berry <[email protected]>2011-09-23 13:28:51 -0700
commit1ad54ae0b1713e399c5db43d0eba87861075b4c7 (patch)
treeade022dea53ca82dffd50fde2cfdda3bdc240e68
parentc06e32596735074536b0e613cbddb1c5fd7b367a (diff)
mesa: Add a flag to indicate whether a program uses gl_ClipDistance.
GLSL 1.30 requires us to use gl_ClipDistance for clipping if the vertex shader contains a static write to it, and otherwise use user-defined clipping planes. Since the driver needs to behave differently in these two cases, we need a flag to record whether the shader has written to gl_ClipDistance. The new flag is called UsesClipDistance. We initially store it in gl_shader_program (since that is the data structure that is available when we check to see whethe gl_ClipDistance was written to), and we later copy it to a flag with the same name in gl_vertex_program, since that is a more convenient place for the driver to access it (in i965, at least). Reviewed-by: Eric Anholt <[email protected]> Tested-by: Brian Paul <[email protected]>
-rw-r--r--src/glsl/linker.cpp5
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ceb49fd5b20..d802a0a9bae 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -244,7 +244,9 @@ count_attribute_slots(const glsl_type *t)
/**
- * Verify that a vertex shader executable meets all semantic requirements
+ * Verify that a vertex shader executable meets all semantic requirements.
+ *
+ * Also sets prog->Vert.UsesClipDistance as a side effect.
*
* \param shader Vertex shader executable to be verified
*/
@@ -279,6 +281,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
"and `gl_ClipDistance'\n");
return false;
}
+ prog->Vert.UsesClipDistance = clip_distance.variable_found();
}
return true;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 74e7e2adf68..81565c6c2ea 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1876,6 +1876,7 @@ struct gl_vertex_program
struct gl_program Base; /**< base class */
GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */
GLboolean IsPositionInvariant;
+ GLboolean UsesClipDistance;
};
@@ -2161,6 +2162,11 @@ struct gl_shader_program
GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
} Geom;
+ /** Vertex shader state - copied into gl_vertex_program at link time */
+ struct {
+ GLboolean UsesClipDistance; /**< True if gl_ClipDistance is written to. */
+ } Vert;
+
/* post-link info: */
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5e565e4ed08..7b2c69fdbdb 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3291,6 +3291,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
switch (prog->_LinkedShaders[i]->Type) {
case GL_VERTEX_SHADER:
+ ((struct gl_vertex_program *)linked_prog)->UsesClipDistance
+ = prog->Vert.UsesClipDistance;
_mesa_reference_vertprog(ctx, &prog->VertexProgram,
(struct gl_vertex_program *)linked_prog);
ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,