diff options
author | Jason Ekstrand <[email protected]> | 2020-03-30 23:00:34 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-06 15:57:30 +0000 |
commit | e78a7a182524f091e2d77ba97bfbe057c3975cab (patch) | |
tree | 04e902a9c9aa72039d98febbb0f75f5a93f8efdd /src/compiler/nir/nir_validate.c | |
parent | 068a3bf0d7cda0301b3dfc2e258698c6848ca706 (diff) |
nir: Assert memory loads are aligned
We've had alignment parameters on these operations for a while but a
bunch of places weren't setting them. That should be resolved now so we
can start validating that they're always set.
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4441>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4441>
Diffstat (limited to 'src/compiler/nir/nir_validate.c')
-rw-r--r-- | src/compiler/nir/nir_validate.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 7ecca048750..3ef4bbcab05 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -570,30 +570,44 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) break; } - case nir_intrinsic_load_uniform: case nir_intrinsic_load_ubo: + case nir_intrinsic_load_ssbo: + case nir_intrinsic_load_shared: + case nir_intrinsic_load_global: + case nir_intrinsic_load_scratch: + /* These memory load operations must have alignments */ + validate_assert(state, + util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); + validate_assert(state, nir_intrinsic_align_offset(instr) < + nir_intrinsic_align_mul(instr)); + /* Fall through */ + + case nir_intrinsic_load_uniform: case nir_intrinsic_load_input: case nir_intrinsic_load_per_vertex_input: case nir_intrinsic_load_interpolated_input: - case nir_intrinsic_load_ssbo: case nir_intrinsic_load_output: case nir_intrinsic_load_per_vertex_output: - case nir_intrinsic_load_shared: case nir_intrinsic_load_push_constant: case nir_intrinsic_load_constant: - case nir_intrinsic_load_global: - case nir_intrinsic_load_scratch: - /* Memory load operations must load at least a byte */ + /* All memory load operations must load at least a byte */ validate_assert(state, nir_dest_bit_size(instr->dest) >= 8); break; - case nir_intrinsic_store_output: - case nir_intrinsic_store_per_vertex_output: case nir_intrinsic_store_ssbo: case nir_intrinsic_store_shared: case nir_intrinsic_store_global: case nir_intrinsic_store_scratch: - /* Memory store operations must store at least a byte */ + /* These memory store operations must also have alignments */ + validate_assert(state, + util_is_power_of_two_nonzero(nir_intrinsic_align_mul(instr))); + validate_assert(state, nir_intrinsic_align_offset(instr) < + nir_intrinsic_align_mul(instr)); + /* Fall through */ + + case nir_intrinsic_store_output: + case nir_intrinsic_store_per_vertex_output: + /* All memory store operations must store at least a byte */ validate_assert(state, nir_src_bit_size(instr->src[0]) >= 8); break; |