nouveau: implement pipe_screen
authorBen Skeggs <skeggsb@gmail.com>
Fri, 29 Feb 2008 04:03:57 +0000 (15:03 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 29 Feb 2008 04:03:57 +0000 (15:03 +1100)
Untested on NV3x/NV5x.  Quite possibly broken.

24 files changed:
src/gallium/drivers/nouveau/nouveau_winsys.h
src/gallium/drivers/nv30/Makefile
src/gallium/drivers/nv30/nv30_context.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_screen.c [new file with mode: 0644]
src/gallium/drivers/nv30/nv30_screen.h [new file with mode: 0644]
src/gallium/drivers/nv30/nv30_surface.c
src/gallium/drivers/nv40/Makefile
src/gallium/drivers/nv40/nv40_context.c
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_miptree.c
src/gallium/drivers/nv40/nv40_screen.c [new file with mode: 0644]
src/gallium/drivers/nv40/nv40_screen.h [new file with mode: 0644]
src/gallium/drivers/nv40/nv40_surface.c
src/gallium/drivers/nv50/Makefile
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_screen.c [new file with mode: 0644]
src/gallium/drivers/nv50/nv50_screen.h [new file with mode: 0644]
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/winsys/dri/nouveau/nouveau_winsys.c
src/gallium/winsys/dri/nouveau/nouveau_winsys_softpipe.c

index b5e470cfaa41dbca2d9f90b39421a0047eb3b94c..98d95e94a58d6809a815fb032522316f58dd7f7a 100644 (file)
@@ -49,13 +49,22 @@ struct nouveau_winsys {
                            unsigned, unsigned, unsigned, unsigned, unsigned);
 };
 
+extern struct pipe_screen *
+nv30_screen_create(struct pipe_winsys *ws, unsigned chipset);
+
 extern struct pipe_context *
-nv30_create(struct pipe_winsys *, struct nouveau_winsys *, unsigned chipset);
+nv30_create(struct pipe_screen *, struct nouveau_winsys *);
+
+extern struct pipe_screen *
+nv40_screen_create(struct pipe_winsys *ws, unsigned chipset);
 
 extern struct pipe_context *
-nv40_create(struct pipe_winsys *, struct nouveau_winsys *, unsigned chipset);
+nv40_create(struct pipe_screen *, struct nouveau_winsys *);
+
+extern struct pipe_screen *
+nv50_screen_create(struct pipe_winsys *ws, unsigned chipset);
 
 extern struct pipe_context *
-nv50_create(struct pipe_winsys *, struct nouveau_winsys *, unsigned chipset);
+nv50_create(struct pipe_screen *, struct nouveau_winsys *);
 
 #endif
index b7c252fc986a98b3b6d4e1fef76ce8acc037fb5c..3f80fb87c9b422b3ba11cf525ea0eaa5366b1e7b 100644 (file)
@@ -11,6 +11,7 @@ DRIVER_SOURCES = \
        nv30_fragtex.c \
        nv30_miptree.c \
        nv30_query.c \
+       nv30_screen.c \
        nv30_state.c \
        nv30_state_emit.c \
        nv30_surface.c \
index e9afeb8017658a73acf43c2fdacee868e507570f..b8452e23b1608d90462599dc1e37ca5d83b24c1f 100644 (file)
@@ -4,80 +4,7 @@
 #include "pipe/p_util.h"
 
 #include "nv30_context.h"
-
-static const char *
-nv30_get_name(struct pipe_context *pipe)
-{
-       struct nv30_context *nv30 = nv30_context(pipe);
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", nv30->chipset);
-       return buffer;
-}
-
-static const char *
-nv30_get_vendor(struct pipe_context *pipe)
-{
-       return "nouveau";
-}
-
-static int
-nv30_get_param(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-               return 16;
-       case PIPE_CAP_NPOT_TEXTURES:
-               return 0;
-       case PIPE_CAP_TWO_SIDED_STENCIL:
-               return 1;
-       case PIPE_CAP_GLSL:
-               return 0;
-       case PIPE_CAP_S3TC:
-               return 0;
-       case PIPE_CAP_ANISOTROPIC_FILTER:
-               return 1;
-       case PIPE_CAP_POINT_SPRITE:
-               return 1;
-       case PIPE_CAP_MAX_RENDER_TARGETS:
-               return 2;
-       case PIPE_CAP_OCCLUSION_QUERY:
-               return 1;
-       case PIPE_CAP_TEXTURE_SHADOW_MAP:
-               return 1;
-       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
-               return 13;
-       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
-               return 10;
-       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
-               return 13;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0;
-       }
-}
-
-static float
-nv30_get_paramf(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_LINE_WIDTH:
-       case PIPE_CAP_MAX_LINE_WIDTH_AA:
-               return 10.0;
-       case PIPE_CAP_MAX_POINT_WIDTH:
-       case PIPE_CAP_MAX_POINT_WIDTH_AA:
-               return 64.0;
-       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
-               return 16.0;
-       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
-               return 4.0;
-       case PIPE_CAP_BITMAP_TEXCOORD_BIAS:
-               return 0.0;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0.0;
-       }
-}
+#include "nv30_screen.h"
 
 static void
 nv30_flush(struct pipe_context *pipe, unsigned flags)
@@ -338,9 +265,10 @@ nv30_init_hwctx(struct nv30_context *nv30, int rankine_class)
 #define NV35TCL_CHIPSET_3X_MASK 0x000001e0
 
 struct pipe_context *
