}
-/**
- * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
- */
static GLbitfield
-update_program_constants(struct gl_context *ctx)
+update_single_program_constants(struct gl_context *ctx,
+ struct gl_program *prog,
+ gl_shader_stage stage)
{
- GLbitfield new_state = 0x0;
-
- if (ctx->FragmentProgram._Current) {
- const struct gl_program_parameter_list *params =
- ctx->FragmentProgram._Current->Parameters;
+ if (prog) {
+ const struct gl_program_parameter_list *params = prog->Parameters;
if (params && params->StateFlags & ctx->NewState) {
- if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]) {
- ctx->NewDriverState |=
- ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT];
- } else {
- new_state |= _NEW_PROGRAM_CONSTANTS;
- }
+ if (ctx->DriverFlags.NewShaderConstants[stage])
+ ctx->NewDriverState |= ctx->DriverFlags.NewShaderConstants[stage];
+ else
+ return _NEW_PROGRAM_CONSTANTS;
}
}
+ return 0;
+}
- /* Don't handle tessellation and geometry shaders here. They don't use
- * any state constants.
- */
- if (ctx->VertexProgram._Current) {
- const struct gl_program_parameter_list *params =
- ctx->VertexProgram._Current->Parameters;
- if (params && params->StateFlags & ctx->NewState) {
- if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]) {
- ctx->NewDriverState |=
- ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX];
- } else {
- new_state |= _NEW_PROGRAM_CONSTANTS;
- }
+/**
+ * This updates fixed-func state constants such as gl_ModelViewMatrix.
+ * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
+ */
+static GLbitfield
+update_program_constants(struct gl_context *ctx)
+{
+ GLbitfield new_state =
+ update_single_program_constants(ctx, ctx->VertexProgram._Current,
+ MESA_SHADER_VERTEX) |
+ update_single_program_constants(ctx, ctx->FragmentProgram._Current,
+ MESA_SHADER_FRAGMENT);
+
+ if (ctx->API == API_OPENGL_COMPAT &&
+ ctx->Const.GLSLVersionCompat >= 150) {
+ new_state |=
+ update_single_program_constants(ctx, ctx->GeometryProgram._Current,
+ MESA_SHADER_GEOMETRY);
+
+ if (_mesa_has_ARB_tessellation_shader(ctx)) {
+ new_state |=
+ update_single_program_constants(ctx, ctx->TessCtrlProgram._Current,
+ MESA_SHADER_TESS_CTRL) |
+ update_single_program_constants(ctx, ctx->TessEvalProgram._Current,
+ MESA_SHADER_TESS_EVAL);
}
}
update_program(ctx);
}
- if (new_state & _NEW_ARRAY)
- _mesa_update_vao_derived_arrays(ctx, ctx->Array.VAO);
-
out:
new_prog_state |= update_program_constants(ctx);
*/
ctx->Driver.UpdateState(ctx);
ctx->NewState = 0;
- ctx->Array.VAO->NewArrays = 0x0;
}
}
+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;
+}
+
+
/**
* Update ctx->VertexProgram._VPMode.
* This is to distinguish whether we're running
_mesa_update_vertex_processing_mode(struct gl_context *ctx)
{
if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX])
- ctx->VertexProgram._VPMode = VP_MODE_SHADER;
+ set_vertex_processing_mode(ctx, VP_MODE_SHADER);
else if (_mesa_arb_vertex_program_enabled(ctx))
- ctx->VertexProgram._VPMode = VP_MODE_SHADER;
+ set_vertex_processing_mode(ctx, VP_MODE_SHADER);
else
- ctx->VertexProgram._VPMode = VP_MODE_FF;
+ set_vertex_processing_mode(ctx, VP_MODE_FF);
}
GLbitfield filter)
{
struct gl_vertex_array_object **ptr = &ctx->Array._DrawVAO;
+ bool new_array = false;
if (*ptr != vao) {
_mesa_reference_vao_(ctx, ptr, vao);
- ctx->NewDriverState |= ctx->DriverFlags.NewArray;
- } else if (vao->NewArrays) {
- ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+
+ 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;
_mesa_set_varying_vp_inputs(ctx, enabled);
}