nvc0_memory_barrier(struct pipe_context *pipe, unsigned flags)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
- int i;
+ int i, s;
if (flags & PIPE_BARRIER_MAPPED_BUFFER) {
for (i = 0; i < nvc0->num_vtxbufs; ++i) {
if (nvc0->idxbuf.buffer &&
nvc0->idxbuf.buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT)
nvc0->base.vbo_dirty = TRUE;
+
+ for (s = 0; s < 5 && !nvc0->cb_dirty; ++s) {
+ uint32_t valid = nvc0->constbuf_valid[s];
+
+ while (valid && !nvc0->cb_dirty) {
+ const unsigned i = ffs(valid) - 1;
+ struct pipe_resource *res;
+
+ valid &= ~(1 << i);
+ if (nvc0->constbuf[s][i].user)
+ continue;
+
+ res = nvc0->constbuf[s][i].u.buf;
+ if (!res)
+ continue;
+
+ if (res->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT)
+ nvc0->cb_dirty = TRUE;
+ }
+ }
}
}
struct nvc0_constbuf constbuf[6][NVC0_MAX_PIPE_CONSTBUFS];
uint16_t constbuf_dirty[6];
+ uint16_t constbuf_valid[6];
+ boolean cb_dirty;
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
unsigned num_vtxbufs;
if (nvc0->constbuf[s][i].user) {
nvc0->constbuf[s][i].u.data = cb->user_buffer;
nvc0->constbuf[s][i].size = cb->buffer_size;
+ nvc0->constbuf_valid[s] |= 1 << i;
} else
if (cb) {
nvc0->constbuf[s][i].offset = cb->buffer_offset;
nvc0->constbuf[s][i].size = align(cb->buffer_size, 0x100);
+ nvc0->constbuf_valid[s] |= 1 << i;
+ }
+ else {
+ nvc0->constbuf_valid[s] &= ~(1 << i);
}
}
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
- int i;
+ int i, s;
/* NOTE: caller must ensure that (min_index + index_bias) is >= 0 */
nvc0->vb_elt_first = info->min_index + info->index_bias;
push->kick_notify = nvc0_draw_vbo_kick_notify;
+ for (s = 0; s < 5 && !nvc0->cb_dirty; ++s) {
+ uint32_t valid = nvc0->constbuf_valid[s];
+
+ while (valid && !nvc0->cb_dirty) {
+ const unsigned i = ffs(valid) - 1;
+ struct pipe_resource *res;
+
+ valid &= ~(1 << i);
+ if (nvc0->constbuf[s][i].user)
+ continue;
+
+ res = nvc0->constbuf[s][i].u.buf;
+ if (!res)
+ continue;
+
+ if (res->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT)
+ nvc0->cb_dirty = TRUE;
+ }
+ }
+
+ if (nvc0->cb_dirty) {
+ IMMED_NVC0(push, NVC0_3D(MEM_BARRIER), 0x1011);
+ nvc0->cb_dirty = FALSE;
+ }
+
if (nvc0->state.vbo_mode) {
nvc0_push_vbo(nvc0, info);
push->kick_notify = nvc0_default_kick_notify;
}
static INLINE uint32_t
-NVC0_FIFO_PKHDR_IL(int subc, int mthd, uint8_t data)
+NVC0_FIFO_PKHDR_IL(int subc, int mthd, uint16_t data)
{
+ assert(data < 0x2000);
return 0x80000000 | (data << 16) | (subc << 13) | (mthd >> 2);
}
}
static INLINE void
-IMMED_NVC0(struct nouveau_pushbuf *push, int subc, int mthd, uint8_t data)
+IMMED_NVC0(struct nouveau_pushbuf *push, int subc, int mthd, uint16_t data)
{
#ifndef NVC0_PUSH_EXPLICIT_SPACE_CHECKING
PUSH_SPACE(push, 1);