-nv30_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
-           unsigned chipset)
+nv30_create(struct pipe_screen *screen, struct nouveau_winsys *nvws)
 {
+       struct pipe_winsys *pipe_winsys = screen->winsys;
+       unsigned chipset = nv30_screen(screen)->chipset;
        struct nv30_context *nv30;
        int rankine_class = 0, ret;
 
@@ -404,12 +332,9 @@ nv30_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
 
        /* Pipe context setup */
        nv30->pipe.winsys = pipe_winsys;
+       nv30->pipe.screen = screen;
 
        nv30->pipe.destroy = nv30_destroy;
-       nv30->pipe.get_name = nv30_get_name;
-       nv30->pipe.get_vendor = nv30_get_vendor;
-       nv30->pipe.get_param = nv30_get_param;
-       nv30->pipe.get_paramf = nv30_get_paramf;
 
        nv30->pipe.draw_arrays = nv30_draw_arrays;
        nv30->pipe.draw_elements = nv30_draw_elements;
@@ -420,7 +345,6 @@ nv30_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
        nv30_init_query_functions(nv30);
        nv30_init_surface_functions(nv30);
        nv30_init_state_functions(nv30);
-       nv30_init_miptree_functions(nv30);
 
        nv30->draw = draw_create();
        assert(nv30->draw);
index d6d16ee86869c88d9de0f48811fbdd75198e0c4d..c63847a087ce5de0ed047af0dd4bda30ce485972 100644 (file)
@@ -91,7 +91,7 @@ nv30_context(struct pipe_context *pipe)
 
 extern void nv30_init_state_functions(struct nv30_context *nv30);
 extern void nv30_init_surface_functions(struct nv30_context *nv30);
-extern void nv30_init_miptree_functions(struct nv30_context *nv30);
+extern void nv30_init_miptree_functions(struct pipe_screen *screen);
 extern void nv30_init_query_functions(struct nv30_context *nv30);
 
 /* nv30_draw.c */
index 5fb89f4cfdc0986838d1b79b66f322103e103dcf..23bcef08ebce391cee3a85152beb77865d2952dc 100644 (file)
@@ -4,6 +4,7 @@
 #include "pipe/p_inlines.h"
 
 #include "nv30_context.h"
+#include "nv30_screen.h"
 
 static void
 nv30_miptree_layout(struct nv30_miptree *nv30mt)
@@ -54,9 +55,9 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
 }
 
 static void
-nv30_miptree_create(struct pipe_context *pipe, struct pipe_texture **pt)
+nv30_miptree_create(struct pipe_screen *screen, struct pipe_texture **pt)
 {
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_winsys *ws = screen->winsys;
        struct nv30_miptree *nv30mt;
 
        nv30mt = realloc(*pt, sizeof(struct nv30_miptree));
@@ -77,9 +78,9 @@ nv30_miptree_create(struct pipe_context *pipe, struct pipe_texture **pt)
 }
 
 static void
-nv30_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
+nv30_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
 {
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_winsys *ws = screen->winsys;
        struct pipe_texture *mt = *pt;
 
        *pt = NULL;
@@ -96,10 +97,42 @@ nv30_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
        }
 }
 
+static struct pipe_surface *
+nv30_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
+                        unsigned face, unsigned level, unsigned zslice)
+{
+       struct pipe_winsys *ws = screen->winsys;
+       struct nv30_miptree *nv30mt = (struct nv30_miptree *)pt;
+       struct pipe_surface *ps;
+
+       ps = ws->surface_alloc(ws);
+       if (!ps)
+               return NULL;
+       pipe_buffer_reference(ws, &ps->buffer, nv30mt->buffer);
+       ps->format = pt->format;
+       ps->cpp = pt->cpp;
+       ps->width = pt->width[level];
+       ps->height = pt->height[level];
+       ps->pitch = nv30mt->level[level].pitch / ps->cpp;
+
+       if (pt->target == PIPE_TEXTURE_CUBE) {
+               ps->offset = nv30mt->level[level].image_offset[face];
+       } else
+       if (pt->target == PIPE_TEXTURE_3D) {
+               ps->offset = nv30mt->level[level].image_offset[zslice];
+       } else {
+               ps->offset = nv30mt->level[level].image_offset[0];
+       }
+
+       return ps;
+}
 void
