Mesa (master): tgsi/sse: add support for system values

Brian Paul brianp at kemper.freedesktop.org
Sat Jan 15 17:25:55 UTC 2011


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Dec  8 18:20:05 2010 -0700

tgsi/sse: add support for system values

---

 src/gallium/auxiliary/tgsi/tgsi_sse2.c |   54 ++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 086d983..3f2cda8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -163,6 +163,14 @@ get_immediate_base( void )
       reg_DX );
 }
 
+static struct x86_reg
+get_system_value_base( void )
+{
+   return x86_make_disp(
+      get_machine_base(),
+      Offset(struct tgsi_exec_machine, SystemValue) );
+}
+
 
 /**
  * Data access helpers.
@@ -229,6 +237,16 @@ get_temp(
 }
 
 static struct x86_reg
+get_system_value(
+   unsigned vec,
+   unsigned chan )
+{
+   return x86_make_disp(
+      get_system_value_base(), /* base */
+      (vec * 4 + chan) * 4 );  /* byte offset from base */
+}
+
+static struct x86_reg
 get_coef(
    unsigned vec,
    unsigned chan,
@@ -423,6 +441,30 @@ emit_tempf(
 }
 
 /**
+ * Copy a system value to xmm register
+ * \param xmm  the destination xmm register
+ * \param vec  the source system value register
+ * \param chan  src channel to fetch (X, Y, Z or W)
+ */
+static void
+emit_system_value(
+   struct x86_function *func,
+   unsigned xmm,
+   unsigned vec,
+   unsigned chan )
+{
+   sse_movss(
+      func,
+      make_xmm( xmm ),
+      get_system_value( vec, chan ) );
+   sse_shufps(
+      func,
+      make_xmm( xmm ),
+      make_xmm( xmm ),
+      SHUF( 0, 0, 0, 0 ) );
+}
+
+/**
  * Load an xmm register with an input attrib coefficient (a0, dadx or dady)
  * \param xmm  the destination xmm register
  * \param vec  the src input/attribute coefficient index
@@ -1281,8 +1323,15 @@ emit_fetch(
             swizzle );
          break;
 
-      case TGSI_FILE_INPUT:
       case TGSI_FILE_SYSTEM_VALUE:
+         emit_system_value(
+            func,
+            xmm,
+            reg->Register.Index,
+            swizzle );
+         break;
+
+      case TGSI_FILE_INPUT:
          emit_inputf(
             func,
             xmm,
@@ -2636,8 +2685,7 @@ emit_declaration(
    struct x86_function *func,
    struct tgsi_full_declaration *decl )
 {
-   if( decl->Declaration.File == TGSI_FILE_INPUT ||
-       decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
+   if( decl->Declaration.File == TGSI_FILE_INPUT ) {
       unsigned first, last, mask;
       unsigned i, j;
 




More information about the mesa-commit mailing list