From d4d584b16e21b24a473d3a31d361432b8fa0b945 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 21:57:53 +1000 Subject: nv04: remove u_simple_screen usage --- src/gallium/drivers/nv04/nv04_screen.c | 57 ++++++++++-------------------- src/gallium/drivers/nv04/nv04_screen.h | 4 +-- src/gallium/drivers/nv04/nv04_surface_2d.c | 14 ++++---- 3 files changed, 28 insertions(+), 47 deletions(-) (limited to 'src/gallium/drivers/nv04') diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index f9f6d97426..308f7e5960 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -1,27 +1,9 @@ #include "pipe/p_screen.h" #include "pipe/p_inlines.h" -#include "util/u_simple_screen.h" #include "nv04_context.h" #include "nv04_screen.h" -static const char * -nv04_screen_get_name(struct pipe_screen *screen) -{ - struct nv04_screen *nv04screen = nv04_screen(screen); - struct nouveau_device *dev = nv04screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv04_screen_get_vendor(struct pipe_screen *screen) -{ - return "nouveau"; -} - static int nv04_screen_get_param(struct pipe_screen *screen, int param) { @@ -144,18 +126,31 @@ struct pipe_screen * nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); + struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; - unsigned chipset = nvws->channel->device->chipset; int ret; if (!screen) return NULL; + pscreen = &screen->base.base; + screen->nvws = nvws; - if (chipset>=0x20) { + pscreen->winsys = ws; + pscreen->destroy = nv04_screen_destroy; + pscreen->get_param = nv04_screen_get_param; + pscreen->get_paramf = nv04_screen_get_paramf; + pscreen->is_format_supported = nv04_screen_is_format_supported; + + nv04_screen_init_miptree_functions(pscreen); + nv04_screen_init_transfer_functions(pscreen); + nouveau_screen_init(&screen->base, dev); + + if (dev->chipset >= 0x20) { fahrenheit_class = 0; sub3d_class = 0; - } else if (chipset>=0x10) { + } else if (dev->chipset >= 0x10) { fahrenheit_class = NV10_DX5_TEXTURED_TRIANGLE; sub3d_class = NV10_CONTEXT_SURFACES_3D; } else { @@ -164,7 +159,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } if (!fahrenheit_class) { - NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", chipset); + NOUVEAU_ERR("Unknown nv04 chipset: nv%02x\n", dev->chipset); return NULL; } @@ -190,24 +185,10 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv04_screen_destroy(&screen->pipe); + nv04_screen_destroy(pscreen); return NULL; } - screen->pipe.winsys = ws; - screen->pipe.destroy = nv04_screen_destroy; - - screen->pipe.get_name = nv04_screen_get_name; - screen->pipe.get_vendor = nv04_screen_get_vendor; - screen->pipe.get_param = nv04_screen_get_param; - screen->pipe.get_paramf = nv04_screen_get_paramf; - - screen->pipe.is_format_supported = nv04_screen_is_format_supported; - - nv04_screen_init_miptree_functions(&screen->pipe); - nv04_screen_init_transfer_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv04/nv04_screen.h b/src/gallium/drivers/nv04/nv04_screen.h index ee6fb6db44..11466b9442 100644 --- a/src/gallium/drivers/nv04/nv04_screen.h +++ b/src/gallium/drivers/nv04/nv04_screen.h @@ -1,11 +1,11 @@ #ifndef __NV04_SCREEN_H__ #define __NV04_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" #include "nv04_surface_2d.h" struct nv04_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; unsigned chipset; diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index f3a8d7efee..2133123582 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -99,8 +99,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *swzsurf = ctx->swzsurf; struct nouveau_grobj *sifm = ctx->sifm; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); const unsigned src_pitch = ((struct nv04_surface *)src)->pitch; const unsigned max_w = 1024; const unsigned max_h = 1024; @@ -169,8 +169,8 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, { struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *m2mf = ctx->m2mf; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned src_pitch = ((struct nv04_surface *)src)->pitch; unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; unsigned dst_offset = dst->offset + dy * dst_pitch + @@ -216,8 +216,8 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *blit = ctx->blit; - struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src)); - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned src_pitch = ((struct nv04_surface *)src)->pitch; unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; int format; @@ -282,7 +282,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, struct nouveau_channel *chan = ctx->nvws->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *rect = ctx->rect; - struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst)); + struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch; int cs2d_format, gdirect_format; -- cgit v1.2.3 From 1b207d9bb81ae3385e5658a81c71fbf2fe15c18f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 08:47:42 +1000 Subject: nouveau: call notifier/grobj etc funcs directly libdrm_nouveau is linked with the winsys, there's no good reason to do all this through yet another layer. --- src/gallium/drivers/nouveau/nouveau_screen.h | 1 + src/gallium/drivers/nouveau/nouveau_winsys.h | 27 --------- src/gallium/drivers/nv04/nv04_screen.c | 32 +++++++---- src/gallium/drivers/nv04/nv04_surface_2d.c | 1 + src/gallium/drivers/nv10/nv10_screen.c | 28 ++++++---- src/gallium/drivers/nv20/nv20_screen.c | 29 ++++++---- src/gallium/drivers/nv30/nv30_query.c | 25 ++++----- src/gallium/drivers/nv30/nv30_screen.c | 64 ++++++++++++---------- src/gallium/drivers/nv30/nv30_vertprog.c | 20 +++---- src/gallium/drivers/nv40/nv40_query.c | 25 ++++----- src/gallium/drivers/nv40/nv40_screen.c | 43 +++++++++------ src/gallium/drivers/nv40/nv40_vertprog.c | 19 +++---- src/gallium/drivers/nv50/nv50_program.c | 18 +++--- src/gallium/drivers/nv50/nv50_screen.c | 39 ++++++++----- .../winsys/drm/nouveau/drm/nouveau_winsys.c | 50 ----------------- 15 files changed, 195 insertions(+), 226 deletions(-) (limited to 'src/gallium/drivers/nv04') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index cffba11762..9968b07896 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -4,6 +4,7 @@ struct nouveau_screen { struct pipe_screen base; struct nouveau_device *device; + struct nouveau_channel *channel; }; static inline struct nouveau_screen * diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index 762c3a2a21..7998497240 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -27,33 +27,6 @@ struct nouveau_winsys { struct pipe_winsys *ws; struct nouveau_channel *channel; - - int (*res_init)(struct nouveau_resource **heap, unsigned start, - unsigned size); - int (*res_alloc)(struct nouveau_resource *heap, int size, void *priv, - struct nouveau_resource **); - void (*res_free)(struct nouveau_resource **); - - int (*grobj_alloc)(struct nouveau_winsys *, int grclass, - struct nouveau_grobj **); - void (*grobj_free)(struct nouveau_grobj **); - - int (*notifier_alloc)(struct nouveau_winsys *, int count, - struct nouveau_notifier **); - void (*notifier_free)(struct nouveau_notifier **); - void (*notifier_reset)(struct nouveau_notifier *, int id); - uint32_t (*notifier_status)(struct nouveau_notifier *, int id); - uint32_t (*notifier_retval)(struct nouveau_notifier *, int id); - int (*notifier_wait)(struct nouveau_notifier *, int id, - int status, double timeout); - - int (*surface_copy)(struct nouveau_winsys *, struct pipe_surface *, - unsigned, unsigned, struct pipe_surface *, - unsigned, unsigned, unsigned, unsigned); - int (*surface_fill)(struct nouveau_winsys *, struct pipe_surface *, - unsigned, unsigned, unsigned, unsigned, unsigned); - - struct nouveau_bo *(*get_bo)(struct pipe_buffer *); }; extern struct pipe_screen * diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 308f7e5960..98e2dafcd8 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -105,10 +105,9 @@ static void nv04_screen_destroy(struct pipe_screen *pscreen) { struct nv04_screen *screen = nv04_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->fahrenheit); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->fahrenheit); nv04_surface_2d_takedown(&screen->eng2d); FREE(pscreen); @@ -127,6 +126,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; int ret; @@ -135,6 +135,13 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv04_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -145,7 +152,6 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv04_screen_init_miptree_functions(pscreen); nv04_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); if (dev->chipset >= 0x20) { fahrenheit_class = 0; @@ -163,26 +169,30 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv04_surface_buffer; - /* 3D object */ - ret = nvws->grobj_alloc(nvws, fahrenheit_class, &screen->fahrenheit); + ret = nouveau_grobj_alloc(chan, 0xbeef0001, fahrenheit_class, + &screen->fahrenheit); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return NULL; } + BIND_RING(chan, screen->fahrenheit, 7); /* 3D surface object */ - ret = nvws->grobj_alloc(nvws, sub3d_class, &screen->context_surfaces_3d); + ret = nouveau_grobj_alloc(chan, 0xbeef0002, sub3d_class, + &screen->context_surfaces_3d); if (ret) { NOUVEAU_ERR("Error creating 3D surface object: %d\n", ret); return NULL; } + BIND_RING(chan, screen->context_surfaces_3d, 6); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv04_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv04_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index 2133123582..fcb6501411 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -4,6 +4,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_util.h" +#include "nouveau/nouveau_screen.h" #include "nv04_surface_2d.h" static INLINE int diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index 5c36bee6e2..f090d2b0b7 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -102,10 +102,9 @@ static void nv10_screen_destroy(struct pipe_screen *pscreen) { struct nv10_screen *screen = nv10_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->celsius); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->celsius); FREE(pscreen); } @@ -123,6 +122,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned celsius_class; int ret; @@ -131,6 +131,13 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv10_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -141,11 +148,6 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv10_screen_init_miptree_functions(pscreen); nv10_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv10_surface_buffer; /* 3D object */ if (dev->chipset >= 0x20) @@ -162,14 +164,20 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, celsius_class, &screen->celsius); + ret = nouveau_grobj_alloc(chan, 0xbeef0001, celsius_class, + &screen->celsius); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->celsius, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv10_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv10_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 6f3d73fe16..4d991852a1 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -1,5 +1,4 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" #include "nv20_context.h" #include "nv20_screen.h" @@ -103,10 +102,9 @@ static void nv20_screen_destroy(struct pipe_screen *pscreen) { struct nv20_screen *screen = nv20_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->kelvin); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->kelvin); FREE(pscreen); } @@ -124,6 +122,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned kelvin_class = 0; int ret; @@ -132,6 +131,13 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv20_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -142,11 +148,6 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv20_screen_init_miptree_functions(pscreen); nv20_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv20_surface_buffer; /* 3D object */ if (dev->chipset >= 0x25) @@ -159,14 +160,20 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, kelvin_class, &screen->kelvin); + ret = nouveau_grobj_alloc(chan, 0xbeef0097, kelvin_class, + &screen->kelvin); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->kelvin, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv20_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv20_screen_destroy(pscreen); diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c index 2f974cf5c4..1d1c8a484e 100644 --- a/src/gallium/drivers/nv30/nv30_query.c +++ b/src/gallium/drivers/nv30/nv30_query.c @@ -29,11 +29,10 @@ nv30_query_create(struct pipe_context *pipe, unsigned query_type) static void nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) { - struct nv30_context *nv30 = nv30_context(pipe); struct nv30_query *q = nv30_query(pq); if (q->object) - nv30->nvws->res_free(&q->object); + nouveau_resource_free(&q->object); FREE(q); } @@ -54,9 +53,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq) pipe->get_query_result(pipe, pq, 1, &tmp); } - if (nv30->nvws->res_alloc(nv30->screen->query_heap, 1, NULL, &q->object)) + if (nouveau_resource_alloc(nv30->screen->query_heap, 1, NULL, &q->object)) assert(0); - nv30->nvws->notifier_reset(nv30->screen->query, q->object->start); + nouveau_notifier_reset(nv30->screen->query, q->object->start); BEGIN_RING(rankine, NV34TCL_QUERY_RESET, 1); OUT_RING (1); @@ -84,27 +83,27 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq, { struct nv30_context *nv30 = nv30_context(pipe); struct nv30_query *q = nv30_query(pq); - struct nouveau_winsys *nvws = nv30->nvws; assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER); if (!q->ready) { unsigned status; - status = nvws->notifier_status(nv30->screen->query, - q->object->start); + status = nouveau_notifier_status(nv30->screen->query, + q->object->start); if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) { if (wait == FALSE) return FALSE; - nvws->notifier_wait(nv30->screen->query, q->object->start, - NV_NOTIFY_STATE_STATUS_COMPLETED, - 0); + + nouveau_notifier_wait_status(nv30->screen->query, + q->object->start, + NV_NOTIFY_STATE_STATUS_COMPLETED, 0); } - q->result = nvws->notifier_retval(nv30->screen->query, - q->object->start); + q->result = nouveau_notifier_return_val(nv30->screen->query, + q->object->start); q->ready = TRUE; - nvws->res_free(&q->object); + nouveau_resource_free(&q->object); } *result = q->result; diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index f516038b9c..60e2f0855d 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -124,14 +124,13 @@ static void nv30_screen_destroy(struct pipe_screen *pscreen) { struct nv30_screen *screen = nv30_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->res_free(&screen->vp_exec_heap); - nvws->res_free(&screen->vp_data_heap); - nvws->res_free(&screen->query_heap); - nvws->notifier_free(&screen->query); - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->rankine); + nouveau_resource_free(&screen->vp_exec_heap); + nouveau_resource_free(&screen->vp_data_heap); + nouveau_resource_free(&screen->query_heap); + nouveau_notifier_free(&screen->query); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->rankine); FREE(pscreen); } @@ -141,6 +140,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned rankine_class = 0; @@ -150,6 +150,13 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv30_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -160,11 +167,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv30_screen_init_miptree_functions(pscreen); nv30_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv30_surface_buffer; /* 3D object */ switch (dev->chipset & 0xf0) { @@ -187,14 +189,20 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, rankine_class, &screen->rankine); + ret = nouveau_grobj_alloc(chan, 0xbeef3097, rankine_class, + &screen->rankine); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->rankine, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv30_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv30_screen_destroy(pscreen); @@ -202,14 +210,14 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Query objects */ - ret = nvws->notifier_alloc(nvws, 32, &screen->query); + ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); nv30_screen_destroy(pscreen); return NULL; } - ret = nvws->res_init(&screen->query_heap, 0, 32); + ret = nouveau_resource_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); nv30_screen_destroy(pscreen); @@ -217,8 +225,8 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Vtxprog resources */ - if (nvws->res_init(&screen->vp_exec_heap, 0, 256) || - nvws->res_init(&screen->vp_data_heap, 0, 256)) { + if (nouveau_resource_init(&screen->vp_exec_heap, 0, 256) || + nouveau_resource_init(&screen->vp_data_heap, 0, 256)) { nv30_screen_destroy(pscreen); return NULL; } @@ -228,23 +236,23 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->rankine, NV34TCL_DMA_COLOR1, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_COLOR0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_VTXBUF0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); /* so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2); so_data (so, 0); so_data (so, screen->query->handle);*/ so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY7, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY8, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); for (i=1; i<8; i++) { so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1); @@ -301,7 +309,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref(NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c index eaf543b8f7..aec39aae9c 100644 --- a/src/gallium/drivers/nv30/nv30_vertprog.c +++ b/src/gallium/drivers/nv30/nv30_vertprog.c @@ -645,7 +645,6 @@ out_err: static boolean nv30_vertprog_validate(struct nv30_context *nv30) { - struct nouveau_winsys *nvws = nv30->nvws; struct pipe_winsys *ws = nv30->pipe.winsys; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_vertex_program *vp; @@ -669,15 +668,15 @@ nv30_vertprog_validate(struct nv30_context *nv30) struct nouveau_stateobj *so; uint vplen = vp->nr_insns; - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) { + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) { while (heap->next && heap->size < vplen) { struct nv30_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->exec); + nouveau_resource_free(&evict->exec); } - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) assert(0); } @@ -694,15 +693,16 @@ nv30_vertprog_validate(struct nv30_context *nv30) if (vp->nr_consts && !vp->data) { struct nouveau_resource *heap = nv30->screen->vp_data_heap; - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) { + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) { while (heap->next && heap->size < vp->nr_consts) { struct nv30_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->data); + nouveau_resource_free(&evict->data); } - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, + &vp->data)) assert(0); } @@ -804,8 +804,6 @@ nv30_vertprog_validate(struct nv30_context *nv30) void nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp) { - struct nouveau_winsys *nvws = nv30->screen->nvws; - vp->translated = FALSE; if (vp->nr_insns) { @@ -820,9 +818,9 @@ nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp) vp->nr_consts = 0; } - nvws->res_free(&vp->exec); + nouveau_resource_free(&vp->exec); vp->exec_start = 0; - nvws->res_free(&vp->data); + nouveau_resource_free(&vp->data); vp->data_start = 0; vp->data_start_min = 0; diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c index 9b9a43f49d..7874aedd42 100644 --- a/src/gallium/drivers/nv40/nv40_query.c +++ b/src/gallium/drivers/nv40/nv40_query.c @@ -29,11 +29,10 @@ nv40_query_create(struct pipe_context *pipe, unsigned query_type) static void nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq) { - struct nv40_context *nv40 = nv40_context(pipe); struct nv40_query *q = nv40_query(pq); if (q->object) - nv40->nvws->res_free(&q->object); + nouveau_resource_free(&q->object); FREE(q); } @@ -54,9 +53,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq) pipe->get_query_result(pipe, pq, 1, &tmp); } - if (nv40->nvws->res_alloc(nv40->screen->query_heap, 1, NULL, &q->object)) + if (nouveau_resource_alloc(nv40->screen->query_heap, 1, NULL, &q->object)) assert(0); - nv40->nvws->notifier_reset(nv40->screen->query, q->object->start); + nouveau_notifier_reset(nv40->screen->query, q->object->start); BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1); OUT_RING (1); @@ -84,27 +83,27 @@ nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq, { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_query *q = nv40_query(pq); - struct nouveau_winsys *nvws = nv40->nvws; assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER); if (!q->ready) { unsigned status; - status = nvws->notifier_status(nv40->screen->query, - q->object->start); + status = nouveau_notifier_status(nv40->screen->query, + q->object->start); if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) { if (wait == FALSE) return FALSE; - nvws->notifier_wait(nv40->screen->query, q->object->start, - NV_NOTIFY_STATE_STATUS_COMPLETED, - 0); + nouveau_notifier_wait_status(nv40->screen->query, + q->object->start, + NV_NOTIFY_STATE_STATUS_COMPLETED, + 0); } - q->result = nvws->notifier_retval(nv40->screen->query, - q->object->start); + q->result = nouveau_notifier_return_val(nv40->screen->query, + q->object->start); q->ready = TRUE; - nvws->res_free(&q->object); + nouveau_resource_free(&q->object); } *result = q->result; diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 3049bd8031..2114c93cd9 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -130,14 +130,13 @@ static void nv40_screen_destroy(struct pipe_screen *pscreen) { struct nv40_screen *screen = nv40_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - nvws->res_free(&screen->vp_exec_heap); - nvws->res_free(&screen->vp_data_heap); - nvws->res_free(&screen->query_heap); - nvws->notifier_free(&screen->query); - nvws->notifier_free(&screen->sync); - nvws->grobj_free(&screen->curie); + nouveau_resource_free(&screen->vp_exec_heap); + nouveau_resource_free(&screen->vp_data_heap); + nouveau_resource_free(&screen->query_heap); + nouveau_notifier_free(&screen->query); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->curie); nouveau_screen_fini(&screen->base); @@ -149,6 +148,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned curie_class = 0; @@ -158,6 +158,13 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; + ret = nouveau_screen_init(&screen->base, dev); + if (ret) { + nv40_screen_destroy(pscreen); + return NULL; + } + screen->base.channel = chan = nvws->channel; + screen->nvws = nvws; pscreen->winsys = ws; @@ -168,11 +175,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv40_screen_init_miptree_functions(pscreen); nv40_screen_init_transfer_functions(pscreen); - nouveau_screen_init(&screen->base, dev); - - /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); - screen->eng2d->buf = nv40_surface_buffer; /* 3D object */ switch (dev->chipset & 0xf0) { @@ -194,14 +196,19 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, curie_class, &screen->curie); + ret = nouveau_grobj_alloc(chan, 0xbeef3097, curie_class, &screen->curie); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); return FALSE; } + BIND_RING(chan, screen->curie, 7); + + /* 2D engine setup */ + screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d->buf = nv40_surface_buffer; /* Notifier for sync purposes */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv40_screen_destroy(pscreen); @@ -209,14 +216,14 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Query objects */ - ret = nvws->notifier_alloc(nvws, 32, &screen->query); + ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query); if (ret) { NOUVEAU_ERR("Error initialising query objects: %d\n", ret); nv40_screen_destroy(pscreen); return NULL; } - ret = nvws->res_init(&screen->query_heap, 0, 32); + nouveau_resource_init(&screen->query_heap, 0, 32); if (ret) { NOUVEAU_ERR("Error initialising query object heap: %d\n", ret); nv40_screen_destroy(pscreen); @@ -224,8 +231,8 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } /* Vtxprog resources */ - if (nvws->res_init(&screen->vp_exec_heap, 0, 512) || - nvws->res_init(&screen->vp_data_heap, 0, 256)) { + if (nouveau_resource_init(&screen->vp_exec_heap, 0, 512) || + nouveau_resource_init(&screen->vp_data_heap, 0, 256)) { nv40_screen_destroy(pscreen); return NULL; } diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c index 7df9a4d326..f32d4d690c 100644 --- a/src/gallium/drivers/nv40/nv40_vertprog.c +++ b/src/gallium/drivers/nv40/nv40_vertprog.c @@ -855,7 +855,6 @@ out_err: static boolean nv40_vertprog_validate(struct nv40_context *nv40) { - struct nouveau_winsys *nvws = nv40->nvws; struct pipe_winsys *ws = nv40->pipe.winsys; struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_vertex_program *vp; @@ -895,15 +894,15 @@ check_gpu_resources: struct nouveau_stateobj *so; uint vplen = vp->nr_insns; - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) { + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) { while (heap->next && heap->size < vplen) { struct nv40_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->exec); + nouveau_resource_free(&evict->exec); } - if (nvws->res_alloc(heap, vplen, vp, &vp->exec)) + if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) assert(0); } @@ -925,15 +924,15 @@ check_gpu_resources: if (vp->nr_consts && !vp->data) { struct nouveau_resource *heap = nv40->screen->vp_data_heap; - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) { + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) { while (heap->next && heap->size < vp->nr_consts) { struct nv40_vertex_program *evict; evict = heap->next->priv; - nvws->res_free(&evict->data); + nouveau_resource_free(&evict->data); } - if (nvws->res_alloc(heap, vp->nr_consts, vp, &vp->data)) + if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) assert(0); } @@ -1035,8 +1034,6 @@ check_gpu_resources: void nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp) { - struct nouveau_winsys *nvws = nv40->screen->nvws; - vp->translated = FALSE; if (vp->nr_insns) { @@ -1051,9 +1048,9 @@ nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp) vp->nr_consts = 0; } - nvws->res_free(&vp->exec); + nouveau_resource_free(&vp->exec); vp->exec_start = 0; - nvws->res_free(&vp->data); + nouveau_resource_free(&vp->data); vp->data_start = 0; vp->data_start_min = 0; diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 1576d4295e..bc853296cb 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2241,13 +2241,14 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) if (!p->data[0] && p->immd_nr) { struct nouveau_resource *heap = nv50->screen->immd_heap[0]; - if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) { + if (nouveau_resource_alloc(heap, p->immd_nr, p, &p->data[0])) { while (heap->next && heap->size < p->immd_nr) { struct nv50_program *evict = heap->next->priv; - nvws->res_free(&evict->data[0]); + nouveau_resource_free(&evict->data[0]); } - if (nvws->res_alloc(heap, p->immd_nr, p, &p->data[0])) + if (nouveau_resource_alloc(heap, p->immd_nr, p, + &p->data[0])) assert(0); } @@ -2260,13 +2261,14 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) struct nouveau_resource *heap = nv50->screen->parm_heap[p->type]; - if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) { + if (nouveau_resource_alloc(heap, p->param_nr, p, &p->data[1])) { while (heap->next && heap->size < p->param_nr) { struct nv50_program *evict = heap->next->priv; - nvws->res_free(&evict->data[1]); + nouveau_resource_free(&evict->data[1]); } - if (nvws->res_alloc(heap, p->param_nr, p, &p->data[1])) + if (nouveau_resource_alloc(heap, p->param_nr, p, + &p->data[1])) assert(0); } } @@ -2472,8 +2474,8 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) nouveau_bo_ref(NULL, &p->bo); - nv50->screen->nvws->res_free(&p->data[0]); - nv50->screen->nvws->res_free(&p->data[1]); + nouveau_resource_free(&p->data[0]); + nouveau_resource_free(&p->data[1]); p->translated = 0; } diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 3b830847ca..709b7419da 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -136,6 +136,10 @@ nv50_screen_destroy(struct pipe_screen *pscreen) { struct nv50_screen *screen = nv50_screen(pscreen); + nouveau_notifier_free(&screen->sync); + nouveau_grobj_free(&screen->tesla); + nouveau_grobj_free(&screen->eng2d); + nouveau_grobj_free(&screen->m2mf); nouveau_screen_fini(&screen->base); FREE(screen); } @@ -145,6 +149,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); struct nouveau_device *dev = nvws->channel->device; + struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned chipset = dev->chipset; @@ -160,6 +165,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv50_screen_destroy(pscreen); return NULL; } + screen->base.channel = chan = nvws->channel; /* Setup the pipe */ screen->nvws = nvws; @@ -174,20 +180,22 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv50_transfer_init_screen_functions(pscreen); /* DMA engine object */ - ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf); + ret = nouveau_grobj_alloc(chan, 0xbeef5039, 0x5039, &screen->m2mf); if (ret) { NOUVEAU_ERR("Error creating M2MF object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->m2mf, 1); /* 2D object */ - ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d); + ret = nouveau_grobj_alloc(chan, 0xbeef502d, 0x502d, &screen->eng2d); if (ret) { NOUVEAU_ERR("Error creating 2D object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->eng2d, 2); /* 3D object */ switch (chipset & 0xf0) { @@ -213,15 +221,16 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; } - ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla); + ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class, &screen->tesla); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); nv50_screen_destroy(pscreen); return NULL; } + BIND_RING(chan, screen->tesla, 3); /* Sync notifier */ - ret = nvws->notifier_alloc(nvws, 1, &screen->sync); + ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); nv50_screen_destroy(pscreen); @@ -232,8 +241,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so = so_new(32, 0); so_method(so, screen->m2mf, 0x0180, 3); so_data (so, screen->sync->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_emit(nvws, so); so_ref (NULL, &so); @@ -241,9 +250,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so = so_new(64, 0); so_method(so, screen->eng2d, NV50_2D_DMA_NOTIFY, 4); so_data (so, screen->sync->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); - so_data (so, screen->nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->eng2d, NV50_2D_OPERATION, 1); so_data (so, NV50_2D_OPERATION_SRCCOPY); so_method(so, screen->eng2d, 0x0290, 1); @@ -263,11 +272,11 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->tesla, NV50TCL_DMA_UNK0(0), NV50TCL_DMA_UNK0__SIZE); for (i = 0; i < NV50TCL_DMA_UNK0__SIZE; i++) - so_data(so, nvws->channel->vram->handle); + so_data(so, chan->vram->handle); so_method(so, screen->tesla, NV50TCL_DMA_UNK1(0), NV50TCL_DMA_UNK1__SIZE); for (i = 0; i < NV50TCL_DMA_UNK1__SIZE; i++) - so_data(so, nvws->channel->vram->handle); + so_data(so, chan->vram->handle); so_method(so, screen->tesla, 0x121c, 1); so_data (so, 1); @@ -295,9 +304,9 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) } } - if (nvws->res_init(&screen->immd_heap[0], 0, 128) || - nvws->res_init(&screen->parm_heap[0], 0, 128) || - nvws->res_init(&screen->parm_heap[1], 0, 128)) + if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) || + nouveau_resource_init(&screen->parm_heap[0], 0, 128) || + nouveau_resource_init(&screen->parm_heap[1], 0, 128)) { NOUVEAU_ERR("Error initialising constant buffers.\n"); nv50_screen_destroy(pscreen); @@ -405,7 +414,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_emit(nvws, so); so_ref (so, &screen->static_init); so_ref (NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c index 2e0148543d..c03e6ddcae 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c @@ -2,40 +2,6 @@ #include "nouveau_winsys_pipe.h" -static int -nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count, - struct nouveau_notifier **notify) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws); - - return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++, - count, notify); -} - -static int -nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass, - struct nouveau_grobj **grobj) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws); - struct nouveau_channel *chan = nvpws->channel; - int ret; - - ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj); - if (ret) - return ret; - - BEGIN_RING(chan, *grobj, 0x0000, 1); - OUT_RING (chan, (*grobj)->handle); - (*grobj)->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT; - return 0; -} - -static struct nouveau_bo * -nouveau_pipe_get_bo(struct pipe_buffer *pb) -{ - return nouveau_pipe_buffer(pb)->bo; -} - struct nouveau_winsys * nouveau_winsys_new(struct pipe_winsys *ws) { @@ -49,22 +15,6 @@ nouveau_winsys_new(struct pipe_winsys *ws) nvws->ws = ws; nvws->channel = nvpws->channel; - nvws->res_init = nouveau_resource_init; - nvws->res_alloc = nouveau_resource_alloc; - nvws->res_free = nouveau_resource_free; - - nvws->grobj_alloc = nouveau_pipe_grobj_alloc; - nvws->grobj_free = nouveau_grobj_free; - - nvws->notifier_alloc = nouveau_pipe_notifier_alloc; - nvws->notifier_free = nouveau_notifier_free; - nvws->notifier_reset = nouveau_notifier_reset; - nvws->notifier_status = nouveau_notifier_status; - nvws->notifier_retval = nouveau_notifier_return_val; - nvws->notifier_wait = nouveau_notifier_wait_status; - - nvws->get_bo = nouveau_pipe_get_bo; - return nvws; } -- cgit v1.2.3 From 80e9e1ee8172d1e5a81d702681897dddd9d815f1 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 10:28:13 +1000 Subject: nouveau: move channel creation into pipe drivers --- src/gallium/drivers/nouveau/nouveau_push.h | 21 +++-- src/gallium/drivers/nouveau/nouveau_screen.c | 5 ++ src/gallium/drivers/nouveau/nouveau_stateobj.h | 25 +++--- src/gallium/drivers/nouveau/nouveau_winsys.h | 18 ++--- src/gallium/drivers/nv04/nv04_screen.c | 9 +-- src/gallium/drivers/nv04/nv04_surface_2d.c | 13 ++- src/gallium/drivers/nv04/nv04_surface_2d.h | 3 +- src/gallium/drivers/nv10/nv10_context.c | 10 +-- src/gallium/drivers/nv10/nv10_screen.c | 9 +-- src/gallium/drivers/nv20/nv20_context.c | 14 ++-- src/gallium/drivers/nv20/nv20_screen.c | 9 +-- src/gallium/drivers/nv30/nv30_screen.c | 11 +-- src/gallium/drivers/nv30/nv30_state_emit.c | 11 +-- src/gallium/drivers/nv30/nv30_state_fb.c | 35 ++++---- src/gallium/drivers/nv30/nv30_vbo.c | 10 +-- src/gallium/drivers/nv40/nv40_draw.c | 2 +- src/gallium/drivers/nv40/nv40_screen.c | 35 ++++---- src/gallium/drivers/nv40/nv40_state_emit.c | 11 +-- src/gallium/drivers/nv40/nv40_state_fb.c | 92 ++++++++++++---------- src/gallium/drivers/nv40/nv40_vbo.c | 10 +-- src/gallium/drivers/nv50/nv50_clear.c | 2 +- src/gallium/drivers/nv50/nv50_context.c | 2 +- src/gallium/drivers/nv50/nv50_program.c | 13 ++- src/gallium/drivers/nv50/nv50_query.c | 4 +- src/gallium/drivers/nv50/nv50_screen.c | 16 ++-- src/gallium/drivers/nv50/nv50_state_validate.c | 40 +++++----- src/gallium/drivers/nv50/nv50_surface.c | 6 +- src/gallium/drivers/nv50/nv50_transfer.c | 3 +- src/gallium/drivers/nv50/nv50_vbo.c | 10 +-- src/gallium/winsys/drm/nouveau/drm/Makefile | 3 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 11 +-- .../winsys/drm/nouveau/drm/nouveau_winsys.c | 20 ----- 32 files changed, 218 insertions(+), 265 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c (limited to 'src/gallium/drivers/nv04') diff --git a/src/gallium/drivers/nouveau/nouveau_push.h b/src/gallium/drivers/nouveau/nouveau_push.h index afe4668fcd..0f2c42915b 100644 --- a/src/gallium/drivers/nouveau/nouveau_push.h +++ b/src/gallium/drivers/nouveau/nouveau_push.h @@ -9,13 +9,13 @@ #define OUT_RING(data) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - (*pc->nvws->channel->pushbuf->cur++) = (data); \ + (*pc->base.channel->pushbuf->cur++) = (data); \ } while(0) #define OUT_RINGp(src,size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - memcpy(pc->nvws->channel->pushbuf->cur, (src), (size) * 4); \ - pc->nvws->channel->pushbuf->cur += (size); \ + memcpy(pc->base.channel->pushbuf->cur, (src), (size) * 4); \ + pc->base.channel->pushbuf->cur += (size); \ } while(0) #define OUT_RINGf(data) do { \ @@ -26,7 +26,7 @@ #define BEGIN_RING(obj,mthd,size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ + struct nouveau_channel *chan = pc->base.channel; \ if (chan->pushbuf->remaining < ((size) + 1)) \ nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \ @@ -47,14 +47,13 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) #define FIRE_RING(fence) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - DO_FIRE_RING(pc->nvws->channel, fence); \ + DO_FIRE_RING(pc->base.channel, fence); \ } while(0) #define OUT_RELOC(bo,data,flags,vor,tor) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ - nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, \ - pc->nvws->get_bo(bo), \ + struct nouveau_channel *chan = pc->base.channel; \ + nouveau_pushbuf_emit_reloc(chan, chan->pushbuf->cur++, nouveau_bo(bo), \ (data), (flags), (vor), (tor)); \ } while(0) @@ -66,8 +65,8 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) /* FB/TT object handle */ #define OUT_RELOCo(bo,flags) do { \ OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \ - pc->nvws->channel->vram->handle, \ - pc->nvws->channel->gart->handle); \ + pc->base.channel->vram->handle, \ + pc->base.channel->gart->handle); \ } while(0) /* Low 32-bits of offset */ @@ -83,7 +82,7 @@ DO_FIRE_RING(struct nouveau_channel *chan, struct pipe_fence_handle **fence) /* A reloc which'll recombine into a NV_DMA_METHOD packet header */ #define OUT_RELOCm(bo, flags, obj, mthd, size) do { \ NOUVEAU_PUSH_CONTEXT(pc); \ - struct nouveau_channel *chan = pc->nvws->channel; \ + struct nouveau_channel *chan = pc->base.channel; \ if (chan->pushbuf->remaining < ((size) + 1)) \ nouveau_pushbuf_flush(chan, ((size) + 1)); \ OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 3cab83eec0..ab522a124a 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -212,7 +212,12 @@ int nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) { struct pipe_screen *pscreen = &screen->base; + int ret; + ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202, + &screen->channel); + if (ret) + return ret; screen->device = dev; pscreen->get_name = nouveau_screen_get_name; diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h index de3ba9cf14..8e818d9d38 100644 --- a/src/gallium/drivers/nouveau/nouveau_stateobj.h +++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h @@ -107,21 +107,21 @@ so_dump(struct nouveau_stateobj *so) } static INLINE void -so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) +so_emit(struct nouveau_channel *chan, struct nouveau_stateobj *so) { - struct nouveau_pushbuf *pb = nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = chan->pushbuf; unsigned nr, i; nr = so->cur - so->push; if (pb->remaining < nr) - nouveau_pushbuf_flush(nvws->channel, nr); + nouveau_pushbuf_flush(chan, nr); pb->remaining -= nr; memcpy(pb->cur, so->push, nr * 4); for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur + r->offset, + nouveau_pushbuf_emit_reloc(chan, pb->cur + r->offset, r->bo, r->data, r->flags, r->vor, r->tor); } @@ -129,30 +129,29 @@ so_emit(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) } static INLINE void -so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so) +so_emit_reloc_markers(struct nouveau_channel *chan, struct nouveau_stateobj *so) { - struct nouveau_pushbuf *pb = nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = chan->pushbuf; unsigned i; if (!so) return; i = so->cur_reloc << 1; - if (nvws->channel->pushbuf->remaining < i) - nouveau_pushbuf_flush(nvws->channel, i); - nvws->channel->pushbuf->remaining -= i; + if (pb->remaining < i) + nouveau_pushbuf_flush(chan, i); + pb->remaining -= i; for (i = 0; i < so->cur_reloc; i++) { struct nouveau_stateobj_reloc *r = &so->reloc[i]; - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, - r->packet, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->packet, (r->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RDWR)) | NOUVEAU_BO_DUMMY, 0, 0); - nouveau_pushbuf_emit_reloc(nvws->channel, pb->cur++, r->bo, - r->data, r->flags | NOUVEAU_BO_DUMMY, + nouveau_pushbuf_emit_reloc(chan, pb->cur++, r->bo, r->data, + r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor); } } diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index 7998497240..42c77e5e77 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -23,44 +23,38 @@ #define NOUVEAU_BUFFER_USAGE_ZETA (1 << 17) #define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18) -struct nouveau_winsys { - struct pipe_winsys *ws; - - struct nouveau_channel *channel; -}; - extern struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv04_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv10_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv20_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv30_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv40_create(struct pipe_screen *, unsigned pctx_id); extern struct pipe_screen * -nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *); +nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *); extern struct pipe_context * nv50_create(struct pipe_screen *, unsigned pctx_id); diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 98e2dafcd8..4bbedfb4d6 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -122,10 +122,9 @@ nv04_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv04_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv04_screen *screen = CALLOC_STRUCT(nv04_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned fahrenheit_class = 0, sub3d_class = 0; @@ -140,9 +139,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv04_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv04_screen_destroy; @@ -188,7 +185,7 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->context_surfaces_3d, 6); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv04_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c index fcb6501411..5afd028ddd 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.c +++ b/src/gallium/drivers/nv04/nv04_surface_2d.c @@ -97,7 +97,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->swzsurf->channel; struct nouveau_grobj *swzsurf = ctx->swzsurf; struct nouveau_grobj *sifm = ctx->sifm; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); @@ -168,7 +168,7 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->m2mf->channel; struct nouveau_grobj *m2mf = ctx->m2mf; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); @@ -214,7 +214,7 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->surf2d->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *blit = ctx->blit; struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src)); @@ -280,7 +280,7 @@ static void nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst, int dx, int dy, int w, int h, unsigned value) { - struct nouveau_channel *chan = ctx->nvws->channel; + struct nouveau_channel *chan = ctx->surf2d->channel; struct nouveau_grobj *surf2d = ctx->surf2d; struct nouveau_grobj *rect = ctx->rect; struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst)); @@ -335,10 +335,10 @@ nv04_surface_2d_takedown(struct nv04_surface_2d **pctx) } struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_winsys *nvws) +nv04_surface_2d_init(struct nouveau_screen *screen) { struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d); - struct nouveau_channel *chan = nvws->channel; + struct nouveau_channel *chan = screen->channel; unsigned handle = 0x88000000, class; int ret; @@ -461,7 +461,6 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws) return NULL; } - ctx->nvws = nvws; ctx->copy = nv04_surface_copy; ctx->fill = nv04_surface_fill; return ctx; diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.h b/src/gallium/drivers/nv04/nv04_surface_2d.h index 82ce7189c8..02b3f56ba8 100644 --- a/src/gallium/drivers/nv04/nv04_surface_2d.h +++ b/src/gallium/drivers/nv04/nv04_surface_2d.h @@ -7,7 +7,6 @@ struct nv04_surface { }; struct nv04_surface_2d { - struct nouveau_winsys *nvws; struct nouveau_notifier *ntfy; struct nouveau_grobj *surf2d; struct nouveau_grobj *swzsurf; @@ -26,7 +25,7 @@ struct nv04_surface_2d { }; struct nv04_surface_2d * -nv04_surface_2d_init(struct nouveau_winsys *nvws); +nv04_surface_2d_init(struct nouveau_screen *screen); void nv04_surface_2d_takedown(struct nv04_surface_2d **); diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c index 3da8d2f568..a127b134ec 100644 --- a/src/gallium/drivers/nv10/nv10_context.c +++ b/src/gallium/drivers/nv10/nv10_context.c @@ -30,18 +30,18 @@ nv10_destroy(struct pipe_context *pipe) static void nv10_init_hwctx(struct nv10_context *nv10) { struct nv10_screen *screen = nv10->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; int i; float projectionmatrix[16]; BEGIN_RING(celsius, NV10TCL_DMA_NOTIFY, 1); OUT_RING (screen->sync->handle); BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY0, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->gart->handle); + OUT_RING (chan->vram->handle); + OUT_RING (chan->gart->handle); BEGIN_RING(celsius, NV10TCL_DMA_IN_MEMORY2, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); + OUT_RING (chan->vram->handle); BEGIN_RING(celsius, NV10TCL_NOP, 1); OUT_RING (0); diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index f090d2b0b7..b03c291f9d 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -118,10 +118,9 @@ nv10_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv10_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv10_screen *screen = CALLOC_STRUCT(nv10_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned celsius_class; @@ -136,9 +135,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv10_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv10_screen_destroy; @@ -173,7 +170,7 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->celsius, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv10_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c index cbc41707d5..b32d0d83ba 100644 --- a/src/gallium/drivers/nv20/nv20_context.c +++ b/src/gallium/drivers/nv20/nv20_context.c @@ -30,7 +30,7 @@ nv20_destroy(struct pipe_context *pipe) static void nv20_init_hwctx(struct nv20_context *nv20) { struct nv20_screen *screen = nv20->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; int i; float projectionmatrix[16]; const boolean is_nv25tcl = (nv20->screen->kelvin->grclass == NV25TCL); @@ -38,11 +38,11 @@ static void nv20_init_hwctx(struct nv20_context *nv20) BEGIN_RING(kelvin, NV20TCL_DMA_NOTIFY, 1); OUT_RING (screen->sync->handle); BEGIN_RING(kelvin, NV20TCL_DMA_TEXTURE0, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->gart->handle); /* TEXTURE1 */ + OUT_RING (chan->vram->handle); + OUT_RING (chan->gart->handle); /* TEXTURE1 */ BEGIN_RING(kelvin, NV20TCL_DMA_COLOR, 2); - OUT_RING (nvws->channel->vram->handle); - OUT_RING (nvws->channel->vram->handle); /* ZETA */ + OUT_RING (chan->vram->handle); + OUT_RING (chan->vram->handle); /* ZETA */ BEGIN_RING(kelvin, NV20TCL_DMA_QUERY, 1); OUT_RING (0); /* renouveau: beef0351, unique */ @@ -99,9 +99,9 @@ static void nv20_init_hwctx(struct nv20_context *nv20) OUT_RING (3); BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY9, 1); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); BEGIN_RING(kelvin, NV25TCL_DMA_IN_MEMORY8, 1); - OUT_RING (nvws->channel->vram->handle); + OUT_RING (chan->vram->handle); } BEGIN_RING(kelvin, NV20TCL_DMA_FENCE, 1); OUT_RING (0); /* renouveau: beef1e10 */ diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 4d991852a1..024356ca74 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -118,10 +118,9 @@ nv20_surface_buffer(struct pipe_surface *surf) } struct pipe_screen * -nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv20_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv20_screen *screen = CALLOC_STRUCT(nv20_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; unsigned kelvin_class = 0; @@ -136,9 +135,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv20_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv20_screen_destroy; @@ -169,7 +166,7 @@ nv20_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->kelvin, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv20_surface_buffer; /* Notifier for sync purposes */ diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 60e2f0855d..31bc1f3173 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -136,10 +136,9 @@ nv30_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -155,9 +154,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv30_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv30_screen_destroy; @@ -198,7 +195,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->rankine, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv30_surface_buffer; /* Notifier for sync purposes */ @@ -307,7 +304,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->rankine, 0x1e94, 1); so_data (so, 0x13); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); nouveau_pushbuf_flush(chan, 0); diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c index c18be20a32..621b8846c8 100644 --- a/src/gallium/drivers/nv30/nv30_state_emit.c +++ b/src/gallium/drivers/nv30/nv30_state_emit.c @@ -38,6 +38,7 @@ nv30_state_do_validate(struct nv30_context *nv30, void nv30_state_emit(struct nv30_context *nv30) { + struct nouveau_channel *chan = nv30->screen->base.channel; struct nv30_state *state = &nv30->state; struct nv30_screen *screen = nv30->screen; unsigned i, samplers; @@ -57,23 +58,23 @@ nv30_state_emit(struct nv30_context *nv30) continue; so_ref (state->hw[i], &nv30->screen->state[i]); if (state->hw[i]) - so_emit(nv30->nvws, nv30->screen->state[i]); + so_emit(chan, nv30->screen->state[i]); states &= ~(1ULL << i); } state->dirty = 0; - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FB]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]); for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) { if (!(samplers & (1 << i))) continue; - so_emit_reloc_markers(nv30->nvws, + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGTEX0+i]); samplers &= ~(1ULL << i); } - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_FRAGPROG]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGPROG]); if (state->hw[NV30_STATE_VTXBUF] /*&& nv30->render_mode == HW*/) - so_emit_reloc_markers(nv30->nvws, state->hw[NV30_STATE_VTXBUF]); + so_emit_reloc_markers(chan, state->hw[NV30_STATE_VTXBUF]); } boolean diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 1be916872f..cb1a260eaa 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -5,6 +5,8 @@ static boolean nv30_state_framebuffer_validate(struct nv30_context *nv30) { struct pipe_framebuffer_state *fb = &nv30->framebuffer; + struct nouveau_channel *chan = nv30->screen->base.channel; + struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv04_surface *rt[2], *zeta = NULL; uint32_t rt_enable, rt_format; int i, colour_format = 0, zeta_format = 0; @@ -79,11 +81,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) } nv30mt = (struct nv30_miptree *)rt[0]->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1); + so_method(so, rankine, NV34TCL_DMA_COLOR0, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2); + chan->vram->handle, chan->gart->handle); + so_method(so, rankine, NV34TCL_COLOR0_PITCH, 2); so_data (so, pitch); so_reloc (so, nouveau_bo(nv30mt->buffer), rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); @@ -91,11 +92,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) { nv30mt = (struct nv30_miptree *)rt[1]->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1); + so_method(so, rankine, NV34TCL_DMA_COLOR1, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2); + chan->vram->handle, chan->gart->handle); + so_method(so, rankine, NV34TCL_COLOR1_OFFSET, 2); so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); so_data (so, rt[1]->pitch); @@ -103,32 +103,31 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) if (zeta_format) { nv30mt = (struct nv30_miptree *)zeta->base.texture; - so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1); + so_method(so, rankine, NV34TCL_DMA_ZETA, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR, - nv30->nvws->channel->vram->handle, - nv30->nvws->channel->gart->handle); - so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1); + chan->vram->handle, chan->gart->handle); + so_method(so, rankine, NV34TCL_ZETA_OFFSET, 1); so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); /* TODO: allocate LMA depth buffer */ } - so_method(so, nv30->screen->rankine, NV34TCL_RT_ENABLE, 1); + so_method(so, rankine, NV34TCL_RT_ENABLE, 1); so_data (so, rt_enable); - so_method(so, nv30->screen->rankine, NV34TCL_RT_HORIZ, 3); + so_method(so, rankine, NV34TCL_RT_HORIZ, 3); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); so_data (so, rt_format); - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_HORIZ, 2); + so_method(so, rankine, NV34TCL_VIEWPORT_HORIZ, 2); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2); + so_method(so, rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2); so_data (so, ((w - 1) << 16) | 0); so_data (so, ((h - 1) << 16) | 0); - so_method(so, nv30->screen->rankine, 0x1d88, 1); + so_method(so, rankine, 0x1d88, 1); so_data (so, (1 << 12) | h); /* Wonder why this is needed, context should all be set to zero on init */ - so_method(so, nv30->screen->rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1); + so_method(so, rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1); so_data (so, 0); so_ref(so, &nv30->state.hw[NV30_STATE_FB]); diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index ff2bf6e71b..9b72bc3002 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -168,7 +168,7 @@ nv30_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; unsigned restart = 0; nv30_vbo_set_idxbuf(nv30, NULL, 0); @@ -228,7 +228,7 @@ static INLINE void nv30_draw_elements_u08(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint8_t *elts = (uint8_t *)ib + start; @@ -277,7 +277,7 @@ static INLINE void nv30_draw_elements_u16(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint16_t *elts = (uint16_t *)ib + start; @@ -326,7 +326,7 @@ static INLINE void nv30_draw_elements_u32(struct nv30_context *nv30, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; while (count) { uint32_t *elts = (uint32_t *)ib + start; @@ -401,7 +401,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct nouveau_channel *chan = nv30->nvws->channel; + struct nouveau_channel *chan = nv30->screen->base.channel; unsigned restart = 0; while (count) { diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c index c83ff91d7e..e7d8cf93a9 100644 --- a/src/gallium/drivers/nv40/nv40_draw.c +++ b/src/gallium/drivers/nv40/nv40_draw.c @@ -81,7 +81,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim, { struct nv40_render_stage *rs = nv40_render_stage(stage); struct nv40_context *nv40 = rs->nv40; - struct nouveau_pushbuf *pb = nv40->nvws->channel->pushbuf; + struct nouveau_pushbuf *pb = nv40->screen->base.channel->pushbuf; unsigned i; /* Ensure there's room for 4xfloat32 + potentially 3 begin/end */ diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 2114c93cd9..b8b2af482a 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -144,10 +144,9 @@ nv40_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -163,9 +162,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nv40_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv40_screen_destroy; @@ -204,7 +201,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) BIND_RING(chan, screen->curie, 7); /* 2D engine setup */ - screen->eng2d = nv04_surface_2d_init(nvws); + screen->eng2d = nv04_surface_2d_init(&screen->base); screen->eng2d->buf = nv40_surface_buffer; /* Notifier for sync purposes */ @@ -242,25 +239,25 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1); so_data (so, screen->sync->handle); so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR1, 1); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_VTXBUF0, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->gart->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->gart->handle); so_method(so, screen->curie, NV40TCL_DMA_FENCE, 2); so_data (so, 0); so_data (so, screen->query->handle); so_method(so, screen->curie, NV40TCL_DMA_UNK01AC, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, NV40TCL_DMA_COLOR2, 2); - so_data (so, nvws->channel->vram->handle); - so_data (so, nvws->channel->vram->handle); + so_data (so, chan->vram->handle); + so_data (so, chan->vram->handle); so_method(so, screen->curie, 0x1ea4, 3); so_data (so, 0x00000010); @@ -285,9 +282,9 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->curie, 0x1e94, 1); so_data (so, 0x00000001); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); - nouveau_pushbuf_flush(nvws->channel, 0); + nouveau_pushbuf_flush(chan, 0); return pscreen; } diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c index 10aae29832..198692965d 100644 --- a/src/gallium/drivers/nv40/nv40_state_emit.c +++ b/src/gallium/drivers/nv40/nv40_state_emit.c @@ -54,6 +54,7 @@ nv40_state_do_validate(struct nv40_context *nv40, void nv40_state_emit(struct nv40_context *nv40) { + struct nouveau_channel *chan = nv40->screen->base.channel; struct nv40_state *state = &nv40->state; struct nv40_screen *screen = nv40->screen; unsigned i, samplers; @@ -73,7 +74,7 @@ nv40_state_emit(struct nv40_context *nv40) continue; so_ref (state->hw[i], &nv40->screen->state[i]); if (state->hw[i]) - so_emit(nv40->nvws, nv40->screen->state[i]); + so_emit(chan, nv40->screen->state[i]); states &= ~(1ULL << i); } @@ -87,17 +88,17 @@ nv40_state_emit(struct nv40_context *nv40) state->dirty = 0; - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FB]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]); for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) { if (!(samplers & (1 << i))) continue; - so_emit_reloc_markers(nv40->nvws, + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGTEX0+i]); samplers &= ~(1ULL << i); } - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_FRAGPROG]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGPROG]); if (state->hw[NV40_STATE_VTXBUF] && nv40->render_mode == HW) - so_emit_reloc_markers(nv40->nvws, state->hw[NV40_STATE_VTXBUF]); + so_emit_reloc_markers(chan, state->hw[NV40_STATE_VTXBUF]); } boolean diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c index d8364ff993..273142f9e0 100644 --- a/src/gallium/drivers/nv40/nv40_state_fb.c +++ b/src/gallium/drivers/nv40/nv40_state_fb.c @@ -13,6 +13,8 @@ nv40_do_surface_buffer(struct pipe_surface *surface) static boolean nv40_state_framebuffer_validate(struct nv40_context *nv40) { + struct nouveau_channel *chan = nv40->screen->base.channel; + struct nouveau_grobj *curie = nv40->screen->curie; struct pipe_framebuffer_state *fb = &nv40->framebuffer; struct nv04_surface *rt[4], *zeta; uint32_t rt_enable, rt_format; @@ -79,76 +81,80 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) } if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR0, 1); - so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2); + so_method(so, curie, NV40TCL_DMA_COLOR0, 1); + so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR0_PITCH, 2); so_data (so, rt[0]->pitch); - so_reloc (so, nv40_surface_buffer(&rt[0]->base), rt[0]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, nv40_surface_buffer(&rt[0]->base), + rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR1, 1); - so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2); - so_reloc (so, nv40_surface_buffer(&rt[1]->base), rt[1]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); + so_method(so, curie, NV40TCL_DMA_COLOR1, 1); + so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR1_OFFSET, 2); + so_reloc (so, nv40_surface_buffer(&rt[1]->base), + rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); so_data (so, rt[1]->pitch); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR2, 1); - so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR2_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&rt[2]->base), rt[2]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_COLOR2, 1); + so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR2_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&rt[2]->base), + rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); + so_method(so, curie, NV40TCL_COLOR2_PITCH, 1); so_data (so, rt[2]->pitch); } if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR3, 1); - so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_COLOR3_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&rt[3]->base), rt[3]->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_COLOR3, 1); + so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_COLOR3_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&rt[3]->base), + rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW, + 0, 0); + so_method(so, curie, NV40TCL_COLOR3_PITCH, 1); so_data (so, rt[3]->pitch); } if (zeta_format) { - so_method(so, nv40->screen->curie, NV40TCL_DMA_ZETA, 1); - so_reloc (so, nv40_surface_buffer(&zeta->base), 0, rt_flags | NOUVEAU_BO_OR, - nv40->nvws->channel->vram->handle, - nv40->nvws->channel->gart->handle); - so_method(so, nv40->screen->curie, NV40TCL_ZETA_OFFSET, 1); - so_reloc (so, nv40_surface_buffer(&zeta->base), zeta->base.offset, rt_flags | - NOUVEAU_BO_LOW, 0, 0); - so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1); + so_method(so, curie, NV40TCL_DMA_ZETA, 1); + so_reloc (so, nv40_surface_buffer(&zeta->base), 0, + rt_flags | NOUVEAU_BO_OR, + chan->vram->handle, chan->gart->handle); + so_method(so, curie, NV40TCL_ZETA_OFFSET, 1); + so_reloc (so, nv40_surface_buffer(&zeta->base), + zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); + so_method(so, curie, NV40TCL_ZETA_PITCH, 1); so_data (so, zeta->pitch); } - so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1); + so_method(so, curie, NV40TCL_RT_ENABLE, 1); so_data (so, rt_enable); - so_method(so, nv40->screen->curie, NV40TCL_RT_HORIZ, 3); + so_method(so, curie, NV40TCL_RT_HORIZ, 3); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); so_data (so, rt_format); - so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_HORIZ, 2); + so_method(so, curie, NV40TCL_VIEWPORT_HORIZ, 2); so_data (so, (w << 16) | 0); so_data (so, (h << 16) | 0); - so_method(so, nv40->screen->curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2); + so_method(so, curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2); so_data (so, ((w - 1) << 16) | 0); so_data (so, ((h - 1) << 16) | 0); - so_method(so, nv40->screen->curie, 0x1d88, 1); + so_method(so, curie, 0x1d88, 1); so_data (so, (1 << 12) | h); so_ref(so, &nv40->state.hw[NV40_STATE_FB]); diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 4abddba110..24bd116539 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -168,7 +168,7 @@ nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; unsigned restart; nv40_vbo_set_idxbuf(nv40, NULL, 0); @@ -227,7 +227,7 @@ static INLINE void nv40_draw_elements_u08(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint8_t *elts = (uint8_t *)ib + start; @@ -276,7 +276,7 @@ static INLINE void nv40_draw_elements_u16(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint16_t *elts = (uint16_t *)ib + start; @@ -325,7 +325,7 @@ static INLINE void nv40_draw_elements_u32(struct nv40_context *nv40, void *ib, unsigned mode, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; while (count) { uint32_t *elts = (uint32_t *)ib + start; @@ -400,7 +400,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct nouveau_channel *chan = nv40->nvws->channel; + struct nouveau_channel *chan = nv40->screen->base.channel; unsigned restart; while (count) { diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index 33427a15a5..e0b2d2880b 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -31,7 +31,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, double depth, unsigned stencil) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned mode = 0, i; diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index a511f655c1..e02afc4be9 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -33,7 +33,7 @@ nv50_flush(struct pipe_context *pipe, unsigned flags, { struct nv50_context *nv50 = (struct nv50_context *)pipe; - FIRE_RING(nv50->screen->nvws->channel); + FIRE_RING(nv50->screen->base.channel); } static void diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index bc853296cb..9d6427e2bc 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2215,7 +2215,7 @@ static void nv50_program_upload_data(struct nv50_context *nv50, float *map, unsigned start, unsigned count, unsigned cbuf) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; while (count) { @@ -2235,7 +2235,6 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map, static void nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) { - struct nouveau_winsys *nvws = nv50->screen->nvws; struct pipe_winsys *ws = nv50->pipe.winsys; if (!p->data[0] && p->immd_nr) { @@ -2288,7 +2287,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) static void nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_program_exec *e; struct nouveau_stateobj *so; @@ -2353,14 +2352,14 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) start = 0; count = p->exec_size; while (count) { - struct nouveau_winsys *nvws = nv50->screen->nvws; + struct nouveau_channel *chan = nv50->screen->base.channel; unsigned nr; - so_emit(nvws, so); + so_emit(chan, so); nr = MIN2(count, 2047); - nr = MIN2(nvws->channel->pushbuf->remaining, nr); - if (nvws->channel->pushbuf->remaining < (nr + 3)) { + nr = MIN2(chan->pushbuf->remaining, nr); + if (chan->pushbuf->remaining < (nr + 3)) { FIRE_RING(chan); continue; } diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 4d05eeac2c..c77ffe84e7 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -71,7 +71,7 @@ static void nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); @@ -87,7 +87,7 @@ static void nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); struct nouveau_bo *bo = nouveau_bo(q->buffer); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 709b7419da..7904b51f77 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -145,10 +145,9 @@ nv50_screen_destroy(struct pipe_screen *pscreen) } struct pipe_screen * -nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) +nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); - struct nouveau_device *dev = nvws->channel->device; struct nouveau_channel *chan; struct pipe_screen *pscreen; struct nouveau_stateobj *so; @@ -160,15 +159,12 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) return NULL; pscreen = &screen->base.base; - ret = nouveau_screen_init(&screen->base, nvws->channel->device); + ret = nouveau_screen_init(&screen->base, dev); if (ret) { nv50_screen_destroy(pscreen); return NULL; } - screen->base.channel = chan = nvws->channel; - - /* Setup the pipe */ - screen->nvws = nvws; + chan = screen->base.channel; pscreen->winsys = ws; pscreen->destroy = nv50_screen_destroy; @@ -243,7 +239,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_data (so, screen->sync->handle); so_data (so, chan->vram->handle); so_data (so, chan->vram->handle); - so_emit(nvws, so); + so_emit(chan, so); so_ref (NULL, &so); /* Static 2D init */ @@ -259,7 +255,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_data (so, 0); so_method(so, screen->eng2d, 0x0888, 1); so_data (so, 1); - so_emit(nvws, so); + so_emit(chan, so); so_ref(NULL, &so); /* Static tesla init */ @@ -411,7 +407,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_method(so, screen->tesla, 0x1458, 1); so_data (so, 1); - so_emit(nvws, so); + so_emit(chan, so); so_ref (so, &screen->static_init); so_ref (NULL, &so); nouveau_pushbuf_flush(chan, 0); diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index d1f0ccdd8a..9e70d4b78d 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -131,7 +131,7 @@ static void nv50_state_emit(struct nv50_context *nv50) { struct nv50_screen *screen = nv50->screen; - struct nouveau_winsys *nvws = screen->nvws; + struct nouveau_channel *chan = screen->base.channel; if (nv50->pctx_id != screen->cur_pctx) { nv50->state.dirty |= 0xffffffff; @@ -139,40 +139,40 @@ nv50_state_emit(struct nv50_context *nv50) } if (nv50->state.dirty & NV50_NEW_FRAMEBUFFER) - so_emit(nvws, nv50->state.fb); + so_emit(chan, nv50->state.fb); if (nv50->state.dirty & NV50_NEW_BLEND) - so_emit(nvws, nv50->state.blend); + so_emit(chan, nv50->state.blend); if (nv50->state.dirty & NV50_NEW_ZSA) - so_emit(nvws, nv50->state.zsa); + so_emit(chan, nv50->state.zsa); if (nv50->state.dirty & NV50_NEW_VERTPROG) - so_emit(nvws, nv50->state.vertprog); + so_emit(chan, nv50->state.vertprog); if (nv50->state.dirty & NV50_NEW_FRAGPROG) - so_emit(nvws, nv50->state.fragprog); + so_emit(chan, nv50->state.fragprog); if (nv50->state.dirty & NV50_NEW_RASTERIZER) - so_emit(nvws, nv50->state.rast); + so_emit(chan, nv50->state.rast); if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR) - so_emit(nvws, nv50->state.blend_colour); + so_emit(chan, nv50->state.blend_colour); if (nv50->state.dirty & NV50_NEW_STIPPLE) - so_emit(nvws, nv50->state.stipple); + so_emit(chan, nv50->state.stipple); if (nv50->state.dirty & NV50_NEW_SCISSOR) - so_emit(nvws, nv50->state.scissor); + so_emit(chan, nv50->state.scissor); if (nv50->state.dirty & NV50_NEW_VIEWPORT) - so_emit(nvws, nv50->state.viewport); + so_emit(chan, nv50->state.viewport); if (nv50->state.dirty & NV50_NEW_SAMPLER) - so_emit(nvws, nv50->state.tsc_upload); + so_emit(chan, nv50->state.tsc_upload); if (nv50->state.dirty & NV50_NEW_TEXTURE) - so_emit(nvws, nv50->state.tic_upload); + so_emit(chan, nv50->state.tic_upload); if (nv50->state.dirty & NV50_NEW_ARRAYS) { - so_emit(nvws, nv50->state.vtxfmt); - so_emit(nvws, nv50->state.vtxbuf); + so_emit(chan, nv50->state.vtxfmt); + so_emit(chan, nv50->state.vtxbuf); } nv50->state.dirty = 0; - so_emit_reloc_markers(nvws, nv50->state.fb); - so_emit_reloc_markers(nvws, nv50->state.vertprog); - so_emit_reloc_markers(nvws, nv50->state.fragprog); - so_emit_reloc_markers(nvws, nv50->state.vtxbuf); - so_emit_reloc_markers(nvws, nv50->screen->static_init); + so_emit_reloc_markers(chan, nv50->state.fb); + so_emit_reloc_markers(chan, nv50->state.vertprog); + so_emit_reloc_markers(chan, nv50->state.fragprog); + so_emit_reloc_markers(chan, nv50->state.vtxbuf); + so_emit_reloc_markers(chan, nv50->screen->static_init); } boolean diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 121eddfc83..cd4e7ef690 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -52,7 +52,7 @@ static int nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) { struct nv50_miptree *mt = nv50_miptree(ps->texture); - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer); int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; @@ -104,7 +104,7 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst, int dx, int dy, struct pipe_surface *src, int sx, int sy, int w, int h) { - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; int ret; @@ -161,7 +161,7 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, { struct nv50_context *nv50 = (struct nv50_context *)pipe; struct nv50_screen *screen = nv50->screen; - struct nouveau_channel *chan = screen->nvws->channel; + struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; int format, ret; diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 5f1e430ad1..a0a2099035 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -24,8 +24,7 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, unsigned src_reloc, unsigned dst_reloc) { struct nv50_screen *screen = nv50_screen(pscreen); - struct nouveau_winsys *nvws = screen->nvws; - struct nouveau_channel *chan = nvws->channel; + struct nouveau_channel *chan = screen->m2mf->channel; struct nouveau_grobj *m2mf = screen->m2mf; struct nouveau_bo *src_bo = nouveau_bo(src); struct nouveau_bo *dst_bo = nouveau_bo(dst); diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 6f4981d1ff..a9b53a0f2e 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -53,7 +53,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; nv50_state_validate(nv50); @@ -83,7 +83,7 @@ static INLINE void nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -112,7 +112,7 @@ static INLINE void nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -141,7 +141,7 @@ static INLINE void nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint8_t *map, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; map += start; @@ -163,7 +163,7 @@ nv50_draw_elements(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->nvws->channel; + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_winsys *ws = pipe->winsys; void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile index 2da78d8690..621ad2a807 100644 --- a/src/gallium/winsys/drm/nouveau/drm/Makefile +++ b/src/gallium/winsys/drm/nouveau/drm/Makefile @@ -4,8 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveaudrm C_SOURCES = nouveau_drm_api.c \ - nouveau_winsys_pipe.c \ - nouveau_winsys.c + nouveau_winsys_pipe.c LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index b355a1391d..22c53f6ea9 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -70,10 +70,9 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct dri1_create_screen_arg *dri1 = (void *)arg; struct pipe_winsys *ws; - struct nouveau_winsys *nvws; struct nouveau_device *dev = NULL; struct pipe_screen *(*init)(struct pipe_winsys *, - struct nouveau_winsys *); + struct nouveau_device *); int ret; ret = nouveau_device_open_existing(&dev, 0, fd, 0); @@ -114,13 +113,7 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) return NULL; } - nvws = nouveau_winsys_new(ws); - if (!nvws) { - ws->destroy(ws); - return NULL; - } - - nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws); + nouveau_pipe_winsys(ws)->pscreen = init(ws, dev); if (!nouveau_pipe_winsys(ws)->pscreen) { ws->destroy(ws); return NULL; diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c deleted file mode 100644 index c03e6ddcae..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "util/u_memory.h" - -#include "nouveau_winsys_pipe.h" - -struct nouveau_winsys * -nouveau_winsys_new(struct pipe_winsys *ws) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_winsys *nvws; - - nvws = CALLOC_STRUCT(nouveau_winsys); - if (!nvws) - return NULL; - - nvws->ws = ws; - nvws->channel = nvpws->channel; - - return nvws; -} - -- cgit v1.2.3 From 6b3ca672eb85d30d6c28e91000e2cc2231a41bef Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Jun 2009 11:21:08 +1000 Subject: nouveau: remove unneeded code from ws, use pipe_buffer_ instead of ws-> --- src/gallium/drivers/nv04/nv04_state.c | 7 +- src/gallium/drivers/nv04/nv04_vbo.c | 16 +- src/gallium/drivers/nv10/nv10_prim_vbuf.c | 14 +- src/gallium/drivers/nv10/nv10_state.c | 7 +- src/gallium/drivers/nv10/nv10_vbo.c | 15 +- src/gallium/drivers/nv20/nv20_prim_vbuf.c | 12 +- src/gallium/drivers/nv20/nv20_state.c | 7 +- src/gallium/drivers/nv20/nv20_vbo.c | 16 +- src/gallium/drivers/nv20/nv20_vertprog.c | 12 +- src/gallium/drivers/nv30/nv30_fragprog.c | 17 +- src/gallium/drivers/nv30/nv30_vbo.c | 18 +- src/gallium/drivers/nv30/nv30_vertprog.c | 12 +- src/gallium/drivers/nv40/nv40_draw.c | 19 +- src/gallium/drivers/nv40/nv40_fragprog.c | 17 +- src/gallium/drivers/nv40/nv40_vbo.c | 17 +- src/gallium/drivers/nv40/nv40_vertprog.c | 9 +- src/gallium/drivers/nv50/nv50_program.c | 8 +- src/gallium/drivers/nv50/nv50_query.c | 8 +- src/gallium/drivers/nv50/nv50_vbo.c | 8 +- src/gallium/winsys/drm/nouveau/drm/Makefile | 3 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 84 +++++---- .../winsys/drm/nouveau/drm/nouveau_drm_api.h | 27 +++ .../winsys/drm/nouveau/drm/nouveau_winsys_pipe.c | 205 --------------------- .../winsys/drm/nouveau/drm/nouveau_winsys_pipe.h | 54 ------ 24 files changed, 198 insertions(+), 414 deletions(-) delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c delete mode 100644 src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h (limited to 'src/gallium/drivers/nv04') diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c index 87c635f962..d356ebd8b3 100644 --- a/src/gallium/drivers/nv04/nv04_state.c +++ b/src/gallium/drivers/nv04/nv04_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -334,7 +335,7 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv04_context *nv04 = nv04_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -342,12 +343,12 @@ nv04_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv04->constbuf[shader], mapped, buf->buffer->size); nv04->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c index d21a0e34f7..e3167814f2 100644 --- a/src/gallium/drivers/nv04/nv04_vbo.c +++ b/src/gallium/drivers/nv04/nv04_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv04_context.h" #include "nv04_state.h" @@ -13,6 +14,7 @@ boolean nv04_draw_elements( struct pipe_context *pipe, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { + struct pipe_screen *pscreen = pipe->screen; struct nv04_context *nv04 = nv04_context( pipe ); struct draw_context *draw = nv04->draw; unsigned i; @@ -25,17 +27,17 @@ boolean nv04_draw_elements( struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv04->vtxbuf[i].buffer) { void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv04->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, + nv04->vtxbuf[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +57,12 @@ boolean nv04_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv04->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv04->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv04->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c index f16e343fa6..1806d5f8cc 100644 --- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c +++ b/src/gallium/drivers/nv10/nv10_prim_vbuf.c @@ -40,7 +40,6 @@ #include "util/u_debug.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "nv10_context.h" #include "nv10_state.h" @@ -124,11 +123,10 @@ nv10_vbuf_render_map_vertices( struct vbuf_render *render ) { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_winsys *winsys = nv10->pipe.winsys; + struct pipe_screen *pscreen = nv10->pipe.screen; - return winsys->buffer_map(winsys, - nv10_render->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); + return pipe_buffer_map(pscreen, nv10_render->buffer, + PIPE_BUFFER_USAGE_CPU_WRITE); } static void @@ -138,10 +136,10 @@ nv10_vbuf_render_unmap_vertices( struct vbuf_render *render, { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_winsys *winsys = nv10->pipe.winsys; + struct pipe_screen *pscreen = nv10->pipe.screen; assert(!nv10_render->buffer); - winsys->buffer_unmap(winsys, nv10_render->buffer); + pipe_buffer_unmap(pscreen, nv10_render->buffer); } static boolean @@ -202,8 +200,6 @@ static void nv10_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render); - struct nv10_context *nv10 = nv10_render->nv10; - struct pipe_screen *pscreen = &nv10->screen->base.base; assert(nv10_render->buffer); pipe_buffer_reference(&nv10_render->buffer, NULL); diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c index 119af66dfd..9b38219b99 100644 --- a/src/gallium/drivers/nv10/nv10_state.c +++ b/src/gallium/drivers/nv10/nv10_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -460,7 +461,7 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv10_context *nv10 = nv10_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -468,12 +469,12 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv10->constbuf[shader], mapped, buf->buffer->size); nv10->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c index d0e788ac03..441a4f75f3 100644 --- a/src/gallium/drivers/nv10/nv10_vbo.c +++ b/src/gallium/drivers/nv10/nv10_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv10_context.h" #include "nv10_state.h" @@ -15,6 +16,7 @@ boolean nv10_draw_elements( struct pipe_context *pipe, { struct nv10_context *nv10 = nv10_context( pipe ); struct draw_context *draw = nv10->draw; + struct pipe_screen *pscreen = pipe->screen; unsigned i; nv10_emit_hw_state(nv10); @@ -24,9 +26,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv10->vtxbuf[i].buffer) { - void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv10->vtxbuf[i].buffer, + void *buf = + pipe_buffer_map(pscreen, nv10->vtxbuf[i].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } @@ -34,8 +35,8 @@ boolean nv10_draw_elements( struct pipe_context *pipe, /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +56,12 @@ boolean nv10_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv10->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv10->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv10->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c index 8f9f27ebdc..ddfcdb8057 100644 --- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c +++ b/src/gallium/drivers/nv20/nv20_prim_vbuf.c @@ -152,12 +152,11 @@ static void * nv20_vbuf_render_map_vertices( struct vbuf_render *render ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys; + struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; if (nv20_render->pbuffer) { - return winsys->buffer_map(winsys, - nv20_render->pbuffer, - PIPE_BUFFER_USAGE_CPU_WRITE); + return pipe_buffer_map(pscreen, nv20_render->pbuffer, + PIPE_BUFFER_USAGE_CPU_WRITE); } else if (nv20_render->mbuffer) { return nv20_render->mbuffer; } else @@ -173,10 +172,10 @@ nv20_vbuf_render_unmap_vertices( struct vbuf_render *render, ushort max_index ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); - struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys; + struct pipe_screen *pscreen = nv20_render->nv20->pipe.screen; if (nv20_render->pbuffer) - winsys->buffer_unmap(winsys, nv20_render->pbuffer); + pipe_buffer_unmap(pscreen, nv20_render->pbuffer); } static boolean @@ -358,7 +357,6 @@ nv20_vbuf_render_release_vertices( struct vbuf_render *render ) { struct nv20_vbuf_render *nv20_render = nv20_vbuf_render(render); struct nv20_context *nv20 = nv20_render->nv20; - struct pipe_screen *pscreen = &nv20->screen->base.base; if (nv20_render->pbuffer) { pipe_buffer_reference(&nv20_render->pbuffer, NULL); diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c index ecec4f49a0..ed4084980f 100644 --- a/src/gallium/drivers/nv20/nv20_state.c +++ b/src/gallium/drivers/nv20/nv20_state.c @@ -2,6 +2,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "tgsi/tgsi_parse.h" @@ -453,7 +454,7 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { struct nv20_context *nv20 = nv20_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); @@ -461,12 +462,12 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) + (mapped = pipe_buffer_map(pscreen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(nv20->constbuf[shader], mapped, buf->buffer->size); nv20->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float)); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(pscreen, buf->buffer); } } } diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c index 24d8f4bef0..84d7db6c5e 100644 --- a/src/gallium/drivers/nv20/nv20_vbo.c +++ b/src/gallium/drivers/nv20/nv20_vbo.c @@ -1,6 +1,7 @@ #include "draw/draw_context.h" #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv20_context.h" #include "nv20_state.h" @@ -13,6 +14,7 @@ boolean nv20_draw_elements( struct pipe_context *pipe, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { + struct pipe_screen *pscreen = pipe->screen; struct nv20_context *nv20 = nv20_context( pipe ); struct draw_context *draw = nv20->draw; unsigned i; @@ -25,17 +27,17 @@ boolean nv20_draw_elements( struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv20->vtxbuf[i].buffer) { void *buf - = pipe->winsys->buffer_map(pipe->winsys, - nv20->vtxbuf[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, + nv20->vtxbuf[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } /* Map index buffer, if present */ if (indexBuffer) { void *mapped_indexes - = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + = pipe_buffer_map(pscreen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -55,12 +57,12 @@ boolean nv20_draw_elements( struct pipe_context *pipe, */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (nv20->vtxbuf[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, nv20->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv20->vtxbuf[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); + pipe_buffer_unmap(pscreen, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); } diff --git a/src/gallium/drivers/nv20/nv20_vertprog.c b/src/gallium/drivers/nv20/nv20_vertprog.c index 5db0e807ff..c1e588902b 100644 --- a/src/gallium/drivers/nv20/nv20_vertprog.c +++ b/src/gallium/drivers/nv20/nv20_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -645,8 +646,8 @@ out_err: static boolean nv20_vertprog_validate(struct nv20_context *nv20) { + struct pipe_screen *pscreen = nv20->pipe.screen; struct nouveau_winsys *nvws = nv20->nvws; - struct pipe_winsys *ws = nv20->pipe.winsys; struct nouveau_grobj *rankine = nv20->screen->rankine; struct nv20_vertex_program *vp; struct pipe_buffer *constbuf; @@ -749,8 +750,8 @@ nv20_vertprog_validate(struct nv20_context *nv20) float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -770,9 +771,8 @@ nv20_vertprog_validate(struct nv20_context *nv20) OUT_RINGp ((uint32_t *)vpd->value, 4); } - if (constbuf) { - ws->buffer_unmap(ws, constbuf); - } + if (constbuf) + pipe_buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c index 956b450726..1d1c556fb1 100644 --- a/src/gallium/drivers/nv30/nv30_fragprog.c +++ b/src/gallium/drivers/nv30/nv30_fragprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -798,12 +799,12 @@ static void nv30_fragprog_upload(struct nv30_context *nv30, struct nv30_fragment_program *fp) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; const uint32_t le = 1; uint32_t *map; int i; - map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); #if 0 for (i = 0; i < fp->insn_len; i++) { @@ -825,7 +826,7 @@ nv30_fragprog_upload(struct nv30_context *nv30, } } - ws->buffer_unmap(ws, fp->buffer); + pipe_buffer_unmap(pscreen, fp->buffer); } static boolean @@ -834,8 +835,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) struct nv30_fragment_program *fp = nv30->fragprog; struct pipe_buffer *constbuf = nv30->constbuf[PIPE_SHADER_FRAGMENT]; - struct pipe_screen *screen = nv30->pipe.screen; - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_stateobj *so; boolean new_consts = FALSE; int i; @@ -850,7 +850,7 @@ nv30_fragprog_validate(struct nv30_context *nv30) return FALSE; } - fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4); + fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv30_fragprog_upload(nv30, fp); so = so_new(8, 1); @@ -872,7 +872,8 @@ update_constants: if (fp->nr_consts) { float *map; - map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); for (i = 0; i < fp->nr_consts; i++) { struct nv30_fragment_program_data *fpd = &fp->consts[i]; uint32_t *p = &fp->insn[fpd->offset]; @@ -883,7 +884,7 @@ update_constants: memcpy(p, cb, 4 * sizeof(float)); new_consts = TRUE; } - ws->buffer_unmap(ws, constbuf); + pipe_buffer_unmap(pscreen, constbuf); if (new_consts) nv30_fragprog_upload(nv30, fp); diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index 9b72bc3002..189656ec81 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -1,5 +1,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv30_context.h" #include "nv30_state.h" @@ -108,7 +109,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, int attrib, struct pipe_vertex_element *ve, struct pipe_vertex_buffer *vb) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_grobj *rankine = nv30->screen->rankine; unsigned type, ncomp; void *map; @@ -116,7 +117,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp)) return FALSE; - map = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); map += vb->buffer_offset + ve->src_offset; switch (type) { @@ -148,18 +149,17 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so, so_data (so, fui(v[0])); break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } } break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } - ws->buffer_unmap(ws, vb->buffer); - + pipe_buffer_unmap(pscreen, vb->buffer); return TRUE; } @@ -368,10 +368,10 @@ nv30_draw_elements_inline(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv30_context *nv30 = nv30_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; void *map; - map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ); if (!ib) { NOUVEAU_ERR("failed mapping ib\n"); return FALSE; @@ -392,7 +392,7 @@ nv30_draw_elements_inline(struct pipe_context *pipe, break; } - ws->buffer_unmap(ws, ib); + pipe_buffer_unmap(pscreen, ib); return TRUE; } diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c index aec39aae9c..c7514efcfe 100644 --- a/src/gallium/drivers/nv30/nv30_vertprog.c +++ b/src/gallium/drivers/nv30/nv30_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -645,7 +646,7 @@ out_err: static boolean nv30_vertprog_validate(struct nv30_context *nv30) { - struct pipe_winsys *ws = nv30->pipe.winsys; + struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_vertex_program *vp; struct pipe_buffer *constbuf; @@ -750,8 +751,8 @@ nv30_vertprog_validate(struct nv30_context *nv30) float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -771,9 +772,8 @@ nv30_vertprog_validate(struct nv30_context *nv30) OUT_RINGp ((uint32_t *)vpd->value, 4); } - if (constbuf) { - ws->buffer_unmap(ws, constbuf); - } + if (constbuf) + pipe_buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c index e7d8cf93a9..b2f19ecb69 100644 --- a/src/gallium/drivers/nv40/nv40_draw.c +++ b/src/gallium/drivers/nv40/nv40_draw.c @@ -1,4 +1,5 @@ #include "pipe/p_shader_tokens.h" +#include "pipe/p_inlines.h" #include "util/u_pack_color.h" @@ -231,7 +232,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; unsigned i; void *map; @@ -241,13 +242,14 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, nv40_state_emit(nv40); for (i = 0; i < nv40->vtxbuf_nr; i++) { - map = ws->buffer_map(ws, nv40->vtxbuf[i].buffer, + map = pipe_buffer_map(pscreen, nv40->vtxbuf[i].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(nv40->draw, i, map); } if (idxbuf) { - map = ws->buffer_map(ws, idxbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, idxbuf, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(nv40->draw, idxbuf_size, map); } else { draw_set_mapped_element_buffer(nv40->draw, 0, NULL); @@ -256,21 +258,22 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, if (nv40->constbuf[PIPE_SHADER_VERTEX]) { const unsigned nr = nv40->constbuf_nr[PIPE_SHADER_VERTEX]; - map = ws->buffer_map(ws, nv40->constbuf[PIPE_SHADER_VERTEX], - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, + nv40->constbuf[PIPE_SHADER_VERTEX], + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_constant_buffer(nv40->draw, map, nr); } draw_arrays(nv40->draw, mode, start, count); for (i = 0; i < nv40->vtxbuf_nr; i++) - ws->buffer_unmap(ws, nv40->vtxbuf[i].buffer); + pipe_buffer_unmap(pscreen, nv40->vtxbuf[i].buffer); if (idxbuf) - ws->buffer_unmap(ws, idxbuf); + pipe_buffer_unmap(pscreen, idxbuf); if (nv40->constbuf[PIPE_SHADER_VERTEX]) - ws->buffer_unmap(ws, nv40->constbuf[PIPE_SHADER_VERTEX]); + pipe_buffer_unmap(pscreen, nv40->constbuf[PIPE_SHADER_VERTEX]); draw_flush(nv40->draw); pipe->flush(pipe, 0, NULL); diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c index b45dfaa913..680976da56 100644 --- a/src/gallium/drivers/nv40/nv40_fragprog.c +++ b/src/gallium/drivers/nv40/nv40_fragprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -881,12 +882,12 @@ static void nv40_fragprog_upload(struct nv40_context *nv40, struct nv40_fragment_program *fp) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; const uint32_t le = 1; uint32_t *map; int i; - map = ws->buffer_map(ws, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); #if 0 for (i = 0; i < fp->insn_len; i++) { @@ -908,7 +909,7 @@ nv40_fragprog_upload(struct nv40_context *nv40, } } - ws->buffer_unmap(ws, fp->buffer); + pipe_buffer_unmap(pscreen, fp->buffer); } static boolean @@ -917,8 +918,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) struct nv40_fragment_program *fp = nv40->fragprog; struct pipe_buffer *constbuf = nv40->constbuf[PIPE_SHADER_FRAGMENT]; - struct pipe_screen *screen = nv40->pipe.screen; - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_stateobj *so; boolean new_consts = FALSE; int i; @@ -933,7 +933,7 @@ nv40_fragprog_validate(struct nv40_context *nv40) return FALSE; } - fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4); + fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4); nv40_fragprog_upload(nv40, fp); so = so_new(4, 1); @@ -951,7 +951,8 @@ update_constants: if (fp->nr_consts) { float *map; - map = ws->buffer_map(ws, constbuf, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); for (i = 0; i < fp->nr_consts; i++) { struct nv40_fragment_program_data *fpd = &fp->consts[i]; uint32_t *p = &fp->insn[fpd->offset]; @@ -962,7 +963,7 @@ update_constants: memcpy(p, cb, 4 * sizeof(float)); new_consts = TRUE; } - ws->buffer_unmap(ws, constbuf); + pipe_buffer_unmap(pscreen, constbuf); if (new_consts) nv40_fragprog_upload(nv40, fp); diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 24bd116539..b2753b8e2e 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -1,5 +1,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv40_context.h" #include "nv40_state.h" @@ -108,7 +109,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, int attrib, struct pipe_vertex_element *ve, struct pipe_vertex_buffer *vb) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_grobj *curie = nv40->screen->curie; unsigned type, ncomp; void *map; @@ -116,7 +117,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp)) return FALSE; - map = ws->buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); map += vb->buffer_offset + ve->src_offset; switch (type) { @@ -148,17 +149,17 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so, so_data (so, fui(v[0])); break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } } break; default: - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return FALSE; } - ws->buffer_unmap(ws, vb->buffer); + pipe_buffer_unmap(pscreen, vb->buffer); return TRUE; } @@ -367,10 +368,10 @@ nv40_draw_elements_inline(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { struct nv40_context *nv40 = nv40_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; void *map; - map = ws->buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ); if (!ib) { NOUVEAU_ERR("failed mapping ib\n"); return FALSE; @@ -391,7 +392,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe, break; } - ws->buffer_unmap(ws, ib); + pipe_buffer_unmap(pscreen, ib); return TRUE; } diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c index f32d4d690c..e75e8d3f42 100644 --- a/src/gallium/drivers/nv40/nv40_vertprog.c +++ b/src/gallium/drivers/nv40/nv40_vertprog.c @@ -1,6 +1,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "tgsi/tgsi_parse.h" @@ -855,7 +856,7 @@ out_err: static boolean nv40_vertprog_validate(struct nv40_context *nv40) { - struct pipe_winsys *ws = nv40->pipe.winsys; + struct pipe_screen *pscreen = nv40->pipe.screen; struct nouveau_grobj *curie = nv40->screen->curie; struct nv40_vertex_program *vp; struct pipe_buffer *constbuf; @@ -980,8 +981,8 @@ check_gpu_resources: float *map = NULL; if (constbuf) { - map = ws->buffer_map(ws, constbuf, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pscreen, constbuf, + PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { @@ -1002,7 +1003,7 @@ check_gpu_resources: } if (constbuf) - ws->buffer_unmap(ws, constbuf); + pscreen->buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 9d6427e2bc..5f7d06dbec 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -2235,7 +2235,7 @@ nv50_program_upload_data(struct nv50_context *nv50, float *map, static void nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) { - struct pipe_winsys *ws = nv50->pipe.winsys; + struct pipe_screen *pscreen = nv50->pipe.screen; if (!p->data[0] && p->immd_nr) { struct nouveau_resource *heap = nv50->screen->immd_heap[0]; @@ -2274,13 +2274,13 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) if (p->param_nr) { unsigned cbuf = NV50_CB_PVP; - float *map = ws->buffer_map(ws, nv50->constbuf[p->type], - PIPE_BUFFER_USAGE_CPU_READ); + float *map = pipe_buffer_map(pscreen, nv50->constbuf[p->type], + PIPE_BUFFER_USAGE_CPU_READ); if (p->type == PIPE_SHADER_FRAGMENT) cbuf = NV50_CB_PFP; nv50_program_upload_data(nv50, map, p->data[1]->start, p->param_nr, cbuf); - ws->buffer_unmap(ws, nv50->constbuf[p->type]); + pipe_buffer_unmap(pscreen, nv50->constbuf[p->type]); } } diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index c77ffe84e7..f57540150a 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -105,7 +105,7 @@ static boolean nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, boolean wait, uint64_t *result) { - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *pscreen = pipe->screen; struct nv50_query *q = nv50_query(pq); /*XXX: Want to be able to return FALSE here instead of blocking @@ -113,11 +113,11 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, */ if (!q->ready) { - uint32_t *map = ws->buffer_map(ws, q->buffer, - PIPE_BUFFER_USAGE_CPU_READ); + uint32_t *map = pipe_buffer_map(pscreen, q->buffer, + PIPE_BUFFER_USAGE_CPU_READ); q->result = map[1]; q->ready = TRUE; - ws->buffer_unmap(ws, q->buffer); + pipe_buffer_unmap(pscreen, q->buffer); } *result = q->result; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index a9b53a0f2e..f81929f238 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -22,6 +22,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_inlines.h" #include "nv50_context.h" @@ -165,8 +166,10 @@ nv50_draw_elements(struct pipe_context *pipe, struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct pipe_winsys *ws = pipe->winsys; - void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + struct pipe_screen *pscreen = pipe->screen; + void *map; + + map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); nv50_state_validate(nv50); @@ -193,6 +196,7 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + pipe_buffer_unmap(pscreen, indexBuffer); pipe->flush(pipe, 0, NULL); return TRUE; } diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile index 621ad2a807..54c3b26c75 100644 --- a/src/gallium/winsys/drm/nouveau/drm/Makefile +++ b/src/gallium/winsys/drm/nouveau/drm/Makefile @@ -3,8 +3,7 @@ include $(TOP)/configs/current LIBNAME = nouveaudrm -C_SOURCES = nouveau_drm_api.c \ - nouveau_winsys_pipe.c +C_SOURCES = nouveau_drm_api.c LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 22c53f6ea9..395b21ec7a 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -1,12 +1,16 @@ +#include "pipe/p_context.h" +#include "pipe/p_state.h" #include "util/u_memory.h" #include "nouveau_drm_api.h" -#include "nouveau_winsys_pipe.h" #include "nouveau_drmif.h" #include "nouveau_channel.h" #include "nouveau_bo.h" +#include "nouveau/nouveau_winsys.h" +#include "nouveau/nouveau_screen.h" + static struct pipe_surface * dri_surface_from_handle(struct pipe_screen *screen, unsigned handle, @@ -58,7 +62,7 @@ dri_surface_from_handle(struct pipe_screen *screen, static struct pipe_surface * nouveau_dri1_front_surface(struct pipe_context *pipe) { - return nouveau_screen(pipe->screen)->front; + return nouveau_winsys_screen(pipe->screen)->front; } static struct dri1_api nouveau_dri1_api = { @@ -69,6 +73,7 @@ static struct pipe_screen * nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct dri1_create_screen_arg *dri1 = (void *)arg; + struct nouveau_winsys *nvws; struct pipe_winsys *ws; struct nouveau_device *dev = NULL; struct pipe_screen *(*init)(struct pipe_winsys *, @@ -107,20 +112,20 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) return NULL; } - ws = nouveau_pipe_winsys_new(dev); - if (!ws) { + nvws = CALLOC_STRUCT(nouveau_winsys); + if (!nvws) { nouveau_device_close(&dev); return NULL; } + ws = &nvws->base; - nouveau_pipe_winsys(ws)->pscreen = init(ws, dev); - if (!nouveau_pipe_winsys(ws)->pscreen) { + nvws->pscreen = init(ws, dev); + if (!nvws->pscreen) { ws->destroy(ws); return NULL; } if (arg->mode == DRM_CREATE_DRI1) { - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); struct nouveau_dri *nvdri = dri1->ddx_info; enum pipe_format format; @@ -129,14 +134,14 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) else format = PIPE_FORMAT_A8R8G8B8_UNORM; - nvpws->front = dri_surface_from_handle(nvpws->pscreen, + nvws->front = dri_surface_from_handle(nvws->pscreen, nvdri->front_offset, format, nvdri->width, nvdri->height, nvdri->front_pitch * (nvdri->bpp / 8)); - if (!nvpws->front) { + if (!nvws->front) { debug_printf("%s: error referencing front buffer\n", __func__); ws->destroy(ws); @@ -146,15 +151,15 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) dri1->api = &nouveau_dri1_api; } - return nouveau_pipe_winsys(ws)->pscreen; + return nvws->pscreen; } static struct pipe_context * nouveau_drm_create_context(struct pipe_screen *pscreen) { - struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen); + struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen); struct pipe_context *(*init)(struct pipe_screen *, unsigned); - unsigned chipset = nvpws->channel->device->chipset; + unsigned chipset = nouveau_screen(pscreen)->device->chipset; int i; switch (chipset & 0xf0) { @@ -185,19 +190,19 @@ nouveau_drm_create_context(struct pipe_screen *pscreen) } /* Find a free slot for a pipe context, allocate a new one if needed */ - for (i = 0; i < nvpws->nr_pctx; i++) { - if (nvpws->pctx[i] == NULL) + for (i = 0; i < nvws->nr_pctx; i++) { + if (nvws->pctx[i] == NULL) break; } - if (i == nvpws->nr_pctx) { - nvpws->nr_pctx++; - nvpws->pctx = realloc(nvpws->pctx, - sizeof(*nvpws->pctx) * nvpws->nr_pctx); + if (i == nvws->nr_pctx) { + nvws->nr_pctx++; + nvws->pctx = realloc(nvws->pctx, + sizeof(*nvws->pctx) * nvws->nr_pctx); } - nvpws->pctx[i] = init(pscreen, i); - return nvpws->pctx[i]; + nvws->pctx[i] = init(pscreen, i); + return nvws->pctx[i]; } static boolean @@ -211,42 +216,41 @@ static struct pipe_buffer * nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name, unsigned handle) { - struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvpb; + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct pipe_buffer *pb; int ret; - nvpb = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvpb) + pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*)); + if (!pb) return NULL; - ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo); + ret = nouveau_bo_handle_ref(dev, handle, (struct nouveau_bo**)(pb+1)); if (ret) { debug_printf("%s: ref name 0x%08x failed with %d\n", __func__, handle, ret); - FREE(nvpb); + FREE(pb); return NULL; } - pipe_reference_init(&nvpb->base.reference, 1); - nvpb->base.screen = pscreen; - nvpb->base.alignment = 0; - nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | - PIPE_BUFFER_USAGE_CPU_READ_WRITE; - nvpb->base.size = nvpb->bo->size; - return &nvpb->base; + pipe_reference_init(&pb->reference, 1); + pb->screen = pscreen; + pb->alignment = 0; + pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | + PIPE_BUFFER_USAGE_CPU_READ_WRITE; + pb->size = nouveau_bo(pb)->size; + return pb; } static boolean nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned *handle) { - struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb); + struct nouveau_bo *bo = nouveau_bo(pb); - if (!nvpb) + if (!bo) return FALSE; - *handle = nvpb->bo->handle; + *handle = bo->handle; return TRUE; } @@ -254,12 +258,12 @@ static boolean nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned *handle) { - struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb); + struct nouveau_bo *bo = nouveau_bo(pb); - if (!nvpb) + if (!bo) return FALSE; - return nouveau_bo_handle_get(nvpb->bo, handle) == 0; + return nouveau_bo_handle_get(bo, handle) == 0; } struct drm_api drm_api_hooks = { diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h index cc237bfc13..e61e0e0957 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h @@ -1,7 +1,34 @@ #ifndef __NOUVEAU_DRM_API_H__ #define __NOUVEAU_DRM_API_H__ + #include "state_tracker/drm_api.h" #include "state_tracker/dri1_api.h" + +#include "pipe/internal/p_winsys_screen.h" + #include "nouveau_dri.h" +struct nouveau_winsys { + struct pipe_winsys base; + + struct pipe_screen *pscreen; + + unsigned nr_pctx; + struct pipe_context **pctx; + + struct pipe_surface *front; +}; + +static INLINE struct nouveau_winsys * +nouveau_winsys(struct pipe_winsys *ws) +{ + return (struct nouveau_winsys *)ws; +} + +static INLINE struct nouveau_winsys * +nouveau_winsys_screen(struct pipe_screen *pscreen) +{ + return nouveau_winsys(pscreen->winsys); +} + #endif diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c deleted file mode 100644 index 2dca8cd3a9..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c +++ /dev/null @@ -1,205 +0,0 @@ -#include "pipe/internal/p_winsys_screen.h" -#include -#include -#include - -#include "nouveau_winsys_pipe.h" - -#include "nouveau_drmif.h" -#include "nouveau_bo.h" - -static const char * -nouveau_get_name(struct pipe_winsys *pws) -{ - return "Nouveau/DRI"; -} - -static uint32_t -nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct pipe_screen *pscreen = nvpws->pscreen; - uint32_t flags = NOUVEAU_BO_LOCAL; - - if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER) - flags |= NOUVEAU_BO_GART; - - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE) - flags |= NOUVEAU_BO_GART; - if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE)) - flags |= NOUVEAU_BO_VRAM; - - switch (nvpws->channel->device->chipset & 0xf0) { - case 0x50: - case 0x80: - case 0x90: - flags |= NOUVEAU_BO_TILED; - if (usage & NOUVEAU_BUFFER_USAGE_ZETA) - flags |= NOUVEAU_BO_ZTILE; - break; - default: - break; - } - } - - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF)) - flags |= NOUVEAU_BO_GART; - } - - if (usage & PIPE_BUFFER_USAGE_INDEX) { - if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF)) - flags |= NOUVEAU_BO_GART; - } - - return flags; -} - -static struct pipe_buffer * -nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment, - unsigned usage, unsigned size) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvbuf; - uint32_t flags; - - nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvbuf) - return NULL; - pipe_reference_init(&nvbuf->base.reference, 1); - nvbuf->base.alignment = alignment; - nvbuf->base.usage = usage; - nvbuf->base.size = size; - - flags = nouveau_flags_from_usage(ws, usage); - flags |= NOUVEAU_BO_MAP; - if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) { - FREE(nvbuf); - return NULL; - } - - return &nvbuf->base; -} - -static struct pipe_buffer * -nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - struct nouveau_device *dev = nvpws->channel->device; - struct nouveau_pipe_buffer *nvbuf; - - nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); - if (!nvbuf) - return NULL; - pipe_reference_init(&nvbuf->base.reference, 1); - nvbuf->base.size = bytes; - - if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) { - FREE(nvbuf); - return NULL; - } - - return &nvbuf->base; -} - -static void -nouveau_pipe_bo_del(struct pipe_buffer *buf) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - - nouveau_bo_ref(NULL, &nvbuf->bo); - FREE(nvbuf); -} - -static void * -nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - uint32_t map_flags = 0; - - if (flags & PIPE_BUFFER_USAGE_CPU_READ) - map_flags |= NOUVEAU_BO_RD; - if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) - map_flags |= NOUVEAU_BO_WR; - - if (nouveau_bo_map(nvbuf->bo, map_flags)) - return NULL; - return nvbuf->bo->map; -} - -static void -nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); - - nouveau_bo_unmap(nvbuf->bo); -} - -static void -nouveau_pipe_fence_reference(struct pipe_winsys *ws, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *pfence) -{ - *ptr = pfence; -} - -static int -nouveau_pipe_fence_signalled(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, unsigned flag) -{ - return 0; -} - -static int -nouveau_pipe_fence_finish(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, unsigned flag) -{ - return 0; -} - -static void -nouveau_destroy(struct pipe_winsys *ws) -{ - struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws); - - nouveau_device_close(&nvpws->channel->device); - FREE(nvpws); -} - -struct pipe_winsys * -nouveau_pipe_winsys_new(struct nouveau_device *dev) -{ - struct nouveau_pipe_winsys *nvpws; - int ret; - - nvpws = CALLOC_STRUCT(nouveau_pipe_winsys); - if (!nvpws) - return NULL; - - ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202, - &nvpws->channel); - if (ret) { - debug_printf("%s: error opening GPU channel: %d\n", - __func__, ret); - FREE(nvpws); - return NULL; - } - nvpws->next_handle = 0x77000000; - - nvpws->base.buffer_create = nouveau_pipe_bo_create; - nvpws->base.buffer_destroy = nouveau_pipe_bo_del; - nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create; - nvpws->base.buffer_map = nouveau_pipe_bo_map; - nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap; - - nvpws->base.fence_reference = nouveau_pipe_fence_reference; - nvpws->base.fence_signalled = nouveau_pipe_fence_signalled; - nvpws->base.fence_finish = nouveau_pipe_fence_finish; - - nvpws->base.get_name = nouveau_get_name; - nvpws->base.destroy = nouveau_destroy; - return &nvpws->base; -} diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h deleted file mode 100644 index ec10f1e00c..0000000000 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef NOUVEAU_PIPE_WINSYS_H -#define NOUVEAU_PIPE_WINSYS_H - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_context.h" - -#include "nouveau/nouveau_winsys.h" - -#include "nouveau_device.h" - -struct nouveau_pipe_buffer { - struct pipe_buffer base; - struct nouveau_bo *bo; -}; - -static INLINE struct nouveau_pipe_buffer * -nouveau_pipe_buffer(struct pipe_buffer *buf) -{ - return (struct nouveau_pipe_buffer *)buf; -} - -struct nouveau_pipe_winsys { - struct pipe_winsys base; - - struct pipe_screen *pscreen; - - struct nouveau_channel *channel; - uint32_t next_handle; - - unsigned nr_pctx; - struct pipe_context **pctx; - - struct pipe_surface *front; -}; - -static INLINE struct nouveau_pipe_winsys * -nouveau_pipe_winsys(struct pipe_winsys *ws) -{ - return (struct nouveau_pipe_winsys *)ws; -} - -static INLINE struct nouveau_pipe_winsys * -nouveau_screen(struct pipe_screen *pscreen) -{ - return nouveau_pipe_winsys(pscreen->winsys); -} - -struct pipe_winsys * -nouveau_pipe_winsys_new(struct nouveau_device *); - -struct nouveau_winsys * -nouveau_winsys_new(struct pipe_winsys *ws); - -#endif -- cgit v1.2.3