Mesa (master): translate: Take and respect a max_index argument.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Apr 26 08:06:09 PDT 2010


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Mon Apr 26 14:49:42 2010 +0100

translate: Take and respect a max_index argument.

---

 src/gallium/auxiliary/translate/translate.h        |    3 ++-
 .../auxiliary/translate/translate_generic.c        |   19 +++++++++++++------
 src/gallium/auxiliary/translate/translate_sse.c    |   10 +++++++++-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h
index 54ed2c1..edd95e0 100644
--- a/src/gallium/auxiliary/translate/translate.h
+++ b/src/gallium/auxiliary/translate/translate.h
@@ -76,7 +76,8 @@ struct translate {
    void (*set_buffer)( struct translate *,
 		       unsigned i,
 		       const void *ptr,
-		       unsigned stride );
+		       unsigned stride,
+		       unsigned max_index );
 
    void (PIPE_CDECL *run_elts)( struct translate *,
                                 const unsigned *elts,
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index c3ec9ae..a9272fb 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -31,6 +31,7 @@
   */
 
 #include "util/u_memory.h"
+#include "util/u_math.h"
 #include "pipe/p_state.h"
 #include "translate.h"
 
@@ -58,6 +59,7 @@ struct translate_generic {
       
       char *input_ptr;
       unsigned input_stride;
+      unsigned max_index;
 
    } attrib[PIPE_MAX_ATTRIBS];
 
@@ -588,19 +590,22 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate,
       for (attr = 0; attr < nr_attrs; attr++) {
 	 float data[4];
          const char *src;
+         unsigned index;
 
 	 char *dst = (vert + 
 		      tg->attrib[attr].output_offset);
 
          if (tg->attrib[attr].instance_divisor) {
-            src = tg->attrib[attr].input_ptr +
-                  tg->attrib[attr].input_stride *
-                  (instance_id / tg->attrib[attr].instance_divisor);
+            index = instance_id / tg->attrib[attr].instance_divisor;
          } else {
-            src = tg->attrib[attr].input_ptr +
-                  tg->attrib[attr].input_stride * elt;
+            index = elt;
          }
 
+         index = MIN2(index, tg->attrib[attr].max_index);
+
+         src = tg->attrib[attr].input_ptr +
+               tg->attrib[attr].input_stride * index;
+
 	 tg->attrib[attr].fetch( src, data );
 
          if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n",
@@ -670,7 +675,8 @@ static void PIPE_CDECL generic_run( struct translate *translate,
 static void generic_set_buffer( struct translate *translate,
 				unsigned buf,
 				const void *ptr,
-				unsigned stride )
+				unsigned stride,
+				unsigned max_index )
 {
    struct translate_generic *tg = translate_generic(translate);
    unsigned i;
@@ -680,6 +686,7 @@ static void generic_set_buffer( struct translate *translate,
 	 tg->attrib[i].input_ptr = ((char *)ptr +
 				    tg->attrib[i].input_offset);
 	 tg->attrib[i].input_stride = stride;
+         tg->attrib[i].max_index = max_index;
       }
    }
 }
diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c
index c13e742..ef3aa67 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -61,6 +61,7 @@ typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate,
 struct translate_buffer {
    const void *base_ptr;
    unsigned stride;
+   unsigned max_index;
 };
 
 struct translate_buffer_varient {
@@ -423,6 +424,11 @@ static boolean init_inputs( struct translate_sse *p,
          } else {
             x86_mov(p->func, tmp_EAX, elt);
          }
+
+         /*
+          * TODO: Respect translate_buffer::max_index.
+          */
+
          x86_imul(p->func, tmp_EAX, buf_stride);
          x86_add(p->func, tmp_EAX, buf_base_ptr);
 
@@ -666,13 +672,15 @@ static boolean build_vertex_emit( struct translate_sse *p,
 static void translate_sse_set_buffer( struct translate *translate,
 				unsigned buf,
 				const void *ptr,
-				unsigned stride )
+				unsigned stride,
+				unsigned max_index )
 {
    struct translate_sse *p = (struct translate_sse *)translate;
 
    if (buf < p->nr_buffers) {
       p->buffer[buf].base_ptr = (char *)ptr;
       p->buffer[buf].stride = stride;
+      p->buffer[buf].max_index = max_index;
    }
 
    if (0) debug_printf("%s %d/%d: %p %d\n", 



More information about the mesa-commit mailing list