mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 09:50:08 +01:00
nir_lower_mem_access_bit_sizes: Assert when 0 components or bits are requested
Prevent the accidental passing of 0 components or bits, as it makes no sense. Cc: mesa-stable Reviewed-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Suggested-by: Karol Herbst <kherbst@redhat.com> Signed-off-by: David Heidelberg <david@ixit.cz> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31103>
This commit is contained in:
parent
45b531fdfc
commit
6bf7b5bcd8
1 changed files with 8 additions and 0 deletions
|
|
@ -88,6 +88,8 @@ lower_mem_load(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
bit_size, align_mul, whole_align_offset,
|
||||
offset_is_const, cb_data);
|
||||
|
||||
assert(requested.num_components > 0);
|
||||
assert(requested.bit_size > 0);
|
||||
assert(util_is_power_of_two_nonzero(align_mul));
|
||||
assert(util_is_power_of_two_nonzero(requested.align));
|
||||
if (requested.num_components == num_components &&
|
||||
|
|
@ -112,6 +114,8 @@ lower_mem_load(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
offset_is_const, cb_data);
|
||||
|
||||
unsigned chunk_bytes;
|
||||
assert(requested.num_components > 0);
|
||||
assert(requested.bit_size > 0);
|
||||
assert(util_is_power_of_two_nonzero(requested.align));
|
||||
if (align_mul < requested.align) {
|
||||
/* For this case, we need to be able to shift the value so we assume
|
||||
|
|
@ -249,6 +253,8 @@ lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
bit_size, align_mul, whole_align_offset,
|
||||
offset_is_const, cb_data);
|
||||
|
||||
assert(requested.num_components > 0);
|
||||
assert(requested.bit_size > 0);
|
||||
assert(util_is_power_of_two_nonzero(align_mul));
|
||||
assert(util_is_power_of_two_nonzero(requested.align));
|
||||
if (requested.num_components == num_components &&
|
||||
|
|
@ -289,6 +295,8 @@ lower_mem_store(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
|
||||
uint32_t chunk_bytes = requested.num_components * (requested.bit_size / 8);
|
||||
|
||||
assert(requested.num_components > 0);
|
||||
assert(requested.bit_size > 0);
|
||||
assert(util_is_power_of_two_nonzero(requested.align));
|
||||
if (chunk_align < requested.align ||
|
||||
chunk_bytes > max_chunk_bytes) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue