2 * Copyright 2008 Ben Skeggs
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #include "nv50_context.h"
24 #include "pipe/p_defines.h"
25 #include "pipe/p_winsys.h"
26 #include "pipe/p_inlines.h"
28 #include "util/u_tile.h"
31 nv50_surface_copy(struct pipe_context
*pipe
, boolean flip
,
32 struct pipe_surface
*dest
, unsigned destx
, unsigned desty
,
33 struct pipe_surface
*src
, unsigned srcx
, unsigned srcy
,
34 unsigned width
, unsigned height
)
36 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
37 struct nouveau_winsys
*nvws
= nv50
->screen
->nvws
;
42 nvws
->surface_copy(nvws
, dest
, destx
, desty
--, src
,
43 srcx
, srcy
++, width
, 1);
46 nvws
->surface_copy(nvws
, dest
, destx
, desty
, src
, srcx
, srcy
,
52 nv50_surface_fill(struct pipe_context
*pipe
, struct pipe_surface
*dest
,
53 unsigned destx
, unsigned desty
, unsigned width
,
54 unsigned height
, unsigned value
)
56 struct nv50_context
*nv50
= (struct nv50_context
*)pipe
;
57 struct nouveau_winsys
*nvws
= nv50
->screen
->nvws
;
59 nvws
->surface_fill(nvws
, dest
, destx
, desty
, width
, height
, value
);
63 nv50_surface_map(struct pipe_screen
*screen
, struct pipe_surface
*ps
,
66 struct nouveau_winsys
*nvws
= nv50_screen(screen
)->nvws
;
67 struct pipe_winsys
*ws
= screen
->winsys
;
68 struct nv50_surface
*s
= nv50_surface(ps
);
69 struct nv50_surface m
= *s
;
73 s
->untiled
= ws
->buffer_create(ws
, 0, 0, ps
->buffer
->size
);
75 m
.base
.buffer
= s
->untiled
;
76 nvws
->surface_copy(nvws
, &m
.base
, 0, 0, &s
->base
, 0, 0,
77 ps
->width
, ps
->height
);
80 /* Map original tiled surface to disallow it being validated while
81 * untiled mirror is mapped.
83 ws
->buffer_map(ws
, ps
->buffer
, flags
);
85 map
= ws
->buffer_map(ws
, s
->untiled
, flags
);
93 nv50_surface_unmap(struct pipe_screen
*pscreen
, struct pipe_surface
*ps
)
95 struct nouveau_winsys
*nvws
= nv50_screen(pscreen
)->nvws
;
96 struct pipe_winsys
*ws
= pscreen
->winsys
;
97 struct nv50_surface
*s
= nv50_surface(ps
);
98 struct nv50_surface m
= *s
;
100 ws
->buffer_unmap(ws
, s
->untiled
);
101 ws
->buffer_unmap(ws
, ps
->buffer
);
103 m
.base
.buffer
= s
->untiled
;
104 nvws
->surface_copy(nvws
, &s
->base
, 0, 0, &m
.base
, 0, 0,
105 ps
->width
, ps
->height
);
107 pipe_buffer_reference(pscreen
, &s
->untiled
, NULL
);
111 nv50_init_surface_functions(struct nv50_context
*nv50
)
113 nv50
->pipe
.surface_copy
= nv50_surface_copy
;
114 nv50
->pipe
.surface_fill
= nv50_surface_fill
;
118 nv50_surface_init_screen_functions(struct pipe_screen
*pscreen
)
120 pscreen
->surface_map
= nv50_surface_map
;
121 pscreen
->surface_unmap
= nv50_surface_unmap
;