gallium: minor re-org of 915 surface/texture code
authorBrian <brian.paul@tungstengraphics.com>
Wed, 20 Feb 2008 21:00:42 +0000 (14:00 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 20 Feb 2008 21:00:42 +0000 (14:00 -0700)
src/gallium/drivers/i915simple/i915_context.c
src/gallium/drivers/i915simple/i915_surface.c
src/gallium/drivers/i915simple/i915_texture.c
src/gallium/drivers/i915simple/i915_texture.h

index 97773f1..acfa349 100644 (file)
@@ -296,13 +296,11 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
    i915_init_state_functions(i915);
    i915_init_flush_functions(i915);
    i915_init_string_functions(i915);
+   i915_init_texture_functions(i915);
 
    i915->pci_id = pci_id;
    i915->flags.is_i945 = is_i945;
 
-   i915->pipe.texture_create = i915_texture_create;
-   i915->pipe.texture_release = i915_texture_release;
-   i915->pipe.texture_update = i915_texture_update;
 
    i915->dirty = ~0;
    i915->hardware_dirty = ~0;
index 17fd278..f4fbedb 100644 (file)
 #include "util/p_tile.h"
 
 
-/*
- * 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)
-{
-   struct i915_texture *tex = (struct i915_texture *)pt;
-   struct pipe_surface *ps;
-   unsigned offset;  /* in bytes */
-
-   offset = tex->level_offset[level];
-
-   if (pt->target == PIPE_TEXTURE_CUBE) {
-      offset += tex->image_offset[level][face] * pt->cpp;
-   }
-   else if (pt->target == PIPE_TEXTURE_3D) {
-      offset += tex->image_offset[level][zslice] * pt->cpp;
-   }
-   else {
-      assert(face == 0);
-      assert(zslice == 0);
-   }
-
-   ps = pipe->winsys->surface_alloc(pipe->winsys);
-   if (ps) {
-      assert(ps->refcount);
-      assert(ps->winsys);
-      pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
-      ps->format = pt->format;
-      ps->cpp = pt->cpp;
-      ps->width = pt->width[level];
-      ps->height = pt->height[level];
-      ps->pitch = tex->pitch;
-      ps->offset = offset;
-   }
-   return ps;
-}
-
-
-
 /* Assumes all values are within bounds -- no checking at this level -
  * do it higher up if required.
  */
@@ -115,6 +73,7 @@ i915_surface_copy(struct pipe_context *pipe,
    }
 }
 
+
 /* Fill a rectangular sub-region.  Need better logic about when to
  * push buffers into AGP - will currently do so whenever possible.
  */
@@ -184,8 +143,6 @@ i915_surface_fill(struct pipe_context *pipe,
 void
 i915_init_surface_functions(struct i915_context *i915)
 {
-   i915->pipe.get_tex_surface = i915_get_tex_surface;
-
    i915->pipe.surface_copy = i915_surface_copy;
    i915->pipe.surface_fill = i915_surface_fill;
 }
index 4ba76d1..b235fae 100644 (file)
@@ -478,7 +478,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
 }
 
 
-struct pipe_texture *
+static struct pipe_texture *
 i915_texture_create(struct pipe_context *pipe,
                     const struct pipe_texture *templat)
 {
@@ -506,7 +506,7 @@ i915_texture_create(struct pipe_context *pipe,
 }
 
 
-void
+static void
 i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
 {
    if (!*pt)
@@ -536,8 +536,60 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
 }
 
 
-void
+static void
 i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
 {
    /* no-op? */
 }
+
+
+/*
+ * 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)
+{
+   struct i915_texture *tex = (struct i915_texture *)pt;
+   struct pipe_surface *ps;
+   unsigned offset;  /* in bytes */
+
+   offset = tex->level_offset[level];
+
+   if (pt->target == PIPE_TEXTURE_CUBE) {
+      offset += tex->image_offset[level][face] * pt->cpp;
+   }
+   else if (pt->target == PIPE_TEXTURE_3D) {
+      offset += tex->image_offset[level][zslice] * pt->cpp;
+   }
+   else {
+      assert(face == 0);
+      assert(zslice == 0);
+   }
+
+   ps = pipe->winsys->surface_alloc(pipe->winsys);
+   if (ps) {
+      assert(ps->refcount);
+      assert(ps->winsys);
+      pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+      ps->format = pt->format;
+      ps->cpp = pt->cpp;
+      ps->width = pt->width[level];
+      ps->height = pt->height[level];
+      ps->pitch = tex->pitch;
+      ps->offset = offset;
+   }
+   return ps;
+}
+
+
+
+void
+i915_init_texture_functions(struct i915_context *i915)
+{
+   i915->pipe.texture_create = i915_texture_create;
+   i915->pipe.texture_release = i915_texture_release;
+   i915->pipe.texture_update = i915_texture_update;
+   i915->pipe.get_tex_surface = i915_get_tex_surface;
+}
index 0312977..6d8d411 100644 (file)
@@ -1,21 +1,38 @@
+/**************************************************************************
+ * 
+ * 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_TEXTURE_H
 #define I915_TEXTURE_H
 
 struct pipe_context;
-struct pipe_texture;
-
-
-struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
-                    const struct pipe_texture *templat);
-
-extern void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
 
 
 extern void
-i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture);
+i915_init_texture_functions(struct i915_context *i915);
 
 
 #endif /* I915_TEXTURE_H */