#include "lp_query.h"
-/**
- * Adjust x, y, width, height to lie on tile bounds.
- */
-static void
-adjust_to_tile_bounds(unsigned x, unsigned y, unsigned width, unsigned height,
- unsigned *x_tile, unsigned *y_tile,
- unsigned *w_tile, unsigned *h_tile)
-{
- *x_tile = x & ~(TILE_SIZE - 1);
- *y_tile = y & ~(TILE_SIZE - 1);
- *w_tile = ((x + width + TILE_SIZE - 1) & ~(TILE_SIZE - 1)) - *x_tile;
- *h_tile = ((y + height + TILE_SIZE - 1) & ~(TILE_SIZE - 1)) - *y_tile;
-}
-
-
-
static void
lp_resource_copy(struct pipe_context *pipe,
struct pipe_resource *dst, unsigned dst_level,
unsigned width = src_box->width;
unsigned height = src_box->height;
unsigned depth = src_box->depth;
- unsigned z;
llvmpipe_flush_resource(pipe,
dst, dst_level,
src_box->width, src_box->height, src_box->depth);
*/
- for (z = 0; z < src_box->depth; z++){
-
- /* set src tiles to linear layout */
- {
- unsigned tx, ty, tw, th;
- unsigned x, y;
+ /* make sure display target resources (which cannot have levels/layers) are mapped */
+ if (src_tex->dt)
+ (void) llvmpipe_resource_map(src, src_level, 0, LP_TEX_USAGE_READ);
+ if (dst_tex->dt)
+ /*
+ * Could set this to WRITE_ALL if complete dst is covered but it gets
+ * ignored anyway.
+ */
+ (void) llvmpipe_resource_map(dst, dst_level, 0, LP_TEX_USAGE_READ_WRITE);
- adjust_to_tile_bounds(src_box->x, src_box->y, width, height,
- &tx, &ty, &tw, &th);
-
- for (y = 0; y < th; y += TILE_SIZE) {
- for (x = 0; x < tw; x += TILE_SIZE) {
- (void) llvmpipe_get_texture_tile_linear(src_tex,
- src_box->z + z, src_level,
- LP_TEX_USAGE_READ,
- tx + x, ty + y);
- }
- }
- }
-
- /* set dst tiles to linear layout */
- {
- unsigned tx, ty, tw, th;
- unsigned x, y;
- enum lp_texture_usage usage;
-
- adjust_to_tile_bounds(dstx, dsty, width, height, &tx, &ty, &tw, &th);
-
- for (y = 0; y < th; y += TILE_SIZE) {
- boolean contained_y = ty + y >= dsty &&
- ty + y + TILE_SIZE <= dsty + height ?
- TRUE : FALSE;
-
- for (x = 0; x < tw; x += TILE_SIZE) {
- boolean contained_x = tx + x >= dstx &&
- tx + x + TILE_SIZE <= dstx + width ?
- TRUE : FALSE;
-
- /*
- * Set the usage mode to WRITE_ALL for the tiles which are
- * completely contained by the dest rectangle.
- */
- if (contained_y && contained_x)
- usage = LP_TEX_USAGE_WRITE_ALL;
- else
- usage = LP_TEX_USAGE_READ_WRITE;
-
- (void) llvmpipe_get_texture_tile_linear(dst_tex,
- dstz + z, dst_level,
- usage,
- tx + x, ty + y);
- }
- }
- }
- }
/* copy */
{
src_box->x, src_box->y, 0);
}
}
+
+ if (src_tex->dt)
+ llvmpipe_resource_unmap(src, 0, 0);
+ if (dst_tex->dt)
+ llvmpipe_resource_unmap(dst, 0, 0);
+
}
{
unsigned offset;
+ assert(llvmpipe_resource_is_texture(&lpr->base));
+
offset = lpr->mip_offsets[level];
if (face_slice > 0)
}
-/**
- * Get pointer to a linear image (not the tile!) at tile (x,y).
- * \return pointer to start of image/face (not the tile)
- */
-ubyte *
-llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
- unsigned face_slice, unsigned level,
- enum lp_texture_usage usage,
- unsigned x, unsigned y)
-{
- uint8_t *linear_image;
-
- assert(llvmpipe_resource_is_texture(&lpr->base));
- assert(x % TILE_SIZE == 0);
- assert(y % TILE_SIZE == 0);
-
- if (!lpr->tex_data) {
- /* allocate memory for the linear image now */
- /* XXX should probably not do that here? */
- alloc_image_data(lpr);
- }
- assert(lpr->tex_data);
-
- /* compute address of the slice/face of the image that contains the tile */
- linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level);
-
- return linear_image;
-}
-
-
/**
* Return size of resource in bytes
*/