mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 00:40:09 +01:00
virgl: Simply loop over the resources to figure-out if it is already added
There is not that many resources added to a command buffer to justify the resource id being cached. Signed-off-by: Corentin Noël <corentin.noel@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32134>
This commit is contained in:
parent
758941ab0c
commit
a7c8677241
4 changed files with 15 additions and 51 deletions
|
|
@ -759,24 +759,14 @@ static void virgl_drm_free_res_list(struct virgl_drm_cmd_buf *cbuf)
|
|||
FREE(cbuf->res_bo);
|
||||
}
|
||||
|
||||
static bool virgl_drm_lookup_res(struct virgl_drm_cmd_buf *cbuf,
|
||||
struct virgl_hw_res *res)
|
||||
static bool virgl_drm_res_is_added(struct virgl_drm_cmd_buf *cbuf,
|
||||
struct virgl_hw_res *res)
|
||||
{
|
||||
unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
|
||||
int i;
|
||||
|
||||
if (cbuf->is_handle_added[hash]) {
|
||||
i = cbuf->reloc_indices_hashlist[hash];
|
||||
for (int i = 0; i < cbuf->cres; i++) {
|
||||
if (cbuf->res_bo[i] == res)
|
||||
return true;
|
||||
|
||||
for (i = 0; i < cbuf->cres; i++) {
|
||||
if (cbuf->res_bo[i] == res) {
|
||||
cbuf->reloc_indices_hashlist[hash] = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -784,7 +774,9 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
|
|||
struct virgl_drm_cmd_buf *cbuf,
|
||||
struct virgl_hw_res *res)
|
||||
{
|
||||
unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
|
||||
bool already_in_list = virgl_drm_res_is_added(cbuf, res);
|
||||
if (unlikely(already_in_list))
|
||||
return;
|
||||
|
||||
if (cbuf->cres >= cbuf->nres) {
|
||||
unsigned new_nres = cbuf->nres + 256;
|
||||
|
|
@ -811,9 +803,6 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
|
|||
cbuf->res_bo[cbuf->cres] = NULL;
|
||||
virgl_drm_resource_reference(&qdws->base, &cbuf->res_bo[cbuf->cres], res);
|
||||
cbuf->res_hlist[cbuf->cres] = res->bo_handle;
|
||||
cbuf->is_handle_added[hash] = true;
|
||||
|
||||
cbuf->reloc_indices_hashlist[hash] = cbuf->cres;
|
||||
p_atomic_inc(&res->num_cs_references);
|
||||
cbuf->cres++;
|
||||
}
|
||||
|
|
@ -832,8 +821,6 @@ static void virgl_drm_clear_res_list(struct virgl_drm_cmd_buf *cbuf)
|
|||
}
|
||||
|
||||
cbuf->cres = 0;
|
||||
|
||||
memset(cbuf->is_handle_added, 0, sizeof(cbuf->is_handle_added));
|
||||
}
|
||||
|
||||
static void virgl_drm_emit_res(struct virgl_winsys *qws,
|
||||
|
|
@ -842,13 +829,11 @@ static void virgl_drm_emit_res(struct virgl_winsys *qws,
|
|||
{
|
||||
struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws);
|
||||
struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf);
|
||||
bool already_in_list = virgl_drm_lookup_res(cbuf, res);
|
||||
|
||||
if (write_buf)
|
||||
cbuf->base.buf[cbuf->base.cdw++] = res->res_handle;
|
||||
|
||||
if (!already_in_list)
|
||||
virgl_drm_add_res(qdws, cbuf, res);
|
||||
virgl_drm_add_res(qdws, cbuf, res);
|
||||
}
|
||||
|
||||
static bool virgl_drm_res_is_ref(struct virgl_winsys *qws,
|
||||
|
|
|
|||
|
|
@ -120,10 +120,6 @@ struct virgl_drm_cmd_buf {
|
|||
struct virgl_hw_res **res_bo;
|
||||
struct virgl_winsys *ws;
|
||||
uint32_t *res_hlist;
|
||||
|
||||
char is_handle_added[512];
|
||||
unsigned reloc_indices_hashlist[512];
|
||||
|
||||
};
|
||||
|
||||
static inline struct virgl_drm_winsys *
|
||||
|
|
|
|||
|
|
@ -415,24 +415,14 @@ alloc:
|
|||
return res;
|
||||
}
|
||||
|
||||
static bool virgl_vtest_lookup_res(struct virgl_vtest_cmd_buf *cbuf,
|
||||
static bool virgl_vtest_res_is_added(struct virgl_vtest_cmd_buf *cbuf,
|
||||
struct virgl_hw_res *res)
|
||||
{
|
||||
unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
|
||||
int i;
|
||||
|
||||
if (cbuf->is_handle_added[hash]) {
|
||||
i = cbuf->reloc_indices_hashlist[hash];
|
||||
for (int i = 0; i < cbuf->cres; i++) {
|
||||
if (cbuf->res_bo[i] == res)
|
||||
return true;
|
||||
|
||||
for (i = 0; i < cbuf->cres; i++) {
|
||||
if (cbuf->res_bo[i] == res) {
|
||||
cbuf->reloc_indices_hashlist[hash] = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +442,9 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws,
|
|||
struct virgl_vtest_cmd_buf *cbuf,
|
||||
struct virgl_hw_res *res)
|
||||
{
|
||||
unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
|
||||
bool already_in_list = virgl_vtest_res_is_added(cbuf, res);
|
||||
if (unlikely(already_in_list))
|
||||
return;
|
||||
|
||||
if (cbuf->cres >= cbuf->nres) {
|
||||
unsigned new_nres = cbuf->nres + 256;
|
||||
|
|
@ -470,9 +462,6 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws,
|
|||
|
||||
cbuf->res_bo[cbuf->cres] = NULL;
|
||||
virgl_vtest_resource_reference(&vtws->base, &cbuf->res_bo[cbuf->cres], res);
|
||||
cbuf->is_handle_added[hash] = true;
|
||||
|
||||
cbuf->reloc_indices_hashlist[hash] = cbuf->cres;
|
||||
p_atomic_inc(&res->num_cs_references);
|
||||
cbuf->cres++;
|
||||
}
|
||||
|
|
@ -549,7 +538,6 @@ static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws,
|
|||
*fence = virgl_vtest_fence_create(vws);
|
||||
|
||||
virgl_vtest_release_all_res(vtws, cbuf);
|
||||
memset(cbuf->is_handle_added, 0, sizeof(cbuf->is_handle_added));
|
||||
cbuf->base.cdw = 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -560,12 +548,10 @@ static void virgl_vtest_emit_res(struct virgl_winsys *vws,
|
|||
{
|
||||
struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
|
||||
struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf);
|
||||
bool already_in_list = virgl_vtest_lookup_res(cbuf, res);
|
||||
|
||||
if (write_buf)
|
||||
cbuf->base.buf[cbuf->base.cdw++] = res->res_handle;
|
||||
if (!already_in_list)
|
||||
virgl_vtest_add_res(vtws, cbuf, res);
|
||||
virgl_vtest_add_res(vtws, cbuf, res);
|
||||
}
|
||||
|
||||
static bool virgl_vtest_res_is_ref(struct virgl_winsys *vws,
|
||||
|
|
|
|||
|
|
@ -79,9 +79,6 @@ struct virgl_vtest_cmd_buf {
|
|||
unsigned cres;
|
||||
struct virgl_winsys *ws;
|
||||
struct virgl_hw_res **res_bo;
|
||||
|
||||
char is_handle_added[512];
|
||||
unsigned reloc_indices_hashlist[512];
|
||||
};
|
||||
|
||||
static inline struct virgl_hw_res *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue