diff options
author | Marek Olšák <[email protected]> | 2016-08-02 16:59:41 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-08-12 18:50:01 +0200 |
commit | ac032d800e5f4cb3ab9166187150a93c17a508aa (patch) | |
tree | c17d1b8bea029be2ab7d47d1329dda13c9d71837 | |
parent | c323d5b8096cec3251c7a4a4269f0f7570fb274f (diff) |
st/mesa: _NEW_TEXTURE & CONSTANTS shouldn't flag states that aren't used
Tested-by: Edmondo Tommasina <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 54 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 6 |
3 files changed, 60 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index c206343b16b..37e382c4456 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -134,6 +134,14 @@ enum { ST_NEW_FS_IMAGES | \ ST_NEW_CS_IMAGES) +#define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \ + ST_NEW_SAMPLERS | \ + ST_NEW_CONSTANTS | \ + ST_NEW_UNIFORM_BUFFER | \ + ST_NEW_ATOMIC_BUFFER | \ + ST_NEW_STORAGE_BUFFER | \ + ST_NEW_IMAGE_UNITS) + /* All state flags within each group: */ #define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1) #define ST_PIPELINE_COMPUTE_STATE_MASK (0xffllu << ST_NEW_CS_STATE_INDEX) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 1ff035586c3..687ca199016 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -123,6 +123,41 @@ st_query_memory_info(struct gl_context *ctx, struct gl_memory_info *out) } +uint64_t +st_get_active_states(struct gl_context *ctx) +{ + struct st_vertex_program *vp = + st_vertex_program(ctx->VertexProgram._Current); + struct st_tessctrl_program *tcp = + st_tessctrl_program(ctx->TessCtrlProgram._Current); + struct st_tesseval_program *tep = + st_tesseval_program(ctx->TessEvalProgram._Current); + struct st_geometry_program *gp = + st_geometry_program(ctx->GeometryProgram._Current); + struct st_fragment_program *fp = + st_fragment_program(ctx->FragmentProgram._Current); + struct st_compute_program *cp = + st_compute_program(ctx->ComputeProgram._Current); + uint64_t active_shader_states = 0; + + if (vp) + active_shader_states |= vp->affected_states; + if (tcp) + active_shader_states |= tcp->affected_states; + if (tep) + active_shader_states |= tep->affected_states; + if (gp) + active_shader_states |= gp->affected_states; + if (fp) + active_shader_states |= fp->affected_states; + if (cp) + active_shader_states |= cp->affected_states; + + /* Mark non-shader-resource shader states as "always active". */ + return active_shader_states | ~ST_ALL_SHADER_RESOURCES; +} + + /** * Called via ctx->Driver.UpdateState() */ @@ -204,17 +239,9 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state) if (new_state & _NEW_PIXEL) st->dirty |= ST_NEW_PIXEL_TRANSFER; - if (new_state & _NEW_TEXTURE) - st->dirty |= ST_NEW_SAMPLER_VIEWS | - ST_NEW_SAMPLERS | - ST_NEW_IMAGE_UNITS; - if (new_state & _NEW_CURRENT_ATTRIB) st->dirty |= ST_NEW_VERTEX_ARRAYS; - if (new_state & _NEW_PROGRAM_CONSTANTS) - st->dirty |= ST_NEW_CONSTANTS; - /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */ if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) st->dirty |= ST_NEW_VS_STATE; @@ -223,8 +250,19 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state) if (new_state & _NEW_PROGRAM) { st->gfx_shaders_may_be_dirty = true; st->compute_shader_may_be_dirty = true; + /* This will mask out unused shader resources. */ + st->active_states = st_get_active_states(ctx); } + if (new_state & _NEW_TEXTURE) + st->dirty |= st->active_states & + (ST_NEW_SAMPLER_VIEWS | + ST_NEW_SAMPLERS | + ST_NEW_IMAGE_UNITS); + + if (new_state & _NEW_PROGRAM_CONSTANTS) + st->dirty |= st->active_states & ST_NEW_CONSTANTS; + /* This is the only core Mesa module we depend upon. * No longer use swrast, swsetup, tnl. */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 556b9c99a23..f82cf3a85aa 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -140,6 +140,9 @@ struct st_context uint64_t dirty; /**< dirty states */ + /** This masks out unused shader resources. Only valid in draw calls. */ + uint64_t active_states; + /* If true, further analysis of states is required to know if something * has changed. Used mainly for shaders. */ @@ -357,6 +360,9 @@ st_create_context(gl_api api, struct pipe_context *pipe, extern void st_destroy_context(struct st_context *st); +uint64_t +st_get_active_states(struct gl_context *ctx); + #ifdef __cplusplus } |