Rename ilo_texture::slice_offsets to ilo_texture::slices and add an accessor, ilo_texture_get_slice().tags/mesa-10.1-rc1
@@ -527,7 +527,7 @@ tex_clear_region(struct ilo_blitter *blitter, | |||
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; | |||
@@ -607,9 +607,9 @@ tex_copy_region(struct ilo_blitter *blitter, | |||
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; |
@@ -872,7 +872,7 @@ tex_layout_apply(const struct tex_layout *layout, struct ilo_texture *tex) | |||
static void | |||
tex_free_slices(struct ilo_texture *tex) | |||
{ | |||
FREE(tex->slice_offsets[0]); | |||
FREE(tex->slices[0]); | |||
} | |||
static bool | |||
@@ -896,11 +896,11 @@ tex_alloc_slices(struct ilo_texture *tex) | |||
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; | |||
} | |||
@@ -1104,7 +1104,7 @@ tex_create(struct pipe_screen *screen, | |||
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: | |||
@@ -1380,9 +1380,11 @@ ilo_texture_alloc_bo(struct ilo_texture *tex) | |||
*/ | |||
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; | |||
@@ -1419,8 +1421,8 @@ ilo_texture_get_slice_offset(const struct ilo_texture *tex, | |||
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); | |||
/* |
@@ -42,6 +42,14 @@ struct ilo_buffer { | |||
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; | |||
@@ -73,11 +81,7 @@ struct ilo_texture { | |||
/* 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; | |||
@@ -110,9 +114,20 @@ ilo_buffer_alloc_bo(struct ilo_buffer *buf); | |||
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 */ |
@@ -186,10 +186,12 @@ tex_get_box_origin(const struct ilo_texture *tex, | |||
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); | |||
@@ -211,6 +213,7 @@ tex_get_box_offset(const struct ilo_texture *tex, unsigned level, | |||
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 */ | |||
@@ -228,7 +231,9 @@ tex_get_slice_stride(const struct ilo_texture *tex, unsigned level) | |||
} | |||
} | |||
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; |