gallium: unify transfer functions
"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 commit is contained in:
parent
ec4c74a9dc
commit
369e468889
|
@ -451,13 +451,12 @@ aaline_create_texture(struct aaline_stage *aaline)
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -482,7 +481,6 @@ aaline_create_texture(struct aaline_stage *aaline)
|
|||
|
||||
/* unmap */
|
||||
pipe->transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -396,9 +396,8 @@ pstip_update_texture(struct pstip_stage *pstip)
|
|||
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.
|
||||
|
@ -421,7 +420,6 @@ pstip_update_texture(struct pstip_stage *pstip)
|
|||
|
||||
/* unmap */
|
||||
pipe->transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -516,14 +516,12 @@ void debug_dump_surface(struct pipe_context *pipe,
|
|||
*/
|
||||
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,
|
||||
|
@ -534,8 +532,6 @@ void debug_dump_surface(struct pipe_context *pipe,
|
|||
data);
|
||||
|
||||
pipe->transfer_unmap(pipe, transfer);
|
||||
error:
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -597,20 +593,21 @@ debug_dump_surface_bmp(struct pipe_context *pipe,
|
|||
{
|
||||
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;
|
||||
|
||||
|
@ -624,7 +621,7 @@ debug_dump_transfer_bmp(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ void debug_dump_surface_bmp(struct pipe_context *pipe,
|
|||
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);
|
||||
|
@ -441,7 +441,7 @@ void debug_dump_float_rgba_bmp(const char *filename,
|
|||
#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
|
||||
|
||||
|
|
|
@ -1111,17 +1111,14 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
|
|||
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,
|
||||
|
@ -1129,9 +1126,6 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
|
|||
|
||||
pipe->transfer_unmap(pipe, srcTrans);
|
||||
pipe->transfer_unmap(pipe, dstTrans);
|
||||
|
||||
pipe->transfer_destroy(pipe, srcTrans);
|
||||
pipe->transfer_destroy(pipe, dstTrans);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,17 +1146,14 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
|
|||
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,
|
||||
|
@ -1172,9 +1163,6 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
|
|||
|
||||
pipe->transfer_unmap(pipe, srcTrans);
|
||||
pipe->transfer_unmap(pipe, dstTrans);
|
||||
|
||||
pipe->transfer_destroy(pipe, srcTrans);
|
||||
pipe->transfer_destroy(pipe, dstTrans);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1207,15 +1195,12 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
|
|||
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,
|
||||
|
@ -1225,9 +1210,6 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
|
|||
|
||||
pipe->transfer_unmap(pipe, srcTrans);
|
||||
pipe->transfer_unmap(pipe, dstTrans);
|
||||
|
||||
pipe->transfer_destroy(pipe, srcTrans);
|
||||
pipe->transfer_destroy(pipe, dstTrans);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -251,19 +251,8 @@ pipe_buffer_map_range(struct pipe_context *pipe,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -285,10 +274,7 @@ static INLINE void
|
|||
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
|
||||
|
@ -397,35 +383,29 @@ pipe_buffer_read(struct pipe_context *pipe,
|
|||
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)
|
||||
static INLINE void *
|
||||
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)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
return context->transfer_map( context, transfer );
|
||||
u_box_2d_zslice(x, y, layer, w, h, &box);
|
||||
return context->transfer_map(context,
|
||||
resource,
|
||||
level,
|
||||
usage,
|
||||
&box, transfer);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
|
@ -435,14 +415,6 @@ pipe_transfer_unmap( struct pipe_context *context,
|
|||
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)
|
||||
|
|
|
@ -69,9 +69,8 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe,
|
|||
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.
|
||||
|
@ -94,7 +93,6 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe,
|
|||
|
||||
/* unmap */
|
||||
pipe->transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,28 +24,16 @@ void u_resource_destroy_vtbl(struct pipe_screen *screen,
|
|||
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,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* 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
|
||||
*/
|
||||
|
|
|
@ -145,27 +145,23 @@ util_resource_copy_region(struct pipe_context *pipe,
|
|||
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);
|
||||
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_trans = pipe_get_transfer(pipe,
|
||||
dst,
|
||||
dst_level,
|
||||
dst_z,
|
||||
PIPE_TRANSFER_WRITE,
|
||||
dst_x, dst_y, w, h);
|
||||
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);
|
||||
|
||||
|
@ -187,9 +183,6 @@ util_resource_copy_region(struct pipe_context *pipe,
|
|||
|
||||
pipe->transfer_unmap(pipe, src_trans);
|
||||
pipe->transfer_unmap(pipe, dst_trans);
|
||||
|
||||
pipe->transfer_destroy(pipe, src_trans);
|
||||
pipe->transfer_destroy(pipe, dst_trans);
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,14 +212,12 @@ util_clear_render_target(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
|
@ -237,10 +228,9 @@ util_clear_render_target(struct pipe_context *pipe,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,16 +260,13 @@ util_clear_depth_stencil(struct pipe_context *pipe,
|
|||
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) {
|
||||
|
@ -376,8 +363,7 @@ util_clear_depth_stencil(struct pipe_context *pipe,
|
|||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pipe->transfer_unmap(pipe, dst_trans);
|
||||
pipe->transfer_destroy(pipe, dst_trans);
|
||||
pipe->transfer_unmap(pipe, dst_trans);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,27 +45,18 @@
|
|||
* 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,12 +64,11 @@ pipe_get_tile_raw(struct pipe_context *pipe,
|
|||
* 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)
|
||||
|
@ -87,14 +77,7 @@ pipe_put_tile_raw(struct pipe_context *pipe,
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,7 +355,7 @@ x32_s8_get_tile_rgba(const unsigned *src,
|
|||
|
||||
void
|
||||
pipe_tile_raw_to_rgba(enum pipe_format format,
|
||||
void *src,
|
||||
const void *src,
|
||||
uint w, uint h,
|
||||
float *dst, unsigned dst_stride)
|
||||
{
|
||||
|
@ -419,7 +402,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
|
|||
|
||||
void
|
||||
pipe_tile_raw_to_unsigned(enum pipe_format format,
|
||||
void *src,
|
||||
const void *src,
|
||||
uint w, uint h,
|
||||
unsigned *dst, unsigned dst_stride)
|
||||
{
|
||||
|
@ -442,18 +425,18 @@ pipe_tile_raw_to_signed(enum pipe_format format,
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -474,7 +457,7 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
|
@ -483,18 +466,18 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe,
|
|||
|
||||
|
||||
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)
|
||||
|
@ -538,14 +521,14 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe,
|
|||
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)
|
||||
|
@ -566,14 +549,14 @@ pipe_put_tile_i_format(struct pipe_context *pipe,
|
|||
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)
|
||||
|
@ -594,7 +577,7 @@ pipe_put_tile_ui_format(struct pipe_context *pipe,
|
|||
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);
|
||||
}
|
||||
|
@ -603,13 +586,13 @@ pipe_put_tile_ui_format(struct pipe_context *pipe,
|
|||
* 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;
|
||||
|
@ -617,12 +600,6 @@ pipe_get_tile_z(struct pipe_context *pipe,
|
|||
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:
|
||||
{
|
||||
|
@ -704,32 +681,24 @@ pipe_get_tile_z(struct pipe_context *pipe,
|
|||
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:
|
||||
{
|
||||
|
@ -825,14 +794,12 @@ pipe_put_tile_z(struct pipe_context *pipe,
|
|||
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)
|
||||
|
@ -853,7 +820,7 @@ pipe_get_tile_ui_format(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
|
@ -862,8 +829,8 @@ pipe_get_tile_ui_format(struct pipe_context *pipe,
|
|||
|
||||
|
||||
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)
|
||||
|
@ -884,7 +851,7 @@ pipe_get_tile_i_format(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
|
|
|
@ -61,66 +61,66 @@ extern "C" {
|
|||
#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);
|
||||
|
||||
|
@ -131,29 +131,29 @@ pipe_tile_raw_to_signed(enum pipe_format format,
|
|||
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);
|
||||
|
|
|
@ -31,17 +31,13 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
|
|||
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);
|
||||
|
@ -68,12 +64,7 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (map)
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
|
||||
if (transfer)
|
||||
pipe_transfer_destroy(pipe, transfer);
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,34 +85,7 @@ void u_default_transfer_flush_region( struct pipe_context *pipe,
|
|||
*/
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -27,18 +27,9 @@ void u_default_transfer_flush_region( struct pipe_context *pipe,
|
|||
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
|
||||
|
@ -53,24 +44,20 @@ struct u_resource_vtbl {
|
|||
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,
|
||||
|
@ -96,17 +83,12 @@ boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
|
|||
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,
|
||||
|
|
|
@ -82,7 +82,6 @@ void u_upload_unmap( struct u_upload_mgr *upload )
|
|||
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;
|
||||
}
|
||||
|
@ -142,13 +141,13 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
|
|||
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;
|
||||
}
|
||||
|
@ -185,6 +184,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
|
|||
if (!upload->map) {
|
||||
pipe_resource_reference(outbuf, NULL);
|
||||
*ptr = NULL;
|
||||
upload->transfer = NULL;
|
||||
return PIPE_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -713,28 +713,21 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
|
|||
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);
|
||||
|
@ -746,9 +739,6 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
|
|||
return sv;
|
||||
|
||||
error_map:
|
||||
pipe->transfer_destroy(pipe, buf_transfer);
|
||||
|
||||
error_transfer:
|
||||
pipe_resource_reference(&matrix, NULL);
|
||||
|
||||
error_matrix:
|
||||
|
|
|
@ -545,15 +545,13 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder,
|
|||
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);
|
||||
|
@ -690,7 +688,6 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder,
|
|||
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;
|
||||
|
|
|
@ -381,21 +381,14 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
|
|||
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) {
|
||||
|
@ -408,7 +401,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -420,9 +412,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
|
|||
return sv;
|
||||
|
||||
error_map:
|
||||
pipe->transfer_destroy(pipe, buf_transfer);
|
||||
|
||||
error_transfer:
|
||||
pipe_resource_reference(&res, NULL);
|
||||
|
||||
error_resource:
|
||||
|
@ -560,33 +549,21 @@ vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
|
|||
|
||||
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
|
||||
|
|
|
@ -450,21 +450,19 @@ Transfers
|
|||
|
||||
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
|
||||
|
@ -515,7 +513,7 @@ These flags control the behavior of a transfer object.
|
|||
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``
|
||||
|
|
|
@ -877,58 +877,35 @@ galahad_context_surface_destroy(struct pipe_context *_pipe,
|
|||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
void *map;
|
||||
|
||||
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);
|
||||
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,
|
||||
|
@ -944,7 +921,6 @@ galahad_context_transfer_flush_region(struct pipe_context *_context,
|
|||
box);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
galahad_context_transfer_unmap(struct pipe_context *_context,
|
||||
struct pipe_transfer *_transfer)
|
||||
|
@ -964,6 +940,9 @@ galahad_context_transfer_unmap(struct pipe_context *_context,
|
|||
|
||||
context->transfer_unmap(context,
|
||||
transfer);
|
||||
|
||||
galahad_transfer_destroy(galahad_context(_context),
|
||||
galahad_transfer(_transfer));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1088,8 +1067,6 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
|
|||
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);
|
||||
|
|
|
@ -173,7 +173,7 @@ galahad_transfer_create(struct galahad_context *glhd_context,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,5 @@ galahad_transfer_destroy(struct galahad_context *glhd_context,
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -31,11 +31,9 @@ i915_resource_from_handle(struct pipe_screen * screen,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,14 +60,16 @@ i915_buffer_destroy(struct pipe_screen *screen,
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -77,30 +79,19 @@ i915_get_transfer(struct pipe_context *pipe,
|
|||
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,
|
||||
|
@ -123,11 +114,9 @@ struct u_resource_vtbl i915_buffer_vtbl =
|
|||
{
|
||||
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 */
|
||||
};
|
||||
|
||||
|
|
|
@ -705,17 +705,22 @@ i915_texture_destroy(struct pipe_screen *screen,
|
|||
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;
|
||||
|
@ -749,15 +754,48 @@ i915_texture_get_transfer(struct pipe_context *pipe,
|
|||
transfer->staging_texture = i915_texture_create(pipe->screen, resource, TRUE);
|
||||
}
|
||||
|
||||
return (struct pipe_transfer*)transfer;
|
||||
if (resource->target != PIPE_TEXTURE_3D &&
|
||||
resource->target != PIPE_TEXTURE_CUBE)
|
||||
assert(box->z == 0);
|
||||
|
||||
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, transfer->b.level, box->z);
|
||||
|
||||
map = iws->buffer_map(iws, tex->buffer,
|
||||
(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) * transfer->b.stride +
|
||||
box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
|
||||
}
|
||||
|
||||
static void
|
||||
i915_transfer_destroy(struct pipe_context *pipe,
|
||||
struct pipe_transfer *transfer)
|
||||
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;
|
||||
|
||||
if (itransfer->staging_texture)
|
||||
tex = i915_texture(itransfer->staging_texture);
|
||||
|
||||
iws->buffer_unmap(iws, tex->buffer);
|
||||
|
||||
if ((itransfer->staging_texture) &&
|
||||
(transfer->usage & PIPE_TRANSFER_WRITE)) {
|
||||
|
@ -775,58 +813,7 @@ i915_transfer_destroy(struct pipe_context *pipe,
|
|||
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);
|
||||
} else {
|
||||
/* TODO this is a sledgehammer */
|
||||
tex = i915_texture(resource);
|
||||
pipe->flush(pipe, NULL);
|
||||
}
|
||||
|
||||
offset = i915_texture_offset(tex, itransfer->b.level, box->z);
|
||||
|
||||
map = iws->buffer_map(iws, tex->buffer,
|
||||
(itransfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
|
||||
if (map == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return map + offset +
|
||||
box->y / util_format_get_blockheight(format) * itransfer->b.stride +
|
||||
box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
|
||||
}
|
||||
|
||||
static void
|
||||
i915_texture_transfer_unmap(struct pipe_context *pipe,
|
||||
struct pipe_transfer *transfer)
|
||||
{
|
||||
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;
|
||||
|
||||
if (itransfer->staging_texture)
|
||||
tex = i915_texture(itransfer->staging_texture);
|
||||
|
||||
iws->buffer_unmap(iws, tex->buffer);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void i915_transfer_inline_write( struct pipe_context *pipe,
|
||||
struct pipe_resource *resource,
|
||||
unsigned level,
|
||||
|
@ -841,7 +828,7 @@ static void i915_transfer_inline_write( struct pipe_context *pipe,
|
|||
const uint8_t *src_data = data;
|
||||
unsigned i;
|
||||
|
||||
transfer = pipe->get_transfer(pipe,
|
||||
transfer = pipe->transfer_get(pipe,
|
||||
resource,
|
||||
level,
|
||||
usage,
|
||||
|
@ -913,24 +900,19 @@ out:
|
|||
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,
|
||||
|
|
|
@ -776,53 +776,34 @@ identity_context_surface_destroy(struct pipe_context *_pipe,
|
|||
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);
|
||||
map = context->transfer_map(context,
|
||||
resource,
|
||||
level,
|
||||
usage,
|
||||
box, &result);
|
||||
|
||||
if (result)
|
||||
return identity_transfer_create(id_context, id_resource, result);
|
||||
return NULL;
|
||||
if (!map)
|
||||
return NULL;
|
||||
|
||||
*transfer = identity_transfer_map(id_context, id_resource, result);
|
||||
return *transfer ? map : NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return context->transfer_map(context,
|
||||
transfer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
identity_context_transfer_flush_region(struct pipe_context *_context,
|
||||
struct pipe_transfer *_transfer,
|
||||
|
@ -850,6 +831,9 @@ identity_context_transfer_unmap(struct pipe_context *_context,
|
|||
|
||||
context->transfer_unmap(context,
|
||||
transfer);
|
||||
|
||||
identity_transfer_destroy(identity_context(_context),
|
||||
identity_transfer(_transfer));
|
||||
}
|
||||
|
||||
|
||||
|
@ -945,8 +929,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
|
|||
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;
|
||||
|
|
|
@ -149,9 +149,9 @@ identity_sampler_view_destroy(struct identity_context *id_context,
|
|||
|
||||
|
||||
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;
|
||||
|
||||
|
@ -175,7 +175,7 @@ identity_transfer_create(struct identity_context *id_context,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -184,8 +184,6 @@ identity_transfer_destroy(struct identity_context *id_context,
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ identity_sampler_view_destroy(struct identity_context *id_context,
|
|||
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);
|
||||
|
||||
|
|
|
@ -622,16 +622,23 @@ llvmpipe_surface_destroy(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
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);
|
||||
|
@ -661,48 +668,19 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
|
|||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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",
|
||||
|
@ -712,7 +690,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
|
|||
transfer->usage);
|
||||
*/
|
||||
|
||||
if (transfer->usage == PIPE_TRANSFER_READ) {
|
||||
if (usage == PIPE_TRANSFER_READ) {
|
||||
tex_usage = LP_TEX_USAGE_READ;
|
||||
mode = "read";
|
||||
}
|
||||
|
@ -722,33 +700,29 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -763,6 +737,14 @@ llvmpipe_transfer_unmap(struct pipe_context *pipe,
|
|||
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
|
||||
|
@ -1474,8 +1456,6 @@ llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
|
|||
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;
|
||||
|
||||
|
|
|
@ -146,32 +146,28 @@ static void noop_resource_destroy(struct pipe_screen *screen,
|
|||
/*
|
||||
* 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;
|
||||
|
||||
return nresource->data;
|
||||
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;
|
||||
}
|
||||
|
||||
static void noop_transfer_flush_region(struct pipe_context *pipe,
|
||||
|
@ -183,13 +179,8 @@ 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,
|
||||
|
@ -280,11 +271,9 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen, void
|
|||
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);
|
||||
|
||||
|
|
|
@ -167,54 +167,6 @@ nouveau_buffer_upload(struct nouveau_context *nv, struct nv04_resource *buf,
|
|||
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)
|
||||
{
|
||||
|
@ -247,19 +199,39 @@ nouveau_buffer_busy(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);
|
||||
|
@ -267,19 +239,24 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -307,6 +284,21 @@ static void
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -341,8 +333,6 @@ const struct u_resource_vtbl nouveau_buffer_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -218,14 +218,16 @@ nv30_blit(struct pipe_context *pipe,
|
|||
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);
|
||||
|
@ -270,11 +272,30 @@ nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
|
|||
if (usage & PIPE_TRANSFER_READ)
|
||||
nv30_transfer_rect(nv30, NEAREST, &tx->img, &tx->tmp);
|
||||
|
||||
return &tx->base;
|
||||
if (tx->tmp.bo->map) {
|
||||
*ptransfer = &tx->base;
|
||||
return tx->tmp.bo->map;
|
||||
}
|
||||
|
||||
if (usage & PIPE_TRANSFER_READ)
|
||||
access |= NOUVEAU_BO_RD;
|
||||
if (usage & PIPE_TRANSFER_WRITE)
|
||||
access |= NOUVEAU_BO_WR;
|
||||
|
||||
ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
|
||||
if (ret) {
|
||||
pipe_resource_reference(&tx->base.resource, NULL);
|
||||
FREE(tx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ptransfer = &tx->base;
|
||||
return tx->tmp.bo->map;
|
||||
}
|
||||
|
||||
static void
|
||||
nv30_miptree_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx)
|
||||
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);
|
||||
|
@ -287,39 +308,9 @@ nv30_miptree_transfer_del(struct pipe_context *pipe, struct pipe_transfer *ptx)
|
|||
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)
|
||||
return tx->tmp.bo->map;
|
||||
|
||||
if (ptx->usage & PIPE_TRANSFER_READ)
|
||||
access |= NOUVEAU_BO_RD;
|
||||
if (ptx->usage & PIPE_TRANSFER_WRITE)
|
||||
access |= NOUVEAU_BO_WR;
|
||||
|
||||
ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
|
||||
if (ret)
|
||||
return NULL;
|
||||
return tx->tmp.bo->map;
|
||||
}
|
||||
|
||||
static void
|
||||
nv30_miptree_transfer_unmap(struct pipe_context *pipe,
|
||||
struct pipe_transfer *ptx)
|
||||
{
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -66,11 +66,9 @@ nv30_resource_screen_init(struct pipe_screen *pscreen)
|
|||
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;
|
||||
|
|
|
@ -145,8 +145,6 @@ const struct u_resource_vtbl nv50_miptree_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -86,11 +86,9 @@ nv50_surface_destroy(struct pipe_context *pipe, struct pipe_surface *ps)
|
|||
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;
|
||||
|
|
|
@ -123,18 +123,13 @@ nv50_miptree_surface_new(struct pipe_context *,
|
|||
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);
|
||||
|
|
|
@ -246,19 +246,22 @@ nv50_m2mf_copy_linear(struct nouveau_context *nv,
|
|||
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;
|
||||
|
@ -320,12 +323,30 @@ nv50_miptree_transfer_new(struct pipe_context *pctx,
|
|||
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;
|
||||
|
@ -350,36 +371,6 @@ nv50_miptree_transfer_del(struct pipe_context *pctx,
|
|||
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,
|
||||
|
|
|
@ -259,8 +259,6 @@ const struct u_resource_vtbl nvc0_miptree_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -44,11 +44,9 @@ nvc0_surface_create(struct pipe_context *pipe,
|
|||
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;
|
||||
|
|
|
@ -44,18 +44,13 @@ nvc0_miptree_surface_new(struct pipe_context *,
|
|||
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);
|
||||
|
|
|
@ -326,12 +326,13 @@ nve4_m2mf_copy_linear(struct nouveau_context *nv,
|
|||
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;
|
||||
|
@ -339,6 +340,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
|
|||
struct nvc0_transfer *tx;
|
||||
uint32_t size;
|
||||
int ret;
|
||||
unsigned flags = 0;
|
||||
|
||||
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
|
||||
return NULL;
|
||||
|
@ -372,6 +374,7 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
|
|||
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;
|
||||
}
|
||||
|
@ -401,12 +404,31 @@ nvc0_miptree_transfer_new(struct pipe_context *pctx,
|
|||
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;
|
||||
|
@ -431,35 +453,6 @@ nvc0_miptree_transfer_del(struct pipe_context *pctx,
|
|||
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,
|
||||
|
|
|
@ -40,11 +40,9 @@ r300_resource_create(struct pipe_screen *screen,
|
|||
|
||||
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;
|
||||
|
|
|
@ -63,79 +63,63 @@ static void r300_buffer_destroy(struct pipe_screen *screen,
|
|||
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 */
|
||||
|
|
|
@ -937,8 +937,6 @@ static const struct u_resource_vtbl r300_texture_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -76,18 +76,21 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
|
|||
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);
|
||||
|
@ -101,7 +104,7 @@ r300_texture_get_transfer(struct pipe_context *ctx,
|
|||
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;
|
||||
|
@ -161,15 +164,8 @@ r300_texture_get_transfer(struct pipe_context *ctx,
|
|||
&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;
|
||||
}
|
||||
|
@ -190,64 +186,43 @@ r300_texture_get_transfer(struct pipe_context *ctx,
|
|||
/* Always referenced in the blit. */
|
||||
r300_flush(ctx, 0, NULL);
|
||||
}
|
||||
return &trans->transfer;
|
||||
} else {
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,12 +230,20 @@ void r300_texture_transfer_unmap(struct pipe_context *ctx,
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -28,20 +28,13 @@
|
|||
|
||||
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,
|
||||
|
|
|
@ -453,27 +453,22 @@ void compute_memory_transfer(
|
|||
"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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,12 +104,10 @@ static void evergreen_cs_set_vertex_buffer(
|
|||
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 */
|
||||
|
@ -841,30 +839,57 @@ void r600_compute_global_buffer_destroy(
|
|||
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;
|
||||
|
@ -884,50 +909,7 @@ void r600_compute_global_transfer_unmap(
|
|||
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(
|
||||
|
|
|
@ -41,11 +41,14 @@ void evergreen_emit_cs_shader(struct r600_context *rctx, struct r600_atom * atom
|
|||
|
||||
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);
|
||||
|
|
|
@ -37,33 +37,6 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
|
|||
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)
|
||||
{
|
||||
|
@ -87,16 +60,47 @@ static void r600_set_constants_dirty_if_bound(struct r600_context *rctx,
|
|||
}
|
||||
}
|
||||
|
||||
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) ||
|
||||
|
@ -134,37 +138,44 @@ static void *r600_buffer_transfer_map(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
#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;
|
||||
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);
|
||||
|
||||
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);
|
||||
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) {
|
||||
|
@ -176,12 +187,6 @@ static void r600_buffer_transfer_unmap(struct pipe_context *pipe,
|
|||
&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);
|
||||
}
|
||||
|
||||
|
@ -189,8 +194,6 @@ 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 */
|
||||
NULL, /* transfer_flush_region */
|
||||
r600_buffer_transfer_unmap, /* transfer_unmap */
|
||||
|
|
|
@ -68,10 +68,8 @@ void r600_init_screen_resource_functions(struct pipe_screen *screen)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -141,17 +141,4 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
|
|||
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
|
||||
|
|
|
@ -240,17 +240,7 @@ static void r600_texture_destroy(struct pipe_screen *screen,
|
|||
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,
|
||||
|
@ -603,17 +593,26 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
|
|||
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.
|
||||
|
@ -644,7 +643,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
|
|||
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;
|
||||
|
@ -657,7 +656,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -670,7 +668,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
|
|||
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;
|
||||
|
@ -697,7 +694,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
|
|||
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;
|
||||
}
|
||||
|
@ -709,21 +705,53 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
|
|||
/* Always referenced in the blit. */
|
||||
r600_flush(ctx, NULL, 0);
|
||||
}
|
||||
return &trans->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);
|
||||
}
|
||||
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;
|
||||
|
||||
if (trans->staging) {
|
||||
buf = ((struct r600_resource *)trans->staging)->cs_buf;
|
||||
} else {
|
||||
buf = ((struct r600_resource *)texture)->cs_buf;
|
||||
}
|
||||
|
||||
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, usage))) {
|
||||
pipe_resource_reference((struct pipe_resource**)&trans->staging, NULL);
|
||||
FREE(trans);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ptransfer = &trans->transfer;
|
||||
return map + offset;
|
||||
}
|
||||
|
||||
void r600_texture_transfer_destroy(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);
|
||||
}
|
||||
|
||||
if (rtransfer->staging) {
|
||||
buf = ((struct r600_resource *)rtransfer->staging)->cs_buf;
|
||||
} else {
|
||||
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,
|
||||
|
@ -738,63 +766,9 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
|
|||
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);
|
||||
}
|
||||
|
||||
if (rtransfer->staging) {
|
||||
buf = ((struct r600_resource *)rtransfer->staging)->cs_buf;
|
||||
} else {
|
||||
buf = ((struct r600_resource *)transfer->resource)->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 (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return map + offset;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if ((transfer->resource->bind & PIPE_BIND_GLOBAL) && transfer->resource->target == PIPE_BUFFER) {
|
||||
return r600_compute_global_transfer_unmap(ctx, transfer);
|
||||
}
|
||||
|
||||
if (rtransfer->staging) {
|
||||
buf = ((struct r600_resource *)rtransfer->staging)->cs_buf;
|
||||
} else {
|
||||
buf = ((struct r600_resource *)transfer->resource)->cs_buf;
|
||||
}
|
||||
rctx->ws->buffer_unmap(buf);
|
||||
}
|
||||
|
||||
void r600_init_surface_functions(struct r600_context *r600)
|
||||
{
|
||||
r600->context.create_surface = r600_create_surface;
|
||||
|
@ -1178,3 +1152,13 @@ out_unknown:
|
|||
/* 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 */
|
||||
};
|
||||
|
|
|
@ -46,15 +46,24 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
|
|||
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;
|
||||
|
@ -62,31 +71,16 @@ static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
|
|||
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,
|
||||
|
@ -95,19 +89,10 @@ 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 */
|
||||
|
|
|
@ -54,10 +54,8 @@ void r600_init_screen_resource_functions(struct pipe_screen *screen)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -254,17 +254,23 @@ static void r600_texture_destroy(struct pipe_screen *screen,
|
|||
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.
|
||||
|
@ -316,7 +322,6 @@ static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
|
|||
}
|
||||
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;
|
||||
|
@ -355,21 +360,60 @@ static struct pipe_transfer* si_texture_get_transfer(struct pipe_context *ctx,
|
|||
/* Always referenced in the blit. */
|
||||
radeonsi_flush(ctx, NULL, 0);
|
||||
}
|
||||
return &trans->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);
|
||||
}
|
||||
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;
|
||||
|
||||
if (trans->staging_texture) {
|
||||
buf = si_resource(trans->staging_texture)->cs_buf;
|
||||
} else {
|
||||
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(texture)->cs_buf;
|
||||
|
||||
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, 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;
|
||||
}
|
||||
|
||||
static void si_texture_transfer_destroy(struct pipe_context *ctx,
|
||||
struct pipe_transfer *transfer)
|
||||
static void si_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_resource_texture *rtex = (struct r600_resource_texture*)texture;
|
||||
|
||||
if (rtransfer->staging_texture) {
|
||||
buf = si_resource(rtransfer->staging_texture)->cs_buf;
|
||||
} else {
|
||||
struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
|
||||
|
||||
if (rtex->flushed_depth_texture) {
|
||||
buf = rtex->flushed_depth_texture->resource.cs_buf;
|
||||
} else {
|
||||
buf = si_resource(transfer->resource)->cs_buf;
|
||||
}
|
||||
}
|
||||
rctx->ws->buffer_unmap(buf);
|
||||
|
||||
if (rtransfer->staging_texture) {
|
||||
if (transfer->usage & PIPE_TRANSFER_WRITE) {
|
||||
r600_copy_from_staging_texture(ctx, rtransfer);
|
||||
|
@ -386,65 +430,10 @@ static void si_texture_transfer_destroy(struct pipe_context *ctx,
|
|||
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;
|
||||
} else {
|
||||
struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
|
||||
|
||||
if (rtex->flushed_depth_texture)
|
||||
buf = rtex->flushed_depth_texture->resource.cs_buf;
|
||||
else
|
||||
buf = si_resource(transfer->resource)->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);
|
||||
}
|
||||
|
||||
if (!(map = rctx->ws->buffer_map(buf, rctx->cs, transfer->usage))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return map + offset;
|
||||
}
|
||||
|
||||
static void si_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;
|
||||
|
||||
if (rtransfer->staging_texture) {
|
||||
buf = si_resource(rtransfer->staging_texture)->cs_buf;
|
||||
} else {
|
||||
struct r600_resource_texture *rtex = (struct r600_resource_texture*)transfer->resource;
|
||||
|
||||
if (rtex->flushed_depth_texture) {
|
||||
buf = rtex->flushed_depth_texture->resource.cs_buf;
|
||||
} else {
|
||||
buf = si_resource(transfer->resource)->cs_buf;
|
||||
}
|
||||
}
|
||||
rctx->ws->buffer_unmap(buf);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
|
|
@ -1019,65 +1019,33 @@ rbug_context_surface_destroy(struct pipe_context *_pipe,
|
|||
|
||||
|
||||
|
||||
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,
|
||||
|
@ -1108,6 +1076,8 @@ rbug_context_transfer_unmap(struct pipe_context *_context,
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -1217,8 +1187,6 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
|
|||
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;
|
||||
|
|
|
@ -266,12 +266,10 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -285,7 +283,6 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
|
|||
NULL);
|
||||
|
||||
context->transfer_unmap(context, t);
|
||||
context->transfer_destroy(context, t);
|
||||
|
||||
pipe_mutex_unlock(rb_screen->list_mutex);
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ rbug_transfer_create(struct rbug_context *rb_context,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -193,8 +193,6 @@ rbug_transfer_destroy(struct rbug_context *rb_context,
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,38 +53,6 @@
|
|||
#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 )
|
||||
{
|
||||
|
|
|
@ -73,8 +73,6 @@ softpipe_draw_vbo(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;
|
||||
|
|
|
@ -75,14 +75,6 @@ softpipe_flush( struct pipe_context *pipe,
|
|||
|
||||
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) {
|
||||
|
|
|
@ -158,12 +158,6 @@ void
|
|||
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);
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc)
|
|||
/*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 );
|
||||
|
@ -131,14 +131,10 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *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) {
|
||||
|
@ -236,14 +232,10 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
|
|||
/* 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);
|
||||
|
@ -256,14 +248,12 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
|
|||
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;
|
||||
|
@ -274,8 +264,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
|
|||
* 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,
|
||||
|
@ -283,8 +272,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
|
|||
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,
|
||||
|
@ -292,8 +280,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
|
|||
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,
|
||||
|
|
|
@ -331,15 +331,22 @@ softpipe_surface_destroy(struct pipe_context *pipe,
|
|||
* \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);
|
||||
|
@ -384,69 +391,41 @@ softpipe_get_transfer(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
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);
|
||||
if (!spt)
|
||||
return NULL;
|
||||
|
||||
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;
|
||||
pt = &spt->base;
|
||||
|
||||
spt->offset = sp_get_tex_image_offset(spr, level, box->z);
|
||||
|
||||
spt->offset +=
|
||||
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);
|
||||
|
||||
return pt;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -472,6 +451,9 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
|
|||
/* Mark the texture as dirty to expire the tile caches. */
|
||||
spr->timestamp++;
|
||||
}
|
||||
|
||||
pipe_resource_reference(&transfer->resource, NULL);
|
||||
FREE(transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,8 +491,6 @@ softpipe_user_buffer_create(struct pipe_screen *screen,
|
|||
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;
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
|
|||
FREE( tc->tile );
|
||||
|
||||
if (tc->transfer) {
|
||||
tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
|
||||
tc->pipe->transfer_unmap(tc->pipe, tc->transfer);
|
||||
}
|
||||
|
||||
FREE( tc );
|
||||
|
@ -158,27 +158,24 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *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);
|
||||
}
|
||||
|
@ -195,24 +192,6 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
|
|||
}
|
||||
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -349,24 +328,23 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
|
|||
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);
|
||||
}
|
||||
|
@ -389,7 +367,7 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos)
|
|||
{
|
||||
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,
|
||||
|
@ -397,21 +375,21 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos)
|
|||
}
|
||||
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,
|
||||
|
@ -516,7 +494,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
|
|||
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,
|
||||
|
@ -524,21 +502,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
|
|||
}
|
||||
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,
|
||||
|
@ -563,7 +541,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
|
|||
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,
|
||||
|
@ -571,21 +549,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
|
|||
}
|
||||
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,
|
||||
|
|
|
@ -112,12 +112,6 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
|
|||
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);
|
||||
|
||||
|
|
|
@ -58,11 +58,9 @@ svga_resource_from_handle(struct pipe_screen * screen,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,17 +62,19 @@ svga_buffer_needs_hw_storage(unsigned usage)
|
|||
* 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) {
|
||||
|
@ -186,21 +188,6 @@ svga_buffer_get_transfer(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -218,6 +205,7 @@ svga_buffer_transfer_map( struct pipe_context *pipe,
|
|||
if (map) {
|
||||
++sbuf->map.count;
|
||||
map += transfer->box.x;
|
||||
*ptransfer = transfer;
|
||||
}
|
||||
|
||||
return map;
|
||||
|
@ -280,16 +268,6 @@ svga_buffer_transfer_unmap( struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
pipe_mutex_unlock(ss->swc_mutex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy transfer
|
||||
*/
|
||||
static void
|
||||
svga_buffer_transfer_destroy(struct pipe_context *pipe,
|
||||
struct pipe_transfer *transfer)
|
||||
{
|
||||
FREE(transfer);
|
||||
}
|
||||
|
||||
|
@ -325,8 +303,6 @@ struct u_resource_vtbl svga_buffer_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -236,12 +236,13 @@ svga_texture_destroy(struct pipe_screen *screen,
|
|||
/* 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);
|
||||
|
@ -259,7 +260,7 @@ svga_texture_get_transfer(struct pipe_context *pipe,
|
|||
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;
|
||||
|
@ -305,8 +306,22 @@ svga_texture_get_transfer(struct pipe_context *pipe,
|
|||
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:
|
||||
|
@ -315,26 +330,6 @@ 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.
|
||||
*/
|
||||
|
@ -342,24 +337,14 @@ static void
|
|||
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;
|
||||
|
@ -381,7 +366,6 @@ svga_texture_transfer_destroy(struct pipe_context *pipe,
|
|||
tex->defined[0][transfer->level] = TRUE;
|
||||
}
|
||||
|
||||
pipe_resource_reference(&st->base.resource, NULL);
|
||||
FREE(st->swbuf);
|
||||
sws->buffer_destroy(sws, st->hwbuf);
|
||||
FREE(st);
|
||||
|
@ -392,8 +376,6 @@ struct u_resource_vtbl svga_texture_vtbl =
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -131,8 +131,10 @@ svga_vbuf_render_map_vertices( struct vbuf_render *render )
|
|||
&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 */
|
||||
|
|
|
@ -1377,18 +1377,20 @@ trace_context_destroy(struct pipe_context *_pipe)
|
|||
*/
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1397,48 +1399,21 @@ trace_context_get_transfer(struct pipe_context *_context,
|
|||
* to transfer_inline_write and ignore read transfers.
|
||||
*/
|
||||
|
||||
result = context->get_transfer(context, texture, level, usage, box);
|
||||
map = context->transfer_map(context, texture, level, usage, box, &result);
|
||||
if (!map)
|
||||
return NULL;
|
||||
|
||||
if (result)
|
||||
result = trace_transfer_create(tr_context, tr_res, result);
|
||||
*transfer = 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);
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
|
@ -1500,6 +1475,7 @@ trace_context_transfer_unmap(struct pipe_context *_context,
|
|||
}
|
||||
|
||||
context->transfer_unmap(context, transfer);
|
||||
trace_transfer_destroy(tr_ctx, tr_trans);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1667,8 +1643,6 @@ trace_context_create(struct trace_screen *tr_scr,
|
|||
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);
|
||||
|
|
|
@ -139,7 +139,7 @@ trace_transfer_create(struct trace_context *tr_ctx,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -148,11 +148,7 @@ void
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ struct pipe_shader_state;
|
|||
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;
|
||||
|
@ -374,22 +375,21 @@ struct pipe_context {
|
|||
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
|
||||
|
@ -399,9 +399,8 @@ struct pipe_context {
|
|||
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??
|
||||
|
|
|
@ -205,7 +205,7 @@ enum pipe_transfer_usage {
|
|||
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),
|
||||
|
@ -300,8 +300,8 @@ enum pipe_transfer_usage {
|
|||
#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 */
|
||||
|
|
|
@ -177,14 +177,10 @@ mapping::mapping(command_queue &q, resource &r,
|
|||
(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);
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +194,5 @@ mapping::mapping(mapping &&m) :
|
|||
mapping::~mapping() {
|
||||
if (pxfer) {
|
||||
pctx->transfer_unmap(pctx, pxfer);
|
||||
pctx->transfer_destroy(pctx, pxfer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1506,15 +1506,16 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
|
|||
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;
|
||||
|
@ -1530,7 +1531,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
|
|||
if(i != resource->transfers.end())
|
||||
{
|
||||
pipe->transfer_unmap(pipe, i->second);
|
||||
pipe->transfer_destroy(pipe, i->second);
|
||||
resource->transfers.erase(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,11 +257,10 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
|
|||
|
||||
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);
|
||||
|
@ -275,7 +274,6 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
|
|||
}
|
||||
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
pipe_transfer_destroy(pipe, transfer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1368,12 +1368,12 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
|
|||
|
||||
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. */
|
||||
|
@ -1385,14 +1385,7 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -1407,8 +1400,6 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
|
|||
|
||||
pipe_transfer_unmap(pipe, tex_xfer);
|
||||
|
||||
pipe_transfer_destroy(pipe, tex_xfer);
|
||||
|
||||
st->teximage(st,
|
||||
ST_TEXTURE_2D,
|
||||
0, /* level */
|
||||
|
|
|
@ -207,15 +207,8 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -224,7 +217,6 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
|
|||
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;
|
||||
|
|
|
@ -236,15 +236,9 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
|
|||
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;
|
||||
}
|
||||
|
@ -254,7 +248,6 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
|
|||
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);
|
||||
|
|
|
@ -78,15 +78,15 @@ static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx,
|
|||
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;
|
||||
|
|
|
@ -442,24 +442,26 @@ void vegaReadPixels(void * data, VGint dataStride,
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -418,17 +418,19 @@ void image_sub_data(struct vg_image *image,
|
|||
}
|
||||
|
||||
{ /* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,25 +450,26 @@ void image_get_sub_data(struct vg_image * image,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,13 +160,13 @@ static INLINE struct pipe_resource *create_gradient_texture(struct vg_paint *p)
|
|||
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;
|
||||
|
|
|
@ -103,15 +103,11 @@ xa_surface_dma(struct xa_context *ctx,
|
|||
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,
|
||||
|
@ -122,14 +118,10 @@ xa_surface_dma(struct xa_context *ctx,
|
|||
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 *
|
||||
|
@ -154,15 +146,12 @@ xa_surface_map(struct xa_context *ctx,
|
|||
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;
|
||||
|
@ -175,7 +164,6 @@ xa_surface_unmap(struct xa_surface *srf)
|
|||
struct pipe_context *pipe = srf->mapping_pipe;
|
||||
|
||||
pipe->transfer_unmap(pipe, srf->transfer);
|
||||
pipe->transfer_destroy(pipe, srf->transfer);
|
||||
srf->transfer = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,16 +240,14 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
|
|||
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) {
|
||||
|
|
|
@ -201,24 +201,23 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
|
|||
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;
|
||||
}
|
||||
|
@ -233,24 +232,24 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
|
|||
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;
|
||||
}
|
||||
|
@ -279,24 +278,23 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -320,7 +318,7 @@ ExaFinishAccess(PixmapPtr pPix, int index)
|
|||
if (!priv)
|
||||
return;
|
||||
|
||||
if (!priv->map_transfer)
|
||||
if (!priv->map_transfer || pPix->devPrivate.ptr == NULL)
|
||||
return;
|
||||
|
||||
exa_debug_printf("ExaFinishAccess %d\n", index);
|
||||
|
@ -328,7 +326,6 @@ ExaFinishAccess(PixmapPtr pPix, int 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;
|
||||
}
|
||||
|
|
|
@ -312,22 +312,18 @@ copy_packed_data(ScrnInfoPtr pScrn,
|
|||
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;
|
||||
|
||||
|
@ -396,9 +392,6 @@ copy_packed_data(ScrnInfoPtr pScrn,
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -173,20 +173,16 @@ upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst,
|
|||
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
|
||||
|
@ -323,20 +319,15 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -369,12 +369,10 @@ static void init_tex( void )
|
|||
{
|
||||
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);
|
||||
|
@ -382,8 +380,6 @@ static void init_tex( void )
|
|||
}
|
||||
|
||||
ctx->transfer_unmap(ctx, t);
|
||||
|
||||
ctx->transfer_destroy(ctx, t);
|
||||
}
|
||||
|
||||
memset(&sv_template, 0, sizeof sv_template);
|
||||
|
|
|
@ -259,7 +259,7 @@ graw_util_create_tex2d(const struct graw_info *info,
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -433,12 +433,10 @@ static void init_tex( void )
|
|||
{
|
||||
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);
|
||||
|
@ -446,8 +444,6 @@ static void init_tex( void )
|
|||
}
|
||||
|
||||
ctx->transfer_unmap(ctx, t);
|
||||
|
||||
ctx->transfer_destroy(ctx, t);
|
||||
}
|
||||
|
||||
memset(&sv_template, 0, sizeof sv_template);
|
||||
|
|
|
@ -242,12 +242,10 @@ static void init_tex( void )
|
|||
{
|
||||
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);
|
||||
|
@ -255,8 +253,6 @@ static void init_tex( void )
|
|||
}
|
||||
|
||||
ctx->transfer_unmap(ctx, t);
|
||||
|
||||
ctx->transfer_destroy(ctx, t);
|
||||
}
|
||||
|
||||
memset(&sv_template, 0, sizeof sv_template);
|
||||
|
|
|
@ -320,12 +320,10 @@ static void init_tex( void )
|
|||
{
|
||||
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);
|
||||
|
@ -333,8 +331,6 @@ static void init_tex( void )
|
|||
}
|
||||
|
||||
ctx->transfer_unmap(ctx, t);
|
||||
|
||||
ctx->transfer_destroy(ctx, t);
|
||||
}
|
||||
|
||||
memset(&sv_template, 0, sizeof sv_template);
|
||||
|
|
|
@ -175,17 +175,13 @@ static void init_prog(struct program *p)
|
|||
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);
|
||||
|
|
|
@ -90,17 +90,18 @@ wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
|
|||
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;
|
||||
}
|
||||
|
@ -204,13 +205,9 @@ wsw_dt_map(struct sw_winsys *ws,
|
|||
|
||||
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;
|
||||
|
||||
|
@ -226,7 +223,7 @@ wsw_dt_map(struct sw_winsys *ws,
|
|||
return wdt->ptr;
|
||||
|
||||
err:
|
||||
pipe->transfer_destroy(pipe, tr);
|
||||
pipe->transfer_unmap(pipe, tr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -245,7 +242,6 @@ wsw_dt_unmap(struct sw_winsys *ws,
|
|||
return;
|
||||
|
||||
pipe->transfer_unmap(pipe, wdt->transfer);
|
||||
pipe->transfer_destroy(pipe, wdt->transfer);
|
||||
pipe->flush(pipe, NULL);
|
||||
wdt->transfer = NULL;
|
||||
}
|
||||
|
|
|
@ -101,10 +101,9 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
|
|||
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
|
||||
|
@ -127,7 +126,6 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
|
|||
}
|
||||
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -306,11 +306,9 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
|
|||
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);
|
||||
|
@ -321,8 +319,6 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
|
|||
|
||||
/* Release transfer */
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
@ -611,11 +607,10 @@ create_cache_trans(struct st_context *st)
|
|||
/* 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);
|
||||
|
@ -645,13 +640,11 @@ st_flush_bitmap_cache(struct st_context *st)
|
|||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -867,9 +860,8 @@ st_destroy_bitmap(struct st_context *st)
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -298,6 +298,9 @@ st_bufferobj_map_range(struct gl_context *ctx,
|
|||
obj->Length = length;
|
||||
obj->AccessFlags = access;
|
||||
}
|
||||
else {
|
||||
st_obj->transfer = NULL;
|
||||
}
|
||||
|
||||
return obj->Pointer;
|
||||
}
|
||||
|
|
|
@ -514,12 +514,10 @@ make_texture(struct st_context *st,
|
|||
/* 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.
|
||||
|
@ -538,7 +536,6 @@ make_texture(struct st_context *st,
|
|||
|
||||
/* unmap */
|
||||
pipe_transfer_unmap(pipe, transfer);
|
||||
pipe->transfer_destroy(pipe, transfer);
|
||||
|
||||
assert(success);
|
||||
|
||||
|
@ -863,12 +860,10 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
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);
|
||||
|
@ -996,7 +991,6 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
|
||||
/* unmap the stencil buffer */
|
||||
pipe_transfer_unmap(pipe, pt);
|
||||
pipe->transfer_destroy(pipe, pt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1247,18 +1241,16 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
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 */
|
||||
|
@ -1283,7 +1275,6 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
|
||||
/* unmap the stencil buffer */
|
||||
pipe_transfer_unmap(pipe, ptDraw);
|
||||
pipe->transfer_destroy(pipe, ptDraw);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1573,13 +1564,15 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
}
|
||||
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)
|
||||
|
@ -1590,8 +1583,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
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) {
|
||||
|
@ -1600,23 +1593,24 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue