intel / DRI2: When available, use DRI2GetBuffersWithFormat
[mesa.git] / src / mesa / state_tracker / st_atom_constbuf.c
index 2856e0f0e0fe02fe99937621a710d0f60bb584a1..3ba7b2692856bda0defeadf6736a7a1d869b98c6 100644 (file)
@@ -42,7 +42,7 @@
 #include "st_atom.h"
 #include "st_atom_constbuf.h"
 #include "st_program.h"
-
+#include "st_inlines.h"
 
 /**
  * Pass the given program parameters to the graphics pipe as a
@@ -62,19 +62,13 @@ void st_upload_constants( struct st_context *st,
    if (params && params->NumParameters) {
       const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4;
 
-      /* Update our own dependency flags.  This works because this
-       * function will also be called whenever the program changes.
-       */
-      st->constants.tracked_state[id].dirty.mesa =
-         (params->StateFlags | _NEW_PROGRAM);
-
       _mesa_load_state_parameters(st->ctx, params);
 
       /* We always need to get a new buffer, to keep the drivers simple and
        * avoid gratuitous rendering synchronization.
        */
-      pipe_reference_buffer(pipe, &cbuf->buffer, NULL );
-      cbuf->buffer = pipe_buffer_create(pipe, 1, PIPE_BUFFER_USAGE_CONSTANT,
+      pipe_buffer_reference(&cbuf->buffer, NULL );
+      cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
                                        paramBytes );
 
       if (0)
@@ -85,14 +79,10 @@ void st_upload_constants( struct st_context *st,
       }
 
       /* load Mesa constants into the constant buffer */
-      if (cbuf->buffer) {
-         void *map = pipe_buffer_map(pipe, cbuf->buffer,
-                                     PIPE_BUFFER_USAGE_CPU_WRITE);
-         memcpy(map, params->ParameterValues, paramBytes);
-         pipe_buffer_unmap(pipe, cbuf->buffer);
-      }
-
-      cbuf->size = paramBytes;
+      if (cbuf->buffer)
+         st_no_flush_pipe_buffer_write(st, cbuf->buffer,
+                                      0, paramBytes,
+                                      params->ParameterValues);
 
       st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf);
    }
@@ -115,7 +105,7 @@ static void update_vs_constants(struct st_context *st )
 const struct st_tracked_state st_update_vs_constants = {
    "st_update_vs_constants",                           /* name */
    {                                                   /* dirty */
-      0,  /* set dynamically above */                  /* mesa */
+      (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS),          /* mesa */
       ST_NEW_VERTEX_PROGRAM,                           /* st */
    },
    update_vs_constants                                 /* update */
@@ -134,7 +124,7 @@ static void update_fs_constants(struct st_context *st )
 const struct st_tracked_state st_update_fs_constants = {
    "st_update_fs_constants",                           /* name */
    {                                                   /* dirty */
-      0,  /* set dynamically above */                  /* mesa */
+      (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS),          /* mesa */
       ST_NEW_FRAGMENT_PROGRAM,                         /* st */
    },
    update_fs_constants                                 /* update */