Mesa (master): i965: Add support for EXT_texture_swizzle to the new FS backend.

Eric Anholt anholt at kemper.freedesktop.org
Sun Oct 3 06:50:19 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Sat Oct  2 23:44:29 2010 -0700

i965: Add support for EXT_texture_swizzle to the new FS backend.

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index dd2af2b..5ebf906 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1437,6 +1437,27 @@ fs_visitor::visit(ir_texture *ir)
 
    if (ir->shadow_comparitor)
       inst->shadow_compare = true;
+
+   if (c->key.tex_swizzles[inst->sampler] != SWIZZLE_NOOP) {
+      fs_reg swizzle_dst = fs_reg(this, glsl_type::vec4_type);
+
+      for (int i = 0; i < 4; i++) {
+	 int swiz = GET_SWZ(c->key.tex_swizzles[inst->sampler], i);
+	 fs_reg l = swizzle_dst;
+	 l.reg_offset += i;
+
+	 if (swiz == SWIZZLE_ZERO) {
+	    emit(fs_inst(BRW_OPCODE_MOV, l, fs_reg(0.0f)));
+	 } else if (swiz == SWIZZLE_ONE) {
+	    emit(fs_inst(BRW_OPCODE_MOV, l, fs_reg(1.0f)));
+	 } else {
+	    fs_reg r = dst;
+	    r.reg_offset += GET_SWZ(c->key.tex_swizzles[inst->sampler], i);
+	    emit(fs_inst(BRW_OPCODE_MOV, l, r));
+	 }
+      }
+      this->result = swizzle_dst;
+   }
 }
 
 void




More information about the mesa-commit mailing list