Mesa (master): llvmpipe: handle firstvertex for vulkan draw parameters

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 27 23:52:21 UTC 2021


Module: Mesa
Branch: master
Commit: ae2edc81271ca19e3a293e74ea6e766b28ff46c4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae2edc81271ca19e3a293e74ea6e766b28ff46c4

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Dec 24 09:50:45 2020 +1000

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 at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8219>

---

 src/gallium/auxiliary/draw/draw_llvm.c         | 5 ++++-
 src/gallium/auxiliary/gallivm/lp_bld_nir.c     | 1 +
 src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 3 +++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h    | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 58636316dfb..19b0d4c5f6b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -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), "");
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 4ab8d5bf956..ba3ddf4891d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -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:
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index 1105f46f10d..7d4820d6a12 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
@@ -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;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index d5a01f82c16..1e2178c64e1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -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;



More information about the mesa-commit mailing list