gallium: WIP: Introduce sampler views.
[mesa.git] / src / gallium / drivers / identity / id_objects.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef ID_OBJECTS_H
29 #define ID_OBJECTS_H
30
31
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_video_state.h"
35
36 #include "id_screen.h"
37
38
39 struct identity_buffer
40 {
41 struct pipe_buffer base;
42
43 struct pipe_buffer *buffer;
44 };
45
46
47 struct identity_texture
48 {
49 struct pipe_texture base;
50
51 struct pipe_texture *texture;
52 };
53
54
55 struct identity_sampler_view
56 {
57 struct pipe_sampler_view base;
58
59 struct pipe_sampler_view *sampler_view;
60 };
61
62
63 struct identity_surface
64 {
65 struct pipe_surface base;
66
67 struct pipe_surface *surface;
68 };
69
70
71 struct identity_transfer
72 {
73 struct pipe_transfer base;
74
75 struct pipe_transfer *transfer;
76 };
77
78
79 struct identity_video_surface
80 {
81 struct pipe_video_surface base;
82
83 struct pipe_video_surface *video_surface;
84 };
85
86
87 static INLINE struct identity_buffer *
88 identity_buffer(struct pipe_buffer *_buffer)
89 {
90 if(!_buffer)
91 return NULL;
92 (void)identity_screen(_buffer->screen);
93 return (struct identity_buffer *)_buffer;
94 }
95
96 static INLINE struct identity_texture *
97 identity_texture(struct pipe_texture *_texture)
98 {
99 if(!_texture)
100 return NULL;
101 (void)identity_screen(_texture->screen);
102 return (struct identity_texture *)_texture;
103 }
104
105 static INLINE struct identity_sampler_view *
106 identity_sampler_view(struct pipe_sampler_view *_sampler_view)
107 {
108 if (!_sampler_view) {
109 return NULL;
110 }
111 return (struct identity_sampler_view *)_sampler_view;
112 }
113
114 static INLINE struct identity_surface *
115 identity_surface(struct pipe_surface *_surface)
116 {
117 if(!_surface)
118 return NULL;
119 (void)identity_texture(_surface->texture);
120 return (struct identity_surface *)_surface;
121 }
122
123 static INLINE struct identity_transfer *
124 identity_transfer(struct pipe_transfer *_transfer)
125 {
126 if(!_transfer)
127 return NULL;
128 (void)identity_texture(_transfer->texture);
129 return (struct identity_transfer *)_transfer;
130 }
131
132 static INLINE struct identity_video_surface *
133 identity_video_surface(struct pipe_video_surface *_video_surface)
134 {
135 if (!_video_surface) {
136 return NULL;
137 }
138 (void)identity_screen(_video_surface->screen);
139 return (struct identity_video_surface *)_video_surface;
140 }
141
142 static INLINE struct pipe_buffer *
143 identity_buffer_unwrap(struct pipe_buffer *_buffer)
144 {
145 if(!_buffer)
146 return NULL;
147 return identity_buffer(_buffer)->buffer;
148 }
149
150 static INLINE struct pipe_texture *
151 identity_texture_unwrap(struct pipe_texture *_texture)
152 {
153 if(!_texture)
154 return NULL;
155 return identity_texture(_texture)->texture;
156 }
157
158 static INLINE struct pipe_sampler_view *
159 identity_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
160 {
161 if (!_sampler_view) {
162 return NULL;
163 }
164 return identity_sampler_view(_sampler_view)->sampler_view;
165 }
166
167 static INLINE struct pipe_surface *
168 identity_surface_unwrap(struct pipe_surface *_surface)
169 {
170 if(!_surface)
171 return NULL;
172 return identity_surface(_surface)->surface;
173 }
174
175 static INLINE struct pipe_transfer *
176 identity_transfer_unwrap(struct pipe_transfer *_transfer)
177 {
178 if(!_transfer)
179 return NULL;
180 return identity_transfer(_transfer)->transfer;
181 }
182
183
184 struct pipe_buffer *
185 identity_buffer_create(struct identity_screen *id_screen,
186 struct pipe_buffer *buffer);
187
188 void
189 identity_buffer_destroy(struct identity_buffer *id_buffer);
190
191 struct pipe_texture *
192 identity_texture_create(struct identity_screen *id_screen,
193 struct pipe_texture *texture);
194
195 void
196 identity_texture_destroy(struct identity_texture *id_texture);
197
198 struct pipe_surface *
199 identity_surface_create(struct identity_texture *id_texture,
200 struct pipe_surface *surface);
201
202 void
203 identity_surface_destroy(struct identity_surface *id_surface);
204
205 struct pipe_transfer *
206 identity_transfer_create(struct identity_texture *id_texture,
207 struct pipe_transfer *transfer);
208
209 void
210 identity_transfer_destroy(struct identity_transfer *id_transfer);
211
212 struct pipe_video_surface *
213 identity_video_surface_create(struct identity_screen *id_screen,
214 struct pipe_video_surface *video_surface);
215
216 void
217 identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
218
219
220 #endif /* ID_OBJECTS_H */