gallium: remove pipe_buffer from surfaces
authorZack Rusin <zackr@vmware.com>
Tue, 3 Feb 2009 04:47:16 +0000 (23:47 -0500)
committerZack Rusin <zackr@vmware.com>
Tue, 3 Feb 2009 04:47:16 +0000 (23:47 -0500)
this change disassociates, at least from the driver perspective,
the surface from buffer. surfaces are technically now views on the
textures so make it so by hiding the buffer in the internals of
textures.

40 files changed:
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/drivers/i915simple/i915_screen.c
src/gallium/drivers/i915simple/i915_state_emit.c
src/gallium/drivers/i915simple/i915_surface.c
src/gallium/drivers/i915simple/i915_texture.c
src/gallium/drivers/i965simple/brw_misc_state.c
src/gallium/drivers/i965simple/brw_surface.c
src/gallium/drivers/i965simple/brw_tex_layout.c
src/gallium/drivers/i965simple/brw_wm_surface_state.c
src/gallium/drivers/nv04/nv04_miptree.c
src/gallium/drivers/nv04/nv04_screen.c
src/gallium/drivers/nv04/nv04_state_emit.c
src/gallium/drivers/nv10/nv10_miptree.c
src/gallium/drivers/nv10/nv10_screen.c
src/gallium/drivers/nv10/nv10_state_emit.c
src/gallium/drivers/nv20/nv20_miptree.c
src/gallium/drivers/nv20/nv20_screen.c
src/gallium/drivers/nv20/nv20_state_emit.c
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv30/nv30_state_fb.c
src/gallium/drivers/nv40/nv40_miptree.c
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/nv40/nv40_state_fb.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_tile_cache.c
src/gallium/drivers/trace/tr_state.c
src/gallium/include/pipe/p_state.h
src/gallium/winsys/egl_xlib/egl_xlib.c
src/gallium/winsys/xlib/Makefile
src/gallium/winsys/xlib/xlib_brw_screen.c
src/gallium/winsys/xlib/xlib_cell.c
src/gallium/winsys/xlib/xlib_softpipe.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_gen_mipmap.c

index 301a58ed7b956bd44db010a284b61cf65be57bdf..2b4cdab6cf3ca85583a5fb5c39c8140fdcfe2c51 100644 (file)
@@ -1125,19 +1125,19 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_READ)
+      srcMap = ((ubyte *) pipe_surface_map(srcSurf,
+                                           PIPE_BUFFER_USAGE_CPU_READ)
                 + srcSurf->offset);
-      dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstMap = ((ubyte *) pipe_surface_map(dstSurf,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE)
                 + dstSurf->offset);
 
       reduce_1d(pt->format,
                 srcSurf->width, srcMap,
                 dstSurf->width, dstMap);
 
-      pipe_buffer_unmap(screen, srcSurf->buffer);
-      pipe_buffer_unmap(screen, dstSurf->buffer);
+      pipe_surface_unmap(srcSurf);
+      pipe_surface_unmap(dstSurf);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);
@@ -1168,11 +1168,11 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_READ)
+      srcMap = ((ubyte *) pipe_surface_map(srcSurf,
+                                           PIPE_BUFFER_USAGE_CPU_READ)
                 + srcSurf->offset);
-      dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstMap = ((ubyte *) pipe_surface_map(dstSurf,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE)
                 + dstSurf->offset);
 
       reduce_2d(pt->format,
@@ -1181,8 +1181,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
                 dstSurf->width, dstSurf->height,
                 dstSurf->stride, dstMap);
 
-      pipe_buffer_unmap(screen, srcSurf->buffer);
-      pipe_buffer_unmap(screen, dstSurf->buffer);
+      pipe_surface_unmap(srcSurf);
+      pipe_surface_unmap(dstSurf);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);
@@ -1212,11 +1212,11 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_READ)
+      srcMap = ((ubyte *) pipe_surface_map(srcSurf,
+                                           PIPE_BUFFER_USAGE_CPU_READ)
                 + srcSurf->offset);
-      dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstMap = ((ubyte *) pipe_surface_map(dstSurf,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE)
                 + dstSurf->offset);
 
 #if 0
@@ -1229,8 +1229,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
       (void) reduce_3d;
 #endif
 
