summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c50
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c8
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c6
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c35
-rw-r--r--src/mesa/state_tracker/st_mipmap_tree.c54
5 files changed, 80 insertions, 73 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index df41d5ce5b..39c0cf6b32 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -455,10 +455,6 @@ alloc_mipmap_tree(struct st_context *st,
cpp = st_sizeof_format(pipeFormat);
- /* allocate texture region/storage */
- mt->region = st->pipe->winsys->region_alloc(st->pipe->winsys,
- cpp, width, height, flags);
-
mt->target = PIPE_TEXTURE_2D;
mt->internal_format = GL_RGBA;
mt->format = pipeFormat;
@@ -469,7 +465,10 @@ alloc_mipmap_tree(struct st_context *st,
mt->depth0 = 1;
mt->cpp = cpp;
mt->compressed = 0;
- mt->pitch = mt->region->pitch;
+ mt->pitch = st->pipe->winsys->surface_pitch(st->pipe->winsys, cpp, width,
+ flags);
+ mt->region = st->pipe->winsys->region_alloc(st->pipe->winsys,
+ mt->pitch * cpp * height, flags);
mt->depth_pitch = 0;
mt->total_height = height;
mt->level[0].level_offset = 0;
@@ -524,7 +523,7 @@ make_mipmap_tree(struct st_context *st,
{
static const GLuint dstImageOffsets = 0;
GLboolean success;
- GLuint pitch = mt->region->pitch;
+ GLuint pitch = mt->pitch;
GLubyte *dest;
const GLbitfield imageTransferStateSave = ctx->_ImageTransferState;
@@ -569,7 +568,7 @@ make_mipmap_tree(struct st_context *st,
mt->depth0 = 1;
mt->cpp = cpp;
mt->compressed = 0;
- mt->pitch = mt->region->pitch;
+ mt->pitch = mt->pitch;
mt->depth_pitch = 0;
mt->total_height = height;
mt->level[0].level_offset = 0;
@@ -952,13 +951,13 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
switch (ps->format) {
case PIPE_FORMAT_U_S8:
{
- ubyte *dest = stmap + spanY * ps->region->pitch + spanX;
+ ubyte *dest = stmap + spanY * ps->pitch + spanX;
memcpy(dest, values, spanWidth);
}
break;
case PIPE_FORMAT_S8_Z24:
{
- uint *dest = (uint *) stmap + spanY * ps->region->pitch + spanX;
+ uint *dest = (uint *) stmap + spanY * ps->pitch + spanX;
GLint k;
for (k = 0; k < spanWidth; k++) {
uint p = dest[k];
@@ -1054,7 +1053,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
{
struct pipe_context *pipe = ctx->st->pipe;
const uint flags = PIPE_SURFACE_FLAG_TEXTURE;
- uint format = 0, cpp, comp, pitch;
+ uint format = 0, cpp, comp;
ubyte *dest;
struct pipe_mipmap_tree *mt;
int row, col;
@@ -1091,9 +1090,9 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
/* allocate texture region/storage */
+ mt->pitch = pipe->winsys->surface_pitch(pipe->winsys, cpp, width, flags);
mt->region = pipe->winsys->region_alloc(pipe->winsys,
- cpp, width, height, flags);
- pitch = mt->region->pitch;
+ mt->pitch * cpp * height, flags);
/* map texture region */
dest = pipe->region_map(pipe, mt->region);
@@ -1110,7 +1109,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
for (row = 0; row < height; row++) {
const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
- ubyte *destRow = dest + row * pitch * cpp;
+ ubyte *destRow = dest + row * mt->pitch * cpp;
if (unpack->LsbFirst) {
/* Lsb first */
@@ -1172,7 +1171,6 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
mt->depth0 = 1;
mt->cpp = cpp;
mt->compressed = 0;
- mt->pitch = mt->region->pitch;
mt->depth_pitch = 0;
mt->total_height = height;
mt->level[0].level_offset = 0;
@@ -1256,7 +1254,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
y = ctx->DrawBuffer->Height - y - 1;
}
- dst = drawMap + (y * psDraw->region->pitch + dstx) * psDraw->region->cpp;
+ dst = drawMap + (y * psDraw->pitch + dstx) * psDraw->cpp;
src = buffer + i * width;
switch (psDraw->format) {
@@ -1297,6 +1295,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
struct pipe_surface *psRead;
+ struct pipe_surface *psTex;
struct pipe_mipmap_tree *mt;
GLfloat *color;
uint format;
@@ -1332,6 +1331,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (!mt)
return;
+ psTex = pipe->get_tex_surface(pipe, mt, 0, 0, 0);
+
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
srcy = ctx->DrawBuffer->Height - srcy - height;
}
@@ -1342,21 +1343,16 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
*/
if (st->haveFramebufferRegions) {
/* copy source framebuffer region into mipmap/texture */
- pipe->region_copy(pipe,
- mt->region, /* dest */
- 0, /* dest_offset */
- 0, 0, /* destx/y */
- psRead->region,
- 0, /* src_offset */
- srcx, srcy, width, height);
+ pipe->surface_copy(pipe,
+ psTex, /* dest */
+ 0, 0, /* destx/y */
+ psRead,
+ srcx, srcy, width, height);
}
else {
/* alternate path using get/put_tile() */
- struct pipe_surface *psTex;
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- psTex = pipe->get_tex_surface(pipe, mt, 0, 0, 0);
-
(void) pipe->region_map(pipe, psRead->region);
(void) pipe->region_map(pipe, psTex->region);
@@ -1366,17 +1362,15 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
pipe->region_unmap(pipe, psRead->region);
pipe->region_unmap(pipe, psTex->region);
- pipe_surface_reference(&psTex, NULL);
-
free(buf);
}
-
/* draw textured quad */
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
mt, stvp, stfp, color, GL_TRUE);
+ pipe_surface_reference(&psTex, NULL);
free_mipmap_tree(st->pipe, mt);
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index f58d532b2a..80c92e8b7a 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -104,6 +104,9 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
assert(strb->surface);
if (!strb->surface)
return GL_FALSE;
+ strb->surface->cpp = cpp;
+ strb->surface->pitch = pipe->winsys->surface_pitch(pipe->winsys, cpp,
+ width, flags);
}
/* free old region */
@@ -115,8 +118,9 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
pipe->winsys->region_release(pipe->winsys, &strb->surface->region);
}
- strb->surface->region = pipe->winsys->region_alloc(pipe->winsys, cpp,
- width, height, flags);
+ strb->surface->region = pipe->winsys->region_alloc(pipe->winsys,
+ strb->surface->pitch *
+ cpp * height, flags);
if (!strb->surface->region)
return GL_FALSE; /* out of memory, try s/w buffer? */
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 2e7c01672a..83fe480af8 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -87,13 +87,13 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
switch (ps->format) {
case PIPE_FORMAT_U_S8:
{
- const ubyte *src = stmap + srcY * ps->region->pitch + x;
+ const ubyte *src = stmap + srcY * ps->pitch + x;
memcpy(values, src, width);
}
break;
case PIPE_FORMAT_S8_Z24:
{
- const uint *src = (uint *) stmap + srcY * ps->region->pitch + x;
+ const uint *src = (uint *) stmap + srcY * ps->pitch + x;
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] >> 24;
@@ -102,7 +102,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
break;
case PIPE_FORMAT_Z24_S8:
{
- const uint *src = (uint *) stmap + srcY * ps->region->pitch + x;
+ const uint *src = (uint *) stmap + srcY * ps->pitch + x;
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] & 0xff;
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 4e6d4857f4..461705119f 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -44,6 +44,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
#define DBG if (0) printf
@@ -1150,7 +1151,6 @@ do_copy_texsubimage(GLcontext *ctx,
struct st_renderbuffer *strb;
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_region *src_region, *dest_region;
- uint dest_offset, src_offset;
uint dest_format, src_format;
(void) texImage;
@@ -1185,12 +1185,13 @@ do_copy_texsubimage(GLcontext *ctx,
ctx->_ImageTransferState == 0x0 &&
src_region &&
dest_region &&
- src_region->cpp == dest_region->cpp) {
+ strb->surface->cpp == stImage->mt->cpp) {
/* do blit-style copy */
- src_offset = 0;
- dest_offset = st_miptree_image_offset(stImage->mt,
- stImage->face,
- stImage->level);
+ struct pipe_surface *dest_surface = pipe->get_tex_surface(pipe,
+ stImage->mt,
+ stImage->face,
+ stImage->level,
+ destZ);
/* XXX may need to invert image depending on window
* vs. user-created FBO
@@ -1213,18 +1214,18 @@ do_copy_texsubimage(GLcontext *ctx,
GL_COPY); /* ? */
#else
- pipe->region_copy(pipe,
- /* dest */
- dest_region,
- dest_offset,
- destX, destY,
- /* src */
- src_region,
- src_offset,
- srcX, srcY,
- /* size */
- width, height);
+ pipe->surface_copy(pipe,
+ /* dest */
+ dest_surface,
+ destX, destY,
+ /* src */
+ strb->surface,
+ srcX, srcY,
+ /* size */
+ width, height);
#endif
+
+ pipe_surface_reference(&dest_surface, NULL);
}
else {
fallback_copy_texsubimage(ctx, target, level,
diff --git a/src/mesa/state_tracker/st_mipmap_tree.c b/src/mesa/state_tracker/st_mipmap_tree.c
index d1db590bee..6ccf33105f 100644
--- a/src/mesa/state_tracker/st_mipmap_tree.c
+++ b/src/mesa/state_tracker/st_mipmap_tree.c
@@ -31,6 +31,8 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
@@ -87,10 +89,9 @@ st_miptree_create(struct pipe_context *pipe,
ok = pipe->mipmap_tree_layout(pipe, mt);
if (ok) {
- /* note: it's OK to pass 'pitch' as 'width' here: */
- mt->region = pipe->winsys->region_alloc(pipe->winsys, mt->cpp, mt->pitch,
- mt->total_height, flags);
- mt->pitch = mt->region->pitch; /*XXX NEW */
+ mt->region = pipe->winsys->region_alloc(pipe->winsys,
+ mt->pitch * mt->cpp *
+ mt->total_height, flags);
}
if (!mt->region) {
@@ -266,24 +267,27 @@ st_miptree_image_data(struct pipe_context *pipe,
GLuint src_row_pitch, GLuint src_image_pitch)
{
GLuint depth = dst->level[level].depth;
- GLuint dst_offset = st_miptree_image_offset(dst, face, level);
- const GLuint *dst_depth_offset = st_miptree_depth_offsets(dst, level);
GLuint i;
GLuint height = 0;
const GLubyte *srcUB = src;
+ struct pipe_surface *dst_surface;
DBG("%s\n", __FUNCTION__);
for (i = 0; i < depth; i++) {
height = dst->level[level].height;
if(dst->compressed)
height /= 4;
- pipe->region_data(pipe, dst->region,
- dst_offset + dst_depth_offset[i], /* dst_offset */
- 0, 0, /* dstx, dsty */
- srcUB,
- src_row_pitch,
- 0, 0, /* source x, y */
- dst->level[level].width, height); /* width, height */
+
+ dst_surface = pipe->get_tex_surface(pipe, dst, face, level, i);
+
+ pipe->surface_data(pipe, dst_surface,
+ 0, 0, /* dstx, dsty */
+ srcUB,
+ src_row_pitch,
+ 0, 0, /* source x, y */
+ dst->level[level].width, height); /* width, height */
+
+ pipe_surface_reference(&dst_surface, NULL);
srcUB += src_image_pitch * dst->cpp;
}
@@ -300,21 +304,25 @@ st_miptree_image_copy(struct pipe_context *pipe,
GLuint width = src->level[level].width;
GLuint height = src->level[level].height;
GLuint depth = src->level[level].depth;
- GLuint dst_offset = st_miptree_image_offset(dst, face, level);
- GLuint src_offset = st_miptree_image_offset(src, face, level);
- const GLuint *dst_depth_offset = st_miptree_depth_offsets(dst, level);
- const GLuint *src_depth_offset = st_miptree_depth_offsets(src, level);
+ struct pipe_surface *src_surface;
+ struct pipe_surface *dst_surface;
GLuint i;
if (dst->compressed)
height /= 4;
for (i = 0; i < depth; i++) {
- pipe->region_copy(pipe,
- dst->region, dst_offset + dst_depth_offset[i],
- 0, 0, /* destX, Y */
- src->region, src_offset + src_depth_offset[i],
- 0, 0, /* srcX, Y */
- width, height);
+ dst_surface = pipe->get_tex_surface(pipe, dst, face, level, i);
+ src_surface = pipe->get_tex_surface(pipe, src, face, level, i);
+
+ pipe->surface_copy(pipe,
+ dst_surface,
+ 0, 0, /* destX, Y */
+ src_surface,
+ 0, 0, /* srcX, Y */
+ width, height);
+
+ pipe_surface_reference(&dst_surface, NULL);
+ pipe_surface_reference(&src_surface, NULL);
}
}