-nv30_init_miptree_functions(struct nv30_context *nv30)
+nv30_init_miptree_functions(struct pipe_screen *screen)
 {
-       nv30->pipe.texture_create = nv30_miptree_create;
-       nv30->pipe.texture_release = nv30_miptree_release;
+       struct nv30_screen *nv30screen = nv30_screen(screen);
+
+       nv30screen->screen.texture_create = nv30_miptree_create;
+       nv30screen->screen.texture_release = nv30_miptree_release;
+       nv30screen->screen.get_tex_surface = nv30_miptree_surface_get;
 }
 
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
new file mode 100644 (file)
index 0000000..6d64025
--- /dev/null
@@ -0,0 +1,151 @@
+#include "pipe/p_screen.h"
+#include "pipe/p_util.h"
+
+#include "nv30_context.h"
+#include "nv30_screen.h"
+
+static const char *
+nv30_screen_get_name(struct pipe_screen *screen)
+{
+       struct nv30_screen *nv30screen = nv30_screen(screen);
+       static char buffer[128];
+
+       snprintf(buffer, sizeof(buffer), "NV%02X", nv30screen->chipset);
+       return buffer;
+}
+
+static const char *
+nv30_screen_get_vendor(struct pipe_screen *screen)
+{
+       return "nouveau";
+}
+
+static int
+nv30_screen_get_param(struct pipe_screen *screen, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+               return 16;
+       case PIPE_CAP_NPOT_TEXTURES:
+               return 0;
+       case PIPE_CAP_TWO_SIDED_STENCIL:
+               return 1;
+       case PIPE_CAP_GLSL:
+               return 0;
+       case PIPE_CAP_S3TC:
+               return 0;
+       case PIPE_CAP_ANISOTROPIC_FILTER:
+               return 1;
+       case PIPE_CAP_POINT_SPRITE:
+               return 1;
+       case PIPE_CAP_MAX_RENDER_TARGETS:
+               return 2;
+       case PIPE_CAP_OCCLUSION_QUERY:
+               return 1;
+       case PIPE_CAP_TEXTURE_SHADOW_MAP:
+               return 1;
+       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+               return 13;
+       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+               return 10;
+       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+               return 13;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0;
+       }
+}
+
+static float
+nv30_screen_get_paramf(struct pipe_screen *screen, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_LINE_WIDTH:
+       case PIPE_CAP_MAX_LINE_WIDTH_AA:
+               return 10.0;
+       case PIPE_CAP_MAX_POINT_WIDTH:
+       case PIPE_CAP_MAX_POINT_WIDTH_AA:
+               return 64.0;
+       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+               return 16.0;
+       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+               return 4.0;
+       case PIPE_CAP_BITMAP_TEXCOORD_BIAS:
+               return 0.0;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0.0;
+       }
+}
+
+static boolean
+nv30_screen_is_format_supported(struct pipe_screen *screen,
+                               enum pipe_format format, uint type)
+{
+       switch (type) {
+       case PIPE_SURFACE:
+               switch (format) {
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
+               case PIPE_FORMAT_R5G6B5_UNORM: 
+               case PIPE_FORMAT_Z24S8_UNORM:
+               case PIPE_FORMAT_Z16_UNORM:
+                       return TRUE;
+               default:
+                       break;
+               }
+               break;
+       case PIPE_TEXTURE:
+               switch (format) {
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
+               case PIPE_FORMAT_A1R5G5B5_UNORM:
+               case PIPE_FORMAT_A4R4G4B4_UNORM:
+               case PIPE_FORMAT_R5G6B5_UNORM: 
+               case PIPE_FORMAT_U_L8:
+               case PIPE_FORMAT_U_A8:
+               case PIPE_FORMAT_U_I8:
+               case PIPE_FORMAT_U_A8_L8:
+               case PIPE_FORMAT_Z16_UNORM:
+               case PIPE_FORMAT_Z24S8_UNORM:
+                       return TRUE;
+               default:
+                       break;
+               }
+               break;
+       default:
+               assert(0);
+       };
+
+       return FALSE;
+}
+
+static void
+nv30_screen_destroy(struct pipe_screen *screen)
+{
+       FREE(screen);
+}
+
+struct pipe_screen *
+nv30_screen_create(struct pipe_winsys *winsys, unsigned chipset)
+{
+       struct nv30_screen *nv30screen = CALLOC_STRUCT(nv30_screen);
+
+       if (!nv30screen)
+               return NULL;
+
+       nv30screen->chipset = chipset;
+
+       nv30screen->screen.winsys = winsys;
+
+       nv30screen->screen.destroy = nv30_screen_destroy;
+
+       nv30screen->screen.get_name = nv30_screen_get_name;
+       nv30screen->screen.get_vendor = nv30_screen_get_vendor;
+       nv30screen->screen.get_param = nv30_screen_get_param;
+       nv30screen->screen.get_paramf = nv30_screen_get_paramf;
+       nv30screen->screen.is_format_supported = 
+               nv30_screen_is_format_supported;
+
+       nv30_init_miptree_functions(&nv30screen->screen);
+       return &nv30screen->screen;
+}
+
diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
new file mode 100644 (file)
index 0000000..e55242f
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __NV30_SCREEN_H__
+#define __NV30_SCREEN_H__
+
+#include "pipe/p_screen.h"
+
+struct nv30_screen {
+       struct pipe_screen screen;
+       unsigned chipset;
+};
+
+static INLINE struct nv30_screen *
+nv30_screen(struct pipe_screen *screen)
+{
+       return (struct nv30_screen *)screen;
+}
+
+extern struct pipe_screen *
+nv30_screen_create(struct pipe_winsys *winsys, unsigned chipset);
+
+#endif
index 974965679f5100ab9acb49f7a008aae461a10082..b20a3dd4c15ddd62cd8f2c6ab07f568fe4bdd9f3 100644 (file)
 #include "pipe/p_inlines.h"
 #include "util/p_tile.h"
 
