llvmpipe: handle firstvertex for vulkan draw parameters
authorDave Airlie <airlied@redhat.com>
Wed, 23 Dec 2020 23:50:45 +0000 (09:50 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 Jan 2021 23:36:52 +0000 (23:36 +0000)
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>

src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi.h

index 5863631..19b0d4c 100644 (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), "");
index 4ab8d5b..ba3ddf4 100644 (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:
index 1105f46..7d4820d 100644 (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;
index d5a01f8..1e2178c 100644 (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;