[Mesa-dev] [PATCH 14/27] glsl: pack fragment shader outputs with component layout qualifiers

Timothy Arceri timothy.arceri at collabora.com
Thu Mar 31 10:57:49 UTC 2016


This actually tries to pack any output with an explicit location we
just let the optimisiation passes clean up the extra assignments if
there was no actual packing done.

V2: fix comment (Anuj)

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 src/compiler/glsl/link_varyings.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index ac99e9a..331d0d4 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -2217,6 +2217,23 @@ assign_varying_locations(struct gl_context *ctx,
    }
 
    if (consumer) {
+      if (consumer->Stage == MESA_SHADER_FRAGMENT) {
+         /* Since we only pack frag shader outputs with an explicit location
+          * we only need to count those outputs.
+          */
+         const uint64_t reserved_slots =
+            reserved_varying_slot(consumer, ir_var_shader_out,
+                                  FRAG_RESULT_DATA0);
+
+         /* Pack frag outputs with the component layout qualifier */
+         unsigned frag_outs = _mesa_bitcount_64(reserved_slots);
+         if (frag_outs > 0)
+            lower_packed_varyings(mem_ctx, frag_outs,
+                                  ir_var_shader_out, 0, consumer,
+                                  FRAG_RESULT_DATA0, true, xfb_enabled,
+                                  ctx->Extensions.ARB_enhanced_layouts);
+      }
+
       lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_in,
                             consumer_vertices, consumer, VARYING_SLOT_VAR0,
                             disable_varying_packing, xfb_enabled,
-- 
2.5.5



More information about the mesa-dev mailing list