Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5564 | serge | 1 | /************************************************************************** |
2 | * |
||
3 | * Copyright 2010 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 RBUG_OBJECTS_H |
||
29 | #define RBUG_OBJECTS_H |
||
30 | |||
31 | |||
32 | #include "pipe/p_compiler.h" |
||
33 | #include "pipe/p_state.h" |
||
34 | |||
35 | #include "rbug_screen.h" |
||
36 | |||
37 | struct rbug_context; |
||
38 | |||
39 | |||
40 | struct rbug_resource |
||
41 | { |
||
42 | struct pipe_resource base; |
||
43 | |||
44 | struct pipe_resource *resource; |
||
45 | |||
46 | struct rbug_list list; |
||
47 | }; |
||
48 | |||
49 | |||
50 | enum rbug_shader_type |
||
51 | { |
||
52 | RBUG_SHADER_GEOM, |
||
53 | RBUG_SHADER_VERTEX, |
||
54 | RBUG_SHADER_FRAGMENT, |
||
55 | }; |
||
56 | |||
57 | struct rbug_shader |
||
58 | { |
||
59 | struct rbug_list list; |
||
60 | |||
61 | void *shader; |
||
62 | void *tokens; |
||
63 | void *replaced_shader; |
||
64 | void *replaced_tokens; |
||
65 | |||
66 | enum rbug_shader_type type; |
||
67 | boolean disabled; |
||
68 | }; |
||
69 | |||
70 | |||
71 | struct rbug_sampler_view |
||
72 | { |
||
73 | struct pipe_sampler_view base; |
||
74 | |||
75 | struct pipe_sampler_view *sampler_view; |
||
76 | }; |
||
77 | |||
78 | |||
79 | struct rbug_surface |
||
80 | { |
||
81 | struct pipe_surface base; |
||
82 | |||
83 | struct pipe_surface *surface; |
||
84 | }; |
||
85 | |||
86 | |||
87 | struct rbug_transfer |
||
88 | { |
||
89 | struct pipe_transfer base; |
||
90 | |||
91 | struct pipe_context *pipe; |
||
92 | struct pipe_transfer *transfer; |
||
93 | }; |
||
94 | |||
95 | |||
96 | static INLINE struct rbug_resource * |
||
97 | rbug_resource(struct pipe_resource *_resource) |
||
98 | { |
||
99 | if (!_resource) |
||
100 | return NULL; |
||
101 | (void)rbug_screen(_resource->screen); |
||
102 | return (struct rbug_resource *)_resource; |
||
103 | } |
||
104 | |||
105 | static INLINE struct rbug_sampler_view * |
||
106 | rbug_sampler_view(struct pipe_sampler_view *_sampler_view) |
||
107 | { |
||
108 | if (!_sampler_view) |
||
109 | return NULL; |
||
110 | (void)rbug_resource(_sampler_view->texture); |
||
111 | return (struct rbug_sampler_view *)_sampler_view; |
||
112 | } |
||
113 | |||
114 | static INLINE struct rbug_surface * |
||
115 | rbug_surface(struct pipe_surface *_surface) |
||
116 | { |
||
117 | if (!_surface) |
||
118 | return NULL; |
||
119 | (void)rbug_resource(_surface->texture); |
||
120 | return (struct rbug_surface *)_surface; |
||
121 | } |
||
122 | |||
123 | static INLINE struct rbug_transfer * |
||
124 | rbug_transfer(struct pipe_transfer *_transfer) |
||
125 | { |
||
126 | if (!_transfer) |
||
127 | return NULL; |
||
128 | (void)rbug_resource(_transfer->resource); |
||
129 | return (struct rbug_transfer *)_transfer; |
||
130 | } |
||
131 | |||
132 | static INLINE struct rbug_shader * |
||
133 | rbug_shader(void *_state) |
||
134 | { |
||
135 | if (!_state) |
||
136 | return NULL; |
||
137 | return (struct rbug_shader *)_state; |
||
138 | } |
||
139 | |||
140 | static INLINE struct pipe_resource * |
||
141 | rbug_resource_unwrap(struct pipe_resource *_resource) |
||
142 | { |
||
143 | if (!_resource) |
||
144 | return NULL; |
||
145 | return rbug_resource(_resource)->resource; |
||
146 | } |
||
147 | |||
148 | static INLINE struct pipe_sampler_view * |
||
149 | rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) |
||
150 | { |
||
151 | if (!_sampler_view) |
||
152 | return NULL; |
||
153 | return rbug_sampler_view(_sampler_view)->sampler_view; |
||
154 | } |
||
155 | |||
156 | static INLINE struct pipe_surface * |
||
157 | rbug_surface_unwrap(struct pipe_surface *_surface) |
||
158 | { |
||
159 | if (!_surface) |
||
160 | return NULL; |
||
161 | return rbug_surface(_surface)->surface; |
||
162 | } |
||
163 | |||
164 | static INLINE struct pipe_transfer * |
||
165 | rbug_transfer_unwrap(struct pipe_transfer *_transfer) |
||
166 | { |
||
167 | if (!_transfer) |
||
168 | return NULL; |
||
169 | return rbug_transfer(_transfer)->transfer; |
||
170 | } |
||
171 | |||
172 | static INLINE void * |
||
173 | rbug_shader_unwrap(void *_state) |
||
174 | { |
||
175 | struct rbug_shader *shader; |
||
176 | if (!_state) |
||
177 | return NULL; |
||
178 | |||
179 | shader = rbug_shader(_state); |
||
180 | return shader->replaced_shader ? shader->replaced_shader : shader->shader; |
||
181 | } |
||
182 | |||
183 | |||
184 | struct pipe_resource * |
||
185 | rbug_resource_create(struct rbug_screen *rb_screen, |
||
186 | struct pipe_resource *resource); |
||
187 | |||
188 | void |
||
189 | rbug_resource_destroy(struct rbug_resource *rb_resource); |
||
190 | |||
191 | struct pipe_surface * |
||
192 | rbug_surface_create(struct rbug_context *rb_context, |
||
193 | struct rbug_resource *rb_resource, |
||
194 | struct pipe_surface *surface); |
||
195 | |||
196 | void |
||
197 | rbug_surface_destroy(struct rbug_context *rb_context, |
||
198 | struct rbug_surface *rb_surface); |
||
199 | |||
200 | struct pipe_sampler_view * |
||
201 | rbug_sampler_view_create(struct rbug_context *rb_context, |
||
202 | struct rbug_resource *rb_resource, |
||
203 | struct pipe_sampler_view *view); |
||
204 | |||
205 | void |
||
206 | rbug_sampler_view_destroy(struct rbug_context *rb_context, |
||
207 | struct rbug_sampler_view *rb_sampler_view); |
||
208 | |||
209 | struct pipe_transfer * |
||
210 | rbug_transfer_create(struct rbug_context *rb_context, |
||
211 | struct rbug_resource *rb_resource, |
||
212 | struct pipe_transfer *transfer); |
||
213 | |||
214 | void |
||
215 | rbug_transfer_destroy(struct rbug_context *rb_context, |
||
216 | struct rbug_transfer *rb_transfer); |
||
217 | |||
218 | void * |
||
219 | rbug_shader_create(struct rbug_context *rb_context, |
||
220 | const struct pipe_shader_state *state, |
||
221 | void *result, enum rbug_shader_type type); |
||
222 | |||
223 | void |
||
224 | rbug_shader_destroy(struct rbug_context *rb_context, |
||
225 | struct rbug_shader *rb_shader); |
||
226 | |||
227 | |||
228 | #endif /* RBUG_OBJECTS_H */ |