#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
#include "st_context.h"
#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
struct gl_program_parameter_list *params,
unsigned id)
{
- struct pipe_winsys *ws = st->pipe->winsys;
+ struct pipe_context *pipe = st->pipe;
struct pipe_constant_buffer *cbuf = &st->state.constants[id];
assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT);
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;
-
_mesa_load_state_parameters(st->ctx, params);
- if (cbuf->buffer && cbuf->size != paramBytes)
- pipe_buffer_reference( ws, &cbuf->buffer, NULL );
-
- if (!cbuf->buffer) {
- cbuf->buffer = ws->buffer_create(ws, 1, PIPE_BUFFER_USAGE_CONSTANT,
- paramBytes);
- }
+ /* We always need to get a new buffer, to keep the drivers simple and
+ * avoid gratuitous rendering synchronization.
+ */
+ pipe_buffer_reference(&cbuf->buffer, NULL );
+ cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
+ paramBytes );
if (0)
{
}
/* load Mesa constants into the constant buffer */
- if (cbuf->buffer) {
- memcpy(ws->buffer_map(ws, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- params->ParameterValues, paramBytes);
- ws->buffer_unmap(ws, 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);
}
}
const struct st_tracked_state st_update_vs_constants = {
- .name = "st_update_vs_constants",
- .dirty = {
- .mesa = 0,
- .st = ST_NEW_VERTEX_PROGRAM,
+ "st_update_vs_constants", /* name */
+ { /* dirty */
+ (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS), /* mesa */
+ ST_NEW_VERTEX_PROGRAM, /* st */
},
- .update = update_vs_constants
+ update_vs_constants /* update */
};
/* Fragment shader:
}
const struct st_tracked_state st_update_fs_constants = {
- .name = "st_update_fs_constants",
- .dirty = {
- .mesa = 0,
- .st = ST_NEW_FRAGMENT_PROGRAM,
+ "st_update_fs_constants", /* name */
+ { /* dirty */
+ (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS), /* mesa */
+ ST_NEW_FRAGMENT_PROGRAM, /* st */
},
- .update = update_fs_constants
+ update_fs_constants /* update */
};