+ struct r300_context* r300 = r300_context(pipe);
+ struct r300_textures_state* state =
+ (struct r300_textures_state*)r300->textures_state.state;
+
+ /* Yeah we have to save all those states to ensure this blitter operation
+ * is really transparent. The states will be restored by the blitter once
+ * copying is done. */
+ r300_blitter_save_states(r300);
+ util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state);
+
+ util_blitter_save_fragment_sampler_states(
+ r300->blitter, state->sampler_state_count,
+ (void**)state->sampler_states);
+
+ util_blitter_save_fragment_sampler_views(
+ r300->blitter, state->sampler_view_count,
+ (struct pipe_sampler_view**)state->sampler_views);
+
+ /* Do a copy */
+ util_blitter_copy(r300->blitter,
+ dst, dstx, dsty, src, srcx, srcy, width, height, TRUE);
+}
+
+/* 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;
+
+ if (dst->texture->format != src->texture->format) {
+ debug_printf("r300: Implementation error: Format mismatch in %s\n"
+ " : src: %s dst: %s\n", __FUNCTION__,
+ util_format_short_name(src->texture->format),
+ util_format_short_name(dst->texture->format));
+ debug_assert(0);
+ }
+
+ if (!pipe->screen->is_format_supported(pipe->screen,
+ old_format, src->texture->target,
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_SAMPLER_VIEW, 0) &&
+ util_format_is_plain(old_format)) {
+ 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_short_name(old_format));
+ }