+/* Copy a block of pixels from one surface to another. */
+void r300_surface_copy(struct pipe_context* pipe,
+ struct pipe_surface* dst,
+ unsigned dstx, unsigned dsty,
+ struct pipe_surface* src,
+ unsigned srcx, unsigned srcy,
+ unsigned width, unsigned height)
+{
+ enum pipe_format old_format = dst->texture->format;
+ enum pipe_format new_format = old_format;
+
+ assert(dst->texture->format == src->texture->format);
+
+ if (!pipe->screen->is_format_supported(pipe->screen,
+ old_format, src->texture->target,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ switch (util_format_get_blocksize(old_format)) {
+ case 1:
+ new_format = PIPE_FORMAT_I8_UNORM;
+ break;
+ case 2:
+ new_format = PIPE_FORMAT_B4G4R4A4_UNORM;
+ break;
+ case 4:
+ new_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+ case 8:
+ new_format = PIPE_FORMAT_R16G16B16A16_UNORM;
+ break;
+ default:
+ debug_printf("r300: surface_copy: Unhandled format: %s. Falling back to software.\n"
+ "r300: surface_copy: Software fallback doesn't work for tiled textures.\n",
+ util_format_name(old_format));
+ }
+ }
+
+ if (old_format != new_format) {
+ dst->format = new_format;
+ src->format = new_format;
+
+ r300_texture_reinterpret_format(pipe->screen,
+ dst->texture, new_format);
+ r300_texture_reinterpret_format(pipe->screen,
+ src->texture, new_format);
+ }
+
+ r300_hw_copy(pipe, dst, dstx, dsty, src, srcx, srcy, width, height);
+
+ if (old_format != new_format) {
+ dst->format = old_format;
+ src->format = old_format;
+
+ r300_texture_reinterpret_format(pipe->screen,
+ dst->texture, old_format);
+ r300_texture_reinterpret_format(pipe->screen,
+ src->texture, old_format);
+ }
+}
+