gallium: introduce 'pipe_screen' for context-independent functions
authorBrian <brian@i915.localnet.net>
Wed, 27 Feb 2008 03:15:14 +0000 (20:15 -0700)
committerBrian <brian@i915.localnet.net>
Wed, 27 Feb 2008 03:15:14 +0000 (20:15 -0700)
This will allow creating textures before a rendering context exists, for example.
Only implemented in i915 driver for now.  i915pipe->texture_create() just
dispatches through to the i915screen->texture_create() to avoid state tracker
changes for now.

14 files changed:
src/gallium/drivers/i915simple/Makefile
src/gallium/drivers/i915simple/i915_context.c
src/gallium/drivers/i915simple/i915_context.h
src/gallium/drivers/i915simple/i915_screen.c [new file with mode: 0644]
src/gallium/drivers/i915simple/i915_screen.h [new file with mode: 0644]
src/gallium/drivers/i915simple/i915_strings.c
src/gallium/drivers/i915simple/i915_texture.c
src/gallium/drivers/i915simple/i915_texture.h
src/gallium/drivers/i915simple/i915_winsys.h
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_inlines.h
src/gallium/include/pipe/p_screen.h [new file with mode: 0644]
src/gallium/include/pipe/p_state.h
src/gallium/winsys/dri/intel/intel_winsys_i915.c

index 2a75f5d57ce7dfe18c7969f164af276b1030459d..3400747a73021338bf5550307cc2a04dfa77ff8c 100644 (file)
@@ -17,6 +17,7 @@ C_SOURCES = \
        i915_state_derived.c \
        i915_state_emit.c \
        i915_state_sampler.c \
+       i915_screen.c \
        i915_strings.c \
        i915_prim_emit.c \
        i915_prim_vbuf.c \
