1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2008 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include "util/ralloc.h"
29bf215546Sopenharmony_ci#include "util/u_inlines.h"
30bf215546Sopenharmony_ci#include "util/u_memory.h"
31bf215546Sopenharmony_ci#include "util/u_framebuffer.h"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "pipe/p_format.h"
34bf215546Sopenharmony_ci#include "pipe/p_screen.h"
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#include "tr_dump.h"
37bf215546Sopenharmony_ci#include "tr_dump_defines.h"
38bf215546Sopenharmony_ci#include "tr_dump_state.h"
39bf215546Sopenharmony_ci#include "tr_public.h"
40bf215546Sopenharmony_ci#include "tr_screen.h"
41bf215546Sopenharmony_ci#include "tr_texture.h"
42bf215546Sopenharmony_ci#include "tr_context.h"
43bf215546Sopenharmony_ci#include "tr_util.h"
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_cistruct trace_query
47bf215546Sopenharmony_ci{
48bf215546Sopenharmony_ci   struct threaded_query base;
49bf215546Sopenharmony_ci   unsigned type;
50bf215546Sopenharmony_ci   unsigned index;
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci   struct pipe_query *query;
53bf215546Sopenharmony_ci};
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_cistatic inline struct trace_query *
57bf215546Sopenharmony_citrace_query(struct pipe_query *query)
58bf215546Sopenharmony_ci{
59bf215546Sopenharmony_ci   return (struct trace_query *)query;
60bf215546Sopenharmony_ci}
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_cistatic inline struct pipe_query *
64bf215546Sopenharmony_citrace_query_unwrap(struct pipe_query *query)
65bf215546Sopenharmony_ci{
66bf215546Sopenharmony_ci   if (query) {
67bf215546Sopenharmony_ci      return trace_query(query)->query;
68bf215546Sopenharmony_ci   } else {
69bf215546Sopenharmony_ci      return NULL;
70bf215546Sopenharmony_ci   }
71bf215546Sopenharmony_ci}
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_cistatic inline struct pipe_surface *
75bf215546Sopenharmony_citrace_surface_unwrap(struct trace_context *tr_ctx,
76bf215546Sopenharmony_ci                     struct pipe_surface *surface)
77bf215546Sopenharmony_ci{
78bf215546Sopenharmony_ci   struct trace_surface *tr_surf;
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci   if (!surface)
81bf215546Sopenharmony_ci      return NULL;
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci   assert(surface->texture);
84bf215546Sopenharmony_ci   if (!surface->texture)
85bf215546Sopenharmony_ci      return surface;
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci   tr_surf = trace_surface(surface);
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci   assert(tr_surf->surface);
90bf215546Sopenharmony_ci   return tr_surf->surface;
91bf215546Sopenharmony_ci}
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_cistatic void
94bf215546Sopenharmony_cidump_fb_state(struct trace_context *tr_ctx,
95bf215546Sopenharmony_ci              const char *method,
96bf215546Sopenharmony_ci              bool deep)
97bf215546Sopenharmony_ci{
98bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
99bf215546Sopenharmony_ci   struct pipe_framebuffer_state *state = &tr_ctx->unwrapped_state;
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", method);
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
104bf215546Sopenharmony_ci   if (deep)
105bf215546Sopenharmony_ci      trace_dump_arg(framebuffer_state_deep, state);
106bf215546Sopenharmony_ci   else
107bf215546Sopenharmony_ci      trace_dump_arg(framebuffer_state, state);
108bf215546Sopenharmony_ci   trace_dump_call_end();
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   tr_ctx->seen_fb_state = true;
111bf215546Sopenharmony_ci}
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_cistatic void
114bf215546Sopenharmony_citrace_context_draw_vbo(struct pipe_context *_pipe,
115bf215546Sopenharmony_ci                       const struct pipe_draw_info *info,
116bf215546Sopenharmony_ci                       unsigned drawid_offset,
117bf215546Sopenharmony_ci                       const struct pipe_draw_indirect_info *indirect,
118bf215546Sopenharmony_ci                       const struct pipe_draw_start_count_bias *draws,
119bf215546Sopenharmony_ci                       unsigned num_draws)
120bf215546Sopenharmony_ci{
121bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
122bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci   if (!tr_ctx->seen_fb_state && trace_dump_is_triggered())
125bf215546Sopenharmony_ci      dump_fb_state(tr_ctx, "current_framebuffer_state", true);
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "draw_vbo");
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   trace_dump_arg(ptr,  pipe);
130bf215546Sopenharmony_ci   trace_dump_arg(draw_info, info);
131bf215546Sopenharmony_ci   trace_dump_arg(int, drawid_offset);
132bf215546Sopenharmony_ci   trace_dump_arg(draw_indirect_info, indirect);
133bf215546Sopenharmony_ci   trace_dump_arg_begin("draws");
134bf215546Sopenharmony_ci   trace_dump_struct_array(draw_start_count, draws, num_draws);
135bf215546Sopenharmony_ci   trace_dump_arg_end();
136bf215546Sopenharmony_ci   trace_dump_arg(uint, num_draws);
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ci   trace_dump_trace_flush();
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ci   pipe->draw_vbo(pipe, info, drawid_offset, indirect, draws, num_draws);
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci   trace_dump_call_end();
143bf215546Sopenharmony_ci}
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci
146bf215546Sopenharmony_cistatic void
147bf215546Sopenharmony_citrace_context_draw_vertex_state(struct pipe_context *_pipe,
148bf215546Sopenharmony_ci                                struct pipe_vertex_state *state,
149bf215546Sopenharmony_ci                                uint32_t partial_velem_mask,
150bf215546Sopenharmony_ci                                struct pipe_draw_vertex_state_info info,
151bf215546Sopenharmony_ci                                const struct pipe_draw_start_count_bias *draws,
152bf215546Sopenharmony_ci                                unsigned num_draws)
153bf215546Sopenharmony_ci{
154bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
155bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ci   if (!tr_ctx->seen_fb_state && trace_dump_is_triggered())
158bf215546Sopenharmony_ci      dump_fb_state(tr_ctx, "current_framebuffer_state", true);
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "draw_vertex_state");
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
163bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
164bf215546Sopenharmony_ci   trace_dump_arg(uint, partial_velem_mask);
165bf215546Sopenharmony_ci   trace_dump_arg(draw_vertex_state_info, info);
166bf215546Sopenharmony_ci   trace_dump_arg_begin("draws");
167bf215546Sopenharmony_ci   trace_dump_struct_array(draw_start_count, draws, num_draws);
168bf215546Sopenharmony_ci   trace_dump_arg_end();
169bf215546Sopenharmony_ci   trace_dump_arg(uint, num_draws);
170bf215546Sopenharmony_ci
171bf215546Sopenharmony_ci   trace_dump_trace_flush();
172bf215546Sopenharmony_ci
173bf215546Sopenharmony_ci   pipe->draw_vertex_state(pipe, state, partial_velem_mask, info, draws,
174bf215546Sopenharmony_ci                           num_draws);
175bf215546Sopenharmony_ci   trace_dump_call_end();
176bf215546Sopenharmony_ci}
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_cistatic struct pipe_query *
180bf215546Sopenharmony_citrace_context_create_query(struct pipe_context *_pipe,
181bf215546Sopenharmony_ci                           unsigned query_type,
182bf215546Sopenharmony_ci                           unsigned index)
183bf215546Sopenharmony_ci{
184bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
185bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
186bf215546Sopenharmony_ci   struct pipe_query *query;
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_query");
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
191bf215546Sopenharmony_ci   trace_dump_arg(query_type, query_type);
192bf215546Sopenharmony_ci   trace_dump_arg(int, index);
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci   query = pipe->create_query(pipe, query_type, index);
195bf215546Sopenharmony_ci
196bf215546Sopenharmony_ci   trace_dump_ret(ptr, query);
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_ci   trace_dump_call_end();
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ci   /* Wrap query object. */
201bf215546Sopenharmony_ci   if (query) {
202bf215546Sopenharmony_ci      struct trace_query *tr_query = CALLOC_STRUCT(trace_query);
203bf215546Sopenharmony_ci      if (tr_query) {
204bf215546Sopenharmony_ci         tr_query->type = query_type;
205bf215546Sopenharmony_ci         tr_query->query = query;
206bf215546Sopenharmony_ci         tr_query->index = index;
207bf215546Sopenharmony_ci         query = (struct pipe_query *)tr_query;
208bf215546Sopenharmony_ci      } else {
209bf215546Sopenharmony_ci         pipe->destroy_query(pipe, query);
210bf215546Sopenharmony_ci         query = NULL;
211bf215546Sopenharmony_ci      }
212bf215546Sopenharmony_ci   }
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci   return query;
215bf215546Sopenharmony_ci}
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_cistatic void
219bf215546Sopenharmony_citrace_context_destroy_query(struct pipe_context *_pipe,
220bf215546Sopenharmony_ci                            struct pipe_query *_query)
221bf215546Sopenharmony_ci{
222bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
223bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
224bf215546Sopenharmony_ci   struct trace_query *tr_query = trace_query(_query);
225bf215546Sopenharmony_ci   struct pipe_query *query = tr_query->query;
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ci   FREE(tr_query);
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "destroy_query");
230bf215546Sopenharmony_ci
231bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
232bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_ci   pipe->destroy_query(pipe, query);
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci   trace_dump_call_end();
237bf215546Sopenharmony_ci}
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_cistatic bool
241bf215546Sopenharmony_citrace_context_begin_query(struct pipe_context *_pipe,
242bf215546Sopenharmony_ci                          struct pipe_query *query)
243bf215546Sopenharmony_ci{
244bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
245bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
246bf215546Sopenharmony_ci   bool ret;
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   query = trace_query_unwrap(query);
249bf215546Sopenharmony_ci
250bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "begin_query");
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
253bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci   ret = pipe->begin_query(pipe, query);
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_ci   trace_dump_call_end();
258bf215546Sopenharmony_ci   return ret;
259bf215546Sopenharmony_ci}
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_cistatic bool
263bf215546Sopenharmony_citrace_context_end_query(struct pipe_context *_pipe,
264bf215546Sopenharmony_ci                        struct pipe_query *_query)
265bf215546Sopenharmony_ci{
266bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
267bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
268bf215546Sopenharmony_ci   bool ret;
269bf215546Sopenharmony_ci
270bf215546Sopenharmony_ci   struct pipe_query *query = trace_query_unwrap(_query);
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "end_query");
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
275bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_ci   if (tr_ctx->threaded)
278bf215546Sopenharmony_ci      threaded_query(query)->flushed = trace_query(_query)->base.flushed;
279bf215546Sopenharmony_ci   ret = pipe->end_query(pipe, query);
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci   trace_dump_call_end();
282bf215546Sopenharmony_ci   return ret;
283bf215546Sopenharmony_ci}
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_cistatic bool
287bf215546Sopenharmony_citrace_context_get_query_result(struct pipe_context *_pipe,
288bf215546Sopenharmony_ci                               struct pipe_query *_query,
289bf215546Sopenharmony_ci                               bool wait,
290bf215546Sopenharmony_ci                               union pipe_query_result *result)
291bf215546Sopenharmony_ci{
292bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
293bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
294bf215546Sopenharmony_ci   struct trace_query *tr_query = trace_query(_query);
295bf215546Sopenharmony_ci   struct pipe_query *query = tr_query->query;
296bf215546Sopenharmony_ci   bool ret;
297bf215546Sopenharmony_ci
298bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "get_query_result");
299bf215546Sopenharmony_ci
300bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
301bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
302bf215546Sopenharmony_ci   trace_dump_arg(bool, wait);
303bf215546Sopenharmony_ci
304bf215546Sopenharmony_ci   if (tr_ctx->threaded)
305bf215546Sopenharmony_ci      threaded_query(query)->flushed = trace_query(_query)->base.flushed;
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci   ret = pipe->get_query_result(pipe, query, wait, result);
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci   trace_dump_arg_begin("result");
310bf215546Sopenharmony_ci   if (ret) {
311bf215546Sopenharmony_ci      trace_dump_query_result(tr_query->type, tr_query->index, result);
312bf215546Sopenharmony_ci   } else {
313bf215546Sopenharmony_ci      trace_dump_null();
314bf215546Sopenharmony_ci   }
315bf215546Sopenharmony_ci   trace_dump_arg_end();
316bf215546Sopenharmony_ci
317bf215546Sopenharmony_ci   trace_dump_ret(bool, ret);
318bf215546Sopenharmony_ci
319bf215546Sopenharmony_ci   trace_dump_call_end();
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ci   return ret;
322bf215546Sopenharmony_ci}
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_cistatic void
325bf215546Sopenharmony_citrace_context_get_query_result_resource(struct pipe_context *_pipe,
326bf215546Sopenharmony_ci                                        struct pipe_query *_query,
327bf215546Sopenharmony_ci                                        enum pipe_query_flags flags,
328bf215546Sopenharmony_ci                                        enum pipe_query_value_type result_type,
329bf215546Sopenharmony_ci                                        int index,
330bf215546Sopenharmony_ci                                        struct pipe_resource *resource,
331bf215546Sopenharmony_ci                                        unsigned offset)
332bf215546Sopenharmony_ci{
333bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
334bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
335bf215546Sopenharmony_ci   struct trace_query *tr_query = trace_query(_query);
336bf215546Sopenharmony_ci   struct pipe_query *query = tr_query->query;
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "get_query_result_resource");
339bf215546Sopenharmony_ci
340bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
341bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
342bf215546Sopenharmony_ci   trace_dump_arg(query_flags, flags);
343bf215546Sopenharmony_ci   trace_dump_arg(uint, result_type);
344bf215546Sopenharmony_ci   trace_dump_arg(uint, index);
345bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
346bf215546Sopenharmony_ci   trace_dump_arg(uint, offset);
347bf215546Sopenharmony_ci
348bf215546Sopenharmony_ci   if (tr_ctx->threaded)
349bf215546Sopenharmony_ci      threaded_query(query)->flushed = tr_query->base.flushed;
350bf215546Sopenharmony_ci
351bf215546Sopenharmony_ci   trace_dump_call_end();
352bf215546Sopenharmony_ci
353bf215546Sopenharmony_ci   pipe->get_query_result_resource(pipe, query, flags, result_type, index, resource, offset);
354bf215546Sopenharmony_ci}
355bf215546Sopenharmony_ci
356bf215546Sopenharmony_ci
357bf215546Sopenharmony_cistatic void
358bf215546Sopenharmony_citrace_context_set_active_query_state(struct pipe_context *_pipe,
359bf215546Sopenharmony_ci                                     bool enable)
360bf215546Sopenharmony_ci{
361bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
362bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_active_query_state");
365bf215546Sopenharmony_ci
366bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
367bf215546Sopenharmony_ci   trace_dump_arg(bool, enable);
368bf215546Sopenharmony_ci
369bf215546Sopenharmony_ci   pipe->set_active_query_state(pipe, enable);
370bf215546Sopenharmony_ci
371bf215546Sopenharmony_ci   trace_dump_call_end();
372bf215546Sopenharmony_ci}
373bf215546Sopenharmony_ci
374bf215546Sopenharmony_ci
375bf215546Sopenharmony_cistatic void *
376bf215546Sopenharmony_citrace_context_create_blend_state(struct pipe_context *_pipe,
377bf215546Sopenharmony_ci                                 const struct pipe_blend_state *state)
378bf215546Sopenharmony_ci{
379bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
380bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
381bf215546Sopenharmony_ci   void * result;
382bf215546Sopenharmony_ci
383bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_blend_state");
384bf215546Sopenharmony_ci
385bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
386bf215546Sopenharmony_ci   trace_dump_arg(blend_state, state);
387bf215546Sopenharmony_ci
388bf215546Sopenharmony_ci   result = pipe->create_blend_state(pipe, state);
389bf215546Sopenharmony_ci
390bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
391bf215546Sopenharmony_ci
392bf215546Sopenharmony_ci   trace_dump_call_end();
393bf215546Sopenharmony_ci
394bf215546Sopenharmony_ci   struct pipe_blend_state *blend = ralloc(tr_ctx, struct pipe_blend_state);
395bf215546Sopenharmony_ci   if (blend) {
396bf215546Sopenharmony_ci      memcpy(blend, state, sizeof(struct pipe_blend_state));
397bf215546Sopenharmony_ci      _mesa_hash_table_insert(&tr_ctx->blend_states, result, blend);
398bf215546Sopenharmony_ci   }
399bf215546Sopenharmony_ci
400bf215546Sopenharmony_ci   return result;
401bf215546Sopenharmony_ci}
402bf215546Sopenharmony_ci
403bf215546Sopenharmony_ci
404bf215546Sopenharmony_cistatic void
405bf215546Sopenharmony_citrace_context_bind_blend_state(struct pipe_context *_pipe,
406bf215546Sopenharmony_ci                               void *state)
407bf215546Sopenharmony_ci{
408bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
409bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_blend_state");
412bf215546Sopenharmony_ci
413bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
414bf215546Sopenharmony_ci   if (state && trace_dump_is_triggered()) {
415bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->blend_states, state);
416bf215546Sopenharmony_ci      if (he)
417bf215546Sopenharmony_ci         trace_dump_arg(blend_state, he->data);
418bf215546Sopenharmony_ci      else
419bf215546Sopenharmony_ci         trace_dump_arg(blend_state, NULL);
420bf215546Sopenharmony_ci   } else
421bf215546Sopenharmony_ci      trace_dump_arg(ptr, state);
422bf215546Sopenharmony_ci
423bf215546Sopenharmony_ci   pipe->bind_blend_state(pipe, state);
424bf215546Sopenharmony_ci
425bf215546Sopenharmony_ci   trace_dump_call_end();
426bf215546Sopenharmony_ci}
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_ci
429bf215546Sopenharmony_cistatic void
430bf215546Sopenharmony_citrace_context_delete_blend_state(struct pipe_context *_pipe,
431bf215546Sopenharmony_ci                                 void *state)
432bf215546Sopenharmony_ci{
433bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
434bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
435bf215546Sopenharmony_ci
436bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_blend_state");
437bf215546Sopenharmony_ci
438bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
439bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
440bf215546Sopenharmony_ci
441bf215546Sopenharmony_ci   pipe->delete_blend_state(pipe, state);
442bf215546Sopenharmony_ci
443bf215546Sopenharmony_ci   if (state) {
444bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->blend_states, state);
445bf215546Sopenharmony_ci      if (he) {
446bf215546Sopenharmony_ci         ralloc_free(he->data);
447bf215546Sopenharmony_ci         _mesa_hash_table_remove(&tr_ctx->blend_states, he);
448bf215546Sopenharmony_ci      }
449bf215546Sopenharmony_ci   }
450bf215546Sopenharmony_ci
451bf215546Sopenharmony_ci   trace_dump_call_end();
452bf215546Sopenharmony_ci}
453bf215546Sopenharmony_ci
454bf215546Sopenharmony_ci
455bf215546Sopenharmony_cistatic void *
456bf215546Sopenharmony_citrace_context_create_sampler_state(struct pipe_context *_pipe,
457bf215546Sopenharmony_ci                                   const struct pipe_sampler_state *state)
458bf215546Sopenharmony_ci{
459bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
460bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
461bf215546Sopenharmony_ci   void * result;
462bf215546Sopenharmony_ci
463bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_sampler_state");
464bf215546Sopenharmony_ci
465bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
466bf215546Sopenharmony_ci   trace_dump_arg(sampler_state, state);
467bf215546Sopenharmony_ci
468bf215546Sopenharmony_ci   result = pipe->create_sampler_state(pipe, state);
469bf215546Sopenharmony_ci
470bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
471bf215546Sopenharmony_ci
472bf215546Sopenharmony_ci   trace_dump_call_end();
473bf215546Sopenharmony_ci
474bf215546Sopenharmony_ci   return result;
475bf215546Sopenharmony_ci}
476bf215546Sopenharmony_ci
477bf215546Sopenharmony_ci
478bf215546Sopenharmony_cistatic void
479bf215546Sopenharmony_citrace_context_bind_sampler_states(struct pipe_context *_pipe,
480bf215546Sopenharmony_ci                                  enum pipe_shader_type shader,
481bf215546Sopenharmony_ci                                  unsigned start,
482bf215546Sopenharmony_ci                                  unsigned num_states,
483bf215546Sopenharmony_ci                                  void **states)
484bf215546Sopenharmony_ci{
485bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
486bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
487bf215546Sopenharmony_ci
488bf215546Sopenharmony_ci   /* remove this when we have pipe->bind_sampler_states(..., start, ...) */
489bf215546Sopenharmony_ci   assert(start == 0);
490bf215546Sopenharmony_ci
491bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_sampler_states");
492bf215546Sopenharmony_ci
493bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
494bf215546Sopenharmony_ci   trace_dump_arg_enum(shader, tr_util_pipe_shader_type_name(shader));
495bf215546Sopenharmony_ci   trace_dump_arg(uint, start);
496bf215546Sopenharmony_ci   trace_dump_arg(uint, num_states);
497bf215546Sopenharmony_ci   trace_dump_arg_array(ptr, states, num_states);
498bf215546Sopenharmony_ci
499bf215546Sopenharmony_ci   pipe->bind_sampler_states(pipe, shader, start, num_states, states);
500bf215546Sopenharmony_ci
501bf215546Sopenharmony_ci   trace_dump_call_end();
502bf215546Sopenharmony_ci}
503bf215546Sopenharmony_ci
504bf215546Sopenharmony_ci
505bf215546Sopenharmony_cistatic void
506bf215546Sopenharmony_citrace_context_delete_sampler_state(struct pipe_context *_pipe,
507bf215546Sopenharmony_ci                                   void *state)
508bf215546Sopenharmony_ci{
509bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
510bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
511bf215546Sopenharmony_ci
512bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_sampler_state");
513bf215546Sopenharmony_ci
514bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
515bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
516bf215546Sopenharmony_ci
517bf215546Sopenharmony_ci   pipe->delete_sampler_state(pipe, state);
518bf215546Sopenharmony_ci
519bf215546Sopenharmony_ci   trace_dump_call_end();
520bf215546Sopenharmony_ci}
521bf215546Sopenharmony_ci
522bf215546Sopenharmony_ci
523bf215546Sopenharmony_cistatic void *
524bf215546Sopenharmony_citrace_context_create_rasterizer_state(struct pipe_context *_pipe,
525bf215546Sopenharmony_ci                                      const struct pipe_rasterizer_state *state)
526bf215546Sopenharmony_ci{
527bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
528bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
529bf215546Sopenharmony_ci   void * result;
530bf215546Sopenharmony_ci
531bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_rasterizer_state");
532bf215546Sopenharmony_ci
533bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
534bf215546Sopenharmony_ci   trace_dump_arg(rasterizer_state, state);
535bf215546Sopenharmony_ci
536bf215546Sopenharmony_ci   result = pipe->create_rasterizer_state(pipe, state);
537bf215546Sopenharmony_ci
538bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
539bf215546Sopenharmony_ci
540bf215546Sopenharmony_ci   trace_dump_call_end();
541bf215546Sopenharmony_ci
542bf215546Sopenharmony_ci   struct pipe_rasterizer_state *rasterizer = ralloc(tr_ctx, struct pipe_rasterizer_state);
543bf215546Sopenharmony_ci   if (rasterizer) {
544bf215546Sopenharmony_ci      memcpy(rasterizer, state, sizeof(struct pipe_rasterizer_state));
545bf215546Sopenharmony_ci      _mesa_hash_table_insert(&tr_ctx->rasterizer_states, result, rasterizer);
546bf215546Sopenharmony_ci   }
547bf215546Sopenharmony_ci
548bf215546Sopenharmony_ci   return result;
549bf215546Sopenharmony_ci}
550bf215546Sopenharmony_ci
551bf215546Sopenharmony_ci
552bf215546Sopenharmony_cistatic void
553bf215546Sopenharmony_citrace_context_bind_rasterizer_state(struct pipe_context *_pipe,
554bf215546Sopenharmony_ci                                    void *state)
555bf215546Sopenharmony_ci{
556bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
557bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
558bf215546Sopenharmony_ci
559bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
560bf215546Sopenharmony_ci
561bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
562bf215546Sopenharmony_ci   if (state && trace_dump_is_triggered()) {
563bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->rasterizer_states, state);
564bf215546Sopenharmony_ci      if (he)
565bf215546Sopenharmony_ci         trace_dump_arg(rasterizer_state, he->data);
566bf215546Sopenharmony_ci      else
567bf215546Sopenharmony_ci         trace_dump_arg(rasterizer_state, NULL);
568bf215546Sopenharmony_ci   } else
569bf215546Sopenharmony_ci      trace_dump_arg(ptr, state);
570bf215546Sopenharmony_ci
571bf215546Sopenharmony_ci   pipe->bind_rasterizer_state(pipe, state);
572bf215546Sopenharmony_ci
573bf215546Sopenharmony_ci   trace_dump_call_end();
574bf215546Sopenharmony_ci}
575bf215546Sopenharmony_ci
576bf215546Sopenharmony_ci
577bf215546Sopenharmony_cistatic void
578bf215546Sopenharmony_citrace_context_delete_rasterizer_state(struct pipe_context *_pipe,
579bf215546Sopenharmony_ci                                      void *state)
580bf215546Sopenharmony_ci{
581bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
582bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
583bf215546Sopenharmony_ci
584bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
585bf215546Sopenharmony_ci
586bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
587bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
588bf215546Sopenharmony_ci
589bf215546Sopenharmony_ci   pipe->delete_rasterizer_state(pipe, state);
590bf215546Sopenharmony_ci
591bf215546Sopenharmony_ci   trace_dump_call_end();
592bf215546Sopenharmony_ci
593bf215546Sopenharmony_ci   if (state) {
594bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->rasterizer_states, state);
595bf215546Sopenharmony_ci      if (he) {
596bf215546Sopenharmony_ci         ralloc_free(he->data);
597bf215546Sopenharmony_ci         _mesa_hash_table_remove(&tr_ctx->rasterizer_states, he);
598bf215546Sopenharmony_ci      }
599bf215546Sopenharmony_ci   }
600bf215546Sopenharmony_ci}
601bf215546Sopenharmony_ci
602bf215546Sopenharmony_ci
603bf215546Sopenharmony_cistatic void *
604bf215546Sopenharmony_citrace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
605bf215546Sopenharmony_ci                                               const struct pipe_depth_stencil_alpha_state *state)
606bf215546Sopenharmony_ci{
607bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
608bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
609bf215546Sopenharmony_ci   void * result;
610bf215546Sopenharmony_ci
611bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
612bf215546Sopenharmony_ci
613bf215546Sopenharmony_ci   result = pipe->create_depth_stencil_alpha_state(pipe, state);
614bf215546Sopenharmony_ci
615bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
616bf215546Sopenharmony_ci   trace_dump_arg(depth_stencil_alpha_state, state);
617bf215546Sopenharmony_ci
618bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
619bf215546Sopenharmony_ci
620bf215546Sopenharmony_ci   trace_dump_call_end();
621bf215546Sopenharmony_ci
622bf215546Sopenharmony_ci   struct pipe_depth_stencil_alpha_state *depth_stencil_alpha = ralloc(tr_ctx, struct pipe_depth_stencil_alpha_state);
623bf215546Sopenharmony_ci   if (depth_stencil_alpha) {
624bf215546Sopenharmony_ci      memcpy(depth_stencil_alpha, state, sizeof(struct pipe_depth_stencil_alpha_state));
625bf215546Sopenharmony_ci      _mesa_hash_table_insert(&tr_ctx->depth_stencil_alpha_states, result, depth_stencil_alpha);
626bf215546Sopenharmony_ci   }
627bf215546Sopenharmony_ci
628bf215546Sopenharmony_ci   return result;
629bf215546Sopenharmony_ci}
630bf215546Sopenharmony_ci
631bf215546Sopenharmony_ci
632bf215546Sopenharmony_cistatic void
633bf215546Sopenharmony_citrace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
634bf215546Sopenharmony_ci                                             void *state)
635bf215546Sopenharmony_ci{
636bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
637bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
638bf215546Sopenharmony_ci
639bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
640bf215546Sopenharmony_ci
641bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
642bf215546Sopenharmony_ci   if (state && trace_dump_is_triggered()) {
643bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->depth_stencil_alpha_states, state);
644bf215546Sopenharmony_ci      if (he)
645bf215546Sopenharmony_ci         trace_dump_arg(depth_stencil_alpha_state, he->data);
646bf215546Sopenharmony_ci      else
647bf215546Sopenharmony_ci         trace_dump_arg(depth_stencil_alpha_state, NULL);
648bf215546Sopenharmony_ci   } else
649bf215546Sopenharmony_ci      trace_dump_arg(ptr, state);
650bf215546Sopenharmony_ci
651bf215546Sopenharmony_ci   pipe->bind_depth_stencil_alpha_state(pipe, state);
652bf215546Sopenharmony_ci
653bf215546Sopenharmony_ci   trace_dump_call_end();
654bf215546Sopenharmony_ci}
655bf215546Sopenharmony_ci
656bf215546Sopenharmony_ci
657bf215546Sopenharmony_cistatic void
658bf215546Sopenharmony_citrace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
659bf215546Sopenharmony_ci                                               void *state)
660bf215546Sopenharmony_ci{
661bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
662bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
663bf215546Sopenharmony_ci
664bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
665bf215546Sopenharmony_ci
666bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
667bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
668bf215546Sopenharmony_ci
669bf215546Sopenharmony_ci   pipe->delete_depth_stencil_alpha_state(pipe, state);
670bf215546Sopenharmony_ci
671bf215546Sopenharmony_ci   trace_dump_call_end();
672bf215546Sopenharmony_ci
673bf215546Sopenharmony_ci   if (state) {
674bf215546Sopenharmony_ci      struct hash_entry *he = _mesa_hash_table_search(&tr_ctx->depth_stencil_alpha_states, state);
675bf215546Sopenharmony_ci      if (he) {
676bf215546Sopenharmony_ci         ralloc_free(he->data);
677bf215546Sopenharmony_ci         _mesa_hash_table_remove(&tr_ctx->depth_stencil_alpha_states, he);
678bf215546Sopenharmony_ci      }
679bf215546Sopenharmony_ci   }
680bf215546Sopenharmony_ci}
681bf215546Sopenharmony_ci
682bf215546Sopenharmony_ci
683bf215546Sopenharmony_ci#define TRACE_SHADER_STATE(shader_type) \
684bf215546Sopenharmony_ci   static void * \
685bf215546Sopenharmony_ci   trace_context_create_##shader_type##_state(struct pipe_context *_pipe, \
686bf215546Sopenharmony_ci                                 const struct pipe_shader_state *state) \
687bf215546Sopenharmony_ci   { \
688bf215546Sopenharmony_ci      struct trace_context *tr_ctx = trace_context(_pipe); \
689bf215546Sopenharmony_ci      struct pipe_context *pipe = tr_ctx->pipe; \
690bf215546Sopenharmony_ci      void * result; \
691bf215546Sopenharmony_ci      trace_dump_call_begin("pipe_context", "create_" #shader_type "_state"); \
692bf215546Sopenharmony_ci      trace_dump_arg(ptr, pipe); \
693bf215546Sopenharmony_ci      trace_dump_arg(shader_state, state); \
694bf215546Sopenharmony_ci      result = pipe->create_##shader_type##_state(pipe, state); \
695bf215546Sopenharmony_ci      trace_dump_ret(ptr, result); \
696bf215546Sopenharmony_ci      trace_dump_call_end(); \
697bf215546Sopenharmony_ci      return result; \
698bf215546Sopenharmony_ci   } \
699bf215546Sopenharmony_ci    \
700bf215546Sopenharmony_ci   static void \
701bf215546Sopenharmony_ci   trace_context_bind_##shader_type##_state(struct pipe_context *_pipe, \
702bf215546Sopenharmony_ci                               void *state) \
703bf215546Sopenharmony_ci   { \
704bf215546Sopenharmony_ci      struct trace_context *tr_ctx = trace_context(_pipe); \
705bf215546Sopenharmony_ci      struct pipe_context *pipe = tr_ctx->pipe; \
706bf215546Sopenharmony_ci      trace_dump_call_begin("pipe_context", "bind_" #shader_type "_state"); \
707bf215546Sopenharmony_ci      trace_dump_arg(ptr, pipe); \
708bf215546Sopenharmony_ci      trace_dump_arg(ptr, state); \
709bf215546Sopenharmony_ci      pipe->bind_##shader_type##_state(pipe, state); \
710bf215546Sopenharmony_ci      trace_dump_call_end(); \
711bf215546Sopenharmony_ci   } \
712bf215546Sopenharmony_ci    \
713bf215546Sopenharmony_ci   static void \
714bf215546Sopenharmony_ci   trace_context_delete_##shader_type##_state(struct pipe_context *_pipe, \
715bf215546Sopenharmony_ci                                 void *state) \
716bf215546Sopenharmony_ci   { \
717bf215546Sopenharmony_ci      struct trace_context *tr_ctx = trace_context(_pipe); \
718bf215546Sopenharmony_ci      struct pipe_context *pipe = tr_ctx->pipe; \
719bf215546Sopenharmony_ci      trace_dump_call_begin("pipe_context", "delete_" #shader_type "_state"); \
720bf215546Sopenharmony_ci      trace_dump_arg(ptr, pipe); \
721bf215546Sopenharmony_ci      trace_dump_arg(ptr, state); \
722bf215546Sopenharmony_ci      pipe->delete_##shader_type##_state(pipe, state); \
723bf215546Sopenharmony_ci      trace_dump_call_end(); \
724bf215546Sopenharmony_ci   }
725bf215546Sopenharmony_ci
726bf215546Sopenharmony_ciTRACE_SHADER_STATE(fs)
727bf215546Sopenharmony_ciTRACE_SHADER_STATE(vs)
728bf215546Sopenharmony_ciTRACE_SHADER_STATE(gs)
729bf215546Sopenharmony_ciTRACE_SHADER_STATE(tcs)
730bf215546Sopenharmony_ciTRACE_SHADER_STATE(tes)
731bf215546Sopenharmony_ci
732bf215546Sopenharmony_ci#undef TRACE_SHADER_STATE
733bf215546Sopenharmony_ci
734bf215546Sopenharmony_cistatic void
735bf215546Sopenharmony_citrace_context_link_shader(struct pipe_context *_pipe, void **shaders)
736bf215546Sopenharmony_ci{
737bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
738bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
739bf215546Sopenharmony_ci
740bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "link_shader");
741bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
742bf215546Sopenharmony_ci   trace_dump_arg_array(ptr, shaders, PIPE_SHADER_TYPES);
743bf215546Sopenharmony_ci   pipe->link_shader(pipe, shaders);
744bf215546Sopenharmony_ci   trace_dump_call_end();
745bf215546Sopenharmony_ci}
746bf215546Sopenharmony_ci
747bf215546Sopenharmony_cistatic inline void *
748bf215546Sopenharmony_citrace_context_create_compute_state(struct pipe_context *_pipe,
749bf215546Sopenharmony_ci                                   const struct pipe_compute_state *state)
750bf215546Sopenharmony_ci{
751bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
752bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
753bf215546Sopenharmony_ci   void * result;
754bf215546Sopenharmony_ci
755bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_compute_state");
756bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
757bf215546Sopenharmony_ci   trace_dump_arg(compute_state, state);
758bf215546Sopenharmony_ci   result = pipe->create_compute_state(pipe, state);
759bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
760bf215546Sopenharmony_ci   trace_dump_call_end();
761bf215546Sopenharmony_ci   return result;
762bf215546Sopenharmony_ci}
763bf215546Sopenharmony_ci
764bf215546Sopenharmony_cistatic inline void
765bf215546Sopenharmony_citrace_context_bind_compute_state(struct pipe_context *_pipe,
766bf215546Sopenharmony_ci                                 void *state)
767bf215546Sopenharmony_ci{
768bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
769bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
770bf215546Sopenharmony_ci
771bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_compute_state");
772bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
773bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
774bf215546Sopenharmony_ci   pipe->bind_compute_state(pipe, state);
775bf215546Sopenharmony_ci   trace_dump_call_end();
776bf215546Sopenharmony_ci}
777bf215546Sopenharmony_ci
778bf215546Sopenharmony_cistatic inline void
779bf215546Sopenharmony_citrace_context_delete_compute_state(struct pipe_context *_pipe,
780bf215546Sopenharmony_ci                                   void *state)
781bf215546Sopenharmony_ci{
782bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
783bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
784bf215546Sopenharmony_ci
785bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_compute_state");
786bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
787bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
788bf215546Sopenharmony_ci   pipe->delete_compute_state(pipe, state);
789bf215546Sopenharmony_ci   trace_dump_call_end();
790bf215546Sopenharmony_ci}
791bf215546Sopenharmony_ci
792bf215546Sopenharmony_cistatic void *
793bf215546Sopenharmony_citrace_context_create_vertex_elements_state(struct pipe_context *_pipe,
794bf215546Sopenharmony_ci                                           unsigned num_elements,
795bf215546Sopenharmony_ci                                           const struct  pipe_vertex_element *elements)
796bf215546Sopenharmony_ci{
797bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
798bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
799bf215546Sopenharmony_ci   void * result;
800bf215546Sopenharmony_ci
801bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_vertex_elements_state");
802bf215546Sopenharmony_ci
803bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
804bf215546Sopenharmony_ci   trace_dump_arg(uint, num_elements);
805bf215546Sopenharmony_ci
806bf215546Sopenharmony_ci   trace_dump_arg_begin("elements");
807bf215546Sopenharmony_ci   trace_dump_struct_array(vertex_element, elements, num_elements);
808bf215546Sopenharmony_ci   trace_dump_arg_end();
809bf215546Sopenharmony_ci
810bf215546Sopenharmony_ci   result = pipe->create_vertex_elements_state(pipe, num_elements, elements);
811bf215546Sopenharmony_ci
812bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
813bf215546Sopenharmony_ci
814bf215546Sopenharmony_ci   trace_dump_call_end();
815bf215546Sopenharmony_ci
816bf215546Sopenharmony_ci   return result;
817bf215546Sopenharmony_ci}
818bf215546Sopenharmony_ci
819bf215546Sopenharmony_ci
820bf215546Sopenharmony_cistatic void
821bf215546Sopenharmony_citrace_context_bind_vertex_elements_state(struct pipe_context *_pipe,
822bf215546Sopenharmony_ci                                         void *state)
823bf215546Sopenharmony_ci{
824bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
825bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
826bf215546Sopenharmony_ci
827bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "bind_vertex_elements_state");
828bf215546Sopenharmony_ci
829bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
830bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
831bf215546Sopenharmony_ci
832bf215546Sopenharmony_ci   pipe->bind_vertex_elements_state(pipe, state);
833bf215546Sopenharmony_ci
834bf215546Sopenharmony_ci   trace_dump_call_end();
835bf215546Sopenharmony_ci}
836bf215546Sopenharmony_ci
837bf215546Sopenharmony_ci
838bf215546Sopenharmony_cistatic void
839bf215546Sopenharmony_citrace_context_delete_vertex_elements_state(struct pipe_context *_pipe,
840bf215546Sopenharmony_ci                                           void *state)
841bf215546Sopenharmony_ci{
842bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
843bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
844bf215546Sopenharmony_ci
845bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_vertex_elements_state");
846bf215546Sopenharmony_ci
847bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
848bf215546Sopenharmony_ci   trace_dump_arg(ptr, state);
849bf215546Sopenharmony_ci
850bf215546Sopenharmony_ci   pipe->delete_vertex_elements_state(pipe, state);
851bf215546Sopenharmony_ci
852bf215546Sopenharmony_ci   trace_dump_call_end();
853bf215546Sopenharmony_ci}
854bf215546Sopenharmony_ci
855bf215546Sopenharmony_ci
856bf215546Sopenharmony_cistatic void
857bf215546Sopenharmony_citrace_context_set_blend_color(struct pipe_context *_pipe,
858bf215546Sopenharmony_ci                              const struct pipe_blend_color *state)
859bf215546Sopenharmony_ci{
860bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
861bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
862bf215546Sopenharmony_ci
863bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_blend_color");
864bf215546Sopenharmony_ci
865bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
866bf215546Sopenharmony_ci   trace_dump_arg(blend_color, state);
867bf215546Sopenharmony_ci
868bf215546Sopenharmony_ci   pipe->set_blend_color(pipe, state);
869bf215546Sopenharmony_ci
870bf215546Sopenharmony_ci   trace_dump_call_end();
871bf215546Sopenharmony_ci}
872bf215546Sopenharmony_ci
873bf215546Sopenharmony_ci
874bf215546Sopenharmony_cistatic void
875bf215546Sopenharmony_citrace_context_set_stencil_ref(struct pipe_context *_pipe,
876bf215546Sopenharmony_ci                              const struct pipe_stencil_ref state)
877bf215546Sopenharmony_ci{
878bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
879bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
880bf215546Sopenharmony_ci
881bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_stencil_ref");
882bf215546Sopenharmony_ci
883bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
884bf215546Sopenharmony_ci   trace_dump_arg(stencil_ref, &state);
885bf215546Sopenharmony_ci
886bf215546Sopenharmony_ci   pipe->set_stencil_ref(pipe, state);
887bf215546Sopenharmony_ci
888bf215546Sopenharmony_ci   trace_dump_call_end();
889bf215546Sopenharmony_ci}
890bf215546Sopenharmony_ci
891bf215546Sopenharmony_ci
892bf215546Sopenharmony_cistatic void
893bf215546Sopenharmony_citrace_context_set_clip_state(struct pipe_context *_pipe,
894bf215546Sopenharmony_ci                             const struct pipe_clip_state *state)
895bf215546Sopenharmony_ci{
896bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
897bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
898bf215546Sopenharmony_ci
899bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_clip_state");
900bf215546Sopenharmony_ci
901bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
902bf215546Sopenharmony_ci   trace_dump_arg(clip_state, state);
903bf215546Sopenharmony_ci
904bf215546Sopenharmony_ci   pipe->set_clip_state(pipe, state);
905bf215546Sopenharmony_ci
906bf215546Sopenharmony_ci   trace_dump_call_end();
907bf215546Sopenharmony_ci}
908bf215546Sopenharmony_ci
909bf215546Sopenharmony_cistatic void
910bf215546Sopenharmony_citrace_context_set_sample_mask(struct pipe_context *_pipe,
911bf215546Sopenharmony_ci                              unsigned sample_mask)
912bf215546Sopenharmony_ci{
913bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
914bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
915bf215546Sopenharmony_ci
916bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_sample_mask");
917bf215546Sopenharmony_ci
918bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
919bf215546Sopenharmony_ci   trace_dump_arg(uint, sample_mask);
920bf215546Sopenharmony_ci
921bf215546Sopenharmony_ci   pipe->set_sample_mask(pipe, sample_mask);
922bf215546Sopenharmony_ci
923bf215546Sopenharmony_ci   trace_dump_call_end();
924bf215546Sopenharmony_ci}
925bf215546Sopenharmony_ci
926bf215546Sopenharmony_cistatic void
927bf215546Sopenharmony_citrace_context_set_constant_buffer(struct pipe_context *_pipe,
928bf215546Sopenharmony_ci                                  enum pipe_shader_type shader, uint index,
929bf215546Sopenharmony_ci                                  bool take_ownership,
930bf215546Sopenharmony_ci                                  const struct pipe_constant_buffer *constant_buffer)
931bf215546Sopenharmony_ci{
932bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
933bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
934bf215546Sopenharmony_ci
935bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_constant_buffer");
936bf215546Sopenharmony_ci
937bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
938bf215546Sopenharmony_ci   trace_dump_arg_enum(shader, tr_util_pipe_shader_type_name(shader));
939bf215546Sopenharmony_ci   trace_dump_arg(uint, index);
940bf215546Sopenharmony_ci   trace_dump_arg(bool, take_ownership);
941bf215546Sopenharmony_ci   trace_dump_arg(constant_buffer, constant_buffer);
942bf215546Sopenharmony_ci
943bf215546Sopenharmony_ci   pipe->set_constant_buffer(pipe, shader, index, take_ownership, constant_buffer);
944bf215546Sopenharmony_ci
945bf215546Sopenharmony_ci   trace_dump_call_end();
946bf215546Sopenharmony_ci}
947bf215546Sopenharmony_ci
948bf215546Sopenharmony_ci
949bf215546Sopenharmony_cistatic void
950bf215546Sopenharmony_citrace_context_set_framebuffer_state(struct pipe_context *_pipe,
951bf215546Sopenharmony_ci                                    const struct pipe_framebuffer_state *state)
952bf215546Sopenharmony_ci{
953bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
954bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
955bf215546Sopenharmony_ci   unsigned i;
956bf215546Sopenharmony_ci
957bf215546Sopenharmony_ci   /* Unwrap the input state */
958bf215546Sopenharmony_ci   memcpy(&tr_ctx->unwrapped_state, state, sizeof(tr_ctx->unwrapped_state));
959bf215546Sopenharmony_ci   for (i = 0; i < state->nr_cbufs; ++i)
960bf215546Sopenharmony_ci      tr_ctx->unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
961bf215546Sopenharmony_ci   for (i = state->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
962bf215546Sopenharmony_ci      tr_ctx->unwrapped_state.cbufs[i] = NULL;
963bf215546Sopenharmony_ci   tr_ctx->unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
964bf215546Sopenharmony_ci   state = &tr_ctx->unwrapped_state;
965bf215546Sopenharmony_ci
966bf215546Sopenharmony_ci   dump_fb_state(tr_ctx, "set_framebuffer_state", trace_dump_is_triggered());
967bf215546Sopenharmony_ci
968bf215546Sopenharmony_ci   pipe->set_framebuffer_state(pipe, state);
969bf215546Sopenharmony_ci}
970bf215546Sopenharmony_ci
971bf215546Sopenharmony_cistatic void
972bf215546Sopenharmony_citrace_context_set_inlinable_constants(struct pipe_context *_pipe, enum pipe_shader_type shader,
973bf215546Sopenharmony_ci                                      uint num_values, uint32_t *values)
974bf215546Sopenharmony_ci{
975bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
976bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
977bf215546Sopenharmony_ci
978bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_inlinable_constants");
979bf215546Sopenharmony_ci
980bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
981bf215546Sopenharmony_ci   trace_dump_arg_enum(shader, tr_util_pipe_shader_type_name(shader));
982bf215546Sopenharmony_ci   trace_dump_arg(uint, num_values);
983bf215546Sopenharmony_ci   trace_dump_arg_array(uint, values, num_values);
984bf215546Sopenharmony_ci
985bf215546Sopenharmony_ci   pipe->set_inlinable_constants(pipe, shader, num_values, values);
986bf215546Sopenharmony_ci
987bf215546Sopenharmony_ci   trace_dump_call_end();
988bf215546Sopenharmony_ci}
989bf215546Sopenharmony_ci
990bf215546Sopenharmony_ci
991bf215546Sopenharmony_cistatic void
992bf215546Sopenharmony_citrace_context_set_polygon_stipple(struct pipe_context *_pipe,
993bf215546Sopenharmony_ci                                  const struct pipe_poly_stipple *state)
994bf215546Sopenharmony_ci{
995bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
996bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
997bf215546Sopenharmony_ci
998bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_polygon_stipple");
999bf215546Sopenharmony_ci
1000bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1001bf215546Sopenharmony_ci   trace_dump_arg(poly_stipple, state);
1002bf215546Sopenharmony_ci
1003bf215546Sopenharmony_ci   pipe->set_polygon_stipple(pipe, state);
1004bf215546Sopenharmony_ci
1005bf215546Sopenharmony_ci   trace_dump_call_end();
1006bf215546Sopenharmony_ci}
1007bf215546Sopenharmony_ci
1008bf215546Sopenharmony_cistatic void
1009bf215546Sopenharmony_citrace_context_set_min_samples(struct pipe_context *_pipe,
1010bf215546Sopenharmony_ci                              unsigned min_samples)
1011bf215546Sopenharmony_ci{
1012bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1013bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1014bf215546Sopenharmony_ci
1015bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_min_samples");
1016bf215546Sopenharmony_ci
1017bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1018bf215546Sopenharmony_ci   trace_dump_arg(uint, min_samples);
1019bf215546Sopenharmony_ci
1020bf215546Sopenharmony_ci   pipe->set_min_samples(pipe, min_samples);
1021bf215546Sopenharmony_ci
1022bf215546Sopenharmony_ci   trace_dump_call_end();
1023bf215546Sopenharmony_ci}
1024bf215546Sopenharmony_ci
1025bf215546Sopenharmony_ci
1026bf215546Sopenharmony_cistatic void
1027bf215546Sopenharmony_citrace_context_set_scissor_states(struct pipe_context *_pipe,
1028bf215546Sopenharmony_ci                                 unsigned start_slot,
1029bf215546Sopenharmony_ci                                 unsigned num_scissors,
1030bf215546Sopenharmony_ci                                 const struct pipe_scissor_state *states)
1031bf215546Sopenharmony_ci{
1032bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1033bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1034bf215546Sopenharmony_ci
1035bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_scissor_states");
1036bf215546Sopenharmony_ci
1037bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1038bf215546Sopenharmony_ci   trace_dump_arg(uint, start_slot);
1039bf215546Sopenharmony_ci   trace_dump_arg(uint, num_scissors);
1040bf215546Sopenharmony_ci   trace_dump_arg(scissor_state, states);
1041bf215546Sopenharmony_ci
1042bf215546Sopenharmony_ci   pipe->set_scissor_states(pipe, start_slot, num_scissors, states);
1043bf215546Sopenharmony_ci
1044bf215546Sopenharmony_ci   trace_dump_call_end();
1045bf215546Sopenharmony_ci}
1046bf215546Sopenharmony_ci
1047bf215546Sopenharmony_ci
1048bf215546Sopenharmony_cistatic void
1049bf215546Sopenharmony_citrace_context_set_viewport_states(struct pipe_context *_pipe,
1050bf215546Sopenharmony_ci                                  unsigned start_slot,
1051bf215546Sopenharmony_ci                                  unsigned num_viewports,
1052bf215546Sopenharmony_ci                                  const struct pipe_viewport_state *states)
1053bf215546Sopenharmony_ci{
1054bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1055bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1056bf215546Sopenharmony_ci
1057bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_viewport_states");
1058bf215546Sopenharmony_ci
1059bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1060bf215546Sopenharmony_ci   trace_dump_arg(uint, start_slot);
1061bf215546Sopenharmony_ci   trace_dump_arg(uint, num_viewports);
1062bf215546Sopenharmony_ci   trace_dump_arg(viewport_state, states);
1063bf215546Sopenharmony_ci
1064bf215546Sopenharmony_ci   pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
1065bf215546Sopenharmony_ci
1066bf215546Sopenharmony_ci   trace_dump_call_end();
1067bf215546Sopenharmony_ci}
1068bf215546Sopenharmony_ci
1069bf215546Sopenharmony_ci
1070bf215546Sopenharmony_cistatic struct pipe_sampler_view *
1071bf215546Sopenharmony_citrace_context_create_sampler_view(struct pipe_context *_pipe,
1072bf215546Sopenharmony_ci                                  struct pipe_resource *resource,
1073bf215546Sopenharmony_ci                                  const struct pipe_sampler_view *templ)
1074bf215546Sopenharmony_ci{
1075bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1076bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1077bf215546Sopenharmony_ci   struct pipe_sampler_view *result;
1078bf215546Sopenharmony_ci   struct trace_sampler_view *tr_view;
1079bf215546Sopenharmony_ci
1080bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_sampler_view");
1081bf215546Sopenharmony_ci
1082bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1083bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1084bf215546Sopenharmony_ci
1085bf215546Sopenharmony_ci   trace_dump_arg_begin("templ");
1086bf215546Sopenharmony_ci   trace_dump_sampler_view_template(templ);
1087bf215546Sopenharmony_ci   trace_dump_arg_end();
1088bf215546Sopenharmony_ci
1089bf215546Sopenharmony_ci   result = pipe->create_sampler_view(pipe, resource, templ);
1090bf215546Sopenharmony_ci
1091bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
1092bf215546Sopenharmony_ci
1093bf215546Sopenharmony_ci   trace_dump_call_end();
1094bf215546Sopenharmony_ci
1095bf215546Sopenharmony_ci   /*
1096bf215546Sopenharmony_ci    * Wrap pipe_sampler_view
1097bf215546Sopenharmony_ci    */
1098bf215546Sopenharmony_ci   tr_view = CALLOC_STRUCT(trace_sampler_view);
1099bf215546Sopenharmony_ci   tr_view->base = *templ;
1100bf215546Sopenharmony_ci   tr_view->base.reference.count = 1;
1101bf215546Sopenharmony_ci   tr_view->base.texture = NULL;
1102bf215546Sopenharmony_ci   pipe_resource_reference(&tr_view->base.texture, resource);
1103bf215546Sopenharmony_ci   tr_view->base.context = _pipe;
1104bf215546Sopenharmony_ci   tr_view->sampler_view = result;
1105bf215546Sopenharmony_ci   result->reference.count += 100000000;
1106bf215546Sopenharmony_ci   tr_view->refcount = 100000000;
1107bf215546Sopenharmony_ci   result = &tr_view->base;
1108bf215546Sopenharmony_ci
1109bf215546Sopenharmony_ci   return result;
1110bf215546Sopenharmony_ci}
1111bf215546Sopenharmony_ci
1112bf215546Sopenharmony_ci
1113bf215546Sopenharmony_cistatic void
1114bf215546Sopenharmony_citrace_context_sampler_view_destroy(struct pipe_context *_pipe,
1115bf215546Sopenharmony_ci                                   struct pipe_sampler_view *_view)
1116bf215546Sopenharmony_ci{
1117bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1118bf215546Sopenharmony_ci   struct trace_sampler_view *tr_view = trace_sampler_view(_view);
1119bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1120bf215546Sopenharmony_ci   struct pipe_sampler_view *view = tr_view->sampler_view;
1121bf215546Sopenharmony_ci
1122bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "sampler_view_destroy");
1123bf215546Sopenharmony_ci
1124bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1125bf215546Sopenharmony_ci   trace_dump_arg(ptr, view);
1126bf215546Sopenharmony_ci
1127bf215546Sopenharmony_ci   p_atomic_add(&tr_view->sampler_view->reference.count, -tr_view->refcount);
1128bf215546Sopenharmony_ci   pipe_sampler_view_reference(&tr_view->sampler_view, NULL);
1129bf215546Sopenharmony_ci
1130bf215546Sopenharmony_ci   trace_dump_call_end();
1131bf215546Sopenharmony_ci
1132bf215546Sopenharmony_ci   pipe_resource_reference(&_view->texture, NULL);
1133bf215546Sopenharmony_ci   FREE(_view);
1134bf215546Sopenharmony_ci}
1135bf215546Sopenharmony_ci
1136bf215546Sopenharmony_ci/********************************************************************
1137bf215546Sopenharmony_ci * surface
1138bf215546Sopenharmony_ci */
1139bf215546Sopenharmony_ci
1140bf215546Sopenharmony_ci
1141bf215546Sopenharmony_cistatic struct pipe_surface *
1142bf215546Sopenharmony_citrace_context_create_surface(struct pipe_context *_pipe,
1143bf215546Sopenharmony_ci                             struct pipe_resource *resource,
1144bf215546Sopenharmony_ci                             const struct pipe_surface *surf_tmpl)
1145bf215546Sopenharmony_ci{
1146bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1147bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1148bf215546Sopenharmony_ci   struct pipe_surface *result = NULL;
1149bf215546Sopenharmony_ci
1150bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_surface");
1151bf215546Sopenharmony_ci
1152bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1153bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1154bf215546Sopenharmony_ci
1155bf215546Sopenharmony_ci   trace_dump_arg_begin("surf_tmpl");
1156bf215546Sopenharmony_ci   trace_dump_surface_template(surf_tmpl, resource->target);
1157bf215546Sopenharmony_ci   trace_dump_arg_end();
1158bf215546Sopenharmony_ci
1159bf215546Sopenharmony_ci
1160bf215546Sopenharmony_ci   result = pipe->create_surface(pipe, resource, surf_tmpl);
1161bf215546Sopenharmony_ci
1162bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
1163bf215546Sopenharmony_ci
1164bf215546Sopenharmony_ci   trace_dump_call_end();
1165bf215546Sopenharmony_ci
1166bf215546Sopenharmony_ci   result = trace_surf_create(tr_ctx, resource, result);
1167bf215546Sopenharmony_ci
1168bf215546Sopenharmony_ci   return result;
1169bf215546Sopenharmony_ci}
1170bf215546Sopenharmony_ci
1171bf215546Sopenharmony_ci
1172bf215546Sopenharmony_cistatic void
1173bf215546Sopenharmony_citrace_context_surface_destroy(struct pipe_context *_pipe,
1174bf215546Sopenharmony_ci                              struct pipe_surface *_surface)
1175bf215546Sopenharmony_ci{
1176bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1177bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1178bf215546Sopenharmony_ci   struct trace_surface *tr_surf = trace_surface(_surface);
1179bf215546Sopenharmony_ci   struct pipe_surface *surface = tr_surf->surface;
1180bf215546Sopenharmony_ci
1181bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "surface_destroy");
1182bf215546Sopenharmony_ci
1183bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1184bf215546Sopenharmony_ci   trace_dump_arg(ptr, surface);
1185bf215546Sopenharmony_ci
1186bf215546Sopenharmony_ci   trace_dump_call_end();
1187bf215546Sopenharmony_ci
1188bf215546Sopenharmony_ci   trace_surf_destroy(tr_surf);
1189bf215546Sopenharmony_ci}
1190bf215546Sopenharmony_ci
1191bf215546Sopenharmony_ci
1192bf215546Sopenharmony_cistatic void
1193bf215546Sopenharmony_citrace_context_set_sampler_views(struct pipe_context *_pipe,
1194bf215546Sopenharmony_ci                                enum pipe_shader_type shader,
1195bf215546Sopenharmony_ci                                unsigned start,
1196bf215546Sopenharmony_ci                                unsigned num,
1197bf215546Sopenharmony_ci                                unsigned unbind_num_trailing_slots,
1198bf215546Sopenharmony_ci                                bool take_ownership,
1199bf215546Sopenharmony_ci                                struct pipe_sampler_view **views)
1200bf215546Sopenharmony_ci{
1201bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1202bf215546Sopenharmony_ci   struct trace_sampler_view *tr_view;
1203bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1204bf215546Sopenharmony_ci   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
1205bf215546Sopenharmony_ci   unsigned i;
1206bf215546Sopenharmony_ci
1207bf215546Sopenharmony_ci   /* remove this when we have pipe->set_sampler_views(..., start, ...) */
1208bf215546Sopenharmony_ci   assert(start == 0);
1209bf215546Sopenharmony_ci
1210bf215546Sopenharmony_ci   for (i = 0; i < num; ++i) {
1211bf215546Sopenharmony_ci      tr_view = trace_sampler_view(views[i]);
1212bf215546Sopenharmony_ci      if (tr_view) {
1213bf215546Sopenharmony_ci         tr_view->refcount--;
1214bf215546Sopenharmony_ci         if (!tr_view->refcount) {
1215bf215546Sopenharmony_ci            tr_view->refcount = 100000000;
1216bf215546Sopenharmony_ci            p_atomic_add(&tr_view->sampler_view->reference.count, tr_view->refcount);
1217bf215546Sopenharmony_ci         }
1218bf215546Sopenharmony_ci      }
1219bf215546Sopenharmony_ci      unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
1220bf215546Sopenharmony_ci   }
1221bf215546Sopenharmony_ci   views = unwrapped_views;
1222bf215546Sopenharmony_ci
1223bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_sampler_views");
1224bf215546Sopenharmony_ci
1225bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1226bf215546Sopenharmony_ci   trace_dump_arg_enum(shader, tr_util_pipe_shader_type_name(shader));
1227bf215546Sopenharmony_ci   trace_dump_arg(uint, start);
1228bf215546Sopenharmony_ci   trace_dump_arg(uint, num);
1229bf215546Sopenharmony_ci   trace_dump_arg(uint, unbind_num_trailing_slots);
1230bf215546Sopenharmony_ci   trace_dump_arg(bool, take_ownership);
1231bf215546Sopenharmony_ci   trace_dump_arg_array(ptr, views, num);
1232bf215546Sopenharmony_ci
1233bf215546Sopenharmony_ci   pipe->set_sampler_views(pipe, shader, start, num,
1234bf215546Sopenharmony_ci                           unbind_num_trailing_slots, take_ownership, views);
1235bf215546Sopenharmony_ci
1236bf215546Sopenharmony_ci   trace_dump_call_end();
1237bf215546Sopenharmony_ci}
1238bf215546Sopenharmony_ci
1239bf215546Sopenharmony_ci
1240bf215546Sopenharmony_cistatic void
1241bf215546Sopenharmony_citrace_context_set_vertex_buffers(struct pipe_context *_pipe,
1242bf215546Sopenharmony_ci                                 unsigned start_slot, unsigned num_buffers,
1243bf215546Sopenharmony_ci                                 unsigned unbind_num_trailing_slots,
1244bf215546Sopenharmony_ci                                 bool take_ownership,
1245bf215546Sopenharmony_ci                                 const struct pipe_vertex_buffer *buffers)
1246bf215546Sopenharmony_ci{
1247bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1248bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1249bf215546Sopenharmony_ci
1250bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_vertex_buffers");
1251bf215546Sopenharmony_ci
1252bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1253bf215546Sopenharmony_ci   trace_dump_arg(uint, start_slot);
1254bf215546Sopenharmony_ci   trace_dump_arg(uint, num_buffers);
1255bf215546Sopenharmony_ci   trace_dump_arg(uint, unbind_num_trailing_slots);
1256bf215546Sopenharmony_ci   trace_dump_arg(bool, take_ownership);
1257bf215546Sopenharmony_ci
1258bf215546Sopenharmony_ci   trace_dump_arg_begin("buffers");
1259bf215546Sopenharmony_ci   trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
1260bf215546Sopenharmony_ci   trace_dump_arg_end();
1261bf215546Sopenharmony_ci
1262bf215546Sopenharmony_ci   pipe->set_vertex_buffers(pipe, start_slot, num_buffers,
1263bf215546Sopenharmony_ci                            unbind_num_trailing_slots, take_ownership,
1264bf215546Sopenharmony_ci                            buffers);
1265bf215546Sopenharmony_ci
1266bf215546Sopenharmony_ci   trace_dump_call_end();
1267bf215546Sopenharmony_ci}
1268bf215546Sopenharmony_ci
1269bf215546Sopenharmony_ci
1270bf215546Sopenharmony_cistatic struct pipe_stream_output_target *
1271bf215546Sopenharmony_citrace_context_create_stream_output_target(struct pipe_context *_pipe,
1272bf215546Sopenharmony_ci                                          struct pipe_resource *res,
1273bf215546Sopenharmony_ci                                          unsigned buffer_offset,
1274bf215546Sopenharmony_ci                                          unsigned buffer_size)
1275bf215546Sopenharmony_ci{
1276bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1277bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1278bf215546Sopenharmony_ci   struct pipe_stream_output_target *result;
1279bf215546Sopenharmony_ci
1280bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_stream_output_target");
1281bf215546Sopenharmony_ci
1282bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1283bf215546Sopenharmony_ci   trace_dump_arg(ptr, res);
1284bf215546Sopenharmony_ci   trace_dump_arg(uint, buffer_offset);
1285bf215546Sopenharmony_ci   trace_dump_arg(uint, buffer_size);
1286bf215546Sopenharmony_ci
1287bf215546Sopenharmony_ci   result = pipe->create_stream_output_target(pipe,
1288bf215546Sopenharmony_ci                                              res, buffer_offset, buffer_size);
1289bf215546Sopenharmony_ci
1290bf215546Sopenharmony_ci   trace_dump_ret(ptr, result);
1291bf215546Sopenharmony_ci
1292bf215546Sopenharmony_ci   trace_dump_call_end();
1293bf215546Sopenharmony_ci
1294bf215546Sopenharmony_ci   return result;
1295bf215546Sopenharmony_ci}
1296bf215546Sopenharmony_ci
1297bf215546Sopenharmony_ci
1298bf215546Sopenharmony_cistatic void
1299bf215546Sopenharmony_citrace_context_stream_output_target_destroy(
1300bf215546Sopenharmony_ci   struct pipe_context *_pipe,
1301bf215546Sopenharmony_ci   struct pipe_stream_output_target *target)
1302bf215546Sopenharmony_ci{
1303bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1304bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1305bf215546Sopenharmony_ci
1306bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "stream_output_target_destroy");
1307bf215546Sopenharmony_ci
1308bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1309bf215546Sopenharmony_ci   trace_dump_arg(ptr, target);
1310bf215546Sopenharmony_ci
1311bf215546Sopenharmony_ci   pipe->stream_output_target_destroy(pipe, target);
1312bf215546Sopenharmony_ci
1313bf215546Sopenharmony_ci   trace_dump_call_end();
1314bf215546Sopenharmony_ci}
1315bf215546Sopenharmony_ci
1316bf215546Sopenharmony_ci
1317bf215546Sopenharmony_cistatic void
1318bf215546Sopenharmony_citrace_context_set_stream_output_targets(struct pipe_context *_pipe,
1319bf215546Sopenharmony_ci                                        unsigned num_targets,
1320bf215546Sopenharmony_ci                                        struct pipe_stream_output_target **tgs,
1321bf215546Sopenharmony_ci                                        const unsigned *offsets)
1322bf215546Sopenharmony_ci{
1323bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1324bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1325bf215546Sopenharmony_ci
1326bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_stream_output_targets");
1327bf215546Sopenharmony_ci
1328bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1329bf215546Sopenharmony_ci   trace_dump_arg(uint, num_targets);
1330bf215546Sopenharmony_ci   trace_dump_arg_array(ptr, tgs, num_targets);
1331bf215546Sopenharmony_ci   trace_dump_arg_array(uint, offsets, num_targets);
1332bf215546Sopenharmony_ci
1333bf215546Sopenharmony_ci   pipe->set_stream_output_targets(pipe, num_targets, tgs, offsets);
1334bf215546Sopenharmony_ci
1335bf215546Sopenharmony_ci   trace_dump_call_end();
1336bf215546Sopenharmony_ci}
1337bf215546Sopenharmony_ci
1338bf215546Sopenharmony_ci
1339bf215546Sopenharmony_cistatic void
1340bf215546Sopenharmony_citrace_context_resource_copy_region(struct pipe_context *_pipe,
1341bf215546Sopenharmony_ci                                   struct pipe_resource *dst,
1342bf215546Sopenharmony_ci                                   unsigned dst_level,
1343bf215546Sopenharmony_ci                                   unsigned dstx, unsigned dsty, unsigned dstz,
1344bf215546Sopenharmony_ci                                   struct pipe_resource *src,
1345bf215546Sopenharmony_ci                                   unsigned src_level,
1346bf215546Sopenharmony_ci                                   const struct pipe_box *src_box)
1347bf215546Sopenharmony_ci{
1348bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1349bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1350bf215546Sopenharmony_ci
1351bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "resource_copy_region");
1352bf215546Sopenharmony_ci
1353bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1354bf215546Sopenharmony_ci   trace_dump_arg(ptr, dst);
1355bf215546Sopenharmony_ci   trace_dump_arg(uint, dst_level);
1356bf215546Sopenharmony_ci   trace_dump_arg(uint, dstx);
1357bf215546Sopenharmony_ci   trace_dump_arg(uint, dsty);
1358bf215546Sopenharmony_ci   trace_dump_arg(uint, dstz);
1359bf215546Sopenharmony_ci   trace_dump_arg(ptr, src);
1360bf215546Sopenharmony_ci   trace_dump_arg(uint, src_level);
1361bf215546Sopenharmony_ci   trace_dump_arg(box, src_box);
1362bf215546Sopenharmony_ci
1363bf215546Sopenharmony_ci   pipe->resource_copy_region(pipe,
1364bf215546Sopenharmony_ci                              dst, dst_level, dstx, dsty, dstz,
1365bf215546Sopenharmony_ci                              src, src_level, src_box);
1366bf215546Sopenharmony_ci
1367bf215546Sopenharmony_ci   trace_dump_call_end();
1368bf215546Sopenharmony_ci}
1369bf215546Sopenharmony_ci
1370bf215546Sopenharmony_ci
1371bf215546Sopenharmony_cistatic void
1372bf215546Sopenharmony_citrace_context_blit(struct pipe_context *_pipe,
1373bf215546Sopenharmony_ci                   const struct pipe_blit_info *_info)
1374bf215546Sopenharmony_ci{
1375bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1376bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1377bf215546Sopenharmony_ci   struct pipe_blit_info info = *_info;
1378bf215546Sopenharmony_ci
1379bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "blit");
1380bf215546Sopenharmony_ci
1381bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1382bf215546Sopenharmony_ci   trace_dump_arg(blit_info, _info);
1383bf215546Sopenharmony_ci
1384bf215546Sopenharmony_ci   pipe->blit(pipe, &info);
1385bf215546Sopenharmony_ci
1386bf215546Sopenharmony_ci   trace_dump_call_end();
1387bf215546Sopenharmony_ci}
1388bf215546Sopenharmony_ci
1389bf215546Sopenharmony_ci
1390bf215546Sopenharmony_cistatic void
1391bf215546Sopenharmony_citrace_context_flush_resource(struct pipe_context *_pipe,
1392bf215546Sopenharmony_ci                             struct pipe_resource *resource)
1393bf215546Sopenharmony_ci{
1394bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1395bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1396bf215546Sopenharmony_ci
1397bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "flush_resource");
1398bf215546Sopenharmony_ci
1399bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1400bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1401bf215546Sopenharmony_ci
1402bf215546Sopenharmony_ci   pipe->flush_resource(pipe, resource);
1403bf215546Sopenharmony_ci
1404bf215546Sopenharmony_ci   trace_dump_call_end();
1405bf215546Sopenharmony_ci}
1406bf215546Sopenharmony_ci
1407bf215546Sopenharmony_ci
1408bf215546Sopenharmony_cistatic void
1409bf215546Sopenharmony_citrace_context_clear(struct pipe_context *_pipe,
1410bf215546Sopenharmony_ci                    unsigned buffers,
1411bf215546Sopenharmony_ci                    const struct pipe_scissor_state *scissor_state,
1412bf215546Sopenharmony_ci                    const union pipe_color_union *color,
1413bf215546Sopenharmony_ci                    double depth,
1414bf215546Sopenharmony_ci                    unsigned stencil)
1415bf215546Sopenharmony_ci{
1416bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1417bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1418bf215546Sopenharmony_ci
1419bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "clear");
1420bf215546Sopenharmony_ci
1421bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1422bf215546Sopenharmony_ci   trace_dump_arg(uint, buffers);
1423bf215546Sopenharmony_ci   trace_dump_arg_begin("scissor_state");
1424bf215546Sopenharmony_ci   trace_dump_scissor_state(scissor_state);
1425bf215546Sopenharmony_ci   trace_dump_arg_end();
1426bf215546Sopenharmony_ci   if (color)
1427bf215546Sopenharmony_ci      trace_dump_arg_array(uint, color->ui, 4);
1428bf215546Sopenharmony_ci   else
1429bf215546Sopenharmony_ci      trace_dump_null();
1430bf215546Sopenharmony_ci   trace_dump_arg(float, depth);
1431bf215546Sopenharmony_ci   trace_dump_arg(uint, stencil);
1432bf215546Sopenharmony_ci
1433bf215546Sopenharmony_ci   pipe->clear(pipe, buffers, scissor_state, color, depth, stencil);
1434bf215546Sopenharmony_ci
1435bf215546Sopenharmony_ci   trace_dump_call_end();
1436bf215546Sopenharmony_ci}
1437bf215546Sopenharmony_ci
1438bf215546Sopenharmony_ci
1439bf215546Sopenharmony_cistatic void
1440bf215546Sopenharmony_citrace_context_clear_render_target(struct pipe_context *_pipe,
1441bf215546Sopenharmony_ci                                  struct pipe_surface *dst,
1442bf215546Sopenharmony_ci                                  const union pipe_color_union *color,
1443bf215546Sopenharmony_ci                                  unsigned dstx, unsigned dsty,
1444bf215546Sopenharmony_ci                                  unsigned width, unsigned height,
1445bf215546Sopenharmony_ci                                  bool render_condition_enabled)
1446bf215546Sopenharmony_ci{
1447bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1448bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1449bf215546Sopenharmony_ci
1450bf215546Sopenharmony_ci   dst = trace_surface_unwrap(tr_ctx, dst);
1451bf215546Sopenharmony_ci
1452bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "clear_render_target");
1453bf215546Sopenharmony_ci
1454bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1455bf215546Sopenharmony_ci   trace_dump_arg(ptr, dst);
1456bf215546Sopenharmony_ci   trace_dump_arg_array(uint, color->ui, 4);
1457bf215546Sopenharmony_ci   trace_dump_arg(uint, dstx);
1458bf215546Sopenharmony_ci   trace_dump_arg(uint, dsty);
1459bf215546Sopenharmony_ci   trace_dump_arg(uint, width);
1460bf215546Sopenharmony_ci   trace_dump_arg(uint, height);
1461bf215546Sopenharmony_ci   trace_dump_arg(bool, render_condition_enabled);
1462bf215546Sopenharmony_ci
1463bf215546Sopenharmony_ci   pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height,
1464bf215546Sopenharmony_ci                             render_condition_enabled);
1465bf215546Sopenharmony_ci
1466bf215546Sopenharmony_ci   trace_dump_call_end();
1467bf215546Sopenharmony_ci}
1468bf215546Sopenharmony_ci
1469bf215546Sopenharmony_cistatic void
1470bf215546Sopenharmony_citrace_context_clear_depth_stencil(struct pipe_context *_pipe,
1471bf215546Sopenharmony_ci                                  struct pipe_surface *dst,
1472bf215546Sopenharmony_ci                                  unsigned clear_flags,
1473bf215546Sopenharmony_ci                                  double depth,
1474bf215546Sopenharmony_ci                                  unsigned stencil,
1475bf215546Sopenharmony_ci                                  unsigned dstx, unsigned dsty,
1476bf215546Sopenharmony_ci                                  unsigned width, unsigned height,
1477bf215546Sopenharmony_ci                                  bool render_condition_enabled)
1478bf215546Sopenharmony_ci{
1479bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1480bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1481bf215546Sopenharmony_ci
1482bf215546Sopenharmony_ci   dst = trace_surface_unwrap(tr_ctx, dst);
1483bf215546Sopenharmony_ci
1484bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "clear_depth_stencil");
1485bf215546Sopenharmony_ci
1486bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1487bf215546Sopenharmony_ci   trace_dump_arg(ptr, dst);
1488bf215546Sopenharmony_ci   trace_dump_arg(uint, clear_flags);
1489bf215546Sopenharmony_ci   trace_dump_arg(float, depth);
1490bf215546Sopenharmony_ci   trace_dump_arg(uint, stencil);
1491bf215546Sopenharmony_ci   trace_dump_arg(uint, dstx);
1492bf215546Sopenharmony_ci   trace_dump_arg(uint, dsty);
1493bf215546Sopenharmony_ci   trace_dump_arg(uint, width);
1494bf215546Sopenharmony_ci   trace_dump_arg(uint, height);
1495bf215546Sopenharmony_ci   trace_dump_arg(bool, render_condition_enabled);
1496bf215546Sopenharmony_ci
1497bf215546Sopenharmony_ci   pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil,
1498bf215546Sopenharmony_ci                             dstx, dsty, width, height,
1499bf215546Sopenharmony_ci                             render_condition_enabled);
1500bf215546Sopenharmony_ci
1501bf215546Sopenharmony_ci   trace_dump_call_end();
1502bf215546Sopenharmony_ci}
1503bf215546Sopenharmony_ci
1504bf215546Sopenharmony_cistatic inline void
1505bf215546Sopenharmony_citrace_context_clear_buffer(struct pipe_context *_pipe,
1506bf215546Sopenharmony_ci                           struct pipe_resource *res,
1507bf215546Sopenharmony_ci                           unsigned offset,
1508bf215546Sopenharmony_ci                           unsigned size,
1509bf215546Sopenharmony_ci                           const void *clear_value,
1510bf215546Sopenharmony_ci                           int clear_value_size)
1511bf215546Sopenharmony_ci{
1512bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1513bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1514bf215546Sopenharmony_ci
1515bf215546Sopenharmony_ci
1516bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "clear_buffer");
1517bf215546Sopenharmony_ci
1518bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1519bf215546Sopenharmony_ci   trace_dump_arg(ptr, res);
1520bf215546Sopenharmony_ci   trace_dump_arg(uint, offset);
1521bf215546Sopenharmony_ci   trace_dump_arg(uint, size);
1522bf215546Sopenharmony_ci   trace_dump_arg(ptr, clear_value);
1523bf215546Sopenharmony_ci   trace_dump_arg(int, clear_value_size);
1524bf215546Sopenharmony_ci
1525bf215546Sopenharmony_ci   pipe->clear_buffer(pipe, res, offset, size, clear_value, clear_value_size);
1526bf215546Sopenharmony_ci
1527bf215546Sopenharmony_ci   trace_dump_call_end();
1528bf215546Sopenharmony_ci}
1529bf215546Sopenharmony_ci
1530bf215546Sopenharmony_cistatic inline void
1531bf215546Sopenharmony_citrace_context_clear_texture(struct pipe_context *_pipe,
1532bf215546Sopenharmony_ci                            struct pipe_resource *res,
1533bf215546Sopenharmony_ci                            unsigned level,
1534bf215546Sopenharmony_ci                            const struct pipe_box *box,
1535bf215546Sopenharmony_ci                            const void *data)
1536bf215546Sopenharmony_ci{
1537bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1538bf215546Sopenharmony_ci   const struct util_format_description *desc = util_format_description(res->format);
1539bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1540bf215546Sopenharmony_ci   union pipe_color_union color;
1541bf215546Sopenharmony_ci   float depth = 0.0f;
1542bf215546Sopenharmony_ci   uint8_t stencil = 0;
1543bf215546Sopenharmony_ci
1544bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "clear_texture");
1545bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1546bf215546Sopenharmony_ci   trace_dump_arg(ptr, res);
1547bf215546Sopenharmony_ci   trace_dump_arg(uint, level);
1548bf215546Sopenharmony_ci   trace_dump_arg_begin("box");
1549bf215546Sopenharmony_ci   trace_dump_box(box);
1550bf215546Sopenharmony_ci   trace_dump_arg_end();
1551bf215546Sopenharmony_ci   if (util_format_has_depth(desc)) {
1552bf215546Sopenharmony_ci      util_format_unpack_z_float(res->format, &depth, data, 1);
1553bf215546Sopenharmony_ci      trace_dump_arg(float, depth);
1554bf215546Sopenharmony_ci   }
1555bf215546Sopenharmony_ci   if (util_format_has_stencil(desc)) {
1556bf215546Sopenharmony_ci      util_format_unpack_s_8uint(res->format, &stencil, data, 1);
1557bf215546Sopenharmony_ci      trace_dump_arg(uint, stencil);
1558bf215546Sopenharmony_ci   }
1559bf215546Sopenharmony_ci   if (!util_format_is_depth_or_stencil(res->format)) {
1560bf215546Sopenharmony_ci      util_format_unpack_rgba(res->format, color.ui, data, 1);
1561bf215546Sopenharmony_ci      trace_dump_arg_array(uint, color.ui, 4);
1562bf215546Sopenharmony_ci   }
1563bf215546Sopenharmony_ci
1564bf215546Sopenharmony_ci   pipe->clear_texture(pipe, res, level, box, data);
1565bf215546Sopenharmony_ci
1566bf215546Sopenharmony_ci   trace_dump_call_end();
1567bf215546Sopenharmony_ci}
1568bf215546Sopenharmony_ci
1569bf215546Sopenharmony_cistatic void
1570bf215546Sopenharmony_citrace_context_flush(struct pipe_context *_pipe,
1571bf215546Sopenharmony_ci                    struct pipe_fence_handle **fence,
1572bf215546Sopenharmony_ci                    unsigned flags)
1573bf215546Sopenharmony_ci{
1574bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1575bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1576bf215546Sopenharmony_ci
1577bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "flush");
1578bf215546Sopenharmony_ci
1579bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1580bf215546Sopenharmony_ci   trace_dump_arg(uint, flags);
1581bf215546Sopenharmony_ci
1582bf215546Sopenharmony_ci   pipe->flush(pipe, fence, flags);
1583bf215546Sopenharmony_ci
1584bf215546Sopenharmony_ci   if (fence)
1585bf215546Sopenharmony_ci      trace_dump_ret(ptr, *fence);
1586bf215546Sopenharmony_ci
1587bf215546Sopenharmony_ci   trace_dump_call_end();
1588bf215546Sopenharmony_ci
1589bf215546Sopenharmony_ci   if (flags & PIPE_FLUSH_END_OF_FRAME) {
1590bf215546Sopenharmony_ci      trace_dump_check_trigger();
1591bf215546Sopenharmony_ci      tr_ctx->seen_fb_state = false;
1592bf215546Sopenharmony_ci   }
1593bf215546Sopenharmony_ci}
1594bf215546Sopenharmony_ci
1595bf215546Sopenharmony_ci
1596bf215546Sopenharmony_cistatic void
1597bf215546Sopenharmony_citrace_context_create_fence_fd(struct pipe_context *_pipe,
1598bf215546Sopenharmony_ci                              struct pipe_fence_handle **fence,
1599bf215546Sopenharmony_ci                              int fd,
1600bf215546Sopenharmony_ci                              enum pipe_fd_type type)
1601bf215546Sopenharmony_ci{
1602bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1603bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1604bf215546Sopenharmony_ci
1605bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_fence_fd");
1606bf215546Sopenharmony_ci
1607bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1608bf215546Sopenharmony_ci   trace_dump_arg_enum(fd, tr_util_pipe_fd_type_name(fd));
1609bf215546Sopenharmony_ci   trace_dump_arg(uint, type);
1610bf215546Sopenharmony_ci
1611bf215546Sopenharmony_ci   pipe->create_fence_fd(pipe, fence, fd, type);
1612bf215546Sopenharmony_ci
1613bf215546Sopenharmony_ci   if (fence)
1614bf215546Sopenharmony_ci      trace_dump_ret(ptr, *fence);
1615bf215546Sopenharmony_ci
1616bf215546Sopenharmony_ci   trace_dump_call_end();
1617bf215546Sopenharmony_ci}
1618bf215546Sopenharmony_ci
1619bf215546Sopenharmony_ci
1620bf215546Sopenharmony_cistatic void
1621bf215546Sopenharmony_citrace_context_fence_server_sync(struct pipe_context *_pipe,
1622bf215546Sopenharmony_ci                                struct pipe_fence_handle *fence)
1623bf215546Sopenharmony_ci{
1624bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1625bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1626bf215546Sopenharmony_ci
1627bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "fence_server_sync");
1628bf215546Sopenharmony_ci
1629bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1630bf215546Sopenharmony_ci   trace_dump_arg(ptr, fence);
1631bf215546Sopenharmony_ci
1632bf215546Sopenharmony_ci   pipe->fence_server_sync(pipe, fence);
1633bf215546Sopenharmony_ci
1634bf215546Sopenharmony_ci   trace_dump_call_end();
1635bf215546Sopenharmony_ci}
1636bf215546Sopenharmony_ci
1637bf215546Sopenharmony_ci
1638bf215546Sopenharmony_cistatic void
1639bf215546Sopenharmony_citrace_context_fence_server_signal(struct pipe_context *_pipe,
1640bf215546Sopenharmony_ci                                struct pipe_fence_handle *fence)
1641bf215546Sopenharmony_ci{
1642bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1643bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1644bf215546Sopenharmony_ci
1645bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "fence_server_signal");
1646bf215546Sopenharmony_ci
1647bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1648bf215546Sopenharmony_ci   trace_dump_arg(ptr, fence);
1649bf215546Sopenharmony_ci
1650bf215546Sopenharmony_ci   pipe->fence_server_signal(pipe, fence);
1651bf215546Sopenharmony_ci
1652bf215546Sopenharmony_ci   trace_dump_call_end();
1653bf215546Sopenharmony_ci}
1654bf215546Sopenharmony_ci
1655bf215546Sopenharmony_ci
1656bf215546Sopenharmony_cistatic inline bool
1657bf215546Sopenharmony_citrace_context_generate_mipmap(struct pipe_context *_pipe,
1658bf215546Sopenharmony_ci                              struct pipe_resource *res,
1659bf215546Sopenharmony_ci                              enum pipe_format format,
1660bf215546Sopenharmony_ci                              unsigned base_level,
1661bf215546Sopenharmony_ci                              unsigned last_level,
1662bf215546Sopenharmony_ci                              unsigned first_layer,
1663bf215546Sopenharmony_ci                              unsigned last_layer)
1664bf215546Sopenharmony_ci{
1665bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1666bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1667bf215546Sopenharmony_ci   bool ret;
1668bf215546Sopenharmony_ci
1669bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "generate_mipmap");
1670bf215546Sopenharmony_ci
1671bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1672bf215546Sopenharmony_ci   trace_dump_arg(ptr, res);
1673bf215546Sopenharmony_ci
1674bf215546Sopenharmony_ci   trace_dump_arg(format, format);
1675bf215546Sopenharmony_ci   trace_dump_arg(uint, base_level);
1676bf215546Sopenharmony_ci   trace_dump_arg(uint, last_level);
1677bf215546Sopenharmony_ci   trace_dump_arg(uint, first_layer);
1678bf215546Sopenharmony_ci   trace_dump_arg(uint, last_layer);
1679bf215546Sopenharmony_ci
1680bf215546Sopenharmony_ci   ret = pipe->generate_mipmap(pipe, res, format, base_level, last_level,
1681bf215546Sopenharmony_ci                               first_layer, last_layer);
1682bf215546Sopenharmony_ci
1683bf215546Sopenharmony_ci   trace_dump_ret(bool, ret);
1684bf215546Sopenharmony_ci   trace_dump_call_end();
1685bf215546Sopenharmony_ci
1686bf215546Sopenharmony_ci   return ret;
1687bf215546Sopenharmony_ci}
1688bf215546Sopenharmony_ci
1689bf215546Sopenharmony_ci
1690bf215546Sopenharmony_cistatic void
1691bf215546Sopenharmony_citrace_context_destroy(struct pipe_context *_pipe)
1692bf215546Sopenharmony_ci{
1693bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
1694bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
1695bf215546Sopenharmony_ci
1696bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "destroy");
1697bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1698bf215546Sopenharmony_ci   trace_dump_call_end();
1699bf215546Sopenharmony_ci
1700bf215546Sopenharmony_ci   pipe->destroy(pipe);
1701bf215546Sopenharmony_ci
1702bf215546Sopenharmony_ci   ralloc_free(tr_ctx);
1703bf215546Sopenharmony_ci}
1704bf215546Sopenharmony_ci
1705bf215546Sopenharmony_ci
1706bf215546Sopenharmony_ci/********************************************************************
1707bf215546Sopenharmony_ci * transfer
1708bf215546Sopenharmony_ci */
1709bf215546Sopenharmony_ci
1710bf215546Sopenharmony_ci
1711bf215546Sopenharmony_cistatic void *
1712bf215546Sopenharmony_citrace_context_transfer_map(struct pipe_context *_context,
1713bf215546Sopenharmony_ci                           struct pipe_resource *resource,
1714bf215546Sopenharmony_ci                           unsigned level,
1715bf215546Sopenharmony_ci                           unsigned usage,
1716bf215546Sopenharmony_ci                           const struct pipe_box *box,
1717bf215546Sopenharmony_ci                           struct pipe_transfer **transfer)
1718bf215546Sopenharmony_ci{
1719bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1720bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_context->pipe;
1721bf215546Sopenharmony_ci   struct pipe_transfer *xfer = NULL;
1722bf215546Sopenharmony_ci   void *map;
1723bf215546Sopenharmony_ci
1724bf215546Sopenharmony_ci   if (resource->target == PIPE_BUFFER)
1725bf215546Sopenharmony_ci      map = pipe->buffer_map(pipe, resource, level, usage, box, &xfer);
1726bf215546Sopenharmony_ci   else
1727bf215546Sopenharmony_ci      map = pipe->texture_map(pipe, resource, level, usage, box, &xfer);
1728bf215546Sopenharmony_ci   if (!map)
1729bf215546Sopenharmony_ci      return NULL;
1730bf215546Sopenharmony_ci   *transfer = trace_transfer_create(tr_context, resource, xfer);
1731bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", resource->target == PIPE_BUFFER ? "buffer_map" : "texture_map");
1732bf215546Sopenharmony_ci
1733bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1734bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1735bf215546Sopenharmony_ci   trace_dump_arg(uint, level);
1736bf215546Sopenharmony_ci   trace_dump_arg(uint, usage);
1737bf215546Sopenharmony_ci   trace_dump_arg(box, box);
1738bf215546Sopenharmony_ci
1739bf215546Sopenharmony_ci   trace_dump_arg(ptr, xfer);
1740bf215546Sopenharmony_ci   trace_dump_ret(ptr, map);
1741bf215546Sopenharmony_ci
1742bf215546Sopenharmony_ci   trace_dump_call_end();
1743bf215546Sopenharmony_ci
1744bf215546Sopenharmony_ci   if (map) {
1745bf215546Sopenharmony_ci      if (usage & PIPE_MAP_WRITE) {
1746bf215546Sopenharmony_ci         trace_transfer(*transfer)->map = map;
1747bf215546Sopenharmony_ci      }
1748bf215546Sopenharmony_ci   }
1749bf215546Sopenharmony_ci
1750bf215546Sopenharmony_ci   return *transfer ? map : NULL;
1751bf215546Sopenharmony_ci}
1752bf215546Sopenharmony_ci
1753bf215546Sopenharmony_cistatic void
1754bf215546Sopenharmony_citrace_context_transfer_flush_region( struct pipe_context *_context,
1755bf215546Sopenharmony_ci				     struct pipe_transfer *_transfer,
1756bf215546Sopenharmony_ci				     const struct pipe_box *box)
1757bf215546Sopenharmony_ci{
1758bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1759bf215546Sopenharmony_ci   struct trace_transfer *tr_transfer = trace_transfer(_transfer);
1760bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_context->pipe;
1761bf215546Sopenharmony_ci   struct pipe_transfer *transfer = tr_transfer->transfer;
1762bf215546Sopenharmony_ci
1763bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "transfer_flush_region");
1764bf215546Sopenharmony_ci
1765bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
1766bf215546Sopenharmony_ci   trace_dump_arg(ptr, transfer);
1767bf215546Sopenharmony_ci   trace_dump_arg(box, box);
1768bf215546Sopenharmony_ci
1769bf215546Sopenharmony_ci   trace_dump_call_end();
1770bf215546Sopenharmony_ci
1771bf215546Sopenharmony_ci   pipe->transfer_flush_region(pipe, transfer, box);
1772bf215546Sopenharmony_ci}
1773bf215546Sopenharmony_ci
1774bf215546Sopenharmony_cistatic void
1775bf215546Sopenharmony_citrace_context_transfer_unmap(struct pipe_context *_context,
1776bf215546Sopenharmony_ci                             struct pipe_transfer *_transfer)
1777bf215546Sopenharmony_ci{
1778bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_context);
1779bf215546Sopenharmony_ci   struct trace_transfer *tr_trans = trace_transfer(_transfer);
1780bf215546Sopenharmony_ci   struct pipe_context *context = tr_ctx->pipe;
1781bf215546Sopenharmony_ci   struct pipe_transfer *transfer = tr_trans->transfer;
1782bf215546Sopenharmony_ci
1783bf215546Sopenharmony_ci
1784bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "transfer_unmap");
1785bf215546Sopenharmony_ci
1786bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1787bf215546Sopenharmony_ci   trace_dump_arg(ptr, transfer);
1788bf215546Sopenharmony_ci
1789bf215546Sopenharmony_ci   trace_dump_call_end();
1790bf215546Sopenharmony_ci
1791bf215546Sopenharmony_ci   if (tr_trans->map && !tr_ctx->threaded) {
1792bf215546Sopenharmony_ci      /*
1793bf215546Sopenharmony_ci       * Fake a texture/buffer_subdata
1794bf215546Sopenharmony_ci       */
1795bf215546Sopenharmony_ci
1796bf215546Sopenharmony_ci      struct pipe_resource *resource = transfer->resource;
1797bf215546Sopenharmony_ci      unsigned usage = transfer->usage;
1798bf215546Sopenharmony_ci      const struct pipe_box *box = &transfer->box;
1799bf215546Sopenharmony_ci      unsigned stride = transfer->stride;
1800bf215546Sopenharmony_ci      unsigned layer_stride = transfer->layer_stride;
1801bf215546Sopenharmony_ci
1802bf215546Sopenharmony_ci      if (resource->target == PIPE_BUFFER) {
1803bf215546Sopenharmony_ci         unsigned offset = box->x;
1804bf215546Sopenharmony_ci         unsigned size = box->width;
1805bf215546Sopenharmony_ci
1806bf215546Sopenharmony_ci         trace_dump_call_begin("pipe_context", "buffer_subdata");
1807bf215546Sopenharmony_ci
1808bf215546Sopenharmony_ci         trace_dump_arg(ptr, context);
1809bf215546Sopenharmony_ci         trace_dump_arg(ptr, resource);
1810bf215546Sopenharmony_ci         trace_dump_arg(uint, usage);
1811bf215546Sopenharmony_ci         trace_dump_arg(uint, offset);
1812bf215546Sopenharmony_ci         trace_dump_arg(uint, size);
1813bf215546Sopenharmony_ci
1814bf215546Sopenharmony_ci         trace_dump_arg_begin("data");
1815bf215546Sopenharmony_ci         trace_dump_box_bytes(tr_trans->map,
1816bf215546Sopenharmony_ci                              resource,
1817bf215546Sopenharmony_ci                              box,
1818bf215546Sopenharmony_ci                              stride,
1819bf215546Sopenharmony_ci                              layer_stride);
1820bf215546Sopenharmony_ci         trace_dump_arg_end();
1821bf215546Sopenharmony_ci
1822bf215546Sopenharmony_ci         trace_dump_arg(uint, stride);
1823bf215546Sopenharmony_ci         trace_dump_arg(uint, layer_stride);
1824bf215546Sopenharmony_ci
1825bf215546Sopenharmony_ci         trace_dump_call_end();
1826bf215546Sopenharmony_ci      } else {
1827bf215546Sopenharmony_ci         unsigned level = transfer->level;
1828bf215546Sopenharmony_ci
1829bf215546Sopenharmony_ci         trace_dump_call_begin("pipe_context", "texture_subdata");
1830bf215546Sopenharmony_ci
1831bf215546Sopenharmony_ci         trace_dump_arg(ptr, context);
1832bf215546Sopenharmony_ci         trace_dump_arg(ptr, resource);
1833bf215546Sopenharmony_ci         trace_dump_arg(uint, level);
1834bf215546Sopenharmony_ci         trace_dump_arg(uint, usage);
1835bf215546Sopenharmony_ci         trace_dump_arg(box, box);
1836bf215546Sopenharmony_ci
1837bf215546Sopenharmony_ci         trace_dump_arg_begin("data");
1838bf215546Sopenharmony_ci         trace_dump_box_bytes(tr_trans->map,
1839bf215546Sopenharmony_ci                              resource,
1840bf215546Sopenharmony_ci                              box,
1841bf215546Sopenharmony_ci                              stride,
1842bf215546Sopenharmony_ci                              layer_stride);
1843bf215546Sopenharmony_ci         trace_dump_arg_end();
1844bf215546Sopenharmony_ci
1845bf215546Sopenharmony_ci         trace_dump_arg(uint, stride);
1846bf215546Sopenharmony_ci         trace_dump_arg(uint, layer_stride);
1847bf215546Sopenharmony_ci
1848bf215546Sopenharmony_ci         trace_dump_call_end();
1849bf215546Sopenharmony_ci      }
1850bf215546Sopenharmony_ci
1851bf215546Sopenharmony_ci      tr_trans->map = NULL;
1852bf215546Sopenharmony_ci   }
1853bf215546Sopenharmony_ci
1854bf215546Sopenharmony_ci   if (transfer->resource->target == PIPE_BUFFER)
1855bf215546Sopenharmony_ci      context->buffer_unmap(context, transfer);
1856bf215546Sopenharmony_ci   else
1857bf215546Sopenharmony_ci      context->texture_unmap(context, transfer);
1858bf215546Sopenharmony_ci   trace_transfer_destroy(tr_ctx, tr_trans);
1859bf215546Sopenharmony_ci}
1860bf215546Sopenharmony_ci
1861bf215546Sopenharmony_ci
1862bf215546Sopenharmony_cistatic void
1863bf215546Sopenharmony_citrace_context_buffer_subdata(struct pipe_context *_context,
1864bf215546Sopenharmony_ci                             struct pipe_resource *resource,
1865bf215546Sopenharmony_ci                             unsigned usage, unsigned offset,
1866bf215546Sopenharmony_ci                             unsigned size, const void *data)
1867bf215546Sopenharmony_ci{
1868bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1869bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1870bf215546Sopenharmony_ci   struct pipe_box box;
1871bf215546Sopenharmony_ci
1872bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "buffer_subdata");
1873bf215546Sopenharmony_ci
1874bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1875bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1876bf215546Sopenharmony_ci   trace_dump_arg(uint, usage);
1877bf215546Sopenharmony_ci   trace_dump_arg(uint, offset);
1878bf215546Sopenharmony_ci   trace_dump_arg(uint, size);
1879bf215546Sopenharmony_ci
1880bf215546Sopenharmony_ci   trace_dump_arg_begin("data");
1881bf215546Sopenharmony_ci   u_box_1d(offset, size, &box);
1882bf215546Sopenharmony_ci   trace_dump_box_bytes(data, resource, &box, 0, 0);
1883bf215546Sopenharmony_ci   trace_dump_arg_end();
1884bf215546Sopenharmony_ci
1885bf215546Sopenharmony_ci   trace_dump_call_end();
1886bf215546Sopenharmony_ci
1887bf215546Sopenharmony_ci   context->buffer_subdata(context, resource, usage, offset, size, data);
1888bf215546Sopenharmony_ci}
1889bf215546Sopenharmony_ci
1890bf215546Sopenharmony_ci
1891bf215546Sopenharmony_cistatic void
1892bf215546Sopenharmony_citrace_context_texture_subdata(struct pipe_context *_context,
1893bf215546Sopenharmony_ci                              struct pipe_resource *resource,
1894bf215546Sopenharmony_ci                              unsigned level,
1895bf215546Sopenharmony_ci                              unsigned usage,
1896bf215546Sopenharmony_ci                              const struct pipe_box *box,
1897bf215546Sopenharmony_ci                              const void *data,
1898bf215546Sopenharmony_ci                              unsigned stride,
1899bf215546Sopenharmony_ci                              unsigned layer_stride)
1900bf215546Sopenharmony_ci{
1901bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1902bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1903bf215546Sopenharmony_ci
1904bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "texture_subdata");
1905bf215546Sopenharmony_ci
1906bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1907bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1908bf215546Sopenharmony_ci   trace_dump_arg(uint, level);
1909bf215546Sopenharmony_ci   trace_dump_arg(uint, usage);
1910bf215546Sopenharmony_ci   trace_dump_arg(box, box);
1911bf215546Sopenharmony_ci
1912bf215546Sopenharmony_ci   trace_dump_arg_begin("data");
1913bf215546Sopenharmony_ci   trace_dump_box_bytes(data,
1914bf215546Sopenharmony_ci                        resource,
1915bf215546Sopenharmony_ci                        box,
1916bf215546Sopenharmony_ci                        stride,
1917bf215546Sopenharmony_ci                        layer_stride);
1918bf215546Sopenharmony_ci   trace_dump_arg_end();
1919bf215546Sopenharmony_ci
1920bf215546Sopenharmony_ci   trace_dump_arg(uint, stride);
1921bf215546Sopenharmony_ci   trace_dump_arg(uint, layer_stride);
1922bf215546Sopenharmony_ci
1923bf215546Sopenharmony_ci   trace_dump_call_end();
1924bf215546Sopenharmony_ci
1925bf215546Sopenharmony_ci   context->texture_subdata(context, resource, level, usage, box,
1926bf215546Sopenharmony_ci                            data, stride, layer_stride);
1927bf215546Sopenharmony_ci}
1928bf215546Sopenharmony_ci
1929bf215546Sopenharmony_cistatic void
1930bf215546Sopenharmony_citrace_context_invalidate_resource(struct pipe_context *_context,
1931bf215546Sopenharmony_ci                                  struct pipe_resource *resource)
1932bf215546Sopenharmony_ci{
1933bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1934bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1935bf215546Sopenharmony_ci
1936bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "invalidate_resource");
1937bf215546Sopenharmony_ci
1938bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1939bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
1940bf215546Sopenharmony_ci
1941bf215546Sopenharmony_ci   trace_dump_call_end();
1942bf215546Sopenharmony_ci
1943bf215546Sopenharmony_ci   context->invalidate_resource(context, resource);
1944bf215546Sopenharmony_ci}
1945bf215546Sopenharmony_ci
1946bf215546Sopenharmony_cistatic void
1947bf215546Sopenharmony_citrace_context_set_context_param(struct pipe_context *_context,
1948bf215546Sopenharmony_ci                                enum pipe_context_param param,
1949bf215546Sopenharmony_ci                                unsigned value)
1950bf215546Sopenharmony_ci{
1951bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1952bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1953bf215546Sopenharmony_ci
1954bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_context_param");
1955bf215546Sopenharmony_ci
1956bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1957bf215546Sopenharmony_ci   trace_dump_arg(uint, param);
1958bf215546Sopenharmony_ci   trace_dump_arg(uint, value);
1959bf215546Sopenharmony_ci
1960bf215546Sopenharmony_ci   trace_dump_call_end();
1961bf215546Sopenharmony_ci
1962bf215546Sopenharmony_ci   context->set_context_param(context, param, value);
1963bf215546Sopenharmony_ci}
1964bf215546Sopenharmony_ci
1965bf215546Sopenharmony_cistatic void
1966bf215546Sopenharmony_citrace_context_set_debug_callback(struct pipe_context *_context, const struct util_debug_callback *cb)
1967bf215546Sopenharmony_ci{
1968bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1969bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1970bf215546Sopenharmony_ci
1971bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_debug_callback");
1972bf215546Sopenharmony_ci
1973bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1974bf215546Sopenharmony_ci
1975bf215546Sopenharmony_ci   trace_dump_call_end();
1976bf215546Sopenharmony_ci
1977bf215546Sopenharmony_ci   context->set_debug_callback(context, cb);
1978bf215546Sopenharmony_ci}
1979bf215546Sopenharmony_ci
1980bf215546Sopenharmony_cistatic void
1981bf215546Sopenharmony_citrace_context_render_condition(struct pipe_context *_context,
1982bf215546Sopenharmony_ci                               struct pipe_query *query,
1983bf215546Sopenharmony_ci                               bool condition,
1984bf215546Sopenharmony_ci                               enum pipe_render_cond_flag mode)
1985bf215546Sopenharmony_ci{
1986bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
1987bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
1988bf215546Sopenharmony_ci
1989bf215546Sopenharmony_ci   query = trace_query_unwrap(query);
1990bf215546Sopenharmony_ci
1991bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "render_condition");
1992bf215546Sopenharmony_ci
1993bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
1994bf215546Sopenharmony_ci   trace_dump_arg(ptr, query);
1995bf215546Sopenharmony_ci   trace_dump_arg(bool, condition);
1996bf215546Sopenharmony_ci   trace_dump_arg(uint, mode);
1997bf215546Sopenharmony_ci
1998bf215546Sopenharmony_ci   trace_dump_call_end();
1999bf215546Sopenharmony_ci
2000bf215546Sopenharmony_ci   context->render_condition(context, query, condition, mode);
2001bf215546Sopenharmony_ci}
2002bf215546Sopenharmony_ci
2003bf215546Sopenharmony_cistatic void
2004bf215546Sopenharmony_citrace_context_render_condition_mem(struct pipe_context *_context,
2005bf215546Sopenharmony_ci                                    struct pipe_resource *buffer,
2006bf215546Sopenharmony_ci                                    uint32_t offset,
2007bf215546Sopenharmony_ci                                    bool condition)
2008bf215546Sopenharmony_ci{
2009bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2010bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2011bf215546Sopenharmony_ci
2012bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "render_condition_mem");
2013bf215546Sopenharmony_ci
2014bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2015bf215546Sopenharmony_ci   trace_dump_arg(ptr, buffer);
2016bf215546Sopenharmony_ci   trace_dump_arg(uint, offset);
2017bf215546Sopenharmony_ci   trace_dump_arg(bool, condition);
2018bf215546Sopenharmony_ci
2019bf215546Sopenharmony_ci   trace_dump_call_end();
2020bf215546Sopenharmony_ci
2021bf215546Sopenharmony_ci   context->render_condition_mem(context, buffer, offset, condition);
2022bf215546Sopenharmony_ci}
2023bf215546Sopenharmony_ci
2024bf215546Sopenharmony_ci
2025bf215546Sopenharmony_cistatic void
2026bf215546Sopenharmony_citrace_context_texture_barrier(struct pipe_context *_context, unsigned flags)
2027bf215546Sopenharmony_ci{
2028bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2029bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2030bf215546Sopenharmony_ci
2031bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "texture_barrier");
2032bf215546Sopenharmony_ci
2033bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2034bf215546Sopenharmony_ci   trace_dump_arg(uint, flags);
2035bf215546Sopenharmony_ci
2036bf215546Sopenharmony_ci   trace_dump_call_end();
2037bf215546Sopenharmony_ci
2038bf215546Sopenharmony_ci   context->texture_barrier(context, flags);
2039bf215546Sopenharmony_ci}
2040bf215546Sopenharmony_ci
2041bf215546Sopenharmony_ci
2042bf215546Sopenharmony_cistatic void
2043bf215546Sopenharmony_citrace_context_memory_barrier(struct pipe_context *_context,
2044bf215546Sopenharmony_ci                             unsigned flags)
2045bf215546Sopenharmony_ci{
2046bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2047bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2048bf215546Sopenharmony_ci
2049bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "memory_barrier");
2050bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2051bf215546Sopenharmony_ci   trace_dump_arg(uint, flags);
2052bf215546Sopenharmony_ci   trace_dump_call_end();
2053bf215546Sopenharmony_ci
2054bf215546Sopenharmony_ci   context->memory_barrier(context, flags);
2055bf215546Sopenharmony_ci}
2056bf215546Sopenharmony_ci
2057bf215546Sopenharmony_ci
2058bf215546Sopenharmony_cistatic bool
2059bf215546Sopenharmony_citrace_context_resource_commit(struct pipe_context *_context,
2060bf215546Sopenharmony_ci                              struct pipe_resource *resource,
2061bf215546Sopenharmony_ci                              unsigned level, struct pipe_box *box, bool commit)
2062bf215546Sopenharmony_ci{
2063bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2064bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2065bf215546Sopenharmony_ci
2066bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "resource_commit");
2067bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2068bf215546Sopenharmony_ci   trace_dump_arg(ptr, resource);
2069bf215546Sopenharmony_ci   trace_dump_arg(uint, level);
2070bf215546Sopenharmony_ci   trace_dump_arg(box, box);
2071bf215546Sopenharmony_ci   trace_dump_arg(bool, commit);
2072bf215546Sopenharmony_ci   trace_dump_call_end();
2073bf215546Sopenharmony_ci
2074bf215546Sopenharmony_ci   return context->resource_commit(context, resource, level, box, commit);
2075bf215546Sopenharmony_ci}
2076bf215546Sopenharmony_ci
2077bf215546Sopenharmony_cistatic void
2078bf215546Sopenharmony_citrace_context_set_tess_state(struct pipe_context *_context,
2079bf215546Sopenharmony_ci                             const float default_outer_level[4],
2080bf215546Sopenharmony_ci                             const float default_inner_level[2])
2081bf215546Sopenharmony_ci{
2082bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2083bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2084bf215546Sopenharmony_ci
2085bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_tess_state");
2086bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2087bf215546Sopenharmony_ci   trace_dump_arg_array(float, default_outer_level, 4);
2088bf215546Sopenharmony_ci   trace_dump_arg_array(float, default_inner_level, 2);
2089bf215546Sopenharmony_ci   trace_dump_call_end();
2090bf215546Sopenharmony_ci
2091bf215546Sopenharmony_ci   context->set_tess_state(context, default_outer_level, default_inner_level);
2092bf215546Sopenharmony_ci}
2093bf215546Sopenharmony_ci
2094bf215546Sopenharmony_cistatic void
2095bf215546Sopenharmony_citrace_context_set_patch_vertices(struct pipe_context *_context,
2096bf215546Sopenharmony_ci                                 uint8_t patch_vertices)
2097bf215546Sopenharmony_ci{
2098bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2099bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2100bf215546Sopenharmony_ci
2101bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_patch_vertices");
2102bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2103bf215546Sopenharmony_ci   trace_dump_arg(uint, patch_vertices);
2104bf215546Sopenharmony_ci   trace_dump_call_end();
2105bf215546Sopenharmony_ci
2106bf215546Sopenharmony_ci   context->set_patch_vertices(context, patch_vertices);
2107bf215546Sopenharmony_ci}
2108bf215546Sopenharmony_ci
2109bf215546Sopenharmony_cistatic void trace_context_set_shader_buffers(struct pipe_context *_context,
2110bf215546Sopenharmony_ci                                             enum pipe_shader_type shader,
2111bf215546Sopenharmony_ci                                             unsigned start, unsigned nr,
2112bf215546Sopenharmony_ci                                             const struct pipe_shader_buffer *buffers,
2113bf215546Sopenharmony_ci                                             unsigned writable_bitmask)
2114bf215546Sopenharmony_ci{
2115bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2116bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2117bf215546Sopenharmony_ci
2118bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_shader_buffers");
2119bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2120bf215546Sopenharmony_ci   trace_dump_arg(uint, shader);
2121bf215546Sopenharmony_ci   trace_dump_arg(uint, start);
2122bf215546Sopenharmony_ci   trace_dump_arg_begin("buffers");
2123bf215546Sopenharmony_ci   trace_dump_struct_array(shader_buffer, buffers, nr);
2124bf215546Sopenharmony_ci   trace_dump_arg_end();
2125bf215546Sopenharmony_ci   trace_dump_arg(uint, writable_bitmask);
2126bf215546Sopenharmony_ci   trace_dump_call_end();
2127bf215546Sopenharmony_ci
2128bf215546Sopenharmony_ci   context->set_shader_buffers(context, shader, start, nr, buffers,
2129bf215546Sopenharmony_ci                               writable_bitmask);
2130bf215546Sopenharmony_ci}
2131bf215546Sopenharmony_ci
2132bf215546Sopenharmony_cistatic void trace_context_set_shader_images(struct pipe_context *_context,
2133bf215546Sopenharmony_ci                                            enum pipe_shader_type shader,
2134bf215546Sopenharmony_ci                                            unsigned start, unsigned nr,
2135bf215546Sopenharmony_ci                                            unsigned unbind_num_trailing_slots,
2136bf215546Sopenharmony_ci                                            const struct pipe_image_view *images)
2137bf215546Sopenharmony_ci{
2138bf215546Sopenharmony_ci   struct trace_context *tr_context = trace_context(_context);
2139bf215546Sopenharmony_ci   struct pipe_context *context = tr_context->pipe;
2140bf215546Sopenharmony_ci
2141bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "set_shader_images");
2142bf215546Sopenharmony_ci   trace_dump_arg(ptr, context);
2143bf215546Sopenharmony_ci   trace_dump_arg(uint, shader);
2144bf215546Sopenharmony_ci   trace_dump_arg(uint, start);
2145bf215546Sopenharmony_ci   trace_dump_arg_begin("images");
2146bf215546Sopenharmony_ci   trace_dump_struct_array(image_view, images, nr);
2147bf215546Sopenharmony_ci   trace_dump_arg_end();
2148bf215546Sopenharmony_ci   trace_dump_arg(uint, unbind_num_trailing_slots);
2149bf215546Sopenharmony_ci   trace_dump_call_end();
2150bf215546Sopenharmony_ci
2151bf215546Sopenharmony_ci   context->set_shader_images(context, shader, start, nr,
2152bf215546Sopenharmony_ci                              unbind_num_trailing_slots, images);
2153bf215546Sopenharmony_ci}
2154bf215546Sopenharmony_ci
2155bf215546Sopenharmony_cistatic void trace_context_launch_grid(struct pipe_context *_pipe,
2156bf215546Sopenharmony_ci                                      const struct pipe_grid_info *info)
2157bf215546Sopenharmony_ci{
2158bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2159bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2160bf215546Sopenharmony_ci
2161bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "launch_grid");
2162bf215546Sopenharmony_ci
2163bf215546Sopenharmony_ci   trace_dump_arg(ptr,  pipe);
2164bf215546Sopenharmony_ci   trace_dump_arg(grid_info, info);
2165bf215546Sopenharmony_ci
2166bf215546Sopenharmony_ci   trace_dump_trace_flush();
2167bf215546Sopenharmony_ci
2168bf215546Sopenharmony_ci   pipe->launch_grid(pipe, info);
2169bf215546Sopenharmony_ci
2170bf215546Sopenharmony_ci   trace_dump_call_end();
2171bf215546Sopenharmony_ci}
2172bf215546Sopenharmony_ci
2173bf215546Sopenharmony_cistatic uint64_t trace_context_create_texture_handle(struct pipe_context *_pipe,
2174bf215546Sopenharmony_ci                                                    struct pipe_sampler_view *view,
2175bf215546Sopenharmony_ci                                                    const struct pipe_sampler_state *state)
2176bf215546Sopenharmony_ci{
2177bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2178bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2179bf215546Sopenharmony_ci   uint64_t handle;
2180bf215546Sopenharmony_ci
2181bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_texture_handle");
2182bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2183bf215546Sopenharmony_ci   trace_dump_arg(ptr, view);
2184bf215546Sopenharmony_ci   trace_dump_arg_begin("state");
2185bf215546Sopenharmony_ci   trace_dump_arg(sampler_state, state);
2186bf215546Sopenharmony_ci   trace_dump_arg_end();
2187bf215546Sopenharmony_ci
2188bf215546Sopenharmony_ci   handle = pipe->create_texture_handle(pipe, view, state);
2189bf215546Sopenharmony_ci
2190bf215546Sopenharmony_ci   trace_dump_ret(uint, handle);
2191bf215546Sopenharmony_ci   trace_dump_call_end();
2192bf215546Sopenharmony_ci
2193bf215546Sopenharmony_ci   return handle;
2194bf215546Sopenharmony_ci}
2195bf215546Sopenharmony_ci
2196bf215546Sopenharmony_cistatic void trace_context_delete_texture_handle(struct pipe_context *_pipe,
2197bf215546Sopenharmony_ci                                                uint64_t handle)
2198bf215546Sopenharmony_ci{
2199bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2200bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2201bf215546Sopenharmony_ci
2202bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_texture_handle");
2203bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2204bf215546Sopenharmony_ci   trace_dump_arg(uint, handle);
2205bf215546Sopenharmony_ci   trace_dump_call_end();
2206bf215546Sopenharmony_ci
2207bf215546Sopenharmony_ci   pipe->delete_texture_handle(pipe, handle);
2208bf215546Sopenharmony_ci}
2209bf215546Sopenharmony_ci
2210bf215546Sopenharmony_cistatic void trace_context_make_texture_handle_resident(struct pipe_context *_pipe,
2211bf215546Sopenharmony_ci                                                       uint64_t handle,
2212bf215546Sopenharmony_ci                                                       bool resident)
2213bf215546Sopenharmony_ci{
2214bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2215bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2216bf215546Sopenharmony_ci
2217bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "make_texture_handle_resident");
2218bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2219bf215546Sopenharmony_ci   trace_dump_arg(uint, handle);
2220bf215546Sopenharmony_ci   trace_dump_arg(bool, resident);
2221bf215546Sopenharmony_ci   trace_dump_call_end();
2222bf215546Sopenharmony_ci
2223bf215546Sopenharmony_ci   pipe->make_texture_handle_resident(pipe, handle, resident);
2224bf215546Sopenharmony_ci}
2225bf215546Sopenharmony_ci
2226bf215546Sopenharmony_cistatic uint64_t trace_context_create_image_handle(struct pipe_context *_pipe,
2227bf215546Sopenharmony_ci                                                  const struct pipe_image_view *image)
2228bf215546Sopenharmony_ci{
2229bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2230bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2231bf215546Sopenharmony_ci   uint64_t handle;
2232bf215546Sopenharmony_ci
2233bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "create_image_handle");
2234bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2235bf215546Sopenharmony_ci   trace_dump_arg_begin("image");
2236bf215546Sopenharmony_ci   trace_dump_image_view(image);
2237bf215546Sopenharmony_ci   trace_dump_arg_end();
2238bf215546Sopenharmony_ci
2239bf215546Sopenharmony_ci   handle = pipe->create_image_handle(pipe, image);
2240bf215546Sopenharmony_ci
2241bf215546Sopenharmony_ci   trace_dump_ret(uint, handle);
2242bf215546Sopenharmony_ci   trace_dump_call_end();
2243bf215546Sopenharmony_ci
2244bf215546Sopenharmony_ci   return handle;
2245bf215546Sopenharmony_ci}
2246bf215546Sopenharmony_ci
2247bf215546Sopenharmony_cistatic void trace_context_delete_image_handle(struct pipe_context *_pipe,
2248bf215546Sopenharmony_ci                                              uint64_t handle)
2249bf215546Sopenharmony_ci{
2250bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2251bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2252bf215546Sopenharmony_ci
2253bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "delete_image_handle");
2254bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2255bf215546Sopenharmony_ci   trace_dump_arg(uint, handle);
2256bf215546Sopenharmony_ci   trace_dump_call_end();
2257bf215546Sopenharmony_ci
2258bf215546Sopenharmony_ci   pipe->delete_image_handle(pipe, handle);
2259bf215546Sopenharmony_ci}
2260bf215546Sopenharmony_ci
2261bf215546Sopenharmony_cistatic void trace_context_make_image_handle_resident(struct pipe_context *_pipe,
2262bf215546Sopenharmony_ci                                                    uint64_t handle,
2263bf215546Sopenharmony_ci                                                    unsigned access,
2264bf215546Sopenharmony_ci                                                    bool resident)
2265bf215546Sopenharmony_ci{
2266bf215546Sopenharmony_ci   struct trace_context *tr_ctx = trace_context(_pipe);
2267bf215546Sopenharmony_ci   struct pipe_context *pipe = tr_ctx->pipe;
2268bf215546Sopenharmony_ci
2269bf215546Sopenharmony_ci   trace_dump_call_begin("pipe_context", "make_image_handle_resident");
2270bf215546Sopenharmony_ci   trace_dump_arg(ptr, pipe);
2271bf215546Sopenharmony_ci   trace_dump_arg(uint, handle);
2272bf215546Sopenharmony_ci   trace_dump_arg(uint, access);
2273bf215546Sopenharmony_ci   trace_dump_arg(bool, resident);
2274bf215546Sopenharmony_ci   trace_dump_call_end();
2275bf215546Sopenharmony_ci
2276bf215546Sopenharmony_ci   pipe->make_image_handle_resident(pipe, handle, access, resident);
2277bf215546Sopenharmony_ci}
2278bf215546Sopenharmony_ci
2279bf215546Sopenharmony_cistruct pipe_context *
2280bf215546Sopenharmony_citrace_context_create(struct trace_screen *tr_scr,
2281bf215546Sopenharmony_ci                     struct pipe_context *pipe)
2282bf215546Sopenharmony_ci{
2283bf215546Sopenharmony_ci   struct trace_context *tr_ctx;
2284bf215546Sopenharmony_ci
2285bf215546Sopenharmony_ci   if (!pipe)
2286bf215546Sopenharmony_ci      goto error1;
2287bf215546Sopenharmony_ci
2288bf215546Sopenharmony_ci   if (!trace_enabled())
2289bf215546Sopenharmony_ci      goto error1;
2290bf215546Sopenharmony_ci
2291bf215546Sopenharmony_ci   tr_ctx = rzalloc(NULL, struct trace_context);
2292bf215546Sopenharmony_ci   if (!tr_ctx)
2293bf215546Sopenharmony_ci      goto error1;
2294bf215546Sopenharmony_ci
2295bf215546Sopenharmony_ci   _mesa_hash_table_init(&tr_ctx->blend_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
2296bf215546Sopenharmony_ci   _mesa_hash_table_init(&tr_ctx->rasterizer_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
2297bf215546Sopenharmony_ci   _mesa_hash_table_init(&tr_ctx->depth_stencil_alpha_states, tr_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
2298bf215546Sopenharmony_ci
2299bf215546Sopenharmony_ci   tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */
2300bf215546Sopenharmony_ci   tr_ctx->base.screen = &tr_scr->base;
2301bf215546Sopenharmony_ci   tr_ctx->base.stream_uploader = pipe->stream_uploader;
2302bf215546Sopenharmony_ci   tr_ctx->base.const_uploader = pipe->const_uploader;
2303bf215546Sopenharmony_ci
2304bf215546Sopenharmony_ci   tr_ctx->base.destroy = trace_context_destroy;
2305bf215546Sopenharmony_ci
2306bf215546Sopenharmony_ci#define TR_CTX_INIT(_member) \
2307bf215546Sopenharmony_ci   tr_ctx->base . _member = pipe -> _member ? trace_context_ ## _member : NULL
2308bf215546Sopenharmony_ci
2309bf215546Sopenharmony_ci   TR_CTX_INIT(draw_vbo);
2310bf215546Sopenharmony_ci   TR_CTX_INIT(draw_vertex_state);
2311bf215546Sopenharmony_ci   TR_CTX_INIT(render_condition);
2312bf215546Sopenharmony_ci   TR_CTX_INIT(render_condition_mem);
2313bf215546Sopenharmony_ci   TR_CTX_INIT(create_query);
2314bf215546Sopenharmony_ci   TR_CTX_INIT(destroy_query);
2315bf215546Sopenharmony_ci   TR_CTX_INIT(begin_query);
2316bf215546Sopenharmony_ci   TR_CTX_INIT(end_query);
2317bf215546Sopenharmony_ci   TR_CTX_INIT(get_query_result);
2318bf215546Sopenharmony_ci   TR_CTX_INIT(get_query_result_resource);
2319bf215546Sopenharmony_ci   TR_CTX_INIT(set_active_query_state);
2320bf215546Sopenharmony_ci   TR_CTX_INIT(create_blend_state);
2321bf215546Sopenharmony_ci   TR_CTX_INIT(bind_blend_state);
2322bf215546Sopenharmony_ci   TR_CTX_INIT(delete_blend_state);
2323bf215546Sopenharmony_ci   TR_CTX_INIT(create_sampler_state);
2324bf215546Sopenharmony_ci   TR_CTX_INIT(bind_sampler_states);
2325bf215546Sopenharmony_ci   TR_CTX_INIT(delete_sampler_state);
2326bf215546Sopenharmony_ci   TR_CTX_INIT(create_rasterizer_state);
2327bf215546Sopenharmony_ci   TR_CTX_INIT(bind_rasterizer_state);
2328bf215546Sopenharmony_ci   TR_CTX_INIT(delete_rasterizer_state);
2329bf215546Sopenharmony_ci   TR_CTX_INIT(create_depth_stencil_alpha_state);
2330bf215546Sopenharmony_ci   TR_CTX_INIT(bind_depth_stencil_alpha_state);
2331bf215546Sopenharmony_ci   TR_CTX_INIT(delete_depth_stencil_alpha_state);
2332bf215546Sopenharmony_ci   TR_CTX_INIT(create_fs_state);
2333bf215546Sopenharmony_ci   TR_CTX_INIT(bind_fs_state);
2334bf215546Sopenharmony_ci   TR_CTX_INIT(delete_fs_state);
2335bf215546Sopenharmony_ci   TR_CTX_INIT(create_vs_state);
2336bf215546Sopenharmony_ci   TR_CTX_INIT(bind_vs_state);
2337bf215546Sopenharmony_ci   TR_CTX_INIT(delete_vs_state);
2338bf215546Sopenharmony_ci   TR_CTX_INIT(create_gs_state);
2339bf215546Sopenharmony_ci   TR_CTX_INIT(bind_gs_state);
2340bf215546Sopenharmony_ci   TR_CTX_INIT(delete_gs_state);
2341bf215546Sopenharmony_ci   TR_CTX_INIT(create_tcs_state);
2342bf215546Sopenharmony_ci   TR_CTX_INIT(bind_tcs_state);
2343bf215546Sopenharmony_ci   TR_CTX_INIT(delete_tcs_state);
2344bf215546Sopenharmony_ci   TR_CTX_INIT(create_tes_state);
2345bf215546Sopenharmony_ci   TR_CTX_INIT(bind_tes_state);
2346bf215546Sopenharmony_ci   TR_CTX_INIT(delete_tes_state);
2347bf215546Sopenharmony_ci   TR_CTX_INIT(create_compute_state);
2348bf215546Sopenharmony_ci   TR_CTX_INIT(bind_compute_state);
2349bf215546Sopenharmony_ci   TR_CTX_INIT(delete_compute_state);
2350bf215546Sopenharmony_ci   TR_CTX_INIT(link_shader);
2351bf215546Sopenharmony_ci   TR_CTX_INIT(create_vertex_elements_state);
2352bf215546Sopenharmony_ci   TR_CTX_INIT(bind_vertex_elements_state);
2353bf215546Sopenharmony_ci   TR_CTX_INIT(delete_vertex_elements_state);
2354bf215546Sopenharmony_ci   TR_CTX_INIT(set_blend_color);
2355bf215546Sopenharmony_ci   TR_CTX_INIT(set_stencil_ref);
2356bf215546Sopenharmony_ci   TR_CTX_INIT(set_clip_state);
2357bf215546Sopenharmony_ci   TR_CTX_INIT(set_sample_mask);
2358bf215546Sopenharmony_ci   TR_CTX_INIT(set_constant_buffer);
2359bf215546Sopenharmony_ci   TR_CTX_INIT(set_framebuffer_state);
2360bf215546Sopenharmony_ci   TR_CTX_INIT(set_inlinable_constants);
2361bf215546Sopenharmony_ci   TR_CTX_INIT(set_polygon_stipple);
2362bf215546Sopenharmony_ci   TR_CTX_INIT(set_min_samples);
2363bf215546Sopenharmony_ci   TR_CTX_INIT(set_scissor_states);
2364bf215546Sopenharmony_ci   TR_CTX_INIT(set_viewport_states);
2365bf215546Sopenharmony_ci   TR_CTX_INIT(set_sampler_views);
2366bf215546Sopenharmony_ci   TR_CTX_INIT(create_sampler_view);
2367bf215546Sopenharmony_ci   TR_CTX_INIT(sampler_view_destroy);
2368bf215546Sopenharmony_ci   TR_CTX_INIT(create_surface);
2369bf215546Sopenharmony_ci   TR_CTX_INIT(surface_destroy);
2370bf215546Sopenharmony_ci   TR_CTX_INIT(set_vertex_buffers);
2371bf215546Sopenharmony_ci   TR_CTX_INIT(create_stream_output_target);
2372bf215546Sopenharmony_ci   TR_CTX_INIT(stream_output_target_destroy);
2373bf215546Sopenharmony_ci   TR_CTX_INIT(set_stream_output_targets);
2374bf215546Sopenharmony_ci   /* this is lavapipe-only and can't be traced */
2375bf215546Sopenharmony_ci   tr_ctx->base.stream_output_target_offset = pipe->stream_output_target_offset;
2376bf215546Sopenharmony_ci   TR_CTX_INIT(resource_copy_region);
2377bf215546Sopenharmony_ci   TR_CTX_INIT(blit);
2378bf215546Sopenharmony_ci   TR_CTX_INIT(flush_resource);
2379bf215546Sopenharmony_ci   TR_CTX_INIT(clear);
2380bf215546Sopenharmony_ci   TR_CTX_INIT(clear_render_target);
2381bf215546Sopenharmony_ci   TR_CTX_INIT(clear_depth_stencil);
2382bf215546Sopenharmony_ci   TR_CTX_INIT(clear_texture);
2383bf215546Sopenharmony_ci   TR_CTX_INIT(clear_buffer);
2384bf215546Sopenharmony_ci   TR_CTX_INIT(flush);
2385bf215546Sopenharmony_ci   TR_CTX_INIT(create_fence_fd);
2386bf215546Sopenharmony_ci   TR_CTX_INIT(fence_server_sync);
2387bf215546Sopenharmony_ci   TR_CTX_INIT(fence_server_signal);
2388bf215546Sopenharmony_ci   TR_CTX_INIT(generate_mipmap);
2389bf215546Sopenharmony_ci   TR_CTX_INIT(texture_barrier);
2390bf215546Sopenharmony_ci   TR_CTX_INIT(memory_barrier);
2391bf215546Sopenharmony_ci   TR_CTX_INIT(resource_commit);
2392bf215546Sopenharmony_ci   TR_CTX_INIT(set_tess_state);
2393bf215546Sopenharmony_ci   TR_CTX_INIT(set_patch_vertices);
2394bf215546Sopenharmony_ci   TR_CTX_INIT(set_shader_buffers);
2395bf215546Sopenharmony_ci   TR_CTX_INIT(launch_grid);
2396bf215546Sopenharmony_ci   TR_CTX_INIT(set_shader_images);
2397bf215546Sopenharmony_ci   TR_CTX_INIT(create_texture_handle);
2398bf215546Sopenharmony_ci   TR_CTX_INIT(delete_texture_handle);
2399bf215546Sopenharmony_ci   TR_CTX_INIT(make_texture_handle_resident);
2400bf215546Sopenharmony_ci   TR_CTX_INIT(create_image_handle);
2401bf215546Sopenharmony_ci   TR_CTX_INIT(delete_image_handle);
2402bf215546Sopenharmony_ci   TR_CTX_INIT(make_image_handle_resident);
2403bf215546Sopenharmony_ci
2404bf215546Sopenharmony_ci   tr_ctx->base.buffer_map = tr_ctx->base.texture_map = trace_context_transfer_map;
2405bf215546Sopenharmony_ci   tr_ctx->base.buffer_unmap = tr_ctx->base.texture_unmap = trace_context_transfer_unmap;
2406bf215546Sopenharmony_ci   TR_CTX_INIT(transfer_flush_region);
2407bf215546Sopenharmony_ci   TR_CTX_INIT(buffer_subdata);
2408bf215546Sopenharmony_ci   TR_CTX_INIT(texture_subdata);
2409bf215546Sopenharmony_ci   TR_CTX_INIT(invalidate_resource);
2410bf215546Sopenharmony_ci   TR_CTX_INIT(set_context_param);
2411bf215546Sopenharmony_ci   TR_CTX_INIT(set_debug_callback);
2412bf215546Sopenharmony_ci
2413bf215546Sopenharmony_ci#undef TR_CTX_INIT
2414bf215546Sopenharmony_ci
2415bf215546Sopenharmony_ci   tr_ctx->pipe = pipe;
2416bf215546Sopenharmony_ci
2417bf215546Sopenharmony_ci   return &tr_ctx->base;
2418bf215546Sopenharmony_ci
2419bf215546Sopenharmony_cierror1:
2420bf215546Sopenharmony_ci   return pipe;
2421bf215546Sopenharmony_ci}
2422bf215546Sopenharmony_ci
2423bf215546Sopenharmony_ci
2424bf215546Sopenharmony_ci/**
2425bf215546Sopenharmony_ci * Sanity checker: check that the given context really is a
2426bf215546Sopenharmony_ci * trace context (and not the wrapped driver's context).
2427bf215546Sopenharmony_ci */
2428bf215546Sopenharmony_civoid
2429bf215546Sopenharmony_citrace_context_check(const struct pipe_context *pipe)
2430bf215546Sopenharmony_ci{
2431bf215546Sopenharmony_ci   ASSERTED struct trace_context *tr_ctx = (struct trace_context *) pipe;
2432bf215546Sopenharmony_ci   assert(tr_ctx->base.destroy == trace_context_destroy);
2433bf215546Sopenharmony_ci}
2434bf215546Sopenharmony_ci
2435bf215546Sopenharmony_ci/**
2436bf215546Sopenharmony_ci * Threaded context is not wrapped, and so it may call fence functions directly
2437bf215546Sopenharmony_ci */
2438bf215546Sopenharmony_cistruct pipe_context *
2439bf215546Sopenharmony_citrace_get_possibly_threaded_context(struct pipe_context *pipe)
2440bf215546Sopenharmony_ci{
2441bf215546Sopenharmony_ci   return pipe->destroy == trace_context_destroy ? ((struct trace_context*)pipe)->pipe : pipe;
2442bf215546Sopenharmony_ci}
2443