gallivm: add base instance sysval support
authorDave Airlie <airlied@redhat.com>
Tue, 3 Dec 2019 05:54:21 +0000 (15:54 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 12 Dec 2019 00:16:19 +0000 (10:16 +1000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
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
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c

index ad0ba8b1015491df6fbf87f26a5773bb9a1effd8..4a3bada06e087d33c2871589b476b0a5fc6e04e3 100644 (file)
@@ -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);
          }
 
index 8861a8324b5a89605419730db10db31291cbeb26..547161ba7fe3de2ff7c5e7f9fb91f0ff4450eb70 100644 (file)
@@ -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:
index 5c3a40cdfea67328fd3e7312c7a4d6fe81f0dc28..a95af23ae0d3229b27d25565fb0ccb70fc014728 100644 (file)
@@ -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;
index 7048fbc3325e6e3ba8f90f292ed685216d35a683..d82044f770ff61185bfa1d739e661eedc1fac5ad 100644 (file)
@@ -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;
index 0d6030635c892d289ef4a0f27a1cc0b512b590e3..a4606a67615fa7bc7036b733c5dd862f60daf01e 100644 (file)
@@ -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;