summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom.h8
-rw-r--r--src/mesa/state_tracker/st_context.c54
-rw-r--r--src/mesa/state_tracker/st_context.h6
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
}