Module: Mesa
Branch: master
Commit: 0a58b258caf67aa85c49bb4160b48a61b535e2be
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a58b258caf67aa85c49bb4160b48a61b535e2be

Author: Nicolai Hähnle <nicolai.haeh...@amd.com>
Date:   Mon Nov 21 10:36:50 2016 +0100

st/glsl_to_tgsi: swizzle PROGRAM_OUTPUTs correctly in src_register translation

This is required for reading directly from fragment shader stencil and depth
outputs.

Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 978dc46..8a247ea 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5383,9 +5383,19 @@ src_register(struct st_translate *t, const st_src_reg 
*reg)
 
    case PROGRAM_TEMPORARY:
    case PROGRAM_ARRAY:
-   case PROGRAM_OUTPUT:
       return ureg_src(dst_register(t, reg->file, reg->index, reg->array_id));
 
+   case PROGRAM_OUTPUT: {
+      struct ureg_dst dst = dst_register(t, reg->file, reg->index, 
reg->array_id);
+      assert(dst.WriteMask != 0);
+      unsigned shift = ffs(dst.WriteMask) - 1;
+      return ureg_swizzle(ureg_src(dst),
+                          shift,
+                          MIN2(shift + 1, 3),
+                          MIN2(shift + 2, 3),
+                          MIN2(shift + 3, 3));
+   }
+
    case PROGRAM_UNIFORM:
       assert(reg->index >= 0);
       return reg->index < t->num_constants ?

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

Reply via email to