X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fllvmpipe%2Flp_texture.c;h=0088b6ad0289f5cd14275585dcf3f0ddd247bc51;hb=72c6d0e506ad0e8262dddbc7a7cf2d6813761753;hp=cd1dddcd39a46ec123ff484618ec11c6392f86e8;hpb=7688a4749e9266fe6c5f86b62e19d3a0975c3f57;p=mesa.git diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index cd1dddcd39a..0088b6ad028 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -36,54 +36,28 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" +#include "util/u_cpu_detect.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_simple_list.h" #include "util/u_transfer.h" #include "lp_context.h" #include "lp_flush.h" #include "lp_screen.h" -#include "lp_tile_image.h" #include "lp_texture.h" #include "lp_setup.h" -#include "lp_tile_size.h" +#include "lp_state.h" +#include "lp_rast.h" #include "state_tracker/sw_winsys.h" -static INLINE boolean -resource_is_texture(const struct pipe_resource *resource) -{ - const unsigned tex_binds = (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED | - PIPE_BIND_DEPTH_STENCIL | - PIPE_BIND_SAMPLER_VIEW); - const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource); - - return (lpr->base.bind & tex_binds) ? TRUE : FALSE; -} - - - -/** - * Allocate storage for llvmpipe_texture::layout array. - * The number of elements is width_in_tiles * height_in_tiles. - */ -static enum lp_texture_layout * -alloc_layout_array(unsigned num_slices, unsigned width, unsigned height) -{ - const unsigned tx = align(width, TILE_SIZE) / TILE_SIZE; - const unsigned ty = align(height, TILE_SIZE) / TILE_SIZE; - - assert(num_slices * tx * ty > 0); - assert(LP_TEX_LAYOUT_NONE == 0); /* calloc'ing LP_TEX_LAYOUT_NONE here */ - - return (enum lp_texture_layout *) - calloc(num_slices * tx * ty, sizeof(enum lp_texture_layout)); -} - +#ifdef DEBUG +static struct llvmpipe_resource resource_list; +#endif +static unsigned id_counter = 0; /** @@ -99,46 +73,113 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen, unsigned width = pt->width0; unsigned height = pt->height0; unsigned depth = pt->depth0; + uint64_t total_size = 0; + unsigned layers = pt->array_size; assert(LP_MAX_TEXTURE_2D_LEVELS <= LP_MAX_TEXTURE_LEVELS); assert(LP_MAX_TEXTURE_3D_LEVELS <= LP_MAX_TEXTURE_LEVELS); for (level = 0; level <= pt->last_level; level++) { - const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; - const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; - unsigned nblocksx, num_slices; - - if (lpr->base.target == PIPE_TEXTURE_CUBE) - num_slices = 6; - else if (lpr->base.target == PIPE_TEXTURE_3D) - num_slices = depth; - else - num_slices = 1; - - /* Allocate storage for whole quads. This is particularly important - * for depth surfaces, which are currently stored in a swizzled format. - */ - nblocksx = util_format_get_nblocksx(pt->format, align(width, TILE_SIZE)); - lpr->row_stride[level] = - align(nblocksx * util_format_get_blocksize(pt->format), 16); + /* Row stride and image stride */ + { + unsigned align_x, align_y, nblocksx, nblocksy, block_size; + + /* For non-compressed formats we need 4x4 pixel alignment + * so we can read/write LP_RASTER_BLOCK_SIZE when rendering to them. + * We also want cache line size in x direction, + * otherwise same cache line could end up in multiple threads. + * For explicit 1d resources however we reduce this to 4x1 and + * handle specially in render output code (as we need to do special + * handling there for buffers in any case). + */ + if (util_format_is_compressed(pt->format)) + align_x = align_y = 1; + else { + align_x = LP_RASTER_BLOCK_SIZE; + if (llvmpipe_resource_is_1d(&lpr->base)) + align_y = 1; + else + align_y = LP_RASTER_BLOCK_SIZE; + } + + nblocksx = util_format_get_nblocksx(pt->format, + align(width, align_x)); + nblocksy = util_format_get_nblocksy(pt->format, + align(height, align_y)); + block_size = util_format_get_blocksize(pt->format); + + if (util_format_is_compressed(pt->format)) + lpr->row_stride[level] = nblocksx * block_size; + else + lpr->row_stride[level] = align(nblocksx * block_size, util_cpu_caps.cacheline); + + /* if row_stride * height > LP_MAX_TEXTURE_SIZE */ + if (lpr->row_stride[level] > LP_MAX_TEXTURE_SIZE / nblocksy) { + /* image too large */ + goto fail; + } + + lpr->img_stride[level] = lpr->row_stride[level] * nblocksy; + } + + /* Number of 3D image slices, cube faces or texture array layers */ + { + unsigned num_slices; + + if (lpr->base.target == PIPE_TEXTURE_CUBE) + num_slices = 6; + else if (lpr->base.target == PIPE_TEXTURE_3D) + num_slices = depth; + else if (lpr->base.target == PIPE_TEXTURE_1D_ARRAY || + lpr->base.target == PIPE_TEXTURE_2D_ARRAY) + num_slices = layers; + else + num_slices = 1; + + lpr->num_slices_faces[level] = num_slices; + } - lpr->img_stride[level] = lpr->row_stride[level] * align(height, TILE_SIZE); + /* if img_stride * num_slices_faces > LP_MAX_TEXTURE_SIZE */ + if (lpr->img_stride[level] > + LP_MAX_TEXTURE_SIZE / lpr->num_slices_faces[level]) { + /* volume too large */ + goto fail; + } - lpr->tiles_per_row[level] = width_t; - lpr->tiles_per_image[level] = width_t * height_t; - lpr->num_slices_faces[level] = num_slices; - lpr->layout[level] = alloc_layout_array(num_slices, width, height); + total_size += (uint64_t) lpr->num_slices_faces[level] + * (uint64_t) lpr->img_stride[level]; + if (total_size > LP_MAX_TEXTURE_SIZE) { + goto fail; + } + /* Compute size of next mipmap level */ width = u_minify(width, 1); height = u_minify(height, 1); depth = u_minify(depth, 1); } return TRUE; + +fail: + return FALSE; } +/** + * Check the size of the texture specified by 'res'. + * \return TRUE if OK, FALSE if too large. + */ +static boolean +llvmpipe_can_create_resource(struct pipe_screen *screen, + const struct pipe_resource *res) +{ + struct llvmpipe_resource lpr; + memset(&lpr, 0, sizeof(lpr)); + lpr.base = *res; + return llvmpipe_texture_layout(llvmpipe_screen(screen), &lpr); +} + static boolean llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, @@ -149,18 +190,12 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, /* Round up the surface size to a multiple of the tile size to * avoid tile clipping. */ - const unsigned width = align(lpr->base.width0, TILE_SIZE); - const unsigned height = align(lpr->base.height0, TILE_SIZE); - const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; - const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; + const unsigned width = MAX2(1, align(lpr->base.width0, TILE_SIZE)); + const unsigned height = MAX2(1, align(lpr->base.height0, TILE_SIZE)); - lpr->tiles_per_row[0] = width_t; - lpr->tiles_per_image[0] = width_t * height_t; lpr->num_slices_faces[0] = 1; lpr->img_stride[0] = 0; - lpr->layout[0] = alloc_layout_array(1, width, height); - lpr->dt = winsys->displaytarget_create(winsys, lpr->base.bind, lpr->base.format, @@ -168,7 +203,20 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, 16, &lpr->row_stride[0] ); - return lpr->dt != NULL; + if (lpr->dt == NULL) + return FALSE; + + { + void *map = winsys->displaytarget_map(winsys, lpr->dt, + PIPE_TRANSFER_WRITE); + + if (map) + memset(map, 0, height * lpr->row_stride[0]); + + winsys->displaytarget_unmap(winsys, lpr->dt); + } + + return TRUE; } @@ -176,7 +224,6 @@ static struct pipe_resource * llvmpipe_resource_create(struct pipe_screen *_screen, const struct pipe_resource *templat) { - static unsigned id_counter = 0; struct llvmpipe_screen *screen = llvmpipe_screen(_screen); struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource); if (!lpr) @@ -186,42 +233,52 @@ llvmpipe_resource_create(struct pipe_screen *_screen, pipe_reference_init(&lpr->base.reference, 1); lpr->base.screen = &screen->base; - assert(lpr->base.bind); + /* assert(lpr->base.bind); */ - if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { - /* displayable surface */ - if (!llvmpipe_displaytarget_layout(screen, lpr)) - goto fail; - assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); - } - else if (lpr->base.bind & (PIPE_BIND_SAMPLER_VIEW | - PIPE_BIND_DEPTH_STENCIL)) { - /* texture map */ - if (!llvmpipe_texture_layout(screen, lpr)) - goto fail; - assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); + if (llvmpipe_resource_is_texture(&lpr->base)) { + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_SCANOUT | + PIPE_BIND_SHARED)) { + /* displayable surface */ + if (!llvmpipe_displaytarget_layout(screen, lpr)) + goto fail; + } + else { + /* texture map */ + if (!llvmpipe_texture_layout(screen, lpr)) + goto fail; + } } else { /* other data (vertex buffer, const buffer, etc) */ - const enum pipe_format format = templat->format; - const uint w = templat->width0 / util_format_get_blockheight(format); - const uint h = templat->height0 / util_format_get_blockwidth(format); - const uint d = templat->depth0; - const uint bpp = util_format_get_blocksize(format); - const uint bytes = w * h * d * bpp; - lpr->data = align_malloc(bytes, 16); + const uint bytes = templat->width0; + assert(util_format_get_blocksize(templat->format) == 1); + assert(templat->height0 == 1); + assert(templat->depth0 == 1); + assert(templat->last_level == 0); + /* + * Reserve some extra storage since if we'd render to a buffer we + * read/write always LP_RASTER_BLOCK_SIZE pixels, but the element + * offset doesn't need to be aligned to LP_RASTER_BLOCK_SIZE. + */ + lpr->data = align_malloc(bytes + (LP_RASTER_BLOCK_SIZE - 1) * 4 * sizeof(float), 16); + /* + * buffers don't really have stride but it's probably safer + * (for code doing same calculations for buffers and textures) + * to put something sane in there. + */ + lpr->row_stride[0] = bytes; if (!lpr->data) goto fail; - } - - if (resource_is_texture(&lpr->base)) { - assert(lpr->layout[0]); + memset(lpr->data, 0, bytes); } lpr->id = id_counter++; +#ifdef DEBUG + insert_at_tail(&resource_list, lpr); +#endif + return &lpr->base; fail: @@ -232,7 +289,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen, static void llvmpipe_resource_destroy(struct pipe_screen *pscreen, - struct pipe_resource *pt) + struct pipe_resource *pt) { struct llvmpipe_screen *screen = llvmpipe_screen(pscreen); struct llvmpipe_resource *lpr = llvmpipe_resource(pt); @@ -242,30 +299,11 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, struct sw_winsys *winsys = screen->winsys; winsys->displaytarget_destroy(winsys, lpr->dt); } - else if (resource_is_texture(pt)) { - /* regular texture */ - uint level; - + else if (llvmpipe_resource_is_texture(pt)) { /* free linear image data */ - for (level = 0; level < Elements(lpr->linear); level++) { - if (lpr->linear[level].data) { - align_free(lpr->linear[level].data); - lpr->linear[level].data = NULL; - } - } - - /* free tiled image data */ - for (level = 0; level < Elements(lpr->tiled); level++) { - if (lpr->tiled[level].data) { - align_free(lpr->tiled[level].data); - lpr->tiled[level].data = NULL; - } - } - - /* free layout flag arrays */ - for (level = 0; level < Elements(lpr->tiled); level++) { - free(lpr->layout[level]); - lpr->layout[level] = NULL; + if (lpr->linear_img.data) { + align_free(lpr->linear_img.data); + lpr->linear_img.data = NULL; } } else if (!lpr->userBuffer) { @@ -273,6 +311,11 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, align_free(lpr->data); } +#ifdef DEBUG + if (lpr->next) + remove_from_list(lpr); +#endif + FREE(lpr); } @@ -282,26 +325,20 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, */ void * llvmpipe_resource_map(struct pipe_resource *resource, - unsigned face, - unsigned level, - unsigned zslice, - enum lp_texture_usage tex_usage, - enum lp_texture_layout layout) + unsigned level, + unsigned layer, + enum lp_texture_usage tex_usage) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); uint8_t *map; - assert(face < 6); assert(level < LP_MAX_TEXTURE_LEVELS); + assert(layer < (u_minify(resource->depth0, level) + resource->array_size - 1)); assert(tex_usage == LP_TEX_USAGE_READ || tex_usage == LP_TEX_USAGE_READ_WRITE || tex_usage == LP_TEX_USAGE_WRITE_ALL); - assert(layout == LP_TEX_LAYOUT_NONE || - layout == LP_TEX_LAYOUT_TILED || - layout == LP_TEX_LAYOUT_LINEAR); - if (lpr->dt) { /* display target */ struct llvmpipe_screen *screen = llvmpipe_screen(resource->screen); @@ -315,34 +352,20 @@ llvmpipe_resource_map(struct pipe_resource *resource, dt_usage = PIPE_TRANSFER_READ_WRITE; } - assert(face == 0); assert(level == 0); - assert(zslice == 0); + assert(layer == 0); /* FIXME: keep map count? */ map = winsys->displaytarget_map(winsys, lpr->dt, dt_usage); /* install this linear image in texture data structure */ - lpr->linear[level].data = map; - - map = llvmpipe_get_texture_image(lpr, face + zslice, level, - tex_usage, layout); - assert(map); + lpr->linear_img.data = map; return map; } - else if (resource_is_texture(resource)) { - /* regular texture */ - if (resource->target != PIPE_TEXTURE_CUBE) { - assert(face == 0); - } - if (resource->target != PIPE_TEXTURE_3D) { - assert(zslice == 0); - } + else if (llvmpipe_resource_is_texture(resource)) { - map = llvmpipe_get_texture_image(lpr, face + zslice, level, - tex_usage, layout); - assert(map); + map = llvmpipe_get_texture_image(lpr, layer, level, tex_usage); return map; } else { @@ -356,9 +379,8 @@ llvmpipe_resource_map(struct pipe_resource *resource, */ void llvmpipe_resource_unmap(struct pipe_resource *resource, - unsigned face, unsigned level, - unsigned zslice) + unsigned layer) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); @@ -367,14 +389,8 @@ llvmpipe_resource_unmap(struct pipe_resource *resource, struct llvmpipe_screen *lp_screen = llvmpipe_screen(resource->screen); struct sw_winsys *winsys = lp_screen->winsys; - assert(face == 0); assert(level == 0); - assert(zslice == 0); - - /* make sure linear image is up to date */ - (void) llvmpipe_get_texture_image(lpr, face + zslice, level, - LP_TEX_USAGE_READ, - LP_TEX_LAYOUT_LINEAR); + assert(layer == 0); winsys->displaytarget_unmap(winsys, lpr->dt); } @@ -386,10 +402,7 @@ llvmpipe_resource_data(struct pipe_resource *resource) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); - assert((lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED | - PIPE_BIND_SAMPLER_VIEW)) == 0); + assert(!llvmpipe_resource_is_texture(resource)); return lpr->data; } @@ -397,29 +410,54 @@ llvmpipe_resource_data(struct pipe_resource *resource) static struct pipe_resource * llvmpipe_resource_from_handle(struct pipe_screen *screen, - const struct pipe_resource *template, - struct winsys_handle *whandle) + const struct pipe_resource *template, + struct winsys_handle *whandle) { struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys; - struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource); - if (!lpr) - return NULL; + struct llvmpipe_resource *lpr; + + /* XXX Seems like from_handled depth textures doesn't work that well */ + + lpr = CALLOC_STRUCT(llvmpipe_resource); + if (!lpr) { + goto no_lpr; + } lpr->base = *template; pipe_reference_init(&lpr->base.reference, 1); lpr->base.screen = screen; + /* + * Looks like unaligned displaytargets work just fine, + * at least sampler/render ones. + */ +#if 0 + assert(lpr->base.width0 == width); + assert(lpr->base.height0 == height); +#endif + + lpr->num_slices_faces[0] = 1; + lpr->img_stride[0] = 0; + lpr->dt = winsys->displaytarget_from_handle(winsys, template, whandle, &lpr->row_stride[0]); - if (!lpr->dt) - goto fail; + if (!lpr->dt) { + goto no_dt; + } + + lpr->id = id_counter++; + +#ifdef DEBUG + insert_at_tail(&resource_list, lpr); +#endif return &lpr->base; - fail: +no_dt: FREE(lpr); +no_lpr: return NULL; } @@ -440,101 +478,74 @@ llvmpipe_resource_get_handle(struct pipe_screen *screen, } -static struct pipe_surface * -llvmpipe_get_tex_surface(struct pipe_screen *screen, - struct pipe_resource *pt, - unsigned face, unsigned level, unsigned zslice, - enum lp_texture_usage usage) -{ - struct pipe_surface *ps; - - assert(level <= pt->last_level); - - ps = CALLOC_STRUCT(pipe_surface); - if (ps) { - pipe_reference_init(&ps->reference, 1); - pipe_resource_reference(&ps->texture, pt); - ps->format = pt->format; - ps->width = u_minify(pt->width0, level); - ps->height = u_minify(pt->height0, level); - ps->usage = usage; - - ps->face = face; - ps->level = level; - ps->zslice = zslice; - } - return ps; -} - - -static void -llvmpipe_tex_surface_destroy(struct pipe_surface *surf) -{ - /* 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(surf->texture); - pipe_resource_reference(&surf->texture, NULL); - FREE(surf); -} - - -static struct pipe_transfer * -llvmpipe_get_transfer(struct pipe_context *pipe, - struct pipe_resource *resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box) -{ - struct llvmpipe_resource *lprex = llvmpipe_resource(resource); - struct llvmpipe_transfer *lpr; - - assert(resource); - assert(sr.level <= resource->last_level); - - lpr = CALLOC_STRUCT(llvmpipe_transfer); - if (lpr) { - struct pipe_transfer *pt = &lpr->base; - pipe_resource_reference(&pt->resource, resource); - pt->box = *box; - pt->sr = sr; - pt->stride = lprex->row_stride[sr.level]; - pt->usage = usage; - - return pt; - } - return NULL; -} - - -static void -llvmpipe_transfer_destroy(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - /* Effectively do the texture_update work here - if texture images - * needed post-processing to put them into hardware layout, this is - * where it would happen. For llvmpipe, nothing to do. - */ - assert (transfer->resource); - pipe_resource_reference(&transfer->resource, NULL); - FREE(transfer); -} - - static void * llvmpipe_transfer_map( struct pipe_context *pipe, - struct pipe_transfer *transfer ) + struct 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_screen *screen = llvmpipe_screen(pipe->screen); + struct llvmpipe_resource *lpr = llvmpipe_resource(resource); + struct llvmpipe_transfer *lpt; + struct pipe_transfer *pt; ubyte *map; - struct llvmpipe_resource *lpr; enum pipe_format format; enum lp_texture_usage tex_usage; const char *mode; - assert(transfer->sr.face < 6); - assert(transfer->sr.level < LP_MAX_TEXTURE_LEVELS); + assert(resource); + assert(level <= resource->last_level); + + /* + * Transfers, like other pipe operations, must happen in order, so flush the + * context if necessary. + */ + if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { + boolean read_only = !(usage & PIPE_TRANSFER_WRITE); + boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK); + if (!llvmpipe_flush_resource(pipe, resource, + level, + read_only, + TRUE, /* cpu_access */ + do_not_block, + __FUNCTION__)) { + /* + * It would have blocked, but state tracker requested no to. + */ + assert(do_not_block); + return NULL; + } + } + + /* Check if we're mapping the current constant buffer */ + if ((usage & PIPE_TRANSFER_WRITE) && + (resource->bind & PIPE_BIND_CONSTANT_BUFFER)) { + unsigned i; + for (i = 0; i < Elements(llvmpipe->constants[PIPE_SHADER_FRAGMENT]); ++i) { + if (resource == llvmpipe->constants[PIPE_SHADER_FRAGMENT][i].buffer) { + /* constants may have changed */ + llvmpipe->dirty |= LP_NEW_CONSTANTS; + break; + } + } + } + + lpt = CALLOC_STRUCT(llvmpipe_transfer); + if (!lpt) + return NULL; + pt = &lpt->base; + pipe_resource_reference(&pt->resource, resource); + pt->box = *box; + pt->level = level; + pt->stride = lpr->row_stride[level]; + pt->layer_stride = lpr->img_stride[level]; + pt->usage = usage; + *transfer = pt; + + assert(level < LP_MAX_TEXTURE_LEVELS); /* printf("tex_transfer_map(%d, %d %d x %d of %d x %d, usage %d )\n", @@ -544,7 +555,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"; } @@ -554,47 +565,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; - /* - * Transfers, like other pipe operations, must happen in order, so flush the - * context if necessary. - */ - llvmpipe_flush_texture(pipe, - transfer->resource, - transfer->sr.face, - transfer->sr.level, - 0, /* flush_flags */ - !(transfer->usage & PIPE_TRANSFER_WRITE), /* read_only */ - TRUE, /* cpu_access */ - FALSE); /* do_not_flush */ - - map = llvmpipe_resource_map(transfer->resource, - transfer->sr.face, - transfer->sr.level, - transfer->box.z, - tex_usage, LP_TEX_LAYOUT_LINEAR); + map = llvmpipe_resource_map(resource, + level, + box->z, + tex_usage); /* 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; } @@ -607,30 +600,73 @@ llvmpipe_transfer_unmap(struct pipe_context *pipe, assert(transfer->resource); llvmpipe_resource_unmap(transfer->resource, - transfer->sr.face, - transfer->sr.level, - transfer->box.z); + 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); } -static unsigned int +unsigned int llvmpipe_is_resource_referenced( struct pipe_context *pipe, - struct pipe_resource *presource, - unsigned face, unsigned level) + struct pipe_resource *presource, + unsigned level) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); - if (presource->target == PIPE_BUFFER) - return PIPE_UNREFERENCED; - + /* + * XXX checking only resources with the right bind flags + * is unsafe since with opengl state tracker we can end up + * with resources bound to places they weren't supposed to be + * (buffers bound as sampler views is one possibility here). + */ + if (!(presource->bind & (PIPE_BIND_DEPTH_STENCIL | + PIPE_BIND_RENDER_TARGET | + PIPE_BIND_SAMPLER_VIEW))) + return LP_UNREFERENCED; + return lp_setup_is_resource_referenced(llvmpipe->setup, presource); } +/** + * Returns the largest possible alignment for a format in llvmpipe + */ +unsigned +llvmpipe_get_format_alignment( enum pipe_format format ) +{ + const struct util_format_description *desc = util_format_description(format); + unsigned size = 0; + unsigned bytes; + unsigned i; + + for (i = 0; i < desc->nr_channels; ++i) { + size += desc->channel[i].size; + } + + bytes = size / 8; + + if (!util_is_power_of_two(bytes)) { + bytes /= desc->nr_channels; + } + + if (bytes % 2 || bytes < 1) { + return 1; + } else { + return bytes; + } +} + /** * Create buffer which wraps user-space data. */ -static struct pipe_resource * +struct pipe_resource * llvmpipe_user_buffer_create(struct pipe_screen *screen, void *ptr, unsigned bytes, @@ -651,6 +687,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen, buffer->base.width0 = bytes; buffer->base.height0 = 1; buffer->base.depth0 = 1; + buffer->base.array_size = 1; buffer->userBuffer = TRUE; buffer->data = ptr; @@ -660,36 +697,12 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen, /** * Compute size (in bytes) need to store a texture image / mipmap level, - * for just one cube face or one 3D texture slice + * for just one cube face, one array layer or one 3D texture slice */ static unsigned -tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level, - enum lp_texture_layout layout) +tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level) { - const unsigned width = u_minify(lpr->base.width0, level); - const unsigned height = u_minify(lpr->base.height0, level); - - assert(layout == LP_TEX_LAYOUT_TILED || - layout == LP_TEX_LAYOUT_LINEAR); - - if (layout == LP_TEX_LAYOUT_TILED) { - /* for tiled layout, force a 32bpp format */ - const enum pipe_format format = PIPE_FORMAT_B8G8R8A8_UNORM; - const unsigned block_size = util_format_get_blocksize(format); - const unsigned nblocksy = - util_format_get_nblocksy(format, align(height, TILE_SIZE)); - const unsigned nblocksx = - util_format_get_nblocksx(format, align(width, TILE_SIZE)); - const unsigned buffer_size = block_size * nblocksy * nblocksx; - return buffer_size; - } - else { - const enum pipe_format format = lpr->base.format; - const unsigned nblocksy = - util_format_get_nblocksy(format, align(height, TILE_SIZE)); - const unsigned buffer_size = nblocksy * lpr->row_stride[level]; - return buffer_size; - } + return lpr->img_stride[level]; } @@ -698,301 +711,135 @@ tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level, * including all cube faces or 3D image slices */ static unsigned -tex_image_size(const struct llvmpipe_resource *lpr, unsigned level, - enum lp_texture_layout layout) +tex_image_size(const struct llvmpipe_resource *lpr, unsigned level) { - const unsigned buf_size = tex_image_face_size(lpr, level, layout); + const unsigned buf_size = tex_image_face_size(lpr, level); return buf_size * lpr->num_slices_faces[level]; } /** - * This function encapsulates some complicated logic for determining - * how to convert a tile of image data from linear layout to tiled - * layout, or vice versa. - * \param cur_layout the current tile layout - * \param target_layout the desired tile layout - * \param usage how the tile will be accessed (R/W vs. read-only, etc) - * \param new_layout_return returns the new layout mode - * \param convert_return returns TRUE if image conversion is needed + * Return pointer to a 2D texture image/face/slice. + * No tiled/linear conversion is done. */ -static void -layout_logic(enum lp_texture_layout cur_layout, - enum lp_texture_layout target_layout, - enum lp_texture_usage usage, - enum lp_texture_layout *new_layout_return, - boolean *convert) +ubyte * +llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr, + unsigned face_slice, unsigned level) { - enum lp_texture_layout other_layout, new_layout; - - *convert = FALSE; - - new_layout = 99; /* debug check */ - - if (target_layout == LP_TEX_LAYOUT_LINEAR) { - other_layout = LP_TEX_LAYOUT_TILED; - } - else { - assert(target_layout == LP_TEX_LAYOUT_TILED); - other_layout = LP_TEX_LAYOUT_LINEAR; - } + struct llvmpipe_texture_image *img; + unsigned offset; - new_layout = target_layout; /* may get changed below */ + img = &lpr->linear_img; + offset = lpr->linear_mip_offsets[level]; - if (cur_layout == LP_TEX_LAYOUT_BOTH) { - if (usage == LP_TEX_USAGE_READ) { - new_layout = LP_TEX_LAYOUT_BOTH; - } - } - else if (cur_layout == other_layout) { - if (usage != LP_TEX_USAGE_WRITE_ALL) { - /* need to convert tiled data to linear or vice versa */ - *convert = TRUE; + if (face_slice > 0) + offset += face_slice * tex_image_face_size(lpr, level); - if (usage == LP_TEX_USAGE_READ) - new_layout = LP_TEX_LAYOUT_BOTH; - } - } - else { - assert(cur_layout == LP_TEX_LAYOUT_NONE || - cur_layout == target_layout); - } - - assert(new_layout == LP_TEX_LAYOUT_BOTH || - new_layout == target_layout); - - *new_layout_return = new_layout; + return (ubyte *) img->data + offset; } /** - * Return pointer to a texture image. No tiled/linear conversion is done. + * Allocate storage for a linear image + * (all cube faces and all 3D slices, all levels). */ -void * -llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr, - unsigned face, unsigned level, - enum lp_texture_layout layout) +static void +alloc_image_data(struct llvmpipe_resource *lpr) { - struct llvmpipe_texture_image *img; - unsigned face_offset; + uint alignment = MAX2(16, util_cpu_caps.cacheline); + uint level; + uint offset = 0; - if (layout == LP_TEX_LAYOUT_LINEAR) { - img = &lpr->linear[level]; + if (lpr->dt) { + /* we get the linear memory from the winsys, and it has + * already been zeroed + */ + struct llvmpipe_screen *screen = llvmpipe_screen(lpr->base.screen); + struct sw_winsys *winsys = screen->winsys; + + assert(lpr->base.last_level == 0); + + lpr->linear_img.data = + winsys->displaytarget_map(winsys, lpr->dt, + PIPE_TRANSFER_READ_WRITE); } else { - assert (layout == LP_TEX_LAYOUT_TILED); - img = &lpr->tiled[level]; + /* not a display target - allocate regular memory */ + /* + * Offset calculation for start of a specific mip/layer is always + * offset = lpr->linear_mip_offsets[level] + lpr->img_stride[level] * layer + */ + for (level = 0; level <= lpr->base.last_level; level++) { + uint buffer_size = tex_image_size(lpr, level); + lpr->linear_mip_offsets[level] = offset; + offset += align(buffer_size, alignment); + } + lpr->linear_img.data = align_malloc(offset, alignment); + if (lpr->linear_img.data) { + memset(lpr->linear_img.data, 0, offset); + } } - - if (face > 0) - face_offset = face * tex_image_face_size(lpr, level, layout); - else - face_offset = 0; - - return (ubyte *) img->data + face_offset; } -static INLINE enum lp_texture_layout -llvmpipe_get_texture_tile_layout(const struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level, - unsigned x, unsigned y) -{ - uint i; - assert(resource_is_texture(&lpr->base)); - assert(x < lpr->tiles_per_row[level]); - i = face_slice * lpr->tiles_per_image[level] - + y * lpr->tiles_per_row[level] + x; - return lpr->layout[level][i]; -} - - -static INLINE void -llvmpipe_set_texture_tile_layout(struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level, - unsigned x, unsigned y, - enum lp_texture_layout layout) -{ - uint i; - assert(resource_is_texture(&lpr->base)); - assert(x < lpr->tiles_per_row[level]); - i = face_slice * lpr->tiles_per_image[level] - + y * lpr->tiles_per_row[level] + x; - lpr->layout[level][i] = layout; -} - - -/** - * Set the layout mode for all tiles in a particular image. - */ -static INLINE void -llvmpipe_set_texture_image_layout(struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level, - unsigned width_t, unsigned height_t, - enum lp_texture_layout layout) -{ - const unsigned start = face_slice * lpr->tiles_per_image[level]; - unsigned i; - - for (i = 0; i < width_t * height_t; i++) { - lpr->layout[level][start + i] = layout; - } -} - /** - * Return pointer to texture image data (either linear or tiled layout) + * Return pointer to texture image data * for a particular cube face or 3D texture slice. * * \param face_slice the cube face or 3D slice of interest * \param usage one of LP_TEX_USAGE_READ/WRITE_ALL/READ_WRITE - * \param layout either LP_TEX_LAYOUT_LINEAR or _TILED or _NONE */ void * llvmpipe_get_texture_image(struct llvmpipe_resource *lpr, unsigned face_slice, unsigned level, - enum lp_texture_usage usage, - enum lp_texture_layout layout) + enum lp_texture_usage usage) { - /* - * 'target' refers to the image which we're retrieving (either in - * tiled or linear layout). - * 'other' refers to the same image but in the other layout. (it may - * or may not exist. - */ struct llvmpipe_texture_image *target_img; - struct llvmpipe_texture_image *other_img; void *target_data; - void *other_data; - const unsigned width = u_minify(lpr->base.width0, level); - const unsigned height = u_minify(lpr->base.height0, level); - const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; - const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; - enum lp_texture_layout other_layout; - boolean only_allocate; - - assert(layout == LP_TEX_LAYOUT_NONE || - layout == LP_TEX_LAYOUT_TILED || - layout == LP_TEX_LAYOUT_LINEAR); + unsigned target_offset; + unsigned *target_off_ptr; assert(usage == LP_TEX_USAGE_READ || usage == LP_TEX_USAGE_READ_WRITE || usage == LP_TEX_USAGE_WRITE_ALL); - /* check for the special case of layout == LP_TEX_LAYOUT_NONE */ - if (layout == LP_TEX_LAYOUT_NONE) { - only_allocate = TRUE; - layout = LP_TEX_LAYOUT_TILED; - } - else { - only_allocate = FALSE; - } - if (lpr->dt) { - assert(lpr->linear[level].data); - } - - /* which is target? which is other? */ - if (layout == LP_TEX_LAYOUT_LINEAR) { - target_img = &lpr->linear[level]; - other_img = &lpr->tiled[level]; - other_layout = LP_TEX_LAYOUT_TILED; - } - else { - target_img = &lpr->tiled[level]; - other_img = &lpr->linear[level]; - other_layout = LP_TEX_LAYOUT_LINEAR; + assert(lpr->linear_img.data); } + target_img = &lpr->linear_img; + target_off_ptr = lpr->linear_mip_offsets; target_data = target_img->data; - other_data = other_img->data; if (!target_data) { /* allocate memory for the target image now */ - unsigned buffer_size = tex_image_size(lpr, level, layout); - target_img->data = align_malloc(buffer_size, 16); + alloc_image_data(lpr); target_data = target_img->data; } - if (face_slice > 0) { - unsigned target_offset, other_offset; + target_offset = target_off_ptr[level]; - target_offset = face_slice * tex_image_face_size(lpr, level, layout); - other_offset = face_slice * tex_image_face_size(lpr, level, other_layout); - if (target_data) { - target_data = (uint8_t *) target_data + target_offset; - } - if (other_data) { - other_data = (uint8_t *) other_data + other_offset; - } + if (face_slice > 0) { + target_offset += face_slice * tex_image_face_size(lpr, level); } - if (only_allocate) { - /* Just allocating tiled memory. Don't initialize it from the - * linear data if it exists. - */ - return target_data; + if (target_data) { + target_data = (uint8_t *) target_data + target_offset; } - if (other_data) { - /* may need to convert other data to the requested layout */ - enum lp_texture_layout new_layout; - unsigned x, y; - - /* loop over all image tiles, doing layout conversion where needed */ - for (y = 0; y < height_t; y++) { - for (x = 0; x < width_t; x++) { - enum lp_texture_layout cur_layout = - llvmpipe_get_texture_tile_layout(lpr, face_slice, level, x, y); - boolean convert; - - layout_logic(cur_layout, layout, usage, &new_layout, &convert); - - if (convert) { - if (layout == LP_TEX_LAYOUT_TILED) { - lp_linear_to_tiled(other_data, target_data, - x * TILE_SIZE, y * TILE_SIZE, - TILE_SIZE, TILE_SIZE, - lpr->base.format, - lpr->row_stride[level]); - } - else { - lp_tiled_to_linear(other_data, target_data, - x * TILE_SIZE, y * TILE_SIZE, - TILE_SIZE, TILE_SIZE, - lpr->base.format, - lpr->row_stride[level]); - } - } - - llvmpipe_set_texture_tile_layout(lpr, face_slice, level, x, y, - new_layout); - } - } - } - else { - /* no other data */ - llvmpipe_set_texture_image_layout(lpr, face_slice, level, - width_t, height_t, layout); - } - - assert(target_data); - return target_data; } /** * Return pointer to start of a texture image (1D, 2D, 3D, CUBE). - * All cube faces and 3D slices will be converted to the requested - * layout if needed. * This is typically used when we're about to sample from a texture. */ void * llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr, unsigned level, - enum lp_texture_usage usage, - enum lp_texture_layout layout) + enum lp_texture_usage usage) { const int slices = lpr->num_slices_faces[level]; int slice; @@ -1001,7 +848,7 @@ llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr, assert(slices > 0); for (slice = slices - 1; slice >= 0; slice--) { - map = llvmpipe_get_texture_image(lpr, slice, level, usage, layout); + map = llvmpipe_get_texture_image(lpr, slice, level, usage); } return map; @@ -1009,51 +856,7 @@ llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr, /** - * Return pointer to start of linear data for a particular 2D texture - * image/face/slice. - */ -static uint8_t * -get_linear_image_address(struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level) -{ - struct llvmpipe_texture_image *linear_img = &lpr->linear[level]; - - if (face_slice > 0) { - unsigned linear_offset = - face_slice * tex_image_face_size(lpr, level, LP_TEX_LAYOUT_LINEAR); - return (uint8_t *) linear_img->data + linear_offset; - } - else { - return (uint8_t *) linear_img->data; - } -} - - -/** - * Return pointer to start of tiled data for a particular 2D texture - * image/face/slice. - */ -static uint8_t * -get_tiled_image_address(struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level) -{ - struct llvmpipe_texture_image *tiled_img = &lpr->tiled[level]; - - if (face_slice > 0) { - unsigned tiled_offset = - face_slice * tex_image_face_size(lpr, level, LP_TEX_LAYOUT_TILED); - return (uint8_t *) tiled_img->data + tiled_offset; - } - else { - return (uint8_t *) tiled_img->data; - } -} - - -/** - * Get pointer to a linear image (not the tile!) where the tile at (x,y) - * is known to be in linear layout. - * Conversion from tiled to linear will be done if necessary. + * Get pointer to a linear image (not the tile!) at tile (x,y). * \return pointer to start of image/face (not the tile) */ ubyte * @@ -1062,129 +865,101 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr, enum lp_texture_usage usage, unsigned x, unsigned y) { - struct llvmpipe_texture_image *linear_img = &lpr->linear[level]; - enum lp_texture_layout cur_layout, new_layout; - const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE; - boolean convert; - uint8_t *tiled_image, *linear_image; + struct llvmpipe_texture_image *linear_img = &lpr->linear_img; + uint8_t *linear_image; - assert(resource_is_texture(&lpr->base)); + assert(llvmpipe_resource_is_texture(&lpr->base)); assert(x % TILE_SIZE == 0); assert(y % TILE_SIZE == 0); if (!linear_img->data) { - /* allocate memory for the tiled image now */ - unsigned buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR); - linear_img->data = align_malloc(buffer_size, 16); + /* allocate memory for the linear image now */ + /* XXX should probably not do that here? */ + alloc_image_data(lpr); } + assert(linear_img->data); /* compute address of the slice/face of the image that contains the tile */ - tiled_image = get_tiled_image_address(lpr, face_slice, level); - linear_image = get_linear_image_address(lpr, face_slice, level); - - - cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty); - - layout_logic(cur_layout, LP_TEX_LAYOUT_LINEAR, usage, - &new_layout, &convert); - - if (convert) { - lp_tiled_to_linear(tiled_image, linear_image, - x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); - } - - if (new_layout != cur_layout) - llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout); + linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level); return linear_image; } /** - * Get pointer to tiled data for rendering. - * \return pointer to the tiled data at the given tile position + * Return size of resource in bytes */ -ubyte * -llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr, - unsigned face_slice, unsigned level, - enum lp_texture_usage usage, - unsigned x, unsigned y) +unsigned +llvmpipe_resource_size(const struct pipe_resource *resource) { - const unsigned width = u_minify(lpr->base.width0, level); - struct llvmpipe_texture_image *tiled_img = &lpr->tiled[level]; - enum lp_texture_layout cur_layout, new_layout; - const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE; - boolean convert; - uint8_t *tiled_image, *linear_image; - - assert(x % TILE_SIZE == 0); - assert(y % TILE_SIZE == 0); + const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource); + unsigned lvl, size = 0; - if (!tiled_img->data) { - /* allocate memory for the tiled image now */ - unsigned buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_TILED); - tiled_img->data = align_malloc(buffer_size, 16); + if (llvmpipe_resource_is_texture(resource)) { + for (lvl = 0; lvl <= lpr->base.last_level; lvl++) { + if (lpr->linear_img.data) + size += tex_image_size(lpr, lvl); + } } - - /* compute address of the slice/face of the image that contains the tile */ - tiled_image = get_tiled_image_address(lpr, face_slice, level); - linear_image = get_linear_image_address(lpr, face_slice, level); - - /* get current tile layout and see if we need to convert the data */ - cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty); - - layout_logic(cur_layout, LP_TEX_LAYOUT_TILED, usage, &new_layout, &convert); - if (convert) { - lp_linear_to_tiled(linear_image, tiled_image, - x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + else { + size = resource->width0; } - if (new_layout != cur_layout) - llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout); - - /* compute, return address of the 64x64 tile */ - { - unsigned tiles_per_row, tile_offset; - - tiles_per_row = align(width, TILE_SIZE) / TILE_SIZE; - - assert(tiles_per_row == lpr->tiles_per_row[level]); + return size; +} - tile_offset = ty * tiles_per_row + tx; - tile_offset *= TILE_SIZE * TILE_SIZE * 4; - assert(tiled_img->data); +#ifdef DEBUG +void +llvmpipe_print_resources(void) +{ + struct llvmpipe_resource *lpr; + unsigned n = 0, total = 0; - return (ubyte *) tiled_image + tile_offset; + debug_printf("LLVMPIPE: current resources:\n"); + foreach(lpr, &resource_list) { + unsigned size = llvmpipe_resource_size(&lpr->base); + debug_printf("resource %u at %p, size %ux%ux%u: %u bytes, refcount %u\n", + lpr->id, (void *) lpr, + lpr->base.width0, lpr->base.height0, lpr->base.depth0, + size, lpr->base.reference.count); + total += size; + n++; } + debug_printf("LLVMPIPE: total size of %u resources: %u\n", n, total); } +#endif void llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen) { +#ifdef DEBUG + /* init linked list for tracking resources */ + { + static boolean first_call = TRUE; + if (first_call) { + memset(&resource_list, 0, sizeof(resource_list)); + make_empty_list(&resource_list); + first_call = FALSE; + } + } +#endif + screen->resource_create = llvmpipe_resource_create; screen->resource_destroy = llvmpipe_resource_destroy; screen->resource_from_handle = llvmpipe_resource_from_handle; screen->resource_get_handle = llvmpipe_resource_get_handle; - screen->user_buffer_create = llvmpipe_user_buffer_create; - - screen->get_tex_surface = llvmpipe_get_tex_surface; - screen->tex_surface_destroy = llvmpipe_tex_surface_destroy; + screen->can_create_resource = llvmpipe_can_create_resource; } 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; - pipe->is_resource_referenced = llvmpipe_is_resource_referenced; - + pipe->transfer_flush_region = u_default_transfer_flush_region; pipe->transfer_inline_write = u_default_transfer_inline_write; }