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

Timothy Arceri timothy.arceri at collabora.com
Mon Dec 21 22:02:04 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 dd96c03..2908af7 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1849,6 +1849,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);
+      }
+
       remove_unused_shader_inputs_and_outputs(prog, consumer,
                                               ir_var_shader_in);
       lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_in,
-- 
2.4.3



More information about the mesa-dev mailing list