for (slice = 0; slice < dst_box->depth; slice++) {
const struct ilo_texture_slice *dst_slice =
- &dst->slice_offsets[dst_level][dst_box->z + slice];
+ ilo_texture_get_slice(dst, dst_level, dst_box->z + slice);
unsigned x1, y1, x2, y2;
x1 = dst_slice->x + dst_box->x;
for (slice = 0; slice < src_box->depth; slice++) {
const struct ilo_texture_slice *dst_slice =
- &dst->slice_offsets[dst_level][dst_z + slice];
+ ilo_texture_get_slice(dst, dst_level, dst_z + slice);
const struct ilo_texture_slice *src_slice =
- &src->slice_offsets[src_level][src_box->z + slice];
+ ilo_texture_get_slice(src, src_level, src_box->z + slice);
unsigned x1, y1, x2, y2, src_x, src_y;
x1 = (dst_slice->x + dst_x) * xscale;
static void
tex_free_slices(struct ilo_texture *tex)
{
- FREE(tex->slice_offsets[0]);
+ FREE(tex->slices[0]);
}
static bool
if (!slices)
return false;
- tex->slice_offsets[0] = slices;
+ tex->slices[0] = slices;
/* point to the respective positions in the buffer */
for (lv = 1; lv <= templ->last_level; lv++) {
- tex->slice_offsets[lv] = tex->slice_offsets[lv - 1] +
+ tex->slices[lv] = tex->slices[lv - 1] +
u_minify(templ->depth0, lv - 1) * templ->array_size;
}
PIPE_BIND_RENDER_TARGET))
tex->bo_flags |= INTEL_ALLOC_FOR_RENDER;
- tex_layout_init(&layout, screen, templ, tex->slice_offsets);
+ tex_layout_init(&layout, screen, templ, tex->slices);
switch (templ->target) {
case PIPE_TEXTURE_1D:
*/
unsigned
ilo_texture_get_slice_offset(const struct ilo_texture *tex,
- int level, int slice,
+ unsigned level, unsigned slice,
unsigned *x_offset, unsigned *y_offset)
{
+ const struct ilo_texture_slice *s =
+ ilo_texture_get_slice(tex, level, slice);
unsigned tile_w, tile_h, tile_size, row_size;
unsigned x, y, slice_offset;
row_size = tex->bo_stride * tile_h;
/* in bytes */
- x = tex->slice_offsets[level][slice].x / tex->block_width * tex->bo_cpp;
- y = tex->slice_offsets[level][slice].y / tex->block_height;
+ x = s->x / tex->block_width * tex->bo_cpp;
+ y = s->y / tex->block_height;
slice_offset = row_size * (y / tile_h) + tile_size * (x / tile_w);
/*
unsigned bo_flags;
};
+/**
+ * A 3D image slice, cube face, or array layer.
+ */
+struct ilo_texture_slice {
+ /* 2D offset to the slice */
+ unsigned x, y;
+};
+
struct ilo_texture {
struct pipe_resource base;
/* true if samples are interleaved */
bool interleaved;
- /* 2D offsets into a layer/slice/face */
- struct ilo_texture_slice {
- unsigned x;
- unsigned y;
- } *slice_offsets[PIPE_MAX_TEXTURE_LEVELS];
+ struct ilo_texture_slice *slices[PIPE_MAX_TEXTURE_LEVELS];
struct ilo_texture *separate_s8;
bool
ilo_texture_alloc_bo(struct ilo_texture *tex);
+static inline struct ilo_texture_slice *
+ilo_texture_get_slice(const struct ilo_texture *tex,
+ unsigned level, unsigned slice)
+{
+ assert(level <= tex->base.last_level);
+ assert(slice < ((tex->base.target == PIPE_TEXTURE_3D) ?
+ u_minify(tex->base.depth0, level) : tex->base.array_size));
+
+ return &tex->slices[level][slice];
+}
+
unsigned
ilo_texture_get_slice_offset(const struct ilo_texture *tex,
- int level, int slice,
+ unsigned level, unsigned slice,
unsigned *x_offset, unsigned *y_offset);
#endif /* ILO_RESOURCE_H */
const struct pipe_box *box,
unsigned *mem_x, unsigned *mem_y)
{
+ const struct ilo_texture_slice *s =
+ ilo_texture_get_slice(tex, level, slice + box->z);
unsigned x, y;
- x = tex->slice_offsets[level][slice + box->z].x + box->x;
- y = tex->slice_offsets[level][slice + box->z].y + box->y;
+ x = s->x + box->x;
+ y = s->y + box->y;
assert(x % tex->block_width == 0 && y % tex->block_height == 0);
static unsigned
tex_get_slice_stride(const struct ilo_texture *tex, unsigned level)
{
+ const struct ilo_texture_slice *s0, *s1;
unsigned qpitch;
/* there is no 3D array texture */
}
}
- qpitch = tex->slice_offsets[level][1].y - tex->slice_offsets[level][0].y;
+ s0 = ilo_texture_get_slice(tex, level, 0);
+ s1 = ilo_texture_get_slice(tex, level, 1);
+ qpitch = s1->y - s0->y;
assert(qpitch % tex->block_height == 0);
return (qpitch / tex->block_height) * tex->bo_stride;