summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/link_varyings.cpp
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-11-05 09:31:21 -0400
committerIlia Mirkin <[email protected]>2016-11-09 20:26:48 -0500
commit73f53c097a6bbd07572d5e46af4893d17ff8af93 (patch)
treec224c022da56f96956f2c898ece75d2fc66f0c2f /src/compiler/glsl/link_varyings.cpp
parent885c78801785701fdca0217a7b0f992f26115ee4 (diff)
glsl: record number of components used in each slot for varying packing
Instead of packing varyings into vec4's, keep track of how many components each slot uses and create varyings with matching types. This ensures that we don't end up using more components than the orginal shader, which is especially important for geometry shader output limits. This comes up for NVIDIA hw, where the limit is 1024 output components for a GS, and the hardware complains *loudly* if you even think about going over. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl/link_varyings.cpp')
-rw-r--r--src/compiler/glsl/link_varyings.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 43204a7c3f2..87d7c91604e 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1217,6 +1217,7 @@ public:
~varying_matches();
void record(ir_variable *producer_var, ir_variable *consumer_var);
unsigned assign_locations(struct gl_shader_program *prog,
+ uint8_t *components,
uint64_t reserved_slots);
void store_locations() const;
@@ -1482,6 +1483,7 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
*/
unsigned
varying_matches::assign_locations(struct gl_shader_program *prog,
+ uint8_t *components,
uint64_t reserved_slots)
{
/* If packing has been disabled then we cannot safely sort the varyings by
@@ -1585,6 +1587,12 @@ varying_matches::assign_locations(struct gl_shader_program *prog,
var->name);
}
+ if (slot_end < MAX_VARYINGS_INCL_PATCH * 4u) {
+ for (unsigned j = *location / 4u; j < slot_end / 4u; j++)
+ components[j] = 4;
+ components[slot_end / 4u] = (slot_end & 3) + 1;
+ }
+
this->matches[i].generic_location = *location;
*location = slot_end + 1;
@@ -2203,7 +2211,9 @@ assign_varying_locations(struct gl_context *ctx,
}
}
- const unsigned slots_used = matches.assign_locations(prog, reserved_slots);
+ uint8_t components[MAX_VARYINGS_INCL_PATCH] = {0};
+ const unsigned slots_used = matches.assign_locations(
+ prog, components, reserved_slots);
matches.store_locations();
for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
@@ -2263,13 +2273,13 @@ assign_varying_locations(struct gl_context *ctx,
}
if (producer) {
- lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_out,
+ lower_packed_varyings(mem_ctx, slots_used, components, ir_var_shader_out,
0, producer, disable_varying_packing,
xfb_enabled);
}
if (consumer) {
- lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_in,
+ lower_packed_varyings(mem_ctx, slots_used, components, ir_var_shader_in,
consumer_vertices, consumer,
disable_varying_packing, xfb_enabled);
}