* texels which are zero. Special case the 1x1 and 2x2 levels.
*/
for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
const uint size = aaline->texture->width[level];
ubyte *data;
uint i, j;
/* This texture is new, no need to flush.
*/
- surface = screen->get_tex_surface(screen, aaline->texture, 0, level, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- data = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, aaline->texture, 0, level, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, size, size);
+ data = screen->transfer_map(screen, transfer);
if (data == NULL)
return FALSE;
else {
d = 255;
}
- data[i * surface->stride + j] = d;
+ data[i * transfer->stride + j] = d;
}
}
/* unmap */
- screen->surface_unmap(screen, surface);
- screen->tex_surface_release(screen, &surface);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_release(screen, &transfer);
}
return TRUE;
}
static const uint bit31 = 1 << 31;
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
const uint *stipple = pstip->state.stipple->stipple;
uint i, j;
ubyte *data;
*/
pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL );
- surface = screen->get_tex_surface(screen, pstip->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- data = screen->surface_map(screen, surface,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, pstip->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
+ data = screen->transfer_map(screen, transfer);
/*
* Load alpha texture.
for (j = 0; j < 32; j++) {
if (stipple[i] & (bit31 >> j)) {
/* fragment "on" */
- data[i * surface->stride + j] = 0;
+ data[i * transfer->stride + j] = 0;
}
else {
/* fragment "off" */
- data[i * surface->stride + j] = 255;
+ data[i * transfer->stride + j] = 255;
}
}
}
/* unmap */
- screen->surface_unmap(screen, surface);
- screen->tex_surface_release(screen, &surface);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_release(screen, &transfer);
}
void debug_dump_surface(const char *prefix,
struct pipe_surface *surface)
{
- unsigned surface_usage;
+ struct pipe_texture *texture;
+ struct pipe_screen *screen;
+ struct pipe_transfer *transfer;
void *data;
if (!surface)
- goto error1;
+ return;
+
+ texture = surface->texture;
+ screen = texture->screen;
- /* XXX: force mappable surface */
- surface_usage = surface->usage;
- surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ transfer = screen->get_tex_transfer(screen, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
- data = pipe_surface_map(surface,
- PIPE_BUFFER_USAGE_CPU_READ);
+ data = screen->transfer_map(screen, transfer);
if(!data)
- goto error2;
+ goto error;
debug_dump_image(prefix,
- surface->format,
- surface->block.size,
- surface->nblocksx,
- surface->nblocksy,
- surface->stride,
+ transfer->format,
+ transfer->block.size,
+ transfer->nblocksx,
+ transfer->nblocksy,
+ transfer->stride,
data);
- pipe_surface_unmap(surface);
-error2:
- surface->usage = surface_usage;
-error1:
- ;
+ screen->transfer_unmap(screen, transfer);
+error:
+ screen->tex_transfer_release(screen, &transfer);
}
struct pipe_surface *surface)
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
+ struct pipe_texture *texture;
+ struct pipe_screen *screen;
struct util_stream *stream;
- unsigned surface_usage;
+ struct pipe_transfer *transfer;
struct bmp_file_header bmfh;
struct bmp_info_header bmih;
float *rgba;
util_stream_write(stream, &bmfh, 14);
util_stream_write(stream, &bmih, 40);
+
+ texture = surface->texture;
+ screen = texture->screen;
- /* XXX: force mappable surface */
- surface_usage = surface->usage;
- surface->usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ transfer = screen->get_tex_transfer(screen, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
y = surface->height;
while(y--) {
- pipe_get_tile_rgba(surface,
+ pipe_get_tile_rgba(transfer,
0, y, surface->width, 1,
rgba);
for(x = 0; x < surface->width; ++x)
util_stream_write(stream, &pixel, 4);
}
}
-
- surface->usage = surface_usage;
+ screen->tex_transfer_release(screen, &transfer);
+
util_stream_close(stream);
error2:
FREE(rgba);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_1d(pt->format,
- srcSurf->width, srcMap,
- dstSurf->width, dstMap);
+ srcTrans->width, srcMap,
+ dstTrans->width, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_release(screen, &srcTrans);
+ screen->tex_transfer_release(screen, &dstTrans);
}
}
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_2d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_release(screen, &srcTrans);
+ screen->tex_transfer_release(screen, &dstTrans);
}
}
struct pipe_texture *pt,
uint face, uint baseLevel, uint lastLevel)
{
+#if 0
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
-#if 0
reduce_3d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
-#else
- (void) reduce_3d;
-#endif
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_release(screen, &srcTrans);
+ screen->tex_transfer_release(screen, &dstTrans);
}
+#else
+ (void) reduce_3d;
+#endif
}
unsigned w, unsigned h)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *new_src = NULL, *new_dst = NULL;
+ struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
- assert(dst->block.size == src->block.size);
- assert(dst->block.width == src->block.width);
- assert(dst->block.height == src->block.height);
+ assert(dst_trans->block.size == src_trans->block.size);
+ assert(dst_trans->block.width == src_trans->block.width);
+ assert(dst_trans->block.height == src_trans->block.height);
- if ((src->usage & PIPE_BUFFER_USAGE_CPU_READ) == 0) {
- /* Need to create new src surface which is CPU readable */
- assert(src->texture);
- if (!src->texture)
- return;
- new_src = screen->get_tex_surface(screen,
+ assert(src->texture && dst->texture);
+ if (!src->texture || !dst->texture)
+ return;
+ src_trans = screen->get_tex_transfer(screen,
src->texture,
src->face,
src->level,
src->zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- src = new_src;
- }
+ PIPE_TRANSFER_READ,
+ src_x, src_y, w, h);
- if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) {
- /* Need to create new dst surface which is CPU writable */
- assert(dst->texture);
- if (!dst->texture)
- return;
- new_dst = screen->get_tex_surface(screen,
+ dst_trans = screen->get_tex_transfer(screen,
dst->texture,
dst->face,
dst->level,
dst->zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- dst = new_dst;
- }
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h);
- src_map = pipe->screen->surface_map(screen,
- src, PIPE_BUFFER_USAGE_CPU_READ);
- dst_map = pipe->screen->surface_map(screen,
- dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+ src_map = pipe->screen->transfer_map(screen, src_trans);
+ dst_map = pipe->screen->transfer_map(screen, dst_trans);
assert(src_map);
assert(dst_map);
if (src_map && dst_map) {
/* If do_flip, invert src_y position and pass negative src stride */
pipe_copy_rect(dst_map,
- &dst->block,
- dst->stride,
- dst_x, dst_y,
+ &dst_trans->block,
+ dst_trans->stride,
+ 0, 0,
w, h,
src_map,
- do_flip ? -(int) src->stride : src->stride,
- src_x,
- do_flip ? src_y + h - 1 : src_y);
+ do_flip ? -(int) src_trans->stride : src_trans->stride,
+ 0,
+ do_flip ? h - 1 : 0);
}
- pipe->screen->surface_unmap(pipe->screen, src);
- pipe->screen->surface_unmap(pipe->screen, dst);
+ pipe->screen->transfer_unmap(pipe->screen, src_trans);
+ pipe->screen->transfer_unmap(pipe->screen, dst_trans);
- if (new_src)
- screen->tex_surface_release(screen, &new_src);
- if (new_dst)
- screen->tex_surface_release(screen, &new_dst);
+ screen->tex_transfer_release(screen, &src_trans);
+ screen->tex_transfer_release(screen, &dst_trans);
}
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map
- + y / dst->block.height * dst->stride
- + x / dst->block.width * dst->block.size;
-}
-
-
#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
unsigned width, unsigned height, unsigned value)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *new_dst = NULL;
+ struct pipe_transfer *dst_trans;
void *dst_map;
- if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) {
- /* Need to create new dst surface which is CPU writable */
- assert(dst->texture);
- if (!dst->texture)
- return;
- new_dst = screen->get_tex_surface(screen,
+ assert(dst->texture);
+ if (!dst->texture)
+ return;
+ dst_trans = screen->get_tex_transfer(screen,
dst->texture,
dst->face,
dst->level,
dst->zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- dst = new_dst;
- }
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height);
- dst_map = pipe->screen->surface_map(screen,
- dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst_map = pipe->screen->transfer_map(screen, dst_trans);
assert(dst_map);
if (dst_map) {
- assert(dst->stride > 0);
+ assert(dst_trans->stride > 0);
- switch (dst->block.size) {
+ switch (dst_trans->block.size) {
case 1:
case 2:
case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride,
- dstx, dsty, width, height, value);
+ pipe_fill_rect(dst_map, &dst_trans->block, dst_trans->stride,
+ 0, 0, width, height, value);
break;
case 8:
{
/* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty);
+ ushort *row = (ushort *) dst_map;
ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
row[j*4+2] = val2;
row[j*4+3] = val3;
}
- row += dst->stride/2;
+ row += dst_trans->stride/2;
}
}
break;
}
}
- pipe->screen->surface_unmap(pipe->screen, dst);
-
- if (new_dst)
- screen->tex_surface_release(screen, &new_dst);
+ pipe->screen->transfer_unmap(pipe->screen, dst_trans);
+ screen->tex_transfer_release(screen, &dst_trans);
}
/**
* RGBA/float tile get/put functions.
* Usable both by drivers and state trackers.
- * Surfaces should already be in a mapped state.
*/
/**
- * Move raw block of pixels from surface to user memory.
- * This should be usable by any hw driver that has mappable surfaces.
+ * Move raw block of pixels from transfer object to user memory.
*/
void
-pipe_get_tile_raw(struct pipe_surface *ps,
+pipe_get_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
void *dst, int dst_stride)
{
+ struct pipe_screen *screen = pt->texture->screen;
const void *src;
if (dst_stride == 0)
- dst_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
+ dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- src = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ);
+ src = screen->transfer_map(screen, pt);
assert(src);
if(!src)
return;
- pipe_copy_rect(dst, &ps->block, dst_stride, 0, 0, w, h, src, ps->stride, x, y);
+ pipe_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
/**
- * Move raw block of pixels from user memory to surface.
- * This should be usable by any hw driver that has mappable surfaces.
+ * Move raw block of pixels from user memory to transfer object.
*/
void
-pipe_put_tile_raw(struct pipe_surface *ps,
+pipe_put_tile_raw(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const void *src, int src_stride)
{
+ struct pipe_screen *screen = pt->texture->screen;
void *dst;
if (src_stride == 0)
- src_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
+ src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- dst = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst = screen->transfer_map(screen, pt);
assert(dst);
if(!dst)
return;
- pipe_copy_rect(dst, &ps->block, ps->stride, x, y, w, h, src, src_stride, 0, 0);
+ pipe_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0);
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
void
-pipe_get_tile_rgba(struct pipe_surface *ps,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
float *p)
{
unsigned dst_stride = w * 4;
void *packed;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size);
+ packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
if (!packed)
return;
- if(ps->format == PIPE_FORMAT_YCBCR || ps->format == PIPE_FORMAT_YCBCR_REV)
+ if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV)
assert((x & 1) == 0);
- pipe_get_tile_raw(ps, x, y, w, h, packed, 0);
+ pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
- pipe_tile_raw_to_rgba(ps->format, packed, w, h, p, dst_stride);
+ pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride);
FREE(packed);
}
void
-pipe_put_tile_rgba(struct pipe_surface *ps,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const float *p)
{
unsigned src_stride = w * 4;
void *packed;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size);
+ packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
if (!packed)
return;
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
assert(0);
}
- pipe_put_tile_raw(ps, x, y, w, h, packed, 0);
+ pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
FREE(packed);
}
* Get a block of Z values, converted to 32-bit range.
*/
void
-pipe_get_tile_z(struct pipe_surface *ps,
+pipe_get_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
uint *z)
{
+ struct pipe_screen *screen = pt->texture->screen;
const uint dstStride = w;
ubyte *map;
uint *pDest = z;
uint i, j;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ);
+ map = (ubyte *)screen->transfer_map(screen, pt);
if (!map) {
assert(0);
return;
}
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_Z32_UNORM:
{
- const uint *pSrc
- = (const uint *)(map + y * ps->stride + x*4);
+ const uint *ptrc
+ = (const uint *)(map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, 4 * w);
+ memcpy(pDest, ptrc, 4 * w);
pDest += dstStride;
- pSrc += ps->stride/4;
+ ptrc += pt->stride/4;
}
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
{
- const uint *pSrc
- = (const uint *)(map + y * ps->stride + x*4);
+ const uint *ptrc
+ = (const uint *)(map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 24-bit Z to 32-bit Z */
- pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff);
+ pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
}
pDest += dstStride;
- pSrc += ps->stride/4;
+ ptrc += pt->stride/4;
}
}
break;
case PIPE_FORMAT_Z16_UNORM:
{
- const ushort *pSrc
- = (const ushort *)(map + y * ps->stride + x*2);
+ const ushort *ptrc
+ = (const ushort *)(map + y * pt->stride + x*2);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 16-bit Z to 32-bit Z */
- pDest[j] = (pSrc[j] << 16) | pSrc[j];
+ pDest[j] = (ptrc[j] << 16) | ptrc[j];
}
pDest += dstStride;
- pSrc += ps->stride/2;
+ ptrc += pt->stride/2;
}
}
break;
assert(0);
}
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
void
-pipe_put_tile_z(struct pipe_surface *ps,
+pipe_put_tile_z(struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const uint *zSrc)
{
+ struct pipe_screen *screen = pt->texture->screen;
const uint srcStride = w;
- const uint *pSrc = zSrc;
+ const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
- if (pipe_clip_tile(x, y, &w, &h, ps))
+ if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = (ubyte *)screen->transfer_map(screen, pt);
if (!map) {
assert(0);
return;
}
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_Z32_UNORM:
{
- uint *pDest = (uint *) (map + y * ps->stride + x*4);
+ uint *pDest = (uint *) (map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, 4 * w);
- pDest += ps->stride/4;
- pSrc += srcStride;
+ memcpy(pDest, ptrc, 4 * w);
+ pDest += pt->stride/4;
+ ptrc += srcStride;
}
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
{
- uint *pDest = (uint *) (map + y * ps->stride + x*4);
+ uint *pDest = (uint *) (map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z (0 stencil) */
- pDest[j] = pSrc[j] >> 8;
+ pDest[j] = ptrc[j] >> 8;
}
- pDest += ps->stride/4;
- pSrc += srcStride;
+ pDest += pt->stride/4;
+ ptrc += srcStride;
}
}
break;
case PIPE_FORMAT_Z16_UNORM:
{
- ushort *pDest = (ushort *) (map + y * ps->stride + x*2);
+ ushort *pDest = (ushort *) (map + y * pt->stride + x*2);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 16-bit Z */
- pDest[j] = pSrc[j] >> 16;
+ pDest[j] = ptrc[j] >> 16;
}
- pDest += ps->stride/2;
- pSrc += srcStride;
+ pDest += pt->stride/2;
+ ptrc += srcStride;
}
}
break;
assert(0);
}
- pipe_surface_unmap(ps);
+ screen->transfer_unmap(screen, pt);
}
#include "pipe/p_compiler.h"
-struct pipe_surface;
+struct pipe_transfer;
/**
- * Clip tile against surface dims.
+ * Clip tile against transfer dims.
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
-pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps)
+pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_transfer *ps)
{
if (x >= ps->width)
return TRUE;
#endif
void
-pipe_get_tile_raw(struct pipe_surface *ps,
+pipe_get_tile_raw(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
void *p, int dst_stride);
void
-pipe_put_tile_raw(struct pipe_surface *ps,
+pipe_put_tile_raw(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
const void *p, int src_stride);
void
-pipe_get_tile_rgba(struct pipe_surface *ps,
+pipe_get_tile_rgba(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
float *p);
void
-pipe_put_tile_rgba(struct pipe_surface *ps,
+pipe_put_tile_rgba(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
const float *p);
void
-pipe_get_tile_z(struct pipe_surface *ps,
+pipe_get_tile_z(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
uint *z);
void
-pipe_put_tile_z(struct pipe_surface *ps,
+pipe_put_tile_z(struct pipe_transfer *ps,
uint x, uint y, uint w, uint h,
const uint *z);
* Map any drawing surfaces which aren't already mapped
*/
void
-softpipe_map_surfaces(struct softpipe_context *sp)
+softpipe_map_transfers(struct softpipe_context *sp)
{
unsigned i;
for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_map_surfaces(sp->cbuf_cache[i]);
+ sp_tile_cache_map_transfers(sp->cbuf_cache[i]);
}
- sp_tile_cache_map_surfaces(sp->zsbuf_cache);
+ sp_tile_cache_map_transfers(sp->zsbuf_cache);
}
* Unmap any mapped drawing surfaces
*/
void
-softpipe_unmap_surfaces(struct softpipe_context *sp)
+softpipe_unmap_transfers(struct softpipe_context *sp)
{
uint i;
sp_flush_tile_cache(sp, sp->zsbuf_cache);
for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]);
+ sp_tile_cache_unmap_transfers(sp->cbuf_cache[i]);
}
- sp_tile_cache_unmap_surfaces(sp->zsbuf_cache);
+ sp_tile_cache_unmap_transfers(sp->zsbuf_cache);
}
if (sp->dirty)
softpipe_update_derived( sp );
- softpipe_map_surfaces(sp);
+ softpipe_map_transfers(sp);
softpipe_map_constant_buffers(sp);
/*
* that's called before swapbuffers because we don't always want
* to unmap surfaces when flushing.
*/
- softpipe_unmap_surfaces(softpipe);
+ softpipe_unmap_transfers(softpipe);
}
/* Enable to dump BMPs of the color/depth buffers each frame */
void
-softpipe_map_surfaces(struct softpipe_context *sp);
+softpipe_map_transfers(struct softpipe_context *sp);
void
-softpipe_unmap_surfaces(struct softpipe_context *sp);
+softpipe_unmap_transfers(struct softpipe_context *sp);
void
softpipe_map_texture_surfaces(struct softpipe_context *sp);
ps->refcount = 1;
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
- ps->block = pt->block;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->nblocksx = pt->nblocksx[level];
- ps->nblocksy = pt->nblocksy[level];
- ps->stride = spt->stride[level];
ps->offset = spt->level_offset[level];
ps->usage = usage;
if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- ps->nblocksy *
- ps->stride;
+ pt->nblocksy[level] * spt->stride[level];
}
else {
assert(face == 0);
}
+static struct pipe_transfer *
+softpipe_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y, unsigned w, unsigned h)
+{
+ struct softpipe_texture *sptex = softpipe_texture(texture);
+ struct softpipe_transfer *spt;
+ struct pipe_transfer *pt;
+
+ assert(texture);
+ assert(level <= texture->last_level);
+
+ spt = CALLOC_STRUCT(softpipe_transfer);
+ pt = &spt->base;
+ if (spt) {
+ pt->refcount = 1;
+ pipe_texture_reference(&pt->texture, texture);
+ pt->format = texture->format;
+ pt->block = texture->block;
+ pt->x = x;
+ pt->y = y;
+ pt->width = w;
+ pt->height = h;
+ pt->nblocksx = texture->nblocksx[level];
+ pt->nblocksy = texture->nblocksy[level];
+ pt->stride = sptex->stride[level];
+ spt->offset = sptex->level_offset[level];
+ pt->usage = usage;
+ pt->face = face;
+ pt->level = level;
+ pt->zslice = zslice;
+
+ if (texture->target == PIPE_TEXTURE_CUBE ||
+ texture->target == PIPE_TEXTURE_3D) {
+ spt->offset += ((texture->target == PIPE_TEXTURE_CUBE) ? face :
+ zslice) * pt->nblocksy * pt->stride;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+ }
+ return pt;
+}
+
+
+static void
+softpipe_tex_transfer_release(struct pipe_screen *screen,
+ struct pipe_transfer **t)
+{
+ struct softpipe_transfer *transfer = softpipe_transfer(*t);
+ /* Effectively do the texture_update work here - if texture images
+ * needed post-processing to put them into hardware layout, this is
+ * where it would happen. For softpipe, nothing to do.
+ */
+ assert (transfer->base.texture);
+ if (--transfer->base.refcount == 0) {
+ pipe_texture_reference(&transfer->base.texture, NULL);
+ FREE(transfer);
+ }
+ *t = NULL;
+}
+
+
static void *
-softpipe_surface_map( struct pipe_screen *screen,
- struct pipe_surface *surface,
- unsigned flags )
+softpipe_transfer_map( struct pipe_screen *screen,
+ struct pipe_transfer *transfer )
{
ubyte *map;
struct softpipe_texture *spt;
+ unsigned flags = 0;
- if (flags & ~surface->usage) {
- assert(0);
- return NULL;
+ assert(transfer->texture);
+ spt = softpipe_texture(transfer->texture);
+
+ if (transfer->usage != PIPE_TRANSFER_READ) {
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ }
+
+ if (transfer->usage != PIPE_TRANSFER_WRITE) {
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
}
- assert(surface->texture);
- spt = softpipe_texture(surface->texture);
map = pipe_buffer_map(screen, spt->buffer, flags);
if (map == NULL)
return NULL;
/* May want to different things here depending on read/write nature
* of the map:
*/
- if (surface->texture &&
- (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
+ if (transfer->texture && transfer->usage != PIPE_TRANSFER_READ)
{
/* Do something to notify sharing contexts of a texture change.
* In softpipe, that would mean flushing the texture cache.
softpipe_screen(screen)->timestamp++;
}
- return map + surface->offset;
+ return map + softpipe_transfer(transfer)->offset +
+ transfer->y / transfer->block.height * transfer->stride +
+ transfer->x / transfer->block.width * transfer->block.size;
}
static void
-softpipe_surface_unmap(struct pipe_screen *screen,
- struct pipe_surface *surface)
+softpipe_transfer_unmap(struct pipe_screen *screen,
+ struct pipe_transfer *transfer)
{
struct softpipe_texture *spt;
- assert(surface->texture);
- spt = softpipe_texture(surface->texture);
+ assert(transfer->texture);
+ spt = softpipe_texture(transfer->texture);
pipe_buffer_unmap( screen, spt->buffer );
}
screen->get_tex_surface = softpipe_get_tex_surface;
screen->tex_surface_release = softpipe_tex_surface_release;
- screen->surface_map = softpipe_surface_map;
- screen->surface_unmap = softpipe_surface_unmap;
+ screen->get_tex_transfer = softpipe_get_tex_transfer;
+ screen->tex_transfer_release = softpipe_tex_transfer_release;
+ screen->transfer_map = softpipe_transfer_map;
+ screen->transfer_unmap = softpipe_transfer_unmap;
}
boolean modified;
};
+struct softpipe_transfer
+{
+ struct pipe_transfer base;
+
+ unsigned long offset;
+};
+
-/** cast wrapper */
+/** cast wrappers */
static INLINE struct softpipe_texture *
softpipe_texture(struct pipe_texture *pt)
{
return (struct softpipe_texture *) pt;
}
+static INLINE struct softpipe_transfer *
+softpipe_transfer(struct pipe_transfer *pt)
+{
+ return (struct softpipe_transfer *) pt;
+}
+
extern void
softpipe_init_texture_funcs( struct softpipe_context *softpipe );
**************************************************************************/
/**
- * Framebuffer/surface tile caching.
+ * Texture tile caching.
*
* Author:
* Brian Paul
{
struct pipe_screen *screen;
struct pipe_surface *surface; /**< the surface we're caching */
- void *surface_map;
+ struct pipe_transfer *transfer;
+ void *transfer_map;
struct pipe_texture *texture; /**< if caching a texture */
struct softpipe_cached_tile entries[NUM_ENTRIES];
uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
uint clear_val;
boolean depth_stencil; /** Is the surface a depth/stencil format? */
- struct pipe_surface *tex_surf;
- void *tex_surf_map;
+ struct pipe_transfer *tex_trans;
+ void *tex_trans_map;
int tex_face, tex_level, tex_z;
struct softpipe_cached_tile tile; /**< scratch tile for clears */
void
sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
{
+ struct pipe_screen *screen;
uint pos;
for (pos = 0; pos < NUM_ENTRIES; pos++) {
/*assert(tc->entries[pos].x < 0);*/
}
- if (tc->surface) {
- pipe_surface_reference(&tc->surface, NULL);
+ if (tc->transfer) {
+ screen = tc->transfer->texture->screen;
+ screen->tex_transfer_release(screen, &tc->transfer);
}
- if (tc->tex_surf) {
- pipe_surface_reference(&tc->tex_surf, NULL);
+ if (tc->tex_trans) {
+ screen = tc->tex_trans->texture->screen;
+ screen->tex_transfer_release(screen, &tc->tex_trans);
}
FREE( tc );
sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
struct pipe_surface *ps)
{
+ struct pipe_screen *screen = ps->texture->screen;
+
assert(!tc->texture);
- if (tc->surface_map) {
- tc->screen->surface_unmap(tc->screen, tc->surface);
- tc->surface_map = NULL;
- }
+ if (tc->transfer) {
+ if (ps->texture == tc->transfer->texture &&
+ ps->face == tc->transfer->face &&
+ ps->level == tc->transfer->level &&
+ ps->zslice == tc->transfer->zslice)
+ return;
- pipe_surface_reference(&tc->surface, ps);
-
- if (tc->surface) {
- if (tc->surface_map) /* XXX: this is always NULL!? */
- tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
- ps->format == PIPE_FORMAT_X8Z24_UNORM ||
- ps->format == PIPE_FORMAT_Z24S8_UNORM ||
- ps->format == PIPE_FORMAT_Z24X8_UNORM ||
- ps->format == PIPE_FORMAT_Z16_UNORM ||
- ps->format == PIPE_FORMAT_Z32_UNORM ||
- ps->format == PIPE_FORMAT_S8_UNORM);
+ if (tc->transfer_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->transfer);
+ tc->transfer_map = NULL;
+ }
+
+ screen->tex_transfer_release(screen, &tc->transfer);
}
+
+ tc->transfer = screen->get_tex_transfer(screen, ps->texture, ps->face,
+ ps->level, ps->zslice,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, ps->width, ps->height);
+
+ tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
+ ps->format == PIPE_FORMAT_X8Z24_UNORM ||
+ ps->format == PIPE_FORMAT_Z24S8_UNORM ||
+ ps->format == PIPE_FORMAT_Z24X8_UNORM ||
+ ps->format == PIPE_FORMAT_Z16_UNORM ||
+ ps->format == PIPE_FORMAT_Z32_UNORM ||
+ ps->format == PIPE_FORMAT_S8_UNORM);
}
/**
- * Return the surface being cached.
+ * Return the transfer being cached.
*/
struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc)
+sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc)
{
- if (tc->surface && !tc->surface_map)
- tc->surface_map = tc->screen->surface_map(tc->screen, tc->surface,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ);
-
- if (tc->tex_surf && !tc->tex_surf_map)
- tc->tex_surf_map = tc->screen->surface_map(tc->screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ if (tc->transfer && !tc->transfer_map)
+ tc->transfer_map = tc->screen->transfer_map(tc->screen, tc->transfer);
+
+ if (tc->tex_trans && !tc->tex_trans_map)
+ tc->tex_trans_map = tc->screen->transfer_map(tc->screen, tc->tex_trans);
}
void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc)
+sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc)
{
- if (tc->surface_map) {
- tc->screen->surface_unmap(tc->screen, tc->surface);
- tc->surface_map = NULL;
+ if (tc->transfer_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->transfer);
+ tc->transfer_map = NULL;
}
- if (tc->tex_surf_map) {
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
- tc->tex_surf_map = NULL;
+ if (tc->tex_trans_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ tc->tex_trans_map = NULL;
}
}
struct softpipe_tile_cache *tc,
struct pipe_texture *texture)
{
+ struct pipe_screen *screen = texture->screen;
uint i;
- assert(!tc->surface);
+ assert(!tc->transfer);
pipe_texture_reference(&tc->texture, texture);
- if (tc->tex_surf_map) {
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
- tc->tex_surf_map = NULL;
+ if (tc->tex_trans_map) {
+ tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ tc->tex_trans_map = NULL;
}
- pipe_surface_reference(&tc->tex_surf, NULL);
+ screen->tex_transfer_release(screen, &tc->tex_trans);
/* mark as entries as invalid/empty */
/* XXX we should try to avoid this when the teximage hasn't changed */
sp_tile_cache_flush_clear(struct pipe_context *pipe,
struct softpipe_tile_cache *tc)
{
- struct pipe_surface *ps = tc->surface;
- const uint w = tc->surface->width;
- const uint h = tc->surface->height;
+ struct pipe_transfer *ps = tc->transfer;
+ const uint w = tc->transfer->width;
+ const uint h = tc->transfer->height;
uint x, y;
uint numCleared = 0;
/**
- * Flush the tile cache: write all dirty tiles back to the surface.
+ * Flush the tile cache: write all dirty tiles back to the transfer.
* any tiles "flagged" as cleared will be "really" cleared.
*/
void
sp_flush_tile_cache(struct softpipe_context *softpipe,
struct softpipe_tile_cache *tc)
{
- struct pipe_surface *ps = tc->surface;
+ struct pipe_transfer *ps = tc->transfer;
int inuse = 0, pos;
if (ps) {
- /* caching a drawing surface */
+ /* caching a drawing transfer */
for (pos = 0; pos < NUM_ENTRIES; pos++) {
struct softpipe_cached_tile *tile = tc->entries + pos;
if (tile->x >= 0) {
sp_get_cached_tile(struct softpipe_context *softpipe,
struct softpipe_tile_cache *tc, int x, int y)
{
- struct pipe_surface *ps = tc->surface;
+ struct pipe_transfer *ps = tc->transfer;
/* tile pos in framebuffer: */
const int tile_x = x & ~(TILE_SIZE - 1);
clear_clear_flag(tc->clear_flags, x, y);
}
else {
- /* get new tile data from surface */
+ /* get new tile data from transfer */
if (tc->depth_stencil) {
pipe_get_tile_raw(ps,
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
level != tile->level) {
/* cache miss */
- /* check if we need to get a new surface */
- if (!tc->tex_surf ||
+ /* check if we need to get a new transfer */
+ if (!tc->tex_trans ||
tc->tex_face != face ||
tc->tex_level != level ||
tc->tex_z != z) {
- /* get new surface (view into texture) */
+ /* get new transfer (view into texture) */
- if (tc->tex_surf_map)
- tc->screen->surface_unmap(tc->screen, tc->tex_surf);
+ if (tc->tex_trans_map)
+ tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ screen->tex_transfer_release(screen, &tc->tex_trans);
- tc->tex_surf = screen->get_tex_surface(screen, tc->texture, face, level, z,
- PIPE_BUFFER_USAGE_CPU_READ);
- tc->tex_surf_map = screen->surface_map(screen, tc->tex_surf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ tc->tex_trans = screen->get_tex_transfer(screen, tc->texture, face, level, z,
+ PIPE_TRANSFER_READ, 0, 0,
+ tc->texture->width[level],
+ tc->texture->height[level]);
+ tc->tex_trans_map = screen->transfer_map(screen, tc->tex_trans);
tc->tex_face = face;
tc->tex_level = level;
tc->tex_z = z;
}
- /* get tile from the surface (view into texture) */
- pipe_get_tile_rgba(tc->tex_surf,
+ /* get tile from the transfer (view into texture) */
+ pipe_get_tile_rgba(tc->tex_trans,
tile_x, tile_y, TILE_SIZE, TILE_SIZE,
(float *) tile->data.color);
tile->x = tile_x;
tc->clear_val = clearValue;
- switch (tc->surface->format) {
+ switch (tc->transfer->format) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
r = (clearValue >> 24) & 0xff;
g = (clearValue >> 16) & 0xff;
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc);
+sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc);
+sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc);
extern void
sp_tile_cache_set_texture(struct pipe_context *pipe,
/**
+ * Transfer object usage flags
+ */
+enum pipe_transfer_usage {
+ PIPE_TRANSFER_READ,
+ PIPE_TRANSFER_WRITE,
+ PIPE_TRANSFER_READ_WRITE //< Read/modify/write
+};
+
+
+/**
* Buffer usage flags
*/
#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0)
#endif
-/* XXX: these are a kludge. will fix when all surfaces are views into
- * textures, and free-floating winsys surfaces go away.
- */
-static INLINE void *
-pipe_surface_map( struct pipe_surface *surf, unsigned flags )
-{
- struct pipe_screen *screen;
- assert(surf->texture);
- screen = surf->texture->screen;
- return screen->surface_map( screen, surf, flags );
-}
-
-static INLINE void
-pipe_surface_unmap( struct pipe_surface *surf )
-{
- struct pipe_screen *screen;
- assert(surf->texture);
- screen = surf->texture->screen;
- screen->surface_unmap( screen, surf );
-}
-
-
-
/**
* Set 'ptr' to point to 'surf' and update reference counting.
* The old thing pointed to, if any, will be unreferenced first.
/** Opaque type */
struct pipe_fence_handle;
+
/**
* Gallium screen/adapter context. Basically everything
* hardware-specific that doesn't actually require a rendering
struct pipe_surface ** );
- void *(*surface_map)( struct pipe_screen *,
- struct pipe_surface *surface,
- unsigned flags );
+ /** Get a transfer object for transferring data to/from a texture */
+ struct pipe_transfer *(*get_tex_transfer)(struct pipe_screen *,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h);
+
+ /* Transfer objects allocated by the above must be released here:
+ */
+ void (*tex_transfer_release)( struct pipe_screen *,
+ struct pipe_transfer ** );
+
+ void *(*transfer_map)( struct pipe_screen *,
+ struct pipe_transfer *transfer );
- void (*surface_unmap)( struct pipe_screen *,
- struct pipe_surface *surface );
+ void (*transfer_unmap)( struct pipe_screen *,
+ struct pipe_transfer *transfer );
/**
unsigned clear_value; /**< XXX may be temporary */
unsigned width; /**< logical width in pixels */
unsigned height; /**< logical height in pixels */
- struct pipe_format_block block;
- unsigned nblocksx; /**< allocated width in blocks */
- unsigned nblocksy; /**< allocated height in blocks */
- unsigned stride; /**< stride in bytes between rows of blocks */
unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */
unsigned offset; /**< offset from start of buffer, in bytes */
unsigned refcount;
/**
+ * Transfer object. For data transfer to/from a texture.
+ */
+struct pipe_transfer
+{
+ enum pipe_format format; /**< PIPE_FORMAT_x */
+ unsigned x; /**< x offset from start of texture image */
+ unsigned y; /**< y offset from start of texture image */
+ unsigned width; /**< logical width in pixels */
+ unsigned height; /**< logical height in pixels */
+ struct pipe_format_block block;
+ unsigned nblocksx; /**< allocated width in blocks */
+ unsigned nblocksy; /**< allocated height in blocks */
+ unsigned stride; /**< stride in bytes between rows of blocks */
+ unsigned refcount;
+ unsigned usage; /**< PIPE_TRANSFER_* */
+
+ struct pipe_texture *texture; /**< texture to transfer to/from */
+ unsigned face;
+ unsigned level;
+ unsigned zslice;
+};
+
+
+/**
* Texture object.
*/
struct pipe_texture
struct aub_dump_bmp db;
unsigned format;
- assert(surface->block.width == 1);
- assert(surface->block.height == 1);
+ assert(surface->texture->block.width == 1);
+ assert(surface->texture->block.height == 1);
- if (surface->block.size == 4)
+ if (surface->texture->block.size == 4)
format = 0x7;
else
format = 0x3;
db.xmin = 0;
db.ymin = 0;
db.format = format;
- db.bpp = surface->block.size * 8;
- db.pitch = surface->stride/surface->block.size;
+ db.bpp = surface->texture->block.size * 8;
+ db.pitch = surface->texture->nblocksx[surface->level];
db.xsize = surface->width;
db.ysize = surface->height;
db.addr = gtt_offset;
return;
if (XSHM_ENABLED(xm_buf) && (xm_buf->tempImage == NULL)) {
- assert(surf->block.width == 1);
- assert(surf->block.height == 1);
- alloc_shm_ximage(xm_buf, b, surf->stride/surf->block.size, surf->height);
+ assert(surf->texture->block.width == 1);
+ assert(surf->texture->block.height == 1);
+ alloc_shm_ximage(xm_buf, b, surf->texture->nblocksx[surf->level],
+ surf->height);
}
ximage = (XSHM_ENABLED(xm_buf)) ? xm_buf->tempImage : b->tempImage;
/* update XImage's fields */
ximage->width = surf->width;
ximage->height = surf->height;
- ximage->bytes_per_line = surf->stride;
+ ximage->bytes_per_line = surf->texture->nblocksx[surf->level];
XPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, 0, 0, surf->width, surf->height);
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
const GLuint rSize = ctx->PixelMaps.RtoR.Size;
const GLuint gSize = ctx->PixelMaps.GtoG.Size;
const GLuint bSize = ctx->PixelMaps.BtoB.Size;
uint *dest;
uint i, j;
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- dest = (uint *) screen->surface_map(screen, surface,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
+ 0, 0, texSize, texSize);
+ dest = (uint *) screen->transfer_map(screen, transfer);
/* Pack four 1D maps into a 2D texture:
* R map is placed horizontally, indexed by S, in channel 0
}
}
- screen->surface_unmap(screen, surface);
- pipe_surface_reference(&surface, NULL);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_release(screen, &transfer);
}
* See also: st_renderbuffer_alloc_storage()
*/
static void
-acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
+acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt,
uint x, uint y, uint w, uint h, float *p)
{
- const enum pipe_format f = acc_ps->format;
- const struct pipe_format_block b = acc_ps->block;
+ const enum pipe_format f = acc_pt->format;
+ const struct pipe_format_block b = acc_pt->block;
- acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_ps->block.size = 8;
- acc_ps->block.width = 1;
- acc_ps->block.height = 1;
+ acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT;
+ acc_pt->block.size = 8;
+ acc_pt->block.width = 1;
+ acc_pt->block.height = 1;
- pipe_get_tile_rgba(acc_ps, x, y, w, h, p);
+ pipe_get_tile_rgba(acc_pt, x, y, w, h, p);
- acc_ps->format = f;
- acc_ps->block = b;
+ acc_pt->format = f;
+ acc_pt->block = b;
}
* See also: st_renderbuffer_alloc_storage()
*/
static void
-acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
+acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt,
uint x, uint y, uint w, uint h, const float *p)
{
- enum pipe_format f = acc_ps->format;
- const struct pipe_format_block b = acc_ps->block;
+ enum pipe_format f = acc_pt->format;
+ const struct pipe_format_block b = acc_pt->block;
- acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_ps->block.size = 8;
- acc_ps->block.width = 1;
- acc_ps->block.height = 1;
+ acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT;
+ acc_pt->block.size = 8;
+ acc_pt->block.width = 1;
+ acc_pt->block.height = 1;
- pipe_put_tile_rgba(acc_ps, x, y, w, h, p);
+ pipe_put_tile_rgba(acc_pt, x, y, w, h, p);
- acc_ps->format = f;
- acc_ps->block = b;
+ acc_pt->format = f;
+ acc_pt->block = b;
}
st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
- struct pipe_surface *acc_ps;
+ struct pipe_transfer *acc_pt;
struct pipe_screen *screen = ctx->st->pipe->screen;
const GLint xpos = ctx->DrawBuffer->_Xmin;
const GLint ypos = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
GLubyte *map;
- acc_ps = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- map = screen->surface_map(screen, acc_ps,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, xpos, ypos,
+ width, height);
+ map = screen->transfer_map(screen, acc_pt);
- /* note acc_strb->format might not equal acc_ps->format */
+ /* note acc_strb->format might not equal acc_pt->format */
switch (acc_strb->format) {
case PIPE_FORMAT_R16G16B16A16_SNORM:
{
GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
int i, j;
for (i = 0; i < height; i++) {
- GLshort *dst = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8);
+ GLshort *dst = (GLshort *) (map + i * acc_pt->stride + xpos * 8);
for (j = 0; j < width; j++) {
dst[0] = r;
dst[1] = g;
_mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
}
- screen->surface_unmap(screen, acc_ps);
- pipe_surface_reference(&acc_ps, NULL);
+ screen->transfer_unmap(screen, acc_pt);
+ screen->tex_transfer_release(screen, &acc_pt);
}
struct st_renderbuffer *acc_strb)
{
struct pipe_screen *screen = ctx->st->pipe->screen;
- struct pipe_surface *acc_ps = acc_strb->surface;
+ struct pipe_transfer *acc_pt;
GLubyte *map;
- map = screen->surface_map(screen, acc_ps,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ_WRITE, xpos, ypos,
+ width, height);
+ map = screen->transfer_map(screen, acc_pt);
- /* note acc_strb->format might not equal acc_ps->format */
+ /* note acc_strb->format might not equal acc_pt->format */
switch (acc_strb->format) {
case PIPE_FORMAT_R16G16B16A16_SNORM:
{
int i, j;
for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8);
+ GLshort *acc = (GLshort *) (map + (ypos + i) * acc_pt->stride + xpos * 8);
for (j = 0; j < width * 4; j++) {
float val = SHORT_TO_FLOAT(acc[j]) * scale + bias;
acc[j] = FLOAT_TO_SHORT(val);
_mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
- screen->surface_unmap(screen, acc_ps);
+ screen->transfer_unmap(screen, acc_pt);
+ screen->tex_transfer_release(screen, &acc_pt);
}
struct st_renderbuffer *color_strb)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *acc_surf, *color_surf;
+ struct pipe_transfer *acc_trans, *color_trans;
GLfloat *colorBuf, *accBuf;
GLint i;
- acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
- (PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ));
+ acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, xpos, ypos,
+ width, height);
- color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, xpos, ypos,
+ width, height);
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, colorBuf);
- acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf);
+ pipe_get_tile_rgba(color_trans, 0, 0, width, height, colorBuf);
+ acc_get_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] + colorBuf[i] * value;
}
- acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf);
+ screen->tex_transfer_release(screen, &acc_trans);
+ acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, xpos, ypos,
+ width, height);
+
+ acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf);
free(colorBuf);
free(accBuf);
- pipe_surface_reference(&acc_surf, NULL);
- pipe_surface_reference(&color_surf, NULL);
+ screen->tex_transfer_release(screen, &acc_trans);
+ screen->tex_transfer_release(screen, &color_trans);
}
struct st_renderbuffer *color_strb)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *acc_surf, *color_surf;
+ struct pipe_transfer *acc_trans, *color_trans;
GLfloat *buf;
GLint i;
- acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, xpos, ypos,
+ width, height);
- color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, xpos, ypos,
+ width, height);
buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, buf);
+ pipe_get_tile_rgba(color_trans, xpos, ypos, width, height, buf);
for (i = 0; i < 4 * width * height; i++) {
buf[i] = buf[i] * value;
}
- acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, buf);
+ acc_put_tile_rgba(pipe, acc_trans, xpos, ypos, width, height, buf);
free(buf);
- pipe_surface_reference(&acc_surf, NULL);
- pipe_surface_reference(&color_surf, NULL);
+ screen->tex_transfer_release(screen, &acc_trans);
+ screen->tex_transfer_release(screen, &color_trans);
}
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
const GLubyte *colormask = ctx->Color.ColorMask;
- struct pipe_surface *acc_surf, *color_surf;
+ struct pipe_transfer *acc_trans, *color_trans;
GLfloat *abuf, *cbuf = NULL;
GLint i, ch;
abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, xpos, ypos,
+ width, height);
- color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0,
- (PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE));
+ color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ_WRITE, xpos, ypos,
+ width, height);
- acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, abuf);
+ acc_get_tile_rgba(pipe, acc_trans, xpos, ypos, width, height, abuf);
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, cbuf);
+ pipe_get_tile_rgba(color_trans, xpos, ypos, width, height, cbuf);
}
for (i = 0; i < width * height; i++) {
}
}
- pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf);
+ pipe_put_tile_rgba(color_trans, xpos, ypos, width, height, abuf);
free(abuf);
if (cbuf)
free(cbuf);
- pipe_surface_reference(&acc_surf, NULL);
- pipe_surface_reference(&color_surf, NULL);
+ screen->tex_transfer_release(screen, &acc_trans);
+ screen->tex_transfer_release(screen, &color_trans);
}
GLfloat color[4];
struct pipe_texture *texture;
- struct pipe_surface *surf;
+ struct pipe_transfer *trans;
GLboolean empty;
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
ubyte *dest;
struct pipe_texture *pt;
return NULL;
}
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
+ 0, 0, width, height);
- /* map texture surface */
- dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+ dest = screen->transfer_map(screen, transfer);
- /* Put image into texture surface */
- memset(dest, 0xff, height * surface->stride);
+ /* Put image into texture transfer */
+ memset(dest, 0xff, height * transfer->stride);
unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap,
- dest, surface->stride);
+ dest, transfer->stride);
_mesa_unmap_bitmap_pbo(ctx, unpack);
- /* Release surface */
- screen->surface_unmap(screen, surface);
- pipe_surface_reference(&surface, NULL);
+ /* Release transfer */
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_release(screen, &transfer);
return pt;
}
cache->ymin = 1000000;
cache->ymax = -1000000;
- if (cache->surf)
- screen->tex_surface_release(screen, &cache->surf);
+ if (cache->trans)
+ screen->tex_transfer_release(screen, &cache->trans);
assert(!cache->texture);
1, 0,
PIPE_TEXTURE_USAGE_SAMPLER);
- /* Map the texture surface.
+ /* Map the texture transfer.
* Subsequent glBitmap calls will write into the texture image.
*/
- cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- cache->buffer = screen->surface_map(screen, cache->surf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ cache->trans = screen->get_tex_transfer(screen, cache->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ BITMAP_CACHE_WIDTH,
+ BITMAP_CACHE_HEIGHT);
+ cache->buffer = screen->transfer_map(screen, cache->trans);
/* init image to all 0xff */
- memset(cache->buffer, 0xff, BITMAP_CACHE_WIDTH * BITMAP_CACHE_HEIGHT);
+ memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
}
cache->xpos, cache->ypos);
*/
- /* The texture surface has been mapped until now.
- * So unmap and release the texture surface before drawing.
+ /* The texture transfer has been mapped until now.
+ * So unmap and release the texture transfer before drawing.
*/
- screen->surface_unmap(screen, cache->surf);
+ screen->transfer_unmap(screen, cache->trans);
cache->buffer = NULL;
- screen->tex_surface_release(screen, &cache->surf);
+ screen->tex_transfer_release(screen, &cache->trans);
draw_bitmap_quad(st->ctx,
cache->xpos,
struct pipe_screen *screen = pipe->screen;
struct bitmap_cache *cache = st->bitmap.cache;
- screen->surface_unmap(screen, cache->surf);
- screen->tex_surface_release(screen, &cache->surf);
+ screen->transfer_unmap(screen, cache->trans);
+ screen->tex_transfer_release(screen, &cache->trans);
if (st->bitmap.vs) {
cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
}
{
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
static const GLuint dstImageOffsets = 0;
GLboolean success;
GLubyte *dest;
/* we'll do pixel transfer in a fragment shader */
ctx->_ImageTransferState = 0x0;
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ width, height);
- /* map texture surface */
- dest = screen->surface_map(screen, surface,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ /* map texture transfer */
+ dest = screen->transfer_map(screen, transfer);
- /* Put image into texture surface.
+ /* Put image into texture transfer.
* Note that the image is actually going to be upside down in
* the texture. We deal with that with texcoords.
*/
mformat, /* gl_texture_format */
dest, /* dest */
0, 0, 0, /* dstX/Y/Zoffset */
- surface->stride, /* dstRowStride, bytes */
+ transfer->stride, /* dstRowStride, bytes */
&dstImageOffsets, /* dstImageOffsets */
width, height, 1, /* size */
format, type, /* src format/type */
unpack);
/* unmap */
- screen->surface_unmap(screen, surface);
- pipe_surface_reference(&surface, NULL);
+ screen->transfer_unmap(screen, transfer);
+ screen->tex_transfer_release(screen, &transfer);
assert(success);
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *strb;
- struct pipe_surface *ps;
+ struct pipe_transfer *pt;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
GLint skipPixels;
ubyte *stmap;
strb = st_renderbuffer(ctx->DrawBuffer->
Attachment[BUFFER_STENCIL].Renderbuffer);
- ps = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ pt = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, x, y,
+ width, height);
- /* map the stencil buffer */
- stmap = screen->surface_map(screen, ps,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ stmap = screen->transfer_map(screen, pt);
/* if width > MAX_WIDTH, have to process image in chunks */
skipPixels = 0;
while (skipPixels < width) {
- const GLint spanX = x + skipPixels;
+ const GLint spanX = skipPixels;
const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH);
GLint row;
for (row = 0; row < height; row++) {
- GLint spanY = y + row;
+ GLint spanY = row;
GLubyte values[MAX_WIDTH];
GLenum destType = GL_UNSIGNED_BYTE;
const GLvoid *source = _mesa_image_address2d(unpack, pixels,
ctx->_ImageTransferState);
if (zoom) {
/*
- _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth,
+ _swrast_write_zoomed_stencil_span(ctx, 0, 0, spanWidth,
spanX, spanY, values);
*/
}
spanY = ctx->DrawBuffer->Height - spanY - 1;
}
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_S8_UNORM:
{
- ubyte *dest = stmap + spanY * ps->stride + spanX;
+ ubyte *dest = stmap + spanY * pt->stride + spanX;
memcpy(dest, values, spanWidth);
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
{
- uint *dest = (uint *) (stmap + spanY * ps->stride + spanX*4);
+ uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
GLint k;
for (k = 0; k < spanWidth; k++) {
uint p = dest[k];
}
/* unmap the stencil buffer */
- screen->surface_unmap(screen, ps);
- pipe_surface_reference(&ps, NULL);
+ screen->transfer_unmap(screen, pt);
+ screen->tex_transfer_release(screen, &pt);
}
{
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
struct pipe_screen *screen = ctx->st->pipe->screen;
- struct pipe_surface *psDraw;
+ struct pipe_transfer *ptDraw;
ubyte *drawMap;
ubyte *buffer;
int i;
st_read_stencil_pixels(ctx, srcx, srcy, width, height, GL_UNSIGNED_BYTE,
&ctx->DefaultPacking, buffer);
- psDraw = screen->get_tex_surface(screen, rbDraw->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ ptDraw = screen->get_tex_transfer(screen, rbDraw->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, dstx, dsty,
+ width, height);
- assert(psDraw->block.width == 1);
- assert(psDraw->block.height == 1);
+ assert(ptDraw->block.width == 1);
+ assert(ptDraw->block.height == 1);
/* map the stencil buffer */
- drawMap = screen->surface_map(screen, psDraw, PIPE_BUFFER_USAGE_CPU_WRITE);
+ drawMap = screen->transfer_map(screen, ptDraw);
/* draw */
/* XXX PixelZoom not handled yet */
const ubyte *src;
int y;
- y = dsty + i;
+ y = i;
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
y = ctx->DrawBuffer->Height - y - 1;
}
- dst = drawMap + y * psDraw->stride + dstx * psDraw->block.size;
+ dst = drawMap + y * ptDraw->stride;
src = buffer + i * width;
- switch (psDraw->format) {
+ switch (ptDraw->format) {
case PIPE_FORMAT_S8Z24_UNORM:
{
uint *dst4 = (uint *) dst;
free(buffer);
/* unmap the stencil buffer */
- screen->surface_unmap(screen, psDraw);
- pipe_surface_reference(&psDraw, NULL);
+ screen->transfer_unmap(screen, ptDraw);
+ screen->tex_transfer_release(screen, &ptDraw);
}
struct st_renderbuffer *rbRead;
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
- struct pipe_surface *psTex;
struct pipe_texture *pt;
GLfloat *color;
enum pipe_format srcFormat, texFormat;
struct pipe_surface *psRead = screen->get_tex_surface(screen,
rbRead->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ);
- psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE );
pipe->surface_copy(pipe,
FALSE,
0, 0, /* destx/y */
psRead,
srcx, srcy, width, height);
- pipe_surface_reference(&psRead, NULL);
+ pipe_surface_reference(&psRead, NULL);
+ pipe_surface_reference(&psTex, NULL);
}
else {
/* CPU-based fallback/conversion */
- struct pipe_surface *psRead = screen->get_tex_surface(screen,
- rbRead->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ struct pipe_transfer *ptRead =
+ screen->get_tex_transfer(screen, rbRead->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, srcx, srcy, width,
+ height);
- psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE );
+ struct pipe_transfer *ptTex =
+ screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
+ 0, 0, width, height);
if (type == GL_COLOR) {
/* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_rgba(psTex, 0, 0, width, height, buf);
+ pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf);
+ pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf);
free(buf);
}
else {
/* GL_DEPTH */
GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
- pipe_get_tile_z(psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_z(psTex, 0, 0, width, height, buf);
+ pipe_get_tile_z(ptRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_z(ptTex, 0, 0, width, height, buf);
free(buf);
}
- pipe_surface_reference(&psRead, NULL);
- }
- pipe_surface_reference(&psTex, NULL);
+ screen->tex_transfer_release(screen, &ptRead);
+ screen->tex_transfer_release(screen, &ptTex);
+ }
/* draw textured quad */
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
assert(strb->surface->texture);
assert(strb->surface->format);
- assert(strb->surface->block.size);
- assert(strb->surface->block.width);
- assert(strb->surface->block.height);
assert(strb->surface->width == width);
assert(strb->surface->height == height);
- assert(strb->surface->stride);
return strb->surface != NULL;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer);
- struct pipe_surface *ps;
+ struct pipe_transfer *pt;
ubyte *stmap;
GLint j;
- /* Create a CPU-READ surface/view into the renderbuffer's texture */
- ps = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
+ y = ctx->DrawBuffer->Height - y - 1;
+ }
+
+ /* Create a read transfer from the renderbuffer's texture */
+ pt = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, x, y, width, height);
/* map the stencil buffer */
- stmap = screen->surface_map(screen, ps, PIPE_BUFFER_USAGE_CPU_READ);
+ stmap = screen->transfer_map(screen, pt);
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
/* process image row by row */
- for (j = 0; j < height; j++, y++) {
+ for (j = 0; j < height; j++) {
GLvoid *dest;
GLstencil values[MAX_WIDTH];
GLint srcY;
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
- srcY = ctx->DrawBuffer->Height - y - 1;
+ srcY = height - j - 1;
}
else {
- srcY = y;
+ srcY = j;
}
/* get stencil values */
- switch (ps->format) {
+ switch (pt->format) {
case PIPE_FORMAT_S8_UNORM:
{
- const ubyte *src = stmap + srcY * ps->stride + x;
+ const ubyte *src = stmap + srcY * pt->stride;
memcpy(values, src, width);
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
{
- const uint *src = (uint *) (stmap + srcY * ps->stride + x*4);
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] >> 24;
break;
case PIPE_FORMAT_Z24S8_UNORM:
{
- const uint *src = (uint *) (stmap + srcY * ps->stride + x*4);
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] & 0xff;
/* unmap the stencil buffer */
- screen->surface_unmap(screen, ps);
- pipe_surface_reference(&ps, NULL);
+ screen->transfer_unmap(screen, pt);
+ screen->tex_transfer_release(screen, &pt);
}
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_surface *surf;
+ struct pipe_transfer *trans;
const GLubyte *map;
GLubyte *dst;
GLint row, col, dy, dstStride;
- surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
- if (!surf) {
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ y = strb->texture->height[0] - y - 1;
+ }
+
+ trans = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, x, y, width, height);
+ if (!trans) {
return GL_FALSE;
}
- map = screen->surface_map(screen, surf, PIPE_BUFFER_USAGE_CPU_READ);
+ map = screen->transfer_map(screen, trans);
if (!map) {
- pipe_surface_reference(&surf, NULL);
+ screen->tex_transfer_release(screen, &trans);
return GL_FALSE;
}
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
- y = surf->height - y - 1;
+ y = height - y - 1;
dy = -1;
}
else {
+ y = 0;
dy = 1;
}
switch (combo) {
case A8R8G8B8_UNORM_TO_RGBA_UBYTE:
for (row = 0; row < height; row++) {
- const GLubyte *src = map + y * surf->stride + x * 4;
+ const GLubyte *src = map + y * trans->stride;
for (col = 0; col < width; col++) {
GLuint pixel = ((GLuint *) src)[col];
dst[col*4+0] = (pixel >> 16) & 0xff;
break;
case A8R8G8B8_UNORM_TO_RGB_UBYTE:
for (row = 0; row < height; row++) {
- const GLubyte *src = map + y * surf->stride + x * 4;
+ const GLubyte *src = map + y * trans->stride;
for (col = 0; col < width; col++) {
GLuint pixel = ((GLuint *) src)[col];
dst[col*3+0] = (pixel >> 16) & 0xff;
break;
case A8R8G8B8_UNORM_TO_BGRA_UINT:
for (row = 0; row < height; row++) {
- const GLubyte *src = map + y * surf->stride + x * 4;
+ const GLubyte *src = map + y * trans->stride;
memcpy(dst, src, 4 * width);
dst += dstStride;
y += dy;
; /* nothing */
}
- screen->surface_unmap(screen, surf);
- pipe_surface_reference(&surf, NULL);
+ screen->transfer_unmap(screen, trans);
+ screen->tex_transfer_release(screen, &trans);
}
return GL_TRUE;
/**
- * Do glReadPixels by getting rows from the framebuffer surface with
+ * Do glReadPixels by getting rows from the framebuffer transfer with
* get_tile(). Convert to requested format/type with Mesa image routines.
* Image transfer ops are done in software too.
*/
GLfloat *df;
struct st_renderbuffer *strb;
struct gl_pixelstore_attrib clippedPacking = *pack;
- struct pipe_surface *surf;
+ struct pipe_transfer *trans;
assert(ctx->ReadBuffer->Width > 0);
/* 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 surface is totally outside the window bounds */
+ /* The ReadPixels transfer is totally outside the window bounds */
return;
}
dfStride = 0;
}
- /* determine bottom-to-top vs. top-to-bottom order */
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
y = strb->Base.Height - 1 - y;
+ }
+
+ /* Create a read transfer from the renderbuffer's texture */
+ trans = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, x, y, width, height);
+
+ /* determine bottom-to-top vs. top-to-bottom order */
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ y = trans->height - 1 - y;
yStep = -1;
}
else {
+ y = 0;
yStep = 1;
}
- /* Create a CPU-READ surface/view into the renderbuffer's texture */
- surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
-
/*
- * Copy pixels from pipe_surface to user memory
+ * Copy pixels from pipe_transfer to user memory
*/
{
/* dest of first pixel in client memory */
const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
format, type);
- if (surf->format == PIPE_FORMAT_S8Z24_UNORM ||
- surf->format == PIPE_FORMAT_X8Z24_UNORM) {
+ if (trans->format == PIPE_FORMAT_S8Z24_UNORM ||
+ trans->format == PIPE_FORMAT_X8Z24_UNORM) {
if (format == GL_DEPTH_COMPONENT) {
for (i = 0; i < height; i++) {
GLuint ztemp[MAX_WIDTH];
GLfloat zfloat[MAX_WIDTH];
const double scale = 1.0 / ((1 << 24) - 1);
- pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0);
+ pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0);
y += yStep;
for (j = 0; j < width; j++) {
zfloat[j] = (float) (scale * (ztemp[j] & 0xffffff));
/* untested, but simple: */
assert(format == GL_DEPTH_STENCIL_EXT);
for (i = 0; i < height; i++) {
- pipe_get_tile_raw(surf, x, y, width, 1, dst, 0);
+ pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0);
y += yStep;
dst += dstStride;
}
}
}
- else if (surf->format == PIPE_FORMAT_Z16_UNORM) {
+ else if (trans->format == PIPE_FORMAT_Z16_UNORM) {
for (i = 0; i < height; i++) {
GLushort ztemp[MAX_WIDTH];
GLfloat zfloat[MAX_WIDTH];
const double scale = 1.0 / 0xffff;
- pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0);
+ pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0);
y += yStep;
for (j = 0; j < width; j++) {
zfloat[j] = (float) (scale * ztemp[j]);
dst += dstStride;
}
}
- else if (surf->format == PIPE_FORMAT_Z32_UNORM) {
+ else if (trans->format == PIPE_FORMAT_Z32_UNORM) {
for (i = 0; i < height; i++) {
GLuint ztemp[MAX_WIDTH];
GLfloat zfloat[MAX_WIDTH];
const double scale = 1.0 / 0xffffffff;
- pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0);
+ pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0);
y += yStep;
for (j = 0; j < width; j++) {
zfloat[j] = (float) (scale * ztemp[j]);
/* RGBA format */
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
- pipe_get_tile_rgba(surf, x, y, width, 1, df);
+ pipe_get_tile_rgba(trans, 0, y, width, 1, df);
y += yStep;
df += dfStride;
if (!dfStride) {
}
}
- pipe_surface_reference(&surf, NULL);
+ screen->tex_transfer_release(screen, &trans);
_mesa_unmap_readpix_pbo(ctx, &clippedPacking);
}
if (stImage->pt) {
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if (stImage->surface)
- dstRowStride = stImage->surface->stride;
+ PIPE_TRANSFER_WRITE, 0, 0,
+ stImage->base.Width,
+ stImage->base.Height);
+ dstRowStride = stImage->transfer->stride;
}
else {
/* Allocate regular memory and store the image there temporarily. */
if (stImage->pt && i < depth) {
st_texture_image_unmap(ctx->st, stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, i,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PIPE_TRANSFER_WRITE, 0, 0,
+ stImage->base.Width,
+ stImage->base.Height);
src += srcImageStride;
}
}
* kernel. Need to explicitly map and unmap it.
*/
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
- texImage->RowStride = stImage->surface->stride / stImage->pt->block.size;
+ PIPE_TRANSFER_READ, 0, 0,
+ stImage->base.Width,
+ stImage->base.Height);
+ texImage->RowStride = stImage->transfer->stride / stImage->pt->block.size;
}
else {
/* Otherwise, the image should actually be stored in
if (stImage->pt && i < depth) {
st_texture_image_unmap(ctx->st, stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, i,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ, 0, 0,
+ stImage->base.Width,
+ stImage->base.Height);
dest += dstImageStride;
}
}
*/
if (stImage->pt) {
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if (stImage->surface)
- dstRowStride = stImage->surface->stride;
+ PIPE_TRANSFER_WRITE,
+ xoffset, yoffset,
+ stImage->base.Width,
+ stImage->base.Height);
+ dstRowStride = stImage->transfer->stride;
}
if (!texImage->Data) {
/* map next slice of 3D texture */
st_texture_image_unmap(ctx->st, stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PIPE_TRANSFER_WRITE,
+ xoffset, yoffset,
+ stImage->base.Width,
+ stImage->base.Height);
src += srcImageStride;
}
}
/**
- * Return 0 for GL_TEXTURE_CUBE_MAP_POSITIVE_X,
- * 1 for GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- * etc.
- * XXX duplicated from main/teximage.c
- */
-static uint
-texture_face(GLenum target)
-{
- if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)
- return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
- else
- return 0;
-}
-
-
-
-/**
- * Do a CopyTexSubImage operation by mapping the source surface and
- * dest surface and using get_tile()/put_tile() to access the pixels/texels.
+ * Do a CopyTexSubImage operation using a read transfer from the source, a write
+ * transfer to the destination and get_tile()/put_tile() to access the pixels/texels.
*
* Note: srcY=0=TOP of renderbuffer
*/
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
- const uint face = texture_face(target);
- struct pipe_texture *pt = stImage->pt;
- struct pipe_surface *src_surf, *dest_surf;
+ struct pipe_transfer *src_trans;
+ GLvoid *texDest;
+
+ assert(width <= MAX_WIDTH);
- /* We'd use strb->surface, here but it's created for GPU read/write only */
- src_surf = pipe->screen->get_tex_surface( pipe->screen,
- strb->texture,
- 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ srcY = strb->Base.Height - 1 - srcY;
+ }
- dest_surf = screen->get_tex_surface(screen, pt, face, level, destZ,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ src_trans = pipe->screen->get_tex_transfer( pipe->screen,
+ strb->texture,
+ 0, 0, 0,
+ PIPE_TRANSFER_READ,
+ srcX, srcY,
+ width, height);
- assert(width <= MAX_WIDTH);
+ texDest = st_texture_image_map(ctx->st, stImage, 0, PIPE_TRANSFER_WRITE,
+ destX, destY, width, height);
if (baseFormat == GL_DEPTH_COMPONENT) {
const GLboolean scaleOrBias = (ctx->Pixel.DepthScale != 1.0F ||
/* determine bottom-to-top vs. top-to-bottom order for src buffer */
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
- srcY = strb->Base.Height - 1 - srcY;
+ srcY = height - 1 - srcY;
yStep = -1;
}
else {
+ srcY = 0;
yStep = 1;
}
/* To avoid a large temp memory allocation, do copy row by row */
- for (row = 0; row < height; row++, srcY += yStep, destY++) {
+ for (row = 0; row < height; row++, srcY += yStep) {
uint data[MAX_WIDTH];
- pipe_get_tile_z(src_surf, srcX, srcY, width, 1, data);
+ pipe_get_tile_z(src_trans, 0, srcY, width, 1, data);
if (scaleOrBias) {
_mesa_scale_and_bias_depth_uint(ctx, width, data);
}
- pipe_put_tile_z(dest_surf, destX, destY, width, 1, data);
+ pipe_put_tile_z(stImage->transfer, 0, row, width, 1, data);
}
}
else {
/* RGBA format */
GLfloat *tempSrc =
(GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
- GLvoid *texDest =
- st_texture_image_map(ctx->st, stImage, 0,PIPE_BUFFER_USAGE_CPU_WRITE);
if (tempSrc && texDest) {
const GLint dims = 2;
struct gl_texture_image *texImage = &stImage->base;
- GLint dstRowStride = stImage->surface->stride;
+ GLint dstRowStride = stImage->transfer->stride;
struct gl_pixelstore_attrib unpack = ctx->DefaultPacking;
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
- /* need to invert src */
- srcY = strb->Base.Height - srcY - height;
unpack.Invert = GL_TRUE;
}
/* XXX this usually involves a lot of int/float conversion.
* try to avoid that someday.
*/
- pipe_get_tile_rgba(src_surf, srcX, srcY, width, height, tempSrc);
+ pipe_get_tile_rgba(src_trans, 0, 0, width, height, tempSrc);
/* Store into texture memory.
* Note that this does some special things such as pixel transfer
texImage->_BaseFormat,
texImage->TexFormat,
texDest,
- destX, destY, destZ,
+ 0, 0, 0,
dstRowStride,
texImage->ImageOffsets,
width, height, 1,
if (tempSrc)
_mesa_free(tempSrc);
- if (texDest)
- st_texture_image_unmap(ctx->st, stImage);
}
- screen->tex_surface_release(screen, &dest_surf);
- screen->tex_surface_release(screen, &src_surf);
+ st_texture_image_unmap(ctx->st, stImage);
+ screen->tex_transfer_release(screen, &src_trans);
}
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
const ubyte *srcData;
ubyte *dstData;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
- srcData = (ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset;
- dstData = (ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset;
+ srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
_mesa_generate_mipmap_level(target, datatype, comps,
0 /*border*/,
pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],
srcData,
- srcSurf->stride, /* stride in bytes */
+ srcTrans->stride, /* stride in bytes */
pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],
dstData,
- dstSurf->stride); /* stride in bytes */
+ dstTrans->stride); /* stride in bytes */
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_release(screen, &srcTrans);
+ screen->tex_transfer_release(screen, &dstTrans);
}
}
*/
GLubyte *
st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
- GLuint zoffset,
- GLuint flags )
+ GLuint zoffset, enum pipe_transfer_usage usage,
+ GLuint x, GLuint y, GLuint w, GLuint h)
{
struct pipe_screen *screen = st->pipe->screen;
struct pipe_texture *pt = stImage->pt;
DBG("%s \n", __FUNCTION__);
- stImage->surface = screen->get_tex_surface(screen, pt, stImage->face,
- stImage->level, zoffset,
- flags);
+ stImage->transfer = screen->get_tex_transfer(screen, pt, stImage->face,
+ stImage->level, zoffset,
+ usage, x, y, w, h);
- if (stImage->surface)
- return screen->surface_map(screen, stImage->surface, flags);
+ if (stImage->transfer)
+ return screen->transfer_map(screen, stImage->transfer);
else
return NULL;
}
DBG("%s\n", __FUNCTION__);
- screen->surface_unmap(screen, stImage->surface);
+ screen->transfer_unmap(screen, stImage->transfer);
- pipe_surface_reference(&stImage->surface, NULL);
+ screen->tex_transfer_release(screen, &stImage->transfer);
}
*/
static void
st_surface_data(struct pipe_context *pipe,
- struct pipe_surface *dst,
+ struct pipe_transfer *dst,
unsigned dstx, unsigned dsty,
const void *src, unsigned src_stride,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
struct pipe_screen *screen = pipe->screen;
- void *map = screen->surface_map(screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+ void *map = screen->transfer_map(screen, dst);
pipe_copy_rect(map,
&dst->block,
src, src_stride,
srcx, srcy);
- screen->surface_unmap(screen, dst);
+ screen->transfer_unmap(screen, dst);
}
GLuint depth = dst->depth[level];
GLuint i;
const GLubyte *srcUB = src;
- struct pipe_surface *dst_surface;
+ struct pipe_transfer *dst_transfer;
DBG("%s\n", __FUNCTION__);
for (i = 0; i < depth; i++) {
- dst_surface = screen->get_tex_surface(screen, dst, face, level, i,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ dst_transfer = screen->get_tex_transfer(screen, dst, face, level, i,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ dst->width[level],
+ dst->height[level]);
- st_surface_data(pipe, dst_surface,
+ st_surface_data(pipe, dst_transfer,
0, 0, /* dstx, dsty */
srcUB,
src_row_stride,
0, 0, /* source x, y */
dst->width[level], dst->height[level]); /* width, height */
- screen->tex_surface_release(screen, &dst_surface);
+ screen->tex_transfer_release(screen, &dst_transfer);
srcUB += src_image_stride;
}
*/
struct pipe_texture *pt;
- struct pipe_surface *surface;
+ struct pipe_transfer *transfer;
};
st_texture_image_map(struct st_context *st,
struct st_texture_image *stImage,
GLuint zoffset,
- GLuint flags);
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h);
extern void
st_texture_image_unmap(struct st_context *st,