-static boolean
-nv30_surface_format_supported(struct pipe_context *pipe,
-                             enum pipe_format format, uint type)
-{
-       switch (type) {
-       case PIPE_SURFACE:
-               switch (format) {
-               case PIPE_FORMAT_A8R8G8B8_UNORM:
-               case PIPE_FORMAT_R5G6B5_UNORM: 
-               case PIPE_FORMAT_Z24S8_UNORM:
-               case PIPE_FORMAT_Z16_UNORM:
-                       return TRUE;
-               default:
-                       break;
-               }
-               break;
-       case PIPE_TEXTURE:
-               switch (format) {
-               case PIPE_FORMAT_A8R8G8B8_UNORM:
-               case PIPE_FORMAT_A1R5G5B5_UNORM:
-               case PIPE_FORMAT_A4R4G4B4_UNORM:
-               case PIPE_FORMAT_R5G6B5_UNORM: 
-               case PIPE_FORMAT_U_L8:
-               case PIPE_FORMAT_U_A8:
-               case PIPE_FORMAT_U_I8:
-               case PIPE_FORMAT_U_A8_L8:
-               case PIPE_FORMAT_Z16_UNORM:
-               case PIPE_FORMAT_Z24S8_UNORM:
-                       return TRUE;
-               default:
-                       break;
-               }
-               break;
-       default:
-               assert(0);
-       };
-
-       return FALSE;
-}
-
-static struct pipe_surface *
-nv30_get_tex_surface(struct pipe_context *pipe, struct pipe_texture *pt,
-                     unsigned face, unsigned level, unsigned zslice)
-{
-       struct pipe_winsys *ws = pipe->winsys;
-       struct nv30_miptree *nv30mt = (struct nv30_miptree *)pt;
-       struct pipe_surface *ps;
-
-       ps = ws->surface_alloc(ws);
-       if (!ps)
-               return NULL;
-       pipe_buffer_reference(ws, &ps->buffer, nv30mt->buffer);
-       ps->format = pt->format;
-       ps->cpp = pt->cpp;
-       ps->width = pt->width[level];
-       ps->height = pt->height[level];
-       ps->pitch = nv30mt->level[level].pitch / ps->cpp;
-
-       if (pt->target == PIPE_TEXTURE_CUBE) {
-               ps->offset = nv30mt->level[level].image_offset[face];
-       } else
-       if (pt->target == PIPE_TEXTURE_3D) {
-               ps->offset = nv30mt->level[level].image_offset[zslice];
-       } else {
-               ps->offset = nv30mt->level[level].image_offset[0];
-       }
-
-       return ps;
-}
-
 static void
 nv30_surface_copy(struct pipe_context *pipe, unsigned do_flip,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
@@ -130,8 +60,6 @@ nv30_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
 void
 nv30_init_surface_functions(struct nv30_context *nv30)
 {
-       nv30->pipe.is_format_supported = nv30_surface_format_supported;
-       nv30->pipe.get_tex_surface = nv30_get_tex_surface;
        nv30->pipe.surface_copy = nv30_surface_copy;
        nv30->pipe.surface_fill = nv30_surface_fill;
 }
index fd002b54e78e17f2a437b09a808a2c945b88540f..3369a21574fd322c5e0685e47cfdf4750ed6dbe3 100644 (file)
@@ -11,6 +11,7 @@ DRIVER_SOURCES = \
        nv40_fragtex.c \
        nv40_miptree.c \
        nv40_query.c \
+       nv40_screen.c \
        nv40_state.c \
        nv40_state_blend.c \
        nv40_state_clip.c \
index 8b5cc693de0128950dc96ffae63664ca3666052b..a7f64c6e9e5708a6416c5cc64b5f4e61faf1fc67 100644 (file)
@@ -4,85 +4,12 @@
 #include "pipe/p_util.h"
 
 #include "nv40_context.h"
+#include "nv40_screen.h"
 
 #define NV4X_GRCLASS4097_CHIPSETS 0x00000baf
 #define NV4X_GRCLASS4497_CHIPSETS 0x00005450
 #define NV6X_GRCLASS4497_CHIPSETS 0x00000088
 
-static const char *
-nv40_get_name(struct pipe_context *pipe)
-{
-       struct nv40_context *nv40 = nv40_context(pipe);
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", nv40->chipset);
-       return buffer;
-}
-
-static const char *
-nv40_get_vendor(struct pipe_context *pipe)
-{
-       return "nouveau";
-}
-
-static int
-nv40_get_param(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-               return 16;
-       case PIPE_CAP_NPOT_TEXTURES:
-               return 1;
-       case PIPE_CAP_TWO_SIDED_STENCIL:
-               return 1;
-       case PIPE_CAP_GLSL:
-               return 0;
-       case PIPE_CAP_S3TC:
-               return 0;
-       case PIPE_CAP_ANISOTROPIC_FILTER:
-               return 1;
-       case PIPE_CAP_POINT_SPRITE:
-               return 1;
-       case PIPE_CAP_MAX_RENDER_TARGETS:
-               return 4;
-       case PIPE_CAP_OCCLUSION_QUERY:
-               return 1;
-       case PIPE_CAP_TEXTURE_SHADOW_MAP:
-               return 1;
-       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
-               return 13;
-       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
-               return 10;
-       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
-               return 13;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0;
-       }
-}
-
-static float
-nv40_get_paramf(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_LINE_WIDTH:
-       case PIPE_CAP_MAX_LINE_WIDTH_AA:
-               return 10.0;
-       case PIPE_CAP_MAX_POINT_WIDTH:
-       case PIPE_CAP_MAX_POINT_WIDTH_AA:
-               return 64.0;
-       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
-               return 16.0;
-       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
-               return 16.0;
-       case PIPE_CAP_BITMAP_TEXCOORD_BIAS:
-               return 0.0;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0.0;
-       }
-}
-
 static void
 nv40_flush(struct pipe_context *pipe, unsigned flags)
 {
@@ -269,10 +196,11 @@ nv40_destroy(struct pipe_context *pipe)
 }
 
 struct pipe_context *
-nv40_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
-           unsigned chipset)
+nv40_create(struct pipe_screen *pscreen, struct nouveau_winsys *nvws)
 {
+       struct pipe_winsys *ws = pscreen->winsys;
        struct nv40_context *nv40;
+       unsigned chipset = nv40_screen(pscreen)->chipset;
 
        nv40 = CALLOC(1, sizeof(struct nv40_context));
        if (!nv40)
@@ -288,11 +216,8 @@ nv40_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws,
        nv40->nvws = nvws;
 
        nv40->pipe.winsys = ws;
+       nv40->pipe.screen = pscreen;
        nv40->pipe.destroy = nv40_destroy;
-       nv40->pipe.get_name = nv40_get_name;
-       nv40->pipe.get_vendor = nv40_get_vendor;
-       nv40->pipe.get_param = nv40_get_param;
-       nv40->pipe.get_paramf = nv40_get_paramf;
        nv40->pipe.draw_arrays = nv40_draw_arrays;
        nv40->pipe.draw_elements = nv40_draw_elements;
        nv40->pipe.clear = nv40_clear;
index 16cc053ad9ff9395192a51f59d6a8c73c8ea21ea..3ddfbd43f60241738c2fed4dea5db8d2e273b7f6 100644 (file)
@@ -178,6 +178,8 @@ extern void nv40_init_surface_functions(struct nv40_context *nv40);
 extern void nv40_init_miptree_functions(struct nv40_context *nv40);
 extern void nv40_init_query_functions(struct nv40_context *nv40);
 
+extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
+
 /* nv40_draw.c */
 extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
 
index 5e1c7ade31b0cff948a2f998c178b743553b6b6d..94ba05b710430855ae5263a321488aed139fe1c4 100644 (file)
@@ -54,9 +54,9 @@ nv40_miptree_layout(struct nv40_miptree *nv40mt)
 }
 
 static struct pipe_texture *