index c3955bbd2dd830d9ec39fa7b20fa2cbbe7722027..8478cd76a540a66e68cd6ff7af33eafe8fa47a87 100644 (file)
@@ -234,33 +234,11 @@ static boolean i915_draw_arrays( struct pipe_context *pipe,
 
 
 
-struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
-                                 struct i915_winsys *i915_winsys,
-                                 unsigned pci_id )
+struct pipe_context *i915_create_context( struct pipe_screen *screen,
+                                          struct pipe_winsys *pipe_winsys,
+                                          struct i915_winsys *i915_winsys )
 {
    struct i915_context *i915;
-   unsigned is_i945 = 0;
-
-   switch (pci_id) {
-   case PCI_CHIP_I915_G:
-   case PCI_CHIP_I915_GM:
-      break;
-
-   case PCI_CHIP_I945_G:
-   case PCI_CHIP_I945_GM:
-   case PCI_CHIP_I945_GME:
-   case PCI_CHIP_G33_G:
-   case PCI_CHIP_Q33_G:
-   case PCI_CHIP_Q35_G:
-      is_i945 = 1;
-      break;
-
-   default:
-      pipe_winsys->printf(pipe_winsys, 
-                         "%s: unknown pci id 0x%x, cannot create context\n", 
-                         __FUNCTION__, pci_id);
-      return NULL;
-   }
 
    i915 = CALLOC_STRUCT(i915_context);
    if (i915 == NULL)
@@ -268,6 +246,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
 
    i915->winsys = i915_winsys;
    i915->pipe.winsys = pipe_winsys;
+   i915->pipe.screen = screen;
 
    i915->pipe.destroy = i915_destroy;
    i915->pipe.is_format_supported = i915_is_format_supported;
@@ -301,9 +280,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
    draw_install_aaline_stage(i915->draw, &i915->pipe);
    draw_install_aapoint_stage(i915->draw, &i915->pipe);
 
-   i915->pci_id = pci_id;
-   i915->flags.is_i945 = is_i945;
-
    i915->dirty = ~0;
    i915->hardware_dirty = ~0;
 
index 20cf7d3c3bf18e812a9f129f4fff83c651daa37e..9fb85c122d1dd2b77ebaed448c3a705503b4ba15 100644 (file)
@@ -245,11 +245,6 @@ struct i915_context
    unsigned hardware_dirty;
    
    unsigned debug;
-   unsigned pci_id;
-
-   struct {
-      unsigned is_i945:1;
-   } flags;
 };
 
 /* A flag for each state_tracker state object:
@@ -322,6 +317,8 @@ void i915_init_surface_functions( struct i915_context *i915 );
 void i915_init_state_functions( struct i915_context *i915 );
 void i915_init_flush_functions( struct i915_context *i915 );
 void i915_init_string_functions( struct i915_context *i915 );
+void i915_init_screen_string_functions(struct pipe_screen *screen);
+
 
 
 
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
new file mode 100644 (file)
index 0000000..7e9d971
--- /dev/null
@@ -0,0 +1,139 @@
+/**************************************************************************
+ * 
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+
+#include "pipe/p_util.h"
+#include "pipe/p_winsys.h"
+
+#include "i915_reg.h"
+#include "i915_screen.h"
+#include "i915_texture.h"
+
+
+static const char *
+i915_get_vendor( struct pipe_screen *pscreen )
+{
+   return "Tungsten Graphics, Inc.";
+}
+
+
+static const char *
+i915_get_name( struct pipe_screen *pscreen )
+{
+   static char buffer[128];
+   const char *chipset;
+
+   switch (i915_screen(pscreen)->pci_id) {
+   case PCI_CHIP_I915_G:
+      chipset = "915G";
+      break;
+   case PCI_CHIP_I915_GM:
+      chipset = "915GM";
+      break;
+   case PCI_CHIP_I945_G:
+      chipset = "945G";
+      break;
+   case PCI_CHIP_I945_GM:
+      chipset = "945GM";
+      break;
+   case PCI_CHIP_I945_GME:
+      chipset = "945GME";
+      break;
+   case PCI_CHIP_G33_G:
+      chipset = "G33";
+      break;
+   case PCI_CHIP_Q35_G:
+      chipset = "Q35";
+      break;
+   case PCI_CHIP_Q33_G:
+      chipset = "Q33";
+      break;
+   default:
+      chipset = "unknown";
+      break;
+   }
+
+   sprintf(buffer, "i915 (chipset: %s)", chipset);
+   return buffer;
+}
+
+
+
+static void
+i915_destroy_screen( struct pipe_screen *screen )
+{
+   FREE(screen);
+}
+
+
+/**
+ * Create a new i915_screen object
+ */
+struct pipe_screen *
+i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
+{
+   struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen);
+
+   if (!i915screen)
+      return NULL;
+
+   switch (pci_id) {
+   case PCI_CHIP_I915_G:
+   case PCI_CHIP_I915_GM:
+      i915screen->is_i945 = FALSE;
+      break;
+
+   case PCI_CHIP_I945_G:
+   case PCI_CHIP_I945_GM:
+   case PCI_CHIP_I945_GME:
+   case PCI_CHIP_G33_G:
+   case PCI_CHIP_Q33_G:
+   case PCI_CHIP_Q35_G:
+      i915screen->is_i945 = TRUE;
+      break;
+
+   default:
+      winsys->printf(winsys, 
+                     "%s: unknown pci id 0x%x, cannot create screen\n", 
+                     __FUNCTION__, pci_id);
+      return NULL;
+   }
+
+   i915screen->pci_id = pci_id;
+
+   i915screen->screen.winsys = winsys;
+
+   i915screen->screen.destroy = i915_destroy_screen;
+
+   i915screen->screen.get_name = i915_get_name;
+   i915screen->screen.get_vendor = i915_get_vendor;
+
+   i915_init_screen_string_functions(&i915screen->screen);
+   i915_init_screen_texture_functions(&i915screen->screen);
+
+   return &i915screen->screen;
+}
diff --git a/src/gallium/drivers/i915simple/i915_screen.h b/src/gallium/drivers/i915simple/i915_screen.h
new file mode 100644 (file)
index 0000000..8394ddb
--- /dev/null
@@ -0,0 +1,60 @@
+/**************************************************************************
+ * 
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+
+#ifndef I915_SCREEN_H
+#define I915_SCREEN_H
+
+
+#include "pipe/p_screen.h"
+
+
+/**
+ * Subclass of pipe_screen
+ */
+struct i915_screen
+{
+   struct pipe_screen screen;
+
+   boolean is_i945;
+   uint pci_id;
+};
+
+
+/** cast wrapper */
+static INLINE struct i915_screen *
+i915_screen(struct pipe_screen *pscreen)
+{
+   return (struct i915_screen *) pscreen;
+}
+
+
+extern struct pipe_screen *
+i915_create_screen(struct pipe_winsys *winsys, uint pci_id);
+
+
+#endif /* I915_SCREEN_H */
index 301fedea197bbe26bd9a76157ef496d3492d8d83..ee62bb2e5de56d3e3525e4625fe0c1446c0f63e5 100644 (file)
  **************************************************************************/
 
 #include "i915_context.h"
