summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_atom.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-06-14 23:09:24 +0200
committerMarek Olšák <[email protected]>2017-06-22 01:51:02 +0200
commit743ad599a97d09b119d26b99f6b79e41b567e421 (patch)
tree3ccdbd3d7ea47037329bc97d8d87e247f7d77c6a /src/mesa/state_tracker/st_atom.c
parent2ec1e32d11ed788dfed229a569a238743b9b1f9f (diff)
st/mesa: don't set 16 scissors and 16 viewports if they're unused
Only do so if there is a shader writing gl_ViewportIndex. This removes a lot of CPU overhead for the most common case. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_atom.c')
-rw-r--r--src/mesa/state_tracker/st_atom.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index bcfbcf878f0..253b5081640 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -76,6 +76,7 @@ static void check_program_state( struct st_context *st )
struct gl_program *new_gp = ctx->GeometryProgram._Current;
struct gl_program *new_fp = ctx->FragmentProgram._Current;
uint64_t dirty = 0;
+ unsigned num_viewports = 1;
/* Flag states used by both new and old shaders to unbind shader resources
* properly when transitioning to shaders that don't use them.
@@ -115,6 +116,23 @@ static void check_program_state( struct st_context *st )
dirty |= st_fragment_program(new_fp)->affected_states;
}
+ /* Find out the number of viewports. This determines how many scissors
+ * and viewport states we need to update.
+ */
+ struct gl_program *last_prim_shader = new_gp ? new_gp :
+ new_tep ? new_tep : new_vp;
+ if (last_prim_shader &&
+ last_prim_shader->info.outputs_written & VARYING_BIT_VIEWPORT)
+ num_viewports = ctx->Const.MaxViewports;
+
+ if (st->state.num_viewports != num_viewports) {
+ st->state.num_viewports = num_viewports;
+ dirty |= ST_NEW_VIEWPORT;
+
+ if (ctx->Scissor.EnableFlags & u_bit_consecutive(0, num_viewports))
+ dirty |= ST_NEW_SCISSOR;
+ }
+
st->dirty |= dirty;
}