rbug: Break out of trace
[mesa.git] / src / gallium / drivers / rbug / rbug_objects.h
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 struct rbug_shader
51 {
52 struct rbug_list list;
53
54 void *shader;
55 void *tokens;
56 void *replaced_shader;
57 void *replaced_tokens;
58
59 boolean disabled;
60 };
61
62
63 struct rbug_sampler_view
64 {
65 struct pipe_sampler_view base;
66
67 struct pipe_sampler_view *sampler_view;
68 };
69
70
71 struct rbug_surface
72 {
73 struct pipe_surface base;
74
75 struct pipe_surface *surface;
76 };
77
78
79 struct rbug_transfer
80 {
81 struct pipe_transfer base;
82
83 struct pipe_context *pipe;
84 struct pipe_transfer *transfer;
85 };
86
87
88 static INLINE struct rbug_resource *
89 rbug_resource(struct pipe_resource *_resource)
90 {
91 if (!_resource)
92 return NULL;
93 (void)rbug_screen(_resource->screen);
94 return (struct rbug_resource *)_resource;
95 }
96
97 static INLINE struct rbug_sampler_view *
98 rbug_sampler_view(struct pipe_sampler_view *_sampler_view)
99 {
100 if (!_sampler_view)
101 return NULL;
102 (void)rbug_resource(_sampler_view->texture);
103 return (struct rbug_sampler_view *)_sampler_view;
104 }
105
106 static INLINE struct rbug_surface *
107 rbug_surface(struct pipe_surface *_surface)
108 {
109 if (!_surface)
110 return NULL;
111 (void)rbug_resource(_surface->texture);
112 return (struct rbug_surface *)_surface;
113 }
114
115 static INLINE struct rbug_transfer *
116 rbug_transfer(struct pipe_transfer *_transfer)
117 {
118 if (!_transfer)
119 return NULL;
120 (void)rbug_resource(_transfer->resource);
121 return (struct rbug_transfer *)_transfer;
122 }
123
124 static INLINE struct rbug_shader *
125 rbug_shader(void *_state)
126 {
127 if (!_state)
128 return NULL;
129 return (struct rbug_shader *)_state;
130 }
131
132 static INLINE struct pipe_resource *
133 rbug_resource_unwrap(struct pipe_resource *_resource)
134 {
135 if (!_resource)
136 return NULL;
137 return rbug_resource(_resource)->resource;
138 }
139
140 static INLINE struct pipe_sampler_view *
141 rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
142 {
143 if (!_sampler_view)
144 return NULL;
145 return rbug_sampler_view(_sampler_view)->sampler_view;
146 }
147
148 static INLINE struct pipe_surface *
149 rbug_surface_unwrap(struct pipe_surface *_surface)
150 {
151 if (!_surface)
152 return NULL;
153 return rbug_surface(_surface)->surface;
154 }
155
156 static INLINE struct pipe_transfer *
157 rbug_transfer_unwrap(struct pipe_transfer *_transfer)
158 {
159 if (!_transfer)
160 return NULL;
161 return rbug_transfer(_transfer)->transfer;
162 }
163
164 static INLINE void *
165 rbug_shader_unwrap(void *_state)
166 {
167 struct rbug_shader *shader;
168 if (!_state)
169 return NULL;
170
171 shader = rbug_shader(_state);
172 return shader->replaced_shader ? shader->replaced_shader : shader->shader;
173 }
174
175
176 struct pipe_resource *
177 rbug_resource_create(struct rbug_screen *rb_screen,
178 struct pipe_resource *resource);
179
180 void
181 rbug_resource_destroy(struct rbug_resource *rb_resource);
182
183 struct pipe_surface *
184 rbug_surface_create(struct rbug_resource *rb_resource,
185 struct pipe_surface *surface);
186
187 void
188 rbug_surface_destroy(struct rbug_surface *rb_surface);
189
190 struct pipe_sampler_view *
191 rbug_sampler_view_create(struct rbug_context *rb_context,
192 struct rbug_resource *rb_resource,
193 struct pipe_sampler_view *view);
194
195 void
196 rbug_sampler_view_destroy(struct rbug_context *rb_context,
197 struct rbug_sampler_view *rb_sampler_view);
198
199 struct pipe_transfer *
200 rbug_transfer_create(struct rbug_context *rb_context,
201 struct rbug_resource *rb_resource,
202 struct pipe_transfer *transfer);
203
204 void
205 rbug_transfer_destroy(struct rbug_context *rb_context,
206 struct rbug_transfer *rb_transfer);
207
208
209 #endif /* RBUG_OBJECTS_H */