1 /**************************************************************************
3 * Copyright 2008 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 #include "util/u_format.h"
29 #include "util/u_memory.h"
30 #include "util/simple_list.h"
33 #include "tr_dump_defines.h"
34 #include "tr_dump_state.h"
35 #include "tr_texture.h"
36 #include "tr_context.h"
37 #include "tr_screen.h"
38 #include "tr_public.h"
41 static boolean trace
= FALSE
;
44 trace_screen_get_name(struct pipe_screen
*_screen
)
46 struct trace_screen
*tr_scr
= trace_screen(_screen
);
47 struct pipe_screen
*screen
= tr_scr
->screen
;
50 trace_dump_call_begin("pipe_screen", "get_name");
52 trace_dump_arg(ptr
, screen
);
54 result
= screen
->get_name(screen
);
56 trace_dump_ret(string
, result
);
58 trace_dump_call_end();
65 trace_screen_get_vendor(struct pipe_screen
*_screen
)
67 struct trace_screen
*tr_scr
= trace_screen(_screen
);
68 struct pipe_screen
*screen
= tr_scr
->screen
;
71 trace_dump_call_begin("pipe_screen", "get_vendor");
73 trace_dump_arg(ptr
, screen
);
75 result
= screen
->get_vendor(screen
);
77 trace_dump_ret(string
, result
);
79 trace_dump_call_end();
86 trace_screen_get_device_vendor(struct pipe_screen
*_screen
)
88 struct trace_screen
*tr_scr
= trace_screen(_screen
);
89 struct pipe_screen
*screen
= tr_scr
->screen
;
92 trace_dump_call_begin("pipe_screen", "get_device_vendor");
94 trace_dump_arg(ptr
, screen
);
96 result
= screen
->get_device_vendor(screen
);
98 trace_dump_ret(string
, result
);
100 trace_dump_call_end();
107 trace_screen_get_param(struct pipe_screen
*_screen
,
110 struct trace_screen
*tr_scr
= trace_screen(_screen
);
111 struct pipe_screen
*screen
= tr_scr
->screen
;
114 trace_dump_call_begin("pipe_screen", "get_param");
116 trace_dump_arg(ptr
, screen
);
117 trace_dump_arg(int, param
);
119 result
= screen
->get_param(screen
, param
);
121 trace_dump_ret(int, result
);
123 trace_dump_call_end();
130 trace_screen_get_shader_param(struct pipe_screen
*_screen
, unsigned shader
,
131 enum pipe_shader_cap param
)
133 struct trace_screen
*tr_scr
= trace_screen(_screen
);
134 struct pipe_screen
*screen
= tr_scr
->screen
;
137 trace_dump_call_begin("pipe_screen", "get_shader_param");
139 trace_dump_arg(ptr
, screen
);
140 trace_dump_arg(uint
, shader
);
141 trace_dump_arg(int, param
);
143 result
= screen
->get_shader_param(screen
, shader
, param
);
145 trace_dump_ret(int, result
);
147 trace_dump_call_end();
154 trace_screen_get_paramf(struct pipe_screen
*_screen
,
155 enum pipe_capf param
)
157 struct trace_screen
*tr_scr
= trace_screen(_screen
);
158 struct pipe_screen
*screen
= tr_scr
->screen
;
161 trace_dump_call_begin("pipe_screen", "get_paramf");
163 trace_dump_arg(ptr
, screen
);
164 trace_dump_arg(int, param
);
166 result
= screen
->get_paramf(screen
, param
);
168 trace_dump_ret(float, result
);
170 trace_dump_call_end();
177 trace_screen_is_format_supported(struct pipe_screen
*_screen
,
178 enum pipe_format format
,
179 enum pipe_texture_target target
,
180 unsigned sample_count
,
183 struct trace_screen
*tr_scr
= trace_screen(_screen
);
184 struct pipe_screen
*screen
= tr_scr
->screen
;
187 trace_dump_call_begin("pipe_screen", "is_format_supported");
189 trace_dump_arg(ptr
, screen
);
190 trace_dump_arg(format
, format
);
191 trace_dump_arg(int, target
);
192 trace_dump_arg(uint
, sample_count
);
193 trace_dump_arg(uint
, tex_usage
);
195 result
= screen
->is_format_supported(screen
, format
, target
, sample_count
,
198 trace_dump_ret(bool, result
);
200 trace_dump_call_end();
206 static struct pipe_context
*
207 trace_screen_context_create(struct pipe_screen
*_screen
, void *priv
,
210 struct trace_screen
*tr_scr
= trace_screen(_screen
);
211 struct pipe_screen
*screen
= tr_scr
->screen
;
212 struct pipe_context
*result
;
214 trace_dump_call_begin("pipe_screen", "context_create");
216 trace_dump_arg(ptr
, screen
);
217 trace_dump_arg(ptr
, priv
);
218 trace_dump_arg(uint
, flags
);
220 result
= screen
->context_create(screen
, priv
, flags
);
222 trace_dump_ret(ptr
, result
);
224 trace_dump_call_end();
226 result
= trace_context_create(tr_scr
, result
);
233 trace_screen_flush_frontbuffer(struct pipe_screen
*_screen
,
234 struct pipe_resource
*_resource
,
235 unsigned level
, unsigned layer
,
236 void *context_private
,
237 struct pipe_box
*sub_box
)
239 struct trace_screen
*tr_scr
= trace_screen(_screen
);
240 struct trace_resource
*tr_res
= trace_resource(_resource
);
241 struct pipe_screen
*screen
= tr_scr
->screen
;
242 struct pipe_resource
*resource
= tr_res
->resource
;
244 trace_dump_call_begin("pipe_screen", "flush_frontbuffer");
246 trace_dump_arg(ptr
, screen
);
247 trace_dump_arg(ptr
, resource
);
248 trace_dump_arg(uint
, level
);
249 trace_dump_arg(uint
, layer
);
250 /* XXX: hide, as there is nothing we can do with this
251 trace_dump_arg(ptr, context_private);
254 screen
->flush_frontbuffer(screen
, resource
, level
, layer
, context_private
, sub_box
);
256 trace_dump_call_end();
260 /********************************************************************
265 static struct pipe_resource
*
266 trace_screen_resource_create(struct pipe_screen
*_screen
,
267 const struct pipe_resource
*templat
)
269 struct trace_screen
*tr_scr
= trace_screen(_screen
);
270 struct pipe_screen
*screen
= tr_scr
->screen
;
271 struct pipe_resource
*result
;
273 trace_dump_call_begin("pipe_screen", "resource_create");
275 trace_dump_arg(ptr
, screen
);
276 trace_dump_arg(resource_template
, templat
);
278 result
= screen
->resource_create(screen
, templat
);
280 trace_dump_ret(ptr
, result
);
282 trace_dump_call_end();
284 result
= trace_resource_create(tr_scr
, result
);
289 static struct pipe_resource
*
290 trace_screen_resource_from_handle(struct pipe_screen
*_screen
,
291 const struct pipe_resource
*templ
,
292 struct winsys_handle
*handle
)
294 struct trace_screen
*tr_screen
= trace_screen(_screen
);
295 struct pipe_screen
*screen
= tr_screen
->screen
;
296 struct pipe_resource
*result
;
298 /* TODO trace call */
300 result
= screen
->resource_from_handle(screen
, templ
, handle
);
302 result
= trace_resource_create(trace_screen(_screen
), result
);
308 trace_screen_resource_get_handle(struct pipe_screen
*_screen
,
309 struct pipe_resource
*_resource
,
310 struct winsys_handle
*handle
)
312 struct trace_screen
*tr_screen
= trace_screen(_screen
);
313 struct trace_resource
*tr_resource
= trace_resource(_resource
);
314 struct pipe_screen
*screen
= tr_screen
->screen
;
315 struct pipe_resource
*resource
= tr_resource
->resource
;
317 /* TODO trace call */
319 return screen
->resource_get_handle(screen
, resource
, handle
);
325 trace_screen_resource_destroy(struct pipe_screen
*_screen
,
326 struct pipe_resource
*_resource
)
328 struct trace_screen
*tr_scr
= trace_screen(_screen
);
329 struct trace_resource
*tr_res
= trace_resource(_resource
);
330 struct pipe_screen
*screen
= tr_scr
->screen
;
331 struct pipe_resource
*resource
= tr_res
->resource
;
333 assert(resource
->screen
== screen
);
335 trace_dump_call_begin("pipe_screen", "resource_destroy");
337 trace_dump_arg(ptr
, screen
);
338 trace_dump_arg(ptr
, resource
);
340 trace_dump_call_end();
342 trace_resource_destroy(tr_scr
, tr_res
);
346 /********************************************************************
352 trace_screen_fence_reference(struct pipe_screen
*_screen
,
353 struct pipe_fence_handle
**pdst
,
354 struct pipe_fence_handle
*src
)
356 struct trace_screen
*tr_scr
= trace_screen(_screen
);
357 struct pipe_screen
*screen
= tr_scr
->screen
;
358 struct pipe_fence_handle
*dst
;
363 trace_dump_call_begin("pipe_screen", "fence_reference");
365 trace_dump_arg(ptr
, screen
);
366 trace_dump_arg(ptr
, dst
);
367 trace_dump_arg(ptr
, src
);
369 screen
->fence_reference(screen
, pdst
, src
);
371 trace_dump_call_end();
376 trace_screen_fence_finish(struct pipe_screen
*_screen
,
377 struct pipe_fence_handle
*fence
,
380 struct trace_screen
*tr_scr
= trace_screen(_screen
);
381 struct pipe_screen
*screen
= tr_scr
->screen
;
384 trace_dump_call_begin("pipe_screen", "fence_finish");
386 trace_dump_arg(ptr
, screen
);
387 trace_dump_arg(ptr
, fence
);
388 trace_dump_arg(uint
, timeout
);
390 result
= screen
->fence_finish(screen
, fence
, timeout
);
392 trace_dump_ret(bool, result
);
394 trace_dump_call_end();
400 /********************************************************************
405 trace_screen_get_timestamp(struct pipe_screen
*_screen
)
407 struct trace_screen
*tr_scr
= trace_screen(_screen
);
408 struct pipe_screen
*screen
= tr_scr
->screen
;
411 trace_dump_call_begin("pipe_screen", "get_timestamp");
412 trace_dump_arg(ptr
, screen
);
414 result
= screen
->get_timestamp(screen
);
416 trace_dump_ret(uint
, result
);
417 trace_dump_call_end();
423 trace_screen_destroy(struct pipe_screen
*_screen
)
425 struct trace_screen
*tr_scr
= trace_screen(_screen
);
426 struct pipe_screen
*screen
= tr_scr
->screen
;
428 trace_dump_call_begin("pipe_screen", "destroy");
429 trace_dump_arg(ptr
, screen
);
430 trace_dump_call_end();
432 screen
->destroy(screen
);
440 static boolean firstrun
= TRUE
;
446 if(trace_dump_trace_begin()) {
447 trace_dumping_start();
455 trace_screen_create(struct pipe_screen
*screen
)
457 struct trace_screen
*tr_scr
;
459 if (!trace_enabled())
462 trace_dump_call_begin("", "pipe_screen_create");
464 tr_scr
= CALLOC_STRUCT(trace_screen
);
468 tr_scr
->base
.destroy
= trace_screen_destroy
;
469 tr_scr
->base
.get_name
= trace_screen_get_name
;
470 tr_scr
->base
.get_vendor
= trace_screen_get_vendor
;
471 tr_scr
->base
.get_device_vendor
= trace_screen_get_device_vendor
;
472 tr_scr
->base
.get_param
= trace_screen_get_param
;
473 tr_scr
->base
.get_shader_param
= trace_screen_get_shader_param
;
474 tr_scr
->base
.get_paramf
= trace_screen_get_paramf
;
475 tr_scr
->base
.is_format_supported
= trace_screen_is_format_supported
;
476 assert(screen
->context_create
);
477 tr_scr
->base
.context_create
= trace_screen_context_create
;
478 tr_scr
->base
.resource_create
= trace_screen_resource_create
;
479 tr_scr
->base
.resource_from_handle
= trace_screen_resource_from_handle
;
480 tr_scr
->base
.resource_get_handle
= trace_screen_resource_get_handle
;
481 tr_scr
->base
.resource_destroy
= trace_screen_resource_destroy
;
482 tr_scr
->base
.fence_reference
= trace_screen_fence_reference
;
483 tr_scr
->base
.fence_finish
= trace_screen_fence_finish
;
484 tr_scr
->base
.flush_frontbuffer
= trace_screen_flush_frontbuffer
;
485 tr_scr
->base
.get_timestamp
= trace_screen_get_timestamp
;
487 tr_scr
->screen
= screen
;
489 trace_dump_ret(ptr
, screen
);
490 trace_dump_call_end();
492 return &tr_scr
->base
;
495 trace_dump_ret(ptr
, screen
);
496 trace_dump_call_end();
502 struct trace_screen
*
503 trace_screen(struct pipe_screen
*screen
)
506 assert(screen
->destroy
== trace_screen_destroy
);
507 return (struct trace_screen
*)screen
;