OSDN Git Service

ab787abdce39fd861c197bab1c21832cbb87479b
[android-x86/external-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_buffer_subdata(struct pipe_context *pipe,
18                               struct pipe_resource *resource,
19                               unsigned usage, unsigned offset,
20                               unsigned size, const void *data);
21
22 void u_default_texture_subdata(struct pipe_context *pipe,
23                                struct pipe_resource *resource,
24                                unsigned level,
25                                unsigned usage,
26                                const struct pipe_box *box,
27                                const void *data,
28                                unsigned stride,
29                                unsigned layer_stride);
30
31 void u_default_transfer_flush_region( struct pipe_context *pipe,
32                                       struct pipe_transfer *transfer,
33                                       const struct pipe_box *box);
34
35 void u_default_transfer_unmap( struct pipe_context *pipe,
36                                struct pipe_transfer *transfer );
37
38
39
40 /* Useful helper to allow >1 implementation of resource functionality
41  * to exist in a single driver.  This is intended to be transitionary!
42  */
43 struct u_resource_vtbl {
44
45    boolean (*resource_get_handle)(struct pipe_screen *,
46                                   struct pipe_resource *tex,
47                                   struct winsys_handle *handle);
48
49    void (*resource_destroy)(struct pipe_screen *,
50                             struct pipe_resource *pt);
51
52    void *(*transfer_map)(struct pipe_context *,
53                          struct pipe_resource *resource,
54                          unsigned level,
55                          unsigned usage,
56                          const struct pipe_box *,
57                          struct pipe_transfer **);
58
59
60    void (*transfer_flush_region)( struct pipe_context *,
61                                   struct pipe_transfer *transfer,
62                                   const struct pipe_box *);
63
64    void (*transfer_unmap)( struct pipe_context *,
65                            struct pipe_transfer *transfer );
66 };
67
68
69 struct u_resource {
70    struct pipe_resource b;
71    const struct u_resource_vtbl *vtbl;
72 };
73
74
75 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
76                                    struct pipe_context *ctx,
77                                    struct pipe_resource *resource,
78                                    struct winsys_handle *handle,
79                                    unsigned usage);
80
81 void u_resource_destroy_vtbl(struct pipe_screen *screen,
82                              struct pipe_resource *resource);
83
84 void *u_transfer_map_vtbl(struct pipe_context *context,
85                           struct pipe_resource *resource,
86                           unsigned level,
87                           unsigned usage,
88                           const struct pipe_box *box,
89                           struct pipe_transfer **transfer);
90
91 void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
92                                    struct pipe_transfer *transfer,
93                                    const struct pipe_box *box);
94
95 void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
96                             struct pipe_transfer *transfer );
97
98 #endif