draw: fix incorrect instancing divisor in LLVM code
authorBrian Paul <brianp@vmware.com>
Tue, 20 Jul 2010 00:29:12 +0000 (18:29 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 20 Jul 2010 00:29:12 +0000 (18:29 -0600)
src/gallium/auxiliary/draw/draw_llvm.c

index 6958c3057cf04aa766485139e38e8c4728132a60..1ee87697b4af6ebebaf0510b21ca4149efd0e4e2 100644 (file)
@@ -380,12 +380,15 @@ generate_fetch(LLVMBuilderRef builder,
    LLVMValueRef cond;
    LLVMValueRef stride;
 
-   cond = LLVMBuildICmp(builder, LLVMIntULE, index, vb_max_index, "");
-
    if (velem->instance_divisor) {
-      index = instance_id;
+      /* array index = instance_id / instance_divisor */
+      index = LLVMBuildUDiv(builder, instance_id,
+                            LLVMConstInt(LLVMInt32Type(), velem->instance_divisor, 0),
+                            "instance_divisor");
    }
 
+   /* limit index to min(inex, vb_max_index) */
+   cond = LLVMBuildICmp(builder, LLVMIntULE, index, vb_max_index, "");
    index = LLVMBuildSelect(builder, cond, index, vb_max_index, "");
 
    stride = LLVMBuildMul(builder, vb_stride, index, "");