draw: fast element translate path without delta
authorKeith Whitwell <keith@tungstengraphics.com>
Mon, 2 Jun 2008 13:36:27 +0000 (14:36 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Mon, 2 Jun 2008 13:37:03 +0000 (14:37 +0100)
src/gallium/auxiliary/draw/draw_pt_vcache.c

index 9ffc99abf97cf90882ea3a9a370aa75d24b24b31..ad86ab4292586650a38cb1dfabb6468f36e4588f 100644 (file)
@@ -201,39 +201,74 @@ static void vcache_ef_quad( struct vcache_frontend *vcache,
 #define FUNC vcache_run
 #include "draw_pt_vcache_tmp.h"
 
+static void rebase_uint_elts( const unsigned *src,
+                              unsigned count,
+                              int delta,
+                              ushort *dest )
+{
+   unsigned i;
+
+   for (i = 0; i < count; i++) 
+      dest[i] = (ushort)(src[i] + delta);
+}
+
+static void rebase_ushort_elts( const ushort *src,
+                                unsigned count,
+                                int delta,
+                                ushort *dest )
+{
+   unsigned i;
+
+   for (i = 0; i < count; i++) 
+      dest[i] = (ushort)(src[i] + delta);
+}
+
+static void rebase_ubyte_elts( const ubyte *src,
+                               unsigned count,
+                               int delta,
+                               ushort *dest )
+{
+   unsigned i;
+
+   for (i = 0; i < count; i++) 
+      dest[i] = (ushort)(src[i] + delta);
+}
+
+
+
 static void translate_uint_elts( const unsigned *src,
                                  unsigned count,
-                                 int delta,
                                  ushort *dest )
 {
    unsigned i;
 
    for (i = 0; i < count; i++) 
-      dest[i] = (ushort)(src[i] + delta);
+      dest[i] = (ushort)(src[i]);
 }
 
 static void translate_ushort_elts( const ushort *src,
                                    unsigned count,
-                                   int delta,
                                    ushort *dest )
 {
    unsigned i;
 
    for (i = 0; i < count; i++) 
-      dest[i] = (ushort)(src[i] + delta);
+      dest[i] = (ushort)(src[i]);
 }
 
 static void translate_ubyte_elts( const ubyte *src,
                                   unsigned count,
-                                  int delta,
                                   ushort *dest )
 {
    unsigned i;
 
    for (i = 0; i < count; i++) 
-      dest[i] = (ushort)(src[i] + delta);
+      dest[i] = (ushort)(src[i]);
 }
 
+
+
+
 #if 0
 static enum pipe_format format_from_get_elt( pt_elt_func get_elt )
 {
@@ -282,31 +317,58 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
       if (!storage)
          goto fail;
       
-      switch(index_size) {
-      case 1:
-         translate_ubyte_elts( (const ubyte *)elts,
-                               draw_count,
-                               0 - (int)min_index,
-                               storage );
-         break;
-
-      case 2:
-         translate_ushort_elts( (const ushort *)elts,
-                                draw_count,
-                                0 - (int)min_index,
-                                storage );
-         break;
-
-      case 4:
-         translate_uint_elts( (const uint *)elts,
-                              draw_count,
-                              0 - (int)min_index,
-                              storage );
-         break;
-
-      default:
-         assert(0);
-         return;
+      if (min_index == 0) {
+         switch(index_size) {
+         case 1:
+            translate_ubyte_elts( (const ubyte *)elts,
+                                  draw_count,
+                                  storage );
+            break;
+
+         case 2:
+            translate_ushort_elts( (const ushort *)elts,
+                                   draw_count,
+                                   storage );
+            break;
+
+         case 4:
+            translate_uint_elts( (const uint *)elts,
+                                 draw_count,
+                                 storage );
+            break;
+
+         default:
+            assert(0);
+            return;
+         }
+      }
+      else {
+         switch(index_size) {
+         case 1:
+            rebase_ubyte_elts( (const ubyte *)elts,
+                                  draw_count,
+                                  0 - (int)min_index,
+                                  storage );
+            break;
+
+         case 2:
+            rebase_ushort_elts( (const ushort *)elts,
+                                   draw_count,
+                                   0 - (int)min_index,
+                                   storage );
+            break;
+
+         case 4:
+            rebase_uint_elts( (const uint *)elts,
+                                 draw_count,
+                                 0 - (int)min_index,
+                                 storage );
+            break;
+
+         default:
+            assert(0);
+            return;
+         }
       }
       transformed_elts = storage;
    }