llvmpipe: handle firstvertex for vulkan draw parameters

Vulkan defines this a bit differently, so add support for
load_first_vertex.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8219>
This commit is contained in:
Dave Airlie 2020-12-24 09:50:45 +10:00 committed by Marge Bot
parent 4ad4cd8906
commit ae2edc8127
4 changed files with 9 additions and 1 deletions

View File

@ -2272,8 +2272,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
* index out of our vertex id here.
* for ARB_shader_draw_parameters, base_vertex should be 0 for non-indexed draws.
*/
LLVMValueRef base_vertex = lp_build_select(&bld, have_elts, vertex_id_offset, lp_build_const_int32(gallivm, 0));;
LLVMValueRef base_vertex = lp_build_select(&bld, have_elts, vertex_id_offset, lp_build_const_int32(gallivm, 0));
system_values.basevertex = lp_build_broadcast_scalar(&blduivec, base_vertex);
/* first vertex is for Vulkan base vertex support */
LLVMValueRef first_vertex = lp_build_select(&bld, have_elts, vertex_id_offset, start_or_maxelt);
system_values.firstvertex = lp_build_broadcast_scalar(&blduivec, first_vertex);
system_values.vertex_id = true_index_array;
system_values.vertex_id_nobase = LLVMBuildSub(builder, true_index_array,
lp_build_broadcast_scalar(&blduivec, vertex_id_offset), "");

View File

@ -1661,6 +1661,7 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
case nir_intrinsic_load_instance_id:
case nir_intrinsic_load_base_instance:
case nir_intrinsic_load_base_vertex:
case nir_intrinsic_load_first_vertex:
case nir_intrinsic_load_work_group_id:
case nir_intrinsic_load_local_invocation_id:
case nir_intrinsic_load_num_work_groups:

View File

@ -1476,6 +1476,9 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base,
case nir_intrinsic_load_base_vertex:
result[0] = bld->system_values.basevertex;
break;
case nir_intrinsic_load_first_vertex:
result[0] = bld->system_values.firstvertex;
break;
case nir_intrinsic_load_vertex_id:
result[0] = bld->system_values.vertex_id;
break;

View File

@ -171,6 +171,7 @@ struct lp_bld_tgsi_system_values {
LLVMValueRef vertex_id_nobase;
LLVMValueRef prim_id;
LLVMValueRef basevertex;
LLVMValueRef firstvertex;
LLVMValueRef invocation_id;
LLVMValueRef draw_id;
LLVMValueRef thread_id;