st/mesa: do vertex and fragment color clamping in shaders
[mesa.git] / src / mesa / state_tracker / st_context.c
index 6d4bc544d0c336ca206ec93d7cc2141ea329c0cb..a3fd4dbcb7f5ec36140b8c7e2dcd9f3c0c9c7a54 100644 (file)
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 #include "main/imports.h"
+#include "main/accum.h"
 #include "main/context.h"
 #include "main/samplerobj.h"
 #include "main/shaderobj.h"
@@ -34,7 +35,6 @@
 #include "glapi/glapi.h"
 #include "st_context.h"
 #include "st_debug.h"
-#include "st_cb_accum.h"
 #include "st_cb_bitmap.h"
 #include "st_cb_blit.h"
 #include "st_cb_bufferobjects.h"
@@ -76,6 +76,17 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state)
 {
    struct st_context *st = st_context(ctx);
 
+   /* Replace _NEW_FRAG_CLAMP with ST_NEW_FRAGMENT_PROGRAM for the fallback. */
+   if (st->clamp_frag_color_in_shader && (new_state & _NEW_FRAG_CLAMP)) {
+      new_state &= ~_NEW_FRAG_CLAMP;
+      st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+   }
+
+   /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
+   if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) {
+      st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+   }
+
    st->dirty.mesa |= new_state;
    st->dirty.st |= ST_NEW_MESA;
 
@@ -144,6 +155,10 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
    /* we want all vertex data to be placed in buffer objects */
    vbo_use_buffer_objects(ctx);
 
+
+   /* make sure that no VBOs are left mapped when we're drawing. */
+   vbo_always_unmap_buffers(ctx);
+
    /* Need these flags:
     */
    st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
@@ -272,7 +287,8 @@ void st_init_driver_functions(struct dd_function_table *functions)
    _mesa_init_shader_object_functions(functions);
    _mesa_init_sampler_object_functions(functions);
 
-   st_init_accum_functions(functions);
+   functions->Accum = _mesa_accum;
+
    st_init_blit_functions(functions);
    st_init_bufferobject_functions(functions);
    st_init_clear_functions(functions);