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

Author: Nicolai Hähnle <nicolai.haeh...@amd.com>
Date:   Fri Oct  7 17:33:07 2016 +0200

st/glsl_to_tgsi: explicit handling of writemask for depth/stencil export

Reviewed-by: Edward O'Callaghan <funfunc...@folklore1984.net>
Reviewed-by: Dave Airlie <airl...@redhat.com>

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f869892..da7b83b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2868,19 +2868,28 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
          } else
             l.writemask = WRITEMASK_XYZW;
       }
-   } else if (ir->lhs->type->is_scalar() &&
-              !ir->lhs->type->is_64bit() &&
-              ir->lhs->variable_referenced()->data.mode == ir_var_shader_out) {
-      /* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
-       * FINISHME: W component of fragment shader output zero, work correctly.
-       */
-      l.writemask = WRITEMASK_XYZW;
    } else {
       int swizzles[4];
       int first_enabled_chan = 0;
       int rhs_chan = 0;
+      ir_variable *variable = ir->lhs->variable_referenced();
+
+      if (shader->Stage == MESA_SHADER_FRAGMENT &&
+          variable->data.mode == ir_var_shader_out &&
+          (variable->data.location == FRAG_RESULT_DEPTH ||
+           variable->data.location == FRAG_RESULT_STENCIL)) {
+         assert(ir->lhs->type->is_scalar());
+         assert(ir->write_mask == WRITEMASK_X);
 
-      l.writemask = ir->write_mask;
+         if (variable->data.location == FRAG_RESULT_DEPTH)
+            l.writemask = WRITEMASK_Z;
+         else {
+            assert(variable->data.location == FRAG_RESULT_STENCIL);
+            l.writemask = WRITEMASK_Y;
+         }
+      } else {
+         l.writemask = ir->write_mask;
+      }
 
       for (int i = 0; i < 4; i++) {
          if (l.writemask & (1 << i)) {

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

Reply via email to