aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2020-04-08 15:08:03 -0500
committerMarge Bot <[email protected]>2020-04-16 17:00:13 +0000
commit33eb43349e8c3e8216f51ec838d9b9ab23361873 (patch)
treeccd01ca1b2b5c6e1448ccec4627538f653601a7e /src/compiler
parent8cbeb13704a59034ffe19a7ffef7b3856a1733e8 (diff)
nir: Add an alignment to nir_intrinsic_load_constant
In f1883cc73d4 we tried to pass through alignments from load_constant intrinsics when rewriting them to load_ubo in iris. However, those intrinsics don't have ALIGN_MUL or ALIGN_OFFSET indices. It's easy enough to add them. We just call the size/align function on the vector type at the end of our deref chain and use the alignment returned from there. It's possible we could do better by walking the whole deref chain but this should be good enough. Fixes: f1883cc73d4 "iris: Set alignments on cbuf0 and constant reads" Closes: #2739 Reviewed-by: Eric Anholt <[email protected]> Tested-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4468>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_intrinsics.py3
-rw-r--r--src/compiler/nir/nir_opt_large_constants.c4
-rw-r--r--src/compiler/nir/nir_validate.c2
3 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index b2cb0371efc..fb4c459e062 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -747,7 +747,8 @@ load("shared", 1, [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
# src[] = { offset }.
load("push_constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
# src[] = { offset }.
-load("constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
+load("constant", 1, [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET],
+ [CAN_ELIMINATE, CAN_REORDER])
# src[] = { address }.
load("global", 1, [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
# src[] = { address }.
diff --git a/src/compiler/nir/nir_opt_large_constants.c b/src/compiler/nir/nir_opt_large_constants.c
index e32265e50ec..7e293ba2c5e 100644
--- a/src/compiler/nir/nir_opt_large_constants.c
+++ b/src/compiler/nir/nir_opt_large_constants.c
@@ -75,11 +75,15 @@ build_constant_load(nir_builder *b, nir_deref_instr *deref,
size_align(var->type, &var_size, &var_align);
assert(var->data.location % var_align == 0);
+ UNUSED unsigned deref_size, deref_align;
+ size_align(deref->type, &deref_size, &deref_align);
+
nir_intrinsic_instr *load =
nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_constant);
load->num_components = num_components;
nir_intrinsic_set_base(load, var->data.location);
nir_intrinsic_set_range(load, var_size);
+ nir_intrinsic_set_align(load, deref_align, 0);
load->src[0] = nir_src_for_ssa(nir_build_deref_offset(b, deref, size_align));
nir_ssa_dest_init(&load->instr, &load->dest,
num_components, bit_size, NULL);
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 410f5906c0b..998017d504a 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -575,6 +575,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
case nir_intrinsic_load_shared:
case nir_intrinsic_load_global:
case nir_intrinsic_load_scratch:
+ case nir_intrinsic_load_constant:
/* These memory load operations must have alignments */
validate_assert(state,
util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr)));
@@ -589,7 +590,6 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
case nir_intrinsic_load_output:
case nir_intrinsic_load_per_vertex_output:
case nir_intrinsic_load_push_constant:
- case nir_intrinsic_load_constant:
/* All memory load operations must load at least a byte */
validate_assert(state, nir_dest_bit_size(instr->dest) >= 8);
break;