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 /src/mesa/state_tracker/st_context.c | |
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]>
Diffstat (limited to 'src/mesa/state_tracker/st_context.c')
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 54 |
1 files changed, 46 insertions, 8 deletions
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. */ |