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.pho...@gmail.com>
Reviewed-by: Edward O'Callaghan <eocallag...@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 3dc916d..93757b8 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1867,6 +1867,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,
+                                  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.5.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to