From 5e481bb5b85de9c616e37ca0537f264df056612c Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 14 Jul 2022 11:08:49 +0200 Subject: [PATCH] v3dv: stop tracking push constant buffer references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we allocate this ourselves we can immediately add it to the job at the time we allocate it. This also fixes a bug we introduced when we implemented inline uniforms because since that commit, if we had an inline uniform buffer at index 1 which happend to have indirect access we would track it in slot 0 instead of slot 1, potentially overwriting the push constant buffer reference. Fixes: ea3223e7a46 ('v3dv: implement VK_EXT_inline_uniform_block') Reviewed-by: Alejandro PiƱeiro Part-of: (cherry picked from commit e451c612df87fc8033d9be64be0c449bd9a17191) --- .pick_status.json | 2 +- src/broadcom/vulkan/v3dv_uniforms.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 303077a4e65..dfe383f095a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4360,7 +4360,7 @@ "description": "v3dv: stop tracking push constant buffer references", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "ea3223e7a4690571583f3a0f2d7c9580952e67d8" }, diff --git a/src/broadcom/vulkan/v3dv_uniforms.c b/src/broadcom/vulkan/v3dv_uniforms.c index 8f14d0195a7..15ef326a51e 100644 --- a/src/broadcom/vulkan/v3dv_uniforms.c +++ b/src/broadcom/vulkan/v3dv_uniforms.c @@ -56,8 +56,8 @@ struct state_bo_list { struct v3dv_bo *states[MAX_TOTAL_STATES]; }; -#define MAX_TOTAL_UNIFORM_BUFFERS (1 + (MAX_UNIFORM_BUFFERS + \ - MAX_INLINE_UNIFORM_BUFFERS) * MAX_STAGES) +#define MAX_TOTAL_UNIFORM_BUFFERS ((MAX_UNIFORM_BUFFERS + \ + MAX_INLINE_UNIFORM_BUFFERS) * MAX_STAGES) #define MAX_TOTAL_STORAGE_BUFFERS (MAX_STORAGE_BUFFERS * MAX_STAGES) struct buffer_bo_list { struct v3dv_bo *ubo[MAX_TOTAL_UNIFORM_BUFFERS]; @@ -98,6 +98,9 @@ check_push_constants_ubo(struct v3dv_cmd_buffer *cmd_buffer, v3dv_bo_alloc(cmd_buffer->device, MAX_PUSH_CONSTANTS_SIZE, "push constants", true); + v3dv_job_add_bo(cmd_buffer->state.job, + cmd_buffer->push_constants_resource.bo); + if (!cmd_buffer->push_constants_resource.bo) { fprintf(stderr, "Failed to allocate memory for push constants\n"); abort(); @@ -254,9 +257,8 @@ write_ubo_ssbo_uniforms(struct v3dv_cmd_buffer *cmd_buffer, */ uint32_t index = v3d_unit_data_get_unit(data); if (content == QUNIFORM_UBO_ADDR && index == 0) { - /* This calls is to ensure that the push_constant_ubo is - * updated. It already take into account it is should do the - * update or not + /* Ensure the push constants UBO is created and updated. This also + * adds the BO to the job so we don't need to track it in buffer_bos. */ check_push_constants_ubo(cmd_buffer, pipeline); @@ -267,7 +269,6 @@ write_ubo_ssbo_uniforms(struct v3dv_cmd_buffer *cmd_buffer, cl_aligned_u32(uniforms, resource->bo->offset + resource->offset + offset + dynamic_offset); - buffer_bos->ubo[0] = resource->bo; } else { if (content == QUNIFORM_UBO_ADDR) { /* We reserve index 0 for push constants and artificially increase our