Tizen 2.0 Release
[profile/ivi/osmesa.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 struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
31                                               struct pipe_resource *resource,
32                                               unsigned level,
33                                               unsigned usage,
34                                               const struct pipe_box *box);
35
36 void u_default_transfer_unmap( struct pipe_context *pipe,
37                                struct pipe_transfer *transfer );
38
39 void u_default_transfer_destroy(struct pipe_context *pipe,
40                                 struct pipe_transfer *transfer);
41
42
43
44 /* Useful helper to allow >1 implementation of resource functionality
45  * to exist in a single driver.  This is intended to be transitionary!
46  */
47 struct u_resource_vtbl {
48
49    boolean (*resource_get_handle)(struct pipe_screen *,
50                                   struct pipe_resource *tex,
51                                   struct winsys_handle *handle);
52
53    void (*resource_destroy)(struct pipe_screen *,
54                             struct pipe_resource *pt);
55
56    struct pipe_transfer *(*get_transfer)(struct pipe_context *,
57                                          struct pipe_resource *resource,
58                                          unsigned level,
59                                          unsigned usage,
60                                          const struct pipe_box *);
61
62    void (*transfer_destroy)(struct pipe_context *,
63                             struct pipe_transfer *);
64
65    void *(*transfer_map)( struct pipe_context *,
66                           struct pipe_transfer *transfer );
67
68    void (*transfer_flush_region)( struct pipe_context *,
69                                   struct pipe_transfer *transfer,
70                                   const struct pipe_box *);
71
72    void (*transfer_unmap)( struct pipe_context *,
73    struct pipe_transfer *transfer );
74
75    void (*transfer_inline_write)( struct pipe_context *pipe,
76                                   struct pipe_resource *resource,
77                                   unsigned level,
78                                   unsigned usage,
79                                   const struct pipe_box *box,
80                                   const void *data,
81                                   unsigned stride,
82                                   unsigned layer_stride);
83 };
84
85
86 struct u_resource {
87    struct pipe_resource b;
88    const struct u_resource_vtbl *vtbl;
89 };
90
91
92 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
93                                    struct pipe_resource *resource,
94                                    struct winsys_handle *handle);
95
96 void u_resource_destroy_vtbl(struct pipe_screen *screen,
97                              struct pipe_resource *resource);
98
99 struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
100                                           struct pipe_resource *resource,
101                                           unsigned level,
102                                           unsigned usage,
103                                           const struct pipe_box *box);
104
105 void u_transfer_destroy_vtbl(struct pipe_context *pipe,
106                              struct pipe_transfer *transfer);
107
108 void *u_transfer_map_vtbl( struct pipe_context *pipe,
109                            struct pipe_transfer *transfer );
110
111 void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
112                                    struct pipe_transfer *transfer,
113                                    const struct pipe_box *box);
114
115 void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
116                             struct pipe_transfer *transfer );
117
118 void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
119                                    struct pipe_resource *resource,
120                                    unsigned level,
121                                    unsigned usage,
122                                    const struct pipe_box *box,
123                                    const void *data,
124                                    unsigned stride,
125                                    unsigned layer_stride);
126
127 void u_default_redefine_user_buffer(struct pipe_context *ctx,
128                                     struct pipe_resource *resource,
129                                     unsigned offset,
130                                     unsigned size);
131
132 #endif