Merge branch 'radeon-texrewrite-clean' into mesa_7_7_branch
[mesa.git] / src / gallium / drivers / svga / svga_pipe_blit.c
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26 #include "svga_screen_texture.h"
27 #include "svga_context.h"
28 #include "svga_cmd.h"
29
30 #define FILE_DEBUG_FLAG DEBUG_BLIT
31
32
33 static void svga_surface_copy(struct pipe_context *pipe,
34 struct pipe_surface *dest,
35 unsigned destx, unsigned desty,
36 struct pipe_surface *src,
37 unsigned srcx, unsigned srcy,
38 unsigned width, unsigned height)
39 {
40 struct svga_context *svga = svga_context(pipe);
41 SVGA3dCopyBox *box;
42 enum pipe_error ret;
43
44 svga_hwtnl_flush_retry( svga );
45
46 ret = SVGA3D_BeginSurfaceCopy(svga->swc,
47 src,
48 dest,
49 &box,
50 1);
51 if(ret != PIPE_OK) {
52
53 svga_context_flush(svga, NULL);
54
55 ret = SVGA3D_BeginSurfaceCopy(svga->swc,
56 src,
57 dest,
58 &box,
59 1);
60 assert(ret == PIPE_OK);
61 }
62
63 box->x = destx;
64 box->y = desty;
65 box->z = 0;
66 box->w = width;
67 box->h = height;
68 box->d = 1;
69 box->srcx = srcx;
70 box->srcy = srcy;
71 box->srcz = 0;
72
73 SVGA_FIFOCommitAll(svga->swc);
74
75 svga_surface(dest)->dirty = TRUE;
76 svga_propagate_surface(pipe, dest);
77 }
78
79
80 void
81 svga_init_blit_functions(struct svga_context *svga)
82 {
83 svga->pipe.surface_copy = svga_surface_copy;
84 }