+
+
+static void
+set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
+{
+ if (ctx->VertexProgram._VPMode == m)
+ return;
+
+ /* On change we may get new maps into the current values */
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
+ /* Finally memorize the value */
+ ctx->VertexProgram._VPMode = m;
+
+ /* Since we only track the varying inputs while being in fixed function
+ * vertex processing mode, we may need to recheck for the
+ * _NEW_VARYING_VP_INPUTS bit.
+ */
+ set_varying_vp_inputs(ctx, ctx->Array._DrawVAOEnabledAttribs);
+}
+
+
+/**
+ * Update ctx->VertexProgram._VPMode.
+ * This is to distinguish whether we're running
+ * a vertex program/shader,
+ * a fixed-function TNL program or
+ * a fixed function vertex transformation without any program.
+ */
+void
+_mesa_update_vertex_processing_mode(struct gl_context *ctx)
+{
+ if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX])
+ set_vertex_processing_mode(ctx, VP_MODE_SHADER);
+ else if (_mesa_arb_vertex_program_enabled(ctx))
+ set_vertex_processing_mode(ctx, VP_MODE_SHADER);
+ else
+ set_vertex_processing_mode(ctx, VP_MODE_FF);
+}
+
+
+/**
+ * Set the _DrawVAO and the net enabled arrays.
+ * The vao->_Enabled bitmask is transformed due to position/generic0
+ * as stored in vao->_AttributeMapMode. Then the filter bitmask is applied
+ * to filter out arrays unwanted for the currently executed draw operation.
+ * For example, the generic attributes are masked out form the _DrawVAO's
+ * enabled arrays when a fixed function array draw is executed.
+ */
+void
+_mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+ GLbitfield filter)
+{
+ struct gl_vertex_array_object **ptr = &ctx->Array._DrawVAO;
+ bool new_array = false;
+ if (*ptr != vao) {
+ _mesa_reference_vao_(ctx, ptr, vao);
+
+ new_array = true;
+ }
+
+ if (vao->NewArrays) {
+ _mesa_update_vao_derived_arrays(ctx, vao);
+ vao->NewArrays = 0;
+
+ new_array = true;
+ }
+
+ /* May shuffle the position and generic0 bits around, filter out unwanted */
+ const GLbitfield enabled = filter & _mesa_get_vao_vp_inputs(vao);
+ if (ctx->Array._DrawVAOEnabledAttribs != enabled)
+ new_array = true;
+
+ if (new_array)
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
+ ctx->Array._DrawVAOEnabledAttribs = enabled;
+ set_varying_vp_inputs(ctx, enabled);
+}