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
);
56 return tr_buf
->buffer
;
60 static INLINE
struct pipe_texture
*
61 trace_texture_unwrap(struct trace_context
*tr_ctx
,
62 struct pipe_texture
*texture
)
64 struct trace_texture
*tr_tex
;
69 tr_tex
= trace_texture(texture
);
71 assert(tr_tex
->texture
);
72 return tr_tex
->texture
;
76 static INLINE
struct pipe_surface
*
77 trace_surface_unwrap(struct trace_context
*tr_ctx
,
78 struct pipe_surface
*surface
)
80 struct trace_screen
*tr_scr
= trace_screen(tr_ctx
->base
.screen
);
81 struct trace_surface
*tr_surf
;
86 assert(surface
->texture
);
90 tr_surf
= trace_surface(surface
);
92 assert(tr_surf
->surface
);
93 assert(tr_surf
->surface
->texture
->screen
== tr_scr
->screen
);
95 return tr_surf
->surface
;
100 trace_context_draw_block(struct trace_context
*tr_ctx
, int flag
)
104 pipe_mutex_lock(tr_ctx
->draw_mutex
);
106 if (tr_ctx
->draw_blocker
& flag
) {
107 tr_ctx
->draw_blocked
|= flag
;
108 } else if ((tr_ctx
->draw_rule
.blocker
& flag
) &&
109 (tr_ctx
->draw_blocker
& 4)) {
110 boolean block
= FALSE
;
111 debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__
,
112 (void *) tr_ctx
->draw_rule
.fs
, (void *) tr_ctx
->curr
.fs
,
113 (void *) tr_ctx
->draw_rule
.vs
, (void *) tr_ctx
->curr
.vs
,
114 (void *) tr_ctx
->draw_rule
.surf
, 0,
115 (void *) tr_ctx
->draw_rule
.tex
, 0);
116 if (tr_ctx
->draw_rule
.fs
&&
117 tr_ctx
->draw_rule
.fs
== tr_ctx
->curr
.fs
)
119 if (tr_ctx
->draw_rule
.vs
&&
120 tr_ctx
->draw_rule
.vs
== tr_ctx
->curr
.vs
)
122 if (tr_ctx
->draw_rule
.surf
&&
123 tr_ctx
->draw_rule
.surf
== tr_ctx
->curr
.zsbuf
)
125 if (tr_ctx
->draw_rule
.surf
)
126 for (k
= 0; k
< tr_ctx
->curr
.nr_cbufs
; k
++)
127 if (tr_ctx
->draw_rule
.surf
== tr_ctx
->curr
.cbufs
[k
])
129 if (tr_ctx
->draw_rule
.tex
) {
130 for (k
= 0; k
< tr_ctx
->curr
.num_texs
; k
++)
131 if (tr_ctx
->draw_rule
.tex
== tr_ctx
->curr
.tex
[k
])
133 for (k
= 0; k
< tr_ctx
->curr
.num_vert_texs
; k
++) {
134 if (tr_ctx
->draw_rule
.tex
== tr_ctx
->curr
.vert_tex
[k
]) {
141 tr_ctx
->draw_blocked
|= (flag
| 4);
144 if (tr_ctx
->draw_blocked
)
145 trace_rbug_notify_draw_blocked(tr_ctx
);
147 /* wait for rbug to clear the blocked flag */
148 while (tr_ctx
->draw_blocked
& flag
) {
149 tr_ctx
->draw_blocked
|= flag
;
150 #ifdef PIPE_THREAD_HAVE_CONDVAR
151 pipe_condvar_wait(tr_ctx
->draw_cond
, tr_ctx
->draw_mutex
);
153 pipe_mutex_unlock(tr_ctx
->draw_mutex
);
154 #ifdef PIPE_SUBSYSTEM_WINDOWS_USER
157 pipe_mutex_lock(tr_ctx
->draw_mutex
);
161 pipe_mutex_unlock(tr_ctx
->draw_mutex
);
165 trace_context_draw_arrays(struct pipe_context
*_pipe
,
166 unsigned mode
, unsigned start
, unsigned count
)
168 struct trace_context
*tr_ctx
= trace_context(_pipe
);
169 struct pipe_context
*pipe
= tr_ctx
->pipe
;
171 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
174 trace_context_draw_block(tr_ctx
, 1);
176 trace_dump_call_begin("pipe_context", "draw_arrays");
178 trace_dump_arg(ptr
, pipe
);
179 trace_dump_arg(uint
, mode
);
180 trace_dump_arg(uint
, start
);
181 trace_dump_arg(uint
, count
);
183 pipe
->draw_arrays(pipe
, mode
, start
, count
);
185 trace_dump_call_end();
187 trace_context_draw_block(tr_ctx
, 2);
192 trace_context_draw_elements(struct pipe_context
*_pipe
,
193 struct pipe_buffer
*_indexBuffer
,
195 unsigned mode
, unsigned start
, unsigned count
)
197 struct trace_context
*tr_ctx
= trace_context(_pipe
);
198 struct trace_buffer
*tr_buf
= trace_buffer(_indexBuffer
);
199 struct pipe_context
*pipe
= tr_ctx
->pipe
;
200 struct pipe_buffer
*indexBuffer
= tr_buf
->buffer
;
202 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
205 trace_context_draw_block(tr_ctx
, 1);
207 trace_screen_user_buffer_update(_pipe
->screen
, indexBuffer
);
209 trace_dump_call_begin("pipe_context", "draw_elements");
211 trace_dump_arg(ptr
, pipe
);
212 trace_dump_arg(ptr
, indexBuffer
);
213 trace_dump_arg(uint
, indexSize
);
214 trace_dump_arg(uint
, mode
);
215 trace_dump_arg(uint
, start
);
216 trace_dump_arg(uint
, count
);
218 pipe
->draw_elements(pipe
, indexBuffer
, indexSize
, mode
, start
, count
);
220 trace_dump_call_end();
222 trace_context_draw_block(tr_ctx
, 2);
227 trace_context_draw_range_elements(struct pipe_context
*_pipe
,
228 struct pipe_buffer
*_indexBuffer
,
236 struct trace_context
*tr_ctx
= trace_context(_pipe
);
237 struct trace_buffer
*tr_buf
= trace_buffer(_indexBuffer
);
238 struct pipe_context
*pipe
= tr_ctx
->pipe
;
239 struct pipe_buffer
*indexBuffer
= tr_buf
->buffer
;
241 if (tr_ctx
->curr
.fs
->disabled
|| tr_ctx
->curr
.vs
->disabled
)
244 trace_context_draw_block(tr_ctx
, 1);
246 trace_screen_user_buffer_update(_pipe
->screen
, indexBuffer
);
248 trace_dump_call_begin("pipe_context", "draw_range_elements");
250 trace_dump_arg(ptr
, pipe
);
251 trace_dump_arg(ptr
, indexBuffer
);
252 trace_dump_arg(uint
, indexSize
);
253 trace_dump_arg(uint
, minIndex
);
254 trace_dump_arg(uint
, maxIndex
);
255 trace_dump_arg(uint
, mode
);
256 trace_dump_arg(uint
, start
);
257 trace_dump_arg(uint
, count
);
259 pipe
->draw_range_elements(pipe
,
261 indexSize
, minIndex
, maxIndex
,
264 trace_dump_call_end();
266 trace_context_draw_block(tr_ctx
, 2);
270 static INLINE
struct pipe_query
*
271 trace_context_create_query(struct pipe_context
*_pipe
,
274 struct trace_context
*tr_ctx
= trace_context(_pipe
);
275 struct pipe_context
*pipe
= tr_ctx
->pipe
;
276 struct pipe_query
*result
;
278 trace_dump_call_begin("pipe_context", "create_query");
280 trace_dump_arg(ptr
, pipe
);
281 trace_dump_arg(uint
, query_type
);
283 result
= pipe
->create_query(pipe
, query_type
);
285 trace_dump_ret(ptr
, result
);
287 trace_dump_call_end();
294 trace_context_destroy_query(struct pipe_context
*_pipe
,
295 struct pipe_query
*query
)
297 struct trace_context
*tr_ctx
= trace_context(_pipe
);
298 struct pipe_context
*pipe
= tr_ctx
->pipe
;
300 trace_dump_call_begin("pipe_context", "destroy_query");
302 trace_dump_arg(ptr
, pipe
);
303 trace_dump_arg(ptr
, query
);
305 pipe
->destroy_query(pipe
, query
);
307 trace_dump_call_end();
312 trace_context_begin_query(struct pipe_context
*_pipe
,
313 struct pipe_query
*query
)
315 struct trace_context
*tr_ctx
= trace_context(_pipe
);
316 struct pipe_context
*pipe
= tr_ctx
->pipe
;
318 trace_dump_call_begin("pipe_context", "begin_query");
320 trace_dump_arg(ptr
, pipe
);
321 trace_dump_arg(ptr
, query
);
323 pipe
->begin_query(pipe
, query
);
325 trace_dump_call_end();
330 trace_context_end_query(struct pipe_context
*_pipe
,
331 struct pipe_query
*query
)
333 struct trace_context
*tr_ctx
= trace_context(_pipe
);
334 struct pipe_context
*pipe
= tr_ctx
->pipe
;
336 trace_dump_call_begin("pipe_context", "end_query");
338 trace_dump_arg(ptr
, pipe
);
339 trace_dump_arg(ptr
, query
);
341 pipe
->end_query(pipe
, query
);
343 trace_dump_call_end();
347 static INLINE boolean
348 trace_context_get_query_result(struct pipe_context
*_pipe
,
349 struct pipe_query
*query
,
353 struct trace_context
*tr_ctx
= trace_context(_pipe
);
354 struct pipe_context
*pipe
= tr_ctx
->pipe
;
358 trace_dump_call_begin("pipe_context", "get_query_result");
360 trace_dump_arg(ptr
, pipe
);
362 _result
= pipe
->get_query_result(pipe
, query
, wait
, presult
);
365 trace_dump_arg(uint
, result
);
366 trace_dump_ret(bool, _result
);
368 trace_dump_call_end();
375 trace_context_create_blend_state(struct pipe_context
*_pipe
,
376 const struct pipe_blend_state
*state
)
378 struct trace_context
*tr_ctx
= trace_context(_pipe
);
379 struct pipe_context
*pipe
= tr_ctx
->pipe
;
382 trace_dump_call_begin("pipe_context", "create_blend_state");
384 trace_dump_arg(ptr
, pipe
);
385 trace_dump_arg(blend_state
, state
);
387 result
= pipe
->create_blend_state(pipe
, state
);
389 trace_dump_ret(ptr
, result
);
391 trace_dump_call_end();
398 trace_context_bind_blend_state(struct pipe_context
*_pipe
,
401 struct trace_context
*tr_ctx
= trace_context(_pipe
);
402 struct pipe_context
*pipe
= tr_ctx
->pipe
;
404 trace_dump_call_begin("pipe_context", "bind_blend_state");
406 trace_dump_arg(ptr
, pipe
);
407 trace_dump_arg(ptr
, state
);
409 pipe
->bind_blend_state(pipe
, state
);
411 trace_dump_call_end();
416 trace_context_delete_blend_state(struct pipe_context
*_pipe
,
419 struct trace_context
*tr_ctx
= trace_context(_pipe
);
420 struct pipe_context
*pipe
= tr_ctx
->pipe
;
422 trace_dump_call_begin("pipe_context", "delete_blend_state");
424 trace_dump_arg(ptr
, pipe
);
425 trace_dump_arg(ptr
, state
);
427 pipe
->delete_blend_state(pipe
, state
);
429 trace_dump_call_end();
434 trace_context_create_sampler_state(struct pipe_context
*_pipe
,
435 const struct pipe_sampler_state
*state
)
437 struct trace_context
*tr_ctx
= trace_context(_pipe
);
438 struct pipe_context
*pipe
= tr_ctx
->pipe
;
441 trace_dump_call_begin("pipe_context", "create_sampler_state");
443 trace_dump_arg(ptr
, pipe
);
444 trace_dump_arg(sampler_state
, state
);
446 result
= pipe
->create_sampler_state(pipe
, state
);
448 trace_dump_ret(ptr
, result
);
450 trace_dump_call_end();
457 trace_context_bind_fragment_sampler_states(struct pipe_context
*_pipe
,
461 struct trace_context
*tr_ctx
= trace_context(_pipe
);
462 struct pipe_context
*pipe
= tr_ctx
->pipe
;
464 trace_dump_call_begin("pipe_context", "bind_fragment_sampler_states");
466 trace_dump_arg(ptr
, pipe
);
467 trace_dump_arg(uint
, num_states
);
468 trace_dump_arg_array(ptr
, states
, num_states
);
470 pipe
->bind_fragment_sampler_states(pipe
, num_states
, states
);
472 trace_dump_call_end();
477 trace_context_bind_vertex_sampler_states(struct pipe_context
*_pipe
,
481 struct trace_context
*tr_ctx
= trace_context(_pipe
);
482 struct pipe_context
*pipe
= tr_ctx
->pipe
;
484 trace_dump_call_begin("pipe_context", "bind_vertex_sampler_states");
486 trace_dump_arg(ptr
, pipe
);
487 trace_dump_arg(uint
, num_states
);
488 trace_dump_arg_array(ptr
, states
, num_states
);
490 pipe
->bind_vertex_sampler_states(pipe
, num_states
, states
);
492 trace_dump_call_end();
497 trace_context_delete_sampler_state(struct pipe_context
*_pipe
,
500 struct trace_context
*tr_ctx
= trace_context(_pipe
);
501 struct pipe_context
*pipe
= tr_ctx
->pipe
;
503 trace_dump_call_begin("pipe_context", "delete_sampler_state");
505 trace_dump_arg(ptr
, pipe
);
506 trace_dump_arg(ptr
, state
);
508 pipe
->delete_sampler_state(pipe
, state
);
510 trace_dump_call_end();
515 trace_context_create_rasterizer_state(struct pipe_context
*_pipe
,
516 const struct pipe_rasterizer_state
*state
)
518 struct trace_context
*tr_ctx
= trace_context(_pipe
);
519 struct pipe_context
*pipe
= tr_ctx
->pipe
;
522 trace_dump_call_begin("pipe_context", "create_rasterizer_state");
524 trace_dump_arg(ptr
, pipe
);
525 trace_dump_arg(rasterizer_state
, state
);
527 result
= pipe
->create_rasterizer_state(pipe
, state
);
529 trace_dump_ret(ptr
, result
);
531 trace_dump_call_end();
538 trace_context_bind_rasterizer_state(struct pipe_context
*_pipe
,
541 struct trace_context
*tr_ctx
= trace_context(_pipe
);
542 struct pipe_context
*pipe
= tr_ctx
->pipe
;
544 trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
546 trace_dump_arg(ptr
, pipe
);
547 trace_dump_arg(ptr
, state
);
549 pipe
->bind_rasterizer_state(pipe
, state
);
551 trace_dump_call_end();
556 trace_context_delete_rasterizer_state(struct pipe_context
*_pipe
,
559 struct trace_context
*tr_ctx
= trace_context(_pipe
);
560 struct pipe_context
*pipe
= tr_ctx
->pipe
;
562 trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
564 trace_dump_arg(ptr
, pipe
);
565 trace_dump_arg(ptr
, state
);
567 pipe
->delete_rasterizer_state(pipe
, state
);
569 trace_dump_call_end();
574 trace_context_create_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
575 const struct pipe_depth_stencil_alpha_state
*state
)
577 struct trace_context
*tr_ctx
= trace_context(_pipe
);
578 struct pipe_context
*pipe
= tr_ctx
->pipe
;
581 trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
583 result
= pipe
->create_depth_stencil_alpha_state(pipe
, state
);
585 trace_dump_arg(ptr
, pipe
);
586 trace_dump_arg(depth_stencil_alpha_state
, state
);
588 trace_dump_ret(ptr
, result
);
590 trace_dump_call_end();
597 trace_context_bind_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
600 struct trace_context
*tr_ctx
= trace_context(_pipe
);
601 struct pipe_context
*pipe
= tr_ctx
->pipe
;
603 trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
605 trace_dump_arg(ptr
, pipe
);
606 trace_dump_arg(ptr
, state
);
608 pipe
->bind_depth_stencil_alpha_state(pipe
, state
);
610 trace_dump_call_end();
615 trace_context_delete_depth_stencil_alpha_state(struct pipe_context
*_pipe
,
618 struct trace_context
*tr_ctx
= trace_context(_pipe
);
619 struct pipe_context
*pipe
= tr_ctx
->pipe
;
621 trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
623 trace_dump_arg(ptr
, pipe
);
624 trace_dump_arg(ptr
, state
);
626 pipe
->delete_depth_stencil_alpha_state(pipe
, state
);
628 trace_dump_call_end();
633 trace_context_create_fs_state(struct pipe_context
*_pipe
,
634 const struct pipe_shader_state
*state
)
636 struct trace_context
*tr_ctx
= trace_context(_pipe
);
637 struct pipe_context
*pipe
= tr_ctx
->pipe
;
640 trace_dump_call_begin("pipe_context", "create_fs_state");
642 trace_dump_arg(ptr
, pipe
);
643 trace_dump_arg(shader_state
, state
);
645 result
= pipe
->create_fs_state(pipe
, state
);
647 trace_dump_ret(ptr
, result
);
649 trace_dump_call_end();
651 result
= trace_shader_create(tr_ctx
, state
, result
, TRACE_SHADER_FRAGMENT
);
658 trace_context_bind_fs_state(struct pipe_context
*_pipe
,
661 struct trace_context
*tr_ctx
= trace_context(_pipe
);
662 struct trace_shader
*tr_shdr
= trace_shader(_state
);
663 struct pipe_context
*pipe
= tr_ctx
->pipe
;
664 void *state
= tr_shdr
? tr_shdr
->state
: NULL
;
666 trace_dump_call_begin("pipe_context", "bind_fs_state");
668 trace_dump_arg(ptr
, pipe
);
669 trace_dump_arg(ptr
, state
);
671 tr_ctx
->curr
.fs
= tr_shdr
;
673 if (tr_shdr
&& tr_shdr
->replaced
)
674 state
= tr_shdr
->replaced
;
676 pipe
->bind_fs_state(pipe
, state
);
678 trace_dump_call_end();
683 trace_context_delete_fs_state(struct pipe_context
*_pipe
,
686 struct trace_context
*tr_ctx
= trace_context(_pipe
);
687 struct trace_shader
*tr_shdr
= trace_shader(_state
);
688 struct pipe_context
*pipe
= tr_ctx
->pipe
;
689 void *state
= tr_shdr
->state
;
691 trace_dump_call_begin("pipe_context", "delete_fs_state");
693 trace_dump_arg(ptr
, pipe
);
694 trace_dump_arg(ptr
, state
);
696 pipe
->delete_fs_state(pipe
, state
);
698 trace_dump_call_end();
700 trace_shader_destroy(tr_ctx
, tr_shdr
);
705 trace_context_create_vs_state(struct pipe_context
*_pipe
,
706 const struct pipe_shader_state
*state
)
708 struct trace_context
*tr_ctx
= trace_context(_pipe
);
709 struct pipe_context
*pipe
= tr_ctx
->pipe
;
712 trace_dump_call_begin("pipe_context", "create_vs_state");
714 trace_dump_arg(ptr
, pipe
);
715 trace_dump_arg(shader_state
, state
);
717 result
= pipe
->create_vs_state(pipe
, state
);
719 trace_dump_ret(ptr
, result
);
721 trace_dump_call_end();
723 result
= trace_shader_create(tr_ctx
, state
, result
, TRACE_SHADER_VERTEX
);
730 trace_context_bind_vs_state(struct pipe_context
*_pipe
,
733 struct trace_context
*tr_ctx
= trace_context(_pipe
);
734 struct trace_shader
*tr_shdr
= trace_shader(_state
);
735 struct pipe_context
*pipe
= tr_ctx
->pipe
;
736 void *state
= tr_shdr
? tr_shdr
->state
: NULL
;
738 trace_dump_call_begin("pipe_context", "bind_vs_state");
740 trace_dump_arg(ptr
, pipe
);
741 trace_dump_arg(ptr
, state
);
743 tr_ctx
->curr
.vs
= tr_shdr
;
745 if (tr_shdr
&& tr_shdr
->replaced
)
746 state
= tr_shdr
->replaced
;
748 pipe
->bind_vs_state(pipe
, state
);
750 trace_dump_call_end();
755 trace_context_delete_vs_state(struct pipe_context
*_pipe
,
758 struct trace_context
*tr_ctx
= trace_context(_pipe
);
759 struct trace_shader
*tr_shdr
= trace_shader(_state
);
760 struct pipe_context
*pipe
= tr_ctx
->pipe
;
761 void *state
= tr_shdr
->state
;
763 trace_dump_call_begin("pipe_context", "delete_vs_state");
765 trace_dump_arg(ptr
, pipe
);
766 trace_dump_arg(ptr
, state
);
768 pipe
->delete_vs_state(pipe
, state
);
770 trace_dump_call_end();
772 trace_shader_destroy(tr_ctx
, tr_shdr
);
777 trace_context_set_blend_color(struct pipe_context
*_pipe
,
778 const struct pipe_blend_color
*state
)
780 struct trace_context
*tr_ctx
= trace_context(_pipe
);
781 struct pipe_context
*pipe
= tr_ctx
->pipe
;
783 trace_dump_call_begin("pipe_context", "set_blend_color");
785 trace_dump_arg(ptr
, pipe
);
786 trace_dump_arg(blend_color
, state
);
788 pipe
->set_blend_color(pipe
, state
);
790 trace_dump_call_end();
795 trace_context_set_clip_state(struct pipe_context
*_pipe
,
796 const struct pipe_clip_state
*state
)
798 struct trace_context
*tr_ctx
= trace_context(_pipe
);
799 struct pipe_context
*pipe
= tr_ctx
->pipe
;
801 trace_dump_call_begin("pipe_context", "set_clip_state");
803 trace_dump_arg(ptr
, pipe
);
804 trace_dump_arg(clip_state
, state
);
806 pipe
->set_clip_state(pipe
, state
);
808 trace_dump_call_end();
813 trace_context_set_constant_buffer(struct pipe_context
*_pipe
,
814 uint shader
, uint index
,
815 const struct pipe_constant_buffer
*buffer
)
817 struct trace_context
*tr_ctx
= trace_context(_pipe
);
818 struct pipe_context
*pipe
= tr_ctx
->pipe
;
821 trace_screen_user_buffer_update(_pipe
->screen
, buffer
->buffer
);
823 trace_dump_call_begin("pipe_context", "set_constant_buffer");
825 trace_dump_arg(ptr
, pipe
);
826 trace_dump_arg(uint
, shader
);
827 trace_dump_arg(uint
, index
);
828 trace_dump_arg(constant_buffer
, buffer
);
831 struct pipe_constant_buffer _buffer
;
832 _buffer
.buffer
= trace_buffer_unwrap(tr_ctx
, buffer
->buffer
);
833 pipe
->set_constant_buffer(pipe
, shader
, index
, &_buffer
);
835 pipe
->set_constant_buffer(pipe
, shader
, index
, buffer
);
838 trace_dump_call_end();
843 trace_context_set_framebuffer_state(struct pipe_context
*_pipe
,
844 const struct pipe_framebuffer_state
*state
)
846 struct trace_context
*tr_ctx
= trace_context(_pipe
);
847 struct pipe_context
*pipe
= tr_ctx
->pipe
;
848 struct pipe_framebuffer_state unwrapped_state
;
852 tr_ctx
->curr
.nr_cbufs
= state
->nr_cbufs
;
853 for (i
= 0; i
< state
->nr_cbufs
; i
++)
855 tr_ctx
->curr
.cbufs
[i
] = trace_texture(state
->cbufs
[i
]->texture
);
857 tr_ctx
->curr
.cbufs
[i
] = NULL
;
859 tr_ctx
->curr
.zsbuf
= trace_texture(state
->zsbuf
->texture
);
861 tr_ctx
->curr
.zsbuf
= NULL
;
864 /* Unwrap the input state */
865 memcpy(&unwrapped_state
, state
, sizeof(unwrapped_state
));
866 for(i
= 0; i
< state
->nr_cbufs
; ++i
)
867 unwrapped_state
.cbufs
[i
] = trace_surface_unwrap(tr_ctx
, state
->cbufs
[i
]);
868 for(i
= state
->nr_cbufs
; i
< PIPE_MAX_COLOR_BUFS
; ++i
)
869 unwrapped_state
.cbufs
[i
] = NULL
;
870 unwrapped_state
.zsbuf
= trace_surface_unwrap(tr_ctx
, state
->zsbuf
);
871 state
= &unwrapped_state
;
873 trace_dump_call_begin("pipe_context", "set_framebuffer_state");
875 trace_dump_arg(ptr
, pipe
);
876 trace_dump_arg(framebuffer_state
, state
);
878 pipe
->set_framebuffer_state(pipe
, state
);
880 trace_dump_call_end();
885 trace_context_set_polygon_stipple(struct pipe_context
*_pipe
,
886 const struct pipe_poly_stipple
*state
)
888 struct trace_context
*tr_ctx
= trace_context(_pipe
);
889 struct pipe_context
*pipe
= tr_ctx
->pipe
;
891 trace_dump_call_begin("pipe_context", "set_polygon_stipple");
893 trace_dump_arg(ptr
, pipe
);
894 trace_dump_arg(poly_stipple
, state
);
896 pipe
->set_polygon_stipple(pipe
, state
);
898 trace_dump_call_end();
903 trace_context_set_scissor_state(struct pipe_context
*_pipe
,
904 const struct pipe_scissor_state
*state
)
906 struct trace_context
*tr_ctx
= trace_context(_pipe
);
907 struct pipe_context
*pipe
= tr_ctx
->pipe
;
909 trace_dump_call_begin("pipe_context", "set_scissor_state");
911 trace_dump_arg(ptr
, pipe
);
912 trace_dump_arg(scissor_state
, state
);
914 pipe
->set_scissor_state(pipe
, state
);
916 trace_dump_call_end();
921 trace_context_set_viewport_state(struct pipe_context
*_pipe
,
922 const struct pipe_viewport_state
*state
)
924 struct trace_context
*tr_ctx
= trace_context(_pipe
);
925 struct pipe_context
*pipe
= tr_ctx
->pipe
;
927 trace_dump_call_begin("pipe_context", "set_viewport_state");
929 trace_dump_arg(ptr
, pipe
);
930 trace_dump_arg(viewport_state
, state
);
932 pipe
->set_viewport_state(pipe
, state
);
934 trace_dump_call_end();
939 trace_context_set_fragment_sampler_textures(struct pipe_context
*_pipe
,
940 unsigned num_textures
,
941 struct pipe_texture
**textures
)
943 struct trace_context
*tr_ctx
= trace_context(_pipe
);
944 struct trace_texture
*tr_tex
;
945 struct pipe_context
*pipe
= tr_ctx
->pipe
;
946 struct pipe_texture
*unwrapped_textures
[PIPE_MAX_SAMPLERS
];
949 tr_ctx
->curr
.num_texs
= num_textures
;
950 for(i
= 0; i
< num_textures
; ++i
) {
951 tr_tex
= trace_texture(textures
[i
]);
952 tr_ctx
->curr
.tex
[i
] = tr_tex
;
953 unwrapped_textures
[i
] = tr_tex
? tr_tex
->texture
: NULL
;
955 textures
= unwrapped_textures
;
957 trace_dump_call_begin("pipe_context", "set_fragment_sampler_textures");
959 trace_dump_arg(ptr
, pipe
);
960 trace_dump_arg(uint
, num_textures
);
961 trace_dump_arg_array(ptr
, textures
, num_textures
);
963 pipe
->set_fragment_sampler_textures(pipe
, num_textures
, textures
);
965 trace_dump_call_end();
970 trace_context_set_vertex_sampler_textures(struct pipe_context
*_pipe
,
971 unsigned num_textures
,
972 struct pipe_texture
**textures
)
974 struct trace_context
*tr_ctx
= trace_context(_pipe
);
975 struct trace_texture
*tr_tex
;
976 struct pipe_context
*pipe
= tr_ctx
->pipe
;
977 struct pipe_texture
*unwrapped_textures
[PIPE_MAX_VERTEX_SAMPLERS
];
980 tr_ctx
->curr
.num_vert_texs
= num_textures
;
981 for(i
= 0; i
< num_textures
; ++i
) {
982 tr_tex
= trace_texture(textures
[i
]);
983 tr_ctx
->curr
.vert_tex
[i
] = tr_tex
;
984 unwrapped_textures
[i
] = tr_tex
? tr_tex
->texture
: NULL
;
986 textures
= unwrapped_textures
;
988 trace_dump_call_begin("pipe_context", "set_vertex_sampler_textures");
990 trace_dump_arg(ptr
, pipe
);
991 trace_dump_arg(uint
, num_textures
);
992 trace_dump_arg_array(ptr
, textures
, num_textures
);
994 pipe
->set_vertex_sampler_textures(pipe
, num_textures
, textures
);
996 trace_dump_call_end();
1001 trace_context_set_vertex_buffers(struct pipe_context
*_pipe
,
1002 unsigned num_buffers
,
1003 const struct pipe_vertex_buffer
*buffers
)
1005 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1006 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1009 for(i
= 0; i
< num_buffers
; ++i
)
1010 trace_screen_user_buffer_update(_pipe
->screen
, buffers
[i
].buffer
);
1012 trace_dump_call_begin("pipe_context", "set_vertex_buffers");
1014 trace_dump_arg(ptr
, pipe
);
1015 trace_dump_arg(uint
, num_buffers
);
1017 trace_dump_arg_begin("buffers");
1018 trace_dump_struct_array(vertex_buffer
, buffers
, num_buffers
);
1019 trace_dump_arg_end();
1022 struct pipe_vertex_buffer
*_buffers
= malloc(num_buffers
* sizeof(*_buffers
));
1023 memcpy(_buffers
, buffers
, num_buffers
* sizeof(*_buffers
));
1024 for (i
= 0; i
< num_buffers
; i
++)
1025 _buffers
[i
].buffer
= trace_buffer_unwrap(tr_ctx
, buffers
[i
].buffer
);
1026 pipe
->set_vertex_buffers(pipe
, num_buffers
, _buffers
);
1029 pipe
->set_vertex_buffers(pipe
, num_buffers
, NULL
);
1032 trace_dump_call_end();
1037 trace_context_set_vertex_elements(struct pipe_context
*_pipe
,
1038 unsigned num_elements
,
1039 const struct pipe_vertex_element
*elements
)
1041 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1042 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1044 trace_dump_call_begin("pipe_context", "set_vertex_elements");
1046 trace_dump_arg(ptr
, pipe
);
1047 trace_dump_arg(uint
, num_elements
);
1049 trace_dump_arg_begin("elements");
1050 trace_dump_struct_array(vertex_element
, elements
, num_elements
);
1051 trace_dump_arg_end();
1053 pipe
->set_vertex_elements(pipe
, num_elements
, elements
);
1055 trace_dump_call_end();
1060 trace_context_surface_copy(struct pipe_context
*_pipe
,
1061 struct pipe_surface
*dest
,
1062 unsigned destx
, unsigned desty
,
1063 struct pipe_surface
*src
,
1064 unsigned srcx
, unsigned srcy
,
1065 unsigned width
, unsigned height
)
1067 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1068 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1070 dest
= trace_surface_unwrap(tr_ctx
, dest
);
1071 src
= trace_surface_unwrap(tr_ctx
, src
);
1073 trace_dump_call_begin("pipe_context", "surface_copy");
1075 trace_dump_arg(ptr
, pipe
);
1076 trace_dump_arg(ptr
, dest
);
1077 trace_dump_arg(uint
, destx
);
1078 trace_dump_arg(uint
, desty
);
1079 trace_dump_arg(ptr
, src
);
1080 trace_dump_arg(uint
, srcx
);
1081 trace_dump_arg(uint
, srcy
);
1082 trace_dump_arg(uint
, width
);
1083 trace_dump_arg(uint
, height
);
1085 pipe
->surface_copy(pipe
,
1087 src
, srcx
, srcy
, width
, height
);
1089 trace_dump_call_end();
1094 trace_context_surface_fill(struct pipe_context
*_pipe
,
1095 struct pipe_surface
*dst
,
1096 unsigned dstx
, unsigned dsty
,
1097 unsigned width
, unsigned height
,
1100 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1101 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1103 dst
= trace_surface_unwrap(tr_ctx
, dst
);
1105 trace_dump_call_begin("pipe_context", "surface_fill");
1107 trace_dump_arg(ptr
, pipe
);
1108 trace_dump_arg(ptr
, dst
);
1109 trace_dump_arg(uint
, dstx
);
1110 trace_dump_arg(uint
, dsty
);
1111 trace_dump_arg(uint
, width
);
1112 trace_dump_arg(uint
, height
);
1114 pipe
->surface_fill(pipe
, dst
, dstx
, dsty
, width
, height
, value
);
1116 trace_dump_call_end();
1121 trace_context_clear(struct pipe_context
*_pipe
,
1127 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1128 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1130 trace_dump_call_begin("pipe_context", "clear");
1132 trace_dump_arg(ptr
, pipe
);
1133 trace_dump_arg(uint
, buffers
);
1134 trace_dump_arg_array(float, rgba
, 4);
1135 trace_dump_arg(float, depth
);
1136 trace_dump_arg(uint
, stencil
);
1138 pipe
->clear(pipe
, buffers
, rgba
, depth
, stencil
);
1140 trace_dump_call_end();
1145 trace_context_flush(struct pipe_context
*_pipe
,
1147 struct pipe_fence_handle
**fence
)
1149 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1150 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1152 trace_dump_call_begin("pipe_context", "flush");
1154 trace_dump_arg(ptr
, pipe
);
1155 trace_dump_arg(uint
, flags
);
1157 pipe
->flush(pipe
, flags
, fence
);
1160 trace_dump_ret(ptr
, *fence
);
1162 trace_dump_call_end();
1167 trace_context_destroy(struct pipe_context
*_pipe
)
1169 struct trace_screen
*tr_scr
= trace_screen(_pipe
->screen
);
1170 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1171 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1173 trace_dump_call_begin("pipe_context", "destroy");
1174 trace_dump_arg(ptr
, pipe
);
1175 trace_dump_call_end();
1177 trace_screen_remove_from_list(tr_scr
, contexts
, tr_ctx
);
1179 pipe
->destroy(pipe
);
1185 trace_is_texture_referenced( struct pipe_context
*_pipe
,
1186 struct pipe_texture
*_texture
,
1187 unsigned face
, unsigned level
)
1189 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1190 struct trace_texture
*tr_tex
= trace_texture(_texture
);
1191 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1192 struct pipe_texture
*texture
= tr_tex
->texture
;
1193 unsigned int referenced
;
1195 trace_dump_call_begin("pipe_context", "is_texture_referenced");
1196 trace_dump_arg(ptr
, pipe
);
1197 trace_dump_arg(ptr
, texture
);
1198 trace_dump_arg(uint
, face
);
1199 trace_dump_arg(uint
, level
);
1201 referenced
= pipe
->is_texture_referenced(pipe
, texture
, face
, level
);
1203 trace_dump_ret(uint
, referenced
);
1204 trace_dump_call_end();
1210 trace_is_buffer_referenced( struct pipe_context
*_pipe
,
1211 struct pipe_buffer
*_buf
)
1213 struct trace_context
*tr_ctx
= trace_context(_pipe
);
1214 struct trace_buffer
*tr_buf
= trace_buffer(_buf
);
1215 struct pipe_context
*pipe
= tr_ctx
->pipe
;
1216 struct pipe_buffer
*buf
= tr_buf
->buffer
;
1217 unsigned int referenced
;
1219 trace_dump_call_begin("pipe_context", "is_buffer_referenced");
1220 trace_dump_arg(ptr
, pipe
);
1221 trace_dump_arg(ptr
, buf
);
1223 referenced
= pipe
->is_buffer_referenced(pipe
, buf
);
1225 trace_dump_ret(uint
, referenced
);
1226 trace_dump_call_end();
1231 static const struct debug_named_value rbug_blocker_flags
[] = {
1237 struct pipe_context
*
1238 trace_context_create(struct pipe_screen
*_screen
,
1239 struct pipe_context
*pipe
)
1241 struct trace_screen
*tr_scr
;
1242 struct trace_context
*tr_ctx
;
1243 struct pipe_screen
*screen
;
1248 if(!trace_enabled())
1251 tr_scr
= trace_screen(_screen
);
1252 screen
= tr_scr
->screen
;
1254 tr_ctx
= CALLOC_STRUCT(trace_context
);
1258 tr_ctx
->draw_blocker
= debug_get_flags_option("RBUG_BLOCK",
1261 pipe_mutex_init(tr_ctx
->draw_mutex
);
1262 pipe_condvar_init(tr_ctx
->draw_cond
);
1263 pipe_mutex_init(tr_ctx
->list_mutex
);
1264 make_empty_list(&tr_ctx
->shaders
);
1266 tr_ctx
->base
.winsys
= _screen
->winsys
;
1267 tr_ctx
->base
.screen
= _screen
;
1268 tr_ctx
->base
.destroy
= trace_context_destroy
;
1269 tr_ctx
->base
.draw_arrays
= trace_context_draw_arrays
;
1270 tr_ctx
->base
.draw_elements
= trace_context_draw_elements
;
1271 tr_ctx
->base
.draw_range_elements
= trace_context_draw_range_elements
;
1272 tr_ctx
->base
.create_query
= trace_context_create_query
;
1273 tr_ctx
->base
.destroy_query
= trace_context_destroy_query
;
1274 tr_ctx
->base
.begin_query
= trace_context_begin_query
;
1275 tr_ctx
->base
.end_query
= trace_context_end_query
;
1276 tr_ctx
->base
.get_query_result
= trace_context_get_query_result
;
1277 tr_ctx
->base
.create_blend_state
= trace_context_create_blend_state
;
1278 tr_ctx
->base
.bind_blend_state
= trace_context_bind_blend_state
;
1279 tr_ctx
->base
.delete_blend_state
= trace_context_delete_blend_state
;
1280 tr_ctx
->base
.create_sampler_state
= trace_context_create_sampler_state
;
1281 tr_ctx
->base
.bind_fragment_sampler_states
= trace_context_bind_fragment_sampler_states
;
1282 tr_ctx
->base
.bind_vertex_sampler_states
= trace_context_bind_vertex_sampler_states
;
1283 tr_ctx
->base
.delete_sampler_state
= trace_context_delete_sampler_state
;
1284 tr_ctx
->base
.create_rasterizer_state
= trace_context_create_rasterizer_state
;
1285 tr_ctx
->base
.bind_rasterizer_state
= trace_context_bind_rasterizer_state
;
1286 tr_ctx
->base
.delete_rasterizer_state
= trace_context_delete_rasterizer_state
;
1287 tr_ctx
->base
.create_depth_stencil_alpha_state
= trace_context_create_depth_stencil_alpha_state
;
1288 tr_ctx
->base
.bind_depth_stencil_alpha_state
= trace_context_bind_depth_stencil_alpha_state
;
1289 tr_ctx
->base
.delete_depth_stencil_alpha_state
= trace_context_delete_depth_stencil_alpha_state
;
1290 tr_ctx
->base
.create_fs_state
= trace_context_create_fs_state
;
1291 tr_ctx
->base
.bind_fs_state
= trace_context_bind_fs_state
;
1292 tr_ctx
->base
.delete_fs_state
= trace_context_delete_fs_state
;
1293 tr_ctx
->base
.create_vs_state
= trace_context_create_vs_state
;
1294 tr_ctx
->base
.bind_vs_state
= trace_context_bind_vs_state
;
1295 tr_ctx
->base
.delete_vs_state
= trace_context_delete_vs_state
;
1296 tr_ctx
->base
.set_blend_color
= trace_context_set_blend_color
;
1297 tr_ctx
->base
.set_clip_state
= trace_context_set_clip_state
;
1298 tr_ctx
->base
.set_constant_buffer
= trace_context_set_constant_buffer
;
1299 tr_ctx
->base
.set_framebuffer_state
= trace_context_set_framebuffer_state
;
1300 tr_ctx
->base
.set_polygon_stipple
= trace_context_set_polygon_stipple
;
1301 tr_ctx
->base
.set_scissor_state
= trace_context_set_scissor_state
;
1302 tr_ctx
->base
.set_viewport_state
= trace_context_set_viewport_state
;
1303 tr_ctx
->base
.set_fragment_sampler_textures
= trace_context_set_fragment_sampler_textures
;
1304 tr_ctx
->base
.set_vertex_sampler_textures
= trace_context_set_vertex_sampler_textures
;
1305 tr_ctx
->base
.set_vertex_buffers
= trace_context_set_vertex_buffers
;
1306 tr_ctx
->base
.set_vertex_elements
= trace_context_set_vertex_elements
;
1307 if (pipe
->surface_copy
)
1308 tr_ctx
->base
.surface_copy
= trace_context_surface_copy
;
1309 if (pipe
->surface_fill
)
1310 tr_ctx
->base
.surface_fill
= trace_context_surface_fill
;
1311 tr_ctx
->base
.clear
= trace_context_clear
;
1312 tr_ctx
->base
.flush
= trace_context_flush
;
1313 tr_ctx
->base
.is_texture_referenced
= trace_is_texture_referenced
;
1314 tr_ctx
->base
.is_buffer_referenced
= trace_is_buffer_referenced
;
1316 tr_ctx
->pipe
= pipe
;
1318 trace_dump_call_begin("", "pipe_context_create");
1319 trace_dump_arg(ptr
, screen
);
1320 trace_dump_ret(ptr
, pipe
);
1321 trace_dump_call_end();
1323 trace_screen_add_to_list(tr_scr
, contexts
, tr_ctx
);
1325 return &tr_ctx
->base
;