summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2007-12-07 12:30:35 +0100
committerMichel Dänzer <[email protected]>2007-12-07 12:30:35 +0100
commitb859cdf6f191b4d8b56537c8dc30082a7e2d94b3 (patch)
tree4bd3149cc81a2fb6434282a70b34361f94710cfd /src/mesa/state_tracker
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/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c33
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c48
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c28
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c13
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c30
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_context.h5
-rw-r--r--src/mesa/state_tracker/st_texture.c9
-rw-r--r--src/mesa/state_tracker/st_texture.h3
9 files changed, 82 insertions, 89 deletions
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 7a245b0ed6d..c8d9cba12f3 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -42,6 +42,7 @@
#include "st_format.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
/**
@@ -68,7 +69,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
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));
@@ -83,7 +84,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
free(accBuf);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(acc_ps);
}
@@ -99,7 +100,7 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
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);
@@ -111,7 +112,7 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
free(accBuf);
- pipe->region_unmap(pipe, acc_ps->region);
+ pipe_surface_unmap(acc_ps);
}
@@ -128,8 +129,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
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);
@@ -143,8 +144,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
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);
}
@@ -159,8 +160,8 @@ accum_load(struct pipe_context *pipe, GLfloat value,
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);
@@ -172,8 +173,8 @@ accum_load(struct pipe_context *pipe, GLfloat value,
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);
}
@@ -190,8 +191,8 @@ accum_return(GLcontext *ctx, GLfloat value,
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);
@@ -218,8 +219,8 @@ accum_return(GLcontext *ctx, GLfloat value,
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);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index c28ad15b294..a61daffb20a 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -492,11 +492,10 @@ make_texture(struct st_context *st,
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.
*/
@@ -513,7 +512,7 @@ make_texture(struct st_context *st,
unpack);
/* unmap */
- pipe->region_unmap(pipe, surface->region);
+ pipe_surface_unmap(surface);
pipe_surface_reference(&surface, NULL);
assert(success);
@@ -852,7 +851,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
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;
@@ -909,7 +908,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
/* unmap the stencil buffer */
- pipe->region_unmap(pipe, ps->region);
+ pipe_surface_unmap(ps);
}
@@ -1027,11 +1026,10 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
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.
*/
@@ -1089,7 +1087,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
} /* row */
/* Release surface */
- pipe->region_unmap(pipe, surface->region);
+ pipe_surface_unmap(surface);
pipe_surface_reference(&surface, NULL);
pt->format = format;
@@ -1130,8 +1128,6 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
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;
@@ -1147,8 +1143,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
/* 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,
@@ -1192,8 +1188,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
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);
}
@@ -1252,11 +1248,11 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
/* 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 */
@@ -1267,14 +1263,14 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* 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);
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 43681b7f8a9..6b9023c4104 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -109,22 +109,22 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
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;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 83fe480af85..e2243e7de49 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -39,6 +39,7 @@
#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"
@@ -56,8 +57,6 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
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;
@@ -65,7 +64,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
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);
@@ -122,7 +121,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
/* unmap the stencil buffer */
- pipe->region_unmap(pipe, ps->region);
+ pipe_surface_unmap(ps);
}
@@ -151,7 +150,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* 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;
}
@@ -180,7 +179,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
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 */
@@ -231,7 +230,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
- pipe->region_unmap(pipe, strb->surface->region);
+ pipe_surface_unmap(strb->surface);
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index acc97df2e76..1fcef746c1f 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -64,7 +64,7 @@ struct st_texture_object
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;
@@ -721,7 +721,7 @@ st_TexImage(GLcontext * ctx,
}
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;
}
@@ -731,7 +731,7 @@ st_TexImage(GLcontext * ctx,
_mesa_unmap_teximage_pbo(ctx, unpack);
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
@@ -860,7 +860,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
}
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;
}
@@ -870,7 +870,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
/* Unmap */
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
}
@@ -948,7 +948,7 @@ st_TexSubimage(GLcontext * ctx,
}
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;
}
@@ -966,7 +966,7 @@ st_TexSubimage(GLcontext * ctx,
_mesa_unmap_teximage_pbo(ctx, packing);
if (stImage->pt) {
- st_texture_image_unmap(ctx->st, stImage);
+ st_texture_image_unmap(stImage);
texImage->Data = NULL;
}
}
@@ -1051,8 +1051,8 @@ texture_face(GLenum target)
/**
- * 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
*/
@@ -1088,8 +1088,8 @@ fallback_copy_texsubimage(GLcontext *ctx,
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));
@@ -1110,8 +1110,8 @@ fallback_copy_texsubimage(GLcontext *ctx,
}
- (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);
}
@@ -1178,8 +1178,8 @@ do_copy_texsubimage(GLcontext *ctx,
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 */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index a4ec3721bef..abde6d64b01 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -103,7 +103,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
- st->haveFramebufferRegions = GL_TRUE;
+ st->haveFramebufferSurfaces = GL_TRUE;
st->pixel_xfer.cache = _mesa_new_program_cache();
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index db97014c5a7..c31b76c63f3 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -34,7 +34,6 @@
struct st_context;
-struct st_region;
struct st_texture_object;
struct st_fragment_program;
struct draw_context;
@@ -131,11 +130,11 @@ struct st_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:
*/
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index a5582c31c0b..1ec45148736 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_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_inlines.h"
#include "pipe/p_winsys.h"
@@ -187,17 +188,15 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
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);
}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index b25e3f3f3bd..f49d91a0692 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -65,8 +65,7 @@ st_texture_image_map(struct st_context *st,
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