summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_varyings.cpp
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-06-13 03:17:22 +0200
committerMarek Olšák <[email protected]>2013-07-02 17:02:14 +0200
commit3c555827c3e2fdb84ee4b4b8fd8296985cbb1fda (patch)
tree344bc224a6b3893dd4b2b7a516f89f6c52857886 /src/glsl/link_varyings.cpp
parent284d9549123d7a5417310d359c2c46a4317e47bb (diff)
glsl/linker: check against varying limit after unused varyings are eliminated
We counted even the varyings which were later eliminated, which was suboptimal. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/link_varyings.cpp')
-rw-r--r--src/glsl/link_varyings.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 4fdbdc19942..5abc61293ae 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1113,16 +1113,12 @@ assign_varying_locations(struct gl_context *ctx,
}
}
- unsigned varying_vectors = 0;
-
if (consumer) {
foreach_list(node, consumer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_shader_in))
- continue;
-
- if (var->is_unmatched_generic_inout) {
+ if (var && var->mode == ir_var_shader_in &&
+ var->is_unmatched_generic_inout) {
if (prog->Version <= 120) {
/* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
*
@@ -1148,15 +1144,32 @@ assign_varying_locations(struct gl_context *ctx,
* value is written by the previous stage.
*/
var->mode = ir_var_auto;
- } else if (is_varying_var(consumer->Type, var)) {
- /* The packing rules are used for vertex shader inputs are also
- * used for fragment shader inputs.
- */
- varying_vectors += count_attribute_slots(var->type);
}
}
}
+ return true;
+}
+
+bool
+check_against_varying_limit(struct gl_context *ctx,
+ struct gl_shader_program *prog,
+ gl_shader *consumer)
+{
+ unsigned varying_vectors = 0;
+
+ foreach_list(node, consumer->ir) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if (var && var->mode == ir_var_shader_in &&
+ is_varying_var(consumer->Type, var)) {
+ /* The packing rules used for vertex shader inputs are also
+ * used for fragment shader inputs.
+ */
+ varying_vectors += count_attribute_slots(var->type);
+ }
+ }
+
if (ctx->API == API_OPENGLES2 || prog->IsES) {
if (varying_vectors > ctx->Const.MaxVarying) {
if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) {