summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2007-12-07 12:30:35 +0100
committerBen Skeggs <skeggsb@gmail.com>2007-12-09 12:05:26 +1100
commit0a44a3fa2f9eb295106cd4c64549f55cc54f432f (patch)
treee4b6a6075dfe37f8ab70505b1cbed33bbb74bece /src/mesa/pipe
parent7f984e1d2ab65a3d34ec0c0ef7487211dd644561 (diff)
Eliminate struct pipe_region.
Directly use struct pipe_buffer_handle for storage and struct pipe_surface for (un)mapping.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/failover/fo_context.c2
-rw-r--r--src/mesa/pipe/i915simple/Makefile1
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c1
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h6
-rw-r--r--src/mesa/pipe/i915simple/i915_regions.c78
-rw-r--r--src/mesa/pipe/i915simple/i915_state_emit.c6
-rw-r--r--src/mesa/pipe/i915simple/i915_surface.c35
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c17
-rw-r--r--src/mesa/pipe/p_context.h10
-rw-r--r--src/mesa/pipe/p_inlines.h53
-rw-r--r--src/mesa/pipe/p_state.h22
-rw-r--r--src/mesa/pipe/softpipe/Makefile1
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c84
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_region.c79
-rw-r--r--src/mesa/pipe/softpipe/sp_region.h40
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h2
-rw-r--r--src/mesa/pipe/softpipe/sp_state_surface.c28
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c61
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c18
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c24
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.h6
-rw-r--r--src/mesa/pipe/xlib/xm_api.c2
-rw-r--r--src/mesa/pipe/xlib/xm_buffer.c9
-rw-r--r--src/mesa/pipe/xlib/xm_surface.c8
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c50
27 files changed, 186 insertions, 463 deletions
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c
index a25563d451..a1291f583b 100644
--- a/src/mesa/pipe/failover/fo_context.c
+++ b/src/mesa/pipe/failover/fo_context.c
@@ -140,8 +140,6 @@ struct pipe_context *failover_create( struct pipe_context *hw,
#endif
failover->pipe.get_tex_surface = hw->get_tex_surface;
- failover->pipe.region_map = hw->region_map;
- failover->pipe.region_unmap = hw->region_unmap;
failover->pipe.surface_data = hw->surface_data;
failover->pipe.surface_copy = hw->surface_copy;
failover->pipe.surface_fill = hw->surface_fill;
diff --git a/src/mesa/pipe/i915simple/Makefile b/src/mesa/pipe/i915simple/Makefile
index 1223b386a3..2f91de3afc 100644
--- a/src/mesa/pipe/i915simple/Makefile
+++ b/src/mesa/pipe/i915simple/Makefile
@@ -12,7 +12,6 @@ DRIVER_SOURCES = \
i915_context.c \
i915_debug.c \
i915_debug_fp.c \
- i915_regions.c \
i915_state.c \
i915_state_immediate.c \
i915_state_dynamic.c \
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index 94649231cf..07b331c528 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -348,7 +348,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
draw_set_rasterize_stage(i915->draw, i915_draw_render_stage(i915));
}
- i915_init_region_functions(i915);
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
i915_init_flush_functions(i915);
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 8ed3465be2..dbf0c885cc 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -175,7 +175,7 @@ struct i915_texture {
/* The data is held here:
*/
- struct pipe_region *region;
+ struct pipe_buffer_handle *buffer;
};
struct i915_context
@@ -289,10 +289,10 @@ void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
/***********************************************************************
- * i915_region.c:
+ * i915_surface.c:
*/
-void i915_init_region_functions( struct i915_context *i915 );
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 );
diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c
deleted file mode 100644
index 82fdec83d0..0000000000
--- a/src/mesa/pipe/i915simple/i915_regions.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 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.
- *
- **************************************************************************/
-
-/* Provide additional functionality on top of bufmgr buffers:
- * - 2d semantics and blit operations (XXX: remove/simplify blits??)
- * - refcounting of buffers for multiple images in a buffer.
- * - refcounting of buffer mappings.
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_winsys.h"
-#include "i915_context.h"
-
-
-
-
-static ubyte *
-i915_region_map(struct pipe_context *pipe, struct pipe_region *region)
-{
- struct i915_context *i915 = i915_context( pipe );
-
- if (!region->map_refcount++) {
- region->map = i915->pipe.winsys->buffer_map( i915->pipe.winsys,
- region->buffer,
- PIPE_BUFFER_FLAG_WRITE |
- PIPE_BUFFER_FLAG_READ);
- }
-
- return region->map;
-}
-
-static void
-i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
-{
- struct i915_context *i915 = i915_context( pipe );
-
- if (region->map_refcount > 0) {
- assert(region->map);
- if (!--region->map_refcount) {
- i915->pipe.winsys->buffer_unmap( i915->pipe.winsys,
- region->buffer );
- region->map = NULL;
- }
- }
-}
-
-
-void
-i915_init_region_functions(struct i915_context *i915)
-{
- i915->pipe.region_map = i915_region_map;
- i915->pipe.region_unmap = i915_region_unmap;
-}
-
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c
index 900a91d896..eda40d7c76 100644
--- a/src/mesa/pipe/i915simple/i915_state_emit.c
+++ b/src/mesa/pipe/i915simple/i915_state_emit.c
@@ -220,7 +220,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
BUF_3D_PITCH(pitch) | /* pitch in bytes */
BUF_3D_USE_FENCE);
- OUT_RELOC(cbuf_surface->region->buffer,
+ OUT_RELOC(cbuf_surface->buffer,
I915_BUFFER_ACCESS_WRITE,
0);
}
@@ -236,7 +236,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
BUF_3D_PITCH(zpitch) | /* pitch in bytes */
BUF_3D_USE_FENCE);
- OUT_RELOC(depth_surface->region->buffer,
+ OUT_RELOC(depth_surface->buffer,
I915_BUFFER_ACCESS_WRITE,
0);
}
@@ -284,7 +284,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
for (unit = 0; unit < I915_TEX_UNITS; unit++) {
if (enabled & (1 << unit)) {
struct pipe_buffer_handle *buf =
- i915->texture[unit]->region->buffer;
+ i915->texture[unit]->buffer;
uint offset = 0;
assert(buf);
diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c
index 385202507d..ecbabe50eb 100644
--- a/src/mesa/pipe/i915simple/i915_surface.c
+++ b/src/mesa/pipe/i915simple/i915_surface.c
@@ -29,6 +29,7 @@
#include "i915_blit.h"
#include "i915_state.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
@@ -57,7 +58,7 @@ i915_get_tile_rgba(struct pipe_context *pipe,
uint x, uint y, uint w, uint h, float *p)
{
const unsigned *src
- = ((const unsigned *) (ps->region->map + ps->offset))
+ = ((const unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -129,7 +130,7 @@ i915_get_tile(struct pipe_context *pipe,
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
CLIP_TILE;
@@ -137,7 +138,7 @@ i915_get_tile(struct pipe_context *pipe,
dst_stride = w0 * cpp;
}
- pSrc = ps->region->map + ps->offset + (y * ps->pitch + x) * cpp;
+ pSrc = ps->map + (y * ps->pitch + x) * cpp;
pDest = (ubyte *) p;
for (i = 0; i < h; i++) {
@@ -163,7 +164,7 @@ i915_put_tile(struct pipe_context *pipe,
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
CLIP_TILE;
@@ -172,7 +173,7 @@ i915_put_tile(struct pipe_context *pipe,
}
pSrc = (const ubyte *) p;
- pDest = ps->region->map + ps->offset + (y * ps->pitch + x) * cpp;
+ pDest = ps->map + (y * ps->pitch + x) * cpp;
for (i = 0; i < h; i++) {
memcpy(pDest, pSrc, w0 * cpp);
@@ -211,7 +212,7 @@ i915_get_tex_surface(struct pipe_context *pipe,
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe_region_reference(&ps->region, tex->region);
+ pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
@@ -274,12 +275,12 @@ i915_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- _mesa_copy_rect(pipe->region_map(pipe, dst->region) + dst->offset,
+ _mesa_copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
- pipe->region_unmap(pipe, dst->region);
+ pipe_surface_unmap(dst);
}
@@ -297,23 +298,23 @@ i915_surface_copy(struct pipe_context *pipe,
assert( dst->cpp == src->cpp );
if (0) {
- _mesa_copy_rect(pipe->region_map(pipe, dst->region) + dst->offset,
+ _mesa_copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty,
width, height,
- pipe->region_map(pipe, src->region) + src->offset,
+ pipe_surface_map(src),
src->pitch,
srcx, srcy);
- pipe->region_unmap(pipe, src->region);
- pipe->region_unmap(pipe, dst->region);
+ pipe_surface_unmap(src);
+ pipe_surface_unmap(dst);
}
else {
i915_copy_blit( i915_context(pipe),
dst->cpp,
- (short) src->pitch, src->region->buffer, src->offset,
- (short) dst->pitch, dst->region->buffer, dst->offset,
+ (short) src->pitch, src->buffer, src->offset,
+ (short) dst->pitch, dst->buffer, dst->offset,
(short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
}
}
@@ -324,7 +325,7 @@ i915_surface_copy(struct pipe_context *pipe,
static ubyte *
get_pointer(struct pipe_surface *dst, unsigned x, unsigned y)
{
- return dst->region->map + (y * dst->pitch + x) * dst->cpp;
+ return dst->map + (y * dst->pitch + x) * dst->cpp;
}
@@ -337,7 +338,7 @@ i915_surface_fill(struct pipe_context *pipe,
if (0) {
unsigned i, j;
- (void)pipe->region_map(pipe, dst->region);
+ (void)pipe_surface_map(dst);
switch (dst->cpp) {
case 1: {
@@ -375,7 +376,7 @@ i915_surface_fill(struct pipe_context *pipe,
i915_fill_blit( i915_context(pipe),
dst->cpp,
(short) dst->pitch,
- dst->region->buffer, dst->offset,
+ dst->buffer, dst->offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
value );
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
index 3bfa806d9e..1ca2815dfb 100644
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ b/src/mesa/pipe/i915simple/i915_texture.c
@@ -33,6 +33,7 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
@@ -494,13 +495,17 @@ i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex)) {
- tex->region = pipe->winsys->region_alloc(pipe->winsys,
- tex->pitch * tex->base.cpp *
- tex->total_height,
- PIPE_SURFACE_FLAG_TEXTURE);
+ tex->buffer = pipe->winsys->buffer_create(pipe->winsys,
+ PIPE_SURFACE_FLAG_TEXTURE);
+
+ if (tex->buffer)
+ pipe->winsys->buffer_data(pipe->winsys, tex->buffer,
+ tex->pitch * tex->base.cpp *
+ tex->total_height, NULL,
+ PIPE_BUFFER_USAGE_PIXEL);
}
- if (!tex->region) {
+ if (!tex->buffer) {
FREE(tex);
tex = NULL;
}
@@ -527,7 +532,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe->winsys->region_release(pipe->winsys, &tex->region);
+ pipe->winsys->buffer_reference(pipe->winsys, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 5033209323..2420d02213 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -37,7 +37,7 @@ struct pipe_state_cache;
* Gallium rendering context. Basically:
* - state setting functions
* - VBO drawing functions
- * - memory region function
+ * - surface functions
* - device queries
*/
struct pipe_context {
@@ -202,14 +202,6 @@ struct pipe_context {
/*
- * Memory region functions
- */
- ubyte *(*region_map)(struct pipe_context *pipe, struct pipe_region *r);
-
- void (*region_unmap)(struct pipe_context *pipe, struct pipe_region *r);
-
-
- /*
* Surface functions
*/
void (*surface_data)(struct pipe_context *pipe,
diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h
index c04d46dddd..1697284b04 100644
--- a/src/mesa/pipe/p_inlines.h
+++ b/src/mesa/pipe/p_inlines.h
@@ -29,40 +29,42 @@
#define P_INLINES_H
#include "p_context.h"
+#include "p_defines.h"
#include "p_winsys.h"
-/**
- * Set 'ptr' to point to 'region' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'region' may be NULL.
- */
+static INLINE ubyte *
+pipe_surface_map(struct pipe_surface *surface)
+{
+ if (!surface->map_refcount++) {
+ surface->map = surface->winsys->buffer_map( surface->winsys,
+ surface->buffer,
+ PIPE_BUFFER_FLAG_WRITE |
+ PIPE_BUFFER_FLAG_READ )
+ + surface->offset;
+ }
+
+ return surface->map;
+}
+
static INLINE void
-pipe_region_reference(struct pipe_region **ptr, struct pipe_region *region)
+pipe_surface_unmap(struct pipe_surface *surface)
{
- assert(ptr);
- if (*ptr) {
- /* unreference the old thing */
- struct pipe_region *oldReg = *ptr;
- assert(oldReg->refcount > 0);
- oldReg->refcount--;
- if (oldReg->refcount == 0) {
- /* free the old region */
- assert(oldReg->map_refcount == 0);
- /* XXX dereference the region->buffer */
- FREE( oldReg );
+ if (surface->map_refcount > 0) {
+ assert(surface->map);
+ if (!--surface->map_refcount) {
+ surface->winsys->buffer_unmap( surface->winsys,
+ surface->buffer );
+ surface->map = NULL;
}
- *ptr = NULL;
- }
- if (region) {
- /* reference the new thing */
- region->refcount++;
- *ptr = region;
}
}
+
/**
- * \sa pipe_region_reference
+ * Set 'ptr' to point to 'surf' and update reference counting.
+ * The old thing pointed to, if any, will be unreferenced first.
+ * 'surf' may be NULL.
*/
static INLINE void
pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
@@ -82,7 +84,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
/**
- * \sa pipe_region_reference
+ * \sa pipe_surface_reference
*/
static INLINE void
pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
@@ -100,4 +102,5 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
}
}
+
#endif /* P_INLINES_H */
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 077a8f5a06..44dec9b773 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -256,32 +256,20 @@ struct pipe_sampler_state
};
-/***
- *** Resource Objects
- ***/
-
-struct pipe_region
-{
- struct pipe_buffer_handle *buffer; /**< driver private buffer handle */
-
- unsigned refcount; /**< Reference count for region */
- ubyte *map; /**< only non-NULL when region is actually mapped */
- unsigned map_refcount; /**< Reference count for mapping */
-};
-
-
/**
- * 2D surface. This is basically a view into a pipe_region (memory buffer).
+ * 2D surface. This is basically a view into a memory buffer.
* May be a renderbuffer, texture mipmap level, etc.
*/
struct pipe_surface
{
- struct pipe_region *region;
+ struct pipe_buffer_handle *buffer; /**< driver private buffer handle */
+ ubyte *map; /**< only non-NULL when surface is actually mapped */
+ unsigned map_refcount; /**< Reference count for mapping */
unsigned format; /**< PIPE_FORMAT_x */
unsigned cpp; /**< bytes per pixel */
unsigned width, height;
unsigned pitch; /**< in pixels */
- unsigned offset; /**< offset from start of region, in bytes */
+ unsigned offset; /**< offset from start of buffer, in bytes */
unsigned refcount;
struct pipe_winsys *winsys; /**< winsys which owns/created the surface */
};
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index 9978884c9b..647cc05373 100644
--- a/src/mesa/pipe/softpipe/Makefile
+++ b/src/mesa/pipe/softpipe/Makefile
@@ -24,7 +24,6 @@ DRIVER_SOURCES = \
sp_quad_output.c \
sp_quad_stencil.c \
sp_quad_stipple.c \
- sp_region.c \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \
diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c
index a4276362b9..496b38fd5f 100644
--- a/src/mesa/pipe/softpipe/sp_clear.c
+++ b/src/mesa/pipe/softpipe/sp_clear.c
@@ -50,12 +50,12 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
softpipe_update_derived(softpipe); /* not needed?? */
- if (ps == sp_tile_cache_get_surface(softpipe->zbuf_cache)) {
+ if (ps == sp_tile_cache_get_surface(softpipe, softpipe->zbuf_cache)) {
float clear[4];
clear[0] = 1.0; /* XXX hack */
sp_tile_cache_clear(softpipe->zbuf_cache, clear);
}
- else if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) {
+ else if (ps == sp_tile_cache_get_surface(softpipe, softpipe->cbuf_cache[0])) {
float clear[4];
clear[0] = 0.2f; /* XXX hack */
clear[1] = 0.2f; /* XXX hack */
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 7a9fccce9a..f7f0316cf2 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -31,12 +31,12 @@
#include "pipe/draw/draw_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
#include "sp_prim_setup.h"
-#include "sp_region.h"
#include "sp_state.h"
#include "sp_surface.h"
#include "sp_tile_cache.h"
@@ -65,44 +65,22 @@ softpipe_is_format_supported( struct pipe_context *pipe, uint format )
void
softpipe_map_surfaces(struct softpipe_context *sp)
{
- struct pipe_context *pipe = &sp->pipe;
+ struct pipe_surface *ps;
unsigned i;
for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
- struct pipe_surface *ps = sp->framebuffer.cbufs[i];
- if (ps->region && !ps->region->map) {
- pipe->region_map(pipe, ps->region);
- }
+ ps = sp->framebuffer.cbufs[i];
+ if (ps->buffer)
+ pipe_surface_map(ps);
}
- if (sp->framebuffer.zbuf) {
- struct pipe_surface *ps = sp->framebuffer.zbuf;
- if (ps->region && !ps->region->map) {
- pipe->region_map(pipe, ps->region);
- }
- }
-
- if (sp->framebuffer.sbuf) {
- struct pipe_surface *ps = sp->framebuffer.sbuf;
- if (ps->region && !ps->region->map) {
- pipe->region_map(pipe, ps->region);
- }
- }
-}
-
+ ps = sp->framebuffer.zbuf;
+ if (ps && ps->buffer)
+ pipe_surface_map(ps);
-void
-softpipe_map_texture_surfaces(struct softpipe_context *sp)
-{
- struct pipe_context *pipe = &sp->pipe;
- uint i;
-
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- struct softpipe_texture *spt = sp->texture[i];
- if (spt) {
- pipe->region_map(pipe, spt->region);
- }
- }
+ ps = sp->framebuffer.sbuf;
+ if (ps && ps->buffer)
+ pipe_surface_map(ps);
}
@@ -112,7 +90,7 @@ softpipe_map_texture_surfaces(struct softpipe_context *sp)
void
softpipe_unmap_surfaces(struct softpipe_context *sp)
{
- struct pipe_context *pipe = &sp->pipe;
+ struct pipe_surface *ps;
uint i;
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
@@ -121,36 +99,18 @@ softpipe_unmap_surfaces(struct softpipe_context *sp)
sp_flush_tile_cache(sp, sp->sbuf_cache);
for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
- struct pipe_surface *ps = sp->framebuffer.cbufs[i];
- if (ps->region)
- pipe->region_unmap(pipe, ps->region);
+ ps = sp->framebuffer.cbufs[i];
+ if (ps->map)
+ pipe_surface_unmap(ps);
}
- if (sp->framebuffer.zbuf) {
- struct pipe_surface *ps = sp->framebuffer.zbuf;
- if (ps->region)
- pipe->region_unmap(pipe, ps->region);
- }
-
- if (sp->framebuffer.sbuf && sp->framebuffer.sbuf != sp->framebuffer.zbuf) {
- struct pipe_surface *ps = sp->framebuffer.sbuf;
- if (ps->region)
- pipe->region_unmap(pipe, ps->region);
- }
-}
-
+ ps = sp->framebuffer.zbuf;
+ if (ps && ps->map)
+ pipe_surface_unmap(ps);
-void
-softpipe_unmap_texture_surfaces(struct softpipe_context *sp)
-{
- struct pipe_context *pipe = &sp->pipe;
- uint i;
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- struct softpipe_texture *spt = sp->texture[i];
- if (spt) {
- pipe->region_unmap(pipe, spt->region);
- }
- }
+ ps = sp->framebuffer.sbuf;
+ if (ps && ps->map)
+ pipe_surface_unmap(ps);
}
@@ -403,8 +363,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
draw_set_rasterize_stage(softpipe->draw, softpipe->setup);
}
-
- sp_init_region_functions(softpipe);
sp_init_surface_functions(softpipe);
return &softpipe->pipe;
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index 8a82cdfe1a..93eb68405d 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -112,7 +112,6 @@ softpipe_draw_elements(struct pipe_context *pipe,
softpipe_update_derived( sp );
softpipe_map_surfaces(sp);
- softpipe_map_texture_surfaces(sp);
softpipe_map_constant_buffers(sp);
/*
@@ -184,7 +183,6 @@ softpipe_draw_elements(struct pipe_context *pipe,
/* Note: leave drawing surfaces mapped */
- softpipe_unmap_texture_surfaces(sp);
softpipe_unmap_constant_buffers(sp);
return TRUE;
diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c
deleted file mode 100644
index 58dc6bb96e..0000000000
--- a/src/mesa/pipe/softpipe/sp_region.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 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.
- *
- **************************************************************************/
-
-/* Provide additional functionality on top of bufmgr buffers:
- * - 2d semantics and blit operations (XXX: remove/simplify blits??)
- * - refcounting of buffers for multiple images in a buffer.
- * - refcounting of buffer mappings.
- */
-
-#include "sp_context.h"
-#include "sp_region.h"
-#include "pipe/p_util.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_defines.h"
-
-
-
-static ubyte *
-sp_region_map(struct pipe_context *pipe, struct pipe_region *region)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
-
- if (!region->map_refcount++) {
- region->map = sp->pipe.winsys->buffer_map( sp->pipe.winsys,
- region->buffer,
- PIPE_BUFFER_FLAG_WRITE |
- PIPE_BUFFER_FLAG_READ);
- }
-
- return region->map;
-}
-
-static void
-sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
-
- if (region->map_refcount > 0) {
- assert(region->map);
- if (!--region->map_refcount) {
- sp->pipe.winsys->buffer_unmap( sp->pipe.winsys,
- region->buffer );
- region->map = NULL;
- }
- }
-}
-
-
-void
-sp_init_region_functions(struct softpipe_context *sp)
-{
- sp->pipe.region_map = sp_region_map;
- sp->pipe.region_unmap = sp_region_unmap;
-}
-
diff --git a/src/mesa/pipe/softpipe/sp_region.h b/src/mesa/pipe/softpipe/sp_region.h
deleted file mode 100644
index 432746b27f..0000000000
--- a/src/mesa/pipe/softpipe/sp_region.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- *
- * 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.
- *
- **************************************************************************/
-
-
-#ifndef SP_REGION_H
-#define SP_REGION_H
-
-
-struct softpipe_context;
-
-
-extern void
-sp_init_region_functions(struct softpipe_context *sp);
-
-
-#endif /* SP_REGION_H */
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index a543735b52..daf9955ca5 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -78,7 +78,7 @@ struct softpipe_texture
/* The data is held here:
*/
- struct pipe_region *region;
+ struct pipe_buffer_handle *buffer;
};
void *
diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c
index d4e0bd1e15..9470ef485f 100644
--- a/src/mesa/pipe/softpipe/sp_state_surface.c
+++ b/src/mesa/pipe/softpipe/sp_state_surface.c
@@ -27,6 +27,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "p_inlines.h"
+
#include "sp_context.h"
#include "sp_state.h"
#include "sp_surface.h"
@@ -54,17 +56,17 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
/* unmap old */
ps = sp->framebuffer.cbufs[i];
- if (ps && ps->region)
- pipe->region_unmap(pipe, ps->region);
+ if (ps && ps->map)
+ pipe_surface_unmap(ps);
/* map new */
ps = fb->cbufs[i];
if (ps)
- pipe->region_map(pipe, ps->region);
+ pipe_surface_map(ps);
/* assign new */
sp->framebuffer.cbufs[i] = fb->cbufs[i];
/* update cache */
- sp_tile_cache_set_surface(sp->cbuf_cache[i], ps);
+ sp_tile_cache_set_surface(sp, sp->cbuf_cache[i], ps);
}
}
@@ -76,8 +78,8 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
sp_flush_tile_cache(sp, sp->zbuf_cache);
/* unmap old */
ps = sp->framebuffer.zbuf;
- if (ps && ps->region)
- pipe->region_unmap(pipe, ps->region);
+ if (ps && ps->map)
+ pipe_surface_unmap(ps);
if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) {
/* combined z/stencil */
sp->framebuffer.sbuf = NULL;
@@ -85,12 +87,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
/* map new */
ps = fb->zbuf;
if (ps)
- pipe->region_map(pipe, ps->region);
+ pipe_surface_map(ps);
/* assign new */
sp->framebuffer.zbuf = fb->zbuf;
/* update cache */
- sp_tile_cache_set_surface(sp->zbuf_cache, ps);
+ sp_tile_cache_set_surface(sp, sp->zbuf_cache, ps);
}
/* XXX combined depth/stencil here */
@@ -101,12 +103,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
/* unmap old */
ps = sp->framebuffer.sbuf;
- if (ps && ps->region)
- pipe->region_unmap(pipe, ps->region);
+ if (ps && ps->map)
+ pipe_surface_unmap(ps);
/* map new */
ps = fb->sbuf;
if (ps && fb->sbuf != fb->zbuf)
- pipe->region_map(pipe, ps->region);
+ pipe_surface_map(ps);
/* assign new */
sp->framebuffer.sbuf = fb->sbuf;
@@ -114,12 +116,12 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
if (fb->sbuf != fb->zbuf) {
/* separate stencil buf */
sp->sbuf_cache = sp->sbuf_cache_sep;
- sp_tile_cache_set_surface(sp->sbuf_cache, ps);
+ sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps);
}
else {
/* combined depth/stencil */
sp->sbuf_cache = sp->zbuf_cache;
- sp_tile_cache_set_surface(sp->sbuf_cache, ps);
+ sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps);
}
}
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index c41bbc59b9..c61e0842fc 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -76,7 +76,7 @@ a8r8g8b8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const unsigned *src
- = ((const unsigned *) (ps->region->map + ps->offset))
+ = ((const unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -107,7 +107,7 @@ a8r8g8b8_put_tile(struct pipe_surface *ps,
const float *p)
{
unsigned *dst
- = ((unsigned *) (ps->region->map + ps->offset))
+ = ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -140,7 +140,7 @@ b8g8r8a8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const unsigned *src
- = ((const unsigned *) (ps->region->map + ps->offset))
+ = ((const unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -171,7 +171,7 @@ b8g8r8a8_put_tile(struct pipe_surface *ps,
const float *p)
{
unsigned *dst
- = ((unsigned *) (ps->region->map + ps->offset))
+ = ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -204,7 +204,7 @@ a1r5g5b5_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ushort *src
- = ((const ushort *) (ps->region->map + ps->offset))
+ = ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
@@ -235,7 +235,7 @@ z16_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ushort *src
- = ((const ushort *) (ps->region->map + ps->offset))
+ = ((const ushort *) (ps->map))
+ y * ps->pitch + x;
const float scale = 1.0f / 65535.0f;
unsigned i, j;
@@ -268,7 +268,7 @@ l8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ubyte *src
- = ((const ubyte *) (ps->region->map + ps->offset))
+ = ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -299,7 +299,7 @@ a8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ubyte *src
- = ((const ubyte *) (ps->region->map + ps->offset))
+ = ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -330,7 +330,7 @@ r16g16b16a16_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const short *src
- = ((const short *) (ps->region->map + ps->offset))
+ = ((const short *) (ps->map))
+ (y * ps->pitch + x) * 4;
unsigned i, j;
unsigned w0 = w;
@@ -362,7 +362,7 @@ r16g16b16a16_put_tile(struct pipe_surface *ps,
const float *p)
{
short *dst
- = ((short *) (ps->region->map + ps->offset))
+ = ((short *) (ps->map))
+ (y * ps->pitch + x) * 4;
unsigned i, j;
unsigned w0 = w;
@@ -399,7 +399,7 @@ i8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ubyte *src
- = ((const ubyte *) (ps->region->map + ps->offset))
+ = ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -430,7 +430,7 @@ a8_l8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const ushort *src
- = ((const ushort *) (ps->region->map + ps->offset))
+ = ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -467,7 +467,7 @@ z32_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const uint *src
- = ((const uint *) (ps->region->map + ps->offset))
+ = ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / (double) 0xffffffff;
unsigned i, j;
@@ -501,7 +501,7 @@ s8z24_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const uint *src
- = ((const uint *) (ps->region->map + ps->offset))
+ = ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / ((1 << 24) - 1);
unsigned i, j;
@@ -535,7 +535,7 @@ z24s8_get_tile(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h, float *p)
{
const uint *src
- = ((const uint *) (ps->region->map + ps->offset))
+ = ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / ((1 << 24) - 1);
unsigned i, j;
@@ -589,7 +589,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe_region_reference(&ps->region, spt->region);
+ pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
@@ -613,7 +613,7 @@ softpipe_get_tile(struct pipe_context *pipe, struct pipe_surface *ps,
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
if (dst_stride == 0) {
dst_stride = w * cpp;
@@ -621,7 +621,7 @@ softpipe_get_tile(struct pipe_context *pipe, struct pipe_surface *ps,
CLIP_TILE;
- pSrc = ps->region->map + ps->offset + (y * ps->pitch + x) * cpp;
+ pSrc = ps->map + (y * ps->pitch + x) * cpp;
pDest = (ubyte *) p;
for (i = 0; i < h; i++) {
@@ -645,7 +645,7 @@ softpipe_put_tile(struct pipe_context *pipe, struct pipe_surface *ps,
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
if (src_stride == 0) {
src_stride = w * cpp;
@@ -654,7 +654,7 @@ softpipe_put_tile(struct pipe_context *pipe, struct pipe_surface *ps,
CLIP_TILE;
pSrc = (const ubyte *) p;
- pDest = ps->region->map + ps->offset + (y * ps->pitch + x) * cpp;
+ pDest = ps->map + (y * ps->pitch + x) * cpp;
for (i = 0; i < h; i++) {
memcpy(pDest, pSrc, w * cpp);
@@ -817,12 +817,12 @@ sp_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- copy_rect(pipe->region_map(pipe, dst->region) + dst->offset,
+ copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
- pipe->region_unmap(pipe, dst->region);
+ pipe_surface_unmap(dst);
}
/* Assumes all values are within bounds -- no checking at this level -
@@ -835,29 +835,26 @@ sp_surface_copy(struct pipe_context *pipe,
struct pipe_surface *src,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- ubyte *src_map, *dst_map;
assert( dst->cpp == src->cpp );
- dst_map = pipe->region_map(pipe, dst->region);
- src_map = pipe->region_map(pipe, src->region);
- copy_rect(dst_map + dst->offset,
+ copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty,
width, height,
- src_map + src->offset,
+ pipe_surface_map(src),
src->pitch,
srcx, srcy);
- pipe->region_unmap(pipe, src->region);
- pipe->region_unmap(pipe, dst->region);
+ pipe_surface_unmap(src);
+ pipe_surface_unmap(dst);
}
static ubyte *
get_pointer(struct pipe_surface *dst, unsigned x, unsigned y)
{
- return dst->region->map + (y * dst->pitch + x) * dst->cpp;
+ return dst->map + (y * dst->pitch + x) * dst->cpp;
}
@@ -879,7 +876,7 @@ sp_surface_fill(struct pipe_context *pipe,
assert(dst->pitch > 0);
assert(width <= dst->pitch);
- (void)pipe->region_map(pipe, dst->region);
+ (void)pipe_surface_map(dst);
switch (dst->cpp) {
case 1:
@@ -935,7 +932,7 @@ sp_surface_fill(struct pipe_context *pipe,
break;
}
- pipe->region_unmap( pipe, dst->region );
+ pipe_surface_unmap( dst );
}
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index 2f9a1e9837..53486f9bba 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -32,6 +32,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
@@ -380,13 +381,18 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
sizeof(struct softpipe_texture) - sizeof(struct pipe_texture));
if (softpipe_mipmap_tree_layout(pipe, spt)) {
- spt->region = pipe->winsys->region_alloc(pipe->winsys,
- spt->pitch * (*pt)->cpp *
- spt->total_height,
- PIPE_SURFACE_FLAG_TEXTURE);
+ spt->buffer = pipe->winsys->buffer_create(pipe->winsys,
+ PIPE_SURFACE_FLAG_TEXTURE);
+
+ if (spt->buffer) {
+ pipe->winsys->buffer_data(pipe->winsys, spt->buffer,
+ spt->pitch * (*pt)->cpp *
+ spt->total_height, NULL,
+ PIPE_BUFFER_USAGE_PIXEL);
+ }
}
- if (!spt->region) {
+ if (!spt->buffer) {
FREE(spt);
spt = NULL;
}
@@ -413,7 +419,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe->winsys->region_release(pipe->winsys, &spt->region);
+ pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (spt->image_offset[i])
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index 62ee6a27c9..08cd39cc55 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -123,16 +123,24 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
void
-sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
+sp_tile_cache_set_surface(struct softpipe_context *sp,
+ struct softpipe_tile_cache *tc,
struct pipe_surface *ps)
{
+ if (tc->surface && tc->surface->map)
+ pipe_surface_unmap(tc->surface);
+
pipe_surface_reference(&tc->surface, ps);
}
struct pipe_surface *
-sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
+sp_tile_cache_get_surface(struct softpipe_context *sp,
+ struct softpipe_tile_cache *tc)
{
+ if (tc->surface && !tc->surface->map)
+ pipe_surface_map(tc->surface);
+
return tc->surface;
}
@@ -162,7 +170,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
boolean is_depth_stencil;
int inuse = 0, pos;
- if (!ps || !ps->region || !ps->region->map)
+ if (!ps || !ps->buffer)
return;
is_depth_stencil = (ps->format == PIPE_FORMAT_S8_Z24 ||
@@ -367,6 +375,16 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
struct pipe_surface *ps
= pipe->get_tex_surface(pipe, tc->texture, face, level, z);
+ if (ps != tc->surface) {
+ if (tc->surface && tc->surface->map)
+ pipe_surface_unmap(tc->surface);
+
+ pipe_surface_reference(&tc->surface, ps);
+
+ if (!tc->surface->map)
+ pipe_surface_map(tc->surface);
+ }
+
pipe->get_tile_rgba(pipe, ps,
tile_x, tile_y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.h b/src/mesa/pipe/softpipe/sp_tile_cache.h
index 9967aa5044..de5ff2c498 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.h
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.h
@@ -63,11 +63,13 @@ extern void
sp_destroy_tile_cache(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
+sp_tile_cache_set_surface(struct softpipe_context *sp,
+ struct softpipe_tile_cache *tc,
struct pipe_surface *sps);
extern struct pipe_surface *
-sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
+sp_tile_cache_get_surface(struct softpipe_context *sp,
+ struct softpipe_tile_cache *tc);
extern void
sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
diff --git a/src/mesa/pipe/xlib/xm_api.c b/src/mesa/pipe/xlib/xm_api.c
index f87d72d0c8..542b4aca49 100644
--- a/src/mesa/pipe/xlib/xm_api.c
+++ b/src/mesa/pipe/xlib/xm_api.c
@@ -1512,7 +1512,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
pipe->get_tile_rgba = xmesa_get_tile_rgba;
pipe->put_tile_rgba = xmesa_put_tile_rgba;
- c->st->haveFramebufferRegions = GL_FALSE;
+ c->st->haveFramebufferSurfaces = GL_FALSE;
/* special pipe->clear function */
pipe->clear = xmesa_clear;
diff --git a/src/mesa/pipe/xlib/xm_buffer.c b/src/mesa/pipe/xlib/xm_buffer.c
index 449e90184b..6fc2f4ba63 100644
--- a/src/mesa/pipe/xlib/xm_buffer.c
+++ b/src/mesa/pipe/xlib/xm_buffer.c
@@ -269,9 +269,8 @@ static void
finish_surface_init(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
{
struct pipe_context *pipe = ctx->st->pipe;
- if (!xrb->St.surface->region) {
- xrb->St.surface->region = pipe->winsys->region_alloc(pipe->winsys, 1,
- 0x0);
+ if (!xrb->St.surface->buffer) {
+ xrb->St.surface->buffer = pipe->winsys->buffer_create(pipe->winsys, 0x0);
}
}
@@ -301,7 +300,7 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->Height = height;
rb->InternalFormat = internalFormat;
- if (!xrb->St.surface || !xrb->St.surface->region)
+ if (!xrb->St.surface || !xrb->St.surface->buffer)
finish_surface_init(ctx, xrb);
/* surface info */
@@ -363,7 +362,7 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
xrb->origin4 = NULL;
}
- if (!xrb->St.surface || !xrb->St.surface->region)
+ if (!xrb->St.surface || !xrb->St.surface->buffer)
finish_surface_init(ctx, xrb);
xrb->St.surface->width = width;
diff --git a/src/mesa/pipe/xlib/xm_surface.c b/src/mesa/pipe/xlib/xm_surface.c
index 58ca2e7fb3..4a54b5c7e1 100644
--- a/src/mesa/pipe/xlib/xm_surface.c
+++ b/src/mesa/pipe/xlib/xm_surface.c
@@ -665,12 +665,12 @@ xmesa_new_color_surface(struct pipe_winsys *winsys, GLuint pipeFormat)
xms->surface.refcount = 1;
xms->surface.winsys = winsys;
- /* Note, the region we allocate doesn't actually have any storage
+ /* Note, the buffer we allocate doesn't actually have any storage
* since we're drawing into an XImage or Pixmap.
- * The region's size will get set in the xmesa_alloc_front/back_storage()
+ * The surface's size will get set in the xmesa_alloc_front/back_storage()
* functions.
*/
- xms->surface.region = winsys->region_alloc(winsys, 1, 0x0);
+ xms->surface.buffer = winsys->buffer_create(winsys, 0x0);
return &xms->surface;
}
@@ -713,7 +713,7 @@ xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, uint value)
{
struct softpipe_context *sp = softpipe_context(pipe);
- if (ps == sp_tile_cache_get_surface(sp->cbuf_cache[0])) {
+ if (ps == sp_tile_cache_get_surface(sp, sp->cbuf_cache[0])) {
float clear[4];
clear[0] = 0.2; /* XXX hack */
clear[1] = 0.2;
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index 99816a811d..295174d4bb 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -186,7 +186,7 @@ xm_get_name(struct pipe_winsys *pws)
static struct pipe_buffer_handle *
-xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
+xm_buffer_create(struct pipe_winsys *pws, unsigned flags)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
buffer->refcount = 1;
@@ -228,47 +228,6 @@ xm_surface_pitch(struct pipe_winsys *winsys, unsigned cpp, unsigned width,
}
-static struct pipe_region *
-xm_region_alloc(struct pipe_winsys *winsys, unsigned size, unsigned flags)
-{
- struct pipe_region *region = CALLOC_STRUCT(pipe_region);
- const unsigned alignment = 64;
-
- region->refcount = 1;
-
- assert(size > 0);
-
- region->buffer = winsys->buffer_create( winsys, alignment );
-
- /* NULL data --> just allocate the space */
- winsys->buffer_data( winsys,
- region->buffer,
- size,
- NULL,
- PIPE_BUFFER_USAGE_PIXEL );
- return region;
-}
-
-
-static void
-xm_region_release(struct pipe_winsys *winsys, struct pipe_region **region)
-{
- if (!*region)
- return;
-
- assert((*region)->refcount > 0);
- (*region)->refcount--;
-
- if ((*region)->refcount == 0) {
- assert((*region)->map_refcount == 0);
-
- winsys->buffer_reference( winsys, &((*region)->buffer), NULL );
- free(*region);
- }
- *region = NULL;
-}
-
-
/**
* Called via pipe->surface_alloc() to create new surfaces (textures,
* renderbuffers, etc.
@@ -301,8 +260,8 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
struct pipe_surface *surf = *s;
surf->refcount--;
if (surf->refcount == 0) {
- if (surf->region)
- winsys->region_release(winsys, &surf->region);
+ if (surf->buffer)
+ winsys->buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -335,9 +294,6 @@ xmesa_get_pipe_winsys(void)
ws->buffer_subdata = xm_buffer_subdata;
ws->buffer_get_subdata = xm_buffer_get_subdata;
- ws->region_alloc = xm_region_alloc;
- ws->region_release = xm_region_release;
-
ws->surface_pitch = xm_surface_pitch;
ws->surface_alloc = xm_surface_alloc;
ws->surface_release = xm_surface_release;