gallivm/nir: add load push constant support
authorDave Airlie <airlied@redhat.com>
Fri, 19 Jun 2020 06:51:50 +0000 (16:51 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 17 Aug 2020 04:30:49 +0000 (14:30 +1000)
This convets the push constant load to a ubo load against the 0 constant buffer,
which is where the vallium layer will bind things.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6082>

src/gallium/auxiliary/gallivm/lp_bld_nir.c

index d2336c173657024d8dd08ccd9e0ac722c22c86ef..702a0bd4ec4199873c45cbeea948bc21ad69a371 100644 (file)
@@ -1019,6 +1019,19 @@ static void visit_load_ubo(struct lp_build_nir_context *bld_base,
                       offset_is_uniform, idx, offset, result);
 }
 
+static void visit_load_push_constant(struct lp_build_nir_context *bld_base,
+                                     nir_intrinsic_instr *instr,
+                                     LLVMValueRef result[4])
+{
+   struct gallivm_state *gallivm = bld_base->base.gallivm;
+   LLVMValueRef offset = get_src(bld_base, instr->src[0]);
+   LLVMValueRef idx = lp_build_const_int32(gallivm, 0);
+   bool offset_is_uniform = nir_src_is_dynamically_uniform(instr->src[0]);
+
+   bld_base->load_ubo(bld_base, nir_dest_num_components(instr->dest), nir_dest_bit_size(instr->dest),
+                      offset_is_uniform, idx, offset, result);
+}
+
 
 static void visit_load_ssbo(struct lp_build_nir_context *bld_base,
                            nir_intrinsic_instr *instr,
@@ -1396,6 +1409,9 @@ static void visit_intrinsic(struct lp_build_nir_context *bld_base,
    case nir_intrinsic_load_ubo:
       visit_load_ubo(bld_base, instr, result);
       break;
+   case nir_intrinsic_load_push_constant:
+      visit_load_push_constant(bld_base, instr, result);
+      break;
    case nir_intrinsic_load_ssbo:
       visit_load_ssbo(bld_base, instr, result);
       break;