240d85c69a183efdef440cfc156c5071ccfab998
[mesa.git] / src / gallium / drivers / trace / tr_context.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
25 *
26 **************************************************************************/
27
28 #include "util/u_inlines.h"
29 #include "util/u_memory.h"
30 #include "util/u_simple_list.h"
31
32 #include "pipe/p_format.h"
33 #include "pipe/p_screen.h"
34
35 #include "tr_dump.h"
36 #include "tr_dump_state.h"
37 #include "tr_public.h"
38 #include "tr_screen.h"
39 #include "tr_texture.h"
40 #include "tr_context.h"
41
42
43
44
45
46 static INLINE struct pipe_resource *
47 trace_resource_unwrap(struct trace_context *tr_ctx,
48 struct pipe_resource *resource)
49 {
50 struct trace_resource *tr_res;
51
52 if(!resource)
53 return NULL;
54
55 tr_res = trace_resource(resource);
56
57 assert(tr_res->resource);
58 return tr_res->resource;
59 }
60
61
62 static INLINE struct pipe_surface *
63 trace_surface_unwrap(struct trace_context *tr_ctx,
64 struct pipe_surface *surface)
65 {
66 struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
67 struct trace_surface *tr_surf;
68
69 if(!surface)
70 return NULL;
71
72 assert(surface->texture);
73 if(!surface->texture)
74 return surface;
75
76 tr_surf = trace_surface(surface);
77
78 assert(tr_surf->surface);
79 assert(tr_surf->surface->texture->screen == tr_scr->screen);
80 (void) tr_scr;
81 return tr_surf->surface;
82 }
83
84
85 static INLINE void
86 trace_context_draw_vbo(struct pipe_context *_pipe,
87 const struct pipe_draw_info *info)
88 {
89 struct trace_context *tr_ctx = trace_context(_pipe);
90 struct pipe_context *pipe = tr_ctx->pipe;
91
92 trace_dump_call_begin("pipe_context", "draw_vbo");
93
94 trace_dump_arg(ptr, pipe);
95 trace_dump_arg(draw_info, info);
96
97 pipe->draw_vbo(pipe, info);
98
99 trace_dump_call_end();
100 }
101
102
103 static INLINE struct pipe_query *
104 trace_context_create_query(struct pipe_context *_pipe,
105 unsigned query_type)
106 {
107 struct trace_context *tr_ctx = trace_context(_pipe);
108 struct pipe_context *pipe = tr_ctx->pipe;
109 struct pipe_query *result;
110
111 trace_dump_call_begin("pipe_context", "create_query");
112
113 trace_dump_arg(ptr, pipe);
114 trace_dump_arg(uint, query_type);
115
116 result = pipe->create_query(pipe, query_type);
117
118 trace_dump_ret(ptr, result);
119
120 trace_dump_call_end();
121
122 return result;
123 }
124
125
126 static INLINE void
127 trace_context_destroy_query(struct pipe_context *_pipe,
128 struct pipe_query *query)
129 {
130 struct trace_context *tr_ctx = trace_context(_pipe);
131 struct pipe_context *pipe = tr_ctx->pipe;
132
133 trace_dump_call_begin("pipe_context", "destroy_query");
134
135 trace_dump_arg(ptr, pipe);
136 trace_dump_arg(ptr, query);
137
138 pipe->destroy_query(pipe, query);
139
140 trace_dump_call_end();
141 }
142
143
144 static INLINE void
145 trace_context_begin_query(struct pipe_context *_pipe,
146 struct pipe_query *query)
147 {
148 struct trace_context *tr_ctx = trace_context(_pipe);
149 struct pipe_context *pipe = tr_ctx->pipe;
150
151 trace_dump_call_begin("pipe_context", "begin_query");
152
153 trace_dump_arg(ptr, pipe);
154 trace_dump_arg(ptr, query);
155
156 pipe->begin_query(pipe, query);
157
158 trace_dump_call_end();
159 }
160
161
162 static INLINE void
163 trace_context_end_query(struct pipe_context *_pipe,
164 struct pipe_query *query)
165 {
166 struct trace_context *tr_ctx = trace_context(_pipe);
167 struct pipe_context *pipe = tr_ctx->pipe;
168
169 trace_dump_call_begin("pipe_context", "end_query");
170
171 trace_dump_arg(ptr, pipe);
172 trace_dump_arg(ptr, query);
173
174 pipe->end_query(pipe, query);
175
176 trace_dump_call_end();
177 }
178
179
180 static INLINE boolean
181 trace_context_get_query_result(struct pipe_context *_pipe,
182 struct pipe_query *query,
183 boolean wait,
184 void *presult)
185 {
186 struct trace_context *tr_ctx = trace_context(_pipe);
187 struct pipe_context *pipe = tr_ctx->pipe;
188 uint64_t result;
189 boolean _result;
190
191 trace_dump_call_begin("pipe_context", "get_query_result");
192
193 trace_dump_arg(ptr, pipe);
194
195 _result = pipe->get_query_result(pipe, query, wait, presult);
196 result = *((uint64_t*)presult);
197
198 trace_dump_arg(uint, result);
199 trace_dump_ret(bool, _result);
200
201 trace_dump_call_end();
202
203 return _result;
204 }
205
206
207 static INLINE void *
208 trace_context_create_blend_state(struct pipe_context *_pipe,
209 const struct pipe_blend_state *state)
210 {
211 struct trace_context *tr_ctx = trace_context(_pipe);
212 struct pipe_context *pipe = tr_ctx->pipe;
213 void * result;
214
215 trace_dump_call_begin("pipe_context", "create_blend_state");
216
217 trace_dump_arg(ptr, pipe);
218 trace_dump_arg(blend_state, state);
219
220 result = pipe->create_blend_state(pipe, state);
221
222 trace_dump_ret(ptr, result);
223
224 trace_dump_call_end();
225
226 return result;
227 }
228
229
230 static INLINE void
231 trace_context_bind_blend_state(struct pipe_context *_pipe,
232 void *state)
233 {
234 struct trace_context *tr_ctx = trace_context(_pipe);
235 struct pipe_context *pipe = tr_ctx->pipe;
236
237 trace_dump_call_begin("pipe_context", "bind_blend_state");
238
239 trace_dump_arg(ptr, pipe);
240 trace_dump_arg(ptr, state);
241
242 pipe->bind_blend_state(pipe, state);
243
244 trace_dump_call_end();
245 }
246
247
248 static INLINE void
249 trace_context_delete_blend_state(struct pipe_context *_pipe,
250 void *state)
251 {
252 struct trace_context *tr_ctx = trace_context(_pipe);
253 struct pipe_context *pipe = tr_ctx->pipe;
254
255 trace_dump_call_begin("pipe_context", "delete_blend_state");
256
257 trace_dump_arg(ptr, pipe);
258 trace_dump_arg(ptr, state);
259
260 pipe->delete_blend_state(pipe, state);
261
262 trace_dump_call_end();
263 }
264
265
266 static INLINE void *
267 trace_context_create_sampler_state(struct pipe_context *_pipe,
268 const struct pipe_sampler_state *state)
269 {
270 struct trace_context *tr_ctx = trace_context(_pipe);
271 struct pipe_context *pipe = tr_ctx->pipe;
272 void * result;
273
274 trace_dump_call_begin("pipe_context", "create_sampler_state");
275
276 trace_dump_arg(ptr, pipe);
277 trace_dump_arg(sampler_state, state);
278
279 result = pipe->create_sampler_state(pipe, state);
280
281 trace_dump_ret(ptr, result);
282
283 trace_dump_call_end();
284
285 return result;
286 }
287
288
289 static INLINE void
290 trace_context_bind_fragment_sampler_states(struct pipe_context *_pipe,
291 unsigned num_states,
292 void **states)
293 {
294 struct trace_context *tr_ctx = trace_context(_pipe);
295 struct pipe_context *pipe = tr_ctx->pipe;
296
297 trace_dump_call_begin("pipe_context", "bind_fragment_sampler_states");
298
299 trace_dump_arg(ptr, pipe);
300 trace_dump_arg(uint, num_states);
301 trace_dump_arg_array(ptr, states, num_states);
302
303 pipe->bind_fragment_sampler_states(pipe, num_states, states);
304
305 trace_dump_call_end();
306 }
307
308
309 static INLINE void
310 trace_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
311 unsigned num_states,
312 void **states)
313 {
314 struct trace_context *tr_ctx = trace_context(_pipe);
315 struct pipe_context *pipe = tr_ctx->pipe;
316
317 if (!pipe->bind_vertex_sampler_states)
318 return;
319
320 trace_dump_call_begin("pipe_context", "bind_vertex_sampler_states");
321
322 trace_dump_arg(ptr, pipe);
323 trace_dump_arg(uint, num_states);
324 trace_dump_arg_array(ptr, states, num_states);
325
326 pipe->bind_vertex_sampler_states(pipe, num_states, states);
327
328 trace_dump_call_end();
329 }
330
331
332 static INLINE void
333 trace_context_delete_sampler_state(struct pipe_context *_pipe,
334 void *state)
335 {
336 struct trace_context *tr_ctx = trace_context(_pipe);
337 struct pipe_context *pipe = tr_ctx->pipe;
338
339 trace_dump_call_begin("pipe_context", "delete_sampler_state");
340
341 trace_dump_arg(ptr, pipe);
342 trace_dump_arg(ptr, state);
343
344 pipe->delete_sampler_state(pipe, state);
345
346 trace_dump_call_end();
347 }
348
349
350 static INLINE void *
351 trace_context_create_rasterizer_state(struct pipe_context *_pipe,
352 const struct pipe_rasterizer_state *state)
353 {
354 struct trace_context *tr_ctx = trace_context(_pipe);
355 struct pipe_context *pipe = tr_ctx->pipe;
356 void * result;
357
358 trace_dump_call_begin("pipe_context", "create_rasterizer_state");
359
360 trace_dump_arg(ptr, pipe);
361 trace_dump_arg(rasterizer_state, state);
362
363 result = pipe->create_rasterizer_state(pipe, state);
364
365 trace_dump_ret(ptr, result);
366
367 trace_dump_call_end();
368
369 return result;
370 }
371
372
373 static INLINE void
374 trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
375 void *state)
376 {
377 struct trace_context *tr_ctx = trace_context(_pipe);
378 struct pipe_context *pipe = tr_ctx->pipe;
379
380 trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
381
382 trace_dump_arg(ptr, pipe);
383 trace_dump_arg(ptr, state);
384
385 pipe->bind_rasterizer_state(pipe, state);
386
387 trace_dump_call_end();
388 }
389
390
391 static INLINE void
392 trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
393 void *state)
394 {
395 struct trace_context *tr_ctx = trace_context(_pipe);
396 struct pipe_context *pipe = tr_ctx->pipe;
397
398 trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
399
400 trace_dump_arg(ptr, pipe);
401 trace_dump_arg(ptr, state);
402
403 pipe->delete_rasterizer_state(pipe, state);
404
405 trace_dump_call_end();
406 }
407
408
409 static INLINE void *
410 trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
411 const struct pipe_depth_stencil_alpha_state *state)
412 {
413 struct trace_context *tr_ctx = trace_context(_pipe);
414 struct pipe_context *pipe = tr_ctx->pipe;
415 void * result;
416
417 trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
418
419 result = pipe->create_depth_stencil_alpha_state(pipe, state);
420
421 trace_dump_arg(ptr, pipe);
422 trace_dump_arg(depth_stencil_alpha_state, state);
423
424 trace_dump_ret(ptr, result);
425
426 trace_dump_call_end();
427
428 return result;
429 }
430
431
432 static INLINE void
433 trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
434 void *state)
435 {
436 struct trace_context *tr_ctx = trace_context(_pipe);
437 struct pipe_context *pipe = tr_ctx->pipe;
438
439 trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
440
441 trace_dump_arg(ptr, pipe);
442 trace_dump_arg(ptr, state);
443
444 pipe->bind_depth_stencil_alpha_state(pipe, state);
445
446 trace_dump_call_end();
447 }
448
449
450 static INLINE void
451 trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
452 void *state)
453 {
454 struct trace_context *tr_ctx = trace_context(_pipe);
455 struct pipe_context *pipe = tr_ctx->pipe;
456
457 trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
458
459 trace_dump_arg(ptr, pipe);
460 trace_dump_arg(ptr, state);
461
462 pipe->delete_depth_stencil_alpha_state(pipe, state);
463
464 trace_dump_call_end();
465 }
466
467
468 static INLINE void *
469 trace_context_create_fs_state(struct pipe_context *_pipe,
470 const struct pipe_shader_state *state)
471 {
472 struct trace_context *tr_ctx = trace_context(_pipe);
473 struct pipe_context *pipe = tr_ctx->pipe;
474 void * result;
475
476 trace_dump_call_begin("pipe_context", "create_fs_state");
477
478 trace_dump_arg(ptr, pipe);
479 trace_dump_arg(shader_state, state);
480
481 result = pipe->create_fs_state(pipe, state);
482
483 trace_dump_ret(ptr, result);
484
485 trace_dump_call_end();
486
487 return result;
488 }
489
490
491 static INLINE void
492 trace_context_bind_fs_state(struct pipe_context *_pipe,
493 void *state)
494 {
495 struct trace_context *tr_ctx = trace_context(_pipe);
496 struct pipe_context *pipe = tr_ctx->pipe;
497
498 trace_dump_call_begin("pipe_context", "bind_fs_state");
499
500 trace_dump_arg(ptr, pipe);
501 trace_dump_arg(ptr, state);
502
503 pipe->bind_fs_state(pipe, state);
504
505 trace_dump_call_end();
506 }
507
508
509 static INLINE void
510 trace_context_delete_fs_state(struct pipe_context *_pipe,
511 void *state)
512 {
513 struct trace_context *tr_ctx = trace_context(_pipe);
514 struct pipe_context *pipe = tr_ctx->pipe;
515
516 trace_dump_call_begin("pipe_context", "delete_fs_state");
517
518 trace_dump_arg(ptr, pipe);
519 trace_dump_arg(ptr, state);
520
521 pipe->delete_fs_state(pipe, state);
522
523 trace_dump_call_end();
524 }
525
526
527 static INLINE void *
528 trace_context_create_vs_state(struct pipe_context *_pipe,
529 const struct pipe_shader_state *state)
530 {
531 struct trace_context *tr_ctx = trace_context(_pipe);
532 struct pipe_context *pipe = tr_ctx->pipe;
533 void * result;
534
535 trace_dump_call_begin("pipe_context", "create_vs_state");
536
537 trace_dump_arg(ptr, pipe);
538 trace_dump_arg(shader_state, state);
539
540 result = pipe->create_vs_state(pipe, state);
541
542 trace_dump_ret(ptr, result);
543
544 trace_dump_call_end();
545
546 return result;
547 }
548
549
550 static INLINE void
551 trace_context_bind_vs_state(struct pipe_context *_pipe,
552 void *state)
553 {
554 struct trace_context *tr_ctx = trace_context(_pipe);
555 struct pipe_context *pipe = tr_ctx->pipe;
556
557 trace_dump_call_begin("pipe_context", "bind_vs_state");
558
559 trace_dump_arg(ptr, pipe);
560 trace_dump_arg(ptr, state);
561
562 pipe->bind_vs_state(pipe, state);
563
564 trace_dump_call_end();
565 }
566
567
568 static INLINE void
569 trace_context_delete_vs_state(struct pipe_context *_pipe,
570 void *state)
571 {
572 struct trace_context *tr_ctx = trace_context(_pipe);
573 struct pipe_context *pipe = tr_ctx->pipe;
574
575 trace_dump_call_begin("pipe_context", "delete_vs_state");
576
577 trace_dump_arg(ptr, pipe);
578 trace_dump_arg(ptr, state);
579
580 pipe->delete_vs_state(pipe, state);
581
582 trace_dump_call_end();
583 }
584
585
586 static INLINE void *
587 trace_context_create_vertex_elements_state(struct pipe_context *_pipe,
588 unsigned num_elements,
589 const struct pipe_vertex_element *elements)
590 {
591 struct trace_context *tr_ctx = trace_context(_pipe);
592 struct pipe_context *pipe = tr_ctx->pipe;
593 void * result;
594
595 trace_dump_call_begin("pipe_context", "create_vertex_elements_state");
596
597 trace_dump_arg(ptr, pipe);
598 trace_dump_arg(uint, num_elements);
599
600 trace_dump_arg_begin("elements");
601 trace_dump_struct_array(vertex_element, elements, num_elements);
602 trace_dump_arg_end();
603
604 result = pipe->create_vertex_elements_state(pipe, num_elements, elements);
605
606 trace_dump_ret(ptr, result);
607
608 trace_dump_call_end();
609
610 return result;
611 }
612
613
614 static INLINE void
615 trace_context_bind_vertex_elements_state(struct pipe_context *_pipe,
616 void *state)
617 {
618 struct trace_context *tr_ctx = trace_context(_pipe);
619 struct pipe_context *pipe = tr_ctx->pipe;
620
621 trace_dump_call_begin("pipe_context", "bind_vertex_elements_state");
622
623 trace_dump_arg(ptr, pipe);
624 trace_dump_arg(ptr, state);
625
626 pipe->bind_vertex_elements_state(pipe, state);
627
628 trace_dump_call_end();
629 }
630
631
632 static INLINE void
633 trace_context_delete_vertex_elements_state(struct pipe_context *_pipe,
634 void *state)
635 {
636 struct trace_context *tr_ctx = trace_context(_pipe);
637 struct pipe_context *pipe = tr_ctx->pipe;
638
639 trace_dump_call_begin("pipe_context", "delete_vertex_elements_state");
640
641 trace_dump_arg(ptr, pipe);
642 trace_dump_arg(ptr, state);
643
644 pipe->delete_vertex_elements_state(pipe, state);
645
646 trace_dump_call_end();
647 }
648
649
650 static INLINE void
651 trace_context_set_blend_color(struct pipe_context *_pipe,
652 const struct pipe_blend_color *state)
653 {
654 struct trace_context *tr_ctx = trace_context(_pipe);
655 struct pipe_context *pipe = tr_ctx->pipe;
656
657 trace_dump_call_begin("pipe_context", "set_blend_color");
658
659 trace_dump_arg(ptr, pipe);
660 trace_dump_arg(blend_color, state);
661
662 pipe->set_blend_color(pipe, state);
663
664 trace_dump_call_end();
665 }
666
667
668 static INLINE void
669 trace_context_set_stencil_ref(struct pipe_context *_pipe,
670 const struct pipe_stencil_ref *state)
671 {
672 struct trace_context *tr_ctx = trace_context(_pipe);
673 struct pipe_context *pipe = tr_ctx->pipe;
674
675 trace_dump_call_begin("pipe_context", "set_stencil_ref");
676
677 trace_dump_arg(ptr, pipe);
678 trace_dump_arg(stencil_ref, state);
679
680 pipe->set_stencil_ref(pipe, state);
681
682 trace_dump_call_end();
683 }
684
685
686 static INLINE void
687 trace_context_set_clip_state(struct pipe_context *_pipe,
688 const struct pipe_clip_state *state)
689 {
690 struct trace_context *tr_ctx = trace_context(_pipe);
691 struct pipe_context *pipe = tr_ctx->pipe;
692
693 trace_dump_call_begin("pipe_context", "set_clip_state");
694
695 trace_dump_arg(ptr, pipe);
696 trace_dump_arg(clip_state, state);
697
698 pipe->set_clip_state(pipe, state);
699
700 trace_dump_call_end();
701 }
702
703 static INLINE void
704 trace_context_set_sample_mask(struct pipe_context *_pipe,
705 unsigned sample_mask)
706 {
707 struct trace_context *tr_ctx = trace_context(_pipe);
708 struct pipe_context *pipe = tr_ctx->pipe;
709
710 trace_dump_call_begin("pipe_context", "set_sample_mask");
711
712 trace_dump_arg(ptr, pipe);
713 trace_dump_arg(uint, sample_mask);
714
715 pipe->set_sample_mask(pipe, sample_mask);
716
717 trace_dump_call_end();
718 }
719
720 static INLINE void
721 trace_context_set_constant_buffer(struct pipe_context *_pipe,
722 uint shader, uint index,
723 struct pipe_resource *buffer)
724 {
725 struct trace_context *tr_ctx = trace_context(_pipe);
726 struct pipe_context *pipe = tr_ctx->pipe;
727
728 if (buffer) {
729 buffer = trace_resource_unwrap(tr_ctx, buffer);
730 }
731
732 trace_dump_call_begin("pipe_context", "set_constant_buffer");
733
734 trace_dump_arg(ptr, pipe);
735 trace_dump_arg(uint, shader);
736 trace_dump_arg(uint, index);
737 trace_dump_arg(ptr, buffer);
738
739 pipe->set_constant_buffer(pipe, shader, index, buffer);
740
741 trace_dump_call_end();
742 }
743
744
745 static INLINE void
746 trace_context_set_framebuffer_state(struct pipe_context *_pipe,
747 const struct pipe_framebuffer_state *state)
748 {
749 struct trace_context *tr_ctx = trace_context(_pipe);
750 struct pipe_context *pipe = tr_ctx->pipe;
751 struct pipe_framebuffer_state unwrapped_state;
752 unsigned i;
753
754
755 /* Unwrap the input state */
756 memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
757 for(i = 0; i < state->nr_cbufs; ++i)
758 unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
759 for(i = state->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
760 unwrapped_state.cbufs[i] = NULL;
761 unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
762 state = &unwrapped_state;
763
764 trace_dump_call_begin("pipe_context", "set_framebuffer_state");
765
766 trace_dump_arg(ptr, pipe);
767 trace_dump_arg(framebuffer_state, state);
768
769 pipe->set_framebuffer_state(pipe, state);
770
771 trace_dump_call_end();
772 }
773
774
775 static INLINE void
776 trace_context_set_polygon_stipple(struct pipe_context *_pipe,
777 const struct pipe_poly_stipple *state)
778 {
779 struct trace_context *tr_ctx = trace_context(_pipe);
780 struct pipe_context *pipe = tr_ctx->pipe;
781
782 trace_dump_call_begin("pipe_context", "set_polygon_stipple");
783
784 trace_dump_arg(ptr, pipe);
785 trace_dump_arg(poly_stipple, state);
786
787 pipe->set_polygon_stipple(pipe, state);
788
789 trace_dump_call_end();
790 }
791
792
793 static INLINE void
794 trace_context_set_scissor_state(struct pipe_context *_pipe,
795 const struct pipe_scissor_state *state)
796 {
797 struct trace_context *tr_ctx = trace_context(_pipe);
798 struct pipe_context *pipe = tr_ctx->pipe;
799
800 trace_dump_call_begin("pipe_context", "set_scissor_state");
801
802 trace_dump_arg(ptr, pipe);
803 trace_dump_arg(scissor_state, state);
804
805 pipe->set_scissor_state(pipe, state);
806
807 trace_dump_call_end();
808 }
809
810
811 static INLINE void
812 trace_context_set_viewport_state(struct pipe_context *_pipe,
813 const struct pipe_viewport_state *state)
814 {
815 struct trace_context *tr_ctx = trace_context(_pipe);
816 struct pipe_context *pipe = tr_ctx->pipe;
817
818 trace_dump_call_begin("pipe_context", "set_viewport_state");
819
820 trace_dump_arg(ptr, pipe);
821 trace_dump_arg(viewport_state, state);
822
823 pipe->set_viewport_state(pipe, state);
824
825 trace_dump_call_end();
826 }
827
828
829 static struct pipe_sampler_view *
830 trace_create_sampler_view(struct pipe_context *_pipe,
831 struct pipe_resource *_resource,
832 const struct pipe_sampler_view *templ)
833 {
834 struct trace_context *tr_ctx = trace_context(_pipe);
835 struct trace_resource *tr_res = trace_resource(_resource);
836 struct pipe_context *pipe = tr_ctx->pipe;
837 struct pipe_resource *resource = tr_res->resource;
838 struct pipe_sampler_view *result;
839 struct trace_sampler_view *tr_view;
840
841 trace_dump_call_begin("pipe_context", "create_sampler_view");
842
843 trace_dump_arg(ptr, pipe);
844 trace_dump_arg(ptr, resource);
845
846 trace_dump_arg_begin("templ");
847 trace_dump_sampler_view_template(templ, resource->target);
848 trace_dump_arg_end();
849
850 result = pipe->create_sampler_view(pipe, resource, templ);
851
852 trace_dump_ret(ptr, result);
853
854 trace_dump_call_end();
855
856 /*
857 * Wrap pipe_sampler_view
858 */
859 tr_view = CALLOC_STRUCT(trace_sampler_view);
860 tr_view->base = *templ;
861 tr_view->base.reference.count = 1;
862 tr_view->base.texture = NULL;
863 pipe_resource_reference(&tr_view->base.texture, _resource);
864 tr_view->base.context = _pipe;
865 tr_view->sampler_view = result;
866 result = &tr_view->base;
867
868 return result;
869 }
870
871
872 static void
873 trace_sampler_view_destroy(struct pipe_context *_pipe,
874 struct pipe_sampler_view *_view)
875 {
876 struct trace_context *tr_ctx = trace_context(_pipe);
877 struct trace_sampler_view *tr_view = trace_sampler_view(_view);
878 struct pipe_context *pipe = tr_ctx->pipe;
879 struct pipe_sampler_view *view = tr_view->sampler_view;
880
881 trace_dump_call_begin("pipe_context", "sampler_view_destroy");
882
883 trace_dump_arg(ptr, pipe);
884 trace_dump_arg(ptr, view);
885
886 pipe_sampler_view_reference(&tr_view->sampler_view, NULL);
887
888 trace_dump_call_end();
889
890 pipe_resource_reference(&_view->texture, NULL);
891 FREE(_view);
892 }
893
894 /********************************************************************
895 * surface
896 */
897
898
899 static struct pipe_surface *
900 trace_create_surface(struct pipe_context *_pipe,
901 struct pipe_resource *_resource,
902 const struct pipe_surface *surf_tmpl)
903 {
904 struct trace_context *tr_ctx = trace_context(_pipe);
905 struct trace_resource *tr_res = trace_resource(_resource);
906 struct pipe_context *pipe = tr_ctx->pipe;
907 struct pipe_resource *resource = tr_res->resource;
908 struct pipe_surface *result = NULL;
909
910 trace_dump_call_begin("pipe_context", "create_surface");
911
912 trace_dump_arg(ptr, pipe);
913 trace_dump_arg(ptr, resource);
914
915 trace_dump_arg_begin("surf_tmpl");
916 trace_dump_surface_template(surf_tmpl, resource->target);
917 trace_dump_arg_end();
918
919
920 result = pipe->create_surface(pipe, resource, surf_tmpl);
921
922 trace_dump_ret(ptr, result);
923
924 trace_dump_call_end();
925
926 result = trace_surf_create(tr_res, result);
927
928 return result;
929 }
930
931
932 static void
933 trace_surface_destroy(struct pipe_context *_pipe,
934 struct pipe_surface *_surface)
935 {
936 struct trace_context *tr_ctx = trace_context(_pipe);
937 struct pipe_context *pipe = tr_ctx->pipe;
938 struct trace_surface *tr_surf = trace_surface(_surface);
939 struct pipe_surface *surface = tr_surf->surface;
940
941 trace_dump_call_begin("pipe_context", "surface_destroy");
942
943 trace_dump_arg(ptr, pipe);
944 trace_dump_arg(ptr, surface);
945
946 trace_dump_call_end();
947
948 trace_surf_destroy(tr_surf);
949 }
950
951
952 static INLINE void
953 trace_context_set_fragment_sampler_views(struct pipe_context *_pipe,
954 unsigned num,
955 struct pipe_sampler_view **views)
956 {
957 struct trace_context *tr_ctx = trace_context(_pipe);
958 struct trace_sampler_view *tr_view;
959 struct pipe_context *pipe = tr_ctx->pipe;
960 struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
961 unsigned i;
962
963 for(i = 0; i < num; ++i) {
964 tr_view = trace_sampler_view(views[i]);
965 unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
966 }
967 views = unwrapped_views;
968
969 trace_dump_call_begin("pipe_context", "set_fragment_sampler_views");
970
971 trace_dump_arg(ptr, pipe);
972 trace_dump_arg(uint, num);
973 trace_dump_arg_array(ptr, views, num);
974
975 pipe->set_fragment_sampler_views(pipe, num, views);
976
977 trace_dump_call_end();
978 }
979
980
981 static INLINE void
982 trace_context_set_vertex_sampler_views(struct pipe_context *_pipe,
983 unsigned num,
984 struct pipe_sampler_view **views)
985 {
986 struct trace_context *tr_ctx = trace_context(_pipe);
987 struct trace_sampler_view *tr_view;
988 struct pipe_context *pipe = tr_ctx->pipe;
989 struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
990 unsigned i;
991
992 if (!pipe->set_vertex_sampler_views)
993 return;
994
995 for(i = 0; i < num; ++i) {
996 tr_view = trace_sampler_view(views[i]);
997 unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
998 }
999 views = unwrapped_views;
1000
1001 trace_dump_call_begin("pipe_context", "set_vertex_sampler_views");
1002
1003 trace_dump_arg(ptr, pipe);
1004 trace_dump_arg(uint, num);
1005 trace_dump_arg_array(ptr, views, num);
1006
1007 pipe->set_vertex_sampler_views(pipe, num, views);
1008
1009 trace_dump_call_end();
1010 }
1011
1012
1013 static INLINE void
1014 trace_context_set_vertex_buffers(struct pipe_context *_pipe,
1015 unsigned num_buffers,
1016 const struct pipe_vertex_buffer *buffers)
1017 {
1018 struct trace_context *tr_ctx = trace_context(_pipe);
1019 struct pipe_context *pipe = tr_ctx->pipe;
1020 unsigned i;
1021
1022 trace_dump_call_begin("pipe_context", "set_vertex_buffers");
1023
1024 trace_dump_arg(ptr, pipe);
1025 trace_dump_arg(uint, num_buffers);
1026
1027 trace_dump_arg_begin("buffers");
1028 trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
1029 trace_dump_arg_end();
1030
1031 if (num_buffers) {
1032 struct pipe_vertex_buffer *_buffers = MALLOC(num_buffers * sizeof(*_buffers));
1033 memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers));
1034 for (i = 0; i < num_buffers; i++)
1035 _buffers[i].buffer = trace_resource_unwrap(tr_ctx, buffers[i].buffer);
1036 pipe->set_vertex_buffers(pipe, num_buffers, _buffers);
1037 FREE(_buffers);
1038 } else {
1039 pipe->set_vertex_buffers(pipe, num_buffers, NULL);
1040 }
1041
1042 trace_dump_call_end();
1043 }
1044
1045
1046 static INLINE void
1047 trace_context_set_index_buffer(struct pipe_context *_pipe,
1048 const struct pipe_index_buffer *ib)
1049 {
1050 struct trace_context *tr_ctx = trace_context(_pipe);
1051 struct pipe_context *pipe = tr_ctx->pipe;
1052
1053 trace_dump_call_begin("pipe_context", "set_index_buffer");
1054
1055 trace_dump_arg(ptr, pipe);
1056 trace_dump_arg(index_buffer, ib);
1057
1058 if (ib) {
1059 struct pipe_index_buffer _ib;
1060 _ib = *ib;
1061 _ib.buffer = trace_resource_unwrap(tr_ctx, ib->buffer);
1062 pipe->set_index_buffer(pipe, &_ib);
1063 } else {
1064 pipe->set_index_buffer(pipe, NULL);
1065 }
1066
1067 trace_dump_call_end();
1068 }
1069
1070
1071 static INLINE struct pipe_stream_output_target *
1072 trace_context_create_stream_output_target(struct pipe_context *_pipe,
1073 struct pipe_resource *res,
1074 unsigned buffer_offset,
1075 unsigned buffer_size)
1076 {
1077 struct trace_context *tr_ctx = trace_context(_pipe);
1078 struct pipe_context *pipe = tr_ctx->pipe;
1079 struct pipe_stream_output_target *result;
1080
1081 res = trace_resource_unwrap(tr_ctx, res);
1082
1083 trace_dump_call_begin("pipe_context", "create_stream_output_target");
1084
1085 trace_dump_arg(ptr, pipe);
1086 trace_dump_arg(ptr, res);
1087 trace_dump_arg(uint, buffer_offset);
1088 trace_dump_arg(uint, buffer_size);
1089
1090 result = pipe->create_stream_output_target(pipe,
1091 res, buffer_offset, buffer_size);
1092
1093 trace_dump_call_end();
1094
1095 return result;
1096 }
1097
1098
1099 static INLINE void
1100 trace_context_stream_output_target_destroy(
1101 struct pipe_context *_pipe,
1102 struct pipe_stream_output_target *target)
1103 {
1104 struct trace_context *tr_ctx = trace_context(_pipe);
1105 struct pipe_context *pipe = tr_ctx->pipe;
1106
1107 trace_dump_call_begin("pipe_context", "stream_output_target_destroy");
1108
1109 trace_dump_arg(ptr, pipe);
1110 trace_dump_arg(ptr, target);
1111
1112 pipe->stream_output_target_destroy(pipe, target);
1113
1114 trace_dump_call_end();
1115 }
1116
1117
1118 static INLINE void
1119 trace_context_set_stream_output_targets(struct pipe_context *_pipe,
1120 unsigned num_targets,
1121 struct pipe_stream_output_target **tgs,
1122 unsigned append_bitmask)
1123 {
1124 struct trace_context *tr_ctx = trace_context(_pipe);
1125 struct pipe_context *pipe = tr_ctx->pipe;
1126
1127 trace_dump_call_begin("pipe_context", "set_stream_output_targets");
1128
1129 trace_dump_arg(ptr, pipe);
1130 trace_dump_arg(uint, num_targets);
1131 trace_dump_arg_array(ptr, tgs, num_targets);
1132 trace_dump_arg(uint, append_bitmask);
1133
1134 pipe->set_stream_output_targets(pipe, num_targets, tgs, append_bitmask);
1135
1136 trace_dump_call_end();
1137 }
1138
1139
1140 static INLINE void
1141 trace_context_resource_copy_region(struct pipe_context *_pipe,
1142 struct pipe_resource *dst,
1143 unsigned dst_level,
1144 unsigned dstx, unsigned dsty, unsigned dstz,
1145 struct pipe_resource *src,
1146 unsigned src_level,
1147 const struct pipe_box *src_box)
1148 {
1149 struct trace_context *tr_ctx = trace_context(_pipe);
1150 struct pipe_context *pipe = tr_ctx->pipe;
1151
1152 dst = trace_resource_unwrap(tr_ctx, dst);
1153 src = trace_resource_unwrap(tr_ctx, src);
1154
1155 trace_dump_call_begin("pipe_context", "resource_copy_region");
1156
1157 trace_dump_arg(ptr, pipe);
1158 trace_dump_arg(ptr, dst);
1159 trace_dump_arg(uint, dst_level);
1160 trace_dump_arg(uint, dstx);
1161 trace_dump_arg(uint, dsty);
1162 trace_dump_arg(uint, dstz);
1163 trace_dump_arg(ptr, src);
1164 trace_dump_arg(uint, src_level);
1165 trace_dump_arg(box, src_box);
1166
1167 pipe->resource_copy_region(pipe,
1168 dst, dst_level, dstx, dsty, dstz,
1169 src, src_level, src_box);
1170
1171 trace_dump_call_end();
1172 }
1173
1174
1175 static INLINE void
1176 trace_context_clear(struct pipe_context *_pipe,
1177 unsigned buffers,
1178 const union pipe_color_union *color,
1179 double depth,
1180 unsigned stencil)
1181 {
1182 struct trace_context *tr_ctx = trace_context(_pipe);
1183 struct pipe_context *pipe = tr_ctx->pipe;
1184
1185 trace_dump_call_begin("pipe_context", "clear");
1186
1187 trace_dump_arg(ptr, pipe);
1188 trace_dump_arg(uint, buffers);
1189 if (color)
1190 trace_dump_arg_array(float, color->f, 4);
1191 else
1192 trace_dump_null();
1193 trace_dump_arg(float, depth);
1194 trace_dump_arg(uint, stencil);
1195
1196 pipe->clear(pipe, buffers, color, depth, stencil);
1197
1198 trace_dump_call_end();
1199 }
1200
1201
1202 static INLINE void
1203 trace_context_clear_render_target(struct pipe_context *_pipe,
1204 struct pipe_surface *dst,
1205 const union pipe_color_union *color,
1206 unsigned dstx, unsigned dsty,
1207 unsigned width, unsigned height)
1208 {
1209 struct trace_context *tr_ctx = trace_context(_pipe);
1210 struct pipe_context *pipe = tr_ctx->pipe;
1211
1212 dst = trace_surface_unwrap(tr_ctx, dst);
1213
1214 trace_dump_call_begin("pipe_context", "clear_render_target");
1215
1216 trace_dump_arg(ptr, pipe);
1217 trace_dump_arg(ptr, dst);
1218 trace_dump_arg_array(float, color->f, 4);
1219 trace_dump_arg(uint, dstx);
1220 trace_dump_arg(uint, dsty);
1221 trace_dump_arg(uint, width);
1222 trace_dump_arg(uint, height);
1223
1224 pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height);
1225
1226 trace_dump_call_end();
1227 }
1228
1229 static INLINE void
1230 trace_context_clear_depth_stencil(struct pipe_context *_pipe,
1231 struct pipe_surface *dst,
1232 unsigned clear_flags,
1233 double depth,
1234 unsigned stencil,
1235 unsigned dstx, unsigned dsty,
1236 unsigned width, unsigned height)
1237 {
1238 struct trace_context *tr_ctx = trace_context(_pipe);
1239 struct pipe_context *pipe = tr_ctx->pipe;
1240
1241 dst = trace_surface_unwrap(tr_ctx, dst);
1242
1243 trace_dump_call_begin("pipe_context", "clear_depth_stencil");
1244
1245 trace_dump_arg(ptr, pipe);
1246 trace_dump_arg(ptr, dst);
1247 trace_dump_arg(uint, clear_flags);
1248 trace_dump_arg(float, depth);
1249 trace_dump_arg(uint, stencil);
1250 trace_dump_arg(uint, dstx);
1251 trace_dump_arg(uint, dsty);
1252 trace_dump_arg(uint, width);
1253 trace_dump_arg(uint, height);
1254
1255 pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil,
1256 dstx, dsty, width, height);
1257
1258 trace_dump_call_end();
1259 }
1260
1261 static INLINE void
1262 trace_context_flush(struct pipe_context *_pipe,
1263 struct pipe_fence_handle **fence)
1264 {
1265 struct trace_context *tr_ctx = trace_context(_pipe);
1266 struct pipe_context *pipe = tr_ctx->pipe;
1267
1268 trace_dump_call_begin("pipe_context", "flush");
1269
1270 trace_dump_arg(ptr, pipe);
1271
1272 pipe->flush(pipe, fence);
1273
1274 if(fence)
1275 trace_dump_ret(ptr, *fence);
1276
1277 trace_dump_call_end();
1278 }
1279
1280
1281 static INLINE void
1282 trace_context_destroy(struct pipe_context *_pipe)
1283 {
1284 struct trace_context *tr_ctx = trace_context(_pipe);
1285 struct pipe_context *pipe = tr_ctx->pipe;
1286
1287 trace_dump_call_begin("pipe_context", "destroy");
1288 trace_dump_arg(ptr, pipe);
1289 trace_dump_call_end();
1290
1291 pipe->destroy(pipe);
1292
1293 FREE(tr_ctx);
1294 }
1295
1296
1297 /********************************************************************
1298 * transfer
1299 */
1300
1301
1302 static struct pipe_transfer *
1303 trace_context_get_transfer(struct pipe_context *_context,
1304 struct pipe_resource *_resource,
1305 unsigned level,
1306 unsigned usage,
1307 const struct pipe_box *box)
1308 {
1309 struct trace_context *tr_context = trace_context(_context);
1310 struct trace_resource *tr_res = trace_resource(_resource);
1311 struct pipe_context *context = tr_context->pipe;
1312 struct pipe_resource *texture = tr_res->resource;
1313 struct pipe_transfer *result = NULL;
1314
1315 assert(texture->screen == context->screen);
1316
1317 /*
1318 * Map and transfers can't be serialized so we convert all write transfers
1319 * to transfer_inline_write and ignore read transfers.
1320 */
1321
1322 result = context->get_transfer(context, texture, level, usage, box);
1323
1324 if (result)
1325 result = trace_transfer_create(tr_context, tr_res, result);
1326
1327 return result;
1328 }
1329
1330
1331 static void
1332 trace_context_transfer_destroy(struct pipe_context *_context,
1333 struct pipe_transfer *_transfer)
1334 {
1335 struct trace_context *tr_context = trace_context(_context);
1336 struct trace_transfer *tr_trans = trace_transfer(_transfer);
1337
1338 trace_transfer_destroy(tr_context, tr_trans);
1339 }
1340
1341
1342 static void *
1343 trace_context_transfer_map(struct pipe_context *_context,
1344 struct pipe_transfer *_transfer)
1345 {
1346 struct trace_context *tr_context = trace_context(_context);
1347 struct trace_transfer *tr_trans = trace_transfer(_transfer);
1348 struct pipe_context *context = tr_context->pipe;
1349 struct pipe_transfer *transfer = tr_trans->transfer;
1350 void *map;
1351
1352 map = context->transfer_map(context, transfer);
1353 if(map) {
1354 if(transfer->usage & PIPE_TRANSFER_WRITE) {
1355 assert(!tr_trans->map);
1356 tr_trans->map = map;
1357 }
1358 }
1359
1360 return map;
1361 }
1362
1363
1364 static void
1365 trace_context_transfer_flush_region( struct pipe_context *_context,
1366 struct pipe_transfer *_transfer,
1367 const struct pipe_box *box)
1368 {
1369 struct trace_context *tr_context = trace_context(_context);
1370 struct trace_transfer *tr_transfer = trace_transfer(_transfer);
1371 struct pipe_context *context = tr_context->pipe;
1372 struct pipe_transfer *transfer = tr_transfer->transfer;
1373
1374 context->transfer_flush_region(context,
1375 transfer,
1376 box);
1377 }
1378
1379 static void
1380 trace_context_transfer_unmap(struct pipe_context *_context,
1381 struct pipe_transfer *_transfer)
1382 {
1383 struct trace_context *tr_ctx = trace_context(_context);
1384 struct trace_transfer *tr_trans = trace_transfer(_transfer);
1385 struct pipe_context *context = tr_ctx->pipe;
1386 struct pipe_transfer *transfer = tr_trans->transfer;
1387
1388 if(tr_trans->map) {
1389 /*
1390 * Fake a transfer_inline_write
1391 */
1392
1393 struct pipe_resource *resource = transfer->resource;
1394 unsigned level = transfer->level;
1395 unsigned usage = transfer->usage;
1396 const struct pipe_box *box = &transfer->box;
1397 unsigned stride = transfer->stride;
1398 unsigned layer_stride = transfer->layer_stride;
1399
1400 trace_dump_call_begin("pipe_context", "transfer_inline_write");
1401
1402 trace_dump_arg(ptr, context);
1403 trace_dump_arg(ptr, resource);
1404 trace_dump_arg(uint, level);
1405 trace_dump_arg(uint, usage);
1406 trace_dump_arg(box, box);
1407
1408 trace_dump_arg_begin("data");
1409 trace_dump_box_bytes(tr_trans->map,
1410 resource->format,
1411 box,
1412 stride,
1413 layer_stride);
1414 trace_dump_arg_end();
1415
1416 trace_dump_arg(uint, stride);
1417 trace_dump_arg(uint, layer_stride);
1418
1419 trace_dump_call_end();
1420
1421 tr_trans->map = NULL;
1422 }
1423
1424 context->transfer_unmap(context, transfer);
1425 }
1426
1427
1428 static void
1429 trace_context_transfer_inline_write(struct pipe_context *_context,
1430 struct pipe_resource *_resource,
1431 unsigned level,
1432 unsigned usage,
1433 const struct pipe_box *box,
1434 const void *data,
1435 unsigned stride,
1436 unsigned layer_stride)
1437 {
1438 struct trace_context *tr_context = trace_context(_context);
1439 struct trace_resource *tr_res = trace_resource(_resource);
1440 struct pipe_context *context = tr_context->pipe;
1441 struct pipe_resource *resource = tr_res->resource;
1442
1443 assert(resource->screen == context->screen);
1444
1445 trace_dump_call_begin("pipe_context", "transfer_inline_write");
1446
1447 trace_dump_arg(ptr, context);
1448 trace_dump_arg(ptr, resource);
1449 trace_dump_arg(uint, level);
1450 trace_dump_arg(uint, usage);
1451 trace_dump_arg(box, box);
1452
1453 trace_dump_arg_begin("data");
1454 trace_dump_box_bytes(data,
1455 resource->format,
1456 box,
1457 stride,
1458 layer_stride);
1459 trace_dump_arg_end();
1460
1461 trace_dump_arg(uint, stride);
1462 trace_dump_arg(uint, layer_stride);
1463
1464 trace_dump_call_end();
1465
1466 context->transfer_inline_write(context, resource,
1467 level, usage, box, data, stride, layer_stride);
1468 }
1469
1470
1471 static void trace_redefine_user_buffer(struct pipe_context *_context,
1472 struct pipe_resource *_resource,
1473 unsigned offset, unsigned size)
1474 {
1475 struct trace_context *tr_context = trace_context(_context);
1476 struct trace_resource *tr_res = trace_resource(_resource);
1477 struct pipe_context *context = tr_context->pipe;
1478 struct pipe_resource *resource = tr_res->resource;
1479
1480 assert(resource->screen == context->screen);
1481
1482 trace_dump_call_begin("pipe_context", "redefine_user_buffer");
1483
1484 trace_dump_arg(ptr, context);
1485 trace_dump_arg(ptr, resource);
1486 trace_dump_arg(uint, offset);
1487 trace_dump_arg(uint, size);
1488
1489 trace_dump_call_end();
1490
1491 context->redefine_user_buffer(context, resource, offset, size);
1492 }
1493
1494
1495 static void trace_render_condition(struct pipe_context *_context,
1496 struct pipe_query *query,
1497 uint mode)
1498 {
1499 struct trace_context *tr_context = trace_context(_context);
1500 struct pipe_context *context = tr_context->pipe;
1501
1502 trace_dump_call_begin("pipe_context", "render_condition");
1503
1504 trace_dump_arg(ptr, context);
1505 trace_dump_arg(ptr, query);
1506 trace_dump_arg(uint, mode);
1507
1508 trace_dump_call_end();
1509
1510 context->render_condition(context, query, mode);
1511 }
1512
1513
1514 static void trace_texture_barrier(struct pipe_context *_context)
1515 {
1516 struct trace_context *tr_context = trace_context(_context);
1517 struct pipe_context *context = tr_context->pipe;
1518
1519 trace_dump_call_begin("pipe_context", "texture_barrier");
1520
1521 trace_dump_arg(ptr, context);
1522
1523 trace_dump_call_end();
1524
1525 context->texture_barrier(context);
1526 }
1527
1528
1529 static const struct debug_named_value rbug_blocker_flags[] = {
1530 {"before", 1, NULL},
1531 {"after", 2, NULL},
1532 DEBUG_NAMED_VALUE_END
1533 };
1534
1535 struct pipe_context *
1536 trace_context_create(struct trace_screen *tr_scr,
1537 struct pipe_context *pipe)
1538 {
1539 struct trace_context *tr_ctx;
1540
1541 if(!pipe)
1542 goto error1;
1543
1544 if(!trace_enabled())
1545 goto error1;
1546
1547 tr_ctx = CALLOC_STRUCT(trace_context);
1548 if(!tr_ctx)
1549 goto error1;
1550
1551 tr_ctx->base.winsys = NULL;
1552 tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
1553 tr_ctx->base.screen = &tr_scr->base;
1554
1555 tr_ctx->base.destroy = trace_context_destroy;
1556 tr_ctx->base.draw_vbo = trace_context_draw_vbo;
1557 tr_ctx->base.create_query = trace_context_create_query;
1558 tr_ctx->base.destroy_query = trace_context_destroy_query;
1559 tr_ctx->base.begin_query = trace_context_begin_query;
1560 tr_ctx->base.end_query = trace_context_end_query;
1561 tr_ctx->base.get_query_result = trace_context_get_query_result;
1562 tr_ctx->base.create_blend_state = trace_context_create_blend_state;
1563 tr_ctx->base.bind_blend_state = trace_context_bind_blend_state;
1564 tr_ctx->base.delete_blend_state = trace_context_delete_blend_state;
1565 tr_ctx->base.create_sampler_state = trace_context_create_sampler_state;
1566 tr_ctx->base.bind_fragment_sampler_states = trace_context_bind_fragment_sampler_states;
1567 tr_ctx->base.bind_vertex_sampler_states = trace_context_bind_vertex_sampler_states;
1568 tr_ctx->base.delete_sampler_state = trace_context_delete_sampler_state;
1569 tr_ctx->base.create_rasterizer_state = trace_context_create_rasterizer_state;
1570 tr_ctx->base.bind_rasterizer_state = trace_context_bind_rasterizer_state;
1571 tr_ctx->base.delete_rasterizer_state = trace_context_delete_rasterizer_state;
1572 tr_ctx->base.create_depth_stencil_alpha_state = trace_context_create_depth_stencil_alpha_state;
1573 tr_ctx->base.bind_depth_stencil_alpha_state = trace_context_bind_depth_stencil_alpha_state;
1574 tr_ctx->base.delete_depth_stencil_alpha_state = trace_context_delete_depth_stencil_alpha_state;
1575 tr_ctx->base.create_fs_state = trace_context_create_fs_state;
1576 tr_ctx->base.bind_fs_state = trace_context_bind_fs_state;
1577 tr_ctx->base.delete_fs_state = trace_context_delete_fs_state;
1578 tr_ctx->base.create_vs_state = trace_context_create_vs_state;
1579 tr_ctx->base.bind_vs_state = trace_context_bind_vs_state;
1580 tr_ctx->base.delete_vs_state = trace_context_delete_vs_state;
1581 tr_ctx->base.create_vertex_elements_state = trace_context_create_vertex_elements_state;
1582 tr_ctx->base.bind_vertex_elements_state = trace_context_bind_vertex_elements_state;
1583 tr_ctx->base.delete_vertex_elements_state = trace_context_delete_vertex_elements_state;
1584 tr_ctx->base.set_blend_color = trace_context_set_blend_color;
1585 tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref;
1586 tr_ctx->base.set_clip_state = trace_context_set_clip_state;
1587 tr_ctx->base.set_sample_mask = trace_context_set_sample_mask;
1588 tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer;
1589 tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state;
1590 tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
1591 tr_ctx->base.set_scissor_state = trace_context_set_scissor_state;
1592 tr_ctx->base.set_viewport_state = trace_context_set_viewport_state;
1593 tr_ctx->base.set_fragment_sampler_views = trace_context_set_fragment_sampler_views;
1594 tr_ctx->base.set_vertex_sampler_views = trace_context_set_vertex_sampler_views;
1595 tr_ctx->base.create_sampler_view = trace_create_sampler_view;
1596 tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy;
1597 tr_ctx->base.create_surface = trace_create_surface;
1598 tr_ctx->base.surface_destroy = trace_surface_destroy;
1599 tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
1600 tr_ctx->base.set_index_buffer = trace_context_set_index_buffer;
1601 tr_ctx->base.create_stream_output_target = trace_context_create_stream_output_target;
1602 tr_ctx->base.stream_output_target_destroy = trace_context_stream_output_target_destroy;
1603 tr_ctx->base.set_stream_output_targets = trace_context_set_stream_output_targets;
1604 tr_ctx->base.resource_copy_region = trace_context_resource_copy_region;
1605 tr_ctx->base.clear = trace_context_clear;
1606 tr_ctx->base.clear_render_target = trace_context_clear_render_target;
1607 tr_ctx->base.clear_depth_stencil = trace_context_clear_depth_stencil;
1608 tr_ctx->base.flush = trace_context_flush;
1609 tr_ctx->base.render_condition = pipe->render_condition ? trace_render_condition : NULL;
1610 tr_ctx->base.texture_barrier = pipe->texture_barrier ? trace_texture_barrier : NULL;
1611
1612 tr_ctx->base.get_transfer = trace_context_get_transfer;
1613 tr_ctx->base.transfer_destroy = trace_context_transfer_destroy;
1614 tr_ctx->base.transfer_map = trace_context_transfer_map;
1615 tr_ctx->base.transfer_unmap = trace_context_transfer_unmap;
1616 tr_ctx->base.transfer_flush_region = trace_context_transfer_flush_region;
1617 tr_ctx->base.transfer_inline_write = trace_context_transfer_inline_write;
1618 tr_ctx->base.redefine_user_buffer = trace_redefine_user_buffer;
1619
1620 tr_ctx->pipe = pipe;
1621
1622 return &tr_ctx->base;
1623
1624 error1:
1625 return pipe;
1626 }