vrend: Cache VS and FS id's in program to speed up comparison

This gives a 6% speed improvement with Unigine Heaven

v2: remove the unlikely for dual_src, the whole statement will
    be changed later (Chia-I Wu)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Gert Wollny 4 years ago
parent 9ad6f60c50
commit 5f1f099222
  1. 8
      src/vrend_renderer.c

@ -355,6 +355,7 @@ struct vrend_linked_shader_program {
bool dual_src_linked; bool dual_src_linked;
struct vrend_shader *ss[PIPE_SHADER_TYPES]; struct vrend_shader *ss[PIPE_SHADER_TYPES];
uint64_t vs_fs_key;
uint32_t ubo_used_mask[PIPE_SHADER_TYPES]; uint32_t ubo_used_mask[PIPE_SHADER_TYPES];
uint32_t samplers_used_mask[PIPE_SHADER_TYPES]; uint32_t samplers_used_mask[PIPE_SHADER_TYPES];
@ -1589,6 +1590,7 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
sprog->ss[PIPE_SHADER_VERTEX] = vs; sprog->ss[PIPE_SHADER_VERTEX] = vs;
sprog->ss[PIPE_SHADER_FRAGMENT] = fs; sprog->ss[PIPE_SHADER_FRAGMENT] = fs;
sprog->vs_fs_key = (uint64_t)vs->id << 32 | fs->id;
sprog->ss[PIPE_SHADER_GEOMETRY] = gs; sprog->ss[PIPE_SHADER_GEOMETRY] = gs;
sprog->ss[PIPE_SHADER_TESS_CTRL] = tcs; sprog->ss[PIPE_SHADER_TESS_CTRL] = tcs;
sprog->ss[PIPE_SHADER_TESS_EVAL] = tes; sprog->ss[PIPE_SHADER_TESS_EVAL] = tes;
@ -1674,15 +1676,15 @@ static struct vrend_linked_shader_program *lookup_shader_program(struct vrend_co
GLuint tes_id, GLuint tes_id,
bool dual_src) bool dual_src)
{ {
uint64_t vs_fs_key = (((uint64_t)vs_id) << 32) | fs_id;
struct vrend_linked_shader_program *ent; struct vrend_linked_shader_program *ent;
LIST_FOR_EACH_ENTRY(ent, &ctx->sub->programs, head) { LIST_FOR_EACH_ENTRY(ent, &ctx->sub->programs, head) {
if (ent->dual_src_linked != dual_src) if (ent->dual_src_linked != dual_src)
continue; continue;
if (ent->ss[PIPE_SHADER_COMPUTE]) if (ent->ss[PIPE_SHADER_COMPUTE])
continue; continue;
if (ent->ss[PIPE_SHADER_VERTEX]->id != vs_id) if (unlikely(ent->vs_fs_key != vs_fs_key))
continue;
if (ent->ss[PIPE_SHADER_FRAGMENT]->id != fs_id)
continue; continue;
if (ent->ss[PIPE_SHADER_GEOMETRY] && if (ent->ss[PIPE_SHADER_GEOMETRY] &&
ent->ss[PIPE_SHADER_GEOMETRY]->id != gs_id) ent->ss[PIPE_SHADER_GEOMETRY]->id != gs_id)

Loading…
Cancel
Save