1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "util/u_inlines.h"
29 #include "util/u_memory.h"
30 #include "util/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_defines.h"
37 #include "tr_dump_state.h"
38 #include "tr_public.h"
39 #include "tr_screen.h"
40 #include "tr_texture.h"
41 #include "tr_context.h"
42
43
44 struct trace_query
45 {
46 unsigned type;
47
48 struct pipe_query *query;
49 };
50
51
52 static inline struct trace_query *
trace_query(struct pipe_query * query)53 trace_query(struct pipe_query *query)
54 {
55 return (struct trace_query *)query;
56 }
57
58
59 static inline struct pipe_query *
trace_query_unwrap(struct pipe_query * query)60 trace_query_unwrap(struct pipe_query *query)
61 {
62 if (query) {
63 return trace_query(query)->query;
64 } else {
65 return NULL;
66 }
67 }
68
69
70 static inline struct pipe_surface *
trace_surface_unwrap(struct trace_context * tr_ctx,struct pipe_surface * surface)71 trace_surface_unwrap(struct trace_context *tr_ctx,
72 struct pipe_surface *surface)
73 {
74 struct trace_surface *tr_surf;
75
76 if (!surface)
77 return NULL;
78
79 assert(surface->texture);
80 if (!surface->texture)
81 return surface;
82
83 tr_surf = trace_surface(surface);
84
85 assert(tr_surf->surface);
86 return tr_surf->surface;
87 }
88
89
90 static void
trace_context_draw_vbo(struct pipe_context * _pipe,const struct pipe_draw_info * info)91 trace_context_draw_vbo(struct pipe_context *_pipe,
92 const struct pipe_draw_info *info)
93 {
94 struct trace_context *tr_ctx = trace_context(_pipe);
95 struct pipe_context *pipe = tr_ctx->pipe;
96
97 trace_dump_call_begin("pipe_context", "draw_vbo");
98
99 trace_dump_arg(ptr, pipe);
100 trace_dump_arg(draw_info, info);
101
102 trace_dump_trace_flush();
103
104 pipe->draw_vbo(pipe, info);
105
106 trace_dump_call_end();
107 }
108
109
110 static struct pipe_query *
trace_context_create_query(struct pipe_context * _pipe,unsigned query_type,unsigned index)111 trace_context_create_query(struct pipe_context *_pipe,
112 unsigned query_type,
113 unsigned index)
114 {
115 struct trace_context *tr_ctx = trace_context(_pipe);
116 struct pipe_context *pipe = tr_ctx->pipe;
117 struct pipe_query *query;
118
119 trace_dump_call_begin("pipe_context", "create_query");
120
121 trace_dump_arg(ptr, pipe);
122 trace_dump_arg(query_type, query_type);
123 trace_dump_arg(int, index);
124
125 query = pipe->create_query(pipe, query_type, index);
126
127 trace_dump_ret(ptr, query);
128
129 trace_dump_call_end();
130
131 /* Wrap query object. */
132 if (query) {
133 struct trace_query *tr_query = CALLOC_STRUCT(trace_query);
134 if (tr_query) {
135 tr_query->type = query_type;
136 tr_query->query = query;
137 query = (struct pipe_query *)tr_query;
138 } else {
139 pipe->destroy_query(pipe, query);
140 query = NULL;
141 }
142 }
143
144 return query;
145 }
146
147
148 static void
trace_context_destroy_query(struct pipe_context * _pipe,struct pipe_query * _query)149 trace_context_destroy_query(struct pipe_context *_pipe,
150 struct pipe_query *_query)
151 {
152 struct trace_context *tr_ctx = trace_context(_pipe);
153 struct pipe_context *pipe = tr_ctx->pipe;
154 struct trace_query *tr_query = trace_query(_query);
155 struct pipe_query *query = tr_query->query;
156
157 FREE(tr_query);
158
159 trace_dump_call_begin("pipe_context", "destroy_query");
160
161 trace_dump_arg(ptr, pipe);
162 trace_dump_arg(ptr, query);
163
164 pipe->destroy_query(pipe, query);
165
166 trace_dump_call_end();
167 }
168
169
170 static bool
trace_context_begin_query(struct pipe_context * _pipe,struct pipe_query * query)171 trace_context_begin_query(struct pipe_context *_pipe,
172 struct pipe_query *query)
173 {
174 struct trace_context *tr_ctx = trace_context(_pipe);
175 struct pipe_context *pipe = tr_ctx->pipe;
176 bool ret;
177
178 query = trace_query_unwrap(query);
179
180 trace_dump_call_begin("pipe_context", "begin_query");
181
182 trace_dump_arg(ptr, pipe);
183 trace_dump_arg(ptr, query);
184
185 ret = pipe->begin_query(pipe, query);
186
187 trace_dump_call_end();
188 return ret;
189 }
190
191
192 static bool
trace_context_end_query(struct pipe_context * _pipe,struct pipe_query * query)193 trace_context_end_query(struct pipe_context *_pipe,
194 struct pipe_query *query)
195 {
196 struct trace_context *tr_ctx = trace_context(_pipe);
197 struct pipe_context *pipe = tr_ctx->pipe;
198 bool ret;
199
200 query = trace_query_unwrap(query);
201
202 trace_dump_call_begin("pipe_context", "end_query");
203
204 trace_dump_arg(ptr, pipe);
205 trace_dump_arg(ptr, query);
206
207 ret = pipe->end_query(pipe, query);
208
209 trace_dump_call_end();
210 return ret;
211 }
212
213
214 static bool
trace_context_get_query_result(struct pipe_context * _pipe,struct pipe_query * _query,bool wait,union pipe_query_result * result)215 trace_context_get_query_result(struct pipe_context *_pipe,
216 struct pipe_query *_query,
217 bool wait,
218 union pipe_query_result *result)
219 {
220 struct trace_context *tr_ctx = trace_context(_pipe);
221 struct pipe_context *pipe = tr_ctx->pipe;
222 struct trace_query *tr_query = trace_query(_query);
223 struct pipe_query *query = tr_query->query;
224 bool ret;
225
226 trace_dump_call_begin("pipe_context", "get_query_result");
227
228 trace_dump_arg(ptr, pipe);
229 trace_dump_arg(ptr, query);
230
231 ret = pipe->get_query_result(pipe, query, wait, result);
232
233 trace_dump_arg_begin("result");
234 if (ret) {
235 trace_dump_query_result(tr_query->type, result);
236 } else {
237 trace_dump_null();
238 }
239 trace_dump_arg_end();
240
241 trace_dump_ret(bool, ret);
242
243 trace_dump_call_end();
244
245 return ret;
246 }
247
248
249 static void
trace_context_set_active_query_state(struct pipe_context * _pipe,bool enable)250 trace_context_set_active_query_state(struct pipe_context *_pipe,
251 bool enable)
252 {
253 struct trace_context *tr_ctx = trace_context(_pipe);
254 struct pipe_context *pipe = tr_ctx->pipe;
255
256 trace_dump_call_begin("pipe_context", "set_active_query_state");
257
258 trace_dump_arg(ptr, pipe);
259 trace_dump_arg(bool, enable);
260
261 pipe->set_active_query_state(pipe, enable);
262
263 trace_dump_call_end();
264 }
265
266
267 static void *
trace_context_create_blend_state(struct pipe_context * _pipe,const struct pipe_blend_state * state)268 trace_context_create_blend_state(struct pipe_context *_pipe,
269 const struct pipe_blend_state *state)
270 {
271 struct trace_context *tr_ctx = trace_context(_pipe);
272 struct pipe_context *pipe = tr_ctx->pipe;
273 void * result;
274
275 trace_dump_call_begin("pipe_context", "create_blend_state");
276
277 trace_dump_arg(ptr, pipe);
278 trace_dump_arg(blend_state, state);
279
280 result = pipe->create_blend_state(pipe, state);
281
282 trace_dump_ret(ptr, result);
283
284 trace_dump_call_end();
285
286 return result;
287 }
288
289
290 static void
trace_context_bind_blend_state(struct pipe_context * _pipe,void * state)291 trace_context_bind_blend_state(struct pipe_context *_pipe,
292 void *state)
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_blend_state");
298
299 trace_dump_arg(ptr, pipe);
300 trace_dump_arg(ptr, state);
301
302 pipe->bind_blend_state(pipe, state);
303
304 trace_dump_call_end();
305 }
306
307
308 static void
trace_context_delete_blend_state(struct pipe_context * _pipe,void * state)309 trace_context_delete_blend_state(struct pipe_context *_pipe,
310 void *state)
311 {
312 struct trace_context *tr_ctx = trace_context(_pipe);
313 struct pipe_context *pipe = tr_ctx->pipe;
314
315 trace_dump_call_begin("pipe_context", "delete_blend_state");
316
317 trace_dump_arg(ptr, pipe);
318 trace_dump_arg(ptr, state);
319
320 pipe->delete_blend_state(pipe, state);
321
322 trace_dump_call_end();
323 }
324
325
326 static void *
trace_context_create_sampler_state(struct pipe_context * _pipe,const struct pipe_sampler_state * state)327 trace_context_create_sampler_state(struct pipe_context *_pipe,
328 const struct pipe_sampler_state *state)
329 {
330 struct trace_context *tr_ctx = trace_context(_pipe);
331 struct pipe_context *pipe = tr_ctx->pipe;
332 void * result;
333
334 trace_dump_call_begin("pipe_context", "create_sampler_state");
335
336 trace_dump_arg(ptr, pipe);
337 trace_dump_arg(sampler_state, state);
338
339 result = pipe->create_sampler_state(pipe, state);
340
341 trace_dump_ret(ptr, result);
342
343 trace_dump_call_end();
344
345 return result;
346 }
347
348
349 static void
trace_context_bind_sampler_states(struct pipe_context * _pipe,enum pipe_shader_type shader,unsigned start,unsigned num_states,void ** states)350 trace_context_bind_sampler_states(struct pipe_context *_pipe,
351 enum pipe_shader_type shader,
352 unsigned start,
353 unsigned num_states,
354 void **states)
355 {
356 struct trace_context *tr_ctx = trace_context(_pipe);
357 struct pipe_context *pipe = tr_ctx->pipe;
358
359 /* remove this when we have pipe->bind_sampler_states(..., start, ...) */
360 assert(start == 0);
361
362 trace_dump_call_begin("pipe_context", "bind_sampler_states");
363
364 trace_dump_arg(ptr, pipe);
365 trace_dump_arg(uint, shader);
366 trace_dump_arg(uint, start);
367 trace_dump_arg(uint, num_states);
368 trace_dump_arg_array(ptr, states, num_states);
369
370 pipe->bind_sampler_states(pipe, shader, start, num_states, states);
371
372 trace_dump_call_end();
373 }
374
375
376 static void
trace_context_delete_sampler_state(struct pipe_context * _pipe,void * state)377 trace_context_delete_sampler_state(struct pipe_context *_pipe,
378 void *state)
379 {
380 struct trace_context *tr_ctx = trace_context(_pipe);
381 struct pipe_context *pipe = tr_ctx->pipe;
382
383 trace_dump_call_begin("pipe_context", "delete_sampler_state");
384
385 trace_dump_arg(ptr, pipe);
386 trace_dump_arg(ptr, state);
387
388 pipe->delete_sampler_state(pipe, state);
389
390 trace_dump_call_end();
391 }
392
393
394 static void *
trace_context_create_rasterizer_state(struct pipe_context * _pipe,const struct pipe_rasterizer_state * state)395 trace_context_create_rasterizer_state(struct pipe_context *_pipe,
396 const struct pipe_rasterizer_state *state)
397 {
398 struct trace_context *tr_ctx = trace_context(_pipe);
399 struct pipe_context *pipe = tr_ctx->pipe;
400 void * result;
401
402 trace_dump_call_begin("pipe_context", "create_rasterizer_state");
403
404 trace_dump_arg(ptr, pipe);
405 trace_dump_arg(rasterizer_state, state);
406
407 result = pipe->create_rasterizer_state(pipe, state);
408
409 trace_dump_ret(ptr, result);
410
411 trace_dump_call_end();
412
413 return result;
414 }
415
416
417 static void
trace_context_bind_rasterizer_state(struct pipe_context * _pipe,void * state)418 trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
419 void *state)
420 {
421 struct trace_context *tr_ctx = trace_context(_pipe);
422 struct pipe_context *pipe = tr_ctx->pipe;
423
424 trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
425
426 trace_dump_arg(ptr, pipe);
427 trace_dump_arg(ptr, state);
428
429 pipe->bind_rasterizer_state(pipe, state);
430
431 trace_dump_call_end();
432 }
433
434
435 static void
trace_context_delete_rasterizer_state(struct pipe_context * _pipe,void * state)436 trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
437 void *state)
438 {
439 struct trace_context *tr_ctx = trace_context(_pipe);
440 struct pipe_context *pipe = tr_ctx->pipe;
441
442 trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
443
444 trace_dump_arg(ptr, pipe);
445 trace_dump_arg(ptr, state);
446
447 pipe->delete_rasterizer_state(pipe, state);
448
449 trace_dump_call_end();
450 }
451
452
453 static void *
trace_context_create_depth_stencil_alpha_state(struct pipe_context * _pipe,const struct pipe_depth_stencil_alpha_state * state)454 trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
455 const struct pipe_depth_stencil_alpha_state *state)
456 {
457 struct trace_context *tr_ctx = trace_context(_pipe);
458 struct pipe_context *pipe = tr_ctx->pipe;
459 void * result;
460
461 trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
462
463 result = pipe->create_depth_stencil_alpha_state(pipe, state);
464
465 trace_dump_arg(ptr, pipe);
466 trace_dump_arg(depth_stencil_alpha_state, state);
467
468 trace_dump_ret(ptr, result);
469
470 trace_dump_call_end();
471
472 return result;
473 }
474
475
476 static void
trace_context_bind_depth_stencil_alpha_state(struct pipe_context * _pipe,void * state)477 trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
478 void *state)
479 {
480 struct trace_context *tr_ctx = trace_context(_pipe);
481 struct pipe_context *pipe = tr_ctx->pipe;
482
483 trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
484
485 trace_dump_arg(ptr, pipe);
486 trace_dump_arg(ptr, state);
487
488 pipe->bind_depth_stencil_alpha_state(pipe, state);
489
490 trace_dump_call_end();
491 }
492
493
494 static void
trace_context_delete_depth_stencil_alpha_state(struct pipe_context * _pipe,void * state)495 trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
496 void *state)
497 {
498 struct trace_context *tr_ctx = trace_context(_pipe);
499 struct pipe_context *pipe = tr_ctx->pipe;
500
501 trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
502
503 trace_dump_arg(ptr, pipe);
504 trace_dump_arg(ptr, state);
505
506 pipe->delete_depth_stencil_alpha_state(pipe, state);
507
508 trace_dump_call_end();
509 }
510
511
512 #define TRACE_SHADER_STATE(shader_type) \
513 static void * \
514 trace_context_create_##shader_type##_state(struct pipe_context *_pipe, \
515 const struct pipe_shader_state *state) \
516 { \
517 struct trace_context *tr_ctx = trace_context(_pipe); \
518 struct pipe_context *pipe = tr_ctx->pipe; \
519 void * result; \
520 trace_dump_call_begin("pipe_context", "create_" #shader_type "_state"); \
521 trace_dump_arg(ptr, pipe); \
522 trace_dump_arg(shader_state, state); \
523 result = pipe->create_##shader_type##_state(pipe, state); \
524 trace_dump_ret(ptr, result); \
525 trace_dump_call_end(); \
526 return result; \
527 } \
528 \
529 static void \
530 trace_context_bind_##shader_type##_state(struct pipe_context *_pipe, \
531 void *state) \
532 { \
533 struct trace_context *tr_ctx = trace_context(_pipe); \
534 struct pipe_context *pipe = tr_ctx->pipe; \
535 trace_dump_call_begin("pipe_context", "bind_" #shader_type "_state"); \
536 trace_dump_arg(ptr, pipe); \
537 trace_dump_arg(ptr, state); \
538 pipe->bind_##shader_type##_state(pipe, state); \
539 trace_dump_call_end(); \
540 } \
541 \
542 static void \
543 trace_context_delete_##shader_type##_state(struct pipe_context *_pipe, \
544 void *state) \
545 { \
546 struct trace_context *tr_ctx = trace_context(_pipe); \
547 struct pipe_context *pipe = tr_ctx->pipe; \
548 trace_dump_call_begin("pipe_context", "delete_" #shader_type "_state"); \
549 trace_dump_arg(ptr, pipe); \
550 trace_dump_arg(ptr, state); \
551 pipe->delete_##shader_type##_state(pipe, state); \
552 trace_dump_call_end(); \
553 }
554
555 TRACE_SHADER_STATE(fs)
TRACE_SHADER_STATE(vs)556 TRACE_SHADER_STATE(vs)
557 TRACE_SHADER_STATE(gs)
558 TRACE_SHADER_STATE(tcs)
559 TRACE_SHADER_STATE(tes)
560
561 #undef TRACE_SHADER_STATE
562
563
564 static inline void *
565 trace_context_create_compute_state(struct pipe_context *_pipe,
566 const struct pipe_compute_state *state)
567 {
568 struct trace_context *tr_ctx = trace_context(_pipe);
569 struct pipe_context *pipe = tr_ctx->pipe;
570 void * result;
571
572 trace_dump_call_begin("pipe_context", "create_compute_state");
573 trace_dump_arg(ptr, pipe);
574 trace_dump_arg(compute_state, state);
575 result = pipe->create_compute_state(pipe, state);
576 trace_dump_ret(ptr, result);
577 trace_dump_call_end();
578 return result;
579 }
580
581 static inline void
trace_context_bind_compute_state(struct pipe_context * _pipe,void * state)582 trace_context_bind_compute_state(struct pipe_context *_pipe,
583 void *state)
584 {
585 struct trace_context *tr_ctx = trace_context(_pipe);
586 struct pipe_context *pipe = tr_ctx->pipe;
587
588 trace_dump_call_begin("pipe_context", "bind_compute_state");
589 trace_dump_arg(ptr, pipe);
590 trace_dump_arg(ptr, state);
591 pipe->bind_compute_state(pipe, state);
592 trace_dump_call_end();
593 }
594
595 static inline void
trace_context_delete_compute_state(struct pipe_context * _pipe,void * state)596 trace_context_delete_compute_state(struct pipe_context *_pipe,
597 void *state)
598 {
599 struct trace_context *tr_ctx = trace_context(_pipe);
600 struct pipe_context *pipe = tr_ctx->pipe;
601
602 trace_dump_call_begin("pipe_context", "delete_compute_state");
603 trace_dump_arg(ptr, pipe);
604 trace_dump_arg(ptr, state);
605 pipe->delete_compute_state(pipe, state);
606 trace_dump_call_end();
607 }
608
609 static void *
trace_context_create_vertex_elements_state(struct pipe_context * _pipe,unsigned num_elements,const struct pipe_vertex_element * elements)610 trace_context_create_vertex_elements_state(struct pipe_context *_pipe,
611 unsigned num_elements,
612 const struct pipe_vertex_element *elements)
613 {
614 struct trace_context *tr_ctx = trace_context(_pipe);
615 struct pipe_context *pipe = tr_ctx->pipe;
616 void * result;
617
618 trace_dump_call_begin("pipe_context", "create_vertex_elements_state");
619
620 trace_dump_arg(ptr, pipe);
621 trace_dump_arg(uint, num_elements);
622
623 trace_dump_arg_begin("elements");
624 trace_dump_struct_array(vertex_element, elements, num_elements);
625 trace_dump_arg_end();
626
627 result = pipe->create_vertex_elements_state(pipe, num_elements, elements);
628
629 trace_dump_ret(ptr, result);
630
631 trace_dump_call_end();
632
633 return result;
634 }
635
636
637 static void
trace_context_bind_vertex_elements_state(struct pipe_context * _pipe,void * state)638 trace_context_bind_vertex_elements_state(struct pipe_context *_pipe,
639 void *state)
640 {
641 struct trace_context *tr_ctx = trace_context(_pipe);
642 struct pipe_context *pipe = tr_ctx->pipe;
643
644 trace_dump_call_begin("pipe_context", "bind_vertex_elements_state");
645
646 trace_dump_arg(ptr, pipe);
647 trace_dump_arg(ptr, state);
648
649 pipe->bind_vertex_elements_state(pipe, state);
650
651 trace_dump_call_end();
652 }
653
654
655 static void
trace_context_delete_vertex_elements_state(struct pipe_context * _pipe,void * state)656 trace_context_delete_vertex_elements_state(struct pipe_context *_pipe,
657 void *state)
658 {
659 struct trace_context *tr_ctx = trace_context(_pipe);
660 struct pipe_context *pipe = tr_ctx->pipe;
661
662 trace_dump_call_begin("pipe_context", "delete_vertex_elements_state");
663
664 trace_dump_arg(ptr, pipe);
665 trace_dump_arg(ptr, state);
666
667 pipe->delete_vertex_elements_state(pipe, state);
668
669 trace_dump_call_end();
670 }
671
672
673 static void
trace_context_set_blend_color(struct pipe_context * _pipe,const struct pipe_blend_color * state)674 trace_context_set_blend_color(struct pipe_context *_pipe,
675 const struct pipe_blend_color *state)
676 {
677 struct trace_context *tr_ctx = trace_context(_pipe);
678 struct pipe_context *pipe = tr_ctx->pipe;
679
680 trace_dump_call_begin("pipe_context", "set_blend_color");
681
682 trace_dump_arg(ptr, pipe);
683 trace_dump_arg(blend_color, state);
684
685 pipe->set_blend_color(pipe, state);
686
687 trace_dump_call_end();
688 }
689
690
691 static void
trace_context_set_stencil_ref(struct pipe_context * _pipe,const struct pipe_stencil_ref * state)692 trace_context_set_stencil_ref(struct pipe_context *_pipe,
693 const struct pipe_stencil_ref *state)
694 {
695 struct trace_context *tr_ctx = trace_context(_pipe);
696 struct pipe_context *pipe = tr_ctx->pipe;
697
698 trace_dump_call_begin("pipe_context", "set_stencil_ref");
699
700 trace_dump_arg(ptr, pipe);
701 trace_dump_arg(stencil_ref, state);
702
703 pipe->set_stencil_ref(pipe, state);
704
705 trace_dump_call_end();
706 }
707
708
709 static void
trace_context_set_clip_state(struct pipe_context * _pipe,const struct pipe_clip_state * state)710 trace_context_set_clip_state(struct pipe_context *_pipe,
711 const struct pipe_clip_state *state)
712 {
713 struct trace_context *tr_ctx = trace_context(_pipe);
714 struct pipe_context *pipe = tr_ctx->pipe;
715
716 trace_dump_call_begin("pipe_context", "set_clip_state");
717
718 trace_dump_arg(ptr, pipe);
719 trace_dump_arg(clip_state, state);
720
721 pipe->set_clip_state(pipe, state);
722
723 trace_dump_call_end();
724 }
725
726 static void
trace_context_set_sample_mask(struct pipe_context * _pipe,unsigned sample_mask)727 trace_context_set_sample_mask(struct pipe_context *_pipe,
728 unsigned sample_mask)
729 {
730 struct trace_context *tr_ctx = trace_context(_pipe);
731 struct pipe_context *pipe = tr_ctx->pipe;
732
733 trace_dump_call_begin("pipe_context", "set_sample_mask");
734
735 trace_dump_arg(ptr, pipe);
736 trace_dump_arg(uint, sample_mask);
737
738 pipe->set_sample_mask(pipe, sample_mask);
739
740 trace_dump_call_end();
741 }
742
743 static void
trace_context_set_constant_buffer(struct pipe_context * _pipe,enum pipe_shader_type shader,uint index,const struct pipe_constant_buffer * constant_buffer)744 trace_context_set_constant_buffer(struct pipe_context *_pipe,
745 enum pipe_shader_type shader, uint index,
746 const struct pipe_constant_buffer *constant_buffer)
747 {
748 struct trace_context *tr_ctx = trace_context(_pipe);
749 struct pipe_context *pipe = tr_ctx->pipe;
750
751 trace_dump_call_begin("pipe_context", "set_constant_buffer");
752
753 trace_dump_arg(ptr, pipe);
754 trace_dump_arg(uint, shader);
755 trace_dump_arg(uint, index);
756 trace_dump_arg(constant_buffer, constant_buffer);
757
758 pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
759
760 trace_dump_call_end();
761 }
762
763
764 static void
trace_context_set_framebuffer_state(struct pipe_context * _pipe,const struct pipe_framebuffer_state * state)765 trace_context_set_framebuffer_state(struct pipe_context *_pipe,
766 const struct pipe_framebuffer_state *state)
767 {
768 struct trace_context *tr_ctx = trace_context(_pipe);
769 struct pipe_context *pipe = tr_ctx->pipe;
770 struct pipe_framebuffer_state unwrapped_state;
771 unsigned i;
772
773
774 /* Unwrap the input state */
775 memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
776 for (i = 0; i < state->nr_cbufs; ++i)
777 unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
778 for (i = state->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
779 unwrapped_state.cbufs[i] = NULL;
780 unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
781 state = &unwrapped_state;
782
783 trace_dump_call_begin("pipe_context", "set_framebuffer_state");
784
785 trace_dump_arg(ptr, pipe);
786 trace_dump_arg(framebuffer_state, state);
787
788 pipe->set_framebuffer_state(pipe, state);
789
790 trace_dump_call_end();
791 }
792
793
794 static void
trace_context_set_polygon_stipple(struct pipe_context * _pipe,const struct pipe_poly_stipple * state)795 trace_context_set_polygon_stipple(struct pipe_context *_pipe,
796 const struct pipe_poly_stipple *state)
797 {
798 struct trace_context *tr_ctx = trace_context(_pipe);
799 struct pipe_context *pipe = tr_ctx->pipe;
800
801 trace_dump_call_begin("pipe_context", "set_polygon_stipple");
802
803 trace_dump_arg(ptr, pipe);
804 trace_dump_arg(poly_stipple, state);
805
806 pipe->set_polygon_stipple(pipe, state);
807
808 trace_dump_call_end();
809 }
810
811
812 static void
trace_context_set_scissor_states(struct pipe_context * _pipe,unsigned start_slot,unsigned num_scissors,const struct pipe_scissor_state * states)813 trace_context_set_scissor_states(struct pipe_context *_pipe,
814 unsigned start_slot,
815 unsigned num_scissors,
816 const struct pipe_scissor_state *states)
817 {
818 struct trace_context *tr_ctx = trace_context(_pipe);
819 struct pipe_context *pipe = tr_ctx->pipe;
820
821 trace_dump_call_begin("pipe_context", "set_scissor_states");
822
823 trace_dump_arg(ptr, pipe);
824 trace_dump_arg(uint, start_slot);
825 trace_dump_arg(uint, num_scissors);
826 trace_dump_arg(scissor_state, states);
827
828 pipe->set_scissor_states(pipe, start_slot, num_scissors, states);
829
830 trace_dump_call_end();
831 }
832
833
834 static void
trace_context_set_viewport_states(struct pipe_context * _pipe,unsigned start_slot,unsigned num_viewports,const struct pipe_viewport_state * states)835 trace_context_set_viewport_states(struct pipe_context *_pipe,
836 unsigned start_slot,
837 unsigned num_viewports,
838 const struct pipe_viewport_state *states)
839 {
840 struct trace_context *tr_ctx = trace_context(_pipe);
841 struct pipe_context *pipe = tr_ctx->pipe;
842
843 trace_dump_call_begin("pipe_context", "set_viewport_states");
844
845 trace_dump_arg(ptr, pipe);
846 trace_dump_arg(uint, start_slot);
847 trace_dump_arg(uint, num_viewports);
848 trace_dump_arg(viewport_state, states);
849
850 pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
851
852 trace_dump_call_end();
853 }
854
855
856 static struct pipe_sampler_view *
trace_context_create_sampler_view(struct pipe_context * _pipe,struct pipe_resource * resource,const struct pipe_sampler_view * templ)857 trace_context_create_sampler_view(struct pipe_context *_pipe,
858 struct pipe_resource *resource,
859 const struct pipe_sampler_view *templ)
860 {
861 struct trace_context *tr_ctx = trace_context(_pipe);
862 struct pipe_context *pipe = tr_ctx->pipe;
863 struct pipe_sampler_view *result;
864 struct trace_sampler_view *tr_view;
865
866 trace_dump_call_begin("pipe_context", "create_sampler_view");
867
868 trace_dump_arg(ptr, pipe);
869 trace_dump_arg(ptr, resource);
870
871 trace_dump_arg_begin("templ");
872 trace_dump_sampler_view_template(templ, resource->target);
873 trace_dump_arg_end();
874
875 result = pipe->create_sampler_view(pipe, resource, templ);
876
877 trace_dump_ret(ptr, result);
878
879 trace_dump_call_end();
880
881 /*
882 * Wrap pipe_sampler_view
883 */
884 tr_view = CALLOC_STRUCT(trace_sampler_view);
885 tr_view->base = *templ;
886 tr_view->base.reference.count = 1;
887 tr_view->base.texture = NULL;
888 pipe_resource_reference(&tr_view->base.texture, resource);
889 tr_view->base.context = _pipe;
890 tr_view->sampler_view = result;
891 result = &tr_view->base;
892
893 return result;
894 }
895
896
897 static void
trace_context_sampler_view_destroy(struct pipe_context * _pipe,struct pipe_sampler_view * _view)898 trace_context_sampler_view_destroy(struct pipe_context *_pipe,
899 struct pipe_sampler_view *_view)
900 {
901 struct trace_context *tr_ctx = trace_context(_pipe);
902 struct trace_sampler_view *tr_view = trace_sampler_view(_view);
903 struct pipe_context *pipe = tr_ctx->pipe;
904 struct pipe_sampler_view *view = tr_view->sampler_view;
905
906 assert(_view->context == _pipe);
907
908 trace_dump_call_begin("pipe_context", "sampler_view_destroy");
909
910 trace_dump_arg(ptr, pipe);
911 trace_dump_arg(ptr, view);
912
913 pipe_sampler_view_reference(&tr_view->sampler_view, NULL);
914
915 trace_dump_call_end();
916
917 pipe_resource_reference(&_view->texture, NULL);
918 FREE(_view);
919 }
920
921 /********************************************************************
922 * surface
923 */
924
925
926 static struct pipe_surface *
trace_context_create_surface(struct pipe_context * _pipe,struct pipe_resource * resource,const struct pipe_surface * surf_tmpl)927 trace_context_create_surface(struct pipe_context *_pipe,
928 struct pipe_resource *resource,
929 const struct pipe_surface *surf_tmpl)
930 {
931 struct trace_context *tr_ctx = trace_context(_pipe);
932 struct pipe_context *pipe = tr_ctx->pipe;
933 struct pipe_surface *result = NULL;
934
935 trace_dump_call_begin("pipe_context", "create_surface");
936
937 trace_dump_arg(ptr, pipe);
938 trace_dump_arg(ptr, resource);
939
940 trace_dump_arg_begin("surf_tmpl");
941 trace_dump_surface_template(surf_tmpl, resource->target);
942 trace_dump_arg_end();
943
944
945 result = pipe->create_surface(pipe, resource, surf_tmpl);
946
947 trace_dump_ret(ptr, result);
948
949 trace_dump_call_end();
950
951 result = trace_surf_create(tr_ctx, resource, result);
952
953 return result;
954 }
955
956
957 static void
trace_context_surface_destroy(struct pipe_context * _pipe,struct pipe_surface * _surface)958 trace_context_surface_destroy(struct pipe_context *_pipe,
959 struct pipe_surface *_surface)
960 {
961 struct trace_context *tr_ctx = trace_context(_pipe);
962 struct pipe_context *pipe = tr_ctx->pipe;
963 struct trace_surface *tr_surf = trace_surface(_surface);
964 struct pipe_surface *surface = tr_surf->surface;
965
966 trace_dump_call_begin("pipe_context", "surface_destroy");
967
968 trace_dump_arg(ptr, pipe);
969 trace_dump_arg(ptr, surface);
970
971 trace_dump_call_end();
972
973 trace_surf_destroy(tr_surf);
974 }
975
976
977 static void
trace_context_set_sampler_views(struct pipe_context * _pipe,enum pipe_shader_type shader,unsigned start,unsigned num,struct pipe_sampler_view ** views)978 trace_context_set_sampler_views(struct pipe_context *_pipe,
979 enum pipe_shader_type shader,
980 unsigned start,
981 unsigned num,
982 struct pipe_sampler_view **views)
983 {
984 struct trace_context *tr_ctx = trace_context(_pipe);
985 struct trace_sampler_view *tr_view;
986 struct pipe_context *pipe = tr_ctx->pipe;
987 struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
988 unsigned i;
989
990 /* remove this when we have pipe->set_sampler_views(..., start, ...) */
991 assert(start == 0);
992
993 for (i = 0; i < num; ++i) {
994 tr_view = trace_sampler_view(views[i]);
995 unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
996 }
997 views = unwrapped_views;
998
999 trace_dump_call_begin("pipe_context", "set_sampler_views");
1000
1001 trace_dump_arg(ptr, pipe);
1002 trace_dump_arg(uint, shader);
1003 trace_dump_arg(uint, start);
1004 trace_dump_arg(uint, num);
1005 trace_dump_arg_array(ptr, views, num);
1006
1007 pipe->set_sampler_views(pipe, shader, start, num, views);
1008
1009 trace_dump_call_end();
1010 }
1011
1012
1013 static void
trace_context_set_vertex_buffers(struct pipe_context * _pipe,unsigned start_slot,unsigned num_buffers,const struct pipe_vertex_buffer * buffers)1014 trace_context_set_vertex_buffers(struct pipe_context *_pipe,
1015 unsigned start_slot, 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
1021 trace_dump_call_begin("pipe_context", "set_vertex_buffers");
1022
1023 trace_dump_arg(ptr, pipe);
1024 trace_dump_arg(uint, start_slot);
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 pipe->set_vertex_buffers(pipe, start_slot, num_buffers, buffers);
1032
1033 trace_dump_call_end();
1034 }
1035
1036
1037 static struct pipe_stream_output_target *
trace_context_create_stream_output_target(struct pipe_context * _pipe,struct pipe_resource * res,unsigned buffer_offset,unsigned buffer_size)1038 trace_context_create_stream_output_target(struct pipe_context *_pipe,
1039 struct pipe_resource *res,
1040 unsigned buffer_offset,
1041 unsigned buffer_size)
1042 {
1043 struct trace_context *tr_ctx = trace_context(_pipe);
1044 struct pipe_context *pipe = tr_ctx->pipe;
1045 struct pipe_stream_output_target *result;
1046
1047 trace_dump_call_begin("pipe_context", "create_stream_output_target");
1048
1049 trace_dump_arg(ptr, pipe);
1050 trace_dump_arg(ptr, res);
1051 trace_dump_arg(uint, buffer_offset);
1052 trace_dump_arg(uint, buffer_size);
1053
1054 result = pipe->create_stream_output_target(pipe,
1055 res, buffer_offset, buffer_size);
1056
1057 trace_dump_ret(ptr, result);
1058
1059 trace_dump_call_end();
1060
1061 return result;
1062 }
1063
1064
1065 static void
trace_context_stream_output_target_destroy(struct pipe_context * _pipe,struct pipe_stream_output_target * target)1066 trace_context_stream_output_target_destroy(
1067 struct pipe_context *_pipe,
1068 struct pipe_stream_output_target *target)
1069 {
1070 struct trace_context *tr_ctx = trace_context(_pipe);
1071 struct pipe_context *pipe = tr_ctx->pipe;
1072
1073 trace_dump_call_begin("pipe_context", "stream_output_target_destroy");
1074
1075 trace_dump_arg(ptr, pipe);
1076 trace_dump_arg(ptr, target);
1077
1078 pipe->stream_output_target_destroy(pipe, target);
1079
1080 trace_dump_call_end();
1081 }
1082
1083
1084 static void
trace_context_set_stream_output_targets(struct pipe_context * _pipe,unsigned num_targets,struct pipe_stream_output_target ** tgs,const unsigned * offsets)1085 trace_context_set_stream_output_targets(struct pipe_context *_pipe,
1086 unsigned num_targets,
1087 struct pipe_stream_output_target **tgs,
1088 const unsigned *offsets)
1089 {
1090 struct trace_context *tr_ctx = trace_context(_pipe);
1091 struct pipe_context *pipe = tr_ctx->pipe;
1092
1093 trace_dump_call_begin("pipe_context", "set_stream_output_targets");
1094
1095 trace_dump_arg(ptr, pipe);
1096 trace_dump_arg(uint, num_targets);
1097 trace_dump_arg_array(ptr, tgs, num_targets);
1098 trace_dump_arg_array(uint, offsets, num_targets);
1099
1100 pipe->set_stream_output_targets(pipe, num_targets, tgs, offsets);
1101
1102 trace_dump_call_end();
1103 }
1104
1105
1106 static void
trace_context_resource_copy_region(struct pipe_context * _pipe,struct pipe_resource * dst,unsigned dst_level,unsigned dstx,unsigned dsty,unsigned dstz,struct pipe_resource * src,unsigned src_level,const struct pipe_box * src_box)1107 trace_context_resource_copy_region(struct pipe_context *_pipe,
1108 struct pipe_resource *dst,
1109 unsigned dst_level,
1110 unsigned dstx, unsigned dsty, unsigned dstz,
1111 struct pipe_resource *src,
1112 unsigned src_level,
1113 const struct pipe_box *src_box)
1114 {
1115 struct trace_context *tr_ctx = trace_context(_pipe);
1116 struct pipe_context *pipe = tr_ctx->pipe;
1117
1118 trace_dump_call_begin("pipe_context", "resource_copy_region");
1119
1120 trace_dump_arg(ptr, pipe);
1121 trace_dump_arg(ptr, dst);
1122 trace_dump_arg(uint, dst_level);
1123 trace_dump_arg(uint, dstx);
1124 trace_dump_arg(uint, dsty);
1125 trace_dump_arg(uint, dstz);
1126 trace_dump_arg(ptr, src);
1127 trace_dump_arg(uint, src_level);
1128 trace_dump_arg(box, src_box);
1129
1130 pipe->resource_copy_region(pipe,
1131 dst, dst_level, dstx, dsty, dstz,
1132 src, src_level, src_box);
1133
1134 trace_dump_call_end();
1135 }
1136
1137
1138 static void
trace_context_blit(struct pipe_context * _pipe,const struct pipe_blit_info * _info)1139 trace_context_blit(struct pipe_context *_pipe,
1140 const struct pipe_blit_info *_info)
1141 {
1142 struct trace_context *tr_ctx = trace_context(_pipe);
1143 struct pipe_context *pipe = tr_ctx->pipe;
1144 struct pipe_blit_info info = *_info;
1145
1146 trace_dump_call_begin("pipe_context", "blit");
1147
1148 trace_dump_arg(ptr, pipe);
1149 trace_dump_arg(blit_info, _info);
1150
1151 pipe->blit(pipe, &info);
1152
1153 trace_dump_call_end();
1154 }
1155
1156
1157 static void
trace_context_flush_resource(struct pipe_context * _pipe,struct pipe_resource * resource)1158 trace_context_flush_resource(struct pipe_context *_pipe,
1159 struct pipe_resource *resource)
1160 {
1161 struct trace_context *tr_ctx = trace_context(_pipe);
1162 struct pipe_context *pipe = tr_ctx->pipe;
1163
1164 trace_dump_call_begin("pipe_context", "flush_resource");
1165
1166 trace_dump_arg(ptr, pipe);
1167 trace_dump_arg(ptr, resource);
1168
1169 pipe->flush_resource(pipe, resource);
1170
1171 trace_dump_call_end();
1172 }
1173
1174
1175 static void
trace_context_clear(struct pipe_context * _pipe,unsigned buffers,const struct pipe_scissor_state * scissor_state,const union pipe_color_union * color,double depth,unsigned stencil)1176 trace_context_clear(struct pipe_context *_pipe,
1177 unsigned buffers,
1178 const struct pipe_scissor_state *scissor_state,
1179 const union pipe_color_union *color,
1180 double depth,
1181 unsigned stencil)
1182 {
1183 struct trace_context *tr_ctx = trace_context(_pipe);
1184 struct pipe_context *pipe = tr_ctx->pipe;
1185
1186 trace_dump_call_begin("pipe_context", "clear");
1187
1188 trace_dump_arg(ptr, pipe);
1189 trace_dump_arg(uint, buffers);
1190 trace_dump_arg_begin("scissor_state");
1191 trace_dump_scissor_state(scissor_state);
1192 trace_dump_arg_end();
1193 trace_dump_arg_begin("color");
1194 if (color)
1195 trace_dump_array(float, color->f, 4);
1196 else
1197 trace_dump_null();
1198 trace_dump_arg_end();
1199 trace_dump_arg(float, depth);
1200 trace_dump_arg(uint, stencil);
1201
1202 pipe->clear(pipe, buffers, scissor_state, color, depth, stencil);
1203
1204 trace_dump_call_end();
1205 }
1206
1207
1208 static void
trace_context_clear_render_target(struct pipe_context * _pipe,struct pipe_surface * dst,const union pipe_color_union * color,unsigned dstx,unsigned dsty,unsigned width,unsigned height,bool render_condition_enabled)1209 trace_context_clear_render_target(struct pipe_context *_pipe,
1210 struct pipe_surface *dst,
1211 const union pipe_color_union *color,
1212 unsigned dstx, unsigned dsty,
1213 unsigned width, unsigned height,
1214 bool render_condition_enabled)
1215 {
1216 struct trace_context *tr_ctx = trace_context(_pipe);
1217 struct pipe_context *pipe = tr_ctx->pipe;
1218
1219 dst = trace_surface_unwrap(tr_ctx, dst);
1220
1221 trace_dump_call_begin("pipe_context", "clear_render_target");
1222
1223 trace_dump_arg(ptr, pipe);
1224 trace_dump_arg(ptr, dst);
1225 trace_dump_arg_array(float, color->f, 4);
1226 trace_dump_arg(uint, dstx);
1227 trace_dump_arg(uint, dsty);
1228 trace_dump_arg(uint, width);
1229 trace_dump_arg(uint, height);
1230 trace_dump_arg(bool, render_condition_enabled);
1231
1232 pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height,
1233 render_condition_enabled);
1234
1235 trace_dump_call_end();
1236 }
1237
1238 static void
trace_context_clear_depth_stencil(struct pipe_context * _pipe,struct pipe_surface * dst,unsigned clear_flags,double depth,unsigned stencil,unsigned dstx,unsigned dsty,unsigned width,unsigned height,bool render_condition_enabled)1239 trace_context_clear_depth_stencil(struct pipe_context *_pipe,
1240 struct pipe_surface *dst,
1241 unsigned clear_flags,
1242 double depth,
1243 unsigned stencil,
1244 unsigned dstx, unsigned dsty,
1245 unsigned width, unsigned height,
1246 bool render_condition_enabled)
1247 {
1248 struct trace_context *tr_ctx = trace_context(_pipe);
1249 struct pipe_context *pipe = tr_ctx->pipe;
1250
1251 dst = trace_surface_unwrap(tr_ctx, dst);
1252
1253 trace_dump_call_begin("pipe_context", "clear_depth_stencil");
1254
1255 trace_dump_arg(ptr, pipe);
1256 trace_dump_arg(ptr, dst);
1257 trace_dump_arg(uint, clear_flags);
1258 trace_dump_arg(float, depth);
1259 trace_dump_arg(uint, stencil);
1260 trace_dump_arg(uint, dstx);
1261 trace_dump_arg(uint, dsty);
1262 trace_dump_arg(uint, width);
1263 trace_dump_arg(uint, height);
1264 trace_dump_arg(bool, render_condition_enabled);
1265
1266 pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil,
1267 dstx, dsty, width, height,
1268 render_condition_enabled);
1269
1270 trace_dump_call_end();
1271 }
1272
1273 static inline void
trace_context_clear_texture(struct pipe_context * _pipe,struct pipe_resource * res,unsigned level,const struct pipe_box * box,const void * data)1274 trace_context_clear_texture(struct pipe_context *_pipe,
1275 struct pipe_resource *res,
1276 unsigned level,
1277 const struct pipe_box *box,
1278 const void *data)
1279 {
1280 struct trace_context *tr_ctx = trace_context(_pipe);
1281 struct pipe_context *pipe = tr_ctx->pipe;
1282
1283
1284 trace_dump_call_begin("pipe_context", "clear_texture");
1285
1286 trace_dump_arg(ptr, pipe);
1287 trace_dump_arg(ptr, res);
1288 trace_dump_arg(uint, level);
1289 trace_dump_arg_begin("box");
1290 trace_dump_box(box);
1291 trace_dump_arg_end();
1292 trace_dump_arg(ptr, data);
1293
1294 pipe->clear_texture(pipe, res, level, box, data);
1295
1296 trace_dump_call_end();
1297 }
1298
1299 static void
trace_context_flush(struct pipe_context * _pipe,struct pipe_fence_handle ** fence,unsigned flags)1300 trace_context_flush(struct pipe_context *_pipe,
1301 struct pipe_fence_handle **fence,
1302 unsigned flags)
1303 {
1304 struct trace_context *tr_ctx = trace_context(_pipe);
1305 struct pipe_context *pipe = tr_ctx->pipe;
1306
1307 trace_dump_call_begin("pipe_context", "flush");
1308
1309 trace_dump_arg(ptr, pipe);
1310 trace_dump_arg(uint, flags);
1311
1312 pipe->flush(pipe, fence, flags);
1313
1314 if (fence)
1315 trace_dump_ret(ptr, *fence);
1316
1317 trace_dump_call_end();
1318 }
1319
1320
1321 static void
trace_context_create_fence_fd(struct pipe_context * _pipe,struct pipe_fence_handle ** fence,int fd,enum pipe_fd_type type)1322 trace_context_create_fence_fd(struct pipe_context *_pipe,
1323 struct pipe_fence_handle **fence,
1324 int fd,
1325 enum pipe_fd_type type)
1326 {
1327 struct trace_context *tr_ctx = trace_context(_pipe);
1328 struct pipe_context *pipe = tr_ctx->pipe;
1329
1330 trace_dump_call_begin("pipe_context", "create_fence_fd");
1331
1332 trace_dump_arg(ptr, pipe);
1333 trace_dump_arg(int, fd);
1334 trace_dump_arg(uint, type);
1335
1336 pipe->create_fence_fd(pipe, fence, fd, type);
1337
1338 if (fence)
1339 trace_dump_ret(ptr, *fence);
1340
1341 trace_dump_call_end();
1342 }
1343
1344
1345 static void
trace_context_fence_server_sync(struct pipe_context * _pipe,struct pipe_fence_handle * fence)1346 trace_context_fence_server_sync(struct pipe_context *_pipe,
1347 struct pipe_fence_handle *fence)
1348 {
1349 struct trace_context *tr_ctx = trace_context(_pipe);
1350 struct pipe_context *pipe = tr_ctx->pipe;
1351
1352 trace_dump_call_begin("pipe_context", "fence_server_sync");
1353
1354 trace_dump_arg(ptr, pipe);
1355 trace_dump_arg(ptr, fence);
1356
1357 pipe->fence_server_sync(pipe, fence);
1358
1359 trace_dump_call_end();
1360 }
1361
1362
1363 static inline bool
trace_context_generate_mipmap(struct pipe_context * _pipe,struct pipe_resource * res,enum pipe_format format,unsigned base_level,unsigned last_level,unsigned first_layer,unsigned last_layer)1364 trace_context_generate_mipmap(struct pipe_context *_pipe,
1365 struct pipe_resource *res,
1366 enum pipe_format format,
1367 unsigned base_level,
1368 unsigned last_level,
1369 unsigned first_layer,
1370 unsigned last_layer)
1371 {
1372 struct trace_context *tr_ctx = trace_context(_pipe);
1373 struct pipe_context *pipe = tr_ctx->pipe;
1374 bool ret;
1375
1376 trace_dump_call_begin("pipe_context", "generate_mipmap");
1377
1378 trace_dump_arg(ptr, pipe);
1379 trace_dump_arg(ptr, res);
1380
1381 trace_dump_arg(format, format);
1382 trace_dump_arg(uint, base_level);
1383 trace_dump_arg(uint, last_level);
1384 trace_dump_arg(uint, first_layer);
1385 trace_dump_arg(uint, last_layer);
1386
1387 ret = pipe->generate_mipmap(pipe, res, format, base_level, last_level,
1388 first_layer, last_layer);
1389
1390 trace_dump_ret(bool, ret);
1391 trace_dump_call_end();
1392
1393 return ret;
1394 }
1395
1396
1397 static void
trace_context_destroy(struct pipe_context * _pipe)1398 trace_context_destroy(struct pipe_context *_pipe)
1399 {
1400 struct trace_context *tr_ctx = trace_context(_pipe);
1401 struct pipe_context *pipe = tr_ctx->pipe;
1402
1403 trace_dump_call_begin("pipe_context", "destroy");
1404 trace_dump_arg(ptr, pipe);
1405 trace_dump_call_end();
1406
1407 pipe->destroy(pipe);
1408
1409 FREE(tr_ctx);
1410 }
1411
1412
1413 /********************************************************************
1414 * transfer
1415 */
1416
1417
1418 static void *
trace_context_transfer_map(struct pipe_context * _context,struct pipe_resource * resource,unsigned level,unsigned usage,const struct pipe_box * box,struct pipe_transfer ** transfer)1419 trace_context_transfer_map(struct pipe_context *_context,
1420 struct pipe_resource *resource,
1421 unsigned level,
1422 unsigned usage,
1423 const struct pipe_box *box,
1424 struct pipe_transfer **transfer)
1425 {
1426 struct trace_context *tr_context = trace_context(_context);
1427 struct pipe_context *context = tr_context->pipe;
1428 struct pipe_transfer *result = NULL;
1429 void *map;
1430
1431 /*
1432 * Map and transfers can't be serialized so we convert all write transfers
1433 * to texture/buffer_subdata and ignore read transfers.
1434 */
1435
1436 map = context->transfer_map(context, resource, level, usage, box, &result);
1437 if (!map)
1438 return NULL;
1439
1440 *transfer = trace_transfer_create(tr_context, resource, result);
1441
1442 if (map) {
1443 if (usage & PIPE_MAP_WRITE) {
1444 trace_transfer(*transfer)->map = map;
1445 }
1446 }
1447
1448 return *transfer ? map : NULL;
1449 }
1450
1451 static void
trace_context_transfer_flush_region(struct pipe_context * _context,struct pipe_transfer * _transfer,const struct pipe_box * box)1452 trace_context_transfer_flush_region( struct pipe_context *_context,
1453 struct pipe_transfer *_transfer,
1454 const struct pipe_box *box)
1455 {
1456 struct trace_context *tr_context = trace_context(_context);
1457 struct trace_transfer *tr_transfer = trace_transfer(_transfer);
1458 struct pipe_context *context = tr_context->pipe;
1459 struct pipe_transfer *transfer = tr_transfer->transfer;
1460
1461 context->transfer_flush_region(context, transfer, box);
1462 }
1463
1464 static void
trace_context_transfer_unmap(struct pipe_context * _context,struct pipe_transfer * _transfer)1465 trace_context_transfer_unmap(struct pipe_context *_context,
1466 struct pipe_transfer *_transfer)
1467 {
1468 struct trace_context *tr_ctx = trace_context(_context);
1469 struct trace_transfer *tr_trans = trace_transfer(_transfer);
1470 struct pipe_context *context = tr_ctx->pipe;
1471 struct pipe_transfer *transfer = tr_trans->transfer;
1472
1473 if (tr_trans->map) {
1474 /*
1475 * Fake a texture/buffer_subdata
1476 */
1477
1478 struct pipe_resource *resource = transfer->resource;
1479 unsigned usage = transfer->usage;
1480 const struct pipe_box *box = &transfer->box;
1481 unsigned stride = transfer->stride;
1482 unsigned layer_stride = transfer->layer_stride;
1483
1484 if (resource->target == PIPE_BUFFER) {
1485 unsigned offset = box->x;
1486 unsigned size = box->width;
1487
1488 trace_dump_call_begin("pipe_context", "buffer_subdata");
1489
1490 trace_dump_arg(ptr, context);
1491 trace_dump_arg(ptr, resource);
1492 trace_dump_arg(uint, usage);
1493 trace_dump_arg(uint, offset);
1494 trace_dump_arg(uint, size);
1495
1496 trace_dump_arg_begin("data");
1497 trace_dump_box_bytes(tr_trans->map,
1498 resource,
1499 box,
1500 stride,
1501 layer_stride);
1502 trace_dump_arg_end();
1503
1504 trace_dump_arg(uint, stride);
1505 trace_dump_arg(uint, layer_stride);
1506
1507 trace_dump_call_end();
1508 } else {
1509 unsigned level = transfer->level;
1510
1511 trace_dump_call_begin("pipe_context", "texture_subdata");
1512
1513 trace_dump_arg(ptr, context);
1514 trace_dump_arg(ptr, resource);
1515 trace_dump_arg(uint, level);
1516 trace_dump_arg(uint, usage);
1517 trace_dump_arg(box, box);
1518
1519 trace_dump_arg_begin("data");
1520 trace_dump_box_bytes(tr_trans->map,
1521 resource,
1522 box,
1523 stride,
1524 layer_stride);
1525 trace_dump_arg_end();
1526
1527 trace_dump_arg(uint, stride);
1528 trace_dump_arg(uint, layer_stride);
1529
1530 trace_dump_call_end();
1531 }
1532
1533 tr_trans->map = NULL;
1534 }
1535
1536 context->transfer_unmap(context, transfer);
1537 trace_transfer_destroy(tr_ctx, tr_trans);
1538 }
1539
1540
1541 static void
trace_context_buffer_subdata(struct pipe_context * _context,struct pipe_resource * resource,unsigned usage,unsigned offset,unsigned size,const void * data)1542 trace_context_buffer_subdata(struct pipe_context *_context,
1543 struct pipe_resource *resource,
1544 unsigned usage, unsigned offset,
1545 unsigned size, const void *data)
1546 {
1547 struct trace_context *tr_context = trace_context(_context);
1548 struct pipe_context *context = tr_context->pipe;
1549 struct pipe_box box;
1550
1551 trace_dump_call_begin("pipe_context", "buffer_subdata");
1552
1553 trace_dump_arg(ptr, context);
1554 trace_dump_arg(ptr, resource);
1555 trace_dump_arg(uint, usage);
1556 trace_dump_arg(uint, offset);
1557 trace_dump_arg(uint, size);
1558
1559 trace_dump_arg_begin("data");
1560 u_box_1d(offset, size, &box);
1561 trace_dump_box_bytes(data, resource, &box, 0, 0);
1562 trace_dump_arg_end();
1563
1564 trace_dump_call_end();
1565
1566 context->buffer_subdata(context, resource, usage, offset, size, data);
1567 }
1568
1569
1570 static void
trace_context_texture_subdata(struct pipe_context * _context,struct pipe_resource * resource,unsigned level,unsigned usage,const struct pipe_box * box,const void * data,unsigned stride,unsigned layer_stride)1571 trace_context_texture_subdata(struct pipe_context *_context,
1572 struct pipe_resource *resource,
1573 unsigned level,
1574 unsigned usage,
1575 const struct pipe_box *box,
1576 const void *data,
1577 unsigned stride,
1578 unsigned layer_stride)
1579 {
1580 struct trace_context *tr_context = trace_context(_context);
1581 struct pipe_context *context = tr_context->pipe;
1582
1583 trace_dump_call_begin("pipe_context", "texture_subdata");
1584
1585 trace_dump_arg(ptr, context);
1586 trace_dump_arg(ptr, resource);
1587 trace_dump_arg(uint, level);
1588 trace_dump_arg(uint, usage);
1589 trace_dump_arg(box, box);
1590
1591 trace_dump_arg_begin("data");
1592 trace_dump_box_bytes(data,
1593 resource,
1594 box,
1595 stride,
1596 layer_stride);
1597 trace_dump_arg_end();
1598
1599 trace_dump_arg(uint, stride);
1600 trace_dump_arg(uint, layer_stride);
1601
1602 trace_dump_call_end();
1603
1604 context->texture_subdata(context, resource, level, usage, box,
1605 data, stride, layer_stride);
1606 }
1607
1608 static void
trace_context_invalidate_resource(struct pipe_context * _context,struct pipe_resource * resource)1609 trace_context_invalidate_resource(struct pipe_context *_context,
1610 struct pipe_resource *resource)
1611 {
1612 struct trace_context *tr_context = trace_context(_context);
1613 struct pipe_context *context = tr_context->pipe;
1614
1615 trace_dump_call_begin("pipe_context", "invalidate_resource");
1616
1617 trace_dump_arg(ptr, context);
1618 trace_dump_arg(ptr, resource);
1619
1620 trace_dump_call_end();
1621
1622 context->invalidate_resource(context, resource);
1623 }
1624
1625 static void
trace_context_set_context_param(struct pipe_context * _context,enum pipe_context_param param,unsigned value)1626 trace_context_set_context_param(struct pipe_context *_context,
1627 enum pipe_context_param param,
1628 unsigned value)
1629 {
1630 struct trace_context *tr_context = trace_context(_context);
1631 struct pipe_context *context = tr_context->pipe;
1632
1633 trace_dump_call_begin("pipe_context", "set_context_param");
1634
1635 trace_dump_arg(ptr, context);
1636 trace_dump_arg(uint, param);
1637 trace_dump_arg(uint, value);
1638
1639 trace_dump_call_end();
1640
1641 context->set_context_param(context, param, value);
1642 }
1643
1644 static void
trace_context_render_condition(struct pipe_context * _context,struct pipe_query * query,bool condition,enum pipe_render_cond_flag mode)1645 trace_context_render_condition(struct pipe_context *_context,
1646 struct pipe_query *query,
1647 bool condition,
1648 enum pipe_render_cond_flag mode)
1649 {
1650 struct trace_context *tr_context = trace_context(_context);
1651 struct pipe_context *context = tr_context->pipe;
1652
1653 query = trace_query_unwrap(query);
1654
1655 trace_dump_call_begin("pipe_context", "render_condition");
1656
1657 trace_dump_arg(ptr, context);
1658 trace_dump_arg(ptr, query);
1659 trace_dump_arg(bool, condition);
1660 trace_dump_arg(uint, mode);
1661
1662 trace_dump_call_end();
1663
1664 context->render_condition(context, query, condition, mode);
1665 }
1666
1667
1668 static void
trace_context_texture_barrier(struct pipe_context * _context,unsigned flags)1669 trace_context_texture_barrier(struct pipe_context *_context, unsigned flags)
1670 {
1671 struct trace_context *tr_context = trace_context(_context);
1672 struct pipe_context *context = tr_context->pipe;
1673
1674 trace_dump_call_begin("pipe_context", "texture_barrier");
1675
1676 trace_dump_arg(ptr, context);
1677 trace_dump_arg(uint, flags);
1678
1679 trace_dump_call_end();
1680
1681 context->texture_barrier(context, flags);
1682 }
1683
1684
1685 static void
trace_context_memory_barrier(struct pipe_context * _context,unsigned flags)1686 trace_context_memory_barrier(struct pipe_context *_context,
1687 unsigned flags)
1688 {
1689 struct trace_context *tr_context = trace_context(_context);
1690 struct pipe_context *context = tr_context->pipe;
1691
1692 trace_dump_call_begin("pipe_context", "memory_barrier");
1693 trace_dump_arg(ptr, context);
1694 trace_dump_arg(uint, flags);
1695 trace_dump_call_end();
1696
1697 context->memory_barrier(context, flags);
1698 }
1699
1700
1701 static bool
trace_context_resource_commit(struct pipe_context * _context,struct pipe_resource * resource,unsigned level,struct pipe_box * box,bool commit)1702 trace_context_resource_commit(struct pipe_context *_context,
1703 struct pipe_resource *resource,
1704 unsigned level, struct pipe_box *box, bool commit)
1705 {
1706 struct trace_context *tr_context = trace_context(_context);
1707 struct pipe_context *context = tr_context->pipe;
1708
1709 trace_dump_call_begin("pipe_context", "resource_commit");
1710 trace_dump_arg(ptr, context);
1711 trace_dump_arg(ptr, resource);
1712 trace_dump_arg(uint, level);
1713 trace_dump_arg(box, box);
1714 trace_dump_arg(bool, commit);
1715 trace_dump_call_end();
1716
1717 return context->resource_commit(context, resource, level, box, commit);
1718 }
1719
1720 static void
trace_context_set_tess_state(struct pipe_context * _context,const float default_outer_level[4],const float default_inner_level[2])1721 trace_context_set_tess_state(struct pipe_context *_context,
1722 const float default_outer_level[4],
1723 const float default_inner_level[2])
1724 {
1725 struct trace_context *tr_context = trace_context(_context);
1726 struct pipe_context *context = tr_context->pipe;
1727
1728 trace_dump_call_begin("pipe_context", "set_tess_state");
1729 trace_dump_arg(ptr, context);
1730 trace_dump_arg_array(float, default_outer_level, 4);
1731 trace_dump_arg_array(float, default_inner_level, 2);
1732 trace_dump_call_end();
1733
1734 context->set_tess_state(context, default_outer_level, default_inner_level);
1735 }
1736
1737
trace_context_set_shader_buffers(struct pipe_context * _context,enum pipe_shader_type shader,unsigned start,unsigned nr,const struct pipe_shader_buffer * buffers,unsigned writable_bitmask)1738 static void trace_context_set_shader_buffers(struct pipe_context *_context,
1739 enum pipe_shader_type shader,
1740 unsigned start, unsigned nr,
1741 const struct pipe_shader_buffer *buffers,
1742 unsigned writable_bitmask)
1743 {
1744 struct trace_context *tr_context = trace_context(_context);
1745 struct pipe_context *context = tr_context->pipe;
1746
1747 trace_dump_call_begin("pipe_context", "set_shader_buffers");
1748 trace_dump_arg(ptr, context);
1749 trace_dump_arg(uint, shader);
1750 trace_dump_arg(uint, start);
1751 trace_dump_arg_begin("buffers");
1752 trace_dump_struct_array(shader_buffer, buffers, nr);
1753 trace_dump_arg(uint, writable_bitmask);
1754 trace_dump_arg_end();
1755 trace_dump_call_end();
1756
1757 context->set_shader_buffers(context, shader, start, nr, buffers,
1758 writable_bitmask);
1759 }
1760
trace_context_set_shader_images(struct pipe_context * _context,enum pipe_shader_type shader,unsigned start,unsigned nr,const struct pipe_image_view * images)1761 static void trace_context_set_shader_images(struct pipe_context *_context,
1762 enum pipe_shader_type shader,
1763 unsigned start, unsigned nr,
1764 const struct pipe_image_view *images)
1765 {
1766 struct trace_context *tr_context = trace_context(_context);
1767 struct pipe_context *context = tr_context->pipe;
1768
1769 trace_dump_call_begin("pipe_context", "set_shader_images");
1770 trace_dump_arg(ptr, context);
1771 trace_dump_arg(uint, shader);
1772 trace_dump_arg(uint, start);
1773 trace_dump_arg_begin("images");
1774 trace_dump_struct_array(image_view, images, nr);
1775 trace_dump_arg_end();
1776 trace_dump_call_end();
1777
1778 context->set_shader_images(context, shader, start, nr, images);
1779 }
1780
trace_context_launch_grid(struct pipe_context * _pipe,const struct pipe_grid_info * info)1781 static void trace_context_launch_grid(struct pipe_context *_pipe,
1782 const struct pipe_grid_info *info)
1783 {
1784 struct trace_context *tr_ctx = trace_context(_pipe);
1785 struct pipe_context *pipe = tr_ctx->pipe;
1786
1787 trace_dump_call_begin("pipe_context", "launch_grid");
1788
1789 trace_dump_arg(ptr, pipe);
1790 trace_dump_arg(grid_info, info);
1791
1792 trace_dump_trace_flush();
1793
1794 pipe->launch_grid(pipe, info);
1795
1796 trace_dump_call_end();
1797 }
1798
trace_context_create_texture_handle(struct pipe_context * _pipe,struct pipe_sampler_view * view,const struct pipe_sampler_state * state)1799 static uint64_t trace_context_create_texture_handle(struct pipe_context *_pipe,
1800 struct pipe_sampler_view *view,
1801 const struct pipe_sampler_state *state)
1802 {
1803 struct trace_context *tr_ctx = trace_context(_pipe);
1804 struct pipe_context *pipe = tr_ctx->pipe;
1805 uint64_t handle;
1806
1807 trace_dump_call_begin("pipe_context", "create_texture_handle");
1808 trace_dump_arg(ptr, pipe);
1809 trace_dump_arg(ptr, view);
1810 trace_dump_arg_begin("state");
1811 trace_dump_arg(sampler_state, state);
1812 trace_dump_arg_end();
1813
1814 handle = pipe->create_texture_handle(pipe, view, state);
1815
1816 trace_dump_ret(uint, handle);
1817 trace_dump_call_end();
1818
1819 return handle;
1820 }
1821
trace_context_delete_texture_handle(struct pipe_context * _pipe,uint64_t handle)1822 static void trace_context_delete_texture_handle(struct pipe_context *_pipe,
1823 uint64_t handle)
1824 {
1825 struct trace_context *tr_ctx = trace_context(_pipe);
1826 struct pipe_context *pipe = tr_ctx->pipe;
1827
1828 trace_dump_call_begin("pipe_context", "delete_texture_handle");
1829 trace_dump_arg(ptr, pipe);
1830 trace_dump_arg(uint, handle);
1831 trace_dump_call_end();
1832
1833 pipe->delete_texture_handle(pipe, handle);
1834 }
1835
trace_context_make_texture_handle_resident(struct pipe_context * _pipe,uint64_t handle,bool resident)1836 static void trace_context_make_texture_handle_resident(struct pipe_context *_pipe,
1837 uint64_t handle,
1838 bool resident)
1839 {
1840 struct trace_context *tr_ctx = trace_context(_pipe);
1841 struct pipe_context *pipe = tr_ctx->pipe;
1842
1843 trace_dump_call_begin("pipe_context", "make_texture_handle_resident");
1844 trace_dump_arg(ptr, pipe);
1845 trace_dump_arg(uint, handle);
1846 trace_dump_arg(bool, resident);
1847 trace_dump_call_end();
1848
1849 pipe->make_texture_handle_resident(pipe, handle, resident);
1850 }
1851
trace_context_create_image_handle(struct pipe_context * _pipe,const struct pipe_image_view * image)1852 static uint64_t trace_context_create_image_handle(struct pipe_context *_pipe,
1853 const struct pipe_image_view *image)
1854 {
1855 struct trace_context *tr_ctx = trace_context(_pipe);
1856 struct pipe_context *pipe = tr_ctx->pipe;
1857 uint64_t handle;
1858
1859 trace_dump_call_begin("pipe_context", "create_image_handle");
1860 trace_dump_arg(ptr, pipe);
1861 trace_dump_arg_begin("image");
1862 trace_dump_image_view(image);
1863 trace_dump_arg_end();
1864
1865 handle = pipe->create_image_handle(pipe, image);
1866
1867 trace_dump_ret(uint, handle);
1868 trace_dump_call_end();
1869
1870 return handle;
1871 }
1872
trace_context_delete_image_handle(struct pipe_context * _pipe,uint64_t handle)1873 static void trace_context_delete_image_handle(struct pipe_context *_pipe,
1874 uint64_t handle)
1875 {
1876 struct trace_context *tr_ctx = trace_context(_pipe);
1877 struct pipe_context *pipe = tr_ctx->pipe;
1878
1879 trace_dump_call_begin("pipe_context", "delete_image_handle");
1880 trace_dump_arg(ptr, pipe);
1881 trace_dump_arg(uint, handle);
1882 trace_dump_call_end();
1883
1884 pipe->delete_image_handle(pipe, handle);
1885 }
1886
trace_context_make_image_handle_resident(struct pipe_context * _pipe,uint64_t handle,unsigned access,bool resident)1887 static void trace_context_make_image_handle_resident(struct pipe_context *_pipe,
1888 uint64_t handle,
1889 unsigned access,
1890 bool resident)
1891 {
1892 struct trace_context *tr_ctx = trace_context(_pipe);
1893 struct pipe_context *pipe = tr_ctx->pipe;
1894
1895 trace_dump_call_begin("pipe_context", "make_image_handle_resident");
1896 trace_dump_arg(ptr, pipe);
1897 trace_dump_arg(uint, handle);
1898 trace_dump_arg(uint, access);
1899 trace_dump_arg(bool, resident);
1900 trace_dump_call_end();
1901
1902 pipe->make_image_handle_resident(pipe, handle, access, resident);
1903 }
1904
1905 struct pipe_context *
trace_context_create(struct trace_screen * tr_scr,struct pipe_context * pipe)1906 trace_context_create(struct trace_screen *tr_scr,
1907 struct pipe_context *pipe)
1908 {
1909 struct trace_context *tr_ctx;
1910
1911 if (!pipe)
1912 goto error1;
1913
1914 if (!trace_enabled())
1915 goto error1;
1916
1917 tr_ctx = CALLOC_STRUCT(trace_context);
1918 if (!tr_ctx)
1919 goto error1;
1920
1921 tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
1922 tr_ctx->base.screen = &tr_scr->base;
1923 tr_ctx->base.stream_uploader = pipe->stream_uploader;
1924 tr_ctx->base.const_uploader = pipe->const_uploader;
1925
1926 tr_ctx->base.destroy = trace_context_destroy;
1927
1928 #define TR_CTX_INIT(_member) \
1929 tr_ctx->base . _member = pipe -> _member ? trace_context_ ## _member : NULL
1930
1931 TR_CTX_INIT(draw_vbo);
1932 TR_CTX_INIT(render_condition);
1933 TR_CTX_INIT(create_query);
1934 TR_CTX_INIT(destroy_query);
1935 TR_CTX_INIT(begin_query);
1936 TR_CTX_INIT(end_query);
1937 TR_CTX_INIT(get_query_result);
1938 TR_CTX_INIT(set_active_query_state);
1939 TR_CTX_INIT(create_blend_state);
1940 TR_CTX_INIT(bind_blend_state);
1941 TR_CTX_INIT(delete_blend_state);
1942 TR_CTX_INIT(create_sampler_state);
1943 TR_CTX_INIT(bind_sampler_states);
1944 TR_CTX_INIT(delete_sampler_state);
1945 TR_CTX_INIT(create_rasterizer_state);
1946 TR_CTX_INIT(bind_rasterizer_state);
1947 TR_CTX_INIT(delete_rasterizer_state);
1948 TR_CTX_INIT(create_depth_stencil_alpha_state);
1949 TR_CTX_INIT(bind_depth_stencil_alpha_state);
1950 TR_CTX_INIT(delete_depth_stencil_alpha_state);
1951 TR_CTX_INIT(create_fs_state);
1952 TR_CTX_INIT(bind_fs_state);
1953 TR_CTX_INIT(delete_fs_state);
1954 TR_CTX_INIT(create_vs_state);
1955 TR_CTX_INIT(bind_vs_state);
1956 TR_CTX_INIT(delete_vs_state);
1957 TR_CTX_INIT(create_gs_state);
1958 TR_CTX_INIT(bind_gs_state);
1959 TR_CTX_INIT(delete_gs_state);
1960 TR_CTX_INIT(create_tcs_state);
1961 TR_CTX_INIT(bind_tcs_state);
1962 TR_CTX_INIT(delete_tcs_state);
1963 TR_CTX_INIT(create_tes_state);
1964 TR_CTX_INIT(bind_tes_state);
1965 TR_CTX_INIT(delete_tes_state);
1966 TR_CTX_INIT(create_compute_state);
1967 TR_CTX_INIT(bind_compute_state);
1968 TR_CTX_INIT(delete_compute_state);
1969 TR_CTX_INIT(create_vertex_elements_state);
1970 TR_CTX_INIT(bind_vertex_elements_state);
1971 TR_CTX_INIT(delete_vertex_elements_state);
1972 TR_CTX_INIT(set_blend_color);
1973 TR_CTX_INIT(set_stencil_ref);
1974 TR_CTX_INIT(set_clip_state);
1975 TR_CTX_INIT(set_sample_mask);
1976 TR_CTX_INIT(set_constant_buffer);
1977 TR_CTX_INIT(set_framebuffer_state);
1978 TR_CTX_INIT(set_polygon_stipple);
1979 TR_CTX_INIT(set_scissor_states);
1980 TR_CTX_INIT(set_viewport_states);
1981 TR_CTX_INIT(set_sampler_views);
1982 TR_CTX_INIT(create_sampler_view);
1983 TR_CTX_INIT(sampler_view_destroy);
1984 TR_CTX_INIT(create_surface);
1985 TR_CTX_INIT(surface_destroy);
1986 TR_CTX_INIT(set_vertex_buffers);
1987 TR_CTX_INIT(create_stream_output_target);
1988 TR_CTX_INIT(stream_output_target_destroy);
1989 TR_CTX_INIT(set_stream_output_targets);
1990 TR_CTX_INIT(resource_copy_region);
1991 TR_CTX_INIT(blit);
1992 TR_CTX_INIT(flush_resource);
1993 TR_CTX_INIT(clear);
1994 TR_CTX_INIT(clear_render_target);
1995 TR_CTX_INIT(clear_depth_stencil);
1996 TR_CTX_INIT(clear_texture);
1997 TR_CTX_INIT(flush);
1998 TR_CTX_INIT(create_fence_fd);
1999 TR_CTX_INIT(fence_server_sync);
2000 TR_CTX_INIT(generate_mipmap);
2001 TR_CTX_INIT(texture_barrier);
2002 TR_CTX_INIT(memory_barrier);
2003 TR_CTX_INIT(resource_commit);
2004 TR_CTX_INIT(set_tess_state);
2005 TR_CTX_INIT(set_shader_buffers);
2006 TR_CTX_INIT(launch_grid);
2007 TR_CTX_INIT(set_shader_images);
2008 TR_CTX_INIT(create_texture_handle);
2009 TR_CTX_INIT(delete_texture_handle);
2010 TR_CTX_INIT(make_texture_handle_resident);
2011 TR_CTX_INIT(create_image_handle);
2012 TR_CTX_INIT(delete_image_handle);
2013 TR_CTX_INIT(make_image_handle_resident);
2014
2015 TR_CTX_INIT(transfer_map);
2016 TR_CTX_INIT(transfer_unmap);
2017 TR_CTX_INIT(transfer_flush_region);
2018 TR_CTX_INIT(buffer_subdata);
2019 TR_CTX_INIT(texture_subdata);
2020 TR_CTX_INIT(invalidate_resource);
2021 TR_CTX_INIT(set_context_param);
2022
2023 #undef TR_CTX_INIT
2024
2025 tr_ctx->pipe = pipe;
2026
2027 return &tr_ctx->base;
2028
2029 error1:
2030 return pipe;
2031 }
2032
2033
2034 /**
2035 * Sanity checker: check that the given context really is a
2036 * trace context (and not the wrapped driver's context).
2037 */
2038 void
trace_context_check(const struct pipe_context * pipe)2039 trace_context_check(const struct pipe_context *pipe)
2040 {
2041 ASSERTED struct trace_context *tr_ctx = (struct trace_context *) pipe;
2042 assert(tr_ctx->base.destroy == trace_context_destroy);
2043 }
2044