[Mesa-dev] [PATCH 37/46] glsl: analyze TES usage of gl_ClipDistance
Marek Olšák
maraeo at gmail.com
Tue Jun 16 16:01:33 PDT 2015
From: Chris Forbes <chrisf at ijw.co.nz>
---
src/glsl/linker.cpp | 19 +++++++++++++++++++
src/mesa/main/mtypes.h | 7 +++++++
src/mesa/main/shaderapi.c | 1 +
3 files changed, 27 insertions(+)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 5ee84fc..1315867 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -629,6 +629,17 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
&prog->Vert.ClipDistanceArraySize);
}
+void
+validate_tess_eval_shader_executable(struct gl_shader_program *prog,
+ struct gl_shader *shader)
+{
+ if (shader == NULL)
+ return;
+
+ analyze_clip_usage(prog, shader, &prog->TessEval.UsesClipDistance,
+ &prog->TessEval.ClipDistanceArraySize);
+}
+
/**
* Verify that a fragment shader executable meets all semantic requirements
@@ -3115,6 +3126,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
case MESA_SHADER_VERTEX:
validate_vertex_shader_executable(prog, sh);
break;
+ case MESA_SHADER_TESS_CTRL:
+ /* nothing to be done */
+ break;
+ case MESA_SHADER_TESS_EVAL:
+ validate_tess_eval_shader_executable(prog, sh);
+ break;
case MESA_SHADER_GEOMETRY:
validate_geometry_shader_executable(prog, sh);
break;
@@ -3134,6 +3151,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (num_shaders[MESA_SHADER_GEOMETRY] > 0)
prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize;
+ else if (num_shaders[MESA_SHADER_TESS_EVAL] > 0)
+ prog->LastClipDistanceArraySize = prog->TessEval.ClipDistanceArraySize;
else if (num_shaders[MESA_SHADER_VERTEX] > 0)
prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;
else
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 25afd61..5de8e14 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2775,6 +2775,13 @@ struct gl_shader_program
/** GL_CW or GL_CCW */
GLenum VertexOrder;
bool PointMode;
+ /**
+ * True if gl_ClipDistance is written to. Copied into
+ * gl_tess_eval_program by _mesa_copy_linked_program_data().
+ */
+ GLboolean UsesClipDistance;
+ GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
+ 0 if not present. */
} TessEval;
/**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 3428680..0d7e21b 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2057,6 +2057,7 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
dst_tep->Spacing = src->TessEval.Spacing;
dst_tep->VertexOrder = src->TessEval.VertexOrder;
dst_tep->PointMode = src->TessEval.PointMode;
+ dst->UsesClipDistanceOut = src->TessEval.UsesClipDistance;
break;
}
case MESA_SHADER_GEOMETRY: {
--
2.1.0
More information about the mesa-dev
mailing list