+ dirty |= st_common_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;