diff options
author | Marek Olšák <[email protected]> | 2011-02-10 11:20:05 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-02-10 11:27:35 +0100 |
commit | fea4ad8f6629cdc83fcffe0db455bba186fb1b1a (patch) | |
tree | 1343c50a3c227fceb98380bb8590598e777b6f46 /src/gallium/drivers/r300/r300_blit.c | |
parent | 7c24a4c6a86402be1f68d23f4d52d4d071957801 (diff) |
r300g: implement accelerated copy_region for compressed formats
Diffstat (limited to 'src/gallium/drivers/r300/r300_blit.c')
-rw-r--r-- | src/gallium/drivers/r300/r300_blit.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 3fa1504ecd9..14c9794888c 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -418,6 +418,7 @@ static void r300_resource_copy_region(struct pipe_context *pipe, struct pipe_resource new_dst = old_dst; const struct util_format_description *desc = util_format_description(dst->format); + struct pipe_box box; if (r300->zmask_in_use && !r300->zmask_locked) { if (fb->zsbuf->texture == src || @@ -429,6 +430,7 @@ static void r300_resource_copy_region(struct pipe_context *pipe, } } + /* Handle non-renderable plain formats. */ if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN && (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB || !pipe->screen->is_format_supported(pipe->screen, @@ -460,6 +462,33 @@ static void r300_resource_copy_region(struct pipe_context *pipe, new_src.format = new_dst.format; } + /* Handle compressed formats. */ + if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { + switch (util_format_get_blocksize(old_dst.format)) { + case 8: + /* 1 pixel = 4 bits, + * we set 1 pixel = 2 bytes ===> 4 times larger pixels. */ + new_dst.format = PIPE_FORMAT_B4G4R4A4_UNORM; + break; + case 16: + /* 1 pixel = 8 bits, + * we set 1 pixel = 4 bytes ===> 4 times larger pixels. */ + new_dst.format = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + } + + /* Since the pixels are 4 times larger, we must decrease + * the image size and the coordinates 4 times. */ + new_src.format = new_dst.format; + new_dst.height0 /= 4; + new_src.height0 /= 4; + dsty /= 4; + box = *src_box; + box.y /= 4; + box.height /= 4; + src_box = &box; + } + if (old_src.format != new_src.format) r300_resource_set_properties(pipe->screen, src, 0, &new_src); if (old_dst.format != new_dst.format) |