u_transfer.h revision 4c7001462607e6e99e474d6271dd481d3f8f201c
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
10struct pipe_context;
11struct winsys_handle;
12
13boolean u_default_resource_get_handle(struct pipe_screen *screen,
14                                      struct pipe_resource *resource,
15                                      struct winsys_handle *handle);
16
17void 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
26void u_default_transfer_flush_region( struct pipe_context *pipe,
27                                      struct pipe_transfer *transfer,
28                                      const struct pipe_box *box);
29
30unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
31                                           struct pipe_resource *resource,
32                                           unsigned level, int layer);
33
34struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
35                                              struct pipe_resource *resource,
36                                              unsigned level,
37                                              unsigned usage,
38                                              const struct pipe_box *box);
39
40void u_default_transfer_unmap( struct pipe_context *pipe,
41                               struct pipe_transfer *transfer );
42
43void u_default_transfer_destroy(struct pipe_context *pipe,
44                                struct pipe_transfer *transfer);
45
46
47
48/* Useful helper to allow >1 implementation of resource functionality
49 * to exist in a single driver.  This is intended to be transitionary!
50 */
51struct u_resource_vtbl {
52
53   boolean (*resource_get_handle)(struct pipe_screen *,
54                                  struct pipe_resource *tex,
55                                  struct winsys_handle *handle);
56
57   void (*resource_destroy)(struct pipe_screen *,
58                            struct pipe_resource *pt);
59
60   unsigned (*is_resource_referenced)(struct pipe_context *pipe,
61                                      struct pipe_resource *texture,
62                                      unsigned level, int layer);
63
64   struct pipe_transfer *(*get_transfer)(struct pipe_context *,
65                                         struct pipe_resource *resource,
66                                         unsigned level,
67                                         unsigned usage,
68                                         const struct pipe_box *);
69
70   void (*transfer_destroy)(struct pipe_context *,
71                            struct pipe_transfer *);
72
73   void *(*transfer_map)( struct pipe_context *,
74                          struct pipe_transfer *transfer );
75
76   void (*transfer_flush_region)( struct pipe_context *,
77                                  struct pipe_transfer *transfer,
78                                  const struct pipe_box *);
79
80   void (*transfer_unmap)( struct pipe_context *,
81   struct pipe_transfer *transfer );
82
83   void (*transfer_inline_write)( struct pipe_context *pipe,
84                                  struct pipe_resource *resource,
85                                  unsigned level,
86                                  unsigned usage,
87                                  const struct pipe_box *box,
88                                  const void *data,
89                                  unsigned stride,
90                                  unsigned layer_stride);
91};
92
93
94struct u_resource {
95   struct pipe_resource b;
96   struct u_resource_vtbl *vtbl;
97};
98
99
100boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
101                                   struct pipe_resource *resource,
102                                   struct winsys_handle *handle);
103
104void u_resource_destroy_vtbl(struct pipe_screen *screen,
105                             struct pipe_resource *resource);
106
107unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
108                                        struct pipe_resource *resource,
109                                        unsigned level, int layer);
110
111struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
112                                          struct pipe_resource *resource,
113                                          unsigned level,
114                                          unsigned usage,
115                                          const struct pipe_box *box);
116
117void u_transfer_destroy_vtbl(struct pipe_context *pipe,
118                             struct pipe_transfer *transfer);
119
120void *u_transfer_map_vtbl( struct pipe_context *pipe,
121                           struct pipe_transfer *transfer );
122
123void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
124                                   struct pipe_transfer *transfer,
125                                   const struct pipe_box *box);
126
127void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
128                            struct pipe_transfer *transfer );
129
130void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
131                                   struct pipe_resource *resource,
132                                   unsigned level,
133                                   unsigned usage,
134                                   const struct pipe_box *box,
135                                   const void *data,
136                                   unsigned stride,
137                                   unsigned layer_stride);
138
139
140
141
142
143
144
145
146#endif
147