diff options
author | Ilia Mirkin <[email protected]> | 2014-07-01 00:49:34 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2014-07-03 20:08:41 -0400 |
commit | 9a37eb8adb6558a4abf47774b583cb582a0ae116 (patch) | |
tree | 78202d7b41dcba2014cbcafb323dcdb3bdf91046 | |
parent | 5d4f5218bb71cb387f1a57ea08125245e5039e94 (diff) |
nvc0: add a memory barrier when there are persistent UBOs
Signed-off-by: Ilia Mirkin <[email protected]>
Cc: "10.2" <[email protected]>
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c | 27 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_winsys.h | 5 |
5 files changed, 57 insertions, 4 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c index e5040c46332..5928c994c5d 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c @@ -60,7 +60,7 @@ static void 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) { @@ -73,6 +73,26 @@ nvc0_memory_barrier(struct pipe_context *pipe, unsigned flags) 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; + } + } } } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h index 052f0bae5c6..ebeb8c48fba 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h @@ -154,6 +154,8 @@ struct nvc0_context { 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; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index ef9d479ca07..d1a7cf51559 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -808,10 +808,15 @@ nvc0_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, 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); } } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c index 83d406d5646..c26b98fb5f0 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c @@ -799,7 +799,7 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) { 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; @@ -832,6 +832,31 @@ nvc0_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) 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; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_winsys.h b/src/gallium/drivers/nouveau/nvc0/nvc0_winsys.h index 3514d9dc3d0..a83b31d0dc4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_winsys.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_winsys.h @@ -80,8 +80,9 @@ NVC0_FIFO_PKHDR_NI(int subc, int mthd, unsigned size) } 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); } @@ -133,7 +134,7 @@ BEGIN_1IC0(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size) } 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); |