1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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_memory.h"
29 #include "util/u_simple_list.h"
31 #include "pipe/p_screen.h"
34 #include "tr_dump_state.h"
36 #include "tr_buffer.h"
37 #include "tr_screen.h"
38 #include "tr_texture.h"
41 static INLINE
struct pipe_buffer
*
42 trace_buffer_unwrap(struct trace_context
*tr_ctx
,
43 struct pipe_buffer
*buffer
)
45 struct trace_screen
*tr_scr
= trace_screen(tr_ctx
->base
.screen
);
46 struct trace_buffer
*tr_buf
;
51 tr_buf
= trace_buffer(buffer
);
53 assert(tr_buf
->buffer
);
54 assert(tr_buf
->buffer
->screen
== tr_scr
->screen
);
55 return tr_buf
->buffer
;
59 static INLINE
struct pipe_texture
*
60 trace_texture_unwrap(struct trace_context
*tr_ctx
,
61 struct pipe_texture
*texture
)
63 struct trace_texture
*tr_tex
;
68 tr_tex
= trace_texture(texture
);
70 assert(tr_tex
->texture
);
71 return tr_tex
->texture
;
75 static INLINE
struct pipe_surface
*
76 trace_surface_unwrap(struct trace_context
*tr_ctx
,
77 struct pipe_surface
*surface
)
79 struct trace_screen
*tr_scr
= trace_screen(tr_ctx
->base
.screen
);
80 struct trace_surface
*tr_surf
;
85 assert(surface
->texture
);
89 tr_surf
= trace_surface(surface
);
91 assert(tr_surf
->surface
);
92 assert(tr_surf
->surface
->texture
->screen
== tr_scr
->screen
);
93 return tr_surf
->surface
;
98 trace_context_set_edgeflags(struct pipe_context
*_pipe
,
99 const unsigned *bitfield
)
101 struct trace_context
*tr_ctx
= trace_context(_pipe
);
102 struct pipe_context
*pipe
= tr_ctx
->pipe
;
104 trace_dump_call_begin("pipe_context", "set_edgeflags");
106 trace_dump_arg(ptr
, pipe
);
107 /* FIXME: we don't know how big this array is */
108 trace_dump_arg(ptr
, bitfield
);
110 pipe
->set_edgeflags(pipe
, bitfield
);;
112 trace_dump_call_end();
117 trace_context_draw_block(struct trace_context
*tr_ctx
, int flag
)
121 pipe_mutex_lock(tr_ctx
->draw_mutex
);
123 if (tr_ctx
->draw_blocker
& flag
) {
124 tr_ctx
->draw_blocked
|= flag
;
125 } else if ((tr_ctx
->draw_rule
.blocker
& flag
) &&
126 (tr_ctx
->draw_blocker
& 4)) {
127 boolean block
= FALSE
;
128 debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__
,
129 (void *) tr_ctx
->draw_rule
.fs
, (void *) tr_ctx
->curr
.fs
,
130 (void *) tr_ctx
->draw_rule
.vs
, (void *) tr_ctx
->curr
.vs
,
131 (void *) tr_ctx
->draw_rule
.surf
, 0,
132 (void *) tr_ctx
->draw_rule
.tex
, 0);
133 if (tr_ctx
->draw_rule
.fs
&&
134 tr_ctx
->draw_rule
.fs
== tr_ctx
->curr
.fs
)
136 if (tr_ctx
->draw_rule
.vs
&&
137 tr_ctx
->draw_rule
.vs
== tr_ctx
->curr
.vs
)
139 if (tr_ctx
->draw_rule
.surf
&&
140 tr_ctx
->draw_rule
.surf
== tr_ctx
->curr
.zsbuf
)
142 if (tr_ctx
->draw_rule
.surf
)
143 for (k
= 0; k
< tr_ctx
->curr
.nr_cbufs
; k
++)
144 if (tr_ctx
->draw_rule
.surf
== tr_ctx
->curr
.cbufs
[k
])
146 if (tr_ctx
->draw_rule
.tex
)
147 for (k
= 0; k
< tr_ctx
->curr
.num_texs
; k
++)
148 if (tr_ctx
->draw_rule
.tex
== tr_ctx
->curr
.tex
[k
])
152 tr_ctx
->draw_blocked
|= (flag
| 4);
155 if (tr_ctx
->draw_blocked
)
156 trace_rbug_notify_draw_blocked(tr_ctx
);
158 /* wait for rbug to clear the blocked flag */
159 while (tr_ctx
->draw_blocked
& flag
) {
160 tr_ctx
->draw_blocked
|= flag
;
161 #ifdef PIPE_THREAD_HAVE_CONDVAR
162 pipe_condvar_wait(tr_ctx
->draw_cond
, tr_ctx
->draw_mutex
);
164 pipe_mutex_unlock(tr_ctx
->draw_mutex
);
165 #ifdef PIPE_SUBSYSTEM_WINDOWS_USER
168 pipe_mutex_lock(tr_ctx
->draw_mutex
);
172 pipe_mutex_unlock(tr_ctx
->draw_mutex
);
175 static INLINE boolean
176 trace_context_draw_arrays(struct pipe_context
*_pipe
,
177 unsigned mode
, unsigned start
, unsigned count
)
179 struct trace_context
*tr_ctx
= trace_context(_pipe
);
180 struct pipe_context
*pipe
= tr_ctx
->pipe
;
183 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
186 trace_context_draw_block(tr_ctx
, 1);
188 trace_dump_call_begin("pipe_context", "draw_arrays");
190 trace_dump_arg(ptr
, pipe
);
191 trace_dump_arg(uint
, mode
);
192 trace_dump_arg(uint
, start
);
193 trace_dump_arg(uint
, count
);
195 result
= pipe
->draw_arrays(pipe
, mode
, start
, count
);;
197 trace_dump_ret(bool, result
);
199 trace_dump_call_end();
201 trace_context_draw_block(tr_ctx
, 2);
207 static INLINE boolean
208 trace_context_draw_elements(struct pipe_context
*_pipe
,
209 struct pipe_buffer
*_indexBuffer
,
211 unsigned mode
, unsigned start
, unsigned count
)
213 struct trace_context
*tr_ctx
= trace_context(_pipe
);
214 struct trace_buffer
*tr_buf
= trace_buffer(_indexBuffer
);
215 struct pipe_context
*pipe
= tr_ctx
->pipe
;
216 struct pipe_buffer
*indexBuffer
= tr_buf
->buffer
;
219 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
222 trace_context_draw_block(tr_ctx
, 1);
224 trace_screen_user_buffer_update(_pipe
->screen
, indexBuffer
);
226 trace_dump_call_begin("pipe_context", "draw_elements");
228 trace_dump_arg(ptr
, pipe
);
229 trace_dump_arg(ptr
, indexBuffer
);
230 trace_dump_arg(uint
, indexSize
);
231 trace_dump_arg(uint
, mode
);
232 trace_dump_arg(uint
, start
);
233 trace_dump_arg(uint
, count
);
235 result
= pipe
->draw_elements(pipe
, indexBuffer
, indexSize
, mode
, start
, count
);;
237 trace_dump_ret(bool, result
);
239 trace_dump_call_end();
241 trace_context_draw_block(tr_ctx
, 2);
247 static INLINE boolean
248 trace_context_draw_range_elements(struct pipe_context
*_pipe
,
249 struct pipe_buffer
*_indexBuffer
,
257 struct trace_context
*tr_ctx
= trace_context(_pipe
);
258 struct trace_buffer
*tr_buf
= trace_buffer(_indexBuffer
);
259 struct pipe_context
*pipe
= tr_ctx
->pipe
;
260 struct pipe_buffer
*indexBuffer
= tr_buf
->buffer
;
263 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
266 trace_context_draw_block(tr_ctx
, 1);
268 trace_screen_user_buffer_update(_pipe
->screen
, indexBuffer
);
270 trace_dump_call_begin("pipe_context", "draw_range_elements");
272 trace_dump_arg(ptr
, pipe
);
273 trace_dump_arg(ptr
, indexBuffer
);
274 trace_dump_arg(uint
, indexSize
);
275 trace_dump_arg(uint
, minIndex
);
276 trace_dump_arg(uint
, maxIndex
);
277 trace_dump_arg(uint
, mode
);
278 trace_dump_arg(uint
, start
);
279 trace_dump_arg(uint
, count
);
281 result
= pipe
->draw_range_elements(pipe
,
283 indexSize
, minIndex
, maxIndex
,
286 trace_dump_ret(bool, result
);
288 trace_dump_call_end();
290 trace_context_draw_block(tr_ctx
, 2);
296 static INLINE
struct pipe_query
*
297 trace_context_create_query(struct pipe_context
*_pipe
,
300 struct trace_context
*tr_ctx
= trace_context(_pipe
);
301 struct pipe_context
*pipe
= tr_ctx
->pipe
;
302 struct pipe_query
*result
;
304 trace_dump_call_begin("pipe_context", "create_query");
306 trace_dump_arg(ptr
, pipe
);
307 trace_dump_arg(uint
, query_type
);
309 result
= pipe
->create_query(pipe
, query_type
);;
311 trace_dump_ret(ptr
, result
);
313 trace_dump_call_end();
320 trace_context_destroy_query(struct pipe_context
*_pipe
,
321 struct pipe_query
*query
)
323 struct trace_context
*tr_ctx
= trace_context(_pipe
);
324 struct pipe_context
*pipe
= tr_ctx
->pipe
;
326 trace_dump_call_begin("pipe_context", "destroy_query");
328 trace_dump_arg(ptr
, pipe
);
329 trace_dump_arg(ptr
, query
);
331 pipe
->destroy_query(pipe
, query
);;
333 trace_dump_call_end();
338 trace_context_begin_query(struct pipe_context
*_pipe
,
339 struct pipe_query
*query
)
341 struct trace_context
*tr_ctx
= trace_context(_pipe
);
342 struct pipe_context
*pipe
= tr_ctx
->pipe
;
344 trace_dump_call_begin("pipe_context", "begin_query");
346 trace_dump_arg(ptr
, pipe
);
347 trace_dump_arg(ptr
, query
);
349 pipe
->begin_query(pipe
, query
);;
351 trace_dump_call_end();
356 trace_context_end_query(struct pipe_context
*_pipe
,
357 struct pipe_query
*query
)
359 struct trace_context
*tr_ctx
= trace_context(_pipe
);
360 struct pipe_context
*pipe
= tr_ctx
->pipe
;
362 trace_dump_call_begin("pipe_context", "end_query");
364 trace_dump_arg(ptr
, pipe
);
365 trace_dump_arg(ptr
, query
);
367 pipe
->end_query(pipe
, query
);
369 trace_dump_call_end();
373 static INLINE boolean
374 trace_context_get_query_result(struct pipe_context
*_pipe
,
375 struct pipe_query
*query
,
379 struct trace_context
*tr_ctx
= trace_context(_pipe
);
380 struct pipe_context
*pipe
= tr_ctx
->pipe
;
384 trace_dump_call_begin("pipe_context", "get_query_result");
386 trace_dump_arg(ptr
, pipe
);
388 _result
= pipe
->get_query_result(pipe
, query
, wait
, presult
);;
391 trace_dump_arg(uint
, result
);
392 trace_dump_ret(bool, _result
);
394 trace_dump_call_end();
401 trace_context_create_blend_state(struct pipe_context
*_pipe
,
402 const struct pipe_blend_state
*state
)
404 struct trace_context
*tr_ctx
= trace_context(_pipe
);
405 struct pipe_context
*pipe
= tr_ctx
->pipe
;
408 trace_dump_call_begin("pipe_context", "create_blend_state");
410 trace_dump_arg(ptr
, pipe
);
411 trace_dump_arg(blend_state
, state
);
413 result
= pipe
->create_blend_state(pipe
, state
);;
415 trace_dump_ret(ptr
, result
);
417 trace_dump_call_end();
424 trace_context_bind_blend_state(struct pipe_context
*_pipe
,
427 struct trace_context
*tr_ctx
= trace_context(_pipe
);
428 struct pipe_context
*pipe
= tr_ctx
->pipe
;
430 trace_dump_call_begin("pipe_context", "bind_blend_state");
432 trace_dump_arg(ptr
, pipe
);
433 trace_dump_arg(ptr
, state
);
435 pipe
->bind_blend_state(pipe
, state
);;
437 trace_dump_call_end();
442 trace_context_delete_blend_state(struct pipe_context
*_pipe
,
445 struct trace_context
*tr_ctx
= trace_context(_pipe
);
446 struct pipe_context
*pipe
= tr_ctx
->pipe
;
448 trace_dump_call_begin("pipe_context", "delete_blend_state");
450 trace_dump_arg(ptr
, pipe
);
451 trace_dump_arg(ptr
, state
);
453 pipe
->delete_blend_state(pipe
, state
);;
455 trace_dump_call_end();
460 trace_context_create_sampler_state(struct pipe_context
*_pipe
,
461 const struct pipe_sampler_state
*state
)
463 struct trace_context
*tr_ctx
= trace_context(_pipe
);
464 struct pipe_context
*pipe
= tr_ctx
->pipe
;
467 trace_dump_call_begin("pipe_context", "create_sampler_state");
469 trace_dump_arg(ptr
, pipe
);
470 trace_dump_arg(sampler_state
, state
);
472 result
= pipe
->create_sampler_state(pipe
, state
);;
474 trace_dump_ret(ptr
, result
);
476 trace_dump_call_end();
483 trace_context_bind_sampler_states(struct pipe_context
*_pipe
,
484 unsigned num_states
, void **states
)
486 struct trace_context
*tr_ctx
= trace_context(_pipe
);
487 struct pipe_context
*pipe
= tr_ctx
->pipe
;
489 trace_dump_call_begin("pipe_context", "bind_sampler_states");
491 trace_dump_arg(ptr
, pipe
);
492 trace_dump_arg(uint
, num_states
);
493 trace_dump_arg_array(ptr
, states
, num_states
);
495 pipe
->bind_sampler_states(pipe
, num_states
, states
);;
497 trace_dump_call_end();
502 trace_context_delete_sampler_state(struct pipe_context
*_pipe
,
505 struct trace_context
*tr_ctx
= trace_context(_pipe
);
506 struct pipe_context
*pipe
= tr_ctx
->pipe
;
508 trace_dump_call_begin("pipe_context", "delete_sampler_state");
510 trace_dump_arg(ptr
, pipe
);
511 trace_dump_arg(ptr
, state
);
513 pipe
->delete_sampler_state(pipe
, state
);;
515 trace_dump_call_end();
520 trace_context_create_rasterizer_state(struct pipe_context
*_pipe
,
521 const struct pipe_rasterizer_state
*state
)
523 struct trace_context
*tr_ctx
= trace_context(_pipe
);
524 struct pipe_context
*pipe
= tr_ctx
->pipe
;
527 trace_dump_call_begin("pipe_context", "create_rasterizer_state");
529 trace_dump_arg(ptr
, pipe
);
530 trace_dump_arg(rasterizer_state
, state
);
532 result
= pipe
->create_rasterizer_state(pipe
, state
);;
534 trace_dump_ret(ptr
, result
);
536 trace_dump_call_end();
543 trace_context_bind_rasterizer_state(struct pipe_context
*_pipe
,
546 struct trace_context
*tr_ctx
= trace_context(_pipe
);
547 struct pipe_context
*pipe
= tr_ctx
->pipe
;
549 trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
551 trace_dump_arg(ptr
, pipe
);
552 trace_dump_arg(ptr
, state
);
554 pipe
->bind_rasterizer_state(pipe
, state
);;
556 trace_dump_call_end();
561 trace_context_delete_rasterizer_state(struct pipe_context
*_pipe
,
564 struct trace_context
*tr_ctx
= trace_context(_pipe
);
565 struct pipe_context
*pipe
= tr_ctx
->pipe
;
567 trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
569 trace_dump_arg(ptr
, pipe
);
570 trace_dump_arg(ptr
, state
);
572 pipe
->delete_rasterizer_state(pipe
, state
);;
574 trace_dump_call_end();
579 trace_context_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
580 const struct pipe_depth_stencil_alpha_state
*state
)
582 struct trace_context
*tr_ctx
= trace_context(_pipe
);
583 struct pipe_context
*pipe
= tr_ctx
->pipe
;
586 trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
588 result
= pipe
->create_depth_stencil_alpha_state(pipe
, state
);;
590 trace_dump_arg(ptr
, pipe
);
591 trace_dump_arg(depth_stencil_alpha_state
, state
);
593 trace_dump_ret(ptr
, result
);
595 trace_dump_call_end();
602 trace_context_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
605 struct trace_context
*tr_ctx
= trace_context(_pipe
);
606 struct pipe_context
*pipe
= tr_ctx
->pipe
;
608 trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
610 trace_dump_arg(ptr
, pipe
);
611 trace_dump_arg(ptr
, state
);
613 pipe
->bind_depth_stencil_alpha_state(pipe
, state
);;
615 trace_dump_call_end();
620 trace_context_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
623 struct trace_context
*tr_ctx
= trace_context(_pipe
);
624 struct pipe_context
*pipe
= tr_ctx
->pipe
;
626 trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
628 trace_dump_arg(ptr
, pipe
);
629 trace_dump_arg(ptr
, state
);
631 pipe
->delete_depth_stencil_alpha_state(pipe
, state
);;
633 trace_dump_call_end();
638 trace_context_create_fs_state(struct pipe_context
*_pipe
,
639 const struct pipe_shader_state
*state
)
641 struct trace_context
*tr_ctx
= trace_context(_pipe
);
642 struct pipe_context
*pipe
= tr_ctx
->pipe
;
645 trace_dump_call_begin("pipe_context", "create_fs_state");
647 trace_dump_arg(ptr
, pipe
);
648 trace_dump_arg(shader_state
, state
);
650 result
= pipe
->create_fs_state(pipe
, state
);;
652 trace_dump_ret(ptr
, result
);
654 trace_dump_call_end();
656 result
= trace_shader_create(tr_ctx
, state
, result
, TRACE_SHADER_FRAGMENT
);
663 trace_context_bind_fs_state(struct pipe_context
*_pipe
,
666 struct trace_context
*tr_ctx
= trace_context(_pipe
);
667 struct trace_shader
*tr_shdr
= trace_shader(_state
);
668 struct pipe_context
*pipe
= tr_ctx
->pipe
;
669 void *state
= tr_shdr
? tr_shdr
->state
: NULL
;
671 trace_dump_call_begin("pipe_context", "bind_fs_state");
673 trace_dump_arg(ptr
, pipe
);
674 trace_dump_arg(ptr
, state
);
676 tr_ctx
->curr
.fs
= tr_shdr
;
678 if (tr_shdr
&& tr_shdr
->replaced
)
679 state
= tr_shdr
->replaced
;
681 pipe
->bind_fs_state(pipe
, state
);
683 trace_dump_call_end();
688 trace_context_delete_fs_state(struct pipe_context
*_pipe
,
691 struct trace_context
*tr_ctx
= trace_context(_pipe
);
692 struct trace_shader
*tr_shdr
= trace_shader(_state
);
693 struct pipe_context
*pipe
= tr_ctx
->pipe
;
694 void *state
= tr_shdr
->state
;
696 trace_dump_call_begin("pipe_context", "delete_fs_state");
698 trace_dump_arg(ptr
, pipe
);
699 trace_dump_arg(ptr
, state
);
701 pipe
->delete_fs_state(pipe
, state
);
703 trace_dump_call_end();
705 trace_shader_destroy(tr_ctx
, tr_shdr
);
710 trace_context_create_vs_state(struct pipe_context
*_pipe
,
711 const struct pipe_shader_state
*state
)
713 struct trace_context
*tr_ctx
= trace_context(_pipe
);
714 struct pipe_context
*pipe
= tr_ctx
->pipe
;
717 trace_dump_call_begin("pipe_context", "create_vs_state");
719 trace_dump_arg(ptr
, pipe
);
720 trace_dump_arg(shader_state
, state
);
722 result
= pipe
->create_vs_state(pipe
, state
);
724 trace_dump_ret(ptr
, result
);
726 trace_dump_call_end();
728 result
= trace_shader_create(tr_ctx
, state
, result
, TRACE_SHADER_VERTEX
);
735 trace_context_bind_vs_state(struct pipe_context
*_pipe
,
738 struct trace_context
*tr_ctx
= trace_context(_pipe
);
739 struct trace_shader
*tr_shdr
= trace_shader(_state
);
740 struct pipe_context
*pipe
= tr_ctx
->pipe
;
741 void *state
= tr_shdr
? tr_shdr
->state
: NULL
;
743 trace_dump_call_begin("pipe_context", "bind_vs_state");
745 trace_dump_arg(ptr
, pipe
);
746 trace_dump_arg(ptr
, state
);
748 tr_ctx
->curr
.vs
= tr_shdr
;
750 if (tr_shdr
&& tr_shdr
->replaced
)
751 state
= tr_shdr
->replaced
;
753 pipe
->bind_vs_state(pipe
, state
);;
755 trace_dump_call_end();
760 trace_context_delete_vs_state(struct pipe_context
*_pipe
,
763 struct trace_context
*tr_ctx
= trace_context(_pipe
);
764 struct trace_shader
*tr_shdr
= trace_shader(_state
);
765 struct pipe_context
*pipe
= tr_ctx
->pipe
;
766 void *state
= tr_shdr
->state
;
768 trace_dump_call_begin("pipe_context", "delete_vs_state");
770 trace_dump_arg(ptr
, pipe
);
771 trace_dump_arg(ptr
, state
);
773 pipe
->delete_vs_state(pipe
, state
);;
775 trace_dump_call_end();
777 trace_shader_destroy(tr_ctx
, tr_shdr
);
782 trace_context_set_blend_color(struct pipe_context
*_pipe
,
783 const struct pipe_blend_color
*state
)
785 struct trace_context
*tr_ctx
= trace_context(_pipe
);
786 struct pipe_context
*pipe
= tr_ctx
->pipe
;
788 trace_dump_call_begin("pipe_context", "set_blend_color");
790 trace_dump_arg(ptr
, pipe
);
791 trace_dump_arg(blend_color
, state
);
793 pipe
->set_blend_color(pipe
, state
);;
795 trace_dump_call_end();
800 trace_context_set_clip_state(struct pipe_context
*_pipe
,
801 const struct pipe_clip_state
*state
)
803 struct trace_context
*tr_ctx
= trace_context(_pipe
);
804 struct pipe_context
*pipe
= tr_ctx
->pipe
;
806 trace_dump_call_begin("pipe_context", "set_clip_state");
808 trace_dump_arg(ptr
, pipe
);
809 trace_dump_arg(clip_state
, state
);
811 pipe
->set_clip_state(pipe
, state
);;
813 trace_dump_call_end();
818 trace_context_set_constant_buffer(struct pipe_context
*_pipe
,
819 uint shader
, uint index
,
820 const struct pipe_constant_buffer
*buffer
)
822 struct trace_context
*tr_ctx
= trace_context(_pipe
);
823 struct pipe_context
*pipe
= tr_ctx
->pipe
;
826 trace_screen_user_buffer_update(_pipe
->screen
, buffer
->buffer
);
828 trace_dump_call_begin("pipe_context", "set_constant_buffer");
830 trace_dump_arg(ptr
, pipe
);
831 trace_dump_arg(uint
, shader
);
832 trace_dump_arg(uint
, index
);
833 trace_dump_arg(constant_buffer
, buffer
);
836 struct pipe_constant_buffer _buffer
;
837 _buffer
.buffer
= trace_buffer_unwrap(tr_ctx
, buffer
->buffer
);
838 pipe
->set_constant_buffer(pipe
, shader
, index
, &_buffer
);
840 pipe
->set_constant_buffer(pipe
, shader
, index
, buffer
);
843 trace_dump_call_end();
848 trace_context_set_framebuffer_state(struct pipe_context
*_pipe
,
849 const struct pipe_framebuffer_state
*state
)
851 struct trace_context
*tr_ctx
= trace_context(_pipe
);
852 struct pipe_context
*pipe
= tr_ctx
->pipe
;
853 struct pipe_framebuffer_state unwrapped_state
;
857 tr_ctx
->curr
.nr_cbufs
= state
->nr_cbufs
;
858 for (i
= 0; i
< state
->nr_cbufs
; i
++)
860 tr_ctx
->curr
.cbufs
[i
] = trace_texture(state
->cbufs
[i
]->texture
);
862 tr_ctx
->curr
.cbufs
[i
] = NULL
;
864 tr_ctx
->curr
.zsbuf
= trace_texture(state
->zsbuf
->texture
);
866 tr_ctx
->curr
.zsbuf
= NULL
;
869 /* Unwrap the input state */
870 memcpy(&unwrapped_state
, state
, sizeof(unwrapped_state
));
871 for(i
= 0; i
< state
->nr_cbufs
; ++i
)
872 unwrapped_state
.cbufs
[i
] = trace_surface_unwrap(tr_ctx
, state
->cbufs
[i
]);
873 for(i
= state
->nr_cbufs
; i
< PIPE_MAX_COLOR_BUFS
; ++i
)
874 unwrapped_state
.cbufs
[i
] = NULL
;
875 unwrapped_state
.zsbuf
= trace_surface_unwrap(tr_ctx
, state
->zsbuf
);
876 state
= &unwrapped_state
;
878 trace_dump_call_begin("pipe_context", "set_framebuffer_state");
880 trace_dump_arg(ptr
, pipe
);
881 trace_dump_arg(framebuffer_state
, state
);
883 pipe
->set_framebuffer_state(pipe
, state
);;
885 trace_dump_call_end();
890 trace_context_set_polygon_stipple(struct pipe_context
*_pipe
,
891 const struct pipe_poly_stipple
*state
)
893 struct trace_context
*tr_ctx
= trace_context(_pipe
);
894 struct pipe_context
*pipe
= tr_ctx
->pipe
;
896 trace_dump_call_begin("pipe_context", "set_polygon_stipple");
898 trace_dump_arg(ptr
, pipe
);
899 trace_dump_arg(poly_stipple
, state
);
901 pipe
->set_polygon_stipple(pipe
, state
);;
903 trace_dump_call_end();
908 trace_context_set_scissor_state(struct pipe_context
*_pipe
,
909 const struct pipe_scissor_state
*state
)
911 struct trace_context
*tr_ctx
= trace_context(_pipe
);
912 struct pipe_context
*pipe
= tr_ctx
->pipe
;
914 trace_dump_call_begin("pipe_context", "set_scissor_state");
916 trace_dump_arg(ptr
, pipe
);
917 trace_dump_arg(scissor_state
, state
);
919 pipe
->set_scissor_state(pipe
, state
);;
921 trace_dump_call_end();
926 trace_context_set_viewport_state(struct pipe_context
*_pipe
,
927 const struct pipe_viewport_state
*state
)
929 struct trace_context
*tr_ctx
= trace_context(_pipe
);
930 struct pipe_context
*pipe
= tr_ctx
->pipe
;
932 trace_dump_call_begin("pipe_context", "set_viewport_state");
934 trace_dump_arg(ptr
, pipe
);
935 trace_dump_arg(viewport_state
, state
);
937 pipe
->set_viewport_state(pipe
, state
);;
939 trace_dump_call_end();
944 trace_context_set_sampler_textures(struct pipe_context
*_pipe
,
945 unsigned num_textures
,
946 struct pipe_texture
**textures
)
948 struct trace_context
*tr_ctx
= trace_context(_pipe
);
949 struct trace_texture
*tr_tex
;
950 struct pipe_context
*pipe
= tr_ctx
->pipe
;
951 struct pipe_texture
*unwrapped_textures
[PIPE_MAX_SAMPLERS
];
954 tr_ctx
->curr
.num_texs
= num_textures
;
955 for(i
= 0; i
< num_textures
; ++i
) {
956 tr_tex
= trace_texture(textures
[i
]);
957 tr_ctx
->curr
.tex
[i
] = tr_tex
;
958 unwrapped_textures
[i
] = tr_tex
? tr_tex
->texture
: NULL
;
960 textures
= unwrapped_textures
;
962 trace_dump_call_begin("pipe_context", "set_sampler_textures");
964 trace_dump_arg(ptr
, pipe
);
965 trace_dump_arg(uint
, num_textures
);
966 trace_dump_arg_array(ptr
, textures
, num_textures
);
968 pipe
->set_sampler_textures(pipe
, num_textures
, textures
);;
970 trace_dump_call_end();
975 trace_context_set_vertex_buffers(struct pipe_context
*_pipe
,
976 unsigned num_buffers
,
977 const struct pipe_vertex_buffer
*buffers
)
979 struct trace_context
*tr_ctx
= trace_context(_pipe
);
980 struct pipe_context
*pipe
= tr_ctx
->pipe
;
983 for(i
= 0; i
< num_buffers
; ++i
)
984 trace_screen_user_buffer_update(_pipe
->screen
, buffers
[i
].buffer
);
986 trace_dump_call_begin("pipe_context", "set_vertex_buffers");
988 trace_dump_arg(ptr
, pipe
);
989 trace_dump_arg(uint
, num_buffers
);
991 trace_dump_arg_begin("buffers");
992 trace_dump_struct_array(vertex_buffer
, buffers
, num_buffers
);
993 trace_dump_arg_end();
996 struct pipe_vertex_buffer
*_buffers
= malloc(num_buffers
* sizeof(*_buffers
));
997 memcpy(_buffers
, buffers
, num_buffers
* sizeof(*_buffers
));
998 for (i
= 0; i
< num_buffers
; i
++)
999 _buffers
[i
].buffer
= trace_buffer_unwrap(tr_ctx
, buffers
[i
].buffer
);
1000 pipe
->set_vertex_buffers(pipe
, num_buffers
, _buffers
);
1003 pipe
->set_vertex_buffers(pipe
, num_buffers
, NULL
);
1006 trace_dump_call_end();
1011 trace_context_set_vertex_elements(struct pipe_context
*_pipe
,
1012 unsigned num_elements
,
1013 const struct pipe_vertex_element
*elements
)
1015 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1016 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1018 trace_dump_call_begin("pipe_context", "set_vertex_elements");
1020 trace_dump_arg(ptr
, pipe
);
1021 trace_dump_arg(uint
, num_elements
);
1023 trace_dump_arg_begin("elements");
1024 trace_dump_struct_array(vertex_element
, elements
, num_elements
);
1025 trace_dump_arg_end();
1027 pipe
->set_vertex_elements(pipe
, num_elements
, elements
);;
1029 trace_dump_call_end();
1034 trace_context_surface_copy(struct pipe_context
*_pipe
,
1035 struct pipe_surface
*dest
,
1036 unsigned destx
, unsigned desty
,
1037 struct pipe_surface
*src
,
1038 unsigned srcx
, unsigned srcy
,
1039 unsigned width
, unsigned height
)
1041 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1042 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1044 dest
= trace_surface_unwrap(tr_ctx
, dest
);
1045 src
= trace_surface_unwrap(tr_ctx
, src
);
1047 trace_dump_call_begin("pipe_context", "surface_copy");
1049 trace_dump_arg(ptr
, pipe
);
1050 trace_dump_arg(ptr
, dest
);
1051 trace_dump_arg(uint
, destx
);
1052 trace_dump_arg(uint
, desty
);
1053 trace_dump_arg(ptr
, src
);
1054 trace_dump_arg(uint
, srcx
);
1055 trace_dump_arg(uint
, srcy
);
1056 trace_dump_arg(uint
, width
);
1057 trace_dump_arg(uint
, height
);
1059 pipe
->surface_copy(pipe
,
1061 src
, srcx
, srcy
, width
, height
);
1063 trace_dump_call_end();
1068 trace_context_surface_fill(struct pipe_context
*_pipe
,
1069 struct pipe_surface
*dst
,
1070 unsigned dstx
, unsigned dsty
,
1071 unsigned width
, unsigned height
,
1074 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1075 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1077 dst
= trace_surface_unwrap(tr_ctx
, dst
);
1079 trace_dump_call_begin("pipe_context", "surface_fill");
1081 trace_dump_arg(ptr
, pipe
);
1082 trace_dump_arg(ptr
, dst
);
1083 trace_dump_arg(uint
, dstx
);
1084 trace_dump_arg(uint
, dsty
);
1085 trace_dump_arg(uint
, width
);
1086 trace_dump_arg(uint
, height
);
1088 pipe
->surface_fill(pipe
, dst
, dstx
, dsty
, width
, height
, value
);;
1090 trace_dump_call_end();
1095 trace_context_clear(struct pipe_context
*_pipe
,
1101 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1102 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1104 trace_dump_call_begin("pipe_context", "clear");
1106 trace_dump_arg(ptr
, pipe
);
1107 trace_dump_arg(uint
, buffers
);
1108 trace_dump_arg_array(float, rgba
, 4);
1109 trace_dump_arg(float, depth
);
1110 trace_dump_arg(uint
, stencil
);
1112 pipe
->clear(pipe
, buffers
, rgba
, depth
, stencil
);
1114 trace_dump_call_end();
1119 trace_context_flush(struct pipe_context
*_pipe
,
1121 struct pipe_fence_handle
**fence
)
1123 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1124 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1126 trace_dump_call_begin("pipe_context", "flush");
1128 trace_dump_arg(ptr
, pipe
);
1129 trace_dump_arg(uint
, flags
);
1131 pipe
->flush(pipe
, flags
, fence
);;
1134 trace_dump_ret(ptr
, *fence
);
1136 trace_dump_call_end();
1141 trace_context_destroy(struct pipe_context
*_pipe
)
1143 struct trace_screen
*tr_scr
= trace_screen(_pipe
->screen
);
1144 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1145 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1147 trace_dump_call_begin("pipe_context", "destroy");
1148 trace_dump_arg(ptr
, pipe
);
1149 trace_dump_call_end();
1151 trace_screen_remove_from_list(tr_scr
, contexts
, tr_ctx
);
1153 pipe
->destroy(pipe
);
1159 trace_is_texture_referenced( struct pipe_context
*_pipe
,
1160 struct pipe_texture
*_texture
,
1161 unsigned face
, unsigned level
)
1163 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1164 struct trace_texture
*tr_tex
= trace_texture(_texture
);
1165 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1166 struct pipe_texture
*texture
= tr_tex
->texture
;
1167 unsigned int referenced
;
1169 trace_dump_call_begin("pipe_context", "is_texture_referenced");
1170 trace_dump_arg(ptr
, pipe
);
1171 trace_dump_arg(ptr
, texture
);
1172 trace_dump_arg(uint
, face
);
1173 trace_dump_arg(uint
, level
);
1175 referenced
= pipe
->is_texture_referenced(pipe
, texture
, face
, level
);
1177 trace_dump_ret(uint
, referenced
);
1178 trace_dump_call_end();
1184 trace_is_buffer_referenced( struct pipe_context
*_pipe
,
1185 struct pipe_buffer
*_buf
)
1187 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1188 struct trace_buffer
*tr_buf
= trace_buffer(_buf
);
1189 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1190 struct pipe_buffer
*buf
= tr_buf
->buffer
;
1191 unsigned int referenced
;
1193 trace_dump_call_begin("pipe_context", "is_buffer_referenced");
1194 trace_dump_arg(ptr
, pipe
);
1195 trace_dump_arg(ptr
, buf
);
1197 referenced
= pipe
->is_buffer_referenced(pipe
, buf
);
1199 trace_dump_ret(uint
, referenced
);
1200 trace_dump_call_end();
1205 static const struct debug_named_value rbug_blocker_flags
[] = {
1211 struct pipe_context
*
1212 trace_context_create(struct pipe_screen
*_screen
,
1213 struct pipe_context
*pipe
)
1215 struct trace_screen
*tr_scr
;
1216 struct trace_context
*tr_ctx
;
1217 struct pipe_screen
*screen
;
1222 if(!trace_enabled())
1225 tr_scr
= trace_screen(_screen
);
1226 screen
= tr_scr
->screen
;
1228 tr_ctx
= CALLOC_STRUCT(trace_context
);
1232 tr_ctx
->draw_blocker
= debug_get_flags_option("RBUG_BLOCK",
1235 pipe_mutex_init(tr_ctx
->draw_mutex
);
1236 pipe_condvar_init(tr_ctx
->draw_cond
);
1237 pipe_mutex_init(tr_ctx
->list_mutex
);
1238 make_empty_list(&tr_ctx
->shaders
);
1240 tr_ctx
->base
.winsys
= _screen
->winsys
;
1241 tr_ctx
->base
.screen
= _screen
;
1242 tr_ctx
->base
.destroy
= trace_context_destroy
;
1243 tr_ctx
->base
.set_edgeflags
= trace_context_set_edgeflags
;
1244 tr_ctx
->base
.draw_arrays
= trace_context_draw_arrays
;
1245 tr_ctx
->base
.draw_elements
= trace_context_draw_elements
;
1246 tr_ctx
->base
.draw_range_elements
= trace_context_draw_range_elements
;
1247 tr_ctx
->base
.create_query
= trace_context_create_query
;
1248 tr_ctx
->base
.destroy_query
= trace_context_destroy_query
;
1249 tr_ctx
->base
.begin_query
= trace_context_begin_query
;
1250 tr_ctx
->base
.end_query
= trace_context_end_query
;
1251 tr_ctx
->base
.get_query_result
= trace_context_get_query_result
;
1252 tr_ctx
->base
.create_blend_state
= trace_context_create_blend_state
;
1253 tr_ctx
->base
.bind_blend_state
= trace_context_bind_blend_state
;
1254 tr_ctx
->base
.delete_blend_state
= trace_context_delete_blend_state
;
1255 tr_ctx
->base
.create_sampler_state
= trace_context_create_sampler_state
;
1256 tr_ctx
->base
.bind_sampler_states
= trace_context_bind_sampler_states
;
1257 tr_ctx
->base
.delete_sampler_state
= trace_context_delete_sampler_state
;
1258 tr_ctx
->base
.create_rasterizer_state
= trace_context_create_rasterizer_state
;
1259 tr_ctx
->base
.bind_rasterizer_state
= trace_context_bind_rasterizer_state
;
1260 tr_ctx
->base
.delete_rasterizer_state
= trace_context_delete_rasterizer_state
;
1261 tr_ctx
->base
.create_depth_stencil_alpha_state
= trace_context_create_depth_stencil_alpha_state
;
1262 tr_ctx
->base
.bind_depth_stencil_alpha_state
= trace_context_bind_depth_stencil_alpha_state
;
1263 tr_ctx
->base
.delete_depth_stencil_alpha_state
= trace_context_delete_depth_stencil_alpha_state
;
1264 tr_ctx
->base
.create_fs_state
= trace_context_create_fs_state
;
1265 tr_ctx
->base
.bind_fs_state
= trace_context_bind_fs_state
;
1266 tr_ctx
->base
.delete_fs_state
= trace_context_delete_fs_state
;
1267 tr_ctx
->base
.create_vs_state
= trace_context_create_vs_state
;
1268 tr_ctx
->base
.bind_vs_state
= trace_context_bind_vs_state
;
1269 tr_ctx
->base
.delete_vs_state
= trace_context_delete_vs_state
;
1270 tr_ctx
->base
.set_blend_color
= trace_context_set_blend_color
;
1271 tr_ctx
->base
.set_clip_state
= trace_context_set_clip_state
;
1272 tr_ctx
->base
.set_constant_buffer
= trace_context_set_constant_buffer
;
1273 tr_ctx
->base
.set_framebuffer_state
= trace_context_set_framebuffer_state
;
1274 tr_ctx
->base
.set_polygon_stipple
= trace_context_set_polygon_stipple
;
1275 tr_ctx
->base
.set_scissor_state
= trace_context_set_scissor_state
;
1276 tr_ctx
->base
.set_viewport_state
= trace_context_set_viewport_state
;
1277 tr_ctx
->base
.set_sampler_textures
= trace_context_set_sampler_textures
;
1278 tr_ctx
->base
.set_vertex_buffers
= trace_context_set_vertex_buffers
;
1279 tr_ctx
->base
.set_vertex_elements
= trace_context_set_vertex_elements
;
1280 if (pipe
->surface_copy
)
1281 tr_ctx
->base
.surface_copy
= trace_context_surface_copy
;
1282 if (pipe
->surface_fill
)
1283 tr_ctx
->base
.surface_fill
= trace_context_surface_fill
;
1284 tr_ctx
->base
.clear
= trace_context_clear
;
1285 tr_ctx
->base
.flush
= trace_context_flush
;
1286 tr_ctx
->base
.is_texture_referenced
= trace_is_texture_referenced
;
1287 tr_ctx
->base
.is_buffer_referenced
= trace_is_buffer_referenced
;
1289 tr_ctx
->pipe
= pipe
;
1291 trace_dump_call_begin("", "pipe_context_create");
1292 trace_dump_arg(ptr
, screen
);
1293 trace_dump_ret(ptr
, pipe
);
1294 trace_dump_call_end();
1296 trace_screen_add_to_list(tr_scr
, contexts
, tr_ctx
);
1298 return &tr_ctx
->base
;