From e5201987b1bac5caad71a857b35689f4e7fa117b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Wed, 5 Apr 2023 23:15:58 +0200 Subject: [PATCH] radv/amdgpu: Extract radv_amdgpu_cs_add_old_ib_buffer. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This function will be used elsewhere in a following commit. Signed-off-by: Timur Kristóf Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c index 50e25b6..7ccd859 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c @@ -301,6 +301,25 @@ static uint32_t get_nop_packet(struct radv_amdgpu_cs *cs) } static void +radv_amdgpu_cs_add_old_ib_buffer(struct radv_amdgpu_cs *cs) +{ + if (cs->num_old_ib_buffers == cs->max_num_old_ib_buffers) { + unsigned max_num_old_ib_buffers = MAX2(1, cs->max_num_old_ib_buffers * 2); + struct radv_amdgpu_ib *old_ib_buffers = + realloc(cs->old_ib_buffers, max_num_old_ib_buffers * sizeof(*old_ib_buffers)); + if (!old_ib_buffers) { + cs->status = VK_ERROR_OUT_OF_HOST_MEMORY; + return; + } + cs->max_num_old_ib_buffers = max_num_old_ib_buffers; + cs->old_ib_buffers = old_ib_buffers; + } + + cs->old_ib_buffers[cs->num_old_ib_buffers].bo = cs->ib_buffer; + cs->old_ib_buffers[cs->num_old_ib_buffers++].cdw = cs->base.cdw; +} + +static void radv_amdgpu_cs_grow(struct radeon_cmdbuf *_cs, size_t min_size) { struct radv_amdgpu_cs *cs = radv_amdgpu_cs(_cs); @@ -367,20 +386,9 @@ radv_amdgpu_cs_grow(struct radeon_cmdbuf *_cs, size_t min_size) *cs->ib_size_ptr |= cs->base.cdw + 4; - if (cs->num_old_ib_buffers == cs->max_num_old_ib_buffers) { - unsigned max_num_old_ib_buffers = MAX2(1, cs->max_num_old_ib_buffers * 2); - struct radv_amdgpu_ib *old_ib_buffers = - realloc(cs->old_ib_buffers, max_num_old_ib_buffers * sizeof(*old_ib_buffers)); - if (!old_ib_buffers) { - cs->status = VK_ERROR_OUT_OF_HOST_MEMORY; - return; - } - cs->max_num_old_ib_buffers = max_num_old_ib_buffers; - cs->old_ib_buffers = old_ib_buffers; - } - - cs->old_ib_buffers[cs->num_old_ib_buffers].bo = cs->ib_buffer; - cs->old_ib_buffers[cs->num_old_ib_buffers++].cdw = cs->base.cdw; + radv_amdgpu_cs_add_old_ib_buffer(cs); + if (cs->status != VK_SUCCESS) + return; uint64_t ib_size = MAX2(min_size * 4 + 16, cs->base.max_dw * 4 * 2); -- 2.7.4