glsl2: Add and use new variable mode ir_var_temporary
[mesa/nouveau-pmpeg.git] / src / gallium / drivers / rbug / rbug_objects.h
blob49c128d3d1ace5cf416a00c57304d897b21d727a
1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
4 * All Rights Reserved.
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:
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.
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.
26 **************************************************************************/
28 #ifndef RBUG_OBJECTS_H
29 #define RBUG_OBJECTS_H
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_state.h"
35 #include "rbug_screen.h"
37 struct rbug_context;
40 struct rbug_resource
42 struct pipe_resource base;
44 struct pipe_resource *resource;
46 struct rbug_list list;
50 enum rbug_shader_type
52 RBUG_SHADER_GEOM,
53 RBUG_SHADER_VERTEX,
54 RBUG_SHADER_FRAGMENT,
57 struct rbug_shader
59 struct rbug_list list;
61 void *shader;
62 void *tokens;
63 void *replaced_shader;
64 void *replaced_tokens;
66 enum rbug_shader_type type;
67 boolean disabled;
71 struct rbug_sampler_view
73 struct pipe_sampler_view base;
75 struct pipe_sampler_view *sampler_view;
79 struct rbug_surface
81 struct pipe_surface base;
83 struct pipe_surface *surface;
87 struct rbug_transfer
89 struct pipe_transfer base;
91 struct pipe_context *pipe;
92 struct pipe_transfer *transfer;
96 static INLINE struct rbug_resource *
97 rbug_resource(struct pipe_resource *_resource)
99 if (!_resource)
100 return NULL;
101 (void)rbug_screen(_resource->screen);
102 return (struct rbug_resource *)_resource;
105 static INLINE struct rbug_sampler_view *
106 rbug_sampler_view(struct pipe_sampler_view *_sampler_view)
108 if (!_sampler_view)
109 return NULL;
110 (void)rbug_resource(_sampler_view->texture);
111 return (struct rbug_sampler_view *)_sampler_view;
114 static INLINE struct rbug_surface *
115 rbug_surface(struct pipe_surface *_surface)
117 if (!_surface)
118 return NULL;
119 (void)rbug_resource(_surface->texture);
120 return (struct rbug_surface *)_surface;
123 static INLINE struct rbug_transfer *
124 rbug_transfer(struct pipe_transfer *_transfer)
126 if (!_transfer)
127 return NULL;
128 (void)rbug_resource(_transfer->resource);
129 return (struct rbug_transfer *)_transfer;
132 static INLINE struct rbug_shader *
133 rbug_shader(void *_state)
135 if (!_state)
136 return NULL;
137 return (struct rbug_shader *)_state;
140 static INLINE struct pipe_resource *
141 rbug_resource_unwrap(struct pipe_resource *_resource)
143 if (!_resource)
144 return NULL;
145 return rbug_resource(_resource)->resource;
148 static INLINE struct pipe_sampler_view *
149 rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
151 if (!_sampler_view)
152 return NULL;
153 return rbug_sampler_view(_sampler_view)->sampler_view;
156 static INLINE struct pipe_surface *
157 rbug_surface_unwrap(struct pipe_surface *_surface)
159 if (!_surface)
160 return NULL;
161 return rbug_surface(_surface)->surface;
164 static INLINE struct pipe_transfer *
165 rbug_transfer_unwrap(struct pipe_transfer *_transfer)
167 if (!_transfer)
168 return NULL;
169 return rbug_transfer(_transfer)->transfer;
172 static INLINE void *
173 rbug_shader_unwrap(void *_state)
175 struct rbug_shader *shader;
176 if (!_state)
177 return NULL;
179 shader = rbug_shader(_state);
180 return shader->replaced_shader ? shader->replaced_shader : shader->shader;
184 struct pipe_resource *
185 rbug_resource_create(struct rbug_screen *rb_screen,
186 struct pipe_resource *resource);
188 void
189 rbug_resource_destroy(struct rbug_resource *rb_resource);
191 struct pipe_surface *
192 rbug_surface_create(struct rbug_resource *rb_resource,
193 struct pipe_surface *surface);
195 void
196 rbug_surface_destroy(struct rbug_surface *rb_surface);
198 struct pipe_sampler_view *
199 rbug_sampler_view_create(struct rbug_context *rb_context,
200 struct rbug_resource *rb_resource,
201 struct pipe_sampler_view *view);
203 void
204 rbug_sampler_view_destroy(struct rbug_context *rb_context,
205 struct rbug_sampler_view *rb_sampler_view);
207 struct pipe_transfer *
208 rbug_transfer_create(struct rbug_context *rb_context,
209 struct rbug_resource *rb_resource,
210 struct pipe_transfer *transfer);
212 void
213 rbug_transfer_destroy(struct rbug_context *rb_context,
214 struct rbug_transfer *rb_transfer);
216 void *
217 rbug_shader_create(struct rbug_context *rb_context,
218 const struct pipe_shader_state *state,
219 void *result, enum rbug_shader_type type);
221 void
222 rbug_shader_destroy(struct rbug_context *rb_context,
223 struct rbug_shader *rb_shader);
226 #endif /* RBUG_OBJECTS_H */