Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/gallium/auxiliary/util/u_threaded_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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!");

Expand Down
12 changes: 9 additions & 3 deletions src/imagination/vulkan/pvr_arch_g5p_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading