-/**
- * Get pointer to tiled data for rendering.
- * \return pointer to the tiled data at the given tile position
- */
-ubyte *
-llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr,
- unsigned face_slice, unsigned level,
- enum lp_texture_usage usage,
- unsigned x, unsigned y)
-{
- 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;
- unsigned tile_offset;
-
- assert(x % TILE_SIZE == 0);
- assert(y % TILE_SIZE == 0);
-
- if (!tiled_img->data) {
- /* allocate memory for the tiled image now */
- alloc_image_data(lpr, level, LP_TEX_LAYOUT_TILED);
- }
-
- /* compute address of the slice/face of the image that contains the tile */
- tiled_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
- LP_TEX_LAYOUT_TILED);
- linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
- LP_TEX_LAYOUT_LINEAR);
-
- /* 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 && linear_image && tiled_image) {
- lp_linear_to_tiled(linear_image, tiled_image,
- x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
- lpr->row_stride[level],
- lpr->tiles_per_row[level]);
- }
-
- if (!tiled_image)
- return NULL;
-
- 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 */
- tile_offset = (ty * lpr->tiles_per_row[level] + tx)
- * TILE_SIZE * TILE_SIZE * 4;
-
- return (ubyte *) tiled_image + tile_offset;
-}
-
-