• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 boolean
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    boolean 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 boolean
trace_context_get_query_result(struct pipe_context * _pipe,struct pipe_query * _query,boolean wait,union pipe_query_result * result)215 trace_context_get_query_result(struct pipe_context *_pipe,
216                                struct pipe_query *_query,
217                                boolean 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    boolean 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,boolean enable)250 trace_context_set_active_query_state(struct pipe_context *_pipe,
251                                      boolean 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 union pipe_color_union * color,double depth,unsigned stencil)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    trace_dump_arg_begin("color");
1190    if (color)
1191       trace_dump_array(float, color->f, 4);
1192    else
1193       trace_dump_null();
1194    trace_dump_arg_end();
1195    trace_dump_arg(float, depth);
1196    trace_dump_arg(uint, stencil);
1197 
1198    pipe->clear(pipe, buffers, color, depth, stencil);
1199 
1200    trace_dump_call_end();
1201 }
1202 
1203 
1204 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)1205 trace_context_clear_render_target(struct pipe_context *_pipe,
1206                                   struct pipe_surface *dst,
1207                                   const union pipe_color_union *color,
1208                                   unsigned dstx, unsigned dsty,
1209                                   unsigned width, unsigned height,
1210                                   bool render_condition_enabled)
1211 {
1212    struct trace_context *tr_ctx = trace_context(_pipe);
1213    struct pipe_context *pipe = tr_ctx->pipe;
1214 
1215    dst = trace_surface_unwrap(tr_ctx, dst);
1216 
1217    trace_dump_call_begin("pipe_context", "clear_render_target");
1218 
1219    trace_dump_arg(ptr, pipe);
1220    trace_dump_arg(ptr, dst);
1221    trace_dump_arg_array(float, color->f, 4);
1222    trace_dump_arg(uint, dstx);
1223    trace_dump_arg(uint, dsty);
1224    trace_dump_arg(uint, width);
1225    trace_dump_arg(uint, height);
1226    trace_dump_arg(bool, render_condition_enabled);
1227 
1228    pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height,
1229                              render_condition_enabled);
1230 
1231    trace_dump_call_end();
1232 }
1233 
1234 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)1235 trace_context_clear_depth_stencil(struct pipe_context *_pipe,
1236                                   struct pipe_surface *dst,
1237                                   unsigned clear_flags,
1238                                   double depth,
1239                                   unsigned stencil,
1240                                   unsigned dstx, unsigned dsty,
1241                                   unsigned width, unsigned height,
1242                                   bool render_condition_enabled)
1243 {
1244    struct trace_context *tr_ctx = trace_context(_pipe);
1245    struct pipe_context *pipe = tr_ctx->pipe;
1246 
1247    dst = trace_surface_unwrap(tr_ctx, dst);
1248 
1249    trace_dump_call_begin("pipe_context", "clear_depth_stencil");
1250 
1251    trace_dump_arg(ptr, pipe);
1252    trace_dump_arg(ptr, dst);
1253    trace_dump_arg(uint, clear_flags);
1254    trace_dump_arg(float, depth);
1255    trace_dump_arg(uint, stencil);
1256    trace_dump_arg(uint, dstx);
1257    trace_dump_arg(uint, dsty);
1258    trace_dump_arg(uint, width);
1259    trace_dump_arg(uint, height);
1260    trace_dump_arg(bool, render_condition_enabled);
1261 
1262    pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil,
1263                              dstx, dsty, width, height,
1264                              render_condition_enabled);
1265 
1266    trace_dump_call_end();
1267 }
1268 
1269 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)1270 trace_context_clear_texture(struct pipe_context *_pipe,
1271                             struct pipe_resource *res,
1272                             unsigned level,
1273                             const struct pipe_box *box,
1274                             const void *data)
1275 {
1276    struct trace_context *tr_ctx = trace_context(_pipe);
1277    struct pipe_context *pipe = tr_ctx->pipe;
1278 
1279 
1280    trace_dump_call_begin("pipe_context", "clear_texture");
1281 
1282    trace_dump_arg(ptr, pipe);
1283    trace_dump_arg(ptr, res);
1284    trace_dump_arg(uint, level);
1285    trace_dump_arg_begin("box");
1286    trace_dump_box(box);
1287    trace_dump_arg_end();
1288    trace_dump_arg(ptr, data);
1289 
1290    pipe->clear_texture(pipe, res, level, box, data);
1291 
1292    trace_dump_call_end();
1293 }
1294 
1295 static void
trace_context_flush(struct pipe_context * _pipe,struct pipe_fence_handle ** fence,unsigned flags)1296 trace_context_flush(struct pipe_context *_pipe,
1297                     struct pipe_fence_handle **fence,
1298                     unsigned flags)
1299 {
1300    struct trace_context *tr_ctx = trace_context(_pipe);
1301    struct pipe_context *pipe = tr_ctx->pipe;
1302 
1303    trace_dump_call_begin("pipe_context", "flush");
1304 
1305    trace_dump_arg(ptr, pipe);
1306    trace_dump_arg(uint, flags);
1307 
1308    pipe->flush(pipe, fence, flags);
1309 
1310    if (fence)
1311       trace_dump_ret(ptr, *fence);
1312 
1313    trace_dump_call_end();
1314 }
1315 
1316 
1317 static inline boolean
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)1318 trace_context_generate_mipmap(struct pipe_context *_pipe,
1319                               struct pipe_resource *res,
1320                               enum pipe_format format,
1321                               unsigned base_level,
1322                               unsigned last_level,
1323                               unsigned first_layer,
1324                               unsigned last_layer)
1325 {
1326    struct trace_context *tr_ctx = trace_context(_pipe);
1327    struct pipe_context *pipe = tr_ctx->pipe;
1328    boolean ret;
1329 
1330    trace_dump_call_begin("pipe_context", "generate_mipmap");
1331 
1332    trace_dump_arg(ptr, pipe);
1333    trace_dump_arg(ptr, res);
1334 
1335    trace_dump_arg(format, format);
1336    trace_dump_arg(uint, base_level);
1337    trace_dump_arg(uint, last_level);
1338    trace_dump_arg(uint, first_layer);
1339    trace_dump_arg(uint, last_layer);
1340 
1341    ret = pipe->generate_mipmap(pipe, res, format, base_level, last_level,
1342                                first_layer, last_layer);
1343 
1344    trace_dump_ret(bool, ret);
1345    trace_dump_call_end();
1346 
1347    return ret;
1348 }
1349 
1350 
1351 static void
trace_context_destroy(struct pipe_context * _pipe)1352 trace_context_destroy(struct pipe_context *_pipe)
1353 {
1354    struct trace_context *tr_ctx = trace_context(_pipe);
1355    struct pipe_context *pipe = tr_ctx->pipe;
1356 
1357    trace_dump_call_begin("pipe_context", "destroy");
1358    trace_dump_arg(ptr, pipe);
1359    trace_dump_call_end();
1360 
1361    pipe->destroy(pipe);
1362 
1363    FREE(tr_ctx);
1364 }
1365 
1366 
1367 /********************************************************************
1368  * transfer
1369  */
1370 
1371 
1372 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)1373 trace_context_transfer_map(struct pipe_context *_context,
1374                            struct pipe_resource *resource,
1375                            unsigned level,
1376                            unsigned usage,
1377                            const struct pipe_box *box,
1378                            struct pipe_transfer **transfer)
1379 {
1380    struct trace_context *tr_context = trace_context(_context);
1381    struct pipe_context *context = tr_context->pipe;
1382    struct pipe_transfer *result = NULL;
1383    void *map;
1384 
1385    /*
1386     * Map and transfers can't be serialized so we convert all write transfers
1387     * to texture/buffer_subdata and ignore read transfers.
1388     */
1389 
1390    map = context->transfer_map(context, resource, level, usage, box, &result);
1391    if (!map)
1392       return NULL;
1393 
1394    *transfer = trace_transfer_create(tr_context, resource, result);
1395 
1396    if (map) {
1397       if (usage & PIPE_TRANSFER_WRITE) {
1398          trace_transfer(*transfer)->map = map;
1399       }
1400    }
1401 
1402    return *transfer ? map : NULL;
1403 }
1404 
1405 static void
trace_context_transfer_flush_region(struct pipe_context * _context,struct pipe_transfer * _transfer,const struct pipe_box * box)1406 trace_context_transfer_flush_region( struct pipe_context *_context,
1407 				     struct pipe_transfer *_transfer,
1408 				     const struct pipe_box *box)
1409 {
1410    struct trace_context *tr_context = trace_context(_context);
1411    struct trace_transfer *tr_transfer = trace_transfer(_transfer);
1412    struct pipe_context *context = tr_context->pipe;
1413    struct pipe_transfer *transfer = tr_transfer->transfer;
1414 
1415    context->transfer_flush_region(context, transfer, box);
1416 }
1417 
1418 static void
trace_context_transfer_unmap(struct pipe_context * _context,struct pipe_transfer * _transfer)1419 trace_context_transfer_unmap(struct pipe_context *_context,
1420                              struct pipe_transfer *_transfer)
1421 {
1422    struct trace_context *tr_ctx = trace_context(_context);
1423    struct trace_transfer *tr_trans = trace_transfer(_transfer);
1424    struct pipe_context *context = tr_ctx->pipe;
1425    struct pipe_transfer *transfer = tr_trans->transfer;
1426 
1427    if (tr_trans->map) {
1428       /*
1429        * Fake a texture/buffer_subdata
1430        */
1431 
1432       struct pipe_resource *resource = transfer->resource;
1433       unsigned level = transfer->level;
1434       unsigned usage = transfer->usage;
1435       const struct pipe_box *box = &transfer->box;
1436       unsigned stride = transfer->stride;
1437       unsigned layer_stride = transfer->layer_stride;
1438 
1439       if (resource->target == PIPE_BUFFER)
1440          trace_dump_call_begin("pipe_context", "buffer_subdata");
1441       else
1442          trace_dump_call_begin("pipe_context", "texture_subdata");
1443 
1444       trace_dump_arg(ptr, context);
1445       trace_dump_arg(ptr, resource);
1446       trace_dump_arg(uint, level);
1447       trace_dump_arg(uint, usage);
1448       trace_dump_arg(box, box);
1449 
1450       trace_dump_arg_begin("data");
1451       trace_dump_box_bytes(tr_trans->map,
1452                            resource,
1453                            box,
1454                            stride,
1455                            layer_stride);
1456       trace_dump_arg_end();
1457 
1458       trace_dump_arg(uint, stride);
1459       trace_dump_arg(uint, layer_stride);
1460 
1461       trace_dump_call_end();
1462 
1463       tr_trans->map = NULL;
1464    }
1465 
1466    context->transfer_unmap(context, transfer);
1467    trace_transfer_destroy(tr_ctx, tr_trans);
1468 }
1469 
1470 
1471 static void
trace_context_buffer_subdata(struct pipe_context * _context,struct pipe_resource * resource,unsigned usage,unsigned offset,unsigned size,const void * data)1472 trace_context_buffer_subdata(struct pipe_context *_context,
1473                              struct pipe_resource *resource,
1474                              unsigned usage, unsigned offset,
1475                              unsigned size, const void *data)
1476 {
1477    struct trace_context *tr_context = trace_context(_context);
1478    struct pipe_context *context = tr_context->pipe;
1479    struct pipe_box box;
1480 
1481    trace_dump_call_begin("pipe_context", "buffer_subdata");
1482 
1483    trace_dump_arg(ptr, context);
1484    trace_dump_arg(ptr, resource);
1485    trace_dump_arg(uint, usage);
1486    trace_dump_arg(uint, offset);
1487    trace_dump_arg(uint, size);
1488 
1489    trace_dump_arg_begin("data");
1490    u_box_1d(offset, size, &box);
1491    trace_dump_box_bytes(data, resource, &box, 0, 0);
1492    trace_dump_arg_end();
1493 
1494    trace_dump_call_end();
1495 
1496    context->buffer_subdata(context, resource, usage, offset, size, data);
1497 }
1498 
1499 
1500 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)1501 trace_context_texture_subdata(struct pipe_context *_context,
1502                               struct pipe_resource *resource,
1503                               unsigned level,
1504                               unsigned usage,
1505                               const struct pipe_box *box,
1506                               const void *data,
1507                               unsigned stride,
1508                               unsigned layer_stride)
1509 {
1510    struct trace_context *tr_context = trace_context(_context);
1511    struct pipe_context *context = tr_context->pipe;
1512 
1513    trace_dump_call_begin("pipe_context", "texture_subdata");
1514 
1515    trace_dump_arg(ptr, context);
1516    trace_dump_arg(ptr, resource);
1517    trace_dump_arg(uint, level);
1518    trace_dump_arg(uint, usage);
1519    trace_dump_arg(box, box);
1520 
1521    trace_dump_arg_begin("data");
1522    trace_dump_box_bytes(data,
1523                         resource,
1524                         box,
1525                         stride,
1526                         layer_stride);
1527    trace_dump_arg_end();
1528 
1529    trace_dump_arg(uint, stride);
1530    trace_dump_arg(uint, layer_stride);
1531 
1532    trace_dump_call_end();
1533 
1534    context->texture_subdata(context, resource, level, usage, box,
1535                             data, stride, layer_stride);
1536 }
1537 
1538 static void
trace_context_invalidate_resource(struct pipe_context * _context,struct pipe_resource * resource)1539 trace_context_invalidate_resource(struct pipe_context *_context,
1540                                   struct pipe_resource *resource)
1541 {
1542    struct trace_context *tr_context = trace_context(_context);
1543    struct pipe_context *context = tr_context->pipe;
1544 
1545    trace_dump_call_begin("pipe_context", "invalidate_resource");
1546 
1547    trace_dump_arg(ptr, context);
1548    trace_dump_arg(ptr, resource);
1549 
1550    trace_dump_call_end();
1551 
1552    context->invalidate_resource(context, resource);
1553 }
1554 
1555 static void
trace_context_render_condition(struct pipe_context * _context,struct pipe_query * query,boolean condition,enum pipe_render_cond_flag mode)1556 trace_context_render_condition(struct pipe_context *_context,
1557                                struct pipe_query *query,
1558                                boolean condition,
1559                                enum pipe_render_cond_flag mode)
1560 {
1561    struct trace_context *tr_context = trace_context(_context);
1562    struct pipe_context *context = tr_context->pipe;
1563 
1564    query = trace_query_unwrap(query);
1565 
1566    trace_dump_call_begin("pipe_context", "render_condition");
1567 
1568    trace_dump_arg(ptr, context);
1569    trace_dump_arg(ptr, query);
1570    trace_dump_arg(bool, condition);
1571    trace_dump_arg(uint, mode);
1572 
1573    trace_dump_call_end();
1574 
1575    context->render_condition(context, query, condition, mode);
1576 }
1577 
1578 
1579 static void
trace_context_texture_barrier(struct pipe_context * _context,unsigned flags)1580 trace_context_texture_barrier(struct pipe_context *_context, unsigned flags)
1581 {
1582    struct trace_context *tr_context = trace_context(_context);
1583    struct pipe_context *context = tr_context->pipe;
1584 
1585    trace_dump_call_begin("pipe_context", "texture_barrier");
1586 
1587    trace_dump_arg(ptr, context);
1588    trace_dump_arg(uint, flags);
1589 
1590    trace_dump_call_end();
1591 
1592    context->texture_barrier(context, flags);
1593 }
1594 
1595 
1596 static void
trace_context_memory_barrier(struct pipe_context * _context,unsigned flags)1597 trace_context_memory_barrier(struct pipe_context *_context,
1598                              unsigned flags)
1599 {
1600    struct trace_context *tr_context = trace_context(_context);
1601    struct pipe_context *context = tr_context->pipe;
1602 
1603    trace_dump_call_begin("pipe_context", "memory_barrier");
1604    trace_dump_arg(ptr, context);
1605    trace_dump_arg(uint, flags);
1606    trace_dump_call_end();
1607 
1608    context->memory_barrier(context, flags);
1609 }
1610 
1611 
1612 static bool
trace_context_resource_commit(struct pipe_context * _context,struct pipe_resource * resource,unsigned level,struct pipe_box * box,bool commit)1613 trace_context_resource_commit(struct pipe_context *_context,
1614                               struct pipe_resource *resource,
1615                               unsigned level, struct pipe_box *box, bool commit)
1616 {
1617    struct trace_context *tr_context = trace_context(_context);
1618    struct pipe_context *context = tr_context->pipe;
1619 
1620    trace_dump_call_begin("pipe_context", "resource_commit");
1621    trace_dump_arg(ptr, context);
1622    trace_dump_arg(ptr, resource);
1623    trace_dump_arg(uint, level);
1624    trace_dump_arg(box, box);
1625    trace_dump_arg(bool, commit);
1626    trace_dump_call_end();
1627 
1628    return context->resource_commit(context, resource, level, box, commit);
1629 }
1630 
1631 static void
trace_context_set_tess_state(struct pipe_context * _context,const float default_outer_level[4],const float default_inner_level[2])1632 trace_context_set_tess_state(struct pipe_context *_context,
1633                              const float default_outer_level[4],
1634                              const float default_inner_level[2])
1635 {
1636    struct trace_context *tr_context = trace_context(_context);
1637    struct pipe_context *context = tr_context->pipe;
1638 
1639    trace_dump_call_begin("pipe_context", "set_tess_state");
1640    trace_dump_arg(ptr, context);
1641    trace_dump_arg_array(float, default_outer_level, 4);
1642    trace_dump_arg_array(float, default_inner_level, 2);
1643    trace_dump_call_end();
1644 
1645    context->set_tess_state(context, default_outer_level, default_inner_level);
1646 }
1647 
1648 
trace_context_set_shader_buffers(struct pipe_context * _context,enum pipe_shader_type shader,unsigned start,unsigned nr,const struct pipe_shader_buffer * buffers)1649 static void trace_context_set_shader_buffers(struct pipe_context *_context,
1650                                              enum pipe_shader_type shader,
1651                                              unsigned start, unsigned nr,
1652                                              const struct pipe_shader_buffer *buffers)
1653 {
1654    struct trace_context *tr_context = trace_context(_context);
1655    struct pipe_context *context = tr_context->pipe;
1656 
1657    trace_dump_call_begin("pipe_context", "set_shader_buffers");
1658    trace_dump_arg(ptr, context);
1659    trace_dump_arg(uint, shader);
1660    trace_dump_arg(uint, start);
1661    trace_dump_arg_begin("buffers");
1662    trace_dump_struct_array(shader_buffer, buffers, nr);
1663    trace_dump_arg_end();
1664    trace_dump_call_end();
1665 
1666    context->set_shader_buffers(context, shader, start, nr, buffers);
1667 }
1668 
trace_context_set_shader_images(struct pipe_context * _context,enum pipe_shader_type shader,unsigned start,unsigned nr,const struct pipe_image_view * images)1669 static void trace_context_set_shader_images(struct pipe_context *_context,
1670                                             enum pipe_shader_type shader,
1671                                             unsigned start, unsigned nr,
1672                                             const struct pipe_image_view *images)
1673 {
1674    struct trace_context *tr_context = trace_context(_context);
1675    struct pipe_context *context = tr_context->pipe;
1676 
1677    trace_dump_call_begin("pipe_context", "set_shader_images");
1678    trace_dump_arg(ptr, context);
1679    trace_dump_arg(uint, shader);
1680    trace_dump_arg(uint, start);
1681    trace_dump_arg_begin("images");
1682    trace_dump_struct_array(image_view, images, nr);
1683    trace_dump_arg_end();
1684    trace_dump_call_end();
1685 
1686    context->set_shader_images(context, shader, start, nr, images);
1687 }
1688 
trace_context_launch_grid(struct pipe_context * _pipe,const struct pipe_grid_info * info)1689 static void trace_context_launch_grid(struct pipe_context *_pipe,
1690                                       const struct pipe_grid_info *info)
1691 {
1692    struct trace_context *tr_ctx = trace_context(_pipe);
1693    struct pipe_context *pipe = tr_ctx->pipe;
1694 
1695    trace_dump_call_begin("pipe_context", "launch_grid");
1696 
1697    trace_dump_arg(ptr,  pipe);
1698    trace_dump_arg(grid_info, info);
1699 
1700    trace_dump_trace_flush();
1701 
1702    pipe->launch_grid(pipe, info);
1703 
1704    trace_dump_call_end();
1705 }
1706 
trace_context_create_texture_handle(struct pipe_context * _pipe,struct pipe_sampler_view * view,const struct pipe_sampler_state * state)1707 static uint64_t trace_context_create_texture_handle(struct pipe_context *_pipe,
1708                                                     struct pipe_sampler_view *view,
1709                                                     const struct pipe_sampler_state *state)
1710 {
1711    struct trace_context *tr_ctx = trace_context(_pipe);
1712    struct pipe_context *pipe = tr_ctx->pipe;
1713    uint64_t handle;
1714 
1715    trace_dump_call_begin("pipe_context", "create_texture_handle");
1716    trace_dump_arg(ptr, pipe);
1717    trace_dump_arg(ptr, view);
1718    trace_dump_arg_begin("state");
1719    trace_dump_arg(sampler_state, state);
1720    trace_dump_arg_end();
1721 
1722    handle = pipe->create_texture_handle(pipe, view, state);
1723 
1724    trace_dump_ret(uint, handle);
1725    trace_dump_call_end();
1726 
1727    return handle;
1728 }
1729 
trace_context_delete_texture_handle(struct pipe_context * _pipe,uint64_t handle)1730 static void trace_context_delete_texture_handle(struct pipe_context *_pipe,
1731                                                 uint64_t handle)
1732 {
1733    struct trace_context *tr_ctx = trace_context(_pipe);
1734    struct pipe_context *pipe = tr_ctx->pipe;
1735 
1736    trace_dump_call_begin("pipe_context", "delete_texture_handle");
1737    trace_dump_arg(ptr, pipe);
1738    trace_dump_arg(uint, handle);
1739    trace_dump_call_end();
1740 
1741    pipe->delete_texture_handle(pipe, handle);
1742 }
1743 
trace_context_make_texture_handle_resident(struct pipe_context * _pipe,uint64_t handle,bool resident)1744 static void trace_context_make_texture_handle_resident(struct pipe_context *_pipe,
1745                                                        uint64_t handle,
1746                                                        bool resident)
1747 {
1748    struct trace_context *tr_ctx = trace_context(_pipe);
1749    struct pipe_context *pipe = tr_ctx->pipe;
1750 
1751    trace_dump_call_begin("pipe_context", "make_texture_handle_resident");
1752    trace_dump_arg(ptr, pipe);
1753    trace_dump_arg(uint, handle);
1754    trace_dump_arg(bool, resident);
1755    trace_dump_call_end();
1756 
1757    pipe->make_texture_handle_resident(pipe, handle, resident);
1758 }
1759 
trace_context_create_image_handle(struct pipe_context * _pipe,const struct pipe_image_view * image)1760 static uint64_t trace_context_create_image_handle(struct pipe_context *_pipe,
1761                                                   const struct pipe_image_view *image)
1762 {
1763    struct trace_context *tr_ctx = trace_context(_pipe);
1764    struct pipe_context *pipe = tr_ctx->pipe;
1765    uint64_t handle;
1766 
1767    trace_dump_call_begin("pipe_context", "create_image_handle");
1768    trace_dump_arg(ptr, pipe);
1769    trace_dump_arg_begin("image");
1770    trace_dump_image_view(image);
1771    trace_dump_arg_end();
1772 
1773    handle = pipe->create_image_handle(pipe, image);
1774 
1775    trace_dump_ret(uint, handle);
1776    trace_dump_call_end();
1777 
1778    return handle;
1779 }
1780 
trace_context_delete_image_handle(struct pipe_context * _pipe,uint64_t handle)1781 static void trace_context_delete_image_handle(struct pipe_context *_pipe,
1782                                               uint64_t handle)
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", "delete_image_handle");
1788    trace_dump_arg(ptr, pipe);
1789    trace_dump_arg(uint, handle);
1790    trace_dump_call_end();
1791 
1792    pipe->delete_image_handle(pipe, handle);
1793 }
1794 
trace_context_make_image_handle_resident(struct pipe_context * _pipe,uint64_t handle,unsigned access,bool resident)1795 static void trace_context_make_image_handle_resident(struct pipe_context *_pipe,
1796                                                     uint64_t handle,
1797                                                     unsigned access,
1798                                                     bool resident)
1799 {
1800    struct trace_context *tr_ctx = trace_context(_pipe);
1801    struct pipe_context *pipe = tr_ctx->pipe;
1802 
1803    trace_dump_call_begin("pipe_context", "make_image_handle_resident");
1804    trace_dump_arg(ptr, pipe);
1805    trace_dump_arg(uint, handle);
1806    trace_dump_arg(uint, access);
1807    trace_dump_arg(bool, resident);
1808    trace_dump_call_end();
1809 
1810    pipe->make_image_handle_resident(pipe, handle, access, resident);
1811 }
1812 
1813 struct pipe_context *
trace_context_create(struct trace_screen * tr_scr,struct pipe_context * pipe)1814 trace_context_create(struct trace_screen *tr_scr,
1815                      struct pipe_context *pipe)
1816 {
1817    struct trace_context *tr_ctx;
1818 
1819    if (!pipe)
1820       goto error1;
1821 
1822    if (!trace_enabled())
1823       goto error1;
1824 
1825    tr_ctx = CALLOC_STRUCT(trace_context);
1826    if (!tr_ctx)
1827       goto error1;
1828 
1829    tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
1830    tr_ctx->base.screen = &tr_scr->base;
1831    tr_ctx->base.stream_uploader = pipe->stream_uploader;
1832    tr_ctx->base.const_uploader = pipe->const_uploader;
1833 
1834    tr_ctx->base.destroy = trace_context_destroy;
1835 
1836 #define TR_CTX_INIT(_member) \
1837    tr_ctx->base . _member = pipe -> _member ? trace_context_ ## _member : NULL
1838 
1839    TR_CTX_INIT(draw_vbo);
1840    TR_CTX_INIT(render_condition);
1841    TR_CTX_INIT(create_query);
1842    TR_CTX_INIT(destroy_query);
1843    TR_CTX_INIT(begin_query);
1844    TR_CTX_INIT(end_query);
1845    TR_CTX_INIT(get_query_result);
1846    TR_CTX_INIT(set_active_query_state);
1847    TR_CTX_INIT(create_blend_state);
1848    TR_CTX_INIT(bind_blend_state);
1849    TR_CTX_INIT(delete_blend_state);
1850    TR_CTX_INIT(create_sampler_state);
1851    TR_CTX_INIT(bind_sampler_states);
1852    TR_CTX_INIT(delete_sampler_state);
1853    TR_CTX_INIT(create_rasterizer_state);
1854    TR_CTX_INIT(bind_rasterizer_state);
1855    TR_CTX_INIT(delete_rasterizer_state);
1856    TR_CTX_INIT(create_depth_stencil_alpha_state);
1857    TR_CTX_INIT(bind_depth_stencil_alpha_state);
1858    TR_CTX_INIT(delete_depth_stencil_alpha_state);
1859    TR_CTX_INIT(create_fs_state);
1860    TR_CTX_INIT(bind_fs_state);
1861    TR_CTX_INIT(delete_fs_state);
1862    TR_CTX_INIT(create_vs_state);
1863    TR_CTX_INIT(bind_vs_state);
1864    TR_CTX_INIT(delete_vs_state);
1865    TR_CTX_INIT(create_gs_state);
1866    TR_CTX_INIT(bind_gs_state);
1867    TR_CTX_INIT(delete_gs_state);
1868    TR_CTX_INIT(create_tcs_state);
1869    TR_CTX_INIT(bind_tcs_state);
1870    TR_CTX_INIT(delete_tcs_state);
1871    TR_CTX_INIT(create_tes_state);
1872    TR_CTX_INIT(bind_tes_state);
1873    TR_CTX_INIT(delete_tes_state);
1874    TR_CTX_INIT(create_compute_state);
1875    TR_CTX_INIT(bind_compute_state);
1876    TR_CTX_INIT(delete_compute_state);
1877    TR_CTX_INIT(create_vertex_elements_state);
1878    TR_CTX_INIT(bind_vertex_elements_state);
1879    TR_CTX_INIT(delete_vertex_elements_state);
1880    TR_CTX_INIT(set_blend_color);
1881    TR_CTX_INIT(set_stencil_ref);
1882    TR_CTX_INIT(set_clip_state);
1883    TR_CTX_INIT(set_sample_mask);
1884    TR_CTX_INIT(set_constant_buffer);
1885    TR_CTX_INIT(set_framebuffer_state);
1886    TR_CTX_INIT(set_polygon_stipple);
1887    TR_CTX_INIT(set_scissor_states);
1888    TR_CTX_INIT(set_viewport_states);
1889    TR_CTX_INIT(set_sampler_views);
1890    TR_CTX_INIT(create_sampler_view);
1891    TR_CTX_INIT(sampler_view_destroy);
1892    TR_CTX_INIT(create_surface);
1893    TR_CTX_INIT(surface_destroy);
1894    TR_CTX_INIT(set_vertex_buffers);
1895    TR_CTX_INIT(create_stream_output_target);
1896    TR_CTX_INIT(stream_output_target_destroy);
1897    TR_CTX_INIT(set_stream_output_targets);
1898    TR_CTX_INIT(resource_copy_region);
1899    TR_CTX_INIT(blit);
1900    TR_CTX_INIT(flush_resource);
1901    TR_CTX_INIT(clear);
1902    TR_CTX_INIT(clear_render_target);
1903    TR_CTX_INIT(clear_depth_stencil);
1904    TR_CTX_INIT(clear_texture);
1905    TR_CTX_INIT(flush);
1906    TR_CTX_INIT(generate_mipmap);
1907    TR_CTX_INIT(texture_barrier);
1908    TR_CTX_INIT(memory_barrier);
1909    TR_CTX_INIT(resource_commit);
1910    TR_CTX_INIT(set_tess_state);
1911    TR_CTX_INIT(set_shader_buffers);
1912    TR_CTX_INIT(launch_grid);
1913    TR_CTX_INIT(set_shader_images);
1914    TR_CTX_INIT(create_texture_handle);
1915    TR_CTX_INIT(delete_texture_handle);
1916    TR_CTX_INIT(make_texture_handle_resident);
1917    TR_CTX_INIT(create_image_handle);
1918    TR_CTX_INIT(delete_image_handle);
1919    TR_CTX_INIT(make_image_handle_resident);
1920 
1921    TR_CTX_INIT(transfer_map);
1922    TR_CTX_INIT(transfer_unmap);
1923    TR_CTX_INIT(transfer_flush_region);
1924    TR_CTX_INIT(buffer_subdata);
1925    TR_CTX_INIT(texture_subdata);
1926    TR_CTX_INIT(invalidate_resource);
1927 
1928 #undef TR_CTX_INIT
1929 
1930    tr_ctx->pipe = pipe;
1931 
1932    return &tr_ctx->base;
1933 
1934 error1:
1935    return pipe;
1936 }
1937 
1938 
1939 /**
1940  * Sanity checker: check that the given context really is a
1941  * trace context (and not the wrapped driver's context).
1942  */
1943 void
trace_context_check(const struct pipe_context * pipe)1944 trace_context_check(const struct pipe_context *pipe)
1945 {
1946    MAYBE_UNUSED struct trace_context *tr_ctx = (struct trace_context *) pipe;
1947    assert(tr_ctx->base.destroy == trace_context_destroy);
1948 }
1949