diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index b25d6aa341a..95814c82dc2 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -218,6 +218,21 @@ tc_batch_renderpass_infos_resize(struct threaded_context *tc, struct tc_batch *b unsigned old_idx = batch->renderpass_info_idx - 1; bool redo = tc->renderpass_info_recording && tc->renderpass_info_recording == &infos[old_idx].info; + /* A renderpass that rolled over from the previous batch links that batch's + * last info to infos[0] (tc_batch_increment_renderpass_info()). While the + * previous batch executes, the driver thread follows that link + * (threaded_context_get_renderpass_info()) and, when it is done, writes + * through it (tc_batch_execute() clears infos[0].prev). Moving the array + * under it reads and writes freed memory, so let the previous batch finish + * first. infos[0] has ended (this is not index 0) and is signalled, so the + * driver thread cannot be waiting on this thread. + */ + if (infos && batch->renderpass_info_idx > 0 && infos[0].prev && + util_queue_fence_is_signalled(&infos[0].ready)) { + const unsigned idx = batch - tc->batch_slots; + struct tc_batch *prev = &tc->batch_slots[(idx + TC_MAX_BATCHES - 1) % TC_MAX_BATCHES]; + util_queue_fence_wait(&prev->fence); + } if (!util_dynarray_resize(&batch->renderpass_infos, struct tc_batch_rp_info, cur_num + 10)) mesa_loge("tc: memory alloc fail!"); diff --git a/src/imagination/vulkan/pvr_arch_g5p_gfx.c b/src/imagination/vulkan/pvr_arch_g5p_gfx.c index 6fe858b5cc7..a68f5f0ae73 100644 --- a/src/imagination/vulkan/pvr_arch_g5p_gfx.c +++ b/src/imagination/vulkan/pvr_arch_g5p_gfx.c @@ -2480,9 +2480,15 @@ PVR_PER_ARCH(g5p_cmd_draw)(struct pvr_cmd_buffer *cmd_buffer, const struct pvr_g * relocation slack. This also provides old-kernel compatibility without * changing the application's render pass. */ struct pvr_csb *stream = &cs->current_sub_cmd->gfx.control_stream; - const uint64_t occupied = (uint64_t)list_length(&stream->pvr_bo_list) * - PVR_CMD_BUFFER_CSB_BO_SIZE; - if (occupied + PVR_CMD_BUFFER_CSB_BO_SIZE > PVR_G5P_MAX_VDM_BYTES) { + /* A block holds its whole allocation (pvr_csb_buffer_extend(): csb->end is the BO's size), which the kernel + * rounds up to its page: 16 KiB blocks on the iPad, not PVR_CMD_BUFFER_CSB_BO_SIZE. Counting 4 KiB per block + * let a render reach 85 blocks (1.37 MB) and be refused by pvr_arch_g5p_vdm_stream(). */ + uint64_t occupied = 0, block = PVR_CMD_BUFFER_CSB_BO_SIZE; + list_for_each_entry (const struct pvr_bo, b, &stream->pvr_bo_list, link) { + occupied += b->bo->size; + block = MAX2(block, b->bo->size); + } + if (occupied + block > PVR_G5P_MAX_VDM_BYTES) { result = pvr_cmd_buffer_insert_mid_frag_barrier_event(cmd_buffer, PVR_PIPELINE_STAGE_FRAG_BIT, PVR_PIPELINE_STAGE_GEOM_BIT);