diff options
author | Chia-I Wu <[email protected]> | 2013-12-26 11:46:25 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-01-08 18:11:35 +0800 |
commit | 846f70a6ef8be5297eb6f4cf9cf8dc36ce22b818 (patch) | |
tree | 27d0bb62cfc54415cc43b179b98e00e8e3474bb6 /src/gallium/drivers | |
parent | 127fbc086ba9365e9304843af09fe730edb1d389 (diff) |
ilo: rename and add an accessor for texture slices
Rename ilo_texture::slice_offsets to ilo_texture::slices and add an accessor,
ilo_texture_get_slice().
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_blt.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.h | 27 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_transfer.c | 11 |
4 files changed, 41 insertions, 19 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c index 4e501f14bf1..dba84b0b747 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_blt.c +++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index beb3584249a..c0d9ae49457 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -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); /* diff --git a/src/gallium/drivers/ilo/ilo_resource.h b/src/gallium/drivers/ilo/ilo_resource.h index 1f82c9fab68..d23622af9f3 100644 --- a/src/gallium/drivers/ilo/ilo_resource.h +++ b/src/gallium/drivers/ilo/ilo_resource.h @@ -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 */ diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c index 7d87537e99f..4bd688d5c73 100644 --- a/src/gallium/drivers/ilo/ilo_transfer.c +++ b/src/gallium/drivers/ilo/ilo_transfer.c @@ -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; |