1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
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
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"
42 struct pipe_resource base
;
44 struct pipe_resource
*resource
;
46 struct rbug_list list
;
59 struct rbug_list list
;
63 void *replaced_shader
;
64 void *replaced_tokens
;
66 enum rbug_shader_type type
;
71 struct rbug_sampler_view
73 struct pipe_sampler_view base
;
75 struct pipe_sampler_view
*sampler_view
;
81 struct pipe_surface base
;
83 struct pipe_surface
*surface
;
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
)
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
)
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
)
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
)
128 (void)rbug_resource(_transfer
->resource
);
129 return (struct rbug_transfer
*)_transfer
;
132 static INLINE
struct rbug_shader
*
133 rbug_shader(void *_state
)
137 return (struct rbug_shader
*)_state
;
140 static INLINE
struct pipe_resource
*
141 rbug_resource_unwrap(struct pipe_resource
*_resource
)
145 return rbug_resource(_resource
)->resource
;
148 static INLINE
struct pipe_sampler_view
*
149 rbug_sampler_view_unwrap(struct pipe_sampler_view
*_sampler_view
)
153 return rbug_sampler_view(_sampler_view
)->sampler_view
;
156 static INLINE
struct pipe_surface
*
157 rbug_surface_unwrap(struct pipe_surface
*_surface
)
161 return rbug_surface(_surface
)->surface
;
164 static INLINE
struct pipe_transfer
*
165 rbug_transfer_unwrap(struct pipe_transfer
*_transfer
)
169 return rbug_transfer(_transfer
)->transfer
;
173 rbug_shader_unwrap(void *_state
)
175 struct rbug_shader
*shader
;
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
);
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
);
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
);
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
);
213 rbug_transfer_destroy(struct rbug_context
*rb_context
,
214 struct rbug_transfer
*rb_transfer
);
217 rbug_shader_create(struct rbug_context
*rb_context
,
218 const struct pipe_shader_state
*state
,
219 void *result
, enum rbug_shader_type type
);
222 rbug_shader_destroy(struct rbug_context
*rb_context
,
223 struct rbug_shader
*rb_shader
);
226 #endif /* RBUG_OBJECTS_H */