[Mesa-dev] [PATCH 5/7] st/mesa: generalize fallback_copy_image for compressed textures
Marek Olšák
maraeo at gmail.com
Mon Jul 23 23:52:05 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
in order to support ASTC
---
src/mesa/state_tracker/st_cb_copyimage.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_copyimage.c b/src/mesa/state_tracker/st_cb_copyimage.c
index 5230b61877f..f5d8c047800 100644
--- a/src/mesa/state_tracker/st_cb_copyimage.c
+++ b/src/mesa/state_tracker/st_cb_copyimage.c
@@ -525,52 +525,57 @@ copy_image(struct pipe_context *pipe,
PIPE_FORMAT_R16G16_UNORM))
return;
/* Only allow non-identity swizzling on RGBA8 formats. */
/* Simple copy, memcpy with swizzling, no format conversion. */
swizzled_copy(pipe, dst, dst_level, dstx, dsty, dstz, src, src_level,
src_box);
}
-/* Note, the only allowable compressed format for this function is ETC */
static void
fallback_copy_image(struct st_context *st,
struct gl_texture_image *dst_image,
struct pipe_resource *dst_res,
int dst_x, int dst_y, int dst_z,
struct gl_texture_image *src_image,
struct pipe_resource *src_res,
int src_x, int src_y, int src_z,
int src_w, int src_h)
{
uint8_t *dst, *src;
int dst_stride, src_stride;
struct pipe_transfer *dst_transfer, *src_transfer;
unsigned line_bytes;
bool dst_is_compressed = dst_image && _mesa_is_format_compressed(dst_image->TexFormat);
bool src_is_compressed = src_image && _mesa_is_format_compressed(src_image->TexFormat);
+ unsigned dst_blk_w = 1, dst_blk_h = 1, src_blk_w = 1, src_blk_h = 1;
+ if (dst_image)
+ _mesa_get_format_block_size(dst_image->TexFormat, &dst_blk_w, &dst_blk_h);
+ if (src_image)
+ _mesa_get_format_block_size(src_image->TexFormat, &src_blk_w, &src_blk_h);
+
unsigned dst_w = src_w;
unsigned dst_h = src_h;
unsigned lines = src_h;
if (src_is_compressed && !dst_is_compressed) {
- dst_w = DIV_ROUND_UP(dst_w, 4);
- dst_h = DIV_ROUND_UP(dst_h, 4);
+ dst_w = DIV_ROUND_UP(dst_w, src_blk_w);
+ dst_h = DIV_ROUND_UP(dst_h, src_blk_h);
} else if (!src_is_compressed && dst_is_compressed) {
- dst_w *= 4;
- dst_h *= 4;
+ dst_w *= dst_blk_w;
+ dst_h *= dst_blk_h;
}
if (src_is_compressed) {
- lines = DIV_ROUND_UP(lines, 4);
+ lines = DIV_ROUND_UP(lines, src_blk_h);
}
if (src_image)
line_bytes = _mesa_format_row_stride(src_image->TexFormat, src_w);
else
line_bytes = _mesa_format_row_stride(dst_image->TexFormat, dst_w);
if (dst_image) {
st->ctx->Driver.MapTextureImage(
st->ctx, dst_image, dst_z,
--
2.17.1
More information about the mesa-dev
mailing list