v3dv: defer tile_alloc creation in meta TLB ops
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Remove the allocate_tile_state_now parameter from v3dv_job_start_frame().
So v3dv_job_allocate_tile_state() is explicitly called after
job_emit_binning_flush() as we know the value of job->draw_count instead
of using always 0.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40554>
This commit is contained in:
Jose Maria Casanova Crespo 2026-04-09 13:15:35 +02:00 committed by Marge Bot
parent 69880047d8
commit 2b6b859a22
6 changed files with 35 additions and 31 deletions

View file

@ -490,7 +490,6 @@ v3dv_job_start_frame(struct v3dv_job *job,
uint32_t height,
uint32_t layers,
bool allocate_tile_state_for_all_layers,
bool allocate_tile_state_now,
uint32_t render_target_count,
uint8_t max_internal_bpp,
uint8_t total_color_bpp,
@ -511,14 +510,6 @@ v3dv_job_start_frame(struct v3dv_job *job,
job->allocate_tile_state_for_all_layers = allocate_tile_state_for_all_layers;
/* For subpass jobs we postpone tile state allocation until we are finishing
* the job and have made a decision about double-buffer.
*/
if (allocate_tile_state_now) {
if (!v3dv_job_allocate_tile_state(job))
return;
}
v3d_X((&job->device->devinfo), job_emit_binning_prolog)(job, tiling,
allocate_tile_state_for_all_layers ? tiling->layers : 1);
@ -1785,7 +1776,7 @@ cmd_buffer_subpass_create_job(struct v3dv_cmd_buffer *cmd_buffer,
width,
height,
layers,
true, false,
true,
subpass->color_count,
max_internal_bpp,
total_color_bpp,
@ -2776,7 +2767,7 @@ cmd_buffer_restart_job_for_msaa_if_needed(struct v3dv_cmd_buffer *cmd_buffer)
old_job->frame_tiling.width,
old_job->frame_tiling.height,
old_job->frame_tiling.layers,
true, false,
true,
old_job->frame_tiling.render_target_count,
old_job->frame_tiling.internal_bpp,
old_job->frame_tiling.total_color_bpp,

View file

@ -306,7 +306,6 @@ void v3dv_job_start_frame(struct v3dv_job *job,
uint32_t height,
uint32_t layers,
bool allocate_tile_state_for_all_layers,
bool allocate_tile_state_now,
uint32_t render_target_count,
uint8_t max_internal_bpp,
uint8_t total_color_bpp,

View file

@ -138,9 +138,8 @@ clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
if (!job)
return true;
v3dv_job_start_frame(job, width, height, max_layer,
false, true, 1, internal_bpp,
4 * v3d_internal_bpp_words(internal_bpp),
v3dv_job_start_frame(job, width, height, max_layer, false, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
image->vk.samples > VK_SAMPLE_COUNT_1_BIT);
struct v3dv_meta_framebuffer framebuffer;
@ -149,6 +148,8 @@ clear_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
&job->frame_tiling);
v3d_X((&job->device->devinfo), job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return true;
/* If this triggers it is an application bug: the spec requires
* that any aspects to clear are present in the image.

View file

@ -485,15 +485,17 @@ copy_image_to_buffer_tlb(struct v3dv_cmd_buffer *cmd_buffer,
const uint32_t width = DIV_ROUND_UP(region->imageExtent.width, block_w);
const uint32_t height = DIV_ROUND_UP(region->imageExtent.height, block_h);
v3dv_job_start_frame(job, width, height, num_layers, false, true, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
false);
v3dv_job_start_frame(job, width, height, num_layers, false, 1, internal_bpp,
4 * v3d_internal_bpp_words(internal_bpp), false);
struct v3dv_meta_framebuffer framebuffer;
v3d_X((&job->device->devinfo), meta_framebuffer_init)(&framebuffer, fb_format,
internal_type, &job->frame_tiling);
v3d_X((&job->device->devinfo), job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return true;
v3d_X((&job->device->devinfo), meta_emit_copy_image_to_buffer_rcl)
(job, buffer, image, &framebuffer, region);
@ -1377,7 +1379,7 @@ copy_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
const uint32_t width = DIV_ROUND_UP(region->extent.width, block_w);
const uint32_t height = DIV_ROUND_UP(region->extent.height, block_h);
v3dv_job_start_frame(job, width, height, num_layers, false, true, 1,
v3dv_job_start_frame(job, width, height, num_layers, false, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
src->vk.samples > VK_SAMPLE_COUNT_1_BIT);
@ -1386,6 +1388,9 @@ copy_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
internal_type, &job->frame_tiling);
v3d_X((&job->device->devinfo), job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return true;
v3d_X((&job->device->devinfo), meta_emit_copy_image_rcl)(job, dst, src, &framebuffer, region);
v3dv_cmd_buffer_finish_job(cmd_buffer);
@ -2061,7 +2066,7 @@ copy_buffer_to_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
const uint32_t width = DIV_ROUND_UP(region->imageExtent.width, block_w);
const uint32_t height = DIV_ROUND_UP(region->imageExtent.height, block_h);
v3dv_job_start_frame(job, width, height, num_layers, false, true, 1,
v3dv_job_start_frame(job, width, height, num_layers, false, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
false);
@ -2070,6 +2075,9 @@ copy_buffer_to_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
internal_type, &job->frame_tiling);
v3d_X((&job->device->devinfo), job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return true;
v3d_X((&job->device->devinfo), meta_emit_copy_buffer_to_image_rcl)
(job, image, buffer, &framebuffer, region);
@ -4923,15 +4931,17 @@ resolve_image_tlb(struct v3dv_cmd_buffer *cmd_buffer,
(resolve_format, region->srcSubresource.aspectMask,
&internal_type, &internal_bpp);
v3dv_job_start_frame(job, width, height, num_layers, false, true, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
true);
v3dv_job_start_frame(job, width, height, num_layers, false, 1, internal_bpp,
4 * v3d_internal_bpp_words(internal_bpp), true);
struct v3dv_meta_framebuffer framebuffer;
v3d_X((&job->device->devinfo), meta_framebuffer_init)(&framebuffer, resolve_format,
internal_type, &job->frame_tiling);
v3d_X((&job->device->devinfo), job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return true;
v3d_X((&job->device->devinfo), meta_emit_resolve_image_rcl)(job, dst, src,
&framebuffer, region);

View file

@ -1410,15 +1410,16 @@ v3dX(meta_copy_buffer)(struct v3dv_cmd_buffer *cmd_buffer,
uint32_t width, height;
framebuffer_size_for_pixel_count(num_items, &width, &height);
v3dv_job_start_frame(job, width, height, 1, true, true, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
false);
v3dv_job_start_frame(job, width, height, 1, true, 1, internal_bpp,
4 * v3d_internal_bpp_words(internal_bpp), false);
struct v3dv_meta_framebuffer framebuffer;
v3dX(meta_framebuffer_init)(&framebuffer, vk_format, internal_type,
&job->frame_tiling);
v3dX(job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return NULL;
v3dX(meta_emit_copy_buffer_rcl)(job, dst, src, dst_offset, src_offset,
&framebuffer, format, item_size);
@ -1458,15 +1459,16 @@ v3dX(meta_fill_buffer)(struct v3dv_cmd_buffer *cmd_buffer,
uint32_t width, height;
framebuffer_size_for_pixel_count(num_items, &width, &height);
v3dv_job_start_frame(job, width, height, 1, true, true, 1,
internal_bpp, 4 * v3d_internal_bpp_words(internal_bpp),
false);
v3dv_job_start_frame(job, width, height, 1, true, 1, internal_bpp,
4 * v3d_internal_bpp_words(internal_bpp), false);
struct v3dv_meta_framebuffer framebuffer;
v3dX(meta_framebuffer_init)(&framebuffer, VK_FORMAT_R8G8B8A8_UINT,
internal_type, &job->frame_tiling);
v3dX(job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return;
v3dX(meta_emit_fill_buffer_rcl)(job, bo, offset, &framebuffer, data);

View file

@ -30,9 +30,10 @@
void
v3dX(job_emit_noop)(struct v3dv_job *job)
{
v3dv_job_start_frame(job, 1, 1, 1, true, true, 1,
V3D_INTERNAL_BPP_32, 4, false);
v3dv_job_start_frame(job, 1, 1, 1, true, 1, V3D_INTERNAL_BPP_32, 4, false);
v3dX(job_emit_binning_flush)(job);
if (!v3dv_job_allocate_tile_state(job))
return;
struct v3dv_cl *rcl = &job->rcl;
v3dv_cl_ensure_space_with_branch(rcl, 200 + 1 * 256 *