"get_transfer + transfer_map" becomes "transfer_map".
"transfer_unmap + transfer_destroy" becomes "transfer_unmap".
transfer_map must create and return the transfer object and transfer_unmap
must destroy it.
transfer_map is successful if the returned buffer pointer is not NULL.
If transfer_map fails, the pointer to the transfer object remains unchanged
(i.e. doesn't have to be NULL).
Acked-by: Brian Paul <brianp@vmware.com>
/* This texture is new, no need to flush.
*/
- transfer = pipe->get_transfer(pipe,
- aaline->texture,
- level,
- PIPE_TRANSFER_WRITE,
- &box);
+ data = pipe->transfer_map(pipe,
+ aaline->texture,
+ level,
+ PIPE_TRANSFER_WRITE,
+ &box, &transfer);
- data = pipe->transfer_map(pipe, transfer);
if (data == NULL)
return FALSE;
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
return TRUE;
}
uint i, j;
ubyte *data;
- transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
- data = pipe->transfer_map(pipe, transfer);
+ data = pipe_transfer_map(pipe, pstip->texture, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32, &transfer);
/*
* Load alpha texture.
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
*/
texture = surface->texture;
- transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level,
- surface->u.tex.first_layer,
- PIPE_TRANSFER_READ,
- 0, 0, surface->width, surface->height);
-
- data = pipe->transfer_map(pipe, transfer);
+ data = pipe_transfer_map(pipe, texture, surface->u.tex.level,
+ surface->u.tex.first_layer,
+ PIPE_TRANSFER_READ,
+ 0, 0, surface->width, surface->height, &transfer);
if(!data)
- goto error;
+ return;
debug_dump_image(prefix,
texture->format,
data);
pipe->transfer_unmap(pipe, transfer);
-error:
- pipe->transfer_destroy(pipe, transfer);
}
{
struct pipe_transfer *transfer;
struct pipe_resource *texture = surface->texture;
+ void *ptr;
- transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level,
- surface->u.tex.first_layer, PIPE_TRANSFER_READ,
- 0, 0, surface->width, surface->height);
+ ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level,
+ surface->u.tex.first_layer, PIPE_TRANSFER_READ,
+ 0, 0, surface->width, surface->height, &transfer);
- debug_dump_transfer_bmp(pipe, filename, transfer);
+ debug_dump_transfer_bmp(pipe, filename, transfer, ptr);
- pipe->transfer_destroy(pipe, transfer);
+ pipe->transfer_unmap(pipe, transfer);
}
void
debug_dump_transfer_bmp(struct pipe_context *pipe,
const char *filename,
- struct pipe_transfer *transfer)
+ struct pipe_transfer *transfer, void *ptr)
{
float *rgba;
if(!rgba)
goto error1;
- pipe_get_tile_rgba(pipe, transfer, 0, 0,
+ pipe_get_tile_rgba(pipe, transfer, ptr, 0, 0,
transfer->box.width, transfer->box.height,
rgba);
struct pipe_surface *surface);
void debug_dump_transfer_bmp(struct pipe_context *pipe,
const char *filename,
- struct pipe_transfer *transfer);
+ struct pipe_transfer *transfer, void *ptr);
void debug_dump_float_rgba_bmp(const char *filename,
unsigned width, unsigned height,
float *rgba, unsigned stride);
#define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0)
#define debug_dump_surface(pipe, prefix, surface) ((void)0)
#define debug_dump_surface_bmp(pipe, filename, surface) ((void)0)
-#define debug_dump_transfer_bmp(filename, transfer) ((void)0)
+#define debug_dump_transfer_bmp(filename, transfer, ptr) ((void)0)
#define debug_dump_float_rgba_bmp(filename, width, height, rgba, stride) ((void)0)
#endif
struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel));
- dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer,
- PIPE_TRANSFER_WRITE, 0, 0,
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel));
-
- srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
- dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+ srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel), &srcTrans);
+ dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel), &dstTrans);
reduce_1d(pt->format,
srcTrans->box.width, srcMap,
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
-
- pipe->transfer_destroy(pipe, srcTrans);
- pipe->transfer_destroy(pipe, dstTrans);
}
}
struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel));
- dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer,
- PIPE_TRANSFER_WRITE, 0, 0,
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel));
-
- srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
- dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+ srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel), &srcTrans);
+ dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel), &dstTrans);
reduce_2d(pt->format,
srcTrans->box.width, srcTrans->box.height,
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
-
- pipe->transfer_destroy(pipe, srcTrans);
- pipe->transfer_destroy(pipe, dstTrans);
}
}
dst_box.height = u_minify(pt->height0, dstLevel);
dst_box.depth = u_minify(pt->depth0, dstLevel);
- srcTrans = pipe->get_transfer(pipe, pt, srcLevel,
- PIPE_TRANSFER_READ,
- &src_box);
- dstTrans = pipe->get_transfer(pipe, pt, dstLevel,
- PIPE_TRANSFER_WRITE,
- &dst_box);
-
- srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
- dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+ srcMap = pipe->transfer_map(pipe, pt, srcLevel,
+ PIPE_TRANSFER_READ,
+ &src_box, &srcTrans);
+ dstMap = pipe->transfer_map(pipe, pt, dstLevel,
+ PIPE_TRANSFER_WRITE,
+ &dst_box, &dstTrans);
reduce_3d(pt->format,
srcTrans->box.width, srcTrans->box.height, srcTrans->box.depth,
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
-
- pipe->transfer_destroy(pipe, srcTrans);
- pipe->transfer_destroy(pipe, dstTrans);
}
}
u_box_1d(offset, length, &box);
- *transfer = pipe->get_transfer( pipe,
- buffer,
- 0,
- usage,
- &box);
-
- if (*transfer == NULL)
- return NULL;
-
- map = pipe->transfer_map( pipe, *transfer );
+ map = pipe->transfer_map(pipe, buffer, 0, usage, &box, transfer);
if (map == NULL) {
- pipe->transfer_destroy( pipe, *transfer );
- *transfer = NULL;
return NULL;
}
pipe_buffer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- if (transfer) {
- pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
- }
+ pipe->transfer_unmap(pipe, transfer);
}
static INLINE void
offset, size,
PIPE_TRANSFER_READ,
&src_transfer);
+ if (!map)
+ return;
- if (map)
- memcpy(data, map, size);
-
+ memcpy(data, map, size);
pipe_buffer_unmap(pipe, src_transfer);
}
-static INLINE struct pipe_transfer *
-pipe_get_transfer( struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level, unsigned layer,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y,
- unsigned w, unsigned h)
-{
- struct pipe_box box;
- u_box_2d_zslice( x, y, layer, w, h, &box );
- return context->get_transfer( context,
- resource,
- level,
- usage,
- &box );
-}
-
static INLINE void *
-pipe_transfer_map( struct pipe_context *context,
- struct pipe_transfer *transfer )
+pipe_transfer_map(struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level, unsigned layer,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h,
+ struct pipe_transfer **transfer)
{
- return context->transfer_map( context, transfer );
+ struct pipe_box box;
+ u_box_2d_zslice(x, y, layer, w, h, &box);
+ return context->transfer_map(context,
+ resource,
+ level,
+ usage,
+ &box, transfer);
}
static INLINE void
context->transfer_unmap( context, transfer );
}
-
-static INLINE void
-pipe_transfer_destroy( struct pipe_context *context,
- struct pipe_transfer *transfer )
-{
- context->transfer_destroy(context, transfer);
-}
-
static INLINE void
pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
struct pipe_resource *buf)
int i, j;
/* map texture memory */
- transfer = pipe_get_transfer(pipe, tex, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
- data = pipe->transfer_map(pipe, transfer);
+ data = pipe_transfer_map(pipe, tex, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32, &transfer);
/*
* Load alpha texture.
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
ur->vtbl->resource_destroy(screen, resource);
}
-struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+void *u_transfer_map_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct u_resource *ur = u_resource(resource);
- return ur->vtbl->get_transfer(context, resource, level, usage, box);
-}
-
-void u_transfer_destroy_vtbl(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct u_resource *ur = u_resource(transfer->resource);
- ur->vtbl->transfer_destroy(pipe, transfer);
-}
-
-void *u_transfer_map_vtbl( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct u_resource *ur = u_resource(transfer->resource);
- return ur->vtbl->transfer_map(pipe, transfer);
+ return ur->vtbl->transfer_map(context, resource, level, usage, box,
+ transfer);
}
void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
* Good for allocations which have very low lifetime and are allocated
* and freed very often. Use a profiler first to know if it's worth using it!
*
- * Candidates: get_transfer
+ * Candidates: transfer_map
*
* @author Marek Olšák
*/
src_format = src->format;
dst_format = dst->format;
- src_trans = pipe_get_transfer(pipe,
- src,
- src_level,
- src_box->z,
- PIPE_TRANSFER_READ,
- src_box->x, src_box->y, w, h);
-
- dst_trans = pipe_get_transfer(pipe,
- dst,
- dst_level,
- dst_z,
- PIPE_TRANSFER_WRITE,
- dst_x, dst_y, w, h);
+ src_map = pipe_transfer_map(pipe,
+ src,
+ src_level,
+ src_box->z,
+ PIPE_TRANSFER_READ,
+ src_box->x, src_box->y, w, h, &src_trans);
+
+ dst_map = pipe_transfer_map(pipe,
+ dst,
+ dst_level,
+ dst_z,
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h, &dst_trans);
assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
-
- src_map = pipe->transfer_map(pipe, src_trans);
- dst_map = pipe->transfer_map(pipe, dst_trans);
-
assert(src_map);
assert(dst_map);
pipe->transfer_unmap(pipe, src_trans);
pipe->transfer_unmap(pipe, dst_trans);
-
- pipe->transfer_destroy(pipe, src_trans);
- pipe->transfer_destroy(pipe, dst_trans);
}
if (!dst->texture)
return;
/* XXX: should handle multiple layers */
- dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->u.tex.level,
- dst->u.tex.first_layer,
- PIPE_TRANSFER_WRITE,
- dstx, dsty, width, height);
-
- dst_map = pipe->transfer_map(pipe, dst_trans);
+ dst_map = pipe_transfer_map(pipe,
+ dst->texture,
+ dst->u.tex.level,
+ dst->u.tex.first_layer,
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height, &dst_trans);
assert(dst_map);
util_fill_rect(dst_map, dst->texture->format,
dst_trans->stride,
0, 0, width, height, &uc);
- }
- pipe->transfer_unmap(pipe, dst_trans);
- pipe->transfer_destroy(pipe, dst_trans);
+ pipe->transfer_unmap(pipe, dst_trans);
+ }
}
/**
assert(dst->texture);
if (!dst->texture)
return;
- dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->u.tex.level,
- dst->u.tex.first_layer,
- (need_rmw ? PIPE_TRANSFER_READ_WRITE :
- PIPE_TRANSFER_WRITE),
- dstx, dsty, width, height);
-
- dst_map = pipe->transfer_map(pipe, dst_trans);
-
+ dst_map = pipe_transfer_map(pipe,
+ dst->texture,
+ dst->u.tex.level,
+ dst->u.tex.first_layer,
+ (need_rmw ? PIPE_TRANSFER_READ_WRITE :
+ PIPE_TRANSFER_WRITE),
+ dstx, dsty, width, height, &dst_trans);
assert(dst_map);
if (dst_map) {
assert(0);
break;
}
- }
- pipe->transfer_unmap(pipe, dst_trans);
- pipe->transfer_destroy(pipe, dst_trans);
+ pipe->transfer_unmap(pipe, dst_trans);
+ }
}
* Move raw block of pixels from transfer object to user memory.
*/
void
-pipe_get_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_raw(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
void *dst, int dst_stride)
{
- const void *src;
-
if (dst_stride == 0)
dst_stride = util_format_get_stride(pt->resource->format, w);
if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
- src = pipe->transfer_map(pipe, pt);
- assert(src);
- if(!src)
- return;
-
util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
-
- pipe->transfer_unmap(pipe, pt);
}
* Move raw block of pixels from user memory to transfer object.
*/
void
-pipe_put_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_raw(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const void *src, int src_stride)
{
- void *dst;
enum pipe_format format = pt->resource->format;
if (src_stride == 0)
if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
- dst = pipe->transfer_map(pipe, pt);
- assert(dst);
- if(!dst)
- return;
-
util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0);
-
- pipe->transfer_unmap(pipe, pt);
}
void
pipe_tile_raw_to_rgba(enum pipe_format format,
- void *src,
+ const void *src,
uint w, uint h,
float *dst, unsigned dst_stride)
{
void
pipe_tile_raw_to_unsigned(enum pipe_format format,
- void *src,
+ const void *src,
uint w, uint h,
unsigned *dst, unsigned dst_stride)
{
}
void
-pipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
float *p)
{
- pipe_get_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p);
+ pipe_get_tile_rgba_format(pt, src, x, y, w, h, pt->resource->format, p);
}
void
-pipe_get_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_rgba_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
float *p)
assert((x & 1) == 0);
}
- pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
void
-pipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const float *p)
{
- pipe_put_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p);
+ pipe_put_tile_rgba_format(pt, dst, x, y, w, h, pt->resource->format, p);
}
void
-pipe_put_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_rgba_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const float *p)
0, 0, w, h);
}
- pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
FREE(packed);
}
void
-pipe_put_tile_i_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_i_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const int *p)
packed, util_format_get_stride(format, w),
0, 0, w, h);
- pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0);
FREE(packed);
}
void
-pipe_put_tile_ui_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_ui_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const unsigned int *p)
packed, util_format_get_stride(format, w),
0, 0, w, h);
- pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_put_tile_raw(pt, dst, 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_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_z(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
uint *z)
{
const uint dstStride = w;
- ubyte *map;
+ const ubyte *map = src;
uint *pDest = z;
uint i, j;
enum pipe_format format = pt->resource->format;
if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
- map = (ubyte *)pipe->transfer_map(pipe, pt);
- if (!map) {
- assert(0);
- return;
- }
-
switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
default:
assert(0);
}
-
- pipe->transfer_unmap(pipe, pt);
}
void
-pipe_put_tile_z(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_z(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const uint *zSrc)
{
const uint srcStride = w;
const uint *ptrc = zSrc;
- ubyte *map;
+ ubyte *map = dst;
uint i, j;
enum pipe_format format = pt->resource->format;
if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
- map = (ubyte *)pipe->transfer_map(pipe, pt);
- if (!map) {
- assert(0);
- return;
- }
-
switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
default:
assert(0);
}
-
- pipe->transfer_unmap(pipe, pt);
}
void
-pipe_get_tile_ui_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_ui_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
unsigned int *p)
assert((x & 1) == 0);
}
- pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
pipe_tile_raw_to_unsigned(format, packed, w, h, p, dst_stride);
void
-pipe_get_tile_i_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_i_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
int *p)
assert((x & 1) == 0);
}
- pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+ pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
pipe_tile_raw_to_signed(format, packed, w, h, p, dst_stride);
#endif
void
-pipe_get_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_raw(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
void *p, int dst_stride);
void
-pipe_put_tile_raw(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_raw(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const void *p, int src_stride);
void
-pipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_rgba(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
float *p);
void
-pipe_get_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_rgba_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
float *p);
void
-pipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_rgba(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const float *p);
void
-pipe_put_tile_rgba_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_rgba_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const float *p);
void
-pipe_get_tile_z(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_z(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
uint *z);
void
-pipe_put_tile_z(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_z(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
const uint *z);
void
pipe_tile_raw_to_rgba(enum pipe_format format,
- void *src,
+ const void *src,
uint w, uint h,
float *dst, unsigned dst_stride);
void
pipe_tile_raw_to_unsigned(enum pipe_format format,
- void *src,
+ const void *src,
uint w, uint h,
unsigned *dst, unsigned dst_stride);
int *dst, unsigned dst_stride);
void
-pipe_get_tile_ui_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_ui_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
unsigned int *p);
void
-pipe_get_tile_i_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_get_tile_i_format(struct pipe_transfer *pt,
+ const void *src,
uint x, uint y, uint w, uint h,
enum pipe_format format,
int *p);
void
-pipe_put_tile_ui_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_ui_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const unsigned *p);
void
-pipe_put_tile_i_format(struct pipe_context *pipe,
- struct pipe_transfer *pt,
+pipe_put_tile_i_format(struct pipe_transfer *pt,
+ void *dst,
uint x, uint y, uint w, uint h,
enum pipe_format format,
const int *p);
usage |= PIPE_TRANSFER_DISCARD_RANGE;
}
- transfer = pipe->get_transfer(pipe,
- resource,
- level,
- usage,
- box );
- if (transfer == NULL)
- goto out;
-
- map = pipe_transfer_map(pipe, transfer);
+ map = pipe->transfer_map(pipe,
+ resource,
+ level,
+ usage,
+ box, &transfer);
if (map == NULL)
- goto out;
+ return;
if (resource->target == PIPE_BUFFER) {
assert(box->height == 1);
}
}
-out:
- if (map)
- pipe_transfer_unmap(pipe, transfer);
-
- if (transfer)
- pipe_transfer_destroy(pipe, transfer);
+ pipe_transfer_unmap(pipe, transfer);
}
*/
}
-struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
- if (transfer == NULL)
- return NULL;
-
- transfer->resource = resource;
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
-}
-
void u_default_transfer_unmap( struct pipe_context *pipe,
struct pipe_transfer *transfer )
{
}
-
-void u_default_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- FREE(transfer);
-}
struct pipe_transfer *transfer,
const struct pipe_box *box);
-struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box);
-
void u_default_transfer_unmap( struct pipe_context *pipe,
struct pipe_transfer *transfer );
-void u_default_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer);
-
/* Useful helper to allow >1 implementation of resource functionality
void (*resource_destroy)(struct pipe_screen *,
struct pipe_resource *pt);
- struct pipe_transfer *(*get_transfer)(struct pipe_context *,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *);
+ void *(*transfer_map)(struct pipe_context *,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *,
+ struct pipe_transfer **);
- void (*transfer_destroy)(struct pipe_context *,
- struct pipe_transfer *);
-
- void *(*transfer_map)( struct pipe_context *,
- struct pipe_transfer *transfer );
void (*transfer_flush_region)( struct pipe_context *,
struct pipe_transfer *transfer,
const struct pipe_box *);
void (*transfer_unmap)( struct pipe_context *,
- struct pipe_transfer *transfer );
+ struct pipe_transfer *transfer );
void (*transfer_inline_write)( struct pipe_context *pipe,
struct pipe_resource *resource,
void u_resource_destroy_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource);
-struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box);
-
-void u_transfer_destroy_vtbl(struct pipe_context *pipe,
- struct pipe_transfer *transfer);
-
-void *u_transfer_map_vtbl( struct pipe_context *pipe,
- struct pipe_transfer *transfer );
+void *u_transfer_map_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer);
void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
struct pipe_transfer *transfer,
box->x, upload->offset - box->x);
}
pipe_transfer_unmap(upload->pipe, upload->transfer);
- pipe_transfer_destroy(upload->pipe, upload->transfer);
upload->transfer = NULL;
upload->map = NULL;
}
PIPE_TRANSFER_FLUSH_EXPLICIT,
&upload->transfer);
if (upload->map == NULL) {
+ upload->transfer = NULL;
upload->size = 0;
pipe_resource_reference(&upload->buffer, NULL);
return PIPE_ERROR_OUT_OF_MEMORY;
}
upload->size = size;
-
upload->offset = 0;
return PIPE_OK;
}
if (!upload->map) {
pipe_resource_reference(outbuf, NULL);
*ptr = NULL;
+ upload->transfer = NULL;
return PIPE_ERROR_OUT_OF_MEMORY;
}
if (!matrix)
goto error_matrix;
- buf_transfer = pipe->get_transfer
- (
- pipe, matrix,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
-
- pitch = buf_transfer->stride / sizeof(float);
-
- f = pipe->transfer_map(pipe, buf_transfer);
+ f = pipe->transfer_map(pipe, matrix, 0,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf_transfer);
if (!f)
goto error_map;
+ pitch = buf_transfer->stride / sizeof(float);
+
for(i = 0; i < VL_BLOCK_HEIGHT; ++i)
for(j = 0; j < VL_BLOCK_WIDTH; ++j)
// transpose and scale
f[i * pitch + j] = ((const float (*)[8])const_matrix)[j][i] * scale;
pipe->transfer_unmap(pipe, buf_transfer);
- pipe->transfer_destroy(pipe, buf_transfer);
memset(&sv_templ, 0, sizeof(sv_templ));
u_sampler_view_default_template(&sv_templ, matrix, matrix->format);
return sv;
error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
pipe_resource_reference(&matrix, NULL);
error_matrix:
rect.width = tex->width0;
rect.height = tex->height0;
- buf->tex_transfer = dec->base.context->get_transfer
- (
- dec->base.context, tex,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
+ buf->texels =
+ dec->base.context->transfer_map(dec->base.context, tex, 0,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf->tex_transfer);
buf->block_num = 0;
- buf->texels = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer);
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
buf->ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
vl_vb_unmap(&buf->vertex_stream, dec->base.context);
dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer);
- dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer);
vb[0] = dec->quads;
vb[1] = dec->pos;
if (!res)
goto error_resource;
- buf_transfer = pipe->get_transfer
- (
- pipe, res,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
-
- pitch = buf_transfer->stride / sizeof(float);
-
- f = pipe->transfer_map(pipe, buf_transfer);
+ f = pipe->transfer_map(pipe, res,
+ 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf_transfer);
if (!f)
goto error_map;
+ pitch = buf_transfer->stride / sizeof(float);
+
for (i = 0; i < blocks_per_line; ++i)
for (y = 0; y < VL_BLOCK_HEIGHT; ++y)
for (x = 0; x < VL_BLOCK_WIDTH; ++x) {
}
pipe->transfer_unmap(pipe, buf_transfer);
- pipe->transfer_destroy(pipe, buf_transfer);
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
u_sampler_view_default_template(&sv_tmpl, res, res->format);
return sv;
error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
pipe_resource_reference(&res, NULL);
error_resource:
rect.width *= zscan->blocks_per_line;
- buf_transfer = pipe->get_transfer
- (
- pipe, buffer->quant->texture,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
+ data = pipe->transfer_map(pipe, buffer->quant->texture,
+ 0, PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf_transfer);
+ if (!data)
+ return;
pitch = buf_transfer->stride;
- data = pipe->transfer_map(pipe, buf_transfer);
- if (!data)
- goto error_map;
-
for (i = 0; i < zscan->blocks_per_line; ++i)
for (y = 0; y < VL_BLOCK_HEIGHT; ++y)
for (x = 0; x < VL_BLOCK_WIDTH; ++x)
data[i * VL_BLOCK_WIDTH + y * pitch + x] = matrix[x + y * VL_BLOCK_WIDTH];
pipe->transfer_unmap(pipe, buf_transfer);
-
-error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
- return;
}
void
These methods are used to get data to/from a resource.
-``get_transfer`` creates a transfer object.
+``transfer_map`` creates a memory mapping and the transfer object
+associated with it.
+The returned pointer points to the start of the mapped range according to
+the box region, not the beginning of the resource. If transfer_map fails,
+the returned pointer to the buffer memory is NULL, and the pointer
+to the transfer object remains unchanged (i.e. it can be non-NULL).
-``transfer_destroy`` destroys the transfer object. May cause
-data to be written to the resource at this point.
-
-``transfer_map`` creates a memory mapping for the transfer object.
-The returned map points to the start of the mapped range according to
-the box region, not the beginning of the resource.
-
-``transfer_unmap`` remove the memory mapping for the transfer object.
-Any pointers into the map should be considered invalid and discarded.
+``transfer_unmap`` remove the memory mapping for and destroy
+the transfer object. The pointer into the resource should be considered
+invalid and discarded.
``transfer_inline_write`` performs a simplified transfer for simple writes.
-Basically get_transfer, transfer_map, data write, transfer_unmap, and
-transfer_destroy all in one.
+Basically transfer_map, data write, and transfer_unmap all in one.
The box parameter to some of these functions defines a 1D, 2D or 3D
Resource contents read back (or accessed directly) at transfer create time.
``PIPE_TRANSFER_WRITE``
- Resource contents will be written back at transfer_destroy time (or modified
+ Resource contents will be written back at transfer_unmap time (or modified
as a result of being accessed directly).
``PIPE_TRANSFER_MAP_DIRECTLY``
}
-
-static struct pipe_transfer *
-galahad_context_get_transfer(struct pipe_context *_context,
- struct pipe_resource *_resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *
+galahad_context_transfer_map(struct pipe_context *_context,
+ struct pipe_resource *_resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct galahad_context *glhd_context = galahad_context(_context);
struct galahad_resource *glhd_resource = galahad_resource(_resource);
struct pipe_context *context = glhd_context->pipe;
struct pipe_resource *resource = glhd_resource->resource;
struct pipe_transfer *result;
-
- result = context->get_transfer(context,
- resource,
- level,
- usage,
- box);
-
- if (result)
- return galahad_transfer_create(glhd_context, glhd_resource, result);
- return NULL;
-}
-
-static void
-galahad_context_transfer_destroy(struct pipe_context *_pipe,
- struct pipe_transfer *_transfer)
-{
- galahad_transfer_destroy(galahad_context(_pipe),
- galahad_transfer(_transfer));
-}
-
-static void *
-galahad_context_transfer_map(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
-{
- struct galahad_context *glhd_context = galahad_context(_context);
- struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
- struct pipe_context *context = glhd_context->pipe;
- struct pipe_transfer *transfer = glhd_transfer->transfer;
-
- struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
+ void *map;
+
+ map = context->transfer_map(context,
+ resource,
+ level,
+ usage,
+ box, &result);
+ if (!map)
+ return NULL;
glhd_resource->map_count++;
- return context->transfer_map(context,
- transfer);
+ *transfer = galahad_transfer_create(glhd_context, glhd_resource, result);
+ return *transfer ? map : NULL;
}
-
-
static void
galahad_context_transfer_flush_region(struct pipe_context *_context,
struct pipe_transfer *_transfer,
box);
}
-
static void
galahad_context_transfer_unmap(struct pipe_context *_context,
struct pipe_transfer *_transfer)
context->transfer_unmap(context,
transfer);
+
+ galahad_transfer_destroy(galahad_context(_context),
+ galahad_transfer(_transfer));
}
GLHD_PIPE_INIT(sampler_view_destroy);
GLHD_PIPE_INIT(create_surface);
GLHD_PIPE_INIT(surface_destroy);
- GLHD_PIPE_INIT(get_transfer);
- GLHD_PIPE_INIT(transfer_destroy);
GLHD_PIPE_INIT(transfer_map);
GLHD_PIPE_INIT(transfer_flush_region);
GLHD_PIPE_INIT(transfer_unmap);
return &glhd_transfer->base;
error:
- glhd_context->pipe->transfer_destroy(glhd_context->pipe, transfer);
+ glhd_context->pipe->transfer_unmap(glhd_context->pipe, transfer);
return NULL;
}
struct galahad_transfer *glhd_transfer)
{
pipe_resource_reference(&glhd_transfer->base.resource, NULL);
- glhd_context->pipe->transfer_destroy(glhd_context->pipe,
- glhd_transfer->transfer);
FREE(glhd_transfer);
}
void
i915_init_resource_functions(struct i915_context *i915 )
{
- i915->base.get_transfer = u_get_transfer_vtbl;
i915->base.transfer_map = u_transfer_map_vtbl;
i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
i915->base.transfer_unmap = u_transfer_unmap_vtbl;
- i915->base.transfer_destroy = u_transfer_destroy_vtbl;
i915->base.transfer_inline_write = u_transfer_inline_write_vtbl;
}
}
-static struct pipe_transfer *
-i915_get_transfer(struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *
+i915_buffer_transfer_map(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct i915_context *i915 = i915_context(pipe);
+ struct i915_buffer *buffer = i915_buffer(resource);
struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
if (transfer == NULL)
transfer->level = level;
transfer->usage = usage;
transfer->box = *box;
+ *ptransfer = transfer;
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
+ return buffer->data + transfer->box.x;
}
static void
-i915_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+i915_buffer_transfer_unmap(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
{
struct i915_context *i915 = i915_context(pipe);
util_slab_free(&i915->transfer_pool, transfer);
}
-static void *
-i915_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct i915_buffer *buffer = i915_buffer(transfer->resource);
- return buffer->data + transfer->box.x;
-}
-
-
static void
i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx,
struct pipe_resource *resource,
{
i915_buffer_get_handle, /* get_handle */
i915_buffer_destroy, /* resource_destroy */
- i915_get_transfer, /* get_transfer */
- i915_transfer_destroy, /* transfer_destroy */
i915_buffer_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
- u_default_transfer_unmap, /* transfer_unmap */
+ i915_buffer_transfer_unmap, /* transfer_unmap */
i915_buffer_transfer_inline_write /* transfer_inline_write */
};
FREE(tex);
}
-static struct pipe_transfer *
-i915_texture_get_transfer(struct pipe_context *pipe,
+static void *
+i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct i915_context *i915 = i915_context(pipe);
struct i915_texture *tex = i915_texture(resource);
struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool);
boolean use_staging_texture = FALSE;
+ struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
+ enum pipe_format format = resource->format;
+ unsigned offset;
+ char *map;
if (transfer == NULL)
return NULL;
transfer->staging_texture = i915_texture_create(pipe->screen, resource, TRUE);
}
- return (struct pipe_transfer*)transfer;
-}
-
-static void
-i915_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_context *i915 = i915_context(pipe);
- struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
-
- if ((itransfer->staging_texture) &&
- (transfer->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_box sbox;
-
- u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
- pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
- itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
- itransfer->staging_texture,
- 0, &sbox);
- pipe->flush(pipe, NULL);
- pipe_resource_reference(&itransfer->staging_texture, NULL);
- }
-
- util_slab_free(&i915->texture_transfer_pool, itransfer);
-}
-
-static void *
-i915_texture_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
- struct pipe_resource *resource = itransfer->b.resource;
- struct i915_texture *tex = NULL;
- struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
- struct pipe_box *box = &itransfer->b.box;
- enum pipe_format format = resource->format;
- unsigned offset;
- char *map;
-
if (resource->target != PIPE_TEXTURE_3D &&
resource->target != PIPE_TEXTURE_CUBE)
assert(box->z == 0);
- if (itransfer->staging_texture) {
- tex = i915_texture(itransfer->staging_texture);
+ if (transfer->staging_texture) {
+ tex = i915_texture(transfer->staging_texture);
} else {
/* TODO this is a sledgehammer */
tex = i915_texture(resource);
pipe->flush(pipe, NULL);
}
- offset = i915_texture_offset(tex, itransfer->b.level, box->z);
+ offset = i915_texture_offset(tex, transfer->b.level, box->z);
map = iws->buffer_map(iws, tex->buffer,
- (itransfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
+ (transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
if (map == NULL) {
+ pipe_resource_reference(&transfer->staging_texture, NULL);
+ FREE(transfer);
return NULL;
}
+ *ptransfer = &transfer->b;
+
return map + offset +
- box->y / util_format_get_blockheight(format) * itransfer->b.stride +
+ box->y / util_format_get_blockheight(format) * transfer->b.stride +
box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
i915_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct i915_context *i915 = i915_context(pipe);
struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
struct i915_texture *tex = i915_texture(itransfer->b.resource);
struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
tex = i915_texture(itransfer->staging_texture);
iws->buffer_unmap(iws, tex->buffer);
+
+ if ((itransfer->staging_texture) &&
+ (transfer->usage & PIPE_TRANSFER_WRITE)) {
+ struct pipe_box sbox;
+
+ u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
+ pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
+ itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
+ itransfer->staging_texture,
+ 0, &sbox);
+ pipe->flush(pipe, NULL);
+ pipe_resource_reference(&itransfer->staging_texture, NULL);
+ }
+
+ util_slab_free(&i915->texture_transfer_pool, itransfer);
}
+#if 0
static void i915_transfer_inline_write( struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
const uint8_t *src_data = data;
unsigned i;
- transfer = pipe->get_transfer(pipe,
+ transfer = pipe->transfer_get(pipe,
resource,
level,
usage,
if (itransfer)
pipe_transfer_destroy(pipe, &itransfer->b);
}
-
-
+#endif
struct u_resource_vtbl i915_texture_vtbl =
{
i915_texture_get_handle, /* get_handle */
i915_texture_destroy, /* resource_destroy */
- i915_texture_get_transfer, /* get_transfer */
- i915_transfer_destroy, /* transfer_destroy */
i915_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
i915_texture_transfer_unmap, /* transfer_unmap */
- i915_transfer_inline_write /* transfer_inline_write */
+ u_default_transfer_inline_write /* transfer_inline_write */
};
-
-
struct pipe_resource *
i915_texture_create(struct pipe_screen *screen,
const struct pipe_resource *template,
identity_surface(_surf));
}
-static struct pipe_transfer *
-identity_context_get_transfer(struct pipe_context *_context,
+static void *
+identity_context_transfer_map(struct pipe_context *_context,
struct pipe_resource *_resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct identity_context *id_context = identity_context(_context);
struct identity_resource *id_resource = identity_resource(_resource);
struct pipe_context *context = id_context->pipe;
struct pipe_resource *resource = id_resource->resource;
struct pipe_transfer *result;
+ void *map;
- result = context->get_transfer(context,
- resource,
- level,
- usage,
- box);
-
- if (result)
- return identity_transfer_create(id_context, id_resource, result);
- return NULL;
-}
+ map = context->transfer_map(context,
+ resource,
+ level,
+ usage,
+ box, &result);
-static void
-identity_context_transfer_destroy(struct pipe_context *_pipe,
- struct pipe_transfer *_transfer)
-{
- identity_transfer_destroy(identity_context(_pipe),
- identity_transfer(_transfer));
-}
-
-static void *
-identity_context_transfer_map(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
-{
- struct identity_context *id_context = identity_context(_context);
- struct identity_transfer *id_transfer = identity_transfer(_transfer);
- struct pipe_context *context = id_context->pipe;
- struct pipe_transfer *transfer = id_transfer->transfer;
+ if (!map)
+ return NULL;
- return context->transfer_map(context,
- transfer);
+ *transfer = identity_transfer_map(id_context, id_resource, result);
+ return *transfer ? map : NULL;
}
-
-
static void
identity_context_transfer_flush_region(struct pipe_context *_context,
struct pipe_transfer *_transfer,
context->transfer_unmap(context,
transfer);
+
+ identity_transfer_destroy(identity_context(_context),
+ identity_transfer(_transfer));
}
id_pipe->base.surface_destroy = identity_context_surface_destroy;
id_pipe->base.create_sampler_view = identity_context_create_sampler_view;
id_pipe->base.sampler_view_destroy = identity_context_sampler_view_destroy;
- id_pipe->base.get_transfer = identity_context_get_transfer;
- id_pipe->base.transfer_destroy = identity_context_transfer_destroy;
id_pipe->base.transfer_map = identity_context_transfer_map;
id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region;
struct pipe_transfer *
-identity_transfer_create(struct identity_context *id_context,
- struct identity_resource *id_resource,
- struct pipe_transfer *transfer)
+identity_transfer_map(struct identity_context *id_context,
+ struct identity_resource *id_resource,
+ struct pipe_transfer *transfer)
{
struct identity_transfer *id_transfer;
return &id_transfer->base;
error:
- id_context->pipe->transfer_destroy(id_context->pipe, transfer);
+ id_context->pipe->transfer_unmap(id_context->pipe, transfer);
return NULL;
}
struct identity_transfer *id_transfer)
{
pipe_resource_reference(&id_transfer->base.resource, NULL);
- id_context->pipe->transfer_destroy(id_context->pipe,
- id_transfer->transfer);
FREE(id_transfer);
}
struct identity_sampler_view *id_sampler_view);
struct pipe_transfer *
-identity_transfer_create(struct identity_context *id_context,
+identity_transfer_map(struct identity_context *id_context,
struct identity_resource *id_resource,
struct pipe_transfer *transfer);
}
-static struct pipe_transfer *
-llvmpipe_get_transfer(struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *
+llvmpipe_transfer_map( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer )
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
- struct llvmpipe_resource *lprex = llvmpipe_resource(resource);
- struct llvmpipe_transfer *lpr;
+ struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
+ struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
+ struct llvmpipe_transfer *lpt;
+ struct pipe_transfer *pt;
+ ubyte *map;
+ enum pipe_format format;
+ enum lp_texture_usage tex_usage;
+ const char *mode;
assert(resource);
assert(level <= resource->last_level);
if (resource == llvmpipe->constants[PIPE_SHADER_FRAGMENT][0])
llvmpipe->dirty |= LP_NEW_CONSTANTS;
- lpr = CALLOC_STRUCT(llvmpipe_transfer);
- if (lpr) {
- struct pipe_transfer *pt = &lpr->base;
- pipe_resource_reference(&pt->resource, resource);
- pt->box = *box;
- pt->level = level;
- pt->stride = lprex->row_stride[level];
- pt->layer_stride = lprex->img_stride[level];
- pt->usage = usage;
-
- return pt;
- }
- return NULL;
-}
-
-
-static void
-llvmpipe_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- /* 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 llvmpipe, nothing to do.
- */
- assert (transfer->resource);
- pipe_resource_reference(&transfer->resource, NULL);
- FREE(transfer);
-}
-
-
-static void *
-llvmpipe_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
- ubyte *map;
- struct llvmpipe_resource *lpr;
- enum pipe_format format;
- enum lp_texture_usage tex_usage;
- const char *mode;
+ lpt = CALLOC_STRUCT(llvmpipe_transfer);
+ if (!lpt)
+ return NULL;
+ pt = &lpt->base;
+ pipe_resource_reference(&pt->resource, resource);
+ pt->box = *box;
+ pt->level = level;
+ pt->stride = lpr->row_stride[level];
+ pt->layer_stride = lpr->img_stride[level];
+ pt->usage = usage;
+ *transfer = pt;
- assert(transfer->level < LP_MAX_TEXTURE_LEVELS);
+ assert(level < LP_MAX_TEXTURE_LEVELS);
/*
printf("tex_transfer_map(%d, %d %d x %d of %d x %d, usage %d )\n",
transfer->usage);
*/
- if (transfer->usage == PIPE_TRANSFER_READ) {
+ if (usage == PIPE_TRANSFER_READ) {
tex_usage = LP_TEX_USAGE_READ;
mode = "read";
}
}
if (0) {
- struct llvmpipe_resource *lpr = llvmpipe_resource(transfer->resource);
printf("transfer map tex %u mode %s\n", lpr->id, mode);
}
-
- assert(transfer->resource);
- lpr = llvmpipe_resource(transfer->resource);
format = lpr->base.format;
- map = llvmpipe_resource_map(transfer->resource,
- transfer->level,
- transfer->box.z,
+ map = llvmpipe_resource_map(resource,
+ level,
+ box->z,
tex_usage, LP_TEX_LAYOUT_LINEAR);
/* May want to do different things here depending on read/write nature
* of the map:
*/
- if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ if (usage & PIPE_TRANSFER_WRITE) {
/* Do something to notify sharing contexts of a texture change.
*/
screen->timestamp++;
}
map +=
- transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
- transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ box->y / util_format_get_blockheight(format) * pt->stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
return map;
}
llvmpipe_resource_unmap(transfer->resource,
transfer->level,
transfer->box.z);
+
+ /* 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 llvmpipe, nothing to do.
+ */
+ assert (transfer->resource);
+ pipe_resource_reference(&transfer->resource, NULL);
+ FREE(transfer);
}
unsigned int
void
llvmpipe_init_context_resource_funcs(struct pipe_context *pipe)
{
- pipe->get_transfer = llvmpipe_get_transfer;
- pipe->transfer_destroy = llvmpipe_transfer_destroy;
pipe->transfer_map = llvmpipe_transfer_map;
pipe->transfer_unmap = llvmpipe_transfer_unmap;
/*
* transfer
*/
-static struct pipe_transfer *noop_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- enum pipe_transfer_usage usage,
- const struct pipe_box *box)
-{
- struct pipe_transfer *transfer;
-
- transfer = CALLOC_STRUCT(pipe_transfer);
- if (transfer == NULL)
- return NULL;
- pipe_resource_reference(&transfer->resource, resource);
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
- transfer->stride = 1;
- transfer->layer_stride = 1;
- return transfer;
-}
-
static void *noop_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+ struct pipe_resource *resource,
+ unsigned level,
+ enum pipe_transfer_usage usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
- struct noop_resource *nresource = (struct noop_resource *)transfer->resource;
+ struct pipe_transfer *transfer;
+ struct noop_resource *nresource = (struct noop_resource *)resource;
+
+ transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+ pipe_resource_reference(&transfer->resource, resource);
+ transfer->level = level;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = 1;
+ transfer->layer_stride = 1;
+ *ptransfer = transfer;
- return nresource->data;
+ return nresource->data;
}
static void noop_transfer_flush_region(struct pipe_context *pipe,
static void noop_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
-}
-
-static void noop_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- pipe_resource_reference(&transfer->resource, NULL);
- FREE(transfer);
+ pipe_resource_reference(&transfer->resource, NULL);
+ FREE(transfer);
}
static void noop_transfer_inline_write(struct pipe_context *pipe,
ctx->begin_query = noop_begin_query;
ctx->end_query = noop_end_query;
ctx->get_query_result = noop_get_query_result;
- ctx->get_transfer = noop_get_transfer;
ctx->transfer_map = noop_transfer_map;
ctx->transfer_flush_region = noop_transfer_flush_region;
ctx->transfer_unmap = noop_transfer_unmap;
- ctx->transfer_destroy = noop_transfer_destroy;
ctx->transfer_inline_write = noop_transfer_inline_write;
noop_init_state_functions(ctx);
return TRUE;
}
-static struct pipe_transfer *
-nouveau_buffer_transfer_get(struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level, unsigned usage,
- const struct pipe_box *box)
-{
- struct nv04_resource *buf = nv04_resource(resource);
- struct nouveau_context *nv = nouveau_context(pipe);
- struct nouveau_transfer *xfr = CALLOC_STRUCT(nouveau_transfer);
- if (!xfr)
- return NULL;
-
- xfr->base.resource = resource;
- xfr->base.box.x = box->x;
- xfr->base.box.width = box->width;
- xfr->base.usage = usage;
-
- if (buf->domain == NOUVEAU_BO_VRAM) {
- if (usage & PIPE_TRANSFER_READ) {
- if (buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING)
- nouveau_buffer_download(nv, buf, 0, buf->base.width0);
- }
- }
-
- return &xfr->base;
-}
-
-static void
-nouveau_buffer_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct nv04_resource *buf = nv04_resource(transfer->resource);
- struct nouveau_transfer *xfr = nouveau_transfer(transfer);
- struct nouveau_context *nv = nouveau_context(pipe);
-
- if (xfr->base.usage & PIPE_TRANSFER_WRITE) {
- if (buf->domain == NOUVEAU_BO_VRAM) {
- nouveau_buffer_upload(nv, buf, transfer->box.x, transfer->box.width);
- }
-
- if (buf->domain != 0 && (buf->base.bind & (PIPE_BIND_VERTEX_BUFFER |
- PIPE_BIND_INDEX_BUFFER)))
- nouveau_context(pipe)->vbo_dirty = TRUE;
- }
-
- FREE(xfr);
-}
-
static INLINE boolean
nouveau_buffer_sync(struct nv04_resource *buf, unsigned rw)
{
static void *
nouveau_buffer_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+ struct pipe_resource *resource,
+ unsigned level, unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
+ struct nv04_resource *buf = nv04_resource(resource);
struct nouveau_context *nv = nouveau_context(pipe);
- struct nouveau_transfer *xfr = nouveau_transfer(transfer);
- struct nv04_resource *buf = nv04_resource(transfer->resource);
+ struct nouveau_transfer *xfr = CALLOC_STRUCT(nouveau_transfer);
struct nouveau_bo *bo = buf->bo;
uint8_t *map;
int ret;
uint32_t offset = xfr->base.box.x;
uint32_t flags = 0;
- if (buf->domain != NOUVEAU_BO_GART)
+ if (!xfr)
+ return NULL;
+
+ xfr->base.resource = resource;
+ xfr->base.box.x = box->x;
+ xfr->base.box.width = box->width;
+ xfr->base.usage = usage;
+
+ if (buf->domain == NOUVEAU_BO_VRAM) {
+ if (usage & PIPE_TRANSFER_READ) {
+ if (buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING)
+ nouveau_buffer_download(nv, buf, 0, buf->base.width0);
+ }
+ }
+
+ if (buf->domain != NOUVEAU_BO_GART) {
+ *ptransfer = &xfr->base;
return buf->data + offset;
+ }
if (!buf->mm)
flags = nouveau_screen_transfer_flags(xfr->base.usage);
offset += buf->offset;
ret = nouveau_bo_map(buf->bo, flags, nv->screen->client);
- if (ret)
+ if (ret) {
+ FREE(xfr);
return NULL;
+ }
map = (uint8_t *)bo->map + offset;
if (buf->mm) {
if (xfr->base.usage & PIPE_TRANSFER_DONTBLOCK) {
- if (nouveau_buffer_busy(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE))
+ if (nouveau_buffer_busy(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE)) {
+ FREE(xfr);
return NULL;
+ }
} else
if (!(xfr->base.usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
nouveau_buffer_sync(buf, xfr->base.usage & PIPE_TRANSFER_READ_WRITE);
}
}
+ *ptransfer = &xfr->base;
return map;
}
nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct nv04_resource *buf = nv04_resource(transfer->resource);
+ struct nouveau_transfer *xfr = nouveau_transfer(transfer);
+ struct nouveau_context *nv = nouveau_context(pipe);
+
+ if (xfr->base.usage & PIPE_TRANSFER_WRITE) {
+ if (buf->domain == NOUVEAU_BO_VRAM) {
+ nouveau_buffer_upload(nv, buf, transfer->box.x, transfer->box.width);
+ }
+
+ if (buf->domain != 0 && (buf->base.bind & (PIPE_BIND_VERTEX_BUFFER |
+ PIPE_BIND_INDEX_BUFFER)))
+ nouveau_context(pipe)->vbo_dirty = TRUE;
+ }
+
+ FREE(xfr);
}
{
u_default_resource_get_handle, /* get_handle */
nouveau_buffer_destroy, /* resource_destroy */
- nouveau_buffer_transfer_get, /* get_transfer */
- nouveau_buffer_transfer_destroy, /* transfer_destroy */
nouveau_buffer_transfer_map, /* transfer_map */
nouveau_buffer_transfer_flush_region, /* transfer_flush_region */
nouveau_buffer_transfer_unmap, /* transfer_unmap */
util_blitter_blit(nv30->blitter, &info);
}
-static struct pipe_transfer *
-nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
+static void *
+nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
unsigned level, unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct nv30_context *nv30 = nv30_context(pipe);
struct nouveau_device *dev = nv30->screen->base.device;
struct nv30_transfer *tx;
+ unsigned access = 0;
int ret;
tx = CALLOC_STRUCT(nv30_transfer);
if (usage & PIPE_TRANSFER_READ)
nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp);
- return &tx->base;
-}
-
-static void
-nv30_miptree_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
- struct nv30_context *nv30 = nv30_context(pipe);
- struct nv30_transfer *tx = nv30_transfer(ptx);
-
- if (ptx->usage & PIPE_TRANSFER_WRITE)
- nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
-
- nouveau_bo_ref(NULL, &tx->tmp.bo);
- pipe_resource_reference(&ptx->resource, NULL);
- FREE(tx);
-}
-
-static void *
-nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
- struct nv30_context *nv30 = nv30_context(pipe);
- struct nv30_transfer *tx = nv30_transfer(ptx);
- unsigned access = 0;
- int ret;
-
- if (tx->tmp.bo->map)
+ if (tx->tmp.bo->map) {
+ *ptransfer = &tx->base;
return tx->tmp.bo->map;
+ }
- if (ptx->usage & PIPE_TRANSFER_READ)
+ if (usage & PIPE_TRANSFER_READ)
access |= NOUVEAU_BO_RD;
- if (ptx->usage & PIPE_TRANSFER_WRITE)
+ if (usage & PIPE_TRANSFER_WRITE)
access |= NOUVEAU_BO_WR;
ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
- if (ret)
+ if (ret) {
+ pipe_resource_reference(&tx->base.resource, NULL);
+ FREE(tx);
return NULL;
+ }
+
+ *ptransfer = &tx->base;
return tx->tmp.bo->map;
}
nv30_miptree_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *ptx)
{
+ struct nv30_context *nv30 = nv30_context(pipe);
+ struct nv30_transfer *tx = nv30_transfer(ptx);
+
+ if (ptx->usage & PIPE_TRANSFER_WRITE)
+ nv30_transfer_rect(nv30, NEAREST, &tx->tmp, &tx->img);
+
+ nouveau_bo_ref(NULL, &tx->tmp.bo);
+ pipe_resource_reference(&ptx->resource, NULL);
+ FREE(tx);
}
const struct u_resource_vtbl nv30_miptree_vtbl = {
nv30_miptree_get_handle,
nv30_miptree_destroy,
- nv30_miptree_transfer_new,
- nv30_miptree_transfer_del,
nv30_miptree_transfer_map,
u_default_transfer_flush_region,
nv30_miptree_transfer_unmap,
void
nv30_resource_init(struct pipe_context *pipe)
{
- pipe->get_transfer = u_get_transfer_vtbl;
pipe->transfer_map = u_transfer_map_vtbl;
pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
pipe->transfer_unmap = u_transfer_unmap_vtbl;
- pipe->transfer_destroy = u_transfer_destroy_vtbl;
pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
pipe->create_surface = nv30_miptree_surface_new;
pipe->surface_destroy = nv30_miptree_surface_del;
{
nv50_miptree_get_handle, /* get_handle */
nv50_miptree_destroy, /* resource_destroy */
- nv50_miptree_transfer_new, /* get_transfer */
- nv50_miptree_transfer_del, /* transfer_destroy */
nv50_miptree_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
nv50_miptree_transfer_unmap, /* transfer_unmap */
void
nv50_init_resource_functions(struct pipe_context *pcontext)
{
- pcontext->get_transfer = u_get_transfer_vtbl;
pcontext->transfer_map = u_transfer_map_vtbl;
pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
pcontext->transfer_unmap = u_transfer_unmap_vtbl;
- pcontext->transfer_destroy = u_transfer_destroy_vtbl;
pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
pcontext->create_surface = nv50_surface_create;
pcontext->surface_destroy = nv50_surface_destroy;
struct pipe_resource *,
const struct pipe_surface *templ);
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pcontext,
- struct pipe_resource *pt,
+void *
+nv50_miptree_transfer_map(struct pipe_context *pctx,
+ struct pipe_resource *res,
unsigned level,
unsigned usage,
- const struct pipe_box *box);
-void
-nv50_miptree_transfer_del(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
-void *
-nv50_miptree_transfer_map(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer);
void
nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
struct pipe_transfer *ptx);
nouveau_bufctx_reset(bctx, 0);
}
-struct pipe_transfer *
-nv50_miptree_transfer_new(struct pipe_context *pctx,
+void *
+nv50_miptree_transfer_map(struct pipe_context *pctx,
struct pipe_resource *res,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
+ struct nv50_screen *screen = nv50_screen(pctx->screen);
struct nv50_context *nv50 = nv50_context(pctx);
struct nouveau_device *dev = nv50->screen->base.device;
const struct nv50_miptree *mt = nv50_miptree(res);
struct nv50_transfer *tx;
uint32_t size;
int ret;
+ unsigned flags = 0;
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
return NULL;
tx->rect[1].base = 0;
}
- return &tx->base;
+ if (tx->rect[1].bo->map) {
+ *ptransfer = &tx->base;
+ return tx->rect[1].bo->map;
+ }
+
+ if (usage & PIPE_TRANSFER_READ)
+ flags = NOUVEAU_BO_RD;
+ if (usage & PIPE_TRANSFER_WRITE)
+ flags |= NOUVEAU_BO_WR;
+
+ ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client);
+ if (ret) {
+ nouveau_bo_ref(NULL, &tx->rect[1].bo);
+ FREE(tx);
+ return NULL;
+ }
+
+ *ptransfer = &tx->base;
+ return tx->rect[1].bo->map;
}
void
-nv50_miptree_transfer_del(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
+nv50_miptree_transfer_unmap(struct pipe_context *pctx,
+ struct pipe_transfer *transfer)
{
struct nv50_context *nv50 = nv50_context(pctx);
struct nv50_transfer *tx = (struct nv50_transfer *)transfer;
FREE(tx);
}
-void *
-nv50_miptree_transfer_map(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
- struct nv50_screen *screen = nv50_screen(pctx->screen);
- struct nv50_transfer *tx = (struct nv50_transfer *)transfer;
- int ret;
- unsigned flags = 0;
-
- if (tx->rect[1].bo->map)
- return tx->rect[1].bo->map;
-
- if (transfer->usage & PIPE_TRANSFER_READ)
- flags = NOUVEAU_BO_RD;
- if (transfer->usage & PIPE_TRANSFER_WRITE)
- flags |= NOUVEAU_BO_WR;
-
- ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client);
- if (ret)
- return NULL;
- return tx->rect[1].bo->map;
-}
-
-void
-nv50_miptree_transfer_unmap(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
- /* nothing to do */
-}
-
void
nv50_cb_push(struct nouveau_context *nv,
struct nouveau_bo *bo, unsigned domain,
{
nv50_miptree_get_handle, /* get_handle */
nv50_miptree_destroy, /* resource_destroy */
- nvc0_miptree_transfer_new, /* get_transfer */
- nvc0_miptree_transfer_del, /* transfer_destroy */
nvc0_miptree_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
nvc0_miptree_transfer_unmap, /* transfer_unmap */
void
nvc0_init_resource_functions(struct pipe_context *pcontext)
{
- pcontext->get_transfer = u_get_transfer_vtbl;
pcontext->transfer_map = u_transfer_map_vtbl;
pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
pcontext->transfer_unmap = u_transfer_unmap_vtbl;
- pcontext->transfer_destroy = u_transfer_destroy_vtbl;
pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
pcontext->create_surface = nvc0_surface_create;
pcontext->surface_destroy = nv50_surface_destroy;
unsigned
nvc0_mt_zslice_offset(const struct nv50_miptree *, unsigned l, unsigned z);
-struct pipe_transfer *
-nvc0_miptree_transfer_new(struct pipe_context *pcontext,
- struct pipe_resource *pt,
+void *
+nvc0_miptree_transfer_map(struct pipe_context *pctx,
+ struct pipe_resource *res,
unsigned level,
unsigned usage,
- const struct pipe_box *box);
-void
-nvc0_miptree_transfer_del(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
-void *
-nvc0_miptree_transfer_map(struct pipe_context *pcontext,
- struct pipe_transfer *ptx);
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer);
void
nvc0_miptree_transfer_unmap(struct pipe_context *pcontext,
struct pipe_transfer *ptx);
nouveau_bufctx_reset(bctx, 0);
}
-struct pipe_transfer *
-nvc0_miptree_transfer_new(struct pipe_context *pctx,
+void *
+nvc0_miptree_transfer_map(struct pipe_context *pctx,
struct pipe_resource *res,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct nvc0_context *nvc0 = nvc0_context(pctx);
struct nouveau_device *dev = nvc0->screen->base.device;
struct nvc0_transfer *tx;
uint32_t size;
int ret;
+ unsigned flags = 0;
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
return NULL;
ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
size * tx->nlayers, NULL, &tx->rect[1].bo);
if (ret) {
+ pipe_resource_reference(&tx->base.resource, NULL);
FREE(tx);
return NULL;
}
tx->rect[1].base = 0;
}
- return &tx->base;
+ if (tx->rect[1].bo->map) {
+ *ptransfer = &tx->base;
+ return tx->rect[1].bo->map;
+ }
+
+ if (usage & PIPE_TRANSFER_READ)
+ flags = NOUVEAU_BO_RD;
+ if (usage & PIPE_TRANSFER_WRITE)
+ flags |= NOUVEAU_BO_WR;
+
+ ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client);
+ if (ret) {
+ pipe_resource_reference(&tx->base.resource, NULL);
+ nouveau_bo_ref(NULL, &tx->rect[1].bo);
+ FREE(tx);
+ return NULL;
+ }
+
+ *ptransfer = &tx->base;
+ return tx->rect[1].bo->map;
}
void
-nvc0_miptree_transfer_del(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
+nvc0_miptree_transfer_unmap(struct pipe_context *pctx,
+ struct pipe_transfer *transfer)
{
struct nvc0_context *nvc0 = nvc0_context(pctx);
struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer;
FREE(tx);
}
-void *
-nvc0_miptree_transfer_map(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
- struct nvc0_context *nvc0 = nvc0_context(pctx);
- struct nvc0_transfer *tx = (struct nvc0_transfer *)transfer;
- int ret;
- unsigned flags = 0;
-
- if (tx->rect[1].bo->map)
- return tx->rect[1].bo->map;
-
- if (transfer->usage & PIPE_TRANSFER_READ)
- flags = NOUVEAU_BO_RD;
- if (transfer->usage & PIPE_TRANSFER_WRITE)
- flags |= NOUVEAU_BO_WR;
-
- ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client);
- if (ret)
- return NULL;
- return tx->rect[1].bo->map;
-}
-
-void
-nvc0_miptree_transfer_unmap(struct pipe_context *pctx,
- struct pipe_transfer *transfer)
-{
-}
-
void
nvc0_cb_push(struct nouveau_context *nv,
struct nouveau_bo *bo, unsigned domain,
void r300_init_resource_functions(struct r300_context *r300)
{
- r300->context.get_transfer = u_get_transfer_vtbl;
r300->context.transfer_map = u_transfer_map_vtbl;
r300->context.transfer_flush_region = u_default_transfer_flush_region;
r300->context.transfer_unmap = u_transfer_unmap_vtbl;
- r300->context.transfer_destroy = u_transfer_destroy_vtbl;
r300->context.transfer_inline_write = u_default_transfer_inline_write;
r300->context.create_surface = r300_create_surface;
r300->context.surface_destroy = r300_surface_destroy;
FREE(rbuf);
}
-static struct pipe_transfer*
-r300_buffer_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct r300_context *r300 = r300_context(context);
- struct pipe_transfer *transfer =
- util_slab_alloc(&r300->pool_transfers);
-
- transfer->resource = resource;
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
- transfer->stride = 0;
- transfer->layer_stride = 0;
- transfer->data = NULL;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
-}
-
-static void r300_buffer_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct r300_context *r300 = r300_context(pipe);
- util_slab_free(&r300->pool_transfers, transfer);
-}
-
static void *
-r300_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+r300_buffer_transfer_map( struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer )
{
- struct r300_context *r300 = r300_context(pipe);
- struct r300_screen *r300screen = r300_screen(pipe->screen);
- struct radeon_winsys *rws = r300screen->rws;
- struct r300_resource *rbuf = r300_resource(transfer->resource);
+ struct r300_context *r300 = r300_context(context);
+ struct radeon_winsys *rws = r300->screen->rws;
+ struct r300_resource *rbuf = r300_resource(resource);
+ struct pipe_transfer *transfer;
uint8_t *map;
- enum pipe_transfer_usage usage;
- if (rbuf->malloced_buffer)
- return (uint8_t *) rbuf->malloced_buffer + transfer->box.x;
+ transfer = util_slab_alloc(&r300->pool_transfers);
+ transfer->resource = resource;
+ transfer->level = level;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = 0;
+ transfer->layer_stride = 0;
+ transfer->data = NULL;
+
+ if (rbuf->malloced_buffer) {
+ *ptransfer = transfer;
+ return (uint8_t *) rbuf->malloced_buffer + box->x;
+ }
/* Buffers are never used for write, therefore mapping for read can be
* unsynchronized. */
- usage = transfer->usage;
if (!(usage & PIPE_TRANSFER_WRITE)) {
usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
}
map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
- if (map == NULL)
+ if (map == NULL) {
+ util_slab_free(&r300->pool_transfers, transfer);
return NULL;
+ }
- return map + transfer->box.x;
+ *ptransfer = transfer;
+ return map + box->x;
}
static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+ struct pipe_transfer *transfer )
{
- /* no-op */
+ struct r300_context *r300 = r300_context(pipe);
+
+ util_slab_free(&r300->pool_transfers, transfer);
}
static const struct u_resource_vtbl r300_buffer_vtbl =
{
NULL, /* get_handle */
r300_buffer_destroy, /* resource_destroy */
- r300_buffer_get_transfer, /* get_transfer */
- r300_buffer_transfer_destroy, /* transfer_destroy */
r300_buffer_transfer_map, /* transfer_map */
NULL, /* transfer_flush_region */
r300_buffer_transfer_unmap, /* transfer_unmap */
{
NULL, /* get_handle */
r300_texture_destroy, /* resource_destroy */
- r300_texture_get_transfer, /* get_transfer */
- r300_texture_transfer_destroy, /* transfer_destroy */
r300_texture_transfer_map, /* transfer_map */
NULL, /* transfer_flush_region */
r300_texture_transfer_unmap, /* transfer_unmap */
r300_flush(ctx, 0, NULL);
}
-struct pipe_transfer*
-r300_texture_get_transfer(struct pipe_context *ctx,
+void *
+r300_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *texture,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct r300_context *r300 = r300_context(ctx);
struct r300_resource *tex = r300_resource(texture);
struct r300_transfer *trans;
struct pipe_resource base;
boolean referenced_cs, referenced_hw;
+ enum pipe_format format = tex->b.b.format;
+ char *map;
referenced_cs =
r300->rws->cs_is_buffer_referenced(r300->cs, tex->cs_buf, RADEON_USAGE_READWRITE);
trans = CALLOC_STRUCT(r300_transfer);
if (trans) {
/* Initialize the transfer object. */
- pipe_resource_reference(&trans->transfer.resource, texture);
+ trans->transfer.resource = texture;
trans->transfer.level = level;
trans->transfer.usage = usage;
trans->transfer.box = *box;
&base));
if (!trans->linear_texture) {
- /* For linear textures, it's safe to fallback to
- * an unpipelined transfer. */
- if (!tex->tex.microtile && !tex->tex.macrotile[level]) {
- goto unpipelined;
- }
-
- /* Otherwise, go to hell. */
fprintf(stderr,
- "r300: Failed to create a transfer object, praise.\n");
+ "r300: Failed to create a transfer object.\n");
FREE(trans);
return NULL;
}
/* Always referenced in the blit. */
r300_flush(ctx, 0, NULL);
}
- return &trans->transfer;
- }
-
- unpipelined:
- /* Unpipelined transfer. */
- trans->transfer.stride = tex->tex.stride_in_bytes[level];
- trans->offset = r300_texture_get_offset(tex, level, box->z);
-
- if (referenced_cs &&
- !(usage & PIPE_TRANSFER_UNSYNCHRONIZED))
- r300_flush(ctx, 0, NULL);
- return &trans->transfer;
- }
- return NULL;
-}
+ } else {
+ /* Unpipelined transfer. */
+ trans->transfer.stride = tex->tex.stride_in_bytes[level];
+ trans->offset = r300_texture_get_offset(tex, level, box->z);
-void r300_texture_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *trans)
-{
- struct r300_transfer *r300transfer = r300_transfer(trans);
-
- if (r300transfer->linear_texture) {
- if (trans->usage & PIPE_TRANSFER_WRITE) {
- r300_copy_into_tiled_texture(ctx, r300transfer);
+ if (referenced_cs &&
+ !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+ r300_flush(ctx, 0, NULL);
+ }
}
-
- pipe_resource_reference(
- (struct pipe_resource**)&r300transfer->linear_texture, NULL);
}
- pipe_resource_reference(&trans->resource, NULL);
- FREE(trans);
-}
-void* r300_texture_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
-{
- struct r300_context *r300 = r300_context(ctx);
- struct r300_transfer *r300transfer = r300_transfer(transfer);
- struct r300_resource *tex = r300_resource(transfer->resource);
- char *map;
- enum pipe_format format = tex->b.b.format;
-
- if (r300transfer->linear_texture) {
+ if (trans->linear_texture) {
/* The detiled texture is of the same size as the region being mapped
* (no offset needed). */
- return r300->rws->buffer_map(r300transfer->linear_texture->cs_buf,
- r300->cs, transfer->usage);
+ map = r300->rws->buffer_map(trans->linear_texture->cs_buf,
+ r300->cs, usage);
+ if (!map) {
+ pipe_resource_reference(
+ (struct pipe_resource**)&trans->linear_texture, NULL);
+ FREE(trans);
+ return NULL;
+ }
+ *transfer = &trans->transfer;
+ return map;
} else {
/* Tiling is disabled. */
- map = r300->rws->buffer_map(tex->cs_buf, r300->cs, transfer->usage);
-
+ map = r300->rws->buffer_map(tex->cs_buf, r300->cs, usage);
if (!map) {
+ FREE(trans);
return NULL;
}
- return map + r300_transfer(transfer)->offset +
- transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
- transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ *transfer = &trans->transfer;
+ return map + trans->offset +
+ box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
}
struct pipe_transfer *transfer)
{
struct radeon_winsys *rws = r300_context(ctx)->rws;
- struct r300_transfer *r300transfer = r300_transfer(transfer);
+ struct r300_transfer *trans = r300_transfer(transfer);
struct r300_resource *tex = r300_resource(transfer->resource);
- if (r300transfer->linear_texture) {
- rws->buffer_unmap(r300transfer->linear_texture->cs_buf);
+ if (trans->linear_texture) {
+ rws->buffer_unmap(trans->linear_texture->cs_buf);
+
+ if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ r300_copy_into_tiled_texture(ctx, trans);
+ }
+
+ pipe_resource_reference(
+ (struct pipe_resource**)&trans->linear_texture, NULL);
} else {
rws->buffer_unmap(tex->cs_buf);
}
+ FREE(transfer);
}
struct r300_context;
-struct pipe_transfer*
-r300_texture_get_transfer(struct pipe_context *ctx,
+void *
+r300_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *texture,
unsigned level,
unsigned usage,
- const struct pipe_box *box);
-
-void
-r300_texture_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *trans);
-
-void*
-r300_texture_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer *transfer);
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer);
void
r300_texture_transfer_unmap(struct pipe_context *ctx,
"offset_in_chunk = %d, size = %d\n", device_to_host,
offset_in_chunk, size);
- if (device_to_host)
- {
- xfer = pipe->get_transfer(pipe, gart, 0, PIPE_TRANSFER_READ,
+ if (device_to_host) {
+ map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_READ,
&(struct pipe_box) { .width = aligned_size,
- .height = 1, .depth = 1 });
- assert(xfer);
- map = pipe->transfer_map(pipe, xfer);
+ .height = 1, .depth = 1 }, &xfer);
+ assert(xfer);
assert(map);
memcpy(data, map + internal_offset, size);
pipe->transfer_unmap(pipe, xfer);
- pipe->transfer_destroy(pipe, xfer);
} else {
- xfer = pipe->get_transfer(pipe, gart, 0, PIPE_TRANSFER_WRITE,
+ map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_WRITE,
&(struct pipe_box) { .width = aligned_size,
- .height = 1, .depth = 1 });
+ .height = 1, .depth = 1 }, &xfer);
assert(xfer);
- map = pipe->transfer_map(pipe, xfer);
assert(map);
memcpy(map + internal_offset, data, size);
pipe->transfer_unmap(pipe, xfer);
- pipe->transfer_destroy(pipe, xfer);
}
}
state->atom.dirty = true;
}
-const struct u_resource_vtbl r600_global_buffer_vtbl =
+static const struct u_resource_vtbl r600_global_buffer_vtbl =
{
u_default_resource_get_handle, /* get_handle */
r600_compute_global_buffer_destroy, /* resource_destroy */
- r600_compute_global_get_transfer, /* get_transfer */
- r600_compute_global_transfer_destroy, /* transfer_destroy */
r600_compute_global_transfer_map, /* transfer_map */
r600_compute_global_transfer_flush_region,/* transfer_flush_region */
r600_compute_global_transfer_unmap, /* transfer_unmap */
free(res);
}
-void* r600_compute_global_transfer_map(
+void *r600_compute_global_transfer_map(
struct pipe_context *ctx_,
- struct pipe_transfer* transfer)
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
+ struct r600_context *rctx = (struct r600_context*)ctx_;
+ struct compute_memory_pool *pool = rctx->screen->global_pool;
+ struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+ struct r600_resource_global* buffer =
+ (struct r600_resource_global*)transfer->resource;
+ uint32_t* map;
+
+ compute_memory_finalize_pending(pool, ctx_);
+
+ assert(resource->target == PIPE_BUFFER);
+
+ COMPUTE_DBG("* r600_compute_global_get_transfer()\n"
+ "level = %u, usage = %u, box(x = %u, y = %u, z = %u "
+ "width = %u, height = %u, depth = %u)\n", level, usage,
+ box->x, box->y, box->z, box->width, box->height,
+ box->depth);
+
+ transfer->resource = resource;
+ transfer->level = level;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = 0;
+ transfer->layer_stride = 0;
+ transfer->data = NULL;
+
assert(transfer->resource->target == PIPE_BUFFER);
assert(transfer->resource->bind & PIPE_BIND_GLOBAL);
assert(transfer->box.x >= 0);
assert(transfer->box.y == 0);
assert(transfer->box.z == 0);
- struct r600_context *ctx = (struct r600_context *)ctx_;
- struct r600_resource_global* buffer =
- (struct r600_resource_global*)transfer->resource;
-
- uint32_t* map;
///TODO: do it better, mapping is not possible if the pool is too big
COMPUTE_DBG("* r600_compute_global_transfer_map()\n");
- if (!(map = ctx->ws->buffer_map(buffer->chunk->pool->bo->cs_buf,
- ctx->cs, transfer->usage))) {
+ if (!(map = rctx->ws->buffer_map(buffer->chunk->pool->bo->cs_buf,
+ rctx->cs, transfer->usage))) {
+ util_slab_free(&rctx->pool_transfers, transfer);
return NULL;
}
+ *ptransfer = transfer;
+
COMPUTE_DBG("Buffer: %p + %u (buffer offset in global memory) "
"+ %u (box.x)\n", map, buffer->chunk->start_in_dw, transfer->box.x);
return ((char*)(map + buffer->chunk->start_in_dw)) + transfer->box.x;
COMPUTE_DBG("* r600_compute_global_transfer_unmap()\n");
ctx->ws->buffer_unmap(buffer->chunk->pool->bo->cs_buf);
-}
-
-struct pipe_transfer * r600_compute_global_get_transfer(
- struct pipe_context *ctx_,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct r600_context *ctx = (struct r600_context *)ctx_;
- struct compute_memory_pool *pool = ctx->screen->global_pool;
-
- compute_memory_finalize_pending(pool, ctx_);
-
- assert(resource->target == PIPE_BUFFER);
- struct r600_context *rctx = (struct r600_context*)ctx_;
- struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
-
- COMPUTE_DBG("* r600_compute_global_get_transfer()\n"
- "level = %u, usage = %u, box(x = %u, y = %u, z = %u "
- "width = %u, height = %u, depth = %u)\n", level, usage,
- box->x, box->y, box->z, box->width, box->height,
- box->depth);
-
- transfer->resource = resource;
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
- transfer->stride = 0;
- transfer->layer_stride = 0;
- transfer->data = NULL;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
-}
-
-void r600_compute_global_transfer_destroy(
- struct pipe_context *ctx_,
- struct pipe_transfer *transfer)
-{
- struct r600_context *rctx = (struct r600_context*)ctx_;
- util_slab_free(&rctx->pool_transfers, transfer);
+ util_slab_free(&ctx->pool_transfers, transfer);
}
void r600_compute_global_transfer_flush_region(
struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ);
void r600_compute_global_buffer_destroy(struct pipe_screen *screen, struct pipe_resource *res);
-void* r600_compute_global_transfer_map(struct pipe_context *ctx, struct pipe_transfer* transfer);
+void *r600_compute_global_transfer_map(
+ struct pipe_context *ctx_,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer);
void r600_compute_global_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer* transfer);
-struct pipe_transfer * r600_compute_global_get_transfer(struct pipe_context *, struct pipe_resource *, unsigned level,
- unsigned usage, const struct pipe_box *);
-void r600_compute_global_transfer_destroy(struct pipe_context *, struct pipe_transfer *);
void r600_compute_global_transfer_flush_region( struct pipe_context *, struct pipe_transfer *, const struct pipe_box *);
void r600_compute_global_transfer_inline_write( struct pipe_context *, struct pipe_resource *, unsigned level,
unsigned usage, const struct pipe_box *, const void *data, unsigned stride, unsigned layer_stride);
FREE(rbuffer);
}
-static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct r600_context *rctx = (struct r600_context*)ctx;
- struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
-
- assert(box->x + box->width <= resource->width0);
-
- transfer->transfer.resource = resource;
- transfer->transfer.level = level;
- transfer->transfer.usage = usage;
- transfer->transfer.box = *box;
- transfer->transfer.stride = 0;
- transfer->transfer.layer_stride = 0;
- transfer->transfer.data = NULL;
- transfer->staging = NULL;
- transfer->offset = 0;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return &transfer->transfer;
-}
-
static void r600_set_constants_dirty_if_bound(struct r600_context *rctx,
struct r600_resource *rbuffer)
{
}
}
-static void *r600_buffer_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+static void *r600_buffer_get_transfer(struct pipe_context *ctx,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer,
+ void *data, struct r600_resource *staging)
{
- struct r600_resource *rbuffer = r600_resource(transfer->resource);
- struct r600_context *rctx = (struct r600_context*)pipe;
+ struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+
+ transfer->transfer.resource = resource;
+ transfer->transfer.level = level;
+ transfer->transfer.usage = usage;
+ transfer->transfer.box = *box;
+ transfer->transfer.stride = 0;
+ transfer->transfer.layer_stride = 0;
+ transfer->transfer.data = NULL;
+ transfer->staging = NULL;
+ transfer->offset = 0;
+ transfer->staging = staging;
+ *ptransfer = &transfer->transfer;
+ return data;
+}
+
+static void *r600_buffer_transfer_map(struct pipe_context *ctx,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
+{
+ struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_resource *rbuffer = r600_resource(resource);
uint8_t *data;
- if (transfer->usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE &&
- !(transfer->usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
- assert(transfer->usage & PIPE_TRANSFER_WRITE);
+ assert(box->x + box->width <= resource->width0);
+
+ if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE &&
+ !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+ assert(usage & PIPE_TRANSFER_WRITE);
/* Check if mapping this buffer would cause waiting for the GPU. */
if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rbuffer->cs_buf, RADEON_USAGE_READWRITE) ||
}
}
#if 0 /* this is broken (see Bug 53130) */
- else if ((transfer->usage & PIPE_TRANSFER_DISCARD_RANGE) &&
- !(transfer->usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
+ else if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
+ !(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
rctx->screen->has_streamout &&
/* The buffer range must be aligned to 4. */
- transfer->box.x % 4 == 0 && transfer->box.width % 4 == 0) {
- assert(transfer->usage & PIPE_TRANSFER_WRITE);
+ box->x % 4 == 0 && box->width % 4 == 0) {
+ assert(usage & PIPE_TRANSFER_WRITE);
/* Check if mapping this buffer would cause waiting for the GPU. */
if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rbuffer->cs_buf, RADEON_USAGE_READWRITE) ||
rctx->ws->buffer_is_busy(rbuffer->buf, RADEON_USAGE_READWRITE)) {
/* Do a wait-free write-only transfer using a temporary buffer. */
- struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
-
- rtransfer->staging = (struct r600_resource*)
- pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
- PIPE_USAGE_STAGING, transfer->box.width);
- return rctx->ws->buffer_map(rtransfer->staging->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+ struct r600_resource *staging = (struct r600_resource*)
+ pipe_buffer_create(ctx->screen, PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STAGING, box->width);
+ data = rctx->ws->buffer_map(staging->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+
+ if (!data)
+ return NULL;
+ return r600_buffer_get_transfer(ctx, resource, level, usage, box,
+ ptransfer, data, staging);
}
}
#endif
- data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, transfer->usage);
- if (!data)
+ data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, usage);
+ if (!data) {
return NULL;
+ }
+ data += box->x;
- return (uint8_t*)data + transfer->box.x;
+ return r600_buffer_get_transfer(ctx, resource, level, usage, box,
+ ptransfer, data, NULL);
}
static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct r600_context *rctx = (struct r600_context*)pipe;
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
if (rtransfer->staging) {
&rtransfer->staging->b.b, &box);
pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
}
-}
-
-static void r600_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
-{
- struct r600_context *rctx = (struct r600_context*)ctx;
util_slab_free(&rctx->pool_transfers, transfer);
}
{
u_default_resource_get_handle, /* get_handle */
r600_buffer_destroy, /* resource_destroy */
- r600_get_transfer, /* get_transfer */
- r600_transfer_destroy, /* transfer_destroy */
r600_buffer_transfer_map, /* transfer_map */
NULL, /* transfer_flush_region */
r600_buffer_transfer_unmap, /* transfer_unmap */
void r600_init_context_resource_functions(struct r600_context *r600)
{
- r600->context.get_transfer = u_get_transfer_vtbl;
r600->context.transfer_map = u_transfer_map_vtbl;
r600->context.transfer_flush_region = u_default_transfer_flush_region;
r600->context.transfer_unmap = u_transfer_unmap_vtbl;
- r600->context.transfer_destroy = u_transfer_destroy_vtbl;
r600->context.transfer_inline_write = u_default_transfer_inline_write;
}
struct pipe_resource *texture,
struct r600_texture **staging);
-/* r600_texture.c texture transfer functions. */
-struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
- struct pipe_resource *texture,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box);
-void r600_texture_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *trans);
-void* r600_texture_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer* transfer);
-void r600_texture_transfer_unmap(struct pipe_context *ctx,
- struct pipe_transfer* transfer);
-
#endif
FREE(rtex);
}
-static const struct u_resource_vtbl r600_texture_vtbl =
-{
- r600_texture_get_handle, /* get_handle */
- r600_texture_destroy, /* resource_destroy */
- r600_texture_get_transfer, /* get_transfer */
- r600_texture_transfer_destroy, /* transfer_destroy */
- r600_texture_transfer_map, /* transfer_map */
- NULL, /* transfer_flush_region */
- r600_texture_transfer_unmap, /* transfer_unmap */
- NULL /* transfer_inline_write */
-};
+static const struct u_resource_vtbl r600_texture_vtbl;
/* The number of samples can be specified independently of the texture. */
void r600_texture_get_fmask_info(struct r600_screen *rscreen,
return true;
}
-struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
- struct pipe_resource *texture,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *r600_texture_transfer_map(struct pipe_context *ctx,
+ struct pipe_resource *texture,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct r600_context *rctx = (struct r600_context*)ctx;
struct r600_texture *rtex = (struct r600_texture*)texture;
struct pipe_resource resource;
struct r600_transfer *trans;
boolean use_staging_texture = FALSE;
+ enum pipe_format format = texture->format;
+ struct radeon_winsys_cs_handle *buf;
+ unsigned offset = 0;
+ char *map;
+
+ if ((texture->bind & PIPE_BIND_GLOBAL) && texture->target == PIPE_BUFFER) {
+ return r600_compute_global_transfer_map(ctx, texture, level, usage, box, ptransfer);
+ }
/* We cannot map a tiled texture directly because the data is
* in a different order, therefore we do detiling using a blit.
trans = CALLOC_STRUCT(r600_transfer);
if (trans == NULL)
return NULL;
- pipe_resource_reference(&trans->transfer.resource, texture);
+ trans->transfer.resource = texture;
trans->transfer.level = level;
trans->transfer.usage = usage;
trans->transfer.box = *box;
if (!r600_init_flushed_depth_texture(ctx, texture, &staging_depth)) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- pipe_resource_reference(&trans->transfer.resource, NULL);
FREE(trans);
return NULL;
}
trans->transfer.stride = staging_depth->surface.level[level].pitch_bytes;
trans->offset = r600_texture_get_offset(staging_depth, level, box->z);
trans->staging = (struct r600_resource*)staging_depth;
- return &trans->transfer;
} else if (use_staging_texture) {
resource.target = PIPE_TEXTURE_2D;
resource.format = texture->format;
trans->staging = (struct r600_resource*)ctx->screen->resource_create(ctx->screen, &resource);
if (trans->staging == NULL) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- pipe_resource_reference(&trans->transfer.resource, NULL);
FREE(trans);
return NULL;
}
/* Always referenced in the blit. */
r600_flush(ctx, NULL, 0);
}
- return &trans->transfer;
- }
- trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
- trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
- trans->offset = r600_texture_get_offset(rtex, level, box->z);
- return &trans->transfer;
-}
-
-void r600_texture_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
-{
- struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
- struct pipe_resource *texture = transfer->resource;
- struct r600_texture *rtex = (struct r600_texture*)texture;
-
- if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
- if (rtex->is_depth) {
- ctx->resource_copy_region(ctx, texture, transfer->level,
- transfer->box.x, transfer->box.y, transfer->box.z,
- &rtransfer->staging->b.b, transfer->level,
- &transfer->box);
- } else {
- r600_copy_from_staging_texture(ctx, rtransfer);
- }
- }
-
- if (rtransfer->staging)
- pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
-
- pipe_resource_reference(&transfer->resource, NULL);
- FREE(transfer);
-}
-
-void* r600_texture_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer* transfer)
-{
- struct r600_context *rctx = (struct r600_context *)ctx;
- struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
- struct radeon_winsys_cs_handle *buf;
- struct r600_texture *rtex =
- (struct r600_texture*)transfer->resource;
- enum pipe_format format = transfer->resource->format;
- unsigned offset = 0;
- char *map;
-
- if ((transfer->resource->bind & PIPE_BIND_GLOBAL) && transfer->resource->target == PIPE_BUFFER) {
- return r600_compute_global_transfer_map(ctx, transfer);
+ } else {
+ trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
+ trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
+ trans->offset = r600_texture_get_offset(rtex, level, box->z);
}
- if (rtransfer->staging) {
- buf = ((struct r600_resource *)rtransfer->staging)->cs_buf;
+ if (trans->staging) {
+ buf = ((struct r600_resource *)trans->staging)->cs_buf;
} else {
- buf = ((struct r600_resource *)transfer->resource)->cs_buf;
+ buf = ((struct r600_resource *)texture)->cs_buf;
}
- if (rtex->is_depth || !rtransfer->staging)
- offset = rtransfer->offset +
- transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
- transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ if (rtex->is_depth || !trans->staging)
+ offset = trans->offset +
+ box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
- if (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
+ if (!(map = rctx->ws->buffer_map(buf, rctx->cs, usage))) {
+ pipe_resource_reference((struct pipe_resource**)&trans->staging, NULL);
+ FREE(trans);
return NULL;
}
+ *ptransfer = &trans->transfer;
return map + offset;
}
-void r600_texture_transfer_unmap(struct pipe_context *ctx,
- struct pipe_transfer* transfer)
+static void r600_texture_transfer_unmap(struct pipe_context *ctx,
+ struct pipe_transfer* transfer)
{
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
struct r600_context *rctx = (struct r600_context*)ctx;
struct radeon_winsys_cs_handle *buf;
+ struct pipe_resource *texture = transfer->resource;
+ struct r600_texture *rtex = (struct r600_texture*)texture;
if ((transfer->resource->bind & PIPE_BIND_GLOBAL) && transfer->resource->target == PIPE_BUFFER) {
return r600_compute_global_transfer_unmap(ctx, transfer);
buf = ((struct r600_resource *)transfer->resource)->cs_buf;
}
rctx->ws->buffer_unmap(buf);
+
+ if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
+ if (rtex->is_depth) {
+ ctx->resource_copy_region(ctx, texture, transfer->level,
+ transfer->box.x, transfer->box.y, transfer->box.z,
+ &rtransfer->staging->b.b, transfer->level,
+ &transfer->box);
+ } else {
+ r600_copy_from_staging_texture(ctx, rtransfer);
+ }
+ }
+
+ if (rtransfer->staging)
+ pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
+
+ FREE(transfer);
}
void r600_init_surface_functions(struct r600_context *r600)
/* R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format)); */
return ~0;
}
+
+static const struct u_resource_vtbl r600_texture_vtbl =
+{
+ r600_texture_get_handle, /* get_handle */
+ r600_texture_destroy, /* resource_destroy */
+ r600_texture_transfer_map, /* transfer_map */
+ NULL, /* transfer_flush_region */
+ r600_texture_transfer_unmap, /* transfer_unmap */
+ NULL /* transfer_inline_write */
+};
FREE(rbuffer);
}
-static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *r600_buffer_transfer_map(struct pipe_context *ctx,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct r600_context *rctx = (struct r600_context*)ctx;
- struct pipe_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+ struct pipe_transfer *transfer;
+ struct si_resource *rbuffer = si_resource(resource);
+ uint8_t *data;
+ data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, usage);
+ if (!data) {
+ return NULL;
+ }
+
+ transfer = util_slab_alloc(&rctx->pool_transfers);
transfer->resource = resource;
transfer->level = level;
transfer->usage = usage;
transfer->stride = 0;
transfer->layer_stride = 0;
transfer->data = NULL;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
-}
-
-static void *r600_buffer_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct si_resource *rbuffer = si_resource(transfer->resource);
- struct r600_context *rctx = (struct r600_context*)pipe;
- uint8_t *data;
-
- data = rctx->ws->buffer_map(rbuffer->cs_buf, rctx->cs, transfer->usage);
- if (!data)
- return NULL;
+ *ptransfer = transfer;
return (uint8_t*)data + transfer->box.x;
}
-static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
+static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
- /* no-op */
+ struct r600_context *rctx = (struct r600_context*)ctx;
+ util_slab_free(&rctx->pool_transfers, transfer);
}
static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
{
}
-static void r600_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
-{
- struct r600_context *rctx = (struct r600_context*)ctx;
- util_slab_free(&rctx->pool_transfers, transfer);
-}
-
static const struct u_resource_vtbl r600_buffer_vtbl =
{
u_default_resource_get_handle, /* get_handle */
r600_buffer_destroy, /* resource_destroy */
- r600_get_transfer, /* get_transfer */
- r600_transfer_destroy, /* transfer_destroy */
r600_buffer_transfer_map, /* transfer_map */
r600_buffer_transfer_flush_region, /* transfer_flush_region */
r600_buffer_transfer_unmap, /* transfer_unmap */
void r600_init_context_resource_functions(struct r600_context *r600)
{
- r600->context.get_transfer = u_get_transfer_vtbl;
r600->context.transfer_map = u_transfer_map_vtbl;
r600->context.transfer_flush_region = u_transfer_flush_region_vtbl;
r600->context.transfer_unmap = u_transfer_unmap_vtbl;
- r600->context.transfer_destroy = u_transfer_destroy_vtbl;
r600->context.transfer_inline_write = u_default_transfer_inline_write;
}
FREE(rtex);
}
-static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
- struct pipe_resource *texture,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *si_texture_transfer_map(struct pipe_context *ctx,
+ struct pipe_resource *texture,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
+ struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
struct pipe_resource resource;
struct r600_transfer *trans;
int r;
boolean use_staging_texture = FALSE;
+ struct radeon_winsys_cs_handle *buf;
+ enum pipe_format format = texture->format;
+ unsigned offset = 0;
+ char *map;
/* We cannot map a tiled texture directly because the data is
* in a different order, therefore we do detiling using a blit.
}
trans->transfer.stride = rtex->flushed_depth_texture->surface.level[level].pitch_bytes;
trans->offset = r600_texture_get_offset(rtex->flushed_depth_texture, level, box->z);
- return &trans->transfer;
} else if (use_staging_texture) {
resource.target = PIPE_TEXTURE_2D;
resource.format = texture->format;
/* Always referenced in the blit. */
radeonsi_flush(ctx, NULL, 0);
}
- return &trans->transfer;
- }
- trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
- trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
- trans->offset = r600_texture_get_offset(rtex, level, box->z);
- return &trans->transfer;
-}
-
-static void si_texture_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
-{
- struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
- struct pipe_resource *texture = transfer->resource;
- struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
-
- if (rtransfer->staging_texture) {
- if (transfer->usage & PIPE_TRANSFER_WRITE) {
- r600_copy_from_staging_texture(ctx, rtransfer);
- }
- pipe_resource_reference(&rtransfer->staging_texture, NULL);
- }
-
- if (rtex->depth && !rtex->is_flushing_texture) {
- if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture)
- r600_blit_push_depth(ctx, rtex);
+ } else {
+ trans->transfer.stride = rtex->surface.level[level].pitch_bytes;
+ trans->transfer.layer_stride = rtex->surface.level[level].slice_size;
+ trans->offset = r600_texture_get_offset(rtex, level, box->z);
}
- pipe_resource_reference(&transfer->resource, NULL);
- FREE(transfer);
-}
-
-static void* si_texture_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer* transfer)
-{
- struct r600_context *rctx = (struct r600_context *)ctx;
- struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
- struct radeon_winsys_cs_handle *buf;
- enum pipe_format format = transfer->resource->format;
- unsigned offset = 0;
- char *map;
-
- if (rtransfer->staging_texture) {
- buf = si_resource(rtransfer->staging_texture)->cs_buf;
+ if (trans->staging_texture) {
+ buf = si_resource(trans->staging_texture)->cs_buf;
} else {
- struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
+ struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
if (rtex->flushed_depth_texture)
buf = rtex->flushed_depth_texture->resource.cs_buf;
else
- buf = si_resource(transfer->resource)->cs_buf;
+ buf = si_resource(texture)->cs_buf;
- offset = rtransfer->offset +
- transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
- transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ offset = trans->offset +
+ box->y / util_format_get_blockheight(format) * trans->transfer.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
- if (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
+ if (!(map = rctx->ws->buffer_map(buf, rctx->cs, usage))) {
+ pipe_resource_reference(&trans->staging_texture, NULL);
+ pipe_resource_reference(&trans->transfer.resource, NULL);
+ FREE(trans);
return NULL;
}
+ *ptransfer = &trans->transfer;
return map + offset;
}
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
struct r600_context *rctx = (struct r600_context*)ctx;
struct radeon_winsys_cs_handle *buf;
+ struct pipe_resource *texture = transfer->resource;
+ struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
if (rtransfer->staging_texture) {
buf = si_resource(rtransfer->staging_texture)->cs_buf;
}
}
rctx->ws->buffer_unmap(buf);
+
+ if (rtransfer->staging_texture) {
+ if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ r600_copy_from_staging_texture(ctx, rtransfer);
+ }
+ pipe_resource_reference(&rtransfer->staging_texture, NULL);
+ }
+
+ if (rtex->depth && !rtex->is_flushing_texture) {
+ if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtex->flushed_depth_texture)
+ r600_blit_push_depth(ctx, rtex);
+ }
+
+ pipe_resource_reference(&transfer->resource, NULL);
+ FREE(transfer);
}
static const struct u_resource_vtbl r600_texture_vtbl =
{
r600_texture_get_handle, /* get_handle */
r600_texture_destroy, /* resource_destroy */
- si_texture_get_transfer, /* get_transfer */
- si_texture_transfer_destroy, /* transfer_destroy */
si_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region,/* transfer_flush_region */
si_texture_transfer_unmap, /* transfer_unmap */
-static struct pipe_transfer *
-rbug_context_get_transfer(struct pipe_context *_context,
+static void *
+rbug_context_transfer_map(struct pipe_context *_context,
struct pipe_resource *_resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct rbug_context *rb_pipe = rbug_context(_context);
struct rbug_resource *rb_resource = rbug_resource(_resource);
struct pipe_context *context = rb_pipe->pipe;
struct pipe_resource *resource = rb_resource->resource;
struct pipe_transfer *result;
+ void *map;
pipe_mutex_lock(rb_pipe->call_mutex);
- result = context->get_transfer(context,
- resource,
- level,
- usage,
- box);
+ map = context->transfer_map(context,
+ resource,
+ level,
+ usage,
+ box, &result);
pipe_mutex_unlock(rb_pipe->call_mutex);
- if (result)
- return rbug_transfer_create(rb_pipe, rb_resource, result);
- return NULL;
+ *transfer = rbug_transfer_create(rb_pipe, rb_resource, result);
+ return *transfer ? map : NULL;
}
-static void
-rbug_context_transfer_destroy(struct pipe_context *_pipe,
- struct pipe_transfer *_transfer)
-{
- struct rbug_context *rb_pipe = rbug_context(_pipe);
- struct rbug_transfer *rb_transfer =rbug_transfer(_transfer);
-
- pipe_mutex_lock(rb_pipe->call_mutex);
- rbug_transfer_destroy(rb_pipe,
- rb_transfer);
- pipe_mutex_unlock(rb_pipe->call_mutex);
-}
-
-static void *
-rbug_context_transfer_map(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
-{
- struct rbug_context *rb_pipe = rbug_context(_context);
- struct rbug_transfer *rb_transfer = rbug_transfer(_transfer);
- struct pipe_context *context = rb_pipe->pipe;
- struct pipe_transfer *transfer = rb_transfer->transfer;
- void *ret;
-
- pipe_mutex_lock(rb_pipe->call_mutex);
- ret = context->transfer_map(context,
- transfer);
- pipe_mutex_unlock(rb_pipe->call_mutex);
-
- return ret;
-}
-
-
-
static void
rbug_context_transfer_flush_region(struct pipe_context *_context,
struct pipe_transfer *_transfer,
pipe_mutex_lock(rb_pipe->call_mutex);
context->transfer_unmap(context,
transfer);
+ rbug_transfer_destroy(rb_pipe,
+ rb_transfer);
pipe_mutex_unlock(rb_pipe->call_mutex);
}
rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy;
rb_pipe->base.create_surface = rbug_context_create_surface;
rb_pipe->base.surface_destroy = rbug_context_surface_destroy;
- rb_pipe->base.get_transfer = rbug_context_get_transfer;
- rb_pipe->base.transfer_destroy = rbug_context_transfer_destroy;
rb_pipe->base.transfer_map = rbug_context_transfer_map;
rb_pipe->base.transfer_unmap = rbug_context_transfer_unmap;
rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region;
}
tex = tr_tex->resource;
- t = pipe_get_transfer(context, tex,
- gptr->level, gptr->face + gptr->zslice,
- PIPE_TRANSFER_READ,
- gptr->x, gptr->y, gptr->w, gptr->h);
-
- map = context->transfer_map(context, t);
+ map = pipe_transfer_map(context, tex,
+ gptr->level, gptr->face + gptr->zslice,
+ PIPE_TRANSFER_READ,
+ gptr->x, gptr->y, gptr->w, gptr->h, &t);
rbug_send_texture_read_reply(tr_rbug->con, serial,
t->resource->format,
NULL);
context->transfer_unmap(context, t);
- context->transfer_destroy(context, t);
pipe_mutex_unlock(rb_screen->list_mutex);
return &rb_transfer->base;
error:
- rb_context->pipe->transfer_destroy(rb_context->pipe, transfer);
+ rb_context->pipe->transfer_unmap(rb_context->pipe, transfer);
return NULL;
}
struct rbug_transfer *rb_transfer)
{
pipe_resource_reference(&rb_transfer->base.resource, NULL);
- rb_transfer->pipe->transfer_destroy(rb_context->pipe,
- rb_transfer->transfer);
FREE(rb_transfer);
}
#include "sp_screen.h"
-/**
- * Map any drawing surfaces which aren't already mapped
- */
-void
-softpipe_map_transfers(struct softpipe_context *sp)
-{
- unsigned i;
-
- for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_map_transfers(sp->cbuf_cache[i]);
- }
-
- sp_tile_cache_map_transfers(sp->zsbuf_cache);
-}
-
-
-/**
- * Unmap any mapped drawing surfaces
- */
-void
-softpipe_unmap_transfers(struct softpipe_context *sp)
-{
- uint i;
-
- for (i = 0; i < sp->framebuffer.nr_cbufs; i++) {
- sp_tile_cache_unmap_transfers(sp->cbuf_cache[i]);
- }
-
- sp_tile_cache_unmap_transfers(sp->zsbuf_cache);
-}
-
-
static void
softpipe_destroy( struct pipe_context *pipe )
{
softpipe_update_derived(sp, sp->reduced_api_prim);
}
- softpipe_map_transfers(sp);
-
/* Map vertex buffers */
for (i = 0; i < sp->num_vertex_buffers; i++) {
const void *buf = sp->vertex_buffer[i].user_buffer;
softpipe->dirty_render_cache = FALSE;
- /* Need this call for hardware buffers before swapbuffers.
- *
- * there should probably be another/different flush-type function
- * that's called before swapbuffers because we don't always want
- * to unmap surfaces when flushing.
- */
- softpipe_unmap_transfers(softpipe);
-
/* Enable to dump BMPs of the color/depth buffers each frame */
#if 0
if(flags & PIPE_FLUSH_FRAME) {
softpipe_draw_vbo(struct pipe_context *pipe,
const struct pipe_draw_info *info);
-void
-softpipe_map_transfers(struct softpipe_context *sp);
-
-void
-softpipe_unmap_transfers(struct softpipe_context *sp);
-
void
softpipe_map_texture_surfaces(struct softpipe_context *sp);
/*assert(tc->entries[pos].x < 0);*/
}
if (tc->transfer) {
- tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
+ tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
}
if (tc->tex_trans) {
- tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+ tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
}
FREE( tc );
if (!sp_tex_tile_is_compat_view(tc, view)) {
pipe_resource_reference(&tc->texture, texture);
- if (tc->tex_trans) {
- if (tc->tex_trans_map) {
- tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
- tc->tex_trans_map = NULL;
- }
-
- tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+ if (tc->tex_trans_map) {
+ tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
tc->tex_trans = NULL;
+ tc->tex_trans_map = NULL;
}
if (view) {
/* get new transfer (view into texture) */
unsigned width, height, layer;
- if (tc->tex_trans) {
- if (tc->tex_trans_map) {
- tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
- tc->tex_trans_map = NULL;
- }
-
- tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
+ if (tc->tex_trans_map) {
+ tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans);
tc->tex_trans = NULL;
+ tc->tex_trans_map = NULL;
}
width = u_minify(tc->texture->width0, addr.bits.level);
layer = addr.bits.face + addr.bits.z;
}
- tc->tex_trans =
- pipe_get_transfer(tc->pipe, tc->texture,
+ tc->tex_trans_map =
+ pipe_transfer_map(tc->pipe, tc->texture,
addr.bits.level,
layer,
PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED,
- 0, 0, width, height);
-
- tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans);
+ 0, 0, width, height, &tc->tex_trans);
tc->tex_face = addr.bits.face;
tc->tex_level = addr.bits.level;
* the image format.
*/
if (!zs && util_format_is_pure_uint(tc->format)) {
- pipe_get_tile_ui_format(tc->pipe,
- tc->tex_trans,
+ pipe_get_tile_ui_format(tc->tex_trans, tc->tex_trans_map,
addr.bits.x * TILE_SIZE,
addr.bits.y * TILE_SIZE,
TILE_SIZE,
tc->format,
(unsigned *) tile->data.colorui);
} else if (!zs && util_format_is_pure_sint(tc->format)) {
- pipe_get_tile_i_format(tc->pipe,
- tc->tex_trans,
+ pipe_get_tile_i_format(tc->tex_trans, tc->tex_trans_map,
addr.bits.x * TILE_SIZE,
addr.bits.y * TILE_SIZE,
TILE_SIZE,
tc->format,
(int *) tile->data.colori);
} else {
- pipe_get_tile_rgba_format(tc->pipe,
- tc->tex_trans,
+ pipe_get_tile_rgba_format(tc->tex_trans, tc->tex_trans_map,
addr.bits.x * TILE_SIZE,
addr.bits.y * TILE_SIZE,
TILE_SIZE,
* \param usage bitmask of PIPE_TRANSFER_x flags
* \param box the 1D/2D/3D region of interest
*/
-static struct pipe_transfer *
-softpipe_get_transfer(struct pipe_context *pipe,
+static void *
+softpipe_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
+ struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
struct softpipe_resource *spr = softpipe_resource(resource);
struct softpipe_transfer *spt;
+ struct pipe_transfer *pt;
+ enum pipe_format format = resource->format;
+ const unsigned hgt = u_minify(spr->base.height0, level);
+ const unsigned nblocksy = util_format_get_nblocksy(format, hgt);
+ uint8_t *map;
assert(resource);
assert(level <= resource->last_level);
}
spt = CALLOC_STRUCT(softpipe_transfer);
- if (spt) {
- struct pipe_transfer *pt = &spt->base;
- enum pipe_format format = resource->format;
- const unsigned hgt = u_minify(spr->base.height0, level);
- const unsigned nblocksy = util_format_get_nblocksy(format, hgt);
-
- pipe_resource_reference(&pt->resource, resource);
- pt->level = level;
- pt->usage = usage;
- pt->box = *box;
- pt->stride = spr->stride[level];
- pt->layer_stride = pt->stride * nblocksy;
-
- spt->offset = sp_get_tex_image_offset(spr, level, box->z);
-
- spt->offset +=
- box->y / util_format_get_blockheight(format) * spt->base.stride +
- box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ if (!spt)
+ return NULL;
- return pt;
- }
- return NULL;
-}
+ pt = &spt->base;
+ pipe_resource_reference(&pt->resource, resource);
+ pt->level = level;
+ pt->usage = usage;
+ pt->box = *box;
+ pt->stride = spr->stride[level];
+ pt->layer_stride = pt->stride * nblocksy;
-/**
- * Free a pipe_transfer object which was created with
- * softpipe_get_transfer().
- */
-static void
-softpipe_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- pipe_resource_reference(&transfer->resource, NULL);
- FREE(transfer);
-}
+ spt->offset = sp_get_tex_image_offset(spr, level, box->z);
+ spt->offset +=
+ box->y / util_format_get_blockheight(format) * spt->base.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
-/**
- * Create memory mapping for given pipe_transfer object.
- */
-static void *
-softpipe_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct softpipe_transfer *spt = softpipe_transfer(transfer);
- struct softpipe_resource *spr = softpipe_resource(transfer->resource);
- struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
- uint8_t *map;
-
/* resources backed by display target treated specially:
*/
if (spr->dt) {
- map = winsys->displaytarget_map(winsys, spr->dt, transfer->usage);
+ map = winsys->displaytarget_map(winsys, spr->dt, usage);
}
else {
map = spr->data;
}
- if (map == NULL)
+ if (map == NULL) {
+ pipe_resource_reference(&pt->resource, NULL);
+ FREE(spt);
return NULL;
- else
- return map + spt->offset;
+ }
+
+ *transfer = pt;
+ return map + spt->offset;
}
/* Mark the texture as dirty to expire the tile caches. */
spr->timestamp++;
}
+
+ pipe_resource_reference(&transfer->resource, NULL);
+ FREE(transfer);
}
/**
void
softpipe_init_texture_funcs(struct pipe_context *pipe)
{
- pipe->get_transfer = softpipe_get_transfer;
- pipe->transfer_destroy = softpipe_transfer_destroy;
pipe->transfer_map = softpipe_transfer_map;
pipe->transfer_unmap = softpipe_transfer_unmap;
FREE( tc->tile );
if (tc->transfer) {
- tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
+ tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
}
FREE( tc );
{
struct pipe_context *pipe = tc->pipe;
- if (tc->transfer) {
+ if (tc->transfer_map) {
if (ps == tc->surface)
return;
- if (tc->transfer_map) {
- pipe->transfer_unmap(pipe, tc->transfer);
- tc->transfer_map = NULL;
- }
-
- pipe->transfer_destroy(pipe, tc->transfer);
+ pipe->transfer_unmap(pipe, tc->transfer);
tc->transfer = NULL;
+ tc->transfer_map = NULL;
}
tc->surface = ps;
if (ps) {
- tc->transfer = pipe_get_transfer(pipe, ps->texture,
- ps->u.tex.level, ps->u.tex.first_layer,
- PIPE_TRANSFER_READ_WRITE |
- PIPE_TRANSFER_UNSYNCHRONIZED,
- 0, 0, ps->width, ps->height);
+ tc->transfer_map = pipe_transfer_map(pipe, ps->texture,
+ ps->u.tex.level, ps->u.tex.first_layer,
+ PIPE_TRANSFER_READ_WRITE |
+ PIPE_TRANSFER_UNSYNCHRONIZED,
+ 0, 0, ps->width, ps->height,
+ &tc->transfer);
tc->depth_stencil = util_format_is_depth_or_stencil(ps->format);
}
}
-void
-sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc)
-{
- if (tc->transfer && !tc->transfer_map)
- tc->transfer_map = tc->pipe->transfer_map(tc->pipe, tc->transfer);
-}
-
-
-void
-sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc)
-{
- if (tc->transfer_map) {
- tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
- tc->transfer_map = NULL;
- }
-}
-
-
/**
* Set pixels in a tile to the given clear color/value, float.
*/
if (is_clear_flag_set(tc->clear_flags, addr)) {
/* write the scratch tile to the surface */
if (tc->depth_stencil) {
- pipe_put_tile_raw(tc->pipe,
- pt,
+ pipe_put_tile_raw(pt, tc->transfer_map,
x, y, TILE_SIZE, TILE_SIZE,
tc->tile->data.any, 0/*STRIDE*/);
}
else {
if (util_format_is_pure_uint(tc->surface->format)) {
- pipe_put_tile_ui_format(tc->pipe, pt,
+ pipe_put_tile_ui_format(pt, tc->transfer_map,
x, y, TILE_SIZE, TILE_SIZE,
pt->resource->format,
(unsigned *) tc->tile->data.colorui128);
} else if (util_format_is_pure_sint(tc->surface->format)) {
- pipe_put_tile_i_format(tc->pipe, pt,
+ pipe_put_tile_i_format(pt, tc->transfer_map,
x, y, TILE_SIZE, TILE_SIZE,
pt->resource->format,
(int *) tc->tile->data.colori128);
} else {
- pipe_put_tile_rgba(tc->pipe, pt,
+ pipe_put_tile_rgba(pt, tc->transfer_map,
x, y, TILE_SIZE, TILE_SIZE,
(float *) tc->tile->data.color);
}
{
if (!tc->tile_addrs[pos].bits.invalid) {
if (tc->depth_stencil) {
- pipe_put_tile_raw(tc->pipe, tc->transfer,
+ pipe_put_tile_raw(tc->transfer, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
}
else {
if (util_format_is_pure_uint(tc->surface->format)) {
- pipe_put_tile_ui_format(tc->pipe, tc->transfer,
+ pipe_put_tile_ui_format(tc->transfer, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(unsigned *) tc->entries[pos]->data.colorui128);
} else if (util_format_is_pure_sint(tc->surface->format)) {
- pipe_put_tile_i_format(tc->pipe, tc->transfer,
+ pipe_put_tile_i_format(tc->transfer, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(int *) tc->entries[pos]->data.colori128);
} else {
- pipe_put_tile_rgba_format(tc->pipe, tc->transfer,
+ pipe_put_tile_rgba_format(tc->transfer, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
if (tc->tile_addrs[pos].bits.invalid == 0) {
/* put dirty tile back in framebuffer */
if (tc->depth_stencil) {
- pipe_put_tile_raw(tc->pipe, pt,
+ pipe_put_tile_raw(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
}
else {
if (util_format_is_pure_uint(tc->surface->format)) {
- pipe_put_tile_ui_format(tc->pipe, pt,
+ pipe_put_tile_ui_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(unsigned *) tile->data.colorui128);
} else if (util_format_is_pure_sint(tc->surface->format)) {
- pipe_put_tile_i_format(tc->pipe, pt,
+ pipe_put_tile_i_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(int *) tile->data.colori128);
} else {
- pipe_put_tile_rgba_format(tc->pipe, pt,
+ pipe_put_tile_rgba_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
else {
/* get new tile data from transfer */
if (tc->depth_stencil) {
- pipe_get_tile_raw(tc->pipe, pt,
+ pipe_get_tile_raw(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
}
else {
if (util_format_is_pure_uint(tc->surface->format)) {
- pipe_get_tile_ui_format(tc->pipe, pt,
+ pipe_get_tile_ui_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(unsigned *) tile->data.colorui128);
} else if (util_format_is_pure_sint(tc->surface->format)) {
- pipe_get_tile_i_format(tc->pipe, pt,
+ pipe_get_tile_i_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
tc->surface->format,
(int *) tile->data.colori128);
} else {
- pipe_get_tile_rgba_format(tc->pipe, pt,
+ pipe_get_tile_rgba_format(pt, tc->transfer_map,
tc->tile_addrs[pos].bits.x * TILE_SIZE,
tc->tile_addrs[pos].bits.y * TILE_SIZE,
TILE_SIZE, TILE_SIZE,
extern struct pipe_surface *
sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
-extern void
-sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc);
-
extern void
sp_flush_tile_cache(struct softpipe_tile_cache *tc);
void
svga_init_resource_functions(struct svga_context *svga)
{
- svga->pipe.get_transfer = u_get_transfer_vtbl;
svga->pipe.transfer_map = u_transfer_map_vtbl;
svga->pipe.transfer_flush_region = u_transfer_flush_region_vtbl;
svga->pipe.transfer_unmap = u_transfer_unmap_vtbl;
- svga->pipe.transfer_destroy = u_transfer_destroy_vtbl;
svga->pipe.transfer_inline_write = u_transfer_inline_write_vtbl;
}
* the end result is exactly the same as if one DMA was used for every mapped
* range.
*/
-static struct pipe_transfer *
-svga_buffer_get_transfer(struct pipe_context *pipe,
+static void *
+svga_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct svga_context *svga = svga_context(pipe);
struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_buffer *sbuf = svga_buffer(resource);
struct pipe_transfer *transfer;
+ uint8_t *map;
transfer = CALLOC_STRUCT(pipe_transfer);
if (transfer == NULL) {
}
}
- return transfer;
-}
-
-
-/**
- * Map a range of a buffer.
- */
-static void *
-svga_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct svga_buffer *sbuf = svga_buffer(transfer->resource);
-
- uint8_t *map;
-
if (sbuf->swbuf) {
/* User/malloc buffer */
map = sbuf->swbuf;
if (map) {
++sbuf->map.count;
map += transfer->box.x;
+ *ptransfer = transfer;
}
return map;
}
pipe_mutex_unlock(ss->swc_mutex);
-}
-
-
-/**
- * Destroy transfer
- */
-static void
-svga_buffer_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
FREE(transfer);
}
{
u_default_resource_get_handle, /* get_handle */
svga_buffer_destroy, /* resource_destroy */
- svga_buffer_get_transfer, /* get_transfer */
- svga_buffer_transfer_destroy, /* transfer_destroy */
svga_buffer_transfer_map, /* transfer_map */
svga_buffer_transfer_flush_region, /* transfer_flush_region */
svga_buffer_transfer_unmap, /* transfer_unmap */
/* XXX: Still implementing this as if it was a screen function, but
* can now modify it to queue transfers on the context.
*/
-static struct pipe_transfer *
-svga_texture_get_transfer(struct pipe_context *pipe,
+static void *
+svga_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *texture,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct svga_context *svga = svga_context(pipe);
struct svga_screen *ss = svga_screen(pipe->screen);
if (!st)
return NULL;
- pipe_resource_reference(&st->base.resource, texture);
+ st->base.resource = texture;
st->base.level = level;
st->base.usage = usage;
st->base.box = *box;
svga_transfer_dma(svga, st, SVGA3D_READ_HOST_VRAM, flags);
}
- return &st->base;
+ if (st->swbuf) {
+ *ptransfer = &st->base;
+ return st->swbuf;
+ } else {
+ /* The wait for read transfers already happened when svga_transfer_dma
+ * was called. */
+ void *map = sws->buffer_map(sws, st->hwbuf, usage);
+ if (!map)
+ goto fail;
+
+ *ptransfer = &st->base;
+ return map;
+ }
+fail:
+ FREE(st->swbuf);
no_swbuf:
sws->buffer_destroy(sws, st->hwbuf);
no_hwbuf:
}
-/* XXX: Still implementing this as if it was a screen function, but
- * can now modify it to queue transfers on the context.
- */
-static void *
-svga_texture_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st = svga_transfer(transfer);
-
- if(st->swbuf)
- return st->swbuf;
- else
- /* The wait for read transfers already happened when svga_transfer_dma
- * was called. */
- return sws->buffer_map(sws, st->hwbuf, transfer->usage);
-}
-
-
/* XXX: Still implementing this as if it was a screen function, but
* can now modify it to queue transfers on the context.
*/
svga_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct svga_context *svga = svga_context(pipe);
struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st = svga_transfer(transfer);
-
+ struct svga_texture *tex = svga_texture(transfer->resource);
+
if(!st->swbuf)
sws->buffer_unmap(sws, st->hwbuf);
-}
-
-
-static void
-svga_texture_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct svga_context *svga = svga_context(pipe);
- struct svga_texture *tex = svga_texture(transfer->resource);
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st = svga_transfer(transfer);
if (st->base.usage & PIPE_TRANSFER_WRITE) {
SVGA3dSurfaceDMAFlags flags;
tex->defined[0][transfer->level] = TRUE;
}
- pipe_resource_reference(&st->base.resource, NULL);
FREE(st->swbuf);
sws->buffer_destroy(sws, st->hwbuf);
FREE(st);
{
svga_texture_get_handle, /* get_handle */
svga_texture_destroy, /* resource_destroy */
- svga_texture_get_transfer, /* get_transfer */
- svga_texture_transfer_destroy, /* transfer_destroy */
svga_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
svga_texture_transfer_unmap, /* transfer_unmap */
&svga_render->vbuf_transfer);
if (ptr)
return ptr + svga_render->vbuf_offset;
- else
+ else {
+ svga_render->vbuf_transfer = NULL;
return NULL;
+ }
}
else {
/* we probably ran out of memory when allocating the vertex buffer */
*/
-static struct pipe_transfer *
-trace_context_get_transfer(struct pipe_context *_context,
+static void *
+trace_context_transfer_map(struct pipe_context *_context,
struct pipe_resource *_resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct trace_context *tr_context = trace_context(_context);
struct trace_resource *tr_res = trace_resource(_resource);
struct pipe_context *context = tr_context->pipe;
struct pipe_resource *texture = tr_res->resource;
struct pipe_transfer *result = NULL;
+ void *map;
assert(texture->screen == context->screen);
* to transfer_inline_write and ignore read transfers.
*/
- result = context->get_transfer(context, texture, level, usage, box);
-
- if (result)
- result = trace_transfer_create(tr_context, tr_res, result);
-
- return result;
-}
-
-
-static void
-trace_context_transfer_destroy(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
-{
- struct trace_context *tr_context = trace_context(_context);
- struct trace_transfer *tr_trans = trace_transfer(_transfer);
-
- trace_transfer_destroy(tr_context, tr_trans);
-}
+ map = context->transfer_map(context, texture, level, usage, box, &result);
+ if (!map)
+ return NULL;
+ *transfer = trace_transfer_create(tr_context, tr_res, result);
-static void *
-trace_context_transfer_map(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
-{
- struct trace_context *tr_context = trace_context(_context);
- struct trace_transfer *tr_trans = trace_transfer(_transfer);
- struct pipe_context *context = tr_context->pipe;
- struct pipe_transfer *transfer = tr_trans->transfer;
- void *map;
-
- map = context->transfer_map(context, transfer);
- if(map) {
- if(transfer->usage & PIPE_TRANSFER_WRITE) {
- assert(!tr_trans->map);
- tr_trans->map = map;
+ if (map) {
+ if(usage & PIPE_TRANSFER_WRITE) {
+ trace_transfer(*transfer)->map = map;
}
}
- return map;
+ return *transfer ? map : NULL;
}
-
static void
trace_context_transfer_flush_region( struct pipe_context *_context,
struct pipe_transfer *_transfer,
}
context->transfer_unmap(context, transfer);
+ trace_transfer_destroy(tr_ctx, tr_trans);
}
TR_CTX_INIT(render_condition);
TR_CTX_INIT(texture_barrier);
- TR_CTX_INIT(get_transfer);
- TR_CTX_INIT(transfer_destroy);
TR_CTX_INIT(transfer_map);
TR_CTX_INIT(transfer_unmap);
TR_CTX_INIT(transfer_flush_region);
return &tr_trans->base;
error:
- tr_ctx->pipe->transfer_destroy(tr_ctx->pipe, transfer);
+ tr_ctx->pipe->transfer_unmap(tr_ctx->pipe, transfer);
return NULL;
}
trace_transfer_destroy(struct trace_context *tr_context,
struct trace_transfer *tr_trans)
{
- struct pipe_context *context = tr_context->pipe;
- struct pipe_transfer *transfer = tr_trans->transfer;
-
pipe_resource_reference(&tr_trans->base.resource, NULL);
- context->transfer_destroy(context, transfer);
FREE(tr_trans);
}
struct pipe_stencil_ref;
struct pipe_stream_output_target;
struct pipe_surface;
+struct pipe_transfer;
struct pipe_vertex_buffer;
struct pipe_vertex_element;
struct pipe_video_buffer;
struct pipe_surface *);
/**
- * Get a transfer object for transferring data to/from a texture.
+ * Map a resource.
*
* Transfers are (by default) context-private and allow uploads to be
- * interleaved with
+ * interleaved with rendering.
+ *
+ * out_transfer will contain the transfer object that must be passed
+ * to all the other transfer functions. It also contains useful
+ * information (like texture strides).
*/
- struct pipe_transfer *(*get_transfer)(struct pipe_context *,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage, /* a combination of PIPE_TRANSFER_x */
- const struct pipe_box *);
-
- void (*transfer_destroy)(struct pipe_context *,
- struct pipe_transfer *);
-
- void *(*transfer_map)( struct pipe_context *,
- struct pipe_transfer *transfer );
+ void *(*transfer_map)(struct pipe_context *,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage, /* a combination of PIPE_TRANSFER_x */
+ const struct pipe_box *,
+ struct pipe_transfer **out_transfer);
/* If transfer was created with WRITE|FLUSH_EXPLICIT, only the
* regions specified with this call are guaranteed to be written to
struct pipe_transfer *transfer,
const struct pipe_box *);
- void (*transfer_unmap)( struct pipe_context *,
- struct pipe_transfer *transfer );
-
+ void (*transfer_unmap)(struct pipe_context *,
+ struct pipe_transfer *transfer);
/* One-shot transfer operation with data supplied in a user
* pointer. XXX: strides??
PIPE_TRANSFER_READ = (1 << 0),
/**
- * Resource contents will be written back at transfer_destroy
+ * Resource contents will be written back at transfer_unmap
* time (or modified as a result of being accessed directly).
*/
PIPE_TRANSFER_WRITE = (1 << 1),
#define PIPE_BIND_INDEX_BUFFER (1 << 5) /* draw_elements */
#define PIPE_BIND_CONSTANT_BUFFER (1 << 6) /* set_constant_buffer */
#define PIPE_BIND_DISPLAY_TARGET (1 << 8) /* flush_front_buffer */
-#define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* get_transfer */
-#define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */
+#define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* transfer_map */
+#define PIPE_BIND_TRANSFER_READ (1 << 10) /* transfer_map */
#define PIPE_BIND_STREAM_OUTPUT (1 << 11) /* set_stream_output_buffers */
#define PIPE_BIND_CURSOR (1 << 16) /* mouse cursor */
#define PIPE_BIND_CUSTOM (1 << 17) /* state-tracker/winsys usages */
(flags & CL_MAP_READ ? PIPE_TRANSFER_READ : 0 ) |
(blocking ? PIPE_TRANSFER_UNSYNCHRONIZED : 0));
- pxfer = pctx->get_transfer(pctx, r.pipe, 0, usage,
- box(origin + r.offset, region));
- if (!pxfer)
- throw error(CL_OUT_OF_RESOURCES);
-
- p = pctx->transfer_map(pctx, pxfer);
+ p = pctx->transfer_map(pctx, r.pipe, 0, usage,
+ box(origin + r.offset, region), &pxfer);
if (!p) {
- pctx->transfer_destroy(pctx, pxfer);
+ pxfer = NULL;
throw error(CL_OUT_OF_RESOURCES);
}
}
mapping::~mapping() {
if (pxfer) {
pctx->transfer_unmap(pctx, pxfer);
- pctx->transfer_destroy(pctx, pxfer);
}
}
return E_INVALIDARG;
if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT)
usage |= PIPE_TRANSFER_DONTBLOCK;
- struct pipe_transfer* transfer = pipe->get_transfer(pipe, resource->resource, level, usage, &box);
- if(!transfer) {
+ struct pipe_transfer* transfer;
+ void *map = pipe->transfer_map(pipe, resource->resource, level, usage, &box, &transfer);
+ if(!map) {
if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT)
return DXGI_ERROR_WAS_STILL_DRAWING;
else
return E_FAIL;
}
resource->transfers[subresource] = transfer;
- mapped_resource->pData = pipe->transfer_map(pipe, transfer);
+ mapped_resource->pData = map;
mapped_resource->RowPitch = transfer->stride;
mapped_resource->DepthPitch = transfer->layer_stride;
return S_OK;
if(i != resource->transfers.end())
{
pipe->transfer_unmap(pipe, i->second);
- pipe->transfer_destroy(pipe, i->second);
resource->transfers.erase(i);
}
}
get_drawable_info(dPriv, &x, &y, &w, &h);
- transfer = pipe_get_transfer(pipe, res,
- 0, 0, // level, layer,
- PIPE_TRANSFER_WRITE,
- x, y, w, h);
- map = pipe_transfer_map(pipe, transfer);
+ map = pipe_transfer_map(pipe, res,
+ 0, 0, // level, layer,
+ PIPE_TRANSFER_WRITE,
+ x, y, w, h, &transfer);
/* Copy the Drawable content to the mapped texture buffer */
get_image(dPriv, x, y, w, h, map);
}
pipe_transfer_unmap(pipe, transfer);
- pipe_transfer_destroy(pipe, transfer);
}
/*
internal_format = choose_pixel_format(drawable->xm_visual);
- tex_xfer = pipe_get_transfer(pipe, res,
- 0, 0, /* level, layer */
- PIPE_TRANSFER_WRITE,
- x, y,
- w, h);
- if (!tex_xfer)
+ map = pipe_transfer_map(pipe, res,
+ 0, 0, /* level, layer */
+ PIPE_TRANSFER_WRITE,
+ x, y,
+ w, h, &tex_xfer);
+ if (!map)
return;
/* Grab the XImage that we want to turn into a texture. */
ZPixmap);
if (!img) {
- pipe_transfer_destroy(pipe, tex_xfer);
- return;
- }
-
- map = pipe_transfer_map(pipe, tex_xfer);
-
- if (!map) {
- pipe_transfer_destroy(pipe, tex_xfer);
+ pipe_transfer_unmap(pipe, tex_xfer);
return;
}
pipe_transfer_unmap(pipe, tex_xfer);
- pipe_transfer_destroy(pipe, tex_xfer);
-
st->teximage(st,
ST_TEXTURE_2D,
0, /* level */
res = vlsurface->sampler_view->texture;
box = RectToPipeBox(source_rect, res);
- transfer = pipe->get_transfer(pipe, res, 0, PIPE_TRANSFER_READ, &box);
- if (transfer == NULL) {
- pipe_mutex_unlock(vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- map = pipe_transfer_map(pipe, transfer);
- if (map == NULL) {
- pipe_transfer_destroy(pipe, transfer);
+ map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer);
+ if (!map) {
pipe_mutex_unlock(vlsurface->device->mutex);
return VDP_STATUS_RESOURCES;
}
box.width, box.height, map, transfer->stride, 0, 0);
pipe_transfer_unmap(pipe, transfer);
- pipe_transfer_destroy(pipe, transfer);
pipe_mutex_unlock(vlsurface->device->mutex);
return VDP_STATUS_OK;
struct pipe_transfer *transfer;
uint8_t *map;
- transfer = pipe->get_transfer(pipe, sv->texture, 0, PIPE_TRANSFER_READ, &box);
- if (transfer == NULL) {
- pipe_mutex_unlock(vlsurface->device->mutex);
- return VDP_STATUS_RESOURCES;
- }
-
- map = pipe_transfer_map(pipe, transfer);
- if (map == NULL) {
- pipe_transfer_destroy(pipe, transfer);
+ map = pipe->transfer_map(pipe, sv->texture, 0,
+ PIPE_TRANSFER_READ, &box, &transfer);
+ if (!map) {
pipe_mutex_unlock(vlsurface->device->mutex);
return VDP_STATUS_RESOURCES;
}
box.width, box.height, map, transfer->stride, 0, 0);
pipe_transfer_unmap(pipe, transfer);
- pipe_transfer_destroy(pipe, transfer);
}
}
pipe_mutex_unlock(vlsurface->device->mutex);
tex = screen->resource_create(screen, &templ);
{ /* upload color_data */
- struct pipe_transfer *transfer =
- pipe_get_transfer(pipe, tex,
+ struct pipe_transfer *transfer;
+ void *map =
+ pipe_transfer_map(pipe, tex,
0, 0,
PIPE_TRANSFER_READ_WRITE ,
- 0, 0, tex->width0, tex->height0);
- void *map = pipe->transfer_map(pipe, transfer);
+ 0, 0, tex->width0, tex->height0,
+ &transfer);
memcpy(map, color_data, sizeof(VGint)*color_data_len);
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
return tex;
{
VGint y = (stfb->height - sy) - 1, yStep = -1;
struct pipe_transfer *transfer;
+ void *map;
- transfer = pipe_get_transfer(pipe, strb->texture, 0, 0,
- PIPE_TRANSFER_READ,
- 0, 0, sx + width, stfb->height - sy);
+ map = pipe_transfer_map(pipe, strb->texture, 0, 0,
+ PIPE_TRANSFER_READ,
+ 0, 0, sx + width, stfb->height - sy,
+ &transfer);
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
#if 0
debug_printf("%d-%d == %d\n", sy, height, y);
#endif
- pipe_get_tile_rgba(pipe, transfer, sx, y, width, 1, df);
+ pipe_get_tile_rgba(transfer, map, sx, y, width, 1, df);
y += yStep;
_vega_pack_rgba_span_float(ctx, width, temp, dataFormat,
dst + yoffset + xoffset);
dst += dataStride;
}
- pipe->transfer_destroy(pipe, transfer);
+ pipe->transfer_unmap(pipe, transfer);
}
}
}
{ /* upload color_data */
- struct pipe_transfer *transfer = pipe_get_transfer(
- pipe, texture, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0);
+ struct pipe_transfer *transfer;
+ void *map = pipe_transfer_map(pipe, texture, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ texture->width0, texture->height0,
+ &transfer);
src += (dataStride * yoffset);
for (i = 0; i < height; i++) {
_vega_unpack_float_span_rgba(ctx, width, xoffset, src, dataFormat, temp);
- pipe_put_tile_rgba(pipe, transfer, x+image->x, y+image->y, width, 1, df);
+ pipe_put_tile_rgba(transfer, map, x+image->x, y+image->y, width, 1, df);
y += yStep;
src += dataStride;
}
- pipe->transfer_destroy(pipe, transfer);
+ pipe->transfer_unmap(pipe, transfer);
}
}
VGubyte *dst = (VGubyte *)data;
{
- struct pipe_transfer *transfer =
- pipe_get_transfer(pipe,
+ struct pipe_transfer *transfer;
+ void *map =
+ pipe_transfer_map(pipe,
image->sampler_view->texture, 0, 0,
PIPE_TRANSFER_READ,
0, 0,
image->x + image->width,
- image->y + image->height);
+ image->y + image->height, &transfer);
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
#if 0
debug_printf("%d-%d == %d\n", sy, height, y);
#endif
- pipe_get_tile_rgba(pipe, transfer, sx+image->x, y, width, 1, df);
+ pipe_get_tile_rgba(transfer, map, sx+image->x, y, width, 1, df);
y += yStep;
_vega_pack_rgba_span_float(ctx, width, temp, dataFormat, dst);
dst += dataStride;
}
- pipe->transfer_destroy(pipe, transfer);
+ pipe->transfer_unmap(pipe, transfer);
}
}
tex = screen->resource_create(screen, &templ);
{ /* upload color_data */
- struct pipe_transfer *transfer =
- pipe_get_transfer(p->base.ctx->pipe, tex, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, 1024, 1);
- void *map = pipe->transfer_map(pipe, transfer);
+ struct pipe_transfer *transfer;
+ void *map =
+ pipe_transfer_map(p->base.ctx->pipe, tex, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 1024, 1,
+ &transfer);
memcpy(map, p->gradient.color_data, sizeof(VGint)*1024);
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
return tex;
w = boxes->x2 - boxes->x1;
h = boxes->y2 - boxes->y1;
- transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
- transfer_direction, boxes->x1, boxes->y1,
- w, h);
- if (!transfer)
- return -XA_ERR_NORES;
-
- map = pipe_transfer_map(ctx->pipe, transfer);
+ map = pipe_transfer_map(pipe, srf->tex, 0, 0,
+ transfer_direction, boxes->x1, boxes->y1,
+ w, h, &transfer);
if (!map)
- goto out_no_map;
+ return -XA_ERR_NORES;
if (to_surface) {
util_copy_rect(map, srf->tex->format, transfer->stride,
0);
}
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
if (to_surface)
pipe->flush(pipe, &ctx->last_fence);
}
return XA_ERR_NONE;
- out_no_map:
- pipe->transfer_destroy(pipe, transfer);
- return -XA_ERR_NORES;
}
XA_EXPORT void *
if (!transfer_direction)
return NULL;
- srf->transfer = pipe_get_transfer(pipe, srf->tex, 0, 0,
- transfer_direction, 0, 0,
- srf->tex->width0, srf->tex->height0);
- if (!srf->transfer)
- return NULL;
-
- map = pipe_transfer_map(pipe, srf->transfer);
+ map = pipe_transfer_map(pipe, srf->tex, 0, 0,
+ transfer_direction, 0, 0,
+ srf->tex->width0, srf->tex->height0,
+ &srf->transfer);
if (!map)
- pipe->transfer_destroy(pipe, srf->transfer);
+ return NULL;
srf->mapping_pipe = pipe;
return map;
struct pipe_context *pipe = srf->mapping_pipe;
pipe->transfer_unmap(pipe, srf->transfer);
- pipe->transfer_destroy(pipe, srf->transfer);
srf->transfer = NULL;
}
}
crtcp->cursor_handle = whandle.handle;
}
- transfer = pipe_get_transfer(ctx, crtcp->cursor_tex,
- 0, 0,
- PIPE_TRANSFER_WRITE,
- 0, 0, 64, 64);
- ptr = ctx->transfer_map(ctx, transfer);
+ ptr = pipe_transfer_map(ctx, crtcp->cursor_tex,
+ 0, 0,
+ PIPE_TRANSFER_WRITE,
+ 0, 0, 64, 64, &transfer);
util_copy_rect(ptr, crtcp->cursor_tex->format,
transfer->stride, 0, 0,
64, 64, (void*)image, 64 * 4, 0, 0);
ctx->transfer_unmap(ctx, transfer);
- ctx->transfer_destroy(ctx, transfer);
ctx->flush(ctx, &fence);
if (fence) {
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
struct pipe_transfer *transfer;
+ void *map;
if (!priv || !priv->tex)
return FALSE;
- transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
- PIPE_TRANSFER_READ, x, y, w, h);
- if (!transfer)
+ map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
+ PIPE_TRANSFER_READ, x, y, w, h, &transfer);
+ if (!map)
return FALSE;
exa_debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
x, y, w, h, dst_pitch);
util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
- w, h, exa->pipe->transfer_map(exa->pipe, transfer),
- transfer->stride, 0, 0);
+ w, h, map, transfer->stride, 0, 0);
exa->pipe->transfer_unmap(exa->pipe, transfer);
- exa->pipe->transfer_destroy(exa->pipe, transfer);
return TRUE;
}
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
struct pipe_transfer *transfer;
+ void *map;
if (!priv || !priv->tex)
return FALSE;
- transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
- PIPE_TRANSFER_WRITE, x, y, w, h);
- if (!transfer)
+ map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
+ PIPE_TRANSFER_WRITE, x, y, w, h, &transfer);
+ if (!map)
return FALSE;
exa_debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
x, y, w, h, src_pitch);
- util_copy_rect(exa->pipe->transfer_map(exa->pipe, transfer),
+ util_copy_rect(map,
priv->tex->format, transfer->stride, 0, 0, w, h,
(unsigned char*)src, src_pitch, 0, 0);
exa->pipe->transfer_unmap(exa->pipe, transfer);
- exa->pipe->transfer_destroy(exa->pipe, transfer);
return TRUE;
}
assert(pPix->drawable.width <= priv->tex->width0);
assert(pPix->drawable.height <= priv->tex->height0);
- priv->map_transfer =
- pipe_get_transfer(exa->pipe, priv->tex, 0, 0,
+ pPix->devPrivate.ptr =
+ pipe_transfer_map(exa->pipe, priv->tex, 0, 0,
#ifdef EXA_MIXED_PIXMAPS
- PIPE_TRANSFER_MAP_DIRECTLY |
+ PIPE_TRANSFER_MAP_DIRECTLY |
#endif
- PIPE_TRANSFER_READ_WRITE,
- 0, 0,
- pPix->drawable.width,
- pPix->drawable.height );
- if (!priv->map_transfer)
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0,
+ pPix->drawable.width,
+ pPix->drawable.height,
+ &priv->map_transfer);
+ if (!pPix->devPrivate.ptr)
#ifdef EXA_MIXED_PIXMAPS
return FALSE;
#else
FatalError("failed to create transfer\n");
#endif
- pPix->devPrivate.ptr =
- exa->pipe->transfer_map(exa->pipe, priv->map_transfer);
pPix->devKind = priv->map_transfer->stride;
}
if (!priv)
return;
- if (!priv->map_transfer)
+ if (!priv->map_transfer || pPix->devPrivate.ptr == NULL)
return;
exa_debug_printf("ExaFinishAccess %d\n", index);
if (--priv->map_count == 0) {
assert(priv->map_transfer);
exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer);
- exa->pipe->transfer_destroy(exa->pipe, priv->map_transfer);
priv->map_transfer = NULL;
pPix->devPrivate.ptr = NULL;
}
int yidx, uidx, vidx;
int y_array_size = w * h;
- ytrans = pipe_get_transfer(pipe, dst[0],
- 0, 0,
- PIPE_TRANSFER_WRITE,
- left, top, w, h);
- utrans = pipe_get_transfer(pipe, dst[1],
- 0, 0,
- PIPE_TRANSFER_WRITE,
- left, top, w, h);
- vtrans = pipe_get_transfer(pipe, dst[2],
- 0, 0,
- PIPE_TRANSFER_WRITE,
- left, top, w, h);
-
- ymap = (char*)pipe->transfer_map(pipe, ytrans);
- umap = (char*)pipe->transfer_map(pipe, utrans);
- vmap = (char*)pipe->transfer_map(pipe, vtrans);
+ ymap = pipe_transfer_map(pipe, dst[0],
+ 0, 0,
+ PIPE_TRANSFER_WRITE,
+ left, top, w, h, &ytrans);
+ umap = pipe_transfer_map(pipe, dst[1],
+ 0, 0,
+ PIPE_TRANSFER_WRITE,
+ left, top, w, h, &utrans);
+ vmap = pipe_transfer_map(pipe, dst[2],
+ 0, 0,
+ PIPE_TRANSFER_WRITE,
+ left, top, w, h, &vtrans);
yidx = uidx = vidx = 0;
pipe->transfer_unmap(pipe, ytrans);
pipe->transfer_unmap(pipe, utrans);
pipe->transfer_unmap(pipe, vtrans);
- pipe->transfer_destroy(pipe, ytrans);
- pipe->transfer_destroy(pipe, utrans);
- pipe->transfer_destroy(pipe, vtrans);
}
struct pipe_transfer *transfer;
void *map;
- transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
- if (!transfer)
+ map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE,
+ dst_box, &transfer);
+ if (!map)
return;
- map = pipe->transfer_map(pipe, transfer);
- if (map) {
- util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
- dst_box->width, dst_box->height,
- src, src_stride, src_x, src_y);
+ util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
+ dst_box->width, dst_box->height,
+ src, src_stride, src_x, src_y);
- pipe->transfer_unmap(pipe, transfer);
- }
-
- pipe->transfer_destroy(pipe, transfer);
+ pipe->transfer_unmap(pipe, transfer);
}
PUBLIC
dst = subpicture_priv->sampler;
/* TODO: Assert clear rect is within bounds? Or clip? */
- transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
- if (!transfer)
+ map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE,
+ &dst_box, &transfer);
+ if (!map)
return XvMCBadSubpicture;
- map = pipe->transfer_map(pipe, transfer);
- if (map) {
- util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
- dst_box.width, dst_box.height, &uc);
-
- pipe->transfer_unmap(pipe, transfer);
- }
-
- pipe->transfer_destroy(pipe, transfer);
+ util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
+ dst_box.width, dst_box.height, &uc);
+ pipe->transfer_unmap(pipe, transfer);
return Success;
}
{
struct pipe_transfer *t;
uint32_t *ptr;
- t = pipe_get_transfer(ctx, samptex,
- 0, 0, /* level, layer */
- PIPE_TRANSFER_READ,
- 0, 0, SIZE, SIZE); /* x, y, width, height */
-
- ptr = ctx->transfer_map(ctx, t);
+ ptr = pipe_transfer_map(ctx, samptex,
+ 0, 0, /* level, layer */
+ PIPE_TRANSFER_READ,
+ 0, 0, SIZE, SIZE, &t); /* x, y, width, height */
if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
assert(0);
}
ctx->transfer_unmap(ctx, t);
-
- ctx->transfer_destroy(ctx, t);
}
memset(&sv_template, 0, sizeof sv_template);
{
struct pipe_transfer *t;
uint32_t *ptr;
- t = pipe_get_transfer(info->ctx, samptex,
+ t = pipe_transfer_map(info->ctx, samptex,
0, 0, /* level, layer */
PIPE_TRANSFER_READ,
0, 0, SIZE, SIZE); /* x, y, width, height */
{
struct pipe_transfer *t;
uint32_t *ptr;
- t = pipe_get_transfer(ctx, samptex,
- 0, 0, /* level, layer */
- PIPE_TRANSFER_READ,
- 0, 0, SIZE, SIZE); /* x, y, width, height */
-
- ptr = ctx->transfer_map(ctx, t);
+ ptr = pipe_transfer_map(ctx, samptex,
+ 0, 0, /* level, layer */
+ PIPE_TRANSFER_READ,
+ 0, 0, SIZE, SIZE, &t); /* x, y, width, height */
if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
assert(0);
}
ctx->transfer_unmap(ctx, t);
-
- ctx->transfer_destroy(ctx, t);
}
memset(&sv_template, 0, sizeof sv_template);
{
struct pipe_transfer *t;
uint32_t *ptr;
- t = pipe_get_transfer(ctx, samptex,
- 0, 0, /* level, layer */
- PIPE_TRANSFER_READ,
- 0, 0, SIZE, SIZE); /* x, y, width, height */
-
- ptr = ctx->transfer_map(ctx, t);
+ ptr = pipe_transfer_map(ctx, samptex,
+ 0, 0, /* level, layer */
+ PIPE_TRANSFER_READ,
+ 0, 0, SIZE, SIZE, &t); /* x, y, width, height */
if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
assert(0);
}
ctx->transfer_unmap(ctx, t);
-
- ctx->transfer_destroy(ctx, t);
}
memset(&sv_template, 0, sizeof sv_template);
{
struct pipe_transfer *t;
uint32_t *ptr;
- t = pipe_get_transfer(ctx, samptex,
- 0, 0, /* level, layer */
- PIPE_TRANSFER_READ,
- 0, 0, SIZE, SIZE); /* x, y, width, height */
-
- ptr = ctx->transfer_map(ctx, t);
+ ptr = pipe_transfer_map(ctx, samptex,
+ 0, 0, /* level, layer */
+ PIPE_TRANSFER_READ,
+ 0, 0, SIZE, SIZE, &t); /* x, y, width, height */
if (memcmp(ptr, tex2d, sizeof tex2d) != 0) {
assert(0);
}
ctx->transfer_unmap(ctx, t);
-
- ctx->transfer_destroy(ctx, t);
}
memset(&sv_template, 0, sizeof sv_template);
box.width = 2;
box.height = 2;
- t = p->pipe->get_transfer(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box);
-
- ptr = p->pipe->transfer_map(p->pipe, t);
+ ptr = p->pipe->transfer_map(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box, &t);
ptr[0] = 0xffff0000;
ptr[1] = 0xff0000ff;
ptr[2] = 0xff00ff00;
ptr[3] = 0xffffff00;
p->pipe->transfer_unmap(p->pipe, t);
- p->pipe->transfer_destroy(p->pipe, t);
-
u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format);
p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt);
struct pipe_context *pipe = wdt->winsys->pipe;
struct pipe_resource *tex = wdt->tex;
struct pipe_transfer *tr;
+ void *map;
- tr = pipe_get_transfer(pipe, tex, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->tex->width0, wdt->tex->height0);
- if (!tr)
+ map = pipe_transfer_map(pipe, tex, 0, 0,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, wdt->tex->width0, wdt->tex->height0, &tr);
+ if (!map)
return FALSE;
*stride = tr->stride;
wdt->stride = tr->stride;
- pipe->transfer_destroy(pipe, tr);
+ pipe->transfer_unmap(pipe, tr);
return TRUE;
}
assert(!wdt->transfer);
- tr = pipe_get_transfer(pipe, tex, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->tex->width0, wdt->tex->height0);
- if (!tr)
- return NULL;
-
- ptr = pipe->transfer_map(pipe, tr);
+ ptr = pipe_transfer_map(pipe, tex, 0, 0,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, wdt->tex->width0, wdt->tex->height0, &tr);
if (!ptr)
goto err;
return wdt->ptr;
err:
- pipe->transfer_destroy(pipe, tr);
+ pipe->transfer_unmap(pipe, tr);
return NULL;
}
return;
pipe->transfer_unmap(pipe, wdt->transfer);
- pipe->transfer_destroy(pipe, wdt->transfer);
pipe->flush(pipe, NULL);
wdt->transfer = NULL;
}
uint *dest;
uint i, j;
- transfer = pipe_get_transfer(pipe,
- pt, 0, 0, PIPE_TRANSFER_WRITE,
- 0, 0, texSize, texSize);
- dest = (uint *) pipe_transfer_map(pipe, transfer);
+ dest = (uint *) pipe_transfer_map(pipe,
+ pt, 0, 0, PIPE_TRANSFER_WRITE,
+ 0, 0, texSize, texSize, &transfer);
/* Pack four 1D maps into a 2D texture:
* R map is placed horizontally, indexed by S, in channel 0
}
pipe_transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
return NULL;
}
- transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
- PIPE_TRANSFER_WRITE,
- 0, 0, width, height);
-
- dest = pipe_transfer_map(pipe, transfer);
+ dest = pipe_transfer_map(st->pipe, pt, 0, 0,
+ PIPE_TRANSFER_WRITE,
+ 0, 0, width, height, &transfer);
/* Put image into texture transfer */
memset(dest, 0xff, height * transfer->stride);
/* Release transfer */
pipe_transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
-
return pt;
}
/* Map the texture transfer.
* Subsequent glBitmap calls will write into the texture image.
*/
- cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0,
- BITMAP_CACHE_WIDTH,
- BITMAP_CACHE_HEIGHT);
- cache->buffer = pipe_transfer_map(pipe, cache->trans);
+ cache->buffer = pipe_transfer_map(pipe, cache->texture, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ BITMAP_CACHE_WIDTH,
+ BITMAP_CACHE_HEIGHT, &cache->trans);
/* init image to all 0xff */
memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
/* The texture transfer has been mapped until now.
* So unmap and release the texture transfer before drawing.
*/
- if (cache->trans) {
+ if (cache->trans && cache->buffer) {
if (0)
print_cache(cache);
pipe_transfer_unmap(pipe, cache->trans);
cache->buffer = NULL;
-
- pipe->transfer_destroy(pipe, cache->trans);
cache->trans = NULL;
}
}
if (cache) {
- if (cache->trans) {
+ if (cache->trans && cache->buffer) {
pipe_transfer_unmap(pipe, cache->trans);
- pipe->transfer_destroy(pipe, cache->trans);
}
pipe_resource_reference(&st->bitmap.cache->texture, NULL);
free(st->bitmap.cache);
obj->Length = length;
obj->AccessFlags = access;
}
+ else {
+ st_obj->transfer = NULL;
+ }
return obj->Pointer;
}
/* we'll do pixel transfer in a fragment shader */
ctx->_ImageTransferState = 0x0;
- transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0,
- width, height);
-
/* map texture transfer */
- dest = pipe_transfer_map(pipe, transfer);
+ dest = pipe_transfer_map(pipe, pt, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ width, height, &transfer);
/* Put image into texture transfer.
/* unmap */
pipe_transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
assert(success);
usage = PIPE_TRANSFER_WRITE;
}
- pt = pipe_get_transfer(pipe, strb->texture,
- strb->rtt_level, strb->rtt_face + strb->rtt_slice,
- usage, x, y,
- width, height);
-
- stmap = pipe_transfer_map(pipe, pt);
+ stmap = pipe_transfer_map(pipe, strb->texture,
+ strb->rtt_level, strb->rtt_face + strb->rtt_slice,
+ usage, x, y,
+ width, height, &pt);
pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels);
assert(pixels);
/* unmap the stencil buffer */
pipe_transfer_unmap(pipe, pt);
- pipe->transfer_destroy(pipe, pt);
}
dsty = rbDraw->Base.Height - dsty - height;
}
- ptDraw = pipe_get_transfer(pipe,
- rbDraw->texture,
- rbDraw->rtt_level,
- rbDraw->rtt_face + rbDraw->rtt_slice,
- usage, dstx, dsty,
- width, height);
-
assert(util_format_get_blockwidth(ptDraw->resource->format) == 1);
assert(util_format_get_blockheight(ptDraw->resource->format) == 1);
/* map the stencil buffer */
- drawMap = pipe_transfer_map(pipe, ptDraw);
+ drawMap = pipe_transfer_map(pipe,
+ rbDraw->texture,
+ rbDraw->rtt_level,
+ rbDraw->rtt_face + rbDraw->rtt_slice,
+ usage, dstx, dsty,
+ width, height, &ptDraw);
/* draw */
/* XXX PixelZoom not handled yet */
/* unmap the stencil buffer */
pipe_transfer_unmap(pipe, ptDraw);
- pipe->transfer_destroy(pipe, ptDraw);
}
}
else {
/* CPU-based fallback/conversion */
- struct pipe_transfer *ptRead =
- pipe_get_transfer(st->pipe, rbRead->texture,
+ struct pipe_transfer *ptRead;
+ void *mapRead =
+ pipe_transfer_map(st->pipe, rbRead->texture,
rbRead->rtt_level,
rbRead->rtt_face + rbRead->rtt_slice,
PIPE_TRANSFER_READ,
- readX, readY, readW, readH);
+ readX, readY, readW, readH, &ptRead);
struct pipe_transfer *ptTex;
+ void *mapTex;
enum pipe_transfer_usage transfer_usage;
if (ST_DEBUG & DEBUG_FALLBACK)
else
transfer_usage = PIPE_TRANSFER_WRITE;
- ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, transfer_usage,
- 0, 0, width, height);
+ mapTex = pipe_transfer_map(st->pipe, pt, 0, 0, transfer_usage,
+ 0, 0, width, height, &ptTex);
/* copy image from ptRead surface to ptTex surface */
if (type == GL_COLOR) {
enum pipe_format readFormat, drawFormat;
readFormat = util_format_linear(rbRead->texture->format);
drawFormat = util_format_linear(pt->format);
- pipe_get_tile_rgba_format(pipe, ptRead, 0, 0, readW, readH,
+ pipe_get_tile_rgba_format(ptRead, mapRead, 0, 0, readW, readH,
readFormat, buf);
- pipe_put_tile_rgba_format(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+ pipe_put_tile_rgba_format(ptTex, mapTex, pack.SkipPixels,
+ pack.SkipRows,
readW, readH, drawFormat, buf);
free(buf);
}
else {
/* GL_DEPTH */
GLuint *buf = malloc(width * height * sizeof(GLuint));
- pipe_get_tile_z(pipe, ptRead, 0, 0, readW, readH, buf);
- pipe_put_tile_z(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
+ pipe_get_tile_z(ptRead, mapRead, 0, 0, readW, readH, buf);
+ pipe_put_tile_z(ptTex, mapTex, pack.SkipPixels, pack.SkipRows,
readW, readH, buf);
free(buf);
}
- pipe->transfer_destroy(pipe, ptRead);
- pipe->transfer_destroy(pipe, ptTex);
+ pipe->transfer_unmap(pipe, ptRead);
+ pipe->transfer_unmap(pipe, ptTex);
}
/* OK, the texture 'pt' contains the src image/pixels. Now draw a
const GLboolean invert = rb->Name == 0;
unsigned usage;
GLuint y2;
+ GLubyte *map;
if (strb->software) {
/* software-allocated renderbuffer (probably an accum buffer) */
else
y2 = y;
- strb->transfer = pipe_get_transfer(pipe,
- strb->texture,
- strb->rtt_level,
- strb->rtt_face + strb->rtt_slice,
- usage, x, y2, w, h);
- if (strb->transfer) {
- GLubyte *map = pipe_transfer_map(pipe, strb->transfer);
+ map = pipe_transfer_map(pipe,
+ strb->texture,
+ strb->rtt_level,
+ strb->rtt_face + strb->rtt_slice,
+ usage, x, y2, w, h, &strb->transfer);
+ if (map) {
if (invert) {
*rowStrideOut = -strb->transfer->stride;
map += (h - 1) * strb->transfer->stride;
}
pipe_transfer_unmap(pipe, strb->transfer);
- pipe->transfer_destroy(pipe, strb->transfer);
strb->transfer = NULL;
}
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
struct pipe_resource *dst_texture;
- struct pipe_transfer *tex_xfer;
struct pipe_blit_info blit;
unsigned bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_TRANSFER_READ);
+ struct pipe_transfer *tex_xfer;
+ ubyte *map;
/* create temp / dest surface */
if (!util_create_rgba_texture(pipe, width, height, bind,
/* blit/render/decompress */
st->pipe->blit(st->pipe, &blit);
- /* map the dst_surface so we can read from it */
- tex_xfer = pipe_get_transfer(pipe,
- dst_texture, 0, 0,
- PIPE_TRANSFER_READ,
- 0, 0, width, height);
-
pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels);
+ map = pipe_transfer_map(pipe, dst_texture, 0, 0,
+ PIPE_TRANSFER_READ,
+ 0, 0, width, height, &tex_xfer);
+ if (!map) {
+ goto end;
+ }
+
/* copy/pack data into user buffer */
if (_mesa_format_matches_format_and_type(stImage->base.TexFormat,
format, type,
ctx->Pack.SwapBytes)) {
/* memcpy */
const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
- ubyte *map = pipe_transfer_map(pipe, tex_xfer);
+ /* map the dst_surface so we can read from it */
GLuint row;
for (row = 0; row < height; row++) {
GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width,
debug_printf("%s: fallback format translation\n", __FUNCTION__);
/* get float[4] rgba row from surface */
- pipe_get_tile_rgba_format(pipe, tex_xfer, 0, row, width, 1,
+ pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1,
pformat, rgba);
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
}
end:
- _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
-
- pipe->transfer_destroy(pipe, tex_xfer);
+ if (map)
+ pipe_transfer_unmap(pipe, tex_xfer);
+ _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
pipe_resource_reference(&dst_texture, NULL);
}
struct pipe_transfer *src_trans;
GLvoid *texDest;
enum pipe_transfer_usage transfer_usage;
+ void *map;
if (ST_DEBUG & DEBUG_FALLBACK)
debug_printf("%s: fallback processing\n", __FUNCTION__);
srcY = strb->Base.Height - srcY - height;
}
- src_trans = pipe_get_transfer(pipe,
- strb->texture,
- strb->rtt_level,
- strb->rtt_face + strb->rtt_slice,
- PIPE_TRANSFER_READ,
- srcX, srcY,
- width, height);
+ map = pipe_transfer_map(pipe,
+ strb->texture,
+ strb->rtt_level,
+ strb->rtt_face + strb->rtt_slice,
+ PIPE_TRANSFER_READ,
+ srcX, srcY,
+ width, height, &src_trans);
if ((baseFormat == GL_DEPTH_COMPONENT ||
baseFormat == GL_DEPTH_STENCIL) &&
if (data) {
/* To avoid a large temp memory allocation, do copy row by row */
for (row = 0; row < height; row++, srcY += yStep) {
- pipe_get_tile_z(pipe, src_trans, 0, srcY, width, 1, data);
+ pipe_get_tile_z(src_trans, map, 0, srcY, width, 1, data);
if (scaleOrBias) {
_mesa_scale_and_bias_depth_uint(ctx, width, data);
}
- pipe_put_tile_z(pipe, stImage->transfer, 0, row, width, 1, data);
+ pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1,
+ data);
}
}
else {
/* XXX this usually involves a lot of int/float conversion.
* try to avoid that someday.
*/
- pipe_get_tile_rgba_format(pipe, src_trans, 0, 0, width, height,
+ pipe_get_tile_rgba_format(src_trans, map, 0, 0, width, height,
util_format_linear(strb->texture->format),
tempSrc);
}
st_texture_image_unmap(st, stImage);
- pipe->transfer_destroy(pipe, src_trans);
+ pipe->transfer_unmap(pipe, src_trans);
}
{
struct st_texture_object *stObj =
st_texture_object(stImage->base.TexObject);
- struct pipe_context *pipe = st->pipe;
GLuint level;
DBG("%s \n", __FUNCTION__);
else
level = stImage->base.Level;
- stImage->transfer = pipe_get_transfer(st->pipe, stImage->pt, level,
- stImage->base.Face + zoffset,
- usage, x, y, w, h);
-
- if (stImage->transfer)
- return pipe_transfer_map(pipe, stImage->transfer);
- else
- return NULL;
+ return pipe_transfer_map(st->pipe, stImage->pt, level,
+ stImage->base.Face + zoffset,
+ usage, x, y, w, h, &stImage->transfer);
}
DBG("%s\n", __FUNCTION__);
pipe_transfer_unmap(pipe, stImage->transfer);
-
- pipe->transfer_destroy(pipe, stImage->transfer);
stImage->transfer = NULL;
}
region.height = 1;
region.depth = 1;
- xfer = pipe->get_transfer(pipe, src, 0, PIPE_TRANSFER_READ, ®ion);
- map = pipe->transfer_map(pipe, xfer);
+ map = pipe->transfer_map(pipe, src, 0, PIPE_TRANSFER_READ, ®ion, &xfer);
printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]);
pipe->transfer_unmap(pipe, xfer);
- pipe->transfer_destroy(pipe, xfer);
}