-nv40_miptree_create(struct pipe_context *pipe, const struct pipe_texture *pt)
+nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 {
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_winsys *ws = pscreen->winsys;
        struct nv40_miptree *mt;
 
        mt = MALLOC(sizeof(struct nv40_miptree));
@@ -64,6 +64,8 @@ nv40_miptree_create(struct pipe_context *pipe, const struct pipe_texture *pt)
                return NULL;
        mt->base = *pt;
        mt->base.refcount = 1;
+       mt->base.screen = pscreen;
+
        nv40_miptree_layout(mt);
 
        mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
@@ -77,9 +79,9 @@ nv40_miptree_create(struct pipe_context *pipe, const struct pipe_texture *pt)
 }
 
 static void
-nv40_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
+nv40_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **pt)
 {
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_winsys *ws = pscreen->winsys;
        struct pipe_texture *mt = *pt;
 
        *pt = NULL;
@@ -102,10 +104,10 @@ nv40_miptree_update(struct pipe_context *pipe, struct pipe_texture *mt)
 }
 
 static struct pipe_surface *
-nv40_miptree_surface(struct pipe_context *pipe, struct pipe_texture *pt,
+nv40_miptree_surface(struct pipe_screen *pscreen, struct pipe_texture *pt,
                      unsigned face, unsigned level, unsigned zslice)
 {
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_winsys *ws = pscreen->winsys;
        struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
        struct pipe_surface *ps;
 
@@ -134,9 +136,14 @@ nv40_miptree_surface(struct pipe_context *pipe, struct pipe_texture *pt,
 void
 nv40_init_miptree_functions(struct nv40_context *nv40)
 {
-       nv40->pipe.texture_create = nv40_miptree_create;
-       nv40->pipe.texture_release = nv40_miptree_release;
        nv40->pipe.texture_update = nv40_miptree_update;
-       nv40->pipe.get_tex_surface = nv40_miptree_surface;
+}
+
+void
+nv40_screen_init_miptree_functions(struct pipe_screen *pscreen)
+{
+       pscreen->texture_create = nv40_miptree_create;
+       pscreen->texture_release = nv40_miptree_release;
+       pscreen->get_tex_surface = nv40_miptree_surface;
 }
 
diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
new file mode 100644 (file)
index 0000000..1941598
--- /dev/null
@@ -0,0 +1,151 @@
+#include "pipe/p_screen.h"
+#include "pipe/p_util.h"
+
+#include "nv40_context.h"
+#include "nv40_screen.h"
+
+static const char *
+nv40_screen_get_name(struct pipe_screen *pscreen)
+{
+       struct nv40_screen *screen = nv40_screen(pscreen);
+       static char buffer[128];
+
+       snprintf(buffer, sizeof(buffer), "NV%02X", screen->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)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+               return 16;
+       case PIPE_CAP_NPOT_TEXTURES:
+               return 1;
+       case PIPE_CAP_TWO_SIDED_STENCIL:
+               return 1;
+       case PIPE_CAP_GLSL:
+               return 0;
+       case PIPE_CAP_S3TC:
+               return 0;
+       case PIPE_CAP_ANISOTROPIC_FILTER:
+               return 1;
+       case PIPE_CAP_POINT_SPRITE:
+               return 1;
+       case PIPE_CAP_MAX_RENDER_TARGETS:
+               return 4;
+       case PIPE_CAP_OCCLUSION_QUERY:
+               return 1;
+       case PIPE_CAP_TEXTURE_SHADOW_MAP:
+               return 1;
+       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+               return 13;
+       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+               return 10;
+       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+               return 13;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0;
+       }
+}
+
+static float
+nv40_screen_get_paramf(struct pipe_screen *pscreen, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_LINE_WIDTH:
+       case PIPE_CAP_MAX_LINE_WIDTH_AA:
+               return 10.0;
+       case PIPE_CAP_MAX_POINT_WIDTH:
+       case PIPE_CAP_MAX_POINT_WIDTH_AA:
+               return 64.0;
+       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+               return 16.0;
+       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+               return 16.0;
+       case PIPE_CAP_BITMAP_TEXCOORD_BIAS:
+               return 0.0;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0.0;
+       }
+}
+
+static boolean
+nv40_screen_surface_format_supported(struct pipe_screen *pscreen,
+                                    enum pipe_format format, uint type)
+{
+       switch (type) {
+       case PIPE_SURFACE:
+               switch (format) {
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
+               case PIPE_FORMAT_R5G6B5_UNORM: 
+               case PIPE_FORMAT_Z24S8_UNORM:
+               case PIPE_FORMAT_Z16_UNORM:
+                       return TRUE;
+               default:
+                       break;
+               }
+               break;
+       case PIPE_TEXTURE:
+               switch (format) {
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
+               case PIPE_FORMAT_A1R5G5B5_UNORM:
+               case PIPE_FORMAT_A4R4G4B4_UNORM:
+               case PIPE_FORMAT_R5G6B5_UNORM: 
+               case PIPE_FORMAT_U_L8:
+               case PIPE_FORMAT_U_A8:
+               case PIPE_FORMAT_U_I8:
+               case PIPE_FORMAT_U_A8_L8:
+               case PIPE_FORMAT_Z16_UNORM:
+               case PIPE_FORMAT_Z24S8_UNORM:
+                       return TRUE;
+               default:
+                       break;
+               }
+               break;
+       default:
+               assert(0);
+       };
+
+       return FALSE;
+}
+
+static void
+nv40_screen_destroy(struct pipe_screen *pscreen)
+{
+       FREE(pscreen);
+}
+
+struct pipe_screen *
+nv40_screen_create(struct pipe_winsys *ws, unsigned chipset)
+{
+       struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen);
+
+       if (!screen)
+               return NULL;
+
+       screen->chipset = chipset;
+
+       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);
+
+       return &screen->pipe;
+}
+
diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
new file mode 100644 (file)
index 0000000..b30a6c5
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __NV40_SCREEN_H__
+#define __NV40_SCREEN_H__
+
+#include "pipe/p_screen.h"
+
+struct nv40_screen {
+       struct pipe_screen pipe;
+       unsigned chipset;
+};
+
+static INLINE struct nv40_screen *
+nv40_screen(struct pipe_screen *screen)
+{
+       return (struct nv40_screen *)screen;
+}
+
+extern struct pipe_screen *
+nv40_screen_create(struct pipe_winsys *winsys, unsigned chipset);
+
+#endif
index df5d7abdbfc8ada879a9d7c16c3af57db1ca56b8..e8a601169642647358341071e42be88be52f13d4 100644 (file)
 #include "pipe/p_inlines.h"
 #include "util/p_tile.h"
 
