const drm_clip_rect_t *pbox = dPriv->pClipRects;
const int pitch = intelScreen->front.pitch / intelScreen->front.cpp;
const int cpp = intelScreen->front.cpp;
- const struct pipe_region *srcRegion = surf->region;
const int srcpitch = surf->pitch;
int BR13, CMD;
int i;
- ASSERT(srcRegion);
+ ASSERT(surf->buffer);
ASSERT(surf->cpp == cpp);
DBG(SWAP, "screen pitch %d src surface pitch %d\n",
assert(box.x1 < box.x2);
assert(box.y1 < box.y2);
- /* XXX this could be done with pipe->region_copy() */
+ /* XXX this could be done with pipe->surface_copy() */
BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
OUT_BATCH(CMD);
OUT_BATCH(BR13);
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
OUT_BATCH((sbox.y1 << 16) | sbox.x1);
OUT_BATCH((srcpitch * cpp) & 0xffff);
- OUT_RELOC(dri_bo(srcRegion->buffer),
+ OUT_RELOC(dri_bo(surf->buffer),
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
* for all buffers.
*/
static struct pipe_buffer_handle *
-intel_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment)
+intel_buffer_create(struct pipe_winsys *winsys, unsigned flags)
{
struct _DriBufferObject *buffer;
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer, alignment, 0, 0 );
+ "pipe buffer", 1, &buffer, 64, 0, 0 );
return pipe_bo(buffer);
}
}
-static struct pipe_region *
-intel_i915_region_alloc(struct pipe_winsys *winsys,
- unsigned size, unsigned flags)
-{
- struct pipe_region *region = calloc(sizeof(*region), 1);
- const unsigned alignment = 64;
-
- region->refcount = 1;
-
- region->buffer = winsys->buffer_create( winsys, alignment );
-
- winsys->buffer_data( winsys,
- region->buffer,
- size,
- NULL,
- PIPE_BUFFER_USAGE_PIXEL );
-
- return region;
-}
-
-static void
-intel_i915_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;
-}
-
-
static struct pipe_surface *
intel_i915_surface_alloc(struct pipe_winsys *winsys, unsigned format)
{
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;
iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
iws->winsys.printf = intel_printf;
iws->winsys.get_name = intel_get_name;
- iws->winsys.region_alloc = intel_i915_region_alloc;
- iws->winsys.region_release = intel_i915_region_release;
iws->winsys.surface_pitch = intel_i915_surface_pitch;
iws->winsys.surface_alloc = intel_i915_surface_alloc;
iws->winsys.surface_release = intel_i915_surface_release;
#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;
i915_context.c \
i915_debug.c \
i915_debug_fp.c \
- i915_regions.c \
i915_state.c \
i915_state_immediate.c \
i915_state_dynamic.c \
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);
/* The data is held here:
*/
- struct pipe_region *region;
+ struct pipe_buffer_handle *buffer;
};
struct i915_context
/***********************************************************************
- * 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 );
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
-
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);
}
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);
}
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);
#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"
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;
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
CLIP_TILE;
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++) {
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
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, w0 * cpp);
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];
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);
}
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 );
}
}
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;
}
if (0) {
unsigned i, j;
- (void)pipe->region_map(pipe, dst->region);
+ (void)pipe_surface_map(dst);
switch (dst->cpp) {
case 1: {
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 );
#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"
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;
}
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])
* Gallium rendering context. Basically:
* - state setting functions
* - VBO drawing functions
- * - memory region function
+ * - surface functions
* - device queries
*/
struct pipe_context {
uint x, uint y, uint w, uint h, const float *p);
- /*
- * 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
*/
#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)
/**
- * \sa pipe_region_reference
+ * \sa pipe_surface_reference
*/
static INLINE void
pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
}
}
+
#endif /* P_INLINES_H */
};
-/***
- *** 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 */
};
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 \
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 */
#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"
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);
}
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++)
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);
}
draw_set_rasterize_stage(softpipe->draw, softpipe->setup);
}
-
- sp_init_region_functions(softpipe);
sp_init_surface_functions(softpipe);
return &softpipe->pipe;
softpipe_update_derived( sp );
softpipe_map_surfaces(sp);
- softpipe_map_texture_surfaces(sp);
softpipe_map_constant_buffers(sp);
/*
/* Note: leave drawing surfaces mapped */
- softpipe_unmap_texture_surfaces(sp);
softpipe_unmap_constant_buffers(sp);
return TRUE;
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
-
+++ /dev/null
-/**************************************************************************
- *
- * 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 */
/* The data is held here:
*/
- struct pipe_region *region;
+ struct pipe_buffer_handle *buffer;
};
void *
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "p_inlines.h"
+
#include "sp_context.h"
#include "sp_state.h"
#include "sp_surface.h"
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);
}
}
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;
/* 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 */
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;
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);
}
}
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;
const float *p)
{
unsigned *dst
- = ((unsigned *) (ps->region->map + ps->offset))
+ = ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
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;
const float *p)
{
unsigned *dst
- = ((unsigned *) (ps->region->map + ps->offset))
+ = ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
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 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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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];
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
if (dst_stride == 0) {
dst_stride = w * cpp;
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++) {
ubyte *pDest;
uint i;
- assert(ps->region->map);
+ assert(ps->map);
if (src_stride == 0) {
src_stride = w * cpp;
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);
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 -
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;
}
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:
break;
}
- pipe->region_unmap( pipe, dst->region );
+ pipe_surface_unmap( dst );
}
#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"
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;
}
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])
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;
}
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 ||
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);
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,
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;
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);
}
}
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 */
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;
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;
}
{
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;
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;
}
-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.
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;
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;
#include "st_format.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
/**
GLfloat *accBuf;
GLint i;
- (void) pipe->region_map(pipe, acc_ps->region);
+ (void) pipe_surface_map(acc_ps);
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
free(accBuf);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(acc_ps);
}
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe->region_map(pipe, acc_ps->region);
+ (void) pipe_surface_map(acc_ps);
pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(accBuf);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(acc_ps);
}
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- colorMap = pipe->region_map(pipe, color_ps->region);
- accMap = pipe->region_map(pipe, acc_ps->region);
+ colorMap = pipe_surface_map(color_ps);
+ accMap = pipe_surface_map(acc_ps);
pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(colorBuf);
free(accBuf);
- pipe->region_unmap(pipe, color_ps->region);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(color_ps);
+ pipe_surface_unmap(acc_ps);
}
buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe->region_map(pipe, color_ps->region);
- (void) pipe->region_map(pipe, acc_ps->region);
+ (void) pipe_surface_map(color_ps);
+ (void) pipe_surface_map(acc_ps);
pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
free(buf);
- pipe->region_unmap(pipe, color_ps->region);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(color_ps);
+ pipe_surface_unmap(acc_ps);
}
abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe->region_map(pipe, color_ps->region);
- (void) pipe->region_map(pipe, acc_ps->region);
+ (void) pipe_surface_map(color_ps);
+ (void) pipe_surface_map(acc_ps);
pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
if (cbuf)
free(cbuf);
- pipe->region_unmap(pipe, color_ps->region);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(color_ps);
+ pipe_surface_unmap(acc_ps);
}
surface = pipe->get_tex_surface(pipe, pt, 0, 0, 0);
- /* map texture region */
- (void) pipe->region_map(pipe, surface->region);
- dest = surface->region->map + surface->offset;
+ /* map texture surface */
+ dest = pipe_surface_map(surface);
- /* Put image into texture region.
+ /* Put image into texture surface.
* Note that the image is actually going to be upside down in
* the texture. We deal with that with texcoords.
*/
unpack);
/* unmap */
- pipe->region_unmap(pipe, surface->region);
+ pipe_surface_unmap(surface);
pipe_surface_reference(&surface, NULL);
assert(success);
pipe->flush(pipe, 0);
/* map the stencil buffer */
- stmap = pipe->region_map(pipe, ps->region);
+ stmap = pipe_surface_map(ps);
/* if width > MAX_WIDTH, have to process image in chunks */
skipPixels = 0;
}
/* unmap the stencil buffer */
- pipe->region_unmap(pipe, ps->region);
+ pipe_surface_unmap(ps);
}
surface = pipe->get_tex_surface(pipe, pt, 0, 0, 0);
- /* map texture region */
- (void) pipe->region_map(pipe, surface->region);
- dest = surface->region->map + surface->offset;
+ /* map texture surface */
+ dest = pipe_surface_map(surface);
- /* Put image into texture region.
+ /* Put image into texture surface.
* Note that the image is actually going to be upside down in
* the texture. We deal with that with texcoords.
*/
} /* row */
/* Release surface */
- pipe->region_unmap(pipe, surface->region);
+ pipe_surface_unmap(surface);
pipe_surface_reference(&surface, NULL);
pt->format = format;
GLsizei width, GLsizei height,
GLint dstx, GLint dsty)
{
- struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
struct st_renderbuffer *rbRead = st_renderbuffer(ctx->ReadBuffer->_StencilBuffer);
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
struct pipe_surface *psRead = rbRead->surface;
}
/* map the stencil buffers */
- readMap = pipe->region_map(pipe, psRead->region);
- drawMap = pipe->region_map(pipe, psDraw->region);
+ readMap = pipe_surface_map(psRead);
+ drawMap = pipe_surface_map(psDraw);
/* this will do stencil pixel transfer ops */
st_read_stencil_pixels(ctx, srcx, srcy, width, height, GL_UNSIGNED_BYTE,
free(buffer);
/* unmap the stencil buffers */
- pipe->region_unmap(pipe, psRead->region);
- pipe->region_unmap(pipe, psDraw->region);
+ pipe_surface_unmap(psRead);
+ pipe_surface_unmap(psDraw);
}
}
/* For some drivers (like Xlib) it's not possible to treat the
- * front/back color buffers as regions (they're XImages and Pixmaps).
- * So, this var tells us if we can use region_copy here...
+ * front/back color buffers as surfaces (they're XImages and Pixmaps).
+ * So, this var tells us if we can use surface_copy here...
*/
- if (st->haveFramebufferRegions) {
- /* copy source framebuffer region into mipmap/texture */
+ if (st->haveFramebufferSurfaces) {
+ /* copy source framebuffer surface into mipmap/texture */
pipe->surface_copy(pipe,
psTex, /* dest */
0, 0, /* destx/y */
/* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe->region_map(pipe, psRead->region);
- (void) pipe->region_map(pipe, psTex->region);
+ (void) pipe_surface_map(psRead);
+ (void) pipe_surface_map(psTex);
pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
- pipe->region_unmap(pipe, psRead->region);
- pipe->region_unmap(pipe, psTex->region);
+ pipe_surface_unmap(psRead);
+ pipe_surface_unmap(psTex);
free(buf);
}
width, flags);
}
- /* free old region */
- if (strb->surface->region) {
- /* loop here since mapping is refcounted */
- struct pipe_region *r = strb->surface->region;
- while (r->map)
- pipe->region_unmap(pipe, r);
- pipe->winsys->region_release(pipe->winsys, &strb->surface->region);
- }
-
- strb->surface->region = pipe->winsys->region_alloc(pipe->winsys,
- strb->surface->pitch *
- cpp * height, flags);
- if (!strb->surface->region)
+ /* loop here since mapping is refcounted */
+ while (strb->surface->map)
+ pipe_surface_unmap(strb->surface);
+ if (strb->surface->buffer)
+ pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer,
+ NULL);
+
+ strb->surface->buffer = pipe->winsys->buffer_create(pipe->winsys, flags);
+ if (!strb->surface->buffer)
return GL_FALSE; /* out of memory, try s/w buffer? */
- ASSERT(strb->surface->region->buffer);
+ pipe->winsys->buffer_data(pipe->winsys, strb->surface->buffer,
+ strb->surface->pitch * cpp * height, NULL,
+ PIPE_BUFFER_USAGE_PIXEL);
+
+ ASSERT(strb->surface->buffer);
ASSERT(strb->surface->format);
strb->Base.Width = strb->surface->width = width;
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#include "st_context.h"
#include "st_cb_readpixels.h"
#include "st_cb_fbo.h"
const struct gl_pixelstore_attrib *packing,
GLvoid *pixels)
{
- struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer);
struct pipe_surface *ps = strb->surface;
GLint j;
/* map the stencil buffer */
- stmap = pipe->region_map(pipe, ps->region);
+ stmap = pipe_surface_map(ps);
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
/* unmap the stencil buffer */
- pipe->region_unmap(pipe, ps->region);
+ pipe_surface_unmap(ps);
}
/* Do all needed clipping here, so that we can forget about it later */
if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
- /* The ReadPixels region is totally outside the window bounds */
+ /* The ReadPixels surface is totally outside the window bounds */
return;
}
if (!strb)
return;
- pipe->region_map(pipe, strb->surface->region);
+ pipe_surface_map(strb->surface);
if (format == GL_RGBA && type == GL_FLOAT) {
/* write tile(row) directly into user's buffer */
}
}
- pipe->region_unmap(pipe, strb->surface->region);
+ pipe_surface_unmap(strb->surface);
}
GLuint textureOffset;
/* On validation any active images held in main memory or in other
- * regions will be copied to this region and the old storage freed.
+ * textures will be copied to this texture and the old storage freed.
*/
struct pipe_texture *pt;
}
if (stImage->pt && i < depth) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, i);
pixels += srcImageStride;
}
_mesa_unmap_teximage_pbo(ctx, unpack);
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
}
if (stImage->pt && i < depth) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, i);
pixels += dstImageStride;
}
/* Unmap */
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
}
}
if (stImage->pt && i < depth) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i);
pixels += srcImageStride;
}
_mesa_unmap_teximage_pbo(ctx, packing);
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
}
/**
- * Do a CopyTexSubImage operation by mapping the source region and
- * dest region and using get_tile()/put_tile() to access the pixels/texels.
+ * Do a CopyTexSubImage operation by mapping the source surface and
+ * dest surface and using get_tile()/put_tile() to access the pixels/texels.
*
* Note: srcY=0=TOP of renderbuffer
*/
dest_surf = pipe->get_tex_surface(pipe, pt,
face, level, destZ);
- (void) pipe->region_map(pipe, dest_surf->region);
- (void) pipe->region_map(pipe, src_surf->region);
+ (void) pipe_surface_map(dest_surf);
+ (void) pipe_surface_map(src_surf);
/* buffer for one row */
data = (GLfloat *) malloc(width * 4 * sizeof(GLfloat));
}
- (void) pipe->region_unmap(pipe, dest_surf->region);
- (void) pipe->region_unmap(pipe, src_surf->region);
+ (void) pipe_surface_unmap(dest_surf);
+ (void) pipe_surface_unmap(src_surf);
free(data);
}
if (src_format == dest_format &&
ctx->_ImageTransferState == 0x0 &&
- strb->surface->region &&
- dest_surface->region &&
+ strb->surface->buffer &&
+ dest_surface->buffer &&
strb->surface->cpp == stImage->pt->cpp) {
/* do blit-style copy */
st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
- st->haveFramebufferRegions = GL_TRUE;
+ st->haveFramebufferSurfaces = GL_TRUE;
st->pixel_xfer.cache = _mesa_new_program_cache();
struct st_context;
-struct st_region;
struct st_texture_object;
struct st_fragment_program;
struct draw_context;
char vendor[100];
char renderer[100];
- /** Can we access the front/back color buffers as pipe_regions?
+ /** Can we access the front/back color buffers as pipe_surfaces?
* We can't with the Xlib driver...
* This is a hack that should be fixed someday.
*/
- GLboolean haveFramebufferRegions;
+ GLboolean haveFramebufferSurfaces;
/* State to be validated:
*/
#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_inlines.h"
#include "pipe/p_winsys.h"
stImage->surface = st->pipe->get_tex_surface(st->pipe, pt, stImage->face,
stImage->level, zoffset);
- (void) st->pipe->region_map(st->pipe, stImage->surface->region);
-
- return stImage->surface->region->map + stImage->surface->offset;
+ return pipe_surface_map(stImage->surface);
}
void
-st_texture_image_unmap(struct st_context *st, struct st_texture_image *stImage)
+st_texture_image_unmap(struct st_texture_image *stImage)
{
DBG("%s\n", __FUNCTION__);
- st->pipe->region_unmap(st->pipe, stImage->surface->region);
+ pipe_surface_unmap(stImage->surface);
pipe_surface_reference(&stImage->surface, NULL);
}
GLuint zoffset);
extern void
-st_texture_image_unmap(struct st_context *st,
- struct st_texture_image *stImage);
+st_texture_image_unmap(struct st_texture_image *stImage);
/* Return pointers to each 2d slice within an image. Indexed by depth