This adds array (1d,2d) texture support to llvmpipe.
Though probably should do something about 1d array textures requiring gobs
of memory (this issue is not strictly limited to arrays but it is probably
worse there).
Initial code by Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
#define LP_MAX_TEXTURE_2D_LEVELS 14 /* 8K x 8K for now */
#define LP_MAX_TEXTURE_3D_LEVELS 11 /* 1K x 1K x 1K for now */
#define LP_MAX_TEXTURE_CUBE_LEVELS 13 /* 4K x 4K for now */
+#define LP_MAX_TEXTURE_ARRAY_LAYERS 512 /* 8K x 512 / 8K x 8K x 512 */
/** This must be the larger of LP_MAX_TEXTURE_2D/3D_LEVELS */
return LP_MAX_TEXTURE_3D_LEVELS;
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return LP_MAX_TEXTURE_CUBE_LEVELS;
+ case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
+ return LP_MAX_TEXTURE_ARRAY_LAYERS;
case PIPE_CAP_BLEND_EQUATION_SEPARATE:
return 1;
case PIPE_CAP_INDEP_BLEND_ENABLE:
return 1;
case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE:
return 1;
- case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
- return 0;
case PIPE_CAP_DEPTH_CLIP_DISABLE:
return 0;
case PIPE_CAP_SHADER_STENCIL_EXPORT:
assert(target == PIPE_BUFFER ||
target == PIPE_TEXTURE_1D ||
+ target == PIPE_TEXTURE_1D_ARRAY ||
target == PIPE_TEXTURE_2D ||
+ target == PIPE_TEXTURE_2D_ARRAY ||
target == PIPE_TEXTURE_RECT ||
target == PIPE_TEXTURE_3D ||
target == PIPE_TEXTURE_CUBE);
jit_tex = &setup->fs.current.jit_context.textures[i];
jit_tex->width = tex->width0;
jit_tex->height = tex->height0;
- jit_tex->depth = tex->depth0;
jit_tex->first_level = view->u.tex.first_level;
jit_tex->last_level = tex->last_level;
+ if (tex->target == PIPE_TEXTURE_3D) {
+ jit_tex->depth = tex->depth0;
+ }
+ else {
+ jit_tex->depth = tex->array_size;
+ }
+
/* We're referencing the texture's internal data, so save a
* reference to it.
*/
if (view) {
struct pipe_resource *tex = view->texture;
struct llvmpipe_resource *lp_tex = llvmpipe_resource(tex);
+ unsigned num_layers;
+
+ if (tex->target == PIPE_TEXTURE_3D) {
+ num_layers = tex->depth0;
+ }
+ else {
+ num_layers = tex->array_size;
+ }
/* We're referencing the texture's internal data, so save a
* reference to it.
draw_set_mapped_texture(lp->draw,
PIPE_SHADER_VERTEX,
i,
- tex->width0, tex->height0, tex->depth0,
+ tex->width0, tex->height0, num_layers,
view->u.tex.first_level, tex->last_level,
addr,
row_stride, img_stride, mip_offsets);
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;
/**
* 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,
/** Row stride in bytes */
unsigned row_stride[LP_MAX_TEXTURE_LEVELS];
- /** Image stride (for cube maps or 3D textures) in bytes */
+ /** Image stride (for cube maps, array or 3D textures) in bytes */
unsigned img_stride[LP_MAX_TEXTURE_LEVELS];
unsigned tiles_per_row[LP_MAX_TEXTURE_LEVELS];
unsigned tiles_per_image[LP_MAX_TEXTURE_LEVELS];