radv/amdgpu: use the correct IB size when growing a CS with RADV_DEBUG=noibs

The current IB size is copied when radv_amdgpu_cs_add_old_ib_buffer()
is called, which might not be the real IB size because we might still
pad the CS with NOP packets after.

Found by inspection.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23727>
This commit is contained in:
Samuel Pitoiset 2023-06-21 13:42:41 +02:00 committed by Marge Bot
parent 91143f45b8
commit c11a62a7b0

View file

@ -342,11 +342,17 @@ radv_amdgpu_cs_grow(struct radeon_cmdbuf *_cs, size_t min_size)
enum amd_ip_type ip_type = cs->hw_ip;
uint32_t ib_pad_dw_mask = MAX2(3, cs->ws->info.ib_pad_dw_mask[ip_type]);
uint32_t nop_packet = get_nop_packet(cs);
while (!cs->base.cdw || (cs->base.cdw & ib_pad_dw_mask) != ib_pad_dw_mask - 3)
radeon_emit_unchecked(&cs->base, nop_packet);
if (cs->use_ib)
if (cs->use_ib) {
while (!cs->base.cdw || (cs->base.cdw & ib_pad_dw_mask) != ib_pad_dw_mask - 3)
radeon_emit_unchecked(&cs->base, nop_packet);
*cs->ib_size_ptr |= cs->base.cdw + 4;
} else {
/* Pad the CS with NOP packets. */
while (!cs->base.cdw || (cs->base.cdw & ib_pad_dw_mask))
radeon_emit_unchecked(&cs->base, nop_packet);
}
radv_amdgpu_cs_add_old_ib_buffer(cs);
if (cs->status != VK_SUCCESS)
@ -384,10 +390,6 @@ radv_amdgpu_cs_grow(struct radeon_cmdbuf *_cs, size_t min_size)
radeon_emit_unchecked(&cs->base, S_3F2_CHAIN(1) | S_3F2_VALID(1));
cs->ib_size_ptr = cs->base.buf + cs->base.cdw - 1;
} else {
/* Pad the CS with NOP packets. */
while (!cs->base.cdw || (cs->base.cdw & ib_pad_dw_mask))
radeon_emit_unchecked(&cs->base, nop_packet);
}
cs->base.buf = (uint32_t *)cs->ib_mapped;