summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2007-12-07 12:30:35 +0100
committerMichel Dänzer <michel@tungstengraphics.com>2007-12-07 12:30:35 +0100
commitb859cdf6f191b4d8b56537c8dc30082a7e2d94b3 (patch)
tree4bd3149cc81a2fb6434282a70b34361f94710cfd /src/mesa/pipe/i915simple
parent987d59bb83e9e08192563e5f1b52949c5511053c (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/i915simple')
-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
7 files changed, 35 insertions, 109 deletions
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])