summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv50
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2009-06-04 10:19:04 +1000
committerBen Skeggs <bskeggs@redhat.com>2009-06-05 14:37:01 +1000
commitbc466be695913cd504cefddd857ac1cefda87a04 (patch)
treeffdf780ad66bd774d80205478131fc60eed13c05 /src/gallium/drivers/nv50
parent072fdc1fd325256d87b182d4f55c8a5838119cf0 (diff)
nouveau: add pipe_buffer/fence code to pipe drivers, move nv50 over
Diffstat (limited to 'src/gallium/drivers/nv50')
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h2
-rw-r--r--src/gallium/drivers/nv50/nv50_query.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c83
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.h4
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c6
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c4
6 files changed, 41 insertions, 60 deletions
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index d960657066..7b67a75439 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -23,8 +23,6 @@
#define NOUVEAU_MSG(fmt, args...) \
fprintf(stderr, "nouveau: "fmt, ##args);
-#define nouveau_bo(pb) nv50->screen->nvws->get_bo(pb)
-
/* Constant buffer assignment */
#define NV50_CB_PMISC 0
#define NV50_CB_PVP 1
diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 35cebdbdc3..4d05eeac2c 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -90,7 +90,7 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq)
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nv50_query *q = nv50_query(pq);
- struct nouveau_bo *bo = nv50->screen->nvws->get_bo(q->buffer);
+ struct nouveau_bo *bo = nouveau_bo(q->buffer);
WAIT_RING (chan, 5);
BEGIN_RING(chan, tesla, 0x1b00, 4);
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index b7e9df77db..3b830847ca 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -22,8 +22,6 @@
#include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
-
#include "nv50_context.h"
#include "nv50_screen.h"
@@ -68,23 +66,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
return FALSE;
}
-static const char *
-nv50_screen_get_name(struct pipe_screen *pscreen)
-{
- struct nv50_screen *screen = nv50_screen(pscreen);
- struct nouveau_device *dev = screen->nvws->channel->device;
- static char buffer[128];
-
- snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset);
- return buffer;
-}
-
-static const char *
-nv50_screen_get_vendor(struct pipe_screen *pscreen)
-{
- return "nouveau";
-}
-
static int
nv50_screen_get_param(struct pipe_screen *pscreen, int param)
{
@@ -153,7 +134,10 @@ nv50_screen_get_paramf(struct pipe_screen *pscreen, int param)
static void
nv50_screen_destroy(struct pipe_screen *pscreen)
{
- FREE(pscreen);
+ struct nv50_screen *screen = nv50_screen(pscreen);
+
+ nouveau_screen_fini(&screen->base);
+ FREE(screen);
}
struct pipe_screen *
@@ -161,6 +145,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 pipe_screen *pscreen;
struct nouveau_stateobj *so;
unsigned chipset = dev->chipset;
unsigned tesla_class = 0;
@@ -168,13 +153,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
if (!screen)
return NULL;
+ pscreen = &screen->base.base;
+
+ ret = nouveau_screen_init(&screen->base, nvws->channel->device);
+ if (ret) {
+ nv50_screen_destroy(pscreen);
+ return NULL;
+ }
+
+ /* Setup the pipe */
screen->nvws = nvws;
+ pscreen->winsys = ws;
+ pscreen->destroy = nv50_screen_destroy;
+ pscreen->get_param = nv50_screen_get_param;
+ pscreen->get_paramf = nv50_screen_get_paramf;
+ pscreen->is_format_supported = nv50_screen_is_format_supported;
+
+ nv50_screen_init_miptree_functions(pscreen);
+ nv50_transfer_init_screen_functions(pscreen);
+
/* DMA engine object */
ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf);
if (ret) {
NOUVEAU_ERR("Error creating M2MF object: %d\n", ret);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -182,7 +185,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d);
if (ret) {
NOUVEAU_ERR("Error creating 2D object: %d\n", ret);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -200,20 +203,20 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
break;
default:
NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
if (tesla_class == 0) {
NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla);
if (ret) {
NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -221,26 +224,10 @@ nv50_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);
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
- /* Setup the pipe */
- screen->pipe.winsys = ws;
-
- screen->pipe.destroy = nv50_screen_destroy;
-
- screen->pipe.get_name = nv50_screen_get_name;
- screen->pipe.get_vendor = nv50_screen_get_vendor;
- screen->pipe.get_param = nv50_screen_get_param;
- screen->pipe.get_paramf = nv50_screen_get_paramf;
-
- screen->pipe.is_format_supported = nv50_screen_is_format_supported;
-
- nv50_screen_init_miptree_functions(&screen->pipe);
- nv50_transfer_init_screen_functions(&screen->pipe);
- u_simple_screen_init(&screen->pipe);
-
/* Static M2MF init */
so = so_new(32, 0);
so_method(so, screen->m2mf, 0x0180, 3);
@@ -295,7 +282,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
&screen->constbuf_misc[0]);
if (ret) {
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -303,7 +290,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4,
&screen->constbuf_parm[i]);
if (ret) {
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
}
@@ -313,7 +300,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
nvws->res_init(&screen->parm_heap[1], 0, 128))
{
NOUVEAU_ERR("Error initialising constant buffers.\n");
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -362,7 +349,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
*/
ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic);
if (ret) {
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -381,7 +368,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc);
if (ret) {
- nv50_screen_destroy(&screen->pipe);
+ nv50_screen_destroy(pscreen);
return NULL;
}
@@ -420,6 +407,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
so_ref (NULL, &so);
nouveau_pushbuf_flush(nvws->channel, 0);
- return &screen->pipe;
+ return pscreen;
}
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
index fa7d8d0f0d..61e24a5b57 100644
--- a/src/gallium/drivers/nv50/nv50_screen.h
+++ b/src/gallium/drivers/nv50/nv50_screen.h
@@ -1,10 +1,10 @@
#ifndef __NV50_SCREEN_H__
#define __NV50_SCREEN_H__
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
struct nv50_screen {
- struct pipe_screen pipe;
+ struct nouveau_screen base;
struct nouveau_winsys *nvws;
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index c0f0efe158..121eddfc83 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -54,14 +54,10 @@ 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_grobj *eng2d = screen->eng2d;
- struct nouveau_bo *bo;
+ struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer);
int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT;
int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD);
- bo = screen->nvws->get_bo(nv50_miptree(ps->texture)->buffer);
- if (!bo)
- return 1;
-
format = nv50_format(ps->format);
if (format < 0)
return 1;
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index 28e7edd144..5f1e430ad1 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -27,8 +27,8 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src,
struct nouveau_winsys *nvws = screen->nvws;
struct nouveau_channel *chan = nvws->channel;
struct nouveau_grobj *m2mf = screen->m2mf;
- struct nouveau_bo *src_bo = nvws->get_bo(src);
- struct nouveau_bo *dst_bo = nvws->get_bo(dst);
+ struct nouveau_bo *src_bo = nouveau_bo(src);
+ struct nouveau_bo *dst_bo = nouveau_bo(dst);
src_reloc |= NOUVEAU_BO_RD;
dst_reloc |= NOUVEAU_BO_WR;