-static boolean
-nv40_surface_format_supported(struct pipe_context *pipe,
-                             enum pipe_format format, uint type)
-{
-       switch (type) {
-       case PIPE_SURFACE:
-               switch (format) {
-               case PIPE_FORMAT_A8R8G8B8_UNORM:
-               case PIPE_FORMAT_R5G6B5_UNORM: 
-               case PIPE_FORMAT_Z24S8_UNORM:
-               case PIPE_FORMAT_Z16_UNORM:
-                       return TRUE;
-               default:
-                       break;
-               }
-               break;
-       case PIPE_TEXTURE:
-               switch (format) {
-               case PIPE_FORMAT_A8R8G8B8_UNORM:
-               case PIPE_FORMAT_A1R5G5B5_UNORM:
-               case PIPE_FORMAT_A4R4G4B4_UNORM:
-               case PIPE_FORMAT_R5G6B5_UNORM: 
-               case PIPE_FORMAT_U_L8:
-               case PIPE_FORMAT_U_A8:
-               case PIPE_FORMAT_U_I8:
-               case PIPE_FORMAT_U_A8_L8:
-               case PIPE_FORMAT_Z16_UNORM:
-               case PIPE_FORMAT_Z24S8_UNORM:
-                       return TRUE;
-               default:
-                       break;
-               }
-               break;
-       default:
-               assert(0);
-       };
-
-       return FALSE;
-}
-
 static void
 nv40_surface_copy(struct pipe_context *pipe, unsigned do_flip,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
@@ -100,7 +60,6 @@ nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
 void
 nv40_init_surface_functions(struct nv40_context *nv40)
 {
-       nv40->pipe.is_format_supported = nv40_surface_format_supported;
        nv40->pipe.surface_copy = nv40_surface_copy;
        nv40->pipe.surface_fill = nv40_surface_fill;
 }
index 68eb49ff2a358832f67d89dde3cb00a62afc3242..1c0b82887a15078783778edd33948433a0afa397 100644 (file)
@@ -9,6 +9,7 @@ DRIVER_SOURCES = \
        nv50_draw.c \
        nv50_miptree.c \
        nv50_query.c \
+       nv50_screen.c \
        nv50_state.c \
        nv50_surface.c \
        nv50_vbo.c
index 3c5a54bfd3803eef87c0cb948ec89c6e37009831..98022809a6c72417420f39e802bf1f59d6e3657f 100644 (file)
@@ -4,85 +4,7 @@
 #include "pipe/p_util.h"
 
 #include "nv50_context.h"
-
-static boolean
-nv50_is_format_supported(struct pipe_context *pipe, enum pipe_format format,
-                        uint type)
-{
-       return FALSE;
-}
-
-static const char *
-nv50_get_name(struct pipe_context *pipe)
-{
-       struct nv50_context *nv50 = (struct nv50_context *)pipe;
-       static char buffer[128];
-
-       snprintf(buffer, sizeof(buffer), "NV%02X", nv50->chipset);
-       return buffer;
-}
-
-static const char *
-nv50_get_vendor(struct pipe_context *pipe)
-{
-       return "nouveau";
-}
-
-static int
-nv50_get_param(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-               return 32;
-       case PIPE_CAP_NPOT_TEXTURES:
-               return 0;
-       case PIPE_CAP_TWO_SIDED_STENCIL:
-               return 1;
-       case PIPE_CAP_GLSL:
-               return 0;
-       case PIPE_CAP_S3TC:
-               return 0;
-       case PIPE_CAP_ANISOTROPIC_FILTER:
-               return 0;
-       case PIPE_CAP_POINT_SPRITE:
-               return 0;
-       case PIPE_CAP_MAX_RENDER_TARGETS:
-               return 8;
-       case PIPE_CAP_OCCLUSION_QUERY:
-               return 0;
-       case PIPE_CAP_TEXTURE_SHADOW_MAP:
-               return 0;
-       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
-               return 13;
-       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
-               return 10;
-       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
-               return 13;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0;
-       }
-}
-
-static float
-nv50_get_paramf(struct pipe_context *pipe, int param)
-{
-       switch (param) {
-       case PIPE_CAP_MAX_LINE_WIDTH:
-       case PIPE_CAP_MAX_LINE_WIDTH_AA:
-               return 10.0;
-       case PIPE_CAP_MAX_POINT_WIDTH:
-       case PIPE_CAP_MAX_POINT_WIDTH_AA:
-               return 64.0;
-       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
-               return 16.0;
-       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
-               return 4.0;
-       default:
-               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
-               return 0.0;
-       }
-}
+#include "nv50_screen.h"
 
 static void
 nv50_flush(struct pipe_context *pipe, unsigned flags)
