summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-12-11 21:00:26 -0500
committerMarge Bot <eric+marge@anholt.net>2020-12-31 14:39:01 +0000
commit2e57684d2d3ec6ddf5f0e1158af549983c306a3c (patch)
tree74b054430f6323875f2b0bd6c38726810e8a77d6
parent341e312cf4b5fd94fc69e20744b99f7af05ac951 (diff)
pan/bi: Implement load_ubo with the builder
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8135>
-rw-r--r--src/panfrost/bifrost/bifrost_compile.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 6291b3bdb39..6532775fa19 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -775,6 +775,42 @@ bi_emit_st_vary(bi_context *ctx, nir_intrinsic_instr *instr)
}
static void
+bi_emit_load_ubo(bi_builder *b, nir_intrinsic_instr *instr)
+{
+ /* nir_lower_uniforms_to_ubo() should have been called, reserving
+ * UBO #0 for uniforms even if the shaders doesn't have uniforms.
+ */
+ assert(b->shader->nir->info.first_ubo_is_default_ubo);
+
+ bool offset_is_const = nir_src_is_const(instr->src[1]);
+ bi_index dyn_offset = bi_src_index(&instr->src[1]);
+ uint32_t const_offset = 0;
+
+ /* We may need to offset UBO loads by however many sysvals we have */
+ unsigned sysval_offset = 16 * b->shader->sysvals.sysval_count;
+
+ if (nir_src_is_const(instr->src[1]))
+ const_offset = nir_src_as_uint(instr->src[1]);
+
+ if (nir_src_is_const(instr->src[0]) &&
+ nir_src_as_uint(instr->src[0]) == 0 &&
+ b->shader->sysvals.sysval_count) {
+ if (offset_is_const) {
+ const_offset += sysval_offset;
+ } else {
+ dyn_offset = bi_iadd_u32(b, dyn_offset,
+ bi_imm_u32(sysval_offset), false);
+ }
+ }
+
+ bi_load_to(b, instr->num_components * 32,
+ bi_dest_index(&instr->dest), offset_is_const ?
+ bi_imm_u32(const_offset) : dyn_offset,
+ bi_src_index(&instr->src[0]),
+ BI_SEG_UBO);
+}
+
+static void
bi_emit_ld_ubo(bi_context *ctx, nir_intrinsic_instr *instr)
{
/* nir_lower_uniforms_to_ubo() should have been called, reserving