case PIPE_BUFFER:
return FALSE;
case PIPE_TEXTURE_1D:
+ case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D:
+ case PIPE_TEXTURE_2D_ARRAY:
case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_3D:
case PIPE_TEXTURE_CUBE:
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 non-compressed formats we need to align the texture size
* to the tile size to facilitate render-to-texture.
+ * XXX this blows up 1d/1d array textures by unreasonable
+ * amount (factor 64), probably should do something about it.
*/
if (util_format_is_compressed(pt->format))
alignment = 1;
lpr->tiles_per_image[level] = width_t * height_t;
}
- /* Number of 3D image slices or cube faces */
+ /* Number of 3D image slices, cube faces or texture array layers */
{
unsigned num_slices;
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;
return lp_setup_is_resource_referenced(llvmpipe->setup, presource);
}
-boolean
-llvmpipe_is_format_unswizzled( enum pipe_format format )
-{
- const struct util_format_description *desc = util_format_description(format);
- unsigned chan;
-
- if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
- desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB ||
- desc->block.width != 1 ||
- desc->block.height != 1) {
- return FALSE;
- }
-
- for (chan = 0; chan < desc->nr_channels; ++chan) {
- if (desc->channel[chan].type == UTIL_FORMAT_TYPE_VOID && (chan + 1) == desc->nr_channels)
- continue;
-
- if (desc->channel[chan].type != desc->channel[0].type)
- return FALSE;
-
- if (desc->channel[chan].normalized != desc->channel[0].normalized)
- return FALSE;
-
- if (desc->channel[chan].pure_integer != desc->channel[0].pure_integer)
- return FALSE;
- }
-
- return TRUE;
-}
-
/**
* Returns the largest possible alignment for a format in llvmpipe
/**
* 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,
}
-/**
- * Get pointer to tiled data for rendering.
- * \return pointer to the tiled data at the given tile position
- */
-void
-llvmpipe_unswizzle_cbuf_tile(struct llvmpipe_resource *lpr,
- unsigned face_slice, unsigned level,
- unsigned x, unsigned y,
- uint8_t *tile)
-{
- struct llvmpipe_texture_image *linear_img = &lpr->linear_img;
- const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE;
- uint8_t *linear_image;
-
- assert(x % TILE_SIZE == 0);
- assert(y % TILE_SIZE == 0);
-
- if (!linear_img->data) {
- /* allocate memory for the linear image now */
- alloc_image_data(lpr, LP_TEX_LAYOUT_LINEAR);
- }
-
- /* compute address of the slice/face of the image that contains the tile */
- linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
- LP_TEX_LAYOUT_LINEAR);
-
- {
- uint ii = x, jj = y;
- uint tile_offset = jj / TILE_SIZE + ii / TILE_SIZE;
- uint byte_offset = tile_offset * TILE_SIZE * TILE_SIZE * 4;
-
- /* Note that lp_tiled_to_linear expects the tile parameter to
- * point at the first tile in a whole-image sized array. In
- * this code, we have only a single tile and have to do some
- * pointer arithmetic to figure out where the "image" would have
- * started.
- */
- lp_tiled_to_linear(tile - byte_offset, linear_image,
- x, y, TILE_SIZE, TILE_SIZE,
- lpr->base.format,
- lpr->row_stride[level],
- 1); /* tiles per row */
- }
-
- llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty,
- LP_TEX_LAYOUT_LINEAR);
-}
-
-
-/**
- * Get pointer to tiled data for rendering.
- * \return pointer to the tiled data at the given tile position
- */
-void
-llvmpipe_swizzle_cbuf_tile(struct llvmpipe_resource *lpr,
- unsigned face_slice, unsigned level,
- unsigned x, unsigned y,
- uint8_t *tile)
-{
- uint8_t *linear_image;
-
- assert(x % TILE_SIZE == 0);
- assert(y % TILE_SIZE == 0);
-
- /* compute address of the slice/face of the image that contains the tile */
- linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
- LP_TEX_LAYOUT_LINEAR);
-
- if (linear_image) {
- uint ii = x, jj = y;
- uint tile_offset = jj / TILE_SIZE + ii / TILE_SIZE;
- uint byte_offset = tile_offset * TILE_SIZE * TILE_SIZE * 4;
-
- /* Note that lp_linear_to_tiled expects the tile parameter to
- * point at the first tile in a whole-image sized array. In
- * this code, we have only a single tile and have to do some
- * pointer arithmetic to figure out where the "image" would have
- * started.
- */
- lp_linear_to_tiled(linear_image, tile - byte_offset,
- x, y, TILE_SIZE, TILE_SIZE,
- lpr->base.format,
- lpr->row_stride[level],
- 1); /* tiles per row */
- }
-}
-
-
/**
* Return size of resource in bytes
*/