+#include "i915_screen.h"
 #include "i915_reg.h"
 
 
+/** XXX temporary screen/pipe duplication here */
+
+
+static const char *i915_get_vendor_screen( struct pipe_screen *screen )
+{
+   return "Tungsten Graphics, Inc.";
+}
+
 static const char *i915_get_vendor( struct pipe_context *pipe )
 {
    return "Tungsten Graphics, Inc.";
 }
 
 
-static const char *i915_get_name( struct pipe_context *pipe )
+static const char *i915_get_name_screen( struct pipe_screen *screen )
 {
+   struct i915_screen *i915screen = i915_screen(screen);
    static char buffer[128];
    const char *chipset;
 
-   switch (i915_context(pipe)->pci_id) {
+   switch (i915screen->pci_id) {
    case PCI_CHIP_I915_G:
       chipset = "915G";
       break;
@@ -75,9 +85,22 @@ static const char *i915_get_name( struct pipe_context *pipe )
 }
 
 
+static const char *i915_get_name( struct pipe_context *pipe )
+{
+   return pipe->screen->get_name(pipe->screen);
+}
+
+
 void
 i915_init_string_functions(struct i915_context *i915)
 {
    i915->pipe.get_name = i915_get_name;
    i915->pipe.get_vendor = i915_get_vendor;
 }
+
+void
+i915_init_screen_string_functions(struct pipe_screen *screen)
+{
+   screen->get_name = i915_get_name_screen;
+   screen->get_vendor = i915_get_vendor_screen;
+}
index 7fcf4332e14a304189673967c1d41727c607e302..3c9509dee3488d6baf92d988e7a76889aaefa0f2 100644 (file)
@@ -40,6 +40,7 @@
 #include "i915_context.h"
 #include "i915_texture.h"
 #include "i915_debug.h"
+#include "i915_screen.h"
 
 
 static unsigned minify( unsigned d )
@@ -187,7 +188,7 @@ static const int step_offsets[6][2] = {
 
 
 static boolean
-i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
+i915_miptree_layout(struct i915_texture * tex)
 {
    struct pipe_texture *pt = &tex->base;
    unsigned level;
@@ -311,7 +312,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
 
 
 static boolean
-i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
+i945_miptree_layout(struct i915_texture * tex)
 {
    struct pipe_texture *pt = &tex->base;
    unsigned level;
@@ -479,24 +480,26 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
 
 
 static struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
-                    const struct pipe_texture *templat)
+i915_texture_create_screen(struct pipe_screen *screen,
+                           const struct pipe_texture *templat)
 {
    struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
 
    if (tex) {
-      struct i915_context *i915 = i915_context(pipe);
+      struct i915_screen *i915screen = i915_screen(screen);
+      struct pipe_winsys *ws = screen->winsys;
 
       tex->base = *templat;
       tex->base.refcount = 1;
-      tex->base.pipe = pipe;
+      tex->base.pipe = NULL;
+      tex->base.screen = screen;
 
-      if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
-         i915_miptree_layout(pipe, tex))
-        tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
-                                                   PIPE_BUFFER_USAGE_PIXEL,
-                                                   tex->pitch * tex->base.cpp *
-                                                   tex->total_height);
+      if (i915screen->is_i945 ? i945_miptree_layout(tex) :
+         i915_miptree_layout(tex))
+        tex->buffer = ws->buffer_create(ws, 64,
+                                         PIPE_BUFFER_USAGE_PIXEL,
+                                         tex->pitch * tex->base.cpp *
+                                         tex->total_height);
 
       if (!tex->buffer) {
         FREE(tex);
@@ -508,8 +511,17 @@ i915_texture_create(struct pipe_context *pipe,
 }
 
 
+static struct pipe_texture *
+i915_texture_create(struct pipe_context *pipe,
+                    const struct pipe_texture *templat)
+{
+   return pipe->screen->texture_create(pipe->screen, templat);
+}
+
+
 static void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+i915_texture_release_screen(struct pipe_screen *screen,
+                            struct pipe_texture **pt)
 {
    if (!*pt)
       return;
@@ -526,7 +538,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
       DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
       */
 
-      pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
+      pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
 
       for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
          if (tex->image_offset[i])
@@ -538,6 +550,13 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
 }
 
 
+static void
+i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+{
+   i915_texture_release_screen(pipe->screen, pt);
+}
+
+
 static void
 i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
 {
@@ -549,11 +568,12 @@ i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
  * XXX note: same as code in sp_surface.c
  */
 static struct pipe_surface *
-i915_get_tex_surface(struct pipe_context *pipe,
-                     struct pipe_texture *pt,
-                     unsigned face, unsigned level, unsigned zslice)
+i915_get_tex_surface_screen(struct pipe_screen *screen,
+                            struct pipe_texture *pt,
+                            unsigned face, unsigned level, unsigned zslice)
 {
    struct i915_texture *tex = (struct i915_texture *)pt;
+   struct pipe_winsys *ws = screen->winsys;
    struct pipe_surface *ps;
    unsigned offset;  /* in bytes */
 
@@ -570,11 +590,11 @@ i915_get_tex_surface(struct pipe_context *pipe,
       assert(zslice == 0);
    }
 
-   ps = pipe->winsys->surface_alloc(pipe->winsys);
+   ps = ws->surface_alloc(ws);
    if (ps) {
       assert(ps->refcount);
       assert(ps->winsys);
-      pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+      pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
       ps->format = pt->format;
       ps->cpp = pt->cpp;
       ps->width = pt->width[level];
@@ -586,6 +606,14 @@ i915_get_tex_surface(struct pipe_context *pipe,
 }
 
 
+static struct pipe_surface *
+i915_get_tex_surface(struct pipe_context *pipe,
+                     struct pipe_texture *pt,
+                     unsigned face, unsigned level, unsigned zslice)
+{
+   return i915_get_tex_surface_screen(pipe->screen, pt, face, level, zslice);
+}
+
 
 void
 i915_init_texture_functions(struct i915_context *i915)
@@ -595,3 +623,13 @@ i915_init_texture_functions(struct i915_context *i915)
    i915->pipe.texture_update = i915_texture_update;
    i915->pipe.get_tex_surface = i915_get_tex_surface;
 }
+
+
+
+void
+i915_init_screen_texture_functions(struct pipe_screen *screen)
+{
+   screen->texture_create = i915_texture_create_screen;
+   screen->texture_release = i915_texture_release_screen;
+   screen->get_tex_surface = i915_get_tex_surface_screen;
+}
index 6d8d41178f728a7616210ecd1452089c32317c40..7225016a9f4837ebe8d4da7a722c7ec583b84e53 100644 (file)
 #ifndef I915_TEXTURE_H
 #define I915_TEXTURE_H
 
-struct pipe_context;
+struct i915_context;
+struct pipe_screen;
 
 
 extern void
 i915_init_texture_functions(struct i915_context *i915);
 
 
+extern void
+i915_init_screen_texture_functions(struct pipe_screen *screen);
+
+
 #endif /* I915_TEXTURE_H */
index fe49710852bf68a96b02b39bf0c4d819dcd9e54f..e6b0ac9c52ef63c64247c2bc4aa91f6bff593ba4 100644 (file)
@@ -52,6 +52,7 @@
 
 struct pipe_buffer;
 struct pipe_winsys;
+struct pipe_screen;
 
 
 /**
@@ -107,9 +108,8 @@ struct i915_winsys {
 #define I915_BUFFER_USAGE_LIT_VERTEX  (PIPE_BUFFER_USAGE_CUSTOM << 0)
 
 
-struct pipe_context *i915_create( struct pipe_winsys *,
-                                 struct i915_winsys *,
-                                 unsigned pci_id );
-
+struct pipe_context *i915_create_context( struct pipe_screen *,
+                                          struct pipe_winsys *,
+                                          struct i915_winsys * );
 
 #endif 
index f69b52f5e3f049dfd15cc1dc7ce0fc6be3382c53..93fcb1c3e962e5df537d3c54e7b15e6ef03f21ea 100644 (file)
@@ -36,6 +36,8 @@ extern "C" {
 #endif
 
    
+struct pipe_screen;
+
 struct pipe_state_cache;
 
 /* Opaque driver handles:
@@ -51,6 +53,7 @@ struct pipe_query;
  */
 struct pipe_context {
    struct pipe_winsys *winsys;
+   struct pipe_screen *screen;
 
    void *priv;  /** context private data (for DRI for example) */
 
index 21d4827e675e2f6375552db57bbcaaf153a51d2e..a7e97fcd7db5da6c3761903722de6e981cdfe4c1 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "p_context.h"
 #include "p_defines.h"
+#include "p_screen.h"
 #include "p_winsys.h"
 
 
@@ -107,7 +108,15 @@ pipe_texture_reference(struct pipe_texture **ptr,
 
    if (*ptr) {
       struct pipe_context *pipe = (*ptr)->pipe;
-      pipe->texture_release(pipe, ptr);
+      /* XXX temporary mess here */
+      if (pipe) {
+         pipe->texture_release(pipe, ptr);
+      }
+      else {
+         struct pipe_screen *screen = (*ptr)->screen;
+         screen->texture_release(screen, ptr);
+      }
+
       assert(!*ptr);
    }
 
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
new file mode 100644 (file)
index 0000000..6be9a82
--- /dev/null
@@ -0,0 +1,98 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+/**
+ * Screen, Adapter or GPU
+ *
+ * These are driver functions/facilities that are context independent.
+ */
+
+
+#ifndef P_SCREEN_H
+#define P_SCREEN_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/**
+ * Gallium screen/adapter context.  Basically everything
+ * hardware-specific that doesn't actually require a rendering
+ * context.
+ */
+struct pipe_screen {
+   struct pipe_winsys *winsys;
+
+   void (*destroy)( struct pipe_screen * );
+
+
+   /* 
+    * Capability queries
+    */
+   const char *(*get_name)( struct pipe_screen * );
+
+   const char *(*get_vendor)( struct pipe_screen * );
+
+   int (*get_param)( struct pipe_screen *, int param );
+
+   float (*get_paramf)( struct pipe_screen *, int param );
+
+   boolean (*is_format_supported)( struct pipe_screen *,
+                                   enum pipe_format format, 
+                                   uint type );
+
+
+   /*
+    * Texture functions
+    */
+   struct pipe_texture * (*texture_create)(struct pipe_screen *,
+                                           const struct pipe_texture *templat);
+
+   void (*texture_release)(struct pipe_screen *,
+                           struct pipe_texture **pt);
+
+   /** Get a surface which is a "view" into a texture */
+   struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
+                                           struct pipe_texture *texture,
+                                           unsigned face, unsigned level,
+                                           unsigned zslice);
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* P_SCREEN_H */
index 25a6fcc9e63c4f1f663962a7d7a4f1b6ee13f38d..bb4a6cb23ed10c8ea297593abfe69b2abe3db96f 100644 (file)
@@ -63,6 +63,7 @@ extern "C" {
 
 
 /* fwd decls */
+struct pipe_screen;
 struct pipe_surface;
 struct pipe_winsys;
 
@@ -301,6 +302,7 @@ struct pipe_texture
     * XXX this'll change to a pipe_winsys (or pipe_screen)...
     */
    struct pipe_context *pipe;
+   struct pipe_screen *screen;
 };
 
 
index 0ed3890e936fa95d81fa5624c87117e3261595d0..2def1afc31efdb15a435b6d77567c891d460f8f6 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "pipe/p_util.h"
 #include "i915simple/i915_winsys.h"
+#include "i915simple/i915_screen.h"
 
 
 struct intel_i915_winsys {
@@ -135,6 +136,7 @@ intel_create_i915simple( struct intel_context *intel,
                          struct pipe_winsys *winsys )
 {
    struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
+   struct pipe_screen *screen;
    
    /* Fill in this struct with callbacks that i915simple will need to
     * communicate with the window system, buffer manager, etc. 
@@ -146,9 +148,11 @@ intel_create_i915simple( struct intel_context *intel,
    iws->winsys.batch_finish = intel_i915_batch_finish;
    iws->intel = intel;
 
+   screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
+
    /* Create the i915simple context:
     */
-   return i915_create( winsys,
-                      &iws->winsys,
-                      intel->intelScreen->deviceID );
+   return i915_create_context( screen,
+                               winsys,
+                               &iws->winsys );
 }