Use write posting in the kickoff function too.
[mesa.git] / src / mesa / pipe / nv40 / nv40_region.c
1 #include "pipe/p_defines.h"
2 #include "pipe/p_winsys.h"
3
4 #include "nv40_context.h"
5 #include "nv40_dma.h"
6
7 static ubyte *
8 nv40_region_map(struct pipe_context *pipe, struct pipe_region *region)
9 {
10 struct nv40_context *nv40 = (struct nv40_context *)pipe;
11 struct pipe_winsys *ws = nv40->pipe.winsys;
12
13 if (!region->map_refcount++) {
14 region->map = ws->buffer_map(ws, region->buffer,
15 PIPE_BUFFER_FLAG_WRITE |
16 PIPE_BUFFER_FLAG_READ);
17 }
18
19 return region->map;
20 }
21
22 static void
23 nv40_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
24 {
25 struct nv40_context *nv40 = (struct nv40_context *)pipe;
26 struct pipe_winsys *ws = nv40->pipe.winsys;
27
28 if (!--region->map_refcount) {
29 ws->buffer_unmap(ws, region->buffer);
30 region->map = NULL;
31 }
32 }
33
34 static void
35 nv40_region_data(struct pipe_context *pipe,
36 struct pipe_region *dst,
37 unsigned dst_offset,
38 unsigned dstx, unsigned dsty,
39 const void *src, unsigned src_pitch,
40 unsigned srcx, unsigned srcy, unsigned width, unsigned height)
41 {
42 struct nv40_context *nv40 = (struct nv40_context *)pipe;
43 struct nouveau_winsys *nvws = nv40->nvws;
44
45 nvws->region_data(nvws->nv, dst, dst_offset, dstx, dsty,
46 src, src_pitch, srcx, srcy, width, height);
47 }
48
49
50 static void
51 nv40_region_copy(struct pipe_context *pipe, struct pipe_region *dst,
52 unsigned dst_offset, unsigned dstx, unsigned dsty,
53 struct pipe_region *src, unsigned src_offset,
54 unsigned srcx, unsigned srcy, unsigned width, unsigned height)
55 {
56 struct nv40_context *nv40 = (struct nv40_context *)pipe;
57 struct nouveau_winsys *nvws = nv40->nvws;
58
59 nvws->region_copy(nvws->nv, dst, dst_offset, dstx, dsty,
60 src, src_offset, srcx, srcy, width, height);
61 }
62
63 static void
64 nv40_region_fill(struct pipe_context *pipe,
65 struct pipe_region *dst, unsigned dst_offset,
66 unsigned dstx, unsigned dsty,
67 unsigned width, unsigned height, unsigned value)
68 {
69 struct nv40_context *nv40 = (struct nv40_context *)pipe;
70 struct nouveau_winsys *nvws = nv40->nvws;
71
72 nvws->region_fill(nvws->nv, dst, dst_offset, dstx, dsty,
73 width, height, value);
74 }
75
76 void
77 nv40_init_region_functions(struct nv40_context *nv40)
78 {
79 nv40->pipe.region_map = nv40_region_map;
80 nv40->pipe.region_unmap = nv40_region_unmap;
81 nv40->pipe.region_data = nv40_region_data;
82 nv40->pipe.region_copy = nv40_region_copy;
83 nv40->pipe.region_fill = nv40_region_fill;
84 }
85