summaryrefslogtreecommitdiff
path: root/src/broadcom/compiler/nir_to_vir.c
diff options
context:
space:
mode:
authorIago Toral Quiroga <itoral@igalia.com>2021-04-08 09:02:16 +0200
committerMarge Bot <eric+marge@anholt.net>2021-04-09 10:31:40 +0000
commit4b244dc64f439da11bba7224db836b376e2ca75a (patch)
tree554ec6ce811f705dc85abe25ee979efd3438540f /src/broadcom/compiler/nir_to_vir.c
parenta45ab46563f7c700c7c4e676a3af52781444ddb8 (diff)
broadcom/compiler: add a definition for the unifa skip distance
We will be using this distance to setup another optimization in a follow-up patch. Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com> x# Please enter the commit message for your changes. Lines starting Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10100>
Diffstat (limited to 'src/broadcom/compiler/nir_to_vir.c')
-rw-r--r--src/broadcom/compiler/nir_to_vir.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 2fbc81c4535..fbfb57489da 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -2644,6 +2644,12 @@ emit_ldunifa(struct v3d_compile *c, struct qreg *result)
static void
ntq_emit_load_ubo_unifa(struct v3d_compile *c, nir_intrinsic_instr *instr)
{
+ /* Every ldunifa auto-increments the unifa address by 4 bytes, so our
+ * last unifa offset is 4 bytes ahead of the offset of the last load.
+ */
+ static const int32_t max_unifa_skip_dist =
+ MAX_UNIFA_SKIP_DISTANCE - 4;
+
bool dynamic_src = !nir_src_is_const(instr->src[1]);
uint32_t const_offset =
dynamic_src ? 0 : nir_src_as_uint(instr->src[1]);
@@ -2656,7 +2662,10 @@ ntq_emit_load_ubo_unifa(struct v3d_compile *c, nir_intrinsic_instr *instr)
index++;
/* We can only keep track of the last unifa address we used with
- * constant offset loads.
+ * constant offset loads. If the new load targets the same UBO and
+ * is close enough to the previous load, we can skip the unifa register
+ * write by emitting dummy ldunifa instructions to update the unifa
+ * address.
*/
bool skip_unifa = false;
uint32_t ldunifa_skips = 0;
@@ -2665,7 +2674,7 @@ ntq_emit_load_ubo_unifa(struct v3d_compile *c, nir_intrinsic_instr *instr)
} else if (c->cur_block == c->last_unifa_block &&
c->last_unifa_index == index &&
c->last_unifa_offset <= const_offset &&
- c->last_unifa_offset + 12 >= const_offset) {
+ c->last_unifa_offset + max_unifa_skip_dist >= const_offset) {
skip_unifa = true;
ldunifa_skips = (const_offset - c->last_unifa_offset) / 4;
} else {