diff options
author | Eric Anholt <[email protected]> | 2014-10-10 14:17:15 +0200 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-10-10 15:49:22 +0200 |
commit | d09509da2aa5ff709c48bdc4163a2c57811c70ab (patch) | |
tree | 3bdeeeeda0d651036af40fbaaeaafb765ec64edf | |
parent | c6f50c4086a96c3a8d84522ed7ee5c75a8b0868c (diff) |
vc4: Don't look up the compiled shaders unless state has changed.
Improves simulated norast performance on a little benchmark by 38.0965%
+/- 3.27534% (n=11).
-rw-r--r-- | src/gallium/drivers/vc4/vc4_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_draw.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 20 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h index da07cfa6cb2..31dec046860 100644 --- a/src/gallium/drivers/vc4/vc4_context.h +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -57,6 +57,7 @@ #define VC4_DIRTY_INDEXBUF (1 << 16) #define VC4_DIRTY_SCISSOR (1 << 17) #define VC4_DIRTY_FLAT_SHADE_FLAGS (1 << 18) +#define VC4_DIRTY_PRIM_MODE (1 << 19) #define VC4_SHADER_DIRTY_VP (1 << 0) #define VC4_SHADER_DIRTY_FP (1 << 1) @@ -177,6 +178,8 @@ struct vc4_context { unsigned int reg_class_any; unsigned int reg_class_a; + uint8_t prim_mode; + /** @{ Current pipeline state objects */ struct pipe_scissor_state scissor; struct pipe_blend_state *blend; diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index bc08da3734c..1a0c0dc6552 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -99,6 +99,11 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) struct vc4_vertex_stateobj *vtx = vc4->vtx; struct vc4_vertexbuf_stateobj *vertexbuf = &vc4->vertexbuf; + if (vc4->prim_mode != info->mode) { + vc4->prim_mode = info->mode; + vc4->dirty |= VC4_DIRTY_PRIM_MODE; + } + vc4_start_draw(vc4); vc4_update_compiled_shaders(vc4, info->mode); diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index bf76acff2cd..b22426cf9aa 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1792,6 +1792,17 @@ vc4_update_compiled_fs(struct vc4_context *vc4, uint8_t prim_mode) struct vc4_fs_key local_key; struct vc4_fs_key *key = &local_key; + if (!(vc4->dirty & (VC4_DIRTY_PRIM_MODE | + VC4_DIRTY_BLEND | + VC4_DIRTY_FRAMEBUFFER | + VC4_DIRTY_ZSA | + VC4_DIRTY_RASTERIZER | + VC4_DIRTY_FRAGTEX | + VC4_DIRTY_TEXSTATE | + VC4_DIRTY_PROG))) { + return; + } + memset(key, 0, sizeof(*key)); vc4_setup_shared_key(&key->base, &vc4->fragtex); key->base.shader_state = vc4->prog.bind_fs; @@ -1840,6 +1851,15 @@ vc4_update_compiled_vs(struct vc4_context *vc4, uint8_t prim_mode) struct vc4_vs_key local_key; struct vc4_vs_key *key = &local_key; + if (!(vc4->dirty & (VC4_DIRTY_PRIM_MODE | + VC4_DIRTY_RASTERIZER | + VC4_DIRTY_VERTTEX | + VC4_DIRTY_TEXSTATE | + VC4_DIRTY_VTXSTATE | + VC4_DIRTY_PROG))) { + return; + } + memset(key, 0, sizeof(*key)); vc4_setup_shared_key(&key->base, &vc4->verttex); key->base.shader_state = vc4->prog.bind_vs; |