Re: [Mesa-dev] [PATCH] radv: reduce CPU overhead merging bo lists.
On 11 February 2017 at 04:30, Bas Nieuwenhuizenwrote: > Was thinking of a sort or other asymptotically more efficient merge > method, but in the meantime this is I did get that, I just didn't have the brain power to work out what would be better, so just optimised the current code for now. Dave. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] radv: reduce CPU overhead merging bo lists.
Was thinking of a sort or other asymptotically more efficient merge method, but in the meantime this is Reviewed-by: Bas NieuwenhuizenOn Fri, Feb 10, 2017, at 02:07, Dave Airlie wrote: > From: Dave Airlie > > Just noticed we do a fair bit of unneeded searching here. > > Since we know that the buffers in a CS are unique already, > the first time we get any buffers, we can just memcpy those into > place, and when we are searching for subsequent CSes, we only > have to search up until where the previous unique buffers were. > > Signed-off-by: Dave Airlie > --- > src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 12 +++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c > b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c > index b58f5db..9e468bd 100644 > --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c > +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c > @@ -486,9 +486,19 @@ static int radv_amdgpu_create_bo_list(struct > radv_amdgpu_winsys *ws, > else > cs = (struct radv_amdgpu_cs*)cs_array[i]; > > + if (!cs->num_buffers) > + continue; > + > + if (unique_bo_count == 0) { > + memcpy(handles, cs->handles, > cs->num_buffers * sizeof(amdgpu_bo_handle)); > + memcpy(priorities, cs->priorities, > cs->num_buffers * sizeof(uint8_t)); > + unique_bo_count = cs->num_buffers; > + continue; > + } > + int unique_bo_so_far = unique_bo_count; > for (unsigned j = 0; j < cs->num_buffers; ++j) { > bool found = false; > - for (unsigned k = 0; k < unique_bo_count; > ++k) { > + for (unsigned k = 0; k < > unique_bo_so_far; ++k) { > if (handles[k] == cs->handles[j]) { > found = true; > priorities[k] = > MAX2(priorities[k], > -- > 2.7.4 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] radv: reduce CPU overhead merging bo lists.
From: Dave AirlieJust noticed we do a fair bit of unneeded searching here. Since we know that the buffers in a CS are unique already, the first time we get any buffers, we can just memcpy those into place, and when we are searching for subsequent CSes, we only have to search up until where the previous unique buffers were. Signed-off-by: Dave Airlie --- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c index b58f5db..9e468bd 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c @@ -486,9 +486,19 @@ static int radv_amdgpu_create_bo_list(struct radv_amdgpu_winsys *ws, else cs = (struct radv_amdgpu_cs*)cs_array[i]; + if (!cs->num_buffers) + continue; + + if (unique_bo_count == 0) { + memcpy(handles, cs->handles, cs->num_buffers * sizeof(amdgpu_bo_handle)); + memcpy(priorities, cs->priorities, cs->num_buffers * sizeof(uint8_t)); + unique_bo_count = cs->num_buffers; + continue; + } + int unique_bo_so_far = unique_bo_count; for (unsigned j = 0; j < cs->num_buffers; ++j) { bool found = false; - for (unsigned k = 0; k < unique_bo_count; ++k) { + for (unsigned k = 0; k < unique_bo_so_far; ++k) { if (handles[k] == cs->handles[j]) { found = true; priorities[k] = MAX2(priorities[k], -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev