diff options
author | Axel Davy <[email protected]> | 2015-02-19 11:21:12 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2015-04-29 08:28:11 +0200 |
commit | 35fe920e1ec877d487e5dd33c9aea7e1ec1dbe11 (patch) | |
tree | 81d5fb39858295ed6655b13bad93744f67261d6f /src/gallium/state_trackers/nine/nine_pipe.h | |
parent | 54f8e8a18da58c85a2f515d5fd0552fa4f5547bb (diff) |
st/nine: Rework texture data allocation
Some applications assume the memory for multilevel
textures is allocated per continuous blocks.
This patch implements that behaviour.
v2: cache offsets
Reviewed-by: Ilia Mirkin <[email protected]>
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/nine_pipe.h')
-rw-r--r-- | src/gallium/state_trackers/nine/nine_pipe.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index b8e728eace9..1b88612f2cc 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -673,4 +673,45 @@ d3dtexturefiltertype_to_pipe_tex_mipfilter(D3DTEXTUREFILTERTYPE filter) } } +static INLINE unsigned nine_format_get_stride(enum pipe_format format, + unsigned width) +{ + unsigned stride = util_format_get_stride(format, width); + + return align(stride, 4); +} + +static INLINE unsigned nine_format_get_level_alloc_size(enum pipe_format format, + unsigned width, + unsigned height, + unsigned level) +{ + unsigned w, h, size; + + w = u_minify(width, level); + h = u_minify(height, level); + size = nine_format_get_stride(format, w) * + util_format_get_nblocksy(format, h); + return size; +} + +static INLINE unsigned nine_format_get_size_and_offsets(enum pipe_format format, + unsigned *offsets, + unsigned width, + unsigned height, + unsigned last_level) +{ + unsigned l, w, h, size = 0; + + for (l = 0; l <= last_level; ++l) { + w = u_minify(width, l); + h = u_minify(height, l); + offsets[l] = size; + size += nine_format_get_stride(format, w) * + util_format_get_nblocksy(format, h); + } + + return size; +} + #endif /* _NINE_PIPE_H_ */ |