diff options
author | Marek Olšák <[email protected]> | 2019-11-01 22:19:28 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-11-19 18:02:06 -0500 |
commit | c97df7b4c75797e508e76e7f5c83526edfd3e037 (patch) | |
tree | 797c4c2f700a7c45a3aea62f4bb70b6ebf34715b /src/mesa | |
parent | f71e93db0ab2d00602fe5235fad6583887ffd754 (diff) |
st/mesa: consolidate and simplify code flagging program::affected_states
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_program.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_shader_cache.c | 11 |
5 files changed, 20 insertions, 30 deletions
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index ccf58b10e9e..ffc64bd83f1 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -110,7 +110,7 @@ enum { ST_NEW_SAMPLE_STATE | \ ST_NEW_SAMPLE_SHADING) -#define ST_NEW_VERTEX_PROGRAM(st, p) (p->affected_states | \ +#define ST_NEW_VERTEX_PROGRAM(st, p) ((p)->affected_states | \ (st_user_clip_planes_enabled(st->ctx) ? \ ST_NEW_CLIP_STATE : 0)) diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 50fa5d2ad67..62a67cf7fa8 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -150,9 +150,6 @@ st_program_string_notify( struct gl_context *ctx, if (!stfp->shader_program && /* not GLSL->NIR */ !st_translate_fragment_program(st, stfp)) return false; - - if (st->fp == stfp) - st->dirty |= stfp->affected_states; } else if (target == GL_VERTEX_PROGRAM_ARB) { struct st_vertex_program *stvp = (struct st_vertex_program *) prog; @@ -160,9 +157,6 @@ st_program_string_notify( struct gl_context *ctx, if (!stvp->shader_program && /* not GLSL->NIR */ !st_translate_vertex_program(st, stvp)) return false; - - if (st->vp == stvp) - st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp); } else { struct st_common_program *stcp = st_common_program(prog); @@ -170,12 +164,6 @@ st_program_string_notify( struct gl_context *ctx, if (!stcp->shader_program && /* not GLSL->NIR */ !st_translate_common_program(st, stcp)) return false; - - if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) || - (prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) || - (prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) || - (prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp)) - st->dirty |= stcp->affected_states; } st_finalize_program(st, prog); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 21ba2f41ac0..cf2f636df6e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -244,12 +244,17 @@ struct st_context */ unsigned active_queries; - struct st_vertex_program *vp; /**< Currently bound vertex program */ - struct st_common_program *fp; /**< Currently bound fragment program */ - struct st_common_program *gp; /**< Currently bound geometry program */ - struct st_common_program *tcp; /**< Currently bound tess control program */ - struct st_common_program *tep; /**< Currently bound tess eval program */ - struct st_common_program *cp; /**< Currently bound compute program */ + union { + struct { + struct st_vertex_program *vp; /**< Currently bound vertex program */ + struct st_common_program *tcp; /**< Currently bound tess control program */ + struct st_common_program *tep; /**< Currently bound tess eval program */ + struct st_common_program *gp; /**< Currently bound geometry program */ + struct st_common_program *fp; /**< Currently bound fragment program */ + struct st_common_program *cp; /**< Currently bound compute program */ + }; + struct gl_program *current_program[MESA_SHADER_STAGES]; + }; struct st_vp_variant *vp_variant; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 597a0a6135f..05b5353780d 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -62,6 +62,7 @@ #include "st_atifs_to_tgsi.h" #include "st_nir.h" #include "st_shader_cache.h" +#include "st_util.h" #include "cso_cache/cso_context.h" @@ -2054,6 +2055,13 @@ st_precompile_shader_variant(struct st_context *st, void st_finalize_program(struct st_context *st, struct gl_program *prog) { + if (st->current_program[prog->info.stage] == prog) { + if (prog->info.stage == MESA_SHADER_VERTEX) + st->dirty |= ST_NEW_VERTEX_PROGRAM(st, (struct st_vertex_program *)prog); + else + st->dirty |= ((struct st_common_program *)prog)->affected_states; + } + /* Create Gallium shaders now instead of on demand. */ if (ST_DEBUG & DEBUG_PRECOMPILE || st->shader_has_one_variant[prog->info.stage]) diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index 5cd969f3fe5..a5b755b04ec 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -214,10 +214,6 @@ st_deserialise_ir_program(struct gl_context *ctx, } else { read_tgsi_from_cache(&blob_reader, &stvp->state.tokens); } - - if (st->vp == stvp) - st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp); - break; } case MESA_SHADER_TESS_CTRL: @@ -244,13 +240,6 @@ st_deserialise_ir_program(struct gl_context *ctx, } else { read_tgsi_from_cache(&blob_reader, &stcp->state.tokens); } - - if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) || - (prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) || - (prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) || - (prog->info.stage == MESA_SHADER_FRAGMENT && st->fp == stcp) || - (prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp)) - st->dirty |= stcp->affected_states; break; } default: |