From b9f7be9e987fa4535b8ace9c30b1c4c46bba42b2 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 15 Jan 2021 13:04:11 +0100 Subject: [PATCH] vrend: move last used shader program in front of the list With that shaders that are used more frequently will remain at the top of the list, and since the search in the shader program list is linear, this should save some time. Signed-off-by: Gert Wollny Reviewed-by: Chia-I Wu --- src/vrend_renderer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index c9bf8bb..27b44f6 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1662,8 +1662,11 @@ static struct vrend_linked_shader_program *lookup_cs_shader_program(struct vrend LIST_FOR_EACH_ENTRY(ent, &ctx->sub->programs, head) { if (!ent->ss[PIPE_SHADER_COMPUTE]) continue; - if (ent->ss[PIPE_SHADER_COMPUTE]->id == cs_id) + if (ent->ss[PIPE_SHADER_COMPUTE]->id == cs_id) { + list_del(&ent->head); + list_add(&ent->head, &ctx->sub->programs); return ent; + } } return NULL; } @@ -1697,6 +1700,11 @@ static struct vrend_linked_shader_program *lookup_shader_program(struct vrend_co continue; return ent; } + + /* put the entry in front */ + list_del(&ent->head); + list_add(&ent->head, &ctx->sub->programs); + return NULL; }