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.
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
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],