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

Timothy Arceri timothy.arceri at collabora.com
Mon Dec 28 21:00:21 PST 2015


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.
---
 src/glsl/link_varyings.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 7f77f7c..9b434d2 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1900,6 +1900,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 inputs.
+          */
+         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,
+                                  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,
-- 
2.4.3



More information about the mesa-dev mailing list