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

Author: Eric Anholt <e...@anholt.net>
Date:   Sun Sep  7 12:53:03 2014 -0700

vc4: Add support for depth texturing.

---

 src/gallium/drivers/vc4/vc4_program.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 2f85cc6..ba6ed3c 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -499,11 +499,21 @@ tgsi_to_qir_tex(struct vc4_compile *c,
         c->num_texture_samples++;
         struct qreg r4 = qir_TEX_RESULT(c);
 
+        enum pipe_format format = c->key->tex_format[unit];
+
         struct qreg unpacked[4];
-        for (int i = 0; i < 4; i++)
-                unpacked[i] = qir_R4_UNPACK(c, r4, i);
+        if (util_format_is_depth_or_stencil(format)) {
+                struct qreg depthf = qir_ITOF(c, qir_SHR(c, r4,
+                                                         qir_uniform_ui(c, 
8)));
+                struct qreg normalized = qir_FMUL(c, depthf,
+                                                  qir_uniform_f(c, 
1.0f/0xffffff));
+                for (int i = 0; i < 4; i++)
+                        unpacked[i] = normalized;
+        } else {
+                for (int i = 0; i < 4; i++)
+                        unpacked[i] = qir_R4_UNPACK(c, r4, i);
+        }
 
-        enum pipe_format format = c->key->tex_format[unit];
         const uint8_t *swiz = vc4_get_format_swizzle(format);
         for (int i = 0; i < 4; i++) {
                 if (!(tgsi_inst->Dst[0].Register.WriteMask & (1 << i)))

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

Reply via email to