From ecd50ef58b034e604ff6b2fedbb0815953e510ea Mon Sep 17 00:00:00 2001
From: Brian <brian.paul@tungstengraphics.com>
Date: Tue, 26 Feb 2008 08:43:07 -0700
Subject: gallium: remove input_map[] from pipe_shader_state

---
 src/gallium/include/pipe/p_state.h | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src/gallium/include/pipe/p_state.h')

diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 15c88881eb..ddf3c1c79b 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -162,7 +162,6 @@ struct pipe_shader_state
    const struct tgsi_token *tokens;
    ubyte num_inputs;
    ubyte num_outputs;
-   ubyte input_map[PIPE_MAX_SHADER_INPUTS]; /* XXX this may be temporary */
    ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
    ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
    ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
-- 
cgit v1.2.3


From 4da19dbcaa9f3e2d20fffd0145bf0bc756dd7542 Mon Sep 17 00:00:00 2001
From: Brian <brian@i915.localnet.net>
Date: Tue, 26 Feb 2008 19:31:22 -0700
Subject: gallium: remove pipe parameter from pipe_texture_reference()

Added pipe field to pipe_texture (temporary, see comments).
First step toward context-less texture creation...
---
 src/gallium/drivers/cell/ppu/cell_pipe_state.c  |  3 +--
 src/gallium/drivers/i915simple/i915_state.c     |  3 +--
 src/gallium/drivers/i915simple/i915_texture.c   |  1 +
 src/gallium/drivers/i965simple/brw_state.c      |  3 +--
 src/gallium/drivers/softpipe/sp_state_sampler.c |  2 +-
 src/gallium/drivers/softpipe/sp_texture.c       |  1 +
 src/gallium/drivers/softpipe/sp_tile_cache.c    |  2 +-
 src/gallium/include/pipe/p_inlines.h            | 14 +++++++++++++-
 src/gallium/include/pipe/p_state.h              |  5 +++++
 src/mesa/state_tracker/st_cb_texture.c          |  6 +++---
 10 files changed, 28 insertions(+), 12 deletions(-)

(limited to 'src/gallium/include/pipe/p_state.h')

diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 95bfc29fbe..075e0a0c47 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -242,8 +242,7 @@ cell_set_sampler_texture(struct pipe_context *pipe,
 
    draw_flush(cell->draw);
 
-   pipe_texture_reference(pipe,
-                          (struct pipe_texture **) &cell->texture[sampler],
+   pipe_texture_reference((struct pipe_texture **) &cell->texture[sampler],
                           texture);
 
    cell_update_texture_mapping(cell);
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index 9df0e12540..27af46bea0 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -532,8 +532,7 @@ static void i915_set_sampler_texture(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
 
-   pipe_texture_reference(pipe,
-                          (struct pipe_texture **) &i915->texture[sampler],
+   pipe_texture_reference((struct pipe_texture **) &i915->texture[sampler],
                           texture);
 
    i915->dirty |= I915_NEW_TEXTURE;
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 1b415a94d4..7fcf4332e1 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -489,6 +489,7 @@ i915_texture_create(struct pipe_context *pipe,
 
       tex->base = *templat;
       tex->base.refcount = 1;
+      tex->base.pipe = pipe;
 
       if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
 	  i915_miptree_layout(pipe, tex))
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index 2fc048bde0..7466fdc403 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -328,8 +328,7 @@ static void brw_set_sampler_texture(struct pipe_context *pipe,
 {
    struct brw_context *brw = brw_context(pipe);
 
-   pipe_texture_reference(pipe,
-                          (struct pipe_texture **) &brw->attribs.Texture[unit],
+   pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[unit],
                           texture);
 
    brw->state.dirty.brw |= BRW_NEW_TEXTURE;
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 18669a1c6e..1d6dd17d1d 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -83,7 +83,7 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
    draw_flush(softpipe->draw);
 
    assert(unit < PIPE_MAX_SAMPLERS);
-   pipe_texture_reference(pipe, &softpipe->texture[unit], texture);
+   pipe_texture_reference(&softpipe->texture[unit], texture);
 
    sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
 
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 6ba0f09e0a..a96447fa7a 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -90,6 +90,7 @@ softpipe_texture_create(struct pipe_context *pipe,
 
    spt->base = *templat;
    spt->base.refcount = 1;
+   spt->base.pipe = pipe;
 
    softpipe_texture_layout(spt);
 
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index da30dd6c48..0ff93c5527 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -220,7 +220,7 @@ sp_tile_cache_set_texture(struct pipe_context *pipe,
 
    assert(!tc->surface);
 
-   pipe_texture_reference(pipe, &tc->texture, texture);
+   pipe_texture_reference(&tc->texture, texture);
 
    if (tc->tex_surf_map) {
       pipe_surface_unmap(tc->tex_surf);
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index de3fa555c5..21d4827e67 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -97,7 +97,7 @@ pipe_buffer_reference(struct pipe_winsys *winsys,
  * \sa pipe_surface_reference
  */
 static INLINE void
-pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
+pipe_texture_reference(struct pipe_texture **ptr,
 		       struct pipe_texture *pt)
 {
    assert(ptr);
@@ -106,6 +106,7 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
       pt->refcount++;
 
    if (*ptr) {
+      struct pipe_context *pipe = (*ptr)->pipe;
       pipe->texture_release(pipe, ptr);
       assert(!*ptr);
    }
@@ -114,6 +115,17 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
 }
 
 
+static INLINE void
+pipe_texture_release(struct pipe_texture **ptr)
+{
+   struct pipe_context *pipe;
+   assert(ptr);
+   pipe = (*ptr)->pipe;
+   pipe->texture_release(pipe, ptr);
+   *ptr = NULL;
+}
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index ddf3c1c79b..25a6fcc9e6 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -296,6 +296,11 @@ struct pipe_texture
    /* These are also refcounted:
     */
    unsigned refcount;
+
+   /**< pipe that created the texture
+    * XXX this'll change to a pipe_winsys (or pipe_screen)...
+    */
+   struct pipe_context *pipe;
 };
 
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 778fb536bc..f5f956f6ea 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -573,7 +573,7 @@ st_TexImage(GLcontext * ctx,
        st_texture_match_image(stObj->pt, &stImage->base,
                                  stImage->face, stImage->level)) {
 
-      pipe_texture_reference(ctx->st->pipe, &stImage->pt, stObj->pt);
+      pipe_texture_reference(&stImage->pt, stObj->pt);
       assert(stImage->pt);
    }
 
@@ -1371,7 +1371,7 @@ copy_image_data_to_texture(struct st_context *st,
       stImage->base.Data = NULL;
    }
 
-   pipe_texture_reference(st->pipe, &stImage->pt, stObj->pt);
+   pipe_texture_reference(&stImage->pt, stObj->pt);
 }
 
 
@@ -1426,7 +1426,7 @@ st_finalize_texture(GLcontext *ctx,
       if (stObj->pt)
          ctx->st->pipe->texture_release(ctx->st->pipe, &stObj->pt);
 
-      pipe_texture_reference(ctx->st->pipe, &stObj->pt, firstImage->pt);
+      pipe_texture_reference(&stObj->pt, firstImage->pt);
    }
 
    if (firstImage->base.IsCompressed) {
-- 
cgit v1.2.3


From aa59a937ccf41609081d3f9a4973df5478979785 Mon Sep 17 00:00:00 2001
From: Brian <brian@i915.localnet.net>
Date: Tue, 26 Feb 2008 20:15:14 -0700
Subject: gallium: introduce 'pipe_screen' for context-independent functions

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.
---
 src/gallium/drivers/i915simple/Makefile          |   1 +
 src/gallium/drivers/i915simple/i915_context.c    |  32 +-----
 src/gallium/drivers/i915simple/i915_context.h    |   7 +-
 src/gallium/drivers/i915simple/i915_screen.c     | 139 +++++++++++++++++++++++
 src/gallium/drivers/i915simple/i915_screen.h     |  60 ++++++++++
 src/gallium/drivers/i915simple/i915_strings.c    |  27 ++++-
 src/gallium/drivers/i915simple/i915_texture.c    |  76 +++++++++----
 src/gallium/drivers/i915simple/i915_texture.h    |   7 +-
 src/gallium/drivers/i915simple/i915_winsys.h     |   8 +-
 src/gallium/include/pipe/p_context.h             |   3 +
 src/gallium/include/pipe/p_inlines.h             |  11 +-
 src/gallium/include/pipe/p_screen.h              |  98 ++++++++++++++++
 src/gallium/include/pipe/p_state.h               |   2 +
 src/gallium/winsys/dri/intel/intel_winsys_i915.c |  10 +-
 14 files changed, 418 insertions(+), 63 deletions(-)
 create mode 100644 src/gallium/drivers/i915simple/i915_screen.c
 create mode 100644 src/gallium/drivers/i915simple/i915_screen.h
 create mode 100644 src/gallium/include/pipe/p_screen.h

(limited to 'src/gallium/include/pipe/p_state.h')

diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile
index 2a75f5d57c..3400747a73 100644
--- a/src/gallium/drivers/i915simple/Makefile
+++ b/src/gallium/drivers/i915simple/Makefile
@@ -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 \
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index c3955bbd2d..8478cd76a5 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -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;
 
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index 20cf7d3c3b..9fb85c122d 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -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
index 0000000000..7e9d971d38
--- /dev/null
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -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
index 0000000000..8394ddbe89
--- /dev/null
+++ b/src/gallium/drivers/i915simple/i915_screen.h
@@ -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 */
diff --git a/src/gallium/drivers/i915simple/i915_strings.c b/src/gallium/drivers/i915simple/i915_strings.c
index 301fedea19..ee62bb2e5d 100644
--- a/src/gallium/drivers/i915simple/i915_strings.c
+++ b/src/gallium/drivers/i915simple/i915_strings.c
@@ -26,21 +26,31 @@
  **************************************************************************/
 
 #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;
+}
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 7fcf4332e1..3c9509dee3 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -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;
+}
diff --git a/src/gallium/drivers/i915simple/i915_texture.h b/src/gallium/drivers/i915simple/i915_texture.h
index 6d8d41178f..7225016a9f 100644
--- a/src/gallium/drivers/i915simple/i915_texture.h
+++ b/src/gallium/drivers/i915simple/i915_texture.h
@@ -28,11 +28,16 @@
 #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 */
diff --git a/src/gallium/drivers/i915simple/i915_winsys.h b/src/gallium/drivers/i915simple/i915_winsys.h
index fe49710852..e6b0ac9c52 100644
--- a/src/gallium/drivers/i915simple/i915_winsys.h
+++ b/src/gallium/drivers/i915simple/i915_winsys.h
@@ -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 
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index f69b52f5e3..93fcb1c3e9 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -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) */
 
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 21d4827e67..a7e97fcd7d 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -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
index 0000000000..6be9a82b68
--- /dev/null
+++ b/src/gallium/include/pipe/p_screen.h
@@ -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 */
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 25a6fcc9e6..bb4a6cb23e 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -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;
 };
 
 
diff --git a/src/gallium/winsys/dri/intel/intel_winsys_i915.c b/src/gallium/winsys/dri/intel/intel_winsys_i915.c
index 0ed3890e93..2def1afc31 100644
--- a/src/gallium/winsys/dri/intel/intel_winsys_i915.c
+++ b/src/gallium/winsys/dri/intel/intel_winsys_i915.c
@@ -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 );
 }
-- 
cgit v1.2.3


From d8bf051c8b4a1ebe44895413a109d4ab898f7579 Mon Sep 17 00:00:00 2001
From: Brian <brian@i915.localnet.net>
Date: Wed, 27 Feb 2008 18:49:35 -0700
Subject: gallium: remove unneeded pipe ptr from pipe_texture

---
 src/gallium/include/pipe/p_state.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

(limited to 'src/gallium/include/pipe/p_state.h')

diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index bb4a6cb23e..5fab41acbd 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -161,6 +161,7 @@ struct pipe_constant_buffer
 struct pipe_shader_state
 {
    const struct tgsi_token *tokens;
+   /* XXX these are going away */
    ubyte num_inputs;
    ubyte num_outputs;
    ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
@@ -276,8 +277,7 @@ struct pipe_surface
 
 
 /**
- * Texture. Represents one or several texture images on one or several mipmap
- * levels.
+ * Texture object.
  */
 struct pipe_texture
 { 
@@ -298,11 +298,7 @@ struct pipe_texture
     */
    unsigned refcount;
 
-   /**< pipe that created the texture
-    * XXX this'll change to a pipe_winsys (or pipe_screen)...
-    */
-   struct pipe_context *pipe;
-   struct pipe_screen *screen;
+   struct pipe_screen *screen; /**< screen that this texture belongs to */
 };
 
 
-- 
cgit v1.2.3