nouveau: adapt to recent gallium changes

This commit is contained in:
Ben Skeggs 2008-03-30 20:32:22 +10:00
parent 03c60e0fb6
commit bbefb541ad
22 changed files with 121 additions and 117 deletions

View file

@ -27,7 +27,7 @@
#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)
@ -36,9 +36,9 @@
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 { \
@ -73,7 +73,7 @@
#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); \

View file

@ -99,7 +99,7 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so)
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);
@ -120,7 +120,7 @@ so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so)
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++) {

View file

@ -27,7 +27,8 @@ struct nouveau_winsys {
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 **);

View file

@ -7,10 +7,10 @@
#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);
@ -19,18 +19,7 @@ nv10_flush(struct pipe_context *pipe, unsigned flags)
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
@ -253,7 +242,7 @@ nv10_init_hwctx(struct nv10_context *nv10, int celsius_class)
OUT_RING (1);
FIRE_RING ();
FIRE_RING (NULL);
return TRUE;
}

View file

@ -633,24 +633,22 @@ nv10_set_viewport_state(struct pipe_context *pipe,
}
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;
}
@ -693,7 +691,7 @@ nv10_init_state_functions(struct nv10_context *nv10)
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;
}

View file

@ -7,10 +7,10 @@
#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);
@ -19,18 +19,7 @@ nv30_flush(struct pipe_context *pipe, unsigned flags)
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
@ -144,7 +133,7 @@ nv30_init_hwctx(struct nv30_context *nv30, int rankine_class)
BEGIN_RING(rankine, 0x1e94, 1);
OUT_RING (0x13);
FIRE_RING ();
FIRE_RING (NULL);
return TRUE;
}

View file

@ -67,7 +67,7 @@ nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
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

View file

@ -710,24 +710,22 @@ nv30_set_viewport_state(struct pipe_context *pipe,
}
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;
}
@ -770,7 +768,7 @@ nv30_init_state_functions(struct nv30_context *nv30)
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;
}

View file

@ -229,7 +229,7 @@ nv30_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
BEGIN_RING(rankine, NV34TCL_VERTEX_BEGIN_END, 1);
OUT_RING (0);
pipe->flush(pipe, 0);
pipe->flush(pipe, 0, NULL);
return TRUE;
}
@ -418,7 +418,7 @@ nv30_draw_elements(struct pipe_context *pipe,
mode, start, count);
}
pipe->flush(pipe, 0);
pipe->flush(pipe, 0, NULL);
return TRUE;
}

View file

@ -7,10 +7,10 @@
#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);
@ -19,18 +19,7 @@ nv40_flush(struct pipe_context *pipe, unsigned flags)
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

View file

@ -89,7 +89,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
NOUVEAU_ERR("AIII, missed flush\n");
assert(0);
}
FIRE_RING();
FIRE_RING(NULL);
nv40_state_emit(nv40);
}
@ -275,7 +275,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
ws->buffer_unmap(ws, nv40->constbuf[PIPE_SHADER_VERTEX]);
draw_flush(nv40->draw);
pipe->flush(pipe, 0);
pipe->flush(pipe, 0, NULL);
return TRUE;
}

View file

@ -75,7 +75,7 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
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

View file

@ -266,7 +266,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
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;

View file

@ -660,26 +660,26 @@ nv40_set_viewport_state(struct pipe_context *pipe,
}
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;
}
@ -722,7 +722,7 @@ nv40_init_state_functions(struct nv40_context *nv40)
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;
}

View file

@ -123,7 +123,7 @@ nv40_state_validate(struct nv40_context *nv40)
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 |
@ -147,7 +147,7 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
/* 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 |

View file

@ -209,7 +209,7 @@ nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
BEGIN_RING(curie, NV40TCL_BEGIN_END, 1);
OUT_RING (0);
pipe->flush(pipe, 0);
pipe->flush(pipe, 0, NULL);
return TRUE;
}
@ -384,7 +384,7 @@ nv40_draw_elements(struct pipe_context *pipe,
mode, start, count);
}
pipe->flush(pipe, 0);
pipe->flush(pipe, 0, NULL);
return TRUE;
}

View file

@ -7,24 +7,12 @@
#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

View file

@ -171,7 +171,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
so_emit(nvws, so);
so_ref(NULL, &so);
nvws->push_flush(nvws, 0);
nvws->push_flush(nvws, 0, NULL);
screen->pipe.winsys = ws;

View file

@ -422,14 +422,14 @@ nv50_set_viewport_state(struct pipe_context *pipe,
}
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)
{
}
@ -472,7 +472,7 @@ nv50_init_state_functions(struct nv50_context *nv50)
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;
}

View file

@ -282,7 +282,7 @@ nouveau_context_destroy(__DRIcontextPrivate *driContextPriv)
assert(nv);
st_flush(nv->st, PIPE_FLUSH_WAIT);
st_finish(nv->st);
st_destroy_context(nv->st);
if (nv->pctx_id >= 0) {
@ -337,7 +337,7 @@ nouveau_context_unbind(__DRIcontextPrivate *driContextPriv)
struct nouveau_context *nv = driContextPriv->driverPrivate;
(void)nv;
st_flush(nv->st, 0);
st_flush(nv->st, 0, NULL);
return GL_TRUE;
}

View file

@ -69,8 +69,18 @@ nouveau_pipe_push_reloc(struct nouveau_winsys *nvws, void *ptr,
}
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);
}

View file

@ -164,6 +164,44 @@ nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
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)
{
@ -189,6 +227,10 @@ 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;