Mesa (10.4): radeonsi: fix instanced arrays with non-zero start instance

Emil Velikov evelikov at kemper.freedesktop.org
Wed Feb 18 22:22:17 UTC 2015


Module: Mesa
Branch: 10.4
Commit: 51bdd19c97ea6193582af45149c449426797b01d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=51bdd19c97ea6193582af45149c449426797b01d

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sat Jan 31 19:00:44 2015 +0100

radeonsi: fix instanced arrays with non-zero start instance

Fixes piglit ARB_base_instance/arb_base_instance-drawarrays.

Cc: 10.3 10.4 <mesa-stable at lists.freedesktop.org>
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
(cherry picked from commit 50908a89188ee7f079551622cbc8a37c04e8e8ac)

---

 src/gallium/drivers/radeonsi/si_shader.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 541e733..c15e8111 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -228,14 +228,14 @@ static LLVMValueRef get_instance_index_for_fetch(
 
 	LLVMValueRef result = LLVMGetParam(radeon_bld->main_fn,
 					   si_shader_ctx->param_instance_id);
-	result = LLVMBuildAdd(gallivm->builder, result, LLVMGetParam(
-			radeon_bld->main_fn, SI_PARAM_START_INSTANCE), "");
 
+	/* The division must be done before START_INSTANCE is added. */
 	if (divisor > 1)
 		result = LLVMBuildUDiv(gallivm->builder, result,
 				lp_build_const_int32(gallivm, divisor), "");
 
-	return result;
+	return LLVMBuildAdd(gallivm->builder, result, LLVMGetParam(
+			radeon_bld->main_fn, SI_PARAM_START_INSTANCE), "");
 }
 
 static void declare_input_vs(




More information about the mesa-commit mailing list