From: Dave Airlie Date: Tue, 3 Dec 2019 05:54:21 +0000 (+1000) Subject: gallivm: add base instance sysval support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22a40dd1c1efe861b57a3ae43fa13481bea627fc;p=mesa.git gallivm: add base instance sysval support Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index ad0ba8b1015..4a3bada06e0 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1631,7 +1631,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) char func_name[64]; struct lp_type vs_type; LLVMValueRef count, fetch_elts, start_or_maxelt; - LLVMValueRef vertex_id_offset, start_instance; + LLVMValueRef vertex_id_offset; LLVMValueRef stride, step, io_itr; LLVMValueRef ind_vec, start_vec, have_elts, fetch_max, tmp; LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr; @@ -1721,7 +1721,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) vb_ptr = LLVMGetParam(variant_func, 6); system_values.instance_id = LLVMGetParam(variant_func, 7); vertex_id_offset = LLVMGetParam(variant_func, 8); - start_instance = LLVMGetParam(variant_func, 9); + system_values.base_instance = LLVMGetParam(variant_func, 9); fetch_elts = LLVMGetParam(variant_func, 10); lp_build_name(context_ptr, "context"); @@ -1733,7 +1733,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"); + lp_build_name(system_values.base_instance, "start_instance"); lp_build_name(fetch_elts, "fetch_elts"); /* @@ -1848,7 +1848,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) lp_build_const_int32(gallivm, velem->instance_divisor), "instance_divisor"); - instance_index[j] = lp_build_uadd_overflow(gallivm, start_instance, + instance_index[j] = lp_build_uadd_overflow(gallivm, system_values.base_instance, current_instance, &ofbit); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 8861a8324b5..547161ba7fe 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1161,6 +1161,7 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_vertex_id: case nir_intrinsic_load_primitive_id: case nir_intrinsic_load_instance_id: + case nir_intrinsic_load_base_instance: case nir_intrinsic_load_work_group_id: case nir_intrinsic_load_local_invocation_id: case nir_intrinsic_load_num_work_groups: diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 5c3a40cdfea..a95af23ae0d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -922,6 +922,9 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base, case nir_intrinsic_load_instance_id: result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.instance_id); break; + case nir_intrinsic_load_base_instance: + result[0] = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.base_instance); + break; case nir_intrinsic_load_vertex_id: result[0] = bld->system_values.vertex_id; break; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 7048fbc3325..d82044f770f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -165,6 +165,7 @@ struct lp_tgsi_info */ struct lp_bld_tgsi_system_values { LLVMValueRef instance_id; + LLVMValueRef base_instance; LLVMValueRef vertex_id; LLVMValueRef vertex_id_nobase; LLVMValueRef prim_id; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 0d6030635c8..a4606a67615 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1306,6 +1306,11 @@ emit_fetch_system_value( atype = TGSI_TYPE_UNSIGNED; break; + case TGSI_SEMANTIC_BASEINSTANCE: + res = lp_build_broadcast_scalar(&bld_base->uint_bld, bld->system_values.base_instance); + atype = TGSI_TYPE_UNSIGNED; + break; + case TGSI_SEMANTIC_PRIMID: res = bld->system_values.prim_id; atype = TGSI_TYPE_UNSIGNED;