nv40: remove u_simple_screen usage
authorBen Skeggs <bskeggs@redhat.com>
Thu, 4 Jun 2009 11:30:41 +0000 (21:30 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 5 Jun 2009 04:37:01 +0000 (14:37 +1000)
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv40/nv40_screen.h
src/gallium/drivers/nv40/nv40_surface.c
src/gallium/drivers/nv40/nv40_vbo.c

index 393b31c5f070f9d756ddea282a8fdd0ccbe5bf13..97bc83292d4dd0edf3217bbf4af7a8e38701d3b6 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "nv40_state.h"
 
-#define nouveau_bo(pb) nv40->screen->nvws->get_bo(pb)
-
 #define NOUVEAU_ERR(fmt, args...) \
        fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
 #define NOUVEAU_MSG(fmt, args...) \
index 5030c3ecbc841222c81e6ba586fce8f09891f084..3049bd80317a52f3dd59f749f0aa9bacd0abbc97 100644 (file)
@@ -1,5 +1,4 @@
 #include "pipe/p_screen.h"
-#include "util/u_simple_screen.h"
 
 #include "nv40_context.h"
 #include "nv40_screen.h"
@@ -8,23 +7,6 @@
 #define NV4X_GRCLASS4497_CHIPSETS 0x00005450
 #define NV6X_GRCLASS4497_CHIPSETS 0x00000088
 
-static const char *
-nv40_screen_get_name(struct pipe_screen *pscreen)
-{
-       struct nv40_screen *screen = nv40_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 *
-nv40_screen_get_vendor(struct pipe_screen *pscreen)
-{
-       return "nouveau";
-}
-
 static int
 nv40_screen_get_param(struct pipe_screen *pscreen, int param)
 {
@@ -157,6 +139,8 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
        nvws->notifier_free(&screen->sync);
        nvws->grobj_free(&screen->curie);
 
+       nouveau_screen_fini(&screen->base);
+
        FREE(pscreen);
 }
 
@@ -164,36 +148,49 @@ struct pipe_screen *
 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 pipe_screen *pscreen;
        struct nouveau_stateobj *so;
        unsigned curie_class = 0;
-       unsigned chipset = nvws->channel->device->chipset;
        int ret;
 
        if (!screen)
                return NULL;
+       pscreen = &screen->base.base;
+
        screen->nvws = nvws;
 
+       pscreen->winsys = ws;
+       pscreen->destroy = nv40_screen_destroy;
+       pscreen->get_param = nv40_screen_get_param;
+       pscreen->get_paramf = nv40_screen_get_paramf;
+       pscreen->is_format_supported = nv40_screen_surface_format_supported;
+
+       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 (chipset & 0xf0) {
+       switch (dev->chipset & 0xf0) {
        case 0x40:
-               if (NV4X_GRCLASS4097_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV40TCL;
                else
-               if (NV4X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV44TCL;
                break;
        case 0x60:
-               if (NV6X_GRCLASS4497_CHIPSETS & (1 << (chipset & 0x0f)))
+               if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
                        curie_class = NV44TCL;
                break;
        }
 
        if (!curie_class) {
-               NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", chipset);
+               NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", dev->chipset);
                return NULL;
        }
 
@@ -207,7 +204,7 @@ nv40_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);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
@@ -215,21 +212,21 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        ret = nvws->notifier_alloc(nvws, 32, &screen->query);
        if (ret) {
                NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
        ret = nvws->res_init(&screen->query_heap, 0, 32);
        if (ret) {
                NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
        /* Vtxprog resources */
        if (nvws->res_init(&screen->vp_exec_heap, 0, 512) ||
            nvws->res_init(&screen->vp_data_heap, 0, 256)) {
-               nv40_screen_destroy(&screen->pipe);
+               nv40_screen_destroy(pscreen);
                return NULL;
        }
 
@@ -285,20 +282,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
        so_ref(NULL, &so);
        nouveau_pushbuf_flush(nvws->channel, 0);
 
-       screen->pipe.winsys = ws;
-       screen->pipe.destroy = nv40_screen_destroy;
-
-       screen->pipe.get_name = nv40_screen_get_name;
-       screen->pipe.get_vendor = nv40_screen_get_vendor;
-       screen->pipe.get_param = nv40_screen_get_param;
-       screen->pipe.get_paramf = nv40_screen_get_paramf;
-
-       screen->pipe.is_format_supported = nv40_screen_surface_format_supported;
-
-       nv40_screen_init_miptree_functions(&screen->pipe);
-       nv40_screen_init_transfer_functions(&screen->pipe);
-       u_simple_screen_init(&screen->pipe);
-
-       return &screen->pipe;
+       return pscreen;
 }
 
index 7b503bd207dfda69c7793bbccec3f87396c06986..57b4c8fc46cda9ca7f1be5cd8c798e9efeb2acff 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __NV40_SCREEN_H__
 #define __NV40_SCREEN_H__
 
-#include "pipe/p_screen.h"
+#include "nouveau/nouveau_screen.h"
 #include "nv04/nv04_surface_2d.h"
 
 struct nv40_screen {
-       struct pipe_screen pipe;
+       struct nouveau_screen base;
 
        struct nouveau_winsys *nvws;
 
index 1a849da32d71aadd3737c5b46edc35ca0a799bcb..a596547974ab27a21fb1c278f54cae45d99bee51 100644 (file)
  * 
  **************************************************************************/
 
-#include "nv40_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_inlines.h"
+
 #include "util/u_tile.h"
 
+#include "nv40_context.h"
+
 static void
 nv40_surface_copy(struct pipe_context *pipe,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
index 7add803df7f8aeeac06f9ecd0b4209b7f5ab78f3..4abddba1104fdd962cdb64b91b6cda1fb3ba01a9 100644 (file)
@@ -70,7 +70,7 @@ static boolean
 nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
                    unsigned ib_size)
 {
-       struct pipe_screen *pscreen = &nv40->screen->pipe;
+       struct pipe_screen *pscreen = &nv40->screen->base.base;
        unsigned type;
 
        if (!ib) {