summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-11-15 04:37:50 -0800
committerKenneth Graunke <[email protected]>2017-01-06 15:55:37 -0800
commit8b5749f65ac434961308ccb579fb8a816e4f29d5 (patch)
tree0142e966f4bef51c9e5fdf065fcbdc7a0fc09a1e
parent6aa5cb34d03765b7be8611aa516bc201bd337f73 (diff)
glsl: Override the # of varying slots for ClipDistance and TessLevel*.
Right now, this shouldn't have any effect, as all drivers use LowerClipDist and LowerTessFactors to turn the float[] arrays into vectors. However, it should help make it possible for drivers to avoid that lowering. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/compiler/glsl/ir.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index a77b9a9d857..69f1f1a7e5d 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -1621,6 +1621,24 @@ ir_variable::get_extension_warning() const
unsigned
ir_variable::count_attribute_slots(bool is_vertex_stage) const
{
+ /* GLSL contains several built-in arrays that control fixed-function
+ * hardware, and are somewhat special. Clip distances and tessellation
+ * factors are exposed as float[] arrays, but typically are packed
+ * tightly. We want to expose these as taking a single varying slot
+ * and let drivers handle laying them out appropriately.
+ *
+ * Skip this override if the arrays were lowered to vectors.
+ */
+ if (type->without_array()->is_scalar() &&
+ (data.mode == ir_var_shader_in || data.mode == ir_var_shader_out) &&
+ (data.location == VARYING_SLOT_CLIP_DIST0 ||
+ data.location == VARYING_SLOT_CULL_DIST0 ||
+ data.location == VARYING_SLOT_TESS_LEVEL_OUTER ||
+ data.location == VARYING_SLOT_TESS_LEVEL_INNER)) {
+ return type->length / 4;
+ }
+
+ /* For normal variables, simply consult the type. */
bool is_vs_input = is_vertex_stage && this->data.mode == ir_var_shader_in;
return this->type->count_attribute_slots(is_vs_input);
}