-      pipe_buffer_unmap(screen, srcSurf->buffer);
-      pipe_buffer_unmap(screen, dstSurf->buffer);
+      pipe_surface_unmap(srcSurf);
+      pipe_surface_unmap(dstSurf);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);
index 5bb127f3d54810e925874a5be420267d6874c089..39e48105b3e6d3ca61133e236706f29396c7f782 100644 (file)
@@ -209,7 +209,8 @@ i915_surface_map( struct pipe_screen *screen,
                   struct pipe_surface *surface,
                   unsigned flags )
 {
-   char *map = pipe_buffer_map( screen, surface->buffer, flags );
+   struct i915_texture *tex = (struct i915_texture *)surface->texture;
+   char *map = pipe_buffer_map( screen, tex->buffer, flags );
    if (map == NULL)
       return NULL;
 
@@ -228,7 +229,8 @@ static void
 i915_surface_unmap(struct pipe_screen *screen,
                    struct pipe_surface *surface)
 {
-   pipe_buffer_unmap( screen, surface->buffer );
+   struct i915_texture *tex = (struct i915_texture *)surface->texture;
+   pipe_buffer_unmap( screen, tex->buffer );
 }
 
 
index 9bd6f92323d09129b85ff8f53c024159881e2a2d..6558cf1c3e5bb90a5afa2f9c9375d346e88d9927 100644 (file)
@@ -213,18 +213,22 @@ i915_emit_hardware_state(struct i915_context *i915 )
       if (cbuf_surface) {
         unsigned cpitch = cbuf_surface->stride;
         unsigned ctile = BUF_3D_USE_FENCE;
-        if (cbuf_surface->texture &&
-              ((struct i915_texture*)(cbuf_surface->texture))->tiled) {
+         struct i915_texture *tex = (struct i915_texture *)
+                                    cbuf_surface->texture;
+         struct pipe_buffer *buffer = tex->buffer;
+         assert(tex);
+
+        if (tex && tex->tiled) {
            ctile = BUF_3D_TILED_SURFACE;
         }
 
         OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
 
-        OUT_BATCH(BUF_3D_ID_COLOR_BACK | 
+        OUT_BATCH(BUF_3D_ID_COLOR_BACK |
                   BUF_3D_PITCH(cpitch) |  /* pitch in bytes */
                   ctile);
 
-        OUT_RELOC(cbuf_surface->buffer,
+        OUT_RELOC(tex->buffer,
                   I915_BUFFER_ACCESS_WRITE,
                   cbuf_surface->offset);
       }
@@ -234,8 +238,12 @@ i915_emit_hardware_state(struct i915_context *i915 )
       if (depth_surface) {
         unsigned zpitch = depth_surface->stride;
         unsigned ztile = BUF_3D_USE_FENCE;
-        if (depth_surface->texture &&
-              ((struct i915_texture*)(depth_surface->texture))->tiled) {
+         struct i915_texture *tex = (struct i915_texture *)
+                                    depth_surface->texture;
+         struct pipe_buffer *buffer = tex->buffer;
+         assert(tex);
+
+        if (tex && tex->tiled) {
            ztile = BUF_3D_TILED_SURFACE;
         }
 
@@ -245,7 +253,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                   BUF_3D_PITCH(zpitch) |  /* pitch in bytes */
                   ztile);
 
-        OUT_RELOC(depth_surface->buffer,
+        OUT_RELOC(tex->buffer,
                   I915_BUFFER_ACCESS_WRITE,
                   depth_surface->offset);
       }
index 5ffdb76682c56aeb3ced0596587d8a1a5e5077eb..94e2deaf6155db422209ffe88ac951104df56283 100644 (file)
@@ -74,13 +74,15 @@ i915_surface_copy(struct pipe_context *pipe,
       pipe->screen->surface_unmap(pipe->screen, dst);
    }
    else {
+      struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
+      struct i915_texture *src_tex = (struct i915_texture *)src->texture;
       assert(dst->block.width == 1);
       assert(dst->block.height == 1);
       i915_copy_blit( i915_context(pipe),
                       do_flip,
                       dst->block.size,
-                     (unsigned short) src->stride, src->buffer, src->offset,
-                     (unsigned short) dst->stride, dst->buffer, dst->offset,
+                     (unsigned short) src->stride, src_tex->buffer, src->offset,
+                     (unsigned short) dst->stride, dst_tex->buffer, dst->offset,
                      (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
    }
 }
@@ -102,12 +104,13 @@ i915_surface_fill(struct pipe_context *pipe,
       pipe->screen->surface_unmap(pipe->screen, dst);
    }
    else {
+      struct i915_texture *tex = (struct i915_texture *)dst->texture;
       assert(dst->block.width == 1);
       assert(dst->block.height == 1);
       i915_fill_blit( i915_context(pipe),
                      dst->block.size,
                      (unsigned short) dst->stride,
-                     dst->buffer, dst->offset,
+                     tex->buffer, dst->offset,
                      (short) dstx, (short) dsty,
                      (short) width, (short) height,
                      value );
index 803ef3a18712796c8601f6199018e341a7ea0cb0..b2ca3a2286bd0c132ecae580825c4b6254a05edf 100644 (file)
@@ -683,7 +683,6 @@ i915_get_tex_surface(struct pipe_screen *screen,
    if (ps) {
       ps->refcount = 1;
       pipe_texture_reference(&ps->texture, pt);
-      pipe_buffer_reference(screen, &ps->buffer, tex->buffer);
       ps->format = pt->format;
       ps->width = pt->width[level];
       ps->height = pt->height[level];
@@ -755,7 +754,6 @@ i915_tex_surface_release(struct pipe_screen *screen,
       }
 
       pipe_texture_reference(&surf->texture, NULL);
-      pipe_buffer_reference(screen, &surf->buffer, NULL);
       FREE(surf);
    }
 
index be812c5da92f67dc92c8dd380a8438502c1b104a..99ff4403a59e56acd52ab644b799fab4580fafac 100644 (file)
@@ -223,7 +223,7 @@ static void upload_depthbuffer(struct brw_context *brw)
       OUT_BATCH(0);
    } else {
       unsigned int format;
-
+      struct brw_texture *tex = (struct brw_texture *)depth_surface->texture;
       assert(depth_surface->block.width == 1);
       assert(depth_surface->block.height == 1);
       switch (depth_surface->block.size) {
@@ -246,7 +246,7 @@ static void upload_depthbuffer(struct brw_context *brw)
                (BRW_TILEWALK_YMAJOR << 26) |
 //             (depth_surface->region->tiled << 27) |
                (BRW_SURFACE_2D << 29));
-      OUT_RELOC(depth_surface->buffer,
+      OUT_RELOC(tex->buffer,
                PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE, 0);
       OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |
                ((depth_surface->stride/depth_surface->block.size - 1) << 6) |
index 3159eba2fd185b8928ac920d9ee2a8c1e46e7bab..0a95dce1940c264a553b87bd6ec3ae2ad0780ed5 100644 (file)
@@ -74,13 +74,15 @@ brw_surface_copy(struct pipe_context *pipe,
       pipe->screen->surface_unmap(pipe->screen, dst);
    }
    else {
+      struct brw_texture *dst_tex = (struct brw_texture *)dst->texture;
+      struct brw_texture *src_tex = (struct brw_texture *)src->texture;
       assert(dst->block.width == 1);
       assert(dst->block.height == 1);
       brw_copy_blit(brw_context(pipe),
                     do_flip,
                     dst->block.size,
-                    (short) src->stride/src->block.size, src->buffer, src->offset, FALSE,
-                    (short) dst->stride/dst->block.size, dst->buffer, dst->offset, FALSE,
+                    (short) src->stride/src->block.size, src_tex->buffer, src->offset, FALSE,
+                    (short) dst->stride/dst->block.size, dst_tex->buffer, dst->offset, FALSE,
                     (short) srcx, (short) srcy, (short) dstx, (short) dsty,
                     (short) width, (short) height, PIPE_LOGICOP_COPY);
    }
@@ -103,12 +105,13 @@ brw_surface_fill(struct pipe_context *pipe,
       pipe->screen->surface_unmap(pipe->screen, dst);
    }
    else {
+      struct brw_texture *tex = (struct brw_texture *)dst->texture;
       assert(dst->block.width == 1);
       assert(dst->block.height == 1);
       brw_fill_blit(brw_context(pipe),
                     dst->block.size,
                     (short) dst->stride/dst->block.size, 
-                    dst->buffer, dst->offset, FALSE,
+                    tex->buffer, dst->offset, FALSE,
                     (short) dstx, (short) dsty,
                     (short) width, (short) height,
                     value);
index 6af0d5cf4b26341846efeee1aa4646892f192971..448229ed4ee329719a0b59f1c32fff247c664cf6 100644 (file)
@@ -367,7 +367,6 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
    if (ps) {
       ps->refcount = 1;
       pipe_texture_reference(&ps->texture, pt);
-      pipe_buffer_reference(screen, &ps->buffer, tex->buffer);
       ps->format = pt->format;
       ps->width = pt->width[level];
       ps->height = pt->height[level];
index 1a326f99186c93a5097006dedc88f5952b9030b5..1bab5bfdb3a9e5f5cf19f5bf6e6e8a3f726c48f0 100644 (file)
@@ -193,6 +193,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
       /* BRW_NEW_FRAMEBUFFER
        */
       struct pipe_surface *pipe_surface = brw->attribs.FrameBuffer.cbufs[0];/*fixme*/
+      struct brw_texture *tex = (struct brw_texture *)pipe_surface->texture;
 
       memset(&surf, 0, sizeof(surf));
 
@@ -204,7 +205,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
 
         surf.ss0.surface_type = BRW_SURFACE_2D;
 
-        surf.ss1.base_addr = brw_buffer_offset( brw, pipe_surface->buffer );
+        surf.ss1.base_addr = brw_buffer_offset( brw, tex->buffer );
 
         surf.ss2.width = pipe_surface->width - 1;
         surf.ss2.height = pipe_surface->height - 1;
index 01cb8ecbf316dfe3cddd09535520047f234d306c..0575dc0afc20c03e27315c8b8dd56d9331c5bf7d 100644 (file)
@@ -107,7 +107,6 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(pscreen, &ps->buffer, nv04mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
@@ -138,7 +137,6 @@ nv04_miptree_surface_del(struct pipe_screen *pscreen,
                return;
 
        pipe_texture_reference(&ps->texture, NULL);
-       pipe_buffer_reference(pscreen->winsys, &ps->buffer, NULL);
        FREE(ps);
 }
 
index 2ae67840770c40a06969730beb1fdd4a50b22a29..e5e3d4772aaa055b48880f52869b69aaedd4c8f7 100644 (file)
@@ -1,4 +1,5 @@
 #include "pipe/p_screen.h"
+#include "pipe/p_inlines.h"
 #include "util/u_simple_screen.h"
 
 #include "nv04_context.h"
@@ -122,10 +123,10 @@ static void *
 nv04_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
                 unsigned flags )
 {
-       struct pipe_winsys *ws = screen->winsys;
        void *map;
+       struct nv04_miptree *nv04mt = (struct nv04_miptree *)surface->texture;
 
-       map = ws->buffer_map(ws, surface->buffer, flags);
+       map = pipe_buffer_map(screen, nv04mt->buffer, flags);
        if (!map)
                return NULL;
 
@@ -135,9 +136,9 @@ nv04_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
 static void
 nv04_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
-       struct pipe_winsys *ws = screen->winsys;
+       struct nv04_miptree *nv04mt = (struct nv04_miptree *)surface->texture;
 
-       ws->buffer_unmap(ws, surface->buffer);
+       pipe_buffer_unmap(screen, nv04mt->buffer);
 }
 
 static void
index 26491758a01935fc6de56c23b63a614830aac80e..bd8ef1adbff38e54397da68c436091aec5ecc1e8 100644 (file)
@@ -96,6 +96,7 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
        struct pipe_surface *rt, *zeta;
        uint32_t rt_format, w, h;
        int colour_format = 0, zeta_format = 0;
+       struct nv04_miptree *nv04mt = 0;
 
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
@@ -129,14 +130,16 @@ static void nv04_state_emit_framebuffer(struct nv04_context* nv04)
 
        BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
        OUT_RING(rt_format);
-       
+
+       nv04mt = (struct nv04_miptree *)rt->texture;
        /* FIXME pitches have to be aligned ! */
        BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
        OUT_RING(rt->stride|(zeta->stride<<16));
-       OUT_RELOCl(rt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+       OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        if (fb->zsbuf) {
+               nv04mt = (struct nv04_miptree *)zeta->texture;
                BEGIN_RING(context_surfaces_3d, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
-               OUT_RELOCl(zeta->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+               OUT_RELOCl(nv04mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
        }
 }
 
index f8c021261bc9995a0b2aac47bf15c407997a3007..909278213ee12316d1a2468996482333d947d0ee 100644 (file)
@@ -114,7 +114,6 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(screen, &ps->buffer, nv10mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
index 12516fd71e723de1b057f20e9e505ceacb7825fe..2f945a193cce54787d8ea27ab37b564cd644cf35 100644 (file)
@@ -122,8 +122,9 @@ nv10_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
 {
        struct pipe_winsys *ws = screen->winsys;
        void *map;
+        struct nv10_miptree *nv10mt = (struct nv10_miptree *)surface->texture;
 
-       map = ws->buffer_map(ws, surface->buffer, flags);
+       map = ws->buffer_map(ws, nv10mt->buffer, flags);
        if (!map)
                return NULL;
 
@@ -134,8 +135,9 @@ static void
 nv10_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys *ws = screen->winsys;
+        struct nv10_miptree *nv10mt = (struct nv10_miptree *)surface->texture;
 
-       ws->buffer_unmap(ws, surface->buffer);
+       ws->buffer_unmap(ws, nv10mt->buffer);
 }
 
 static void
index 46c7e1d7536b8f15828ad66d0d7e77ee4b5e505f..5dec618b9333202657505f2dddfdcfb884f8279e 100644 (file)
@@ -106,6 +106,7 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
        struct pipe_surface *rt, *zeta = NULL;
        uint32_t rt_format, w, h;
        int colour_format = 0, zeta_format = 0;
+        struct nv10_miptree *nv10mt = 0;
 
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
@@ -147,11 +148,13 @@ static void nv10_state_emit_framebuffer(struct nv10_context* nv10)
                OUT_RING  (rt->stride | (rt->stride << 16));
        }
 
-       nv10->rt[0] = rt->buffer;
+       nv10mt = (struct nv10_miptree *)rt->texture;
+       nv10->rt[0] = nv10mt->buffer;
 
        if (zeta_format)
        {
-               nv10->zeta = zeta->buffer;
+               nv10mt = (struct nv10_miptree *)zeta->texture;
+               nv10->zeta = nv10mt->buffer;
        }
 
        BEGIN_RING(celsius, NV10TCL_RT_HORIZ, 3);
index d2038c391d69e35cb8f6b6294244932f6b456db7..8e4cc809027abd674b30c2fa54d1f795f2328376 100644 (file)
@@ -106,7 +106,6 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(screen, &ps->buffer, nv20mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
@@ -141,7 +140,6 @@ nv20_miptree_surface_release(struct pipe_screen *pscreen,
                return;
 
        pipe_texture_reference(&ps->texture, NULL);
-       pipe_buffer_reference(pscreen, &ps->buffer, NULL);
        FREE(ps);
 }
 
index f09b364b8d9c8499213f16091929878683811db9..c9171fa1781383188c1e1c515464ab2334201299 100644 (file)
@@ -122,8 +122,9 @@ nv20_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
 {
        struct pipe_winsys *ws = screen->winsys;
        void *map;
+       struct nv20_miptree *nv20mt = (struct nv20_miptree *)surface->texture;
 
-       map = ws->buffer_map(ws, surface->buffer, flags);
+       map = ws->buffer_map(ws, nv20mt->buffer, flags);
        if (!map)
                return NULL;
 
@@ -134,8 +135,9 @@ static void
 nv20_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys *ws = screen->winsys;
+       struct nv20_miptree *nv20mt = (struct nv20_miptree *)surface->texture;
 
-       ws->buffer_unmap(ws, surface->buffer);
+       ws->buffer_unmap(ws, nv20mt->buffer);
 }
 
 static void
index ea20078a50a79ca67b26c74ac459689ed822b32c..0f4df9ca317c6f46819ee3002b2a6b410160fb9c 100644 (file)
@@ -112,6 +112,7 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
        struct pipe_surface *rt, *zeta = NULL;
        uint32_t rt_format, w, h;
        int colour_format = 0, zeta_format = 0;
+       struct nv20_miptree *nv20mt = 0;
 
        w = fb->cbufs[0]->width;
        h = fb->cbufs[0]->height;
@@ -153,11 +154,13 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
                OUT_RING  (rt->stride | (rt->stride << 16));
        }
 
-       nv20->rt[0] = rt->buffer;
+       nv20mt = (struct nv20_miptree *)rt->texture;
+       nv20->rt[0] = nv20mt->buffer;
 
        if (zeta_format)
        {
-               nv20->zeta = zeta->buffer;
+               nv20mt = (struct nv20_miptree *)zeta->texture;
+               nv20->zeta = nv20mt->buffer;
        }
 
        BEGIN_RING(kelvin, NV20TCL_RT_HORIZ, 3);
index 79baac714ce1786b3d19ba2c3dab984f1010925f..c55756971b57fefe26feaafc4d0156641938eaf1 100644 (file)
@@ -143,7 +143,6 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(pscreen, &ps->buffer, nv30mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
@@ -181,7 +180,6 @@ nv30_miptree_surface_del(struct pipe_screen *pscreen,
                return;
 
        pipe_texture_reference(&ps->texture, NULL);
-       pipe_buffer_reference(pscreen, &ps->buffer, NULL);
        FREE(ps);
 }
 
index 0f10d914ad2b06df07de9d25a7dcdd28b3b6d00d..9738436dc47a31e8907d739a115762d420c6ba6f 100644 (file)
@@ -134,6 +134,7 @@ nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_map;
        void                    *map;
+       struct nv30_miptree *nv30mt = (struct nv30_miptree *)surface->texture;
 
        if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
                struct nv30_miptree *mt = (struct nv30_miptree *)surface->texture;
@@ -162,7 +163,7 @@ nv30_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
 
        assert(surface_to_map);
 
-       map = ws->buffer_map(ws, surface_to_map->buffer, flags);
+       map = ws->buffer_map(ws, nv30mt->buffer, flags);
        if (!map)
                return NULL;
 
@@ -174,6 +175,7 @@ nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_unmap;
+       struct nv30_miptree *nv30mt = (struct nv30_miptree *)surface->texture;
 
        /* TODO: Copy from shadow just before push buffer is flushed instead.
                 There are probably some programs that map/unmap excessively
@@ -190,7 +192,7 @@ nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 
        assert(surface_to_unmap);
 
-       ws->buffer_unmap(ws, surface_to_unmap->buffer);
+       ws->buffer_unmap(ws, nv30mt->buffer);
 
        if (surface_to_unmap != surface) {
                struct nv30_screen *nvscreen = nv30_screen(screen);
index 8536acc5701238da3128fe73c82f28ef2bf81afd..77368cb20553341a36ef68fa268abfd8d8142352 100644 (file)
@@ -12,6 +12,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
        unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
        unsigned w = fb->width;
        unsigned h = fb->height;
+       struct nv30_miptree *nv30mt;
 
        rt_enable = 0;
        for (i = 0; i < fb->nr_cbufs; i++) {
@@ -77,34 +78,37 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
                        pitch |= (pitch << 16);
                }
 
+               nv30mt = (struct nv30_miptree *)rt[0]->texture;
                so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1);
-               so_reloc (so, rt[0]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
                          nv30->nvws->channel->vram->handle,
                          nv30->nvws->channel->gart->handle);
                so_method(so, nv30->screen->rankine, NV34TCL_COLOR0_PITCH, 2);
                so_data  (so, pitch);
-               so_reloc (so, rt[0]->buffer, rt[0]->offset, rt_flags |
+               so_reloc (so, nv30mt->buffer, rt[0]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
        }
 
        if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
+               nv30mt = (struct nv30_miptree *)rt[1]->texture;
                so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR1, 1);
-               so_reloc (so, rt[1]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
                          nv30->nvws->channel->vram->handle,
                          nv30->nvws->channel->gart->handle);
                so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2);
-               so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
+               so_reloc (so, nv30mt->buffer, rt[1]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_data  (so, rt[1]->stride);
        }
 
        if (zeta_format) {
+               nv30mt = (struct nv30_miptree *)zeta->texture;
                so_method(so, nv30->screen->rankine, NV34TCL_DMA_ZETA, 1);
-               so_reloc (so, zeta->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv30mt->buffer, 0, rt_flags | NOUVEAU_BO_OR,
                          nv30->nvws->channel->vram->handle,
                          nv30->nvws->channel->gart->handle);
                so_method(so, nv30->screen->rankine, NV34TCL_ZETA_OFFSET, 1);
-               so_reloc (so, zeta->buffer, zeta->offset, rt_flags |
+               so_reloc (so, nv30mt->buffer, zeta->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                /* TODO: allocate LMA depth buffer */
        }
index ba912ddcbbf9f4728bf0398d5c5e2bee141e3ee9..b1fba11d2fe443950135afbb3c6fb859fe60c6a2 100644 (file)
@@ -144,7 +144,6 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(pscreen, &ps->buffer, mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
@@ -182,7 +181,6 @@ nv40_miptree_surface_del(struct pipe_screen *pscreen,
                return;
 
        pipe_texture_reference(&ps->texture, NULL);
-       pipe_buffer_reference(pscreen, &ps->buffer, NULL);
        FREE(ps);
 }
 
index 46fe133d71cd77bc914be87eb29c0b2dda630162..41d342d27d25afcc5dffe491647d1115b1e66281 100644 (file)
@@ -143,6 +143,7 @@ nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_map;
        void                    *map;
+        struct nv40_miptree *mt;
 
        if (!(surface->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
                struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
@@ -170,8 +171,8 @@ nv40_surface_map(struct pipe_screen *screen, struct pipe_surface *surface,
                surface_to_map = surface;
 
        assert(surface_to_map);
-
-       map = ws->buffer_map(ws, surface_to_map->buffer, flags);
+        mt = (struct nv40_miptree *)surface_to_map->texture;
+       map = ws->buffer_map(ws, mt->buffer, flags);
        if (!map)
                return NULL;
 
@@ -183,6 +184,7 @@ nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 {
        struct pipe_winsys      *ws = screen->winsys;
        struct pipe_surface     *surface_to_unmap;
+        struct nv40_miptree *mt;
 
        /* TODO: Copy from shadow just before push buffer is flushed instead.
                 There are probably some programs that map/unmap excessively
@@ -199,7 +201,8 @@ nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
 
        assert(surface_to_unmap);
 
-       ws->buffer_unmap(ws, surface_to_unmap->buffer);
+        mt = (struct nv40_miptree *)surface_to_unmap->texture;
+       ws->buffer_unmap(ws, mt->buffer);
 
        if (surface_to_unmap != surface) {
                struct nv40_screen *nvscreen = nv40_screen(screen);
index a2e09e18a4e1716c81bfe350913bb6efa3a79959..454abad31f4f33f6ce4cafabde0717a129cdc6c7 100644 (file)
@@ -1,6 +1,13 @@
 #include "nv40_context.h"
 #include "nouveau/nouveau_util.h"
 
+static struct pipe_buffer *
+nv40_surface_buffer(struct pipe_surface *surface)
+{
+       struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
+       return mt->buffer;
+}
+
 static boolean
 nv40_state_framebuffer_validate(struct nv40_context *nv40)
 {
@@ -71,33 +78,33 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
                so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR0, 1);
-               so_reloc (so, rt[0]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv40_surface_buffer(rt[0]), 0, rt_flags | NOUVEAU_BO_OR,
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2);
                so_data  (so, rt[0]->stride);
-               so_reloc (so, rt[0]->buffer, rt[0]->offset, rt_flags |
+               so_reloc (so, nv40_surface_buffer(rt[0]), rt[0]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
                so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR1, 1);
-               so_reloc (so, rt[1]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv40_surface_buffer(rt[1]), 0, rt_flags | NOUVEAU_BO_OR,
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2);
-               so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
+               so_reloc (so, nv40_surface_buffer(rt[1]), rt[1]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_data  (so, rt[1]->stride);
        }
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
                so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR2, 1);
-               so_reloc (so, rt[2]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv40_surface_buffer(rt[2]), 0, rt_flags | NOUVEAU_BO_OR,
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR2_OFFSET, 1);
-               so_reloc (so, rt[2]->buffer, rt[2]->offset, rt_flags |
+               so_reloc (so, nv40_surface_buffer(rt[2]), rt[2]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1);
                so_data  (so, rt[2]->stride);
@@ -105,11 +112,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
 
        if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
                so_method(so, nv40->screen->curie, NV40TCL_DMA_COLOR3, 1);
-               so_reloc (so, rt[3]->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv40_surface_buffer(rt[3]), 0, rt_flags | NOUVEAU_BO_OR,
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR3_OFFSET, 1);
-               so_reloc (so, rt[3]->buffer, rt[3]->offset, rt_flags |
+               so_reloc (so, nv40_surface_buffer(rt[3]), rt[3]->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1);
                so_data  (so, rt[3]->stride);
@@ -117,11 +124,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
 
        if (zeta_format) {
                so_method(so, nv40->screen->curie, NV40TCL_DMA_ZETA, 1);
-               so_reloc (so, zeta->buffer, 0, rt_flags | NOUVEAU_BO_OR,
+               so_reloc (so, nv40_surface_buffer(zeta), 0, rt_flags | NOUVEAU_BO_OR,
                          nv40->nvws->channel->vram->handle,
                          nv40->nvws->channel->gart->handle);
                so_method(so, nv40->screen->curie, NV40TCL_ZETA_OFFSET, 1);
-               so_reloc (so, zeta->buffer, zeta->offset, rt_flags |
+               so_reloc (so, nv40_surface_buffer(zeta), zeta->offset, rt_flags |
                          NOUVEAU_BO_LOW, 0, 0);
                so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1);
                so_data  (so, zeta->stride);
index 061a4c064b62bc843d88ba9595a8b4b795a35805..6c9e18429acd93bb612fe273397c9402f7a7bdfb 100644 (file)
@@ -99,6 +99,13 @@ nv50_surface(struct pipe_surface *pt)
        return (struct nv50_surface *)pt;
 }
 
+static INLINE struct pipe_buffer *
+nv50_surface_buffer(struct pipe_surface *surface)
+{
+       struct nv50_miptree *mt = (struct nv50_miptree *)surface->texture;
+       return mt->buffer;
+}
+
 struct nv50_state {
        unsigned dirty;
 
index 7770fcc3f2aaa904f6feb129544317ecd71650a9..c6e65c981601c7bde87591e596347b1cc457b8d5 100644 (file)
@@ -179,7 +179,7 @@ nv50_miptree_sync(struct pipe_screen *pscreen, struct nv50_miptree *mt,
 }
 
 /* The reverse of the above */
-void
+static void
 nv50_miptree_sync_cpu(struct pipe_screen *pscreen, struct nv50_miptree *mt,
                      unsigned level, unsigned image)
 {
@@ -232,7 +232,6 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        if (!ps)
                return NULL;
        pipe_texture_reference(&ps->texture, pt);
-       pipe_buffer_reference(pscreen, &ps->buffer, mt->buffer);
        ps->format = pt->format;
        ps->width = pt->width[level];
        ps->height = pt->height[level];
@@ -253,7 +252,6 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
                ps->offset = 0;
                pipe_texture_reference(&ps->texture, pt);
-               pipe_buffer_reference(pscreen, &ps->buffer, lvl->image[img]);
 
                if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
                        mark_dirty(lvl->image_dirty_cpu, img);
@@ -262,7 +260,6 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 
                ps->offset = lvl->image_offset[img];
                pipe_texture_reference(&ps->texture, pt);
-               pipe_buffer_reference(pscreen, &ps->buffer, mt->buffer);
 
                if (flags & PIPE_BUFFER_USAGE_GPU_WRITE)
                        mark_dirty(lvl->image_dirty_gpu, img);
@@ -282,7 +279,6 @@ nv50_miptree_surface_del(struct pipe_screen *pscreen,
 
        if (--ps->refcount <= 0) {
                pipe_texture_reference(&ps->texture, NULL);
-               pipe_buffer_reference(pscreen, &ps->buffer, NULL);
                FREE(s);
        }
 }
index 7686f746eb243f6786a626fbd259c56398b88c77..b902c8cf53f3909db0a8464bd425288e583a61ac 100644 (file)
@@ -970,7 +970,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
        }
 
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
-               struct tgsi_full_src_register *fs = &inst->FullSrcRegisters[i];
+               const struct tgsi_full_src_register *fs = &inst->FullSrcRegisters[i];
 
                if (fs->SrcRegister.File == TGSI_FILE_SAMPLER)
                        unit = fs->SrcRegister.Index;
index 4dc4c04493a1064f49e1a5f954f70c11d5dff4c6..602d76ac7439de3dd2f7d5e43336e5d9e3b0d866 100644 (file)
@@ -46,9 +46,9 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                so_data  (so, fb->cbufs[i]->height);
 
                so_method(so, tesla, NV50TCL_RT_ADDRESS_HIGH(i), 5);
-               so_reloc (so, fb->cbufs[i]->buffer, fb->cbufs[i]->offset,
+               so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset,
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH, 0, 0);
-               so_reloc (so, fb->cbufs[i]->buffer, fb->cbufs[i]->offset,
+               so_reloc (so, nv50_surface_buffer(fb->cbufs[i]), fb->cbufs[i]->offset,
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW, 0, 0);
                switch (fb->cbufs[i]->format) {
                case PIPE_FORMAT_A8R8G8B8_UNORM:
@@ -81,9 +81,9 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                }
 
                so_method(so, tesla, NV50TCL_ZETA_ADDRESS_HIGH, 5);
-               so_reloc (so, fb->zsbuf->buffer, fb->zsbuf->offset,
+               so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset,
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_HIGH, 0, 0);
-               so_reloc (so, fb->zsbuf->buffer, fb->zsbuf->offset,
+               so_reloc (so, nv50_surface_buffer(fb->zsbuf), fb->zsbuf->offset,
                          NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW, 0, 0);
                switch (fb->zsbuf->format) {
                case PIPE_FORMAT_Z24S8_UNORM:
index ed6602ba36454a0ffec6fb8e9c1736d77a0de393..8ebbc84817e1b3ce2a88e5d85e799f758fe60e75 100644 (file)
@@ -65,7 +65,7 @@ nv50_surface_map(struct pipe_screen *screen, struct pipe_surface *ps,
 {
        struct pipe_winsys *ws = screen->winsys;
 
-       return ws->buffer_map(ws, ps->buffer, flags);
+       return ws->buffer_map(ws, nv50_surface_buffer(ps), flags);
 }
 
 static void
@@ -73,7 +73,7 @@ nv50_surface_unmap(struct pipe_screen *pscreen, struct pipe_surface *ps)
 {
        struct pipe_winsys *ws = pscreen->winsys;
 
-       ws->buffer_unmap(ws, ps->buffer);
+       ws->buffer_unmap(ws, nv50_surface_buffer(ps));
 }
 
 void
index 5952378152d284ab331dd601371189a018af5fb1..7af839819348f9c7bbb9d97cb3c18e9bcb2501c3 100644 (file)
@@ -211,11 +211,9 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
    assert(level <= pt->last_level);
 
    ps = CALLOC_STRUCT(pipe_surface);
-   ps->refcount = 1;
    if (ps) {
-      assert(ps->refcount);
+      ps->refcount = 1;
       pipe_texture_reference(&ps->texture, pt);
-      pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
       ps->format = pt->format;
       ps->block = pt->block;
       ps->width = pt->width[level];
@@ -225,7 +223,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
       ps->stride = spt->stride[level];
       ps->offset = spt->level_offset[level];
       ps->usage = usage;
-      
+
       /* Because we are softpipe, anything that the state tracker
        * thought was going to be done with the GPU will actually get
        * done with the CPU.  Let's adjust the flags to take that into
@@ -274,8 +272,7 @@ softpipe_tex_surface_release(struct pipe_screen *screen,
     */
    assert ((*s)->texture);
    if (--surf->refcount == 0) {
-      pipe_texture_reference(&surf->texture, NULL); 
-      pipe_buffer_reference(screen, &surf->buffer, NULL);
+      pipe_texture_reference(&surf->texture, NULL);
       FREE(surf);
    }
    *s = NULL;
@@ -288,13 +285,16 @@ softpipe_surface_map( struct pipe_screen *screen,
                       unsigned flags )
 {
    ubyte *map;
+   struct softpipe_texture *spt;
 
    if (flags & ~surface->usage) {
       assert(0);
       return NULL;
    }
 
-   map = pipe_buffer_map( screen, surface->buffer, flags );
+   assert(surface->texture);
+   spt = softpipe_texture(surface->texture);
+   map = pipe_buffer_map(screen, spt->buffer, flags);
    if (map == NULL)
       return NULL;
 
@@ -318,7 +318,12 @@ static void
 softpipe_surface_unmap(struct pipe_screen *screen,
                        struct pipe_surface *surface)
 {
-   pipe_buffer_unmap( screen, surface->buffer );
+   struct softpipe_texture *spt;
+
+   assert(surface->texture);
+   spt = softpipe_texture(surface->texture);
+
+   pipe_buffer_unmap( screen, spt->buffer );
 }
 
 
index 78b0efa46d27c879d74d15c67df909b4c32bc240..ab76009375c9d62156b80e0c75f6acf903fb9bbd 100644 (file)
@@ -369,7 +369,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
    struct pipe_surface *ps = tc->surface;
    int inuse = 0, pos;
 
-   if (ps && ps->buffer) {
+   if (ps) {
       /* caching a drawing surface */
       for (pos = 0; pos < NUM_ENTRIES; pos++) {
          struct softpipe_cached_tile *tile = tc->entries + pos;
index b23ccc1a3da8ae1ffd221db6917cd196bb82e77c..524f2d61948326f4e7158194bc4fb7660b1dc63a 100644 (file)
@@ -397,7 +397,6 @@ void trace_dump_surface(const struct pipe_surface *state)
 
    trace_dump_struct_begin("pipe_surface");
 
-   trace_dump_member(ptr, state, buffer);
    trace_dump_member(format, state, format);
    trace_dump_member(uint, state, status);
    trace_dump_member(uint, state, clear_value);
index 13fa9ba848cd897bf7d446350988e6b53cc04ac5..dd0dfac238d612f7c7769c4a6e44011a48f7ef0d 100644 (file)
@@ -276,7 +276,6 @@ struct pipe_sampler_state
  */
 struct pipe_surface
 {
-   struct pipe_buffer *buffer;   /**< surface's buffer/memory */
    enum pipe_format format;      /**< PIPE_FORMAT_x */
    unsigned status;              /**< PIPE_SURFACE_STATUS_x */
    unsigned clear_value;         /**< XXX may be temporary */
index 4876339107a40b033bc12530a8ab343fc3e64cc6..c6b0e3d8c5fa691c137680806a539e28f8f53ee7 100644 (file)
@@ -41,6 +41,7 @@
 #include "pipe/internal/p_winsys_screen.h"
 #include "util/u_memory.h"
 #include "softpipe/sp_winsys.h"
+#include "softpipe/sp_texture.h"
 
 #include "eglconfig.h"
 #include "eglconfigutil.h"
@@ -292,7 +293,7 @@ display_surface(struct pipe_winsys *pws,
    assert(ximage->format);
    assert(ximage->bitmap_unit);
 
-   data = pws->buffer_map(pws, psurf->buffer, 0);
+   data = pws->buffer_map(pws, softpipe_texture(psurf->texture)->buffer, 0);
 
    /* update XImage's fields */
    ximage->data = data;
@@ -308,7 +309,7 @@ display_surface(struct pipe_winsys *pws,
    ximage->data = NULL;
    XDestroyImage(ximage);
 
-   pws->buffer_unmap(pws, psurf->buffer);
+   pws->buffer_unmap(pws, softpipe_texture(psurf->texture)->buffer);
 }
 
 
index 5b71e6dc38c206564c51938104c9c0460e7b1e8d..8c2892d49b2b582abc78a0d32a5ea2f1cb3dc9a9 100644 (file)
@@ -22,11 +22,11 @@ INCLUDE_DIRS = \
        -I$(TOP)/src/gallium/state_trackers/glx/xlib \
        -I$(TOP)/src/gallium/auxiliary
 
-DEFINES = \
+DEFINES += \
        -DGALLIUM_SOFTPIPE \
-       -DGALLIUM_CELL \
        -DGALLIUM_TRACE \
        -DGALLIUM_BRW
+#-DGALLIUM_CELL will be defined by the config */
 
 XLIB_WINSYS_SOURCES = \
        xlib.c \
index 5344c502ef7476fc04c1f94997dc89af77be4a6e..51740a9af6472cc889f077cb34ee9f12d9d7264f 100644 (file)
 #include "util/u_memory.h"
 #include "i965simple/brw_winsys.h"
 #include "i965simple/brw_screen.h"
+#include "i965simple/brw_context.h"
+
 
 #include "xlib_brw_aub.h"
 #include "xlib_brw.h"
 #include "xlib.h"
 
-
+static struct pipe_buffer *
+buffer_from_surface(struct pipe_surface *surface)
+{
+   struct brw_texture *texture = (struct brw_texture *)surface;
+   return texture->buffer;
+}
 
 struct aub_buffer {
    char *data;
@@ -226,7 +233,7 @@ aub_flush_frontbuffer( struct pipe_winsys *winsys,
 //   struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
    brw_aub_dump_bmp( global_winsys->aubfile, 
                     surface,
-                    aub_bo(surface->buffer)->offset );
+                    aub_bo(buffer_from_surface(surface))->offset );
 }
 
 
@@ -449,7 +456,7 @@ xlib_brw_display_surface(struct xmesa_buffer *b,
 {
    brw_aub_dump_bmp( global_winsys->aubfile, 
                     surf,
-                    aub_bo(surf->buffer)->offset );
+                    aub_bo(buffer_from_surface(surf))->offset );
 }
 
 
index bf69593c5ca29eb7711a2f93dd5f786515c4101d..c87564f4dc1ed168a0ced5b8acaf910453e505eb 100644 (file)
@@ -51,6 +51,7 @@
 #include "cell/ppu/cell_context.h"
 #include "cell/ppu/cell_screen.h"
 #include "cell/ppu/cell_winsys.h"
+#include "cell/ppu/cell_texture.h"
 
 
 /**
@@ -164,7 +165,8 @@ static void
 xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
 {
    XImage *ximage;
-   struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
+   struct xm_buffer *xm_buf = xm_buffer(
+      cell_texture(surf->texture)->buffer);
    const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
    uint x, y;
 
index 01d24584e2b2845bcb06a272f926a1f8315847b3..586e1dfca5de363c6987f02ae914df559ba63661 100644 (file)
@@ -45,6 +45,7 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "softpipe/sp_winsys.h"
+#include "softpipe/sp_texture.h"
 
 #include "xlib.h"
 
@@ -58,7 +59,7 @@ struct xm_buffer
    boolean userBuffer;  /** Is this a user-space buffer? */
    void *data;
    void *mapped;
-   
+
    XImage *tempImage;
    int shm;
    XShmSegmentInfo shminfo;
@@ -225,11 +226,12 @@ xm_buffer_destroy(struct pipe_winsys *pws,
  * by the XMesaBuffer.
  */
 static void
-xlib_softpipe_display_surface(struct xmesa_buffer *b, 
+xlib_softpipe_display_surface(struct xmesa_buffer *b,
                               struct pipe_surface *surf)
 {
    XImage *ximage;
-   struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
+   struct xm_buffer *xm_buf = xm_buffer(
+      softpipe_texture(surf->texture)->buffer);
    static boolean no_swap = 0;
    static boolean firsttime = 1;
 
index d18946de7dcebfa205ed09219f59cc78634f47db..963ac902d2c695f04f6f6e27dd99cfd32e11b6d8 100644 (file)
@@ -171,7 +171,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
                                                   surface_usage );
 
    assert(strb->surface->texture);
-   assert(strb->surface->buffer);
    assert(strb->surface->format);
    assert(strb->surface->block.size);
    assert(strb->surface->block.width);
index 9e5c35072a1bff2bda552c2123de77803787870c..6a3455aaba213ec7d4a921bbd91ea97eb152d066 100644 (file)
@@ -128,11 +128,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcData = (ubyte *) pipe_buffer_map(pipe->screen, srcSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_READ)
+      srcData = (ubyte *) pipe_surface_map(srcSurf,
+                                           PIPE_BUFFER_USAGE_CPU_READ)
               + srcSurf->offset;
-      dstData = (ubyte *) pipe_buffer_map(pipe->screen, dstSurf->buffer,
-                                          PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstData = (ubyte *) pipe_surface_map(dstSurf,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE)
               + dstSurf->offset;
 
       _mesa_generate_mipmap_level(target, datatype, comps,
@@ -144,8 +144,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
                    dstData,
                    dstSurf->stride); /* stride in bytes */
 
-      pipe_buffer_unmap(pipe->screen, srcSurf->buffer);
-      pipe_buffer_unmap(pipe->screen, dstSurf->buffer);
+      pipe_surface_unmap(srcSurf);
+      pipe_surface_unmap(dstSurf);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);