@@ -134,9 +56,10 @@ nv50_init_hwctx(struct nv50_context *nv50, int tesla_class)
 #define GRCLASS5097_CHIPSETS 0x00000000
 #define GRCLASS8297_CHIPSETS 0x00000010
 struct pipe_context *
-nv50_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
-           unsigned chipset)
+nv50_create(struct pipe_screen *pscreen, struct nouveau_winsys *nvws)
 {
+       struct pipe_winsys *pipe_winsys = pscreen->winsys;
+       unsigned chipset = nv50_screen(pscreen)->chipset;
        struct nv50_context *nv50;
        int tesla_class, ret;
 
@@ -173,13 +96,9 @@ nv50_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
        }
 
        nv50->pipe.winsys = pipe_winsys;
+       nv50->pipe.screen = pscreen;
 
        nv50->pipe.destroy = nv50_destroy;
-       nv50->pipe.is_format_supported = nv50_is_format_supported;
-       nv50->pipe.get_name = nv50_get_name;
-       nv50->pipe.get_vendor = nv50_get_vendor;
-       nv50->pipe.get_param = nv50_get_param;
-       nv50->pipe.get_paramf = nv50_get_paramf;
 
        nv50->pipe.draw_arrays = nv50_draw_arrays;
        nv50->pipe.draw_elements = nv50_draw_elements;
index b99254f619129114f34f08332ae7ef582ce6dc63..a529bf3c3e3fea9417c682ff01200f579a69adfe 100644 (file)
@@ -38,6 +38,8 @@ extern void nv50_init_surface_functions(struct nv50_context *nv50);
 extern void nv50_init_state_functions(struct nv50_context *nv50);
 extern void nv50_init_query_functions(struct nv50_context *nv50);
 
+extern void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen);
+
 /* nv50_draw.c */
 extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
 
index 0c034ed4387a791a0c3d00615f5dba726d0c53e2..720d33fda91a32115fbb3477538f0b0529c89d1b 100644 (file)
@@ -1,25 +1,46 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_util.h"
+#include "pipe/p_screen.h"
 
 #include "nv50_context.h"
 
 static struct pipe_texture *
-nv50_miptree_create(struct pipe_context *pipe, const struct pipe_texture *pt)
+nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 {
        NOUVEAU_ERR("unimplemented\n");
        return NULL;
 }
 
 static void
-nv50_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
+nv50_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **pt)
 {
        NOUVEAU_ERR("unimplemented\n");
 }
 
+static struct pipe_surface *
+nv50_miptree_surface(struct pipe_screen *pscreen, struct pipe_texture *pt,
+                    unsigned face, unsigned level, unsigned zslice)
+{
+       NOUVEAU_ERR("unimplemented\n");
+       return NULL;
+}
+
+void
+nv50_screen_init_miptree_functions(struct pipe_screen *pscreen)
+{
+       pscreen->texture_create = nv50_miptree_create;
+       pscreen->texture_release = nv50_miptree_release;
+       pscreen->get_tex_surface = nv50_miptree_surface;
+}
+
+static void
+nv50_miptree_update(struct pipe_context *pipe, struct pipe_texture *mt)
+{
+}
+
 void
 nv50_init_miptree_functions(struct nv50_context *nv50)
 {
-       nv50->pipe.texture_create = nv50_miptree_create;
-       nv50->pipe.texture_release = nv50_miptree_release;
+       nv50->pipe.texture_update = nv50_miptree_update;
 }
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
new file mode 100644 (file)
index 0000000..8bf82eb
--- /dev/null
@@ -0,0 +1,117 @@
+#include "pipe/p_screen.h"
+#include "pipe/p_util.h"
+
+#include "nv50_context.h"
+#include "nv50_screen.h"
+
+static boolean
+nv50_screen_is_format_supported(struct pipe_screen *pscreen,
+                               enum pipe_format format, uint type)
+{
+       return FALSE;
+}
+
+static const char *
+nv50_screen_get_name(struct pipe_screen *pscreen)
+{
+       struct nv50_screen *screen = nv50_screen(pscreen);
+       static char buffer[128];
+
+       snprintf(buffer, sizeof(buffer), "NV%02X", screen->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)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
+               return 32;
+       case PIPE_CAP_NPOT_TEXTURES:
+               return 0;
+       case PIPE_CAP_TWO_SIDED_STENCIL:
+               return 1;
+       case PIPE_CAP_GLSL:
+               return 0;
+       case PIPE_CAP_S3TC:
+               return 0;
+       case PIPE_CAP_ANISOTROPIC_FILTER:
+               return 0;
+       case PIPE_CAP_POINT_SPRITE:
+               return 0;
+       case PIPE_CAP_MAX_RENDER_TARGETS:
+               return 8;
+       case PIPE_CAP_OCCLUSION_QUERY:
+               return 0;
+       case PIPE_CAP_TEXTURE_SHADOW_MAP:
+               return 0;
+       case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+               return 13;
+       case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+               return 10;
+       case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+               return 13;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0;
+       }
+}
+
+static float
+nv50_screen_get_paramf(struct pipe_screen *pscreen, int param)
+{
+       switch (param) {
+       case PIPE_CAP_MAX_LINE_WIDTH:
+       case PIPE_CAP_MAX_LINE_WIDTH_AA:
+               return 10.0;
+       case PIPE_CAP_MAX_POINT_WIDTH:
+       case PIPE_CAP_MAX_POINT_WIDTH_AA:
+               return 64.0;
+       case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+               return 16.0;
+       case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+               return 4.0;
+       default:
+               NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
+               return 0.0;
+       }
+}
+
+static void
+nv50_screen_destroy(struct pipe_screen *pscreen)
+{
+       FREE(pscreen);
+}
+
+struct pipe_screen *
+nv50_screen_create(struct pipe_winsys *ws, unsigned chipset)
+{
+       struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen);
+
+       if (!screen)
+               return NULL;
+
+       screen->chipset = chipset;
+
+       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);
+
+       return &screen->pipe;
+}
+
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
new file mode 100644 (file)
index 0000000..45ebbb8
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __NV50_SCREEN_H__
+#define __NV50_SCREEN_H__
+
+#include "pipe/p_screen.h"
+
+struct nv50_screen {
+       struct pipe_screen pipe;
+       unsigned chipset;
+};
+
+static INLINE struct nv50_screen *
+nv50_screen(struct pipe_screen *screen)
+{
+       return (struct nv50_screen *)screen;
+}
+
+extern struct pipe_screen *
+nv50_screen_create(struct pipe_winsys *winsys, unsigned chipset);
+
+#endif
index ca92ff02b89bbef5b705b753fc24f388bba19fa9..39cf675a57ccf71d718faa908dae09919e5266da 100644 (file)
 #include "pipe/p_inlines.h"
 #include "util/p_tile.h"
 
-static struct pipe_surface *
-nv50_get_tex_surface(struct pipe_context *pipe,
-                     struct pipe_texture *pt,
-                     unsigned face, unsigned level, unsigned zslice)
-{
-       NOUVEAU_ERR("unimplemented\n");
-       return NULL;
-}
-
 static void
 nv50_surface_copy(struct pipe_context *pipe, unsigned flip,
                  struct pipe_surface *dest, unsigned destx, unsigned desty,
@@ -69,7 +60,6 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
 void
 nv50_init_surface_functions(struct nv50_context *nv50)
 {
-   nv50->pipe.get_tex_surface = nv50_get_tex_surface;
    nv50->pipe.surface_copy = nv50_surface_copy;
    nv50->pipe.surface_fill = nv50_surface_fill;
 }
index 2ca05d84c6066b55b87be8c8208b2b6db73dccc0..1d758e29e75553980573641a04bb74e3787b36b6 100644 (file)
@@ -72,23 +72,29 @@ struct pipe_context *
 nouveau_pipe_create(struct nouveau_context *nv)
 {
        struct nouveau_winsys *nvws = CALLOC_STRUCT(nouveau_winsys);
-       struct pipe_context *(*hw_create)(struct pipe_winsys *,
-                                         struct nouveau_winsys *,
-                                         unsigned);
+       struct pipe_screen *(*hws_create)(struct pipe_winsys *,
+                                         unsigned chipset);
+       struct pipe_context *(*hw_create)(struct pipe_screen *,
+                                         struct nouveau_winsys *);
+       struct pipe_winsys *ws;
+       struct pipe_screen *pscreen;
 
        if (!nvws)
                return NULL;
 
        switch (nv->chipset & 0xf0) {
        case 0x30:
+               hws_create = nv30_screen_create;
                hw_create = nv30_create;
                break;
        case 0x40:
        case 0x60:
+               hws_create = nv40_screen_create;
                hw_create = nv40_create;
                break;
        case 0x50:
        case 0x80:
+               hws_create = nv50_screen_create;
                hw_create = nv50_create;
                break;
        default:
@@ -119,6 +125,8 @@ nouveau_pipe_create(struct nouveau_context *nv)
        nvws->surface_copy      = nouveau_pipe_surface_copy;
        nvws->surface_fill      = nouveau_pipe_surface_fill;
 
-       return hw_create(nouveau_create_pipe_winsys(nv), nvws, nv->chipset);
+       ws = nouveau_create_pipe_winsys(nv);
+       pscreen = hws_create(ws, nv->chipset);
+       return hw_create(pscreen, nvws);
 }
 
index 0e1b4273d1e96002a09587a37a52097ffe7c2a00..704f6c77506357f4518d094cda822ae123c1eef5 100644 (file)
@@ -61,23 +61,25 @@ nouveau_is_format_supported(struct softpipe_winsys *sws, uint format)
        return FALSE;
 }
 
-
-
 struct pipe_context *
 nouveau_create_softpipe(struct nouveau_context *nv)
 {
-   struct nouveau_softpipe_winsys *nvsws;
-   
-   nvsws = CALLOC_STRUCT(nouveau_softpipe_winsys);
-   
-   /* Fill in this struct with callbacks that softpipe will need to
-    * communicate with the window system, buffer manager, etc. 
-    */
-   nvsws->sws.is_format_supported = nouveau_is_format_supported;
-   nvsws->nv = nv;
+       struct nouveau_softpipe_winsys *nvsws;
+       struct pipe_screen *pscreen;
+       struct pipe_winsys *ws;
+
+       ws = nouveau_create_pipe_winsys(nv);
+       if (!ws)
+               return NULL;
+       pscreen = softpipe_create_screen(ws);
+
+       nvsws = CALLOC_STRUCT(nouveau_softpipe_winsys);
+       if (!nvsws)
+               return NULL;
+
+       nvsws->sws.is_format_supported = nouveau_is_format_supported;
+       nvsws->nv = nv;
 
-   /* Create the softpipe context:
-    */
-   return softpipe_create(nouveau_create_pipe_winsys(nv), &nvsws->sws);
+       return softpipe_create(pscreen, ws, &nvsws->sws);
 }