660dc161d33b01ed65ee91955fef4f8111959760
[mesa.git] / src / gallium / auxiliary / util / u_transfer.h
1
2 #ifndef U_TRANSFER_H
3 #define U_TRANSFER_H
4
5 /* Fallback implementations for inline read/writes which just go back
6 * to the regular transfer behaviour.
7 */
8 #include "pipe/p_state.h"
9
10 struct pipe_context;
11 struct winsys_handle;
12
13 boolean u_default_resource_get_handle(struct pipe_screen *screen,
14 struct pipe_resource *resource,
15 struct winsys_handle *handle);
16
17 void u_default_transfer_inline_write( struct pipe_context *pipe,
18 struct pipe_resource *resource,
19 unsigned level,
20 unsigned usage,
21 const struct pipe_box *box,
22 const void *data,
23 unsigned stride,
24 unsigned layer_stride);
25
26 void u_default_transfer_flush_region( struct pipe_context *pipe,
27 struct pipe_transfer *transfer,
28 const struct pipe_box *box);
29
30 void u_default_transfer_unmap( struct pipe_context *pipe,
31 struct pipe_transfer *transfer );
32
33
34
35 /* Useful helper to allow >1 implementation of resource functionality
36 * to exist in a single driver. This is intended to be transitionary!
37 */
38 struct u_resource_vtbl {
39
40 boolean (*resource_get_handle)(struct pipe_screen *,
41 struct pipe_resource *tex,
42 struct winsys_handle *handle);
43
44 void (*resource_destroy)(struct pipe_screen *,
45 struct pipe_resource *pt);
46
47 void *(*transfer_map)(struct pipe_context *,
48 struct pipe_resource *resource,
49 unsigned level,
50 unsigned usage,
51 const struct pipe_box *,
52 struct pipe_transfer **);
53
54
55 void (*transfer_flush_region)( struct pipe_context *,
56 struct pipe_transfer *transfer,
57 const struct pipe_box *);
58
59 void (*transfer_unmap)( struct pipe_context *,
60 struct pipe_transfer *transfer );
61
62 void (*transfer_inline_write)( struct pipe_context *pipe,
63 struct pipe_resource *resource,
64 unsigned level,
65 unsigned usage,
66 const struct pipe_box *box,
67 const void *data,
68 unsigned stride,
69 unsigned layer_stride);
70 };
71
72
73 struct u_resource {
74 struct pipe_resource b;
75 const struct u_resource_vtbl *vtbl;
76 };
77
78
79 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
80 struct pipe_resource *resource,
81 struct winsys_handle *handle,
82 unsigned usage);
83
84 void u_resource_destroy_vtbl(struct pipe_screen *screen,
85 struct pipe_resource *resource);
86
87 void *u_transfer_map_vtbl(struct pipe_context *context,
88 struct pipe_resource *resource,
89 unsigned level,
90 unsigned usage,
91 const struct pipe_box *box,
92 struct pipe_transfer **transfer);
93
94 void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
95 struct pipe_transfer *transfer,
96 const struct pipe_box *box);
97
98 void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
99 struct pipe_transfer *transfer );
100
101 void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
102 struct pipe_resource *resource,
103 unsigned level,
104 unsigned usage,
105 const struct pipe_box *box,
106 const void *data,
107 unsigned stride,
108 unsigned layer_stride);
109
110 #endif