aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_transfer.h
blob: 3412e13c3ccc9641b6e9ab718f444e83d286915e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

#ifndef U_TRANSFER_H
#define U_TRANSFER_H

/* Fallback implementations for inline read/writes which just go back
 * to the regular transfer behaviour.
 */
#include "pipe/p_state.h"

struct pipe_context;
struct winsys_handle;

boolean u_default_resource_get_handle(struct pipe_screen *screen,
                                      struct pipe_resource *resource,
                                      struct winsys_handle *handle);

void u_default_transfer_inline_write( struct pipe_context *pipe,
                                      struct pipe_resource *resource,
                                      unsigned level,
                                      unsigned usage,
                                      const struct pipe_box *box,
                                      const void *data,
                                      unsigned stride,
                                      unsigned layer_stride);

void u_default_transfer_flush_region( struct pipe_context *pipe,
                                      struct pipe_transfer *transfer,
                                      const struct pipe_box *box);

unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
                                           struct pipe_resource *resource,
                                           unsigned level, int layer);

struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
                                              struct pipe_resource *resource,
                                              unsigned level,
                                              unsigned usage,
                                              const struct pipe_box *box);

void u_default_transfer_unmap( struct pipe_context *pipe,
                               struct pipe_transfer *transfer );

void u_default_transfer_destroy(struct pipe_context *pipe,
                                struct pipe_transfer *transfer);



/* Useful helper to allow >1 implementation of resource functionality
 * to exist in a single driver.  This is intended to be transitionary!
 */
struct u_resource_vtbl {

   boolean (*resource_get_handle)(struct pipe_screen *,
                                  struct pipe_resource *tex,
                                  struct winsys_handle *handle);

   void (*resource_destroy)(struct pipe_screen *,
                            struct pipe_resource *pt);

   unsigned (*is_resource_referenced)(struct pipe_context *pipe,
                                      struct pipe_resource *texture,
                                      unsigned level, int layer);

   struct pipe_transfer *(*get_transfer)(struct pipe_context *,
                                         struct pipe_resource *resource,
                                         unsigned level,
                                         unsigned usage,
                                         const struct pipe_box *);

   void (*transfer_destroy)(struct pipe_context *,
                            struct pipe_transfer *);

   void *(*transfer_map)( struct pipe_context *,
                          struct pipe_transfer *transfer );

   void (*transfer_flush_region)( struct pipe_context *,
                                  struct pipe_transfer *transfer,
                                  const struct pipe_box *);

   void (*transfer_unmap)( struct pipe_context *,
   struct pipe_transfer *transfer );

   void (*transfer_inline_write)( struct pipe_context *pipe,
                                  struct pipe_resource *resource,
                                  unsigned level,
                                  unsigned usage,
                                  const struct pipe_box *box,
                                  const void *data,
                                  unsigned stride,
                                  unsigned layer_stride);
};


struct u_resource {
   struct pipe_resource b;
   struct u_resource_vtbl *vtbl;
};


boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
                                   struct pipe_resource *resource,
                                   struct winsys_handle *handle);

void u_resource_destroy_vtbl(struct pipe_screen *screen,
                             struct pipe_resource *resource);

unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
                                        struct pipe_resource *resource,
                                        unsigned level, int layer);

struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
                                          struct pipe_resource *resource,
                                          unsigned level,
                                          unsigned usage,
                                          const struct pipe_box *box);

void u_transfer_destroy_vtbl(struct pipe_context *pipe,
                             struct pipe_transfer *transfer);

void *u_transfer_map_vtbl( struct pipe_context *pipe,
                           struct pipe_transfer *transfer );

void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
                                   struct pipe_transfer *transfer,
                                   const struct pipe_box *box);

void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
                            struct pipe_transfer *transfer );

void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
                                   struct pipe_resource *resource,
                                   unsigned level,
                                   unsigned usage,
                                   const struct pipe_box *box,
                                   const void *data,
                                   unsigned stride,
                                   unsigned layer_stride);








#endif