Mesa (master): translate: don't crash on elts paths with instances

Zack Rusin zack at kemper.freedesktop.org
Wed Jun 16 11:44:11 PDT 2010


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

Author: Zack Rusin <zackr at vmware.com>
Date:   Wed Jun 16 08:52:33 2010 -0400

translate: don't crash on elts paths with instances

---

 .../auxiliary/translate/translate_generic.c        |   23 +++++++++++--------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index f8dbd2b..0e43a51 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -378,25 +378,28 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate,
 	 char *dst = (vert + 
 		      tg->attrib[attr].output_offset);
 
-         if (tg->attrib[attr].instance_divisor) {
-            index = instance_id / tg->attrib[attr].instance_divisor;
-         } else {
-            index = elt;
-         }
+         if (tg->attrib[attr].type == TRANSLATE_ELEMENT_NORMAL) {
+            if (tg->attrib[attr].instance_divisor) {
+               index = instance_id / tg->attrib[attr].instance_divisor;
+            } else {
+               index = elt;
+            }
 
-         index = MIN2(index, tg->attrib[attr].max_index);
+            index = MIN2(index, tg->attrib[attr].max_index);
 
-         src = tg->attrib[attr].input_ptr +
-               tg->attrib[attr].input_stride * index;
+            src = tg->attrib[attr].input_ptr +
+                  tg->attrib[attr].input_stride * index;
 
-	 tg->attrib[attr].fetch( data, src, 0, 0 );
+            tg->attrib[attr].fetch( data, src, 0, 0 );
 
+         } else {
+            data[0] = (float)instance_id;
+         }
          if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n",
                              i, elt, attr, data[0], data[1], data[2], data[3]);
 
 	 tg->attrib[attr].emit( data, dst );
       }
-      
       vert += tg->translate.key.output_stride;
    }
 }



More information about the mesa-commit mailing list