From: Timur Kristóf Date: Mon, 24 Apr 2023 14:46:41 +0000 (+0200) Subject: radv/amdgpu: Use STACK_ARRAY for IB array to reduce stack usage. X-Git-Tag: upstream/23.3.3~8647 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53b439d24fae8a02385d6b04b85024c706c0c256;p=platform%2Fupstream%2Fmesa.git radv/amdgpu: Use STACK_ARRAY for IB array to reduce stack usage. Signed-off-by: Timur Kristóf Reviewed-by: Bas Nieuwenhuizen Part-of: --- diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c index 6c7be42..644a504 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c @@ -909,10 +909,17 @@ radv_amdgpu_winsys_cs_submit_internal( struct radv_amdgpu_cs *last_cs = radv_amdgpu_cs(cs_array[cs_count - 1]); struct radv_amdgpu_winsys *ws = last_cs->ws; + assert(cs_count); + const unsigned num_pre_post_cs = + MAX2(initial_preamble_count, continue_preamble_count) + postamble_count; + const unsigned ib_array_size = MIN2(RADV_MAX_IBS_PER_SUBMIT, num_pre_post_cs + cs_count); + STACK_ARRAY(struct radv_amdgpu_cs_ib_info, ibs, ib_array_size); + struct drm_amdgpu_bo_list_entry *handles = NULL; unsigned num_handles = 0; u_rwlock_rdlock(&ws->global_bo_list.lock); + result = radv_amdgpu_get_bo_list( ws, &cs_array[0], cs_count, initial_preamble_cs, initial_preamble_count, continue_preamble_cs, continue_preamble_count, postamble_cs, postamble_count, &num_handles, &handles); @@ -921,7 +928,6 @@ radv_amdgpu_winsys_cs_submit_internal( /* Configure the CS request. */ const uint8_t *max_ib_per_ip = ws->info.max_submitted_ibs; - struct radv_amdgpu_cs_ib_info ibs[RADV_MAX_IBS_PER_SUBMIT]; struct radv_amdgpu_cs_request request = { .ip_type = last_cs->hw_ip, .ip_instance = 0, @@ -932,10 +938,6 @@ radv_amdgpu_winsys_cs_submit_internal( .number_of_ibs = 0, /* set below */ }; - assert(cs_count); - assert(MAX2(initial_preamble_count, continue_preamble_count) + postamble_count < - RADV_MAX_IBS_PER_SUBMIT); - for (unsigned cs_idx = 0, cs_ib_idx = 0; cs_idx < cs_count;) { struct radeon_cmdbuf **preambles = cs_idx ? continue_preamble_cs : initial_preamble_cs; const unsigned preamble_count = cs_idx ? continue_preamble_count : initial_preamble_count; @@ -1029,6 +1031,7 @@ radv_amdgpu_winsys_cs_submit_internal( fail: u_rwlock_rdunlock(&ws->global_bo_list.lock); + STACK_ARRAY_FINISH(ibs); return result; }