summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_llvm.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2014-08-25 22:05:16 +0200
committerRoland Scheidegger <[email protected]>2014-08-28 03:03:23 +0200
commiteee9f6ae8aa058c70cc499fda7b521c5a5161338 (patch)
tree04bd612dcddf4f04a99c2f334adca62f1880954c /src/gallium/auxiliary/draw/draw_llvm.c
parent17eabfeccfc7d8bbb42533bb7ef3d25b59ca51d7 (diff)
draw: fix base instance handling in llvm path
The base instance needs to be passed to the jited function, otherwise the instanced data fetch will only work with the same start instance when the jit function was created (and baking that into the key instead is not a viable option). This fixes piglit arb_base_instance-drawarrays (modulo some unrelated core/compat context trouble I get for the test). And fix the pipe cap bit in llvmpipe for it now that it actually works (it already worked for softpipe). Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_llvm.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 2c6ca0d0a52..467f07420e2 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -645,7 +645,8 @@ generate_fetch(struct gallivm_state *gallivm,
struct pipe_vertex_element *velem,
LLVMValueRef vbuf,
LLVMValueRef index,
- LLVMValueRef instance_id)
+ LLVMValueRef instance_id,
+ LLVMValueRef start_instance)
{
const struct util_format_description *format_desc =
util_format_description(velem->src_format);
@@ -675,11 +676,11 @@ generate_fetch(struct gallivm_state *gallivm,
* index = start_instance + (instance_id / divisor)
*/
LLVMValueRef current_instance;
- index = lp_build_const_int32(gallivm, draw->start_instance);
current_instance = LLVMBuildUDiv(builder, instance_id,
lp_build_const_int32(gallivm, velem->instance_divisor),
"instance_divisor");
- index = lp_build_uadd_overflow(gallivm, index, current_instance, &ofbit);
+ index = lp_build_uadd_overflow(gallivm, start_instance,
+ current_instance, &ofbit);
}
stride = lp_build_umul_overflow(gallivm, vb_stride, index, &ofbit);
@@ -1473,7 +1474,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
- LLVMTypeRef arg_types[10];
+ LLVMTypeRef arg_types[11];
unsigned num_arg_types =
elts ? Elements(arg_types) : Elements(arg_types) - 1;
LLVMTypeRef func_type;
@@ -1484,7 +1485,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
struct lp_type vs_type;
LLVMValueRef end, start;
LLVMValueRef count, fetch_elts, fetch_elt_max, fetch_count;
- LLVMValueRef vertex_id_offset;
+ LLVMValueRef vertex_id_offset, start_instance;
LLVMValueRef stride, step, io_itr;
LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr;
LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
@@ -1533,6 +1534,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
arg_types[i++] = get_vb_ptr_type(variant); /* pipe_vertex_buffer's */
arg_types[i++] = int32_type; /* instance_id */
arg_types[i++] = int32_type; /* vertex_id_offset */
+ arg_types[i++] = int32_type; /* start_instance */
func_type = LLVMFunctionType(int32_type, arg_types, num_arg_types, 0);
@@ -1556,6 +1558,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
vb_ptr = LLVMGetParam(variant_func, 6 + (elts ? 1 : 0));
system_values.instance_id = LLVMGetParam(variant_func, 7 + (elts ? 1 : 0));
vertex_id_offset = LLVMGetParam(variant_func, 8 + (elts ? 1 : 0));
+ start_instance = LLVMGetParam(variant_func, 9 + (elts ? 1 : 0));
lp_build_name(context_ptr, "context");
lp_build_name(io_ptr, "io");
@@ -1564,6 +1567,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
lp_build_name(vb_ptr, "vb");
lp_build_name(system_values.instance_id, "instance_id");
lp_build_name(vertex_id_offset, "vertex_id_offset");
+ lp_build_name(start_instance, "start_instance");
if (elts) {
fetch_elts = LLVMGetParam(variant_func, 3);
@@ -1712,7 +1716,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
LLVMValueRef vb = LLVMBuildGEP(builder, vb_ptr, &vb_index, 1, "");
generate_fetch(gallivm, draw, vbuffers_ptr,
&aos_attribs[j][i], velem, vb, true_index,
- system_values.instance_id);
+ system_values.instance_id, start_instance);
}
}
convert_to_soa(gallivm, aos_attribs, inputs,