anv: add assert to detect problematic instruction merges

We stick to a rule in the driver that each field is only set in a
single place in the driver. Therefore when merging instructions, we
should never have any bit set to 1 from both sides.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30684>
This commit is contained in:
Lionel Landwerlin 2024-08-07 10:20:13 +03:00 committed by Marge Bot
parent 982106e676
commit e10cbb59a5
2 changed files with 9 additions and 1 deletions

View file

@ -1199,8 +1199,10 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
state = anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
dwords * 4, alignment);
p = state.map;
for (uint32_t i = 0; i < dwords; i++)
for (uint32_t i = 0; i < dwords; i++) {
assert((a[i] & b[i]) == 0);
p[i] = a[i] | b[i];
}
VG(VALGRIND_CHECK_MEM_IS_DEFINED(p, dwords * 4));

View file

@ -2447,6 +2447,9 @@ _anv_combine_address(struct anv_batch *batch, void *location,
assert((pipeline)->state.len == __anv_cmd_length(cmd)); \
__anv_cmd_pack(cmd)(batch, _partial, &name); \
for (uint32_t i = 0; i < __anv_cmd_length(cmd); i++) { \
assert((_partial[i] & \
(pipeline)->batch_data[ \
(pipeline)->state.offset + i]) == 0); \
((uint32_t *)_dst)[i] = _partial[i] | \
(pipeline)->batch_data[(pipeline)->state.offset + i]; \
} \
@ -2466,6 +2469,9 @@ _anv_combine_address(struct anv_batch *batch, void *location,
assert(_cmd_state->len == __anv_cmd_length(cmd)); \
__anv_cmd_pack(cmd)(batch, _partial, &name); \
for (uint32_t i = 0; i < __anv_cmd_length(cmd); i++) { \
assert((_partial[i] & \
(pipeline)->batch_data[ \
(pipeline)->state.offset + i]) == 0); \
((uint32_t *)_dst)[i] = _partial[i] | \
(pipeline)->batch_data[_cmd_state->offset + i]; \
} \