#define BEGIN_RING(obj,mthd,size) do { \
NOUVEAU_PUSH_CONTEXT(pc); \
if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \
- pc->nvws->push_flush(pc->nvws, ((size) + 1)); \
+ pc->nvws->push_flush(pc->nvws, ((size) + 1), NULL); \
OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \
pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \
} while(0)
BEGIN_RING(obj, (mthd) | 0x40000000, (size)); \
} while(0)
-#define FIRE_RING() do { \
+#define FIRE_RING(fence) do { \
NOUVEAU_PUSH_CONTEXT(pc); \
- pc->nvws->push_flush(pc->nvws, 0); \
+ pc->nvws->push_flush(pc->nvws, 0, fence); \
} while(0)
#define OUT_RELOC(bo,data,flags,vor,tor) do { \
#define OUT_RELOCm(bo, flags, obj, mthd, size) do { \
NOUVEAU_PUSH_CONTEXT(pc); \
if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \
- pc->nvws->push_flush(pc->nvws->channel, ((size) + 1)); \
+ pc->nvws->push_flush(pc->nvws->channel, ((size) + 1), NULL); \
OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \
(flags), 0, 0); \
pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \
nr = so->cur - so->push;
if (pb->remaining < nr)
- nvws->push_flush(nvws, nr);
+ nvws->push_flush(nvws, nr, NULL);
pb->remaining -= nr;
memcpy(pb->cur, so->push, nr * 4);
i = so->cur_reloc << 1;
if (nvws->channel->pushbuf->remaining < i)
- nvws->push_flush(nvws, i);
+ nvws->push_flush(nvws, i, NULL);
nvws->channel->pushbuf->remaining -= i;
for (i = 0; i < so->cur_reloc; i++) {
int (*push_reloc)(struct nouveau_winsys *, void *ptr,
struct pipe_buffer *, uint32_t data,
uint32_t flags, uint32_t vor, uint32_t tor);
- int (*push_flush)(struct nouveau_winsys *, unsigned size);
+ int (*push_flush)(struct nouveau_winsys *, unsigned size,
+ struct pipe_fence_handle **fence);
int (*grobj_alloc)(struct nouveau_winsys *, int grclass,
struct nouveau_grobj **);
#include "nv10_screen.h"
static void
-nv10_flush(struct pipe_context *pipe, unsigned flags)
+nv10_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence)
{
struct nv10_context *nv10 = nv10_context(pipe);
- struct nouveau_winsys *nvws = nv10->nvws;
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
BEGIN_RING(celsius, 0x1fd8, 1);
OUT_RING (1);
}
- if (flags & PIPE_FLUSH_WAIT) {
- nvws->notifier_reset(nv10->sync, 0);
- BEGIN_RING(celsius, 0x104, 1);
- OUT_RING (0);
- BEGIN_RING(celsius, 0x100, 1);
- OUT_RING (0);
- }
-
- FIRE_RING();
-
- if (flags & PIPE_FLUSH_WAIT)
- nvws->notifier_wait(nv10->sync, 0, 0, 2000);
+ FIRE_RING(fence);
}
static void
OUT_RING (1);
- FIRE_RING ();
+ FIRE_RING (NULL);
return TRUE;
}
}
static void
-nv10_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_buffer *vb)
+nv10_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_buffer *vb)
{
struct nv10_context *nv10 = nv10_context(pipe);
- nv10->vtxbuf[index] = *vb;
-
+ memcpy(nv10->vtxbuf, vb, sizeof(*vb) * count);
nv10->dirty |= NV10_NEW_ARRAYS;
}
static void
-nv10_set_vertex_element(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_element *ve)
+nv10_set_vertex_elements(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_element *ve)
{
struct nv10_context *nv10 = nv10_context(pipe);
- nv10->vtxelt[index] = *ve;
-
+ memcpy(nv10->vtxelt, ve, sizeof(*ve) * count);
nv10->dirty |= NV10_NEW_ARRAYS;
}
nv10->pipe.set_scissor_state = nv10_set_scissor_state;
nv10->pipe.set_viewport_state = nv10_set_viewport_state;
- nv10->pipe.set_vertex_buffer = nv10_set_vertex_buffer;
- nv10->pipe.set_vertex_element = nv10_set_vertex_element;
+ nv10->pipe.set_vertex_buffers = nv10_set_vertex_buffers;
+ nv10->pipe.set_vertex_elements = nv10_set_vertex_elements;
}
#include "nv30_screen.h"
static void
-nv30_flush(struct pipe_context *pipe, unsigned flags)
+nv30_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence)
{
struct nv30_context *nv30 = nv30_context(pipe);
- struct nouveau_winsys *nvws = nv30->nvws;
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
BEGIN_RING(rankine, 0x1fd8, 1);
OUT_RING (1);
}
- if (flags & PIPE_FLUSH_WAIT) {
- nvws->notifier_reset(nv30->sync, 0);
- BEGIN_RING(rankine, 0x104, 1);
- OUT_RING (0);
- BEGIN_RING(rankine, 0x100, 1);
- OUT_RING (0);
- }
-
- FIRE_RING();
-
- if (flags & PIPE_FLUSH_WAIT)
- nvws->notifier_wait(nv30->sync, 0, 0, 2000);
+ FIRE_RING(fence);
}
static void
BEGIN_RING(rankine, 0x1e94, 1);
OUT_RING (0x13);
- FIRE_RING ();
+ FIRE_RING (NULL);
return TRUE;
}
BEGIN_RING(rankine, NV34TCL_QUERY_GET, 1);
OUT_RING ((0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
- FIRE_RING();
+ FIRE_RING(NULL);
}
static boolean
}
static void
-nv30_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_buffer *vb)
+nv30_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_buffer *vb)
{
struct nv30_context *nv30 = nv30_context(pipe);
- nv30->vtxbuf[index] = *vb;
-
+ memcpy(nv30->vtxbuf, vb, sizeof(*vb) * count);
nv30->dirty |= NV30_NEW_ARRAYS;
}
static void
-nv30_set_vertex_element(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_element *ve)
+nv30_set_vertex_elements(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_element *ve)
{
struct nv30_context *nv30 = nv30_context(pipe);
- nv30->vtxelt[index] = *ve;
-
+ memcpy(nv30->vtxelt, ve, sizeof(*ve) * count);
nv30->dirty |= NV30_NEW_ARRAYS;
}
nv30->pipe.set_scissor_state = nv30_set_scissor_state;
nv30->pipe.set_viewport_state = nv30_set_viewport_state;
- nv30->pipe.set_vertex_buffer = nv30_set_vertex_buffer;
- nv30->pipe.set_vertex_element = nv30_set_vertex_element;
+ nv30->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
+ nv30->pipe.set_vertex_elements = nv30_set_vertex_elements;
}
BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
OUT_RING (0);
- pipe->flush(pipe, 0);
+ pipe->flush(pipe, 0, NULL);
return TRUE;
}
mode, start, count);
}
- pipe->flush(pipe, 0);
+ pipe->flush(pipe, 0, NULL);
return TRUE;
}
#include "nv40_screen.h"
static void
-nv40_flush(struct pipe_context *pipe, unsigned flags)
+nv40_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence)
{
struct nv40_context *nv40 = nv40_context(pipe);
- struct nouveau_winsys *nvws = nv40->nvws;
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
BEGIN_RING(curie, 0x1fd8, 1);
OUT_RING (1);
}
- if (flags & PIPE_FLUSH_WAIT) {
- nvws->notifier_reset(nv40->screen->sync, 0);
- BEGIN_RING(curie, 0x104, 1);
- OUT_RING (0);
- BEGIN_RING(curie, 0x100, 1);
- OUT_RING (0);
- }
-
- FIRE_RING();
-
- if (flags & PIPE_FLUSH_WAIT)
- nvws->notifier_wait(nv40->screen->sync, 0, 0, 2000);
+ FIRE_RING(fence);
}
static void
NOUVEAU_ERR("AIII, missed flush\n");
assert(0);
}
- FIRE_RING();
+ FIRE_RING(NULL);
nv40_state_emit(nv40);
}
ws->buffer_unmap(ws, nv40->constbuf[PIPE_SHADER_VERTEX]);
draw_flush(nv40->draw);
- pipe->flush(pipe, 0);
+ pipe->flush(pipe, 0, NULL);
return TRUE;
}
BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
((q->object->start * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
- FIRE_RING();
+ FIRE_RING(NULL);
}
static boolean
so_emit(nvws, so);
so_ref(NULL, &so);
- nvws->push_flush(nvws, 0);
+ nvws->push_flush(nvws, 0, NULL);
screen->pipe.winsys = ws;
screen->pipe.destroy = nv40_screen_destroy;
}
static void
-nv40_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_buffer *vb)
+nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_buffer *vb)
{
struct nv40_context *nv40 = nv40_context(pipe);
- draw_set_vertex_buffer(nv40->draw, index, vb);
+ draw_set_vertex_buffers(nv40->draw, count, vb);
- nv40->vtxbuf[index] = *vb;
+ memcpy(nv40->vtxbuf, vb, sizeof(*vb) * count);
nv40->dirty |= NV40_NEW_ARRAYS;
}
static void
-nv40_set_vertex_element(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_element *ve)
+nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_element *ve)
{
struct nv40_context *nv40 = nv40_context(pipe);
- draw_set_vertex_element(nv40->draw, index, ve);
+ draw_set_vertex_elements(nv40->draw, count, ve);
- nv40->vtxelt[index] = *ve;
+ memcpy(nv40->vtxelt, ve, sizeof(*ve) * count);
nv40->dirty |= NV40_NEW_ARRAYS;
}
nv40->pipe.set_scissor_state = nv40_set_scissor_state;
nv40->pipe.set_viewport_state = nv40_set_viewport_state;
- nv40->pipe.set_vertex_buffer = nv40_set_vertex_buffer;
- nv40->pipe.set_vertex_element = nv40_set_vertex_element;
+ nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
+ nv40->pipe.set_vertex_elements = nv40_set_vertex_elements;
}
return FALSE;
/* Attempt to go to hwtnl again */
- nv40->pipe.flush(&nv40->pipe, 0);
+ nv40->pipe.flush(&nv40->pipe, 0, NULL);
nv40->dirty |= (NV40_NEW_VIEWPORT |
NV40_NEW_VERTPROG |
NV40_NEW_ARRAYS |
/* Setup for swtnl */
if (nv40->render_mode == HW) {
NOUVEAU_ERR("hw->swtnl 0x%08x\n", nv40->fallback_swtnl);
- nv40->pipe.flush(&nv40->pipe, 0);
+ nv40->pipe.flush(&nv40->pipe, 0, NULL);
nv40->dirty |= (NV40_NEW_VIEWPORT |
NV40_NEW_VERTPROG |
NV40_NEW_ARRAYS |
BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
OUT_RING (0);
- pipe->flush(pipe, 0);
+ pipe->flush(pipe, 0, NULL);
return TRUE;
}
mode, start, count);
}
- pipe->flush(pipe, 0);
+ pipe->flush(pipe, 0, NULL);
return TRUE;
}
#include "nv50_screen.h"
static void
-nv50_flush(struct pipe_context *pipe, unsigned flags)
+nv50_flush(struct pipe_context *pipe, unsigned flags,
+ struct pipe_fence_handle **fence)
{
struct nv50_context *nv50 = (struct nv50_context *)pipe;
- struct nv50_screen *screen = nv50->screen;
- struct nouveau_winsys *nvws = screen->nvws;
- if (flags & PIPE_FLUSH_WAIT) {
- nvws->notifier_reset(screen->sync, 0);
- BEGIN_RING(tesla, 0x104, 1);
- OUT_RING (0);
- BEGIN_RING(tesla, 0x100, 1);
- OUT_RING (0);
- }
-
- FIRE_RING();
-
- if (flags & PIPE_FLUSH_WAIT)
- nvws->notifier_wait(screen->sync, 0, 0, 2000);
+ FIRE_RING(fence);
}
static void
so_emit(nvws, so);
so_ref(NULL, &so);
- nvws->push_flush(nvws, 0);
+ nvws->push_flush(nvws, 0, NULL);
screen->pipe.winsys = ws;
}
static void
-nv50_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_buffer *vb)
+nv50_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_buffer *vb)
{
}
static void
-nv50_set_vertex_element(struct pipe_context *pipe, unsigned index,
- const struct pipe_vertex_element *ve)
+nv50_set_vertex_elements(struct pipe_context *pipe, unsigned count,
+ const struct pipe_vertex_element *ve)
{
}
nv50->pipe.set_scissor_state = nv50_set_scissor_state;
nv50->pipe.set_viewport_state = nv50_set_viewport_state;
- nv50->pipe.set_vertex_buffer = nv50_set_vertex_buffer;
- nv50->pipe.set_vertex_element = nv50_set_vertex_element;
+ nv50->pipe.set_vertex_buffers = nv50_set_vertex_buffers;
+ nv50->pipe.set_vertex_elements = nv50_set_vertex_elements;
}
assert(nv);
- st_flush(nv->st, PIPE_FLUSH_WAIT);
+ st_finish(nv->st);
st_destroy_context(nv->st);
if (nv->pctx_id >= 0) {
struct nouveau_context *nv = driContextPriv->driverPrivate;
(void)nv;
- st_flush(nv->st, 0);
+ st_flush(nv->st, 0, NULL);
return GL_TRUE;
}
}
static int
-nouveau_pipe_push_flush(struct nouveau_winsys *nvws, unsigned size)
+nouveau_pipe_push_flush(struct nouveau_winsys *nvws, unsigned size,
+ struct pipe_fence_handle **fence)
{
+ if (fence) {
+ struct nouveau_pushbuf *pb = nvws->channel->pushbuf;
+ struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(pb);
+ struct nouveau_fence *ref = NULL;
+
+ nouveau_fence_ref(nvpb->fence, &ref);
+ *fence = (struct pipe_fence_handle *)ref;
+ }
+
return nouveau_pushbuf_flush(nvws->channel, size);
}
nouveau_bo_unmap(nvbuf->bo);
}
+static INLINE struct nouveau_fence *
+nouveau_pipe_fence(struct pipe_fence_handle *pfence)
+{
+ return (struct nouveau_fence *)pfence;
+}
+
+static void
+nouveau_pipe_fence_reference(struct pipe_winsys *ws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
+{
+ nouveau_fence_ref((void *)pfence, (void *)ptr);
+}
+
+static int
+nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)ws;
+ struct nouveau_fence *fence = nouveau_pipe_fence(pfence);
+
+ if (nouveau_fence(fence)->signalled == 0)
+ nouveau_fence_flush(nvpws->nv->nvc->channel);
+
+ return !nouveau_fence(fence)->signalled;
+}
+
+static int
+nouveau_pipe_fence_finish(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ struct nouveau_fence *fence = nouveau_pipe_fence(pfence);
+ struct nouveau_fence *ref = NULL;
+
+ nouveau_fence_ref(fence, &ref);
+ return nouveau_fence_wait(&ref);
+}
+
struct pipe_winsys *
nouveau_create_pipe_winsys(struct nouveau_context *nv)
{
pws->buffer_map = nouveau_pipe_bo_map;
pws->buffer_unmap = nouveau_pipe_bo_unmap;
+ pws->fence_reference = nouveau_pipe_fence_reference;
+ pws->fence_signalled = nouveau_pipe_fence_signalled;
+ pws->fence_finish = nouveau_pipe_fence_finish;
+
pws->get_name = nouveau_get_name;
return &nvpws->pws;