1 /**************************************************************************
3 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Copyright 2008 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * on the rights to use, copy, modify, merge, publish, distribute, sub
11 * license, and/or sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 #include "util/u_dump.h"
31 #include "util/u_format.h"
32 #include "tgsi/tgsi_scan.h"
39 CALL_RESOURCE_COPY_REGION
,
44 CALL_CLEAR_RENDER_TARGET
,
45 CALL_CLEAR_DEPTH_STENCIL
,
49 struct call_resource_copy_region
51 struct pipe_resource
*dst
;
53 unsigned dstx
, dsty
, dstz
;
54 struct pipe_resource
*src
;
56 const struct pipe_box
*src_box
;
62 const union pipe_color_union
*color
;
67 struct call_clear_buffer
69 struct pipe_resource
*res
;
72 const void *clear_value
;
76 struct call_generate_mipmap
{
77 struct pipe_resource
*res
;
78 enum pipe_format format
;
90 struct pipe_draw_info draw_vbo
;
91 struct pipe_grid_info launch_grid
;
92 struct call_resource_copy_region resource_copy_region
;
93 struct pipe_blit_info blit
;
94 struct pipe_resource
*flush_resource
;
95 struct call_clear clear
;
96 struct call_clear_buffer clear_buffer
;
97 struct call_generate_mipmap generate_mipmap
;
102 dd_get_file_stream(struct dd_context
*dctx
)
104 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
105 struct pipe_screen
*screen
= dctx
->pipe
->screen
;
106 FILE *f
= dd_get_debug_file(dscreen
->verbose
);
110 fprintf(f
, "Driver vendor: %s\n", screen
->get_vendor(screen
));
111 fprintf(f
, "Device vendor: %s\n", screen
->get_device_vendor(screen
));
112 fprintf(f
, "Device name: %s\n\n", screen
->get_name(screen
));
114 if (dctx
->apitrace_call_number
)
115 fprintf(f
, "Last apitrace call: %u\n\n",
116 dctx
->apitrace_call_number
);
121 dd_close_file_stream(FILE *f
)
127 dd_num_active_viewports(struct dd_context
*dctx
)
129 struct tgsi_shader_info info
;
130 const struct tgsi_token
*tokens
;
132 if (dctx
->shaders
[PIPE_SHADER_GEOMETRY
])
133 tokens
= dctx
->shaders
[PIPE_SHADER_GEOMETRY
]->state
.shader
.tokens
;
134 else if (dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
135 tokens
= dctx
->shaders
[PIPE_SHADER_TESS_EVAL
]->state
.shader
.tokens
;
136 else if (dctx
->shaders
[PIPE_SHADER_VERTEX
])
137 tokens
= dctx
->shaders
[PIPE_SHADER_VERTEX
]->state
.shader
.tokens
;
141 tgsi_scan_shader(tokens
, &info
);
142 return info
.writes_viewport_index
? PIPE_MAX_VIEWPORTS
: 1;
145 #define COLOR_RESET "\033[0m"
146 #define COLOR_SHADER "\033[1;32m"
147 #define COLOR_STATE "\033[1;33m"
149 #define DUMP(name, var) do { \
150 fprintf(f, COLOR_STATE #name ": " COLOR_RESET); \
151 util_dump_##name(f, var); \
155 #define DUMP_I(name, var, i) do { \
156 fprintf(f, COLOR_STATE #name " %i: " COLOR_RESET, i); \
157 util_dump_##name(f, var); \
161 #define DUMP_M(name, var, member) do { \
162 fprintf(f, " " #member ": "); \
163 util_dump_##name(f, (var)->member); \
167 #define DUMP_M_ADDR(name, var, member) do { \
168 fprintf(f, " " #member ": "); \
169 util_dump_##name(f, &(var)->member); \
174 print_named_value(FILE *f
, const char *name
, int value
)
176 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = %i\n", name
, value
);
180 print_named_xvalue(FILE *f
, const char *name
, int value
)
182 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = 0x%08x\n", name
, value
);
186 util_dump_uint(FILE *f
, unsigned i
)
192 util_dump_hex(FILE *f
, unsigned i
)
194 fprintf(f
, "0x%x", i
);
198 util_dump_double(FILE *f
, double d
)
204 util_dump_format(FILE *f
, enum pipe_format format
)
206 fprintf(f
, "%s", util_format_name(format
));
210 util_dump_color_union(FILE *f
, const union pipe_color_union
*color
)
212 fprintf(f
, "{f = {%f, %f, %f, %f}, ui = {%u, %u, %u, %u}",
213 color
->f
[0], color
->f
[1], color
->f
[2], color
->f
[3],
214 color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
218 util_dump_query(FILE *f
, struct dd_query
*query
)
220 if (query
->type
>= PIPE_QUERY_DRIVER_SPECIFIC
)
221 fprintf(f
, "PIPE_QUERY_DRIVER_SPECIFIC + %i",
222 query
->type
- PIPE_QUERY_DRIVER_SPECIFIC
);
224 fprintf(f
, "%s", util_dump_query_type(query
->type
, false));
228 dd_dump_render_condition(struct dd_context
*dctx
, FILE *f
)
230 if (dctx
->render_cond
.query
) {
231 fprintf(f
, "render condition:\n");
232 DUMP_M(query
, &dctx
->render_cond
, query
);
233 DUMP_M(uint
, &dctx
->render_cond
, condition
);
234 DUMP_M(uint
, &dctx
->render_cond
, mode
);
240 dd_dump_draw_vbo(struct dd_context
*dctx
, struct pipe_draw_info
*info
, FILE *f
)
243 const char *shader_str
[PIPE_SHADER_TYPES
];
245 shader_str
[PIPE_SHADER_VERTEX
] = "VERTEX";
246 shader_str
[PIPE_SHADER_TESS_CTRL
] = "TESS_CTRL";
247 shader_str
[PIPE_SHADER_TESS_EVAL
] = "TESS_EVAL";
248 shader_str
[PIPE_SHADER_GEOMETRY
] = "GEOMETRY";
249 shader_str
[PIPE_SHADER_FRAGMENT
] = "FRAGMENT";
250 shader_str
[PIPE_SHADER_COMPUTE
] = "COMPUTE";
252 DUMP(draw_info
, info
);
254 DUMP(index_buffer
, &dctx
->index_buffer
);
255 if (dctx
->index_buffer
.buffer
)
256 DUMP_M(resource
, &dctx
->index_buffer
, buffer
);
258 if (info
->count_from_stream_output
)
259 DUMP_M(stream_output_target
, info
,
260 count_from_stream_output
);
262 DUMP_M(resource
, info
, indirect
);
265 /* TODO: dump active queries */
267 dd_dump_render_condition(dctx
, f
);
269 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++)
270 if (dctx
->vertex_buffers
[i
].buffer
||
271 dctx
->vertex_buffers
[i
].user_buffer
) {
272 DUMP_I(vertex_buffer
, &dctx
->vertex_buffers
[i
], i
);
273 if (dctx
->vertex_buffers
[i
].buffer
)
274 DUMP_M(resource
, &dctx
->vertex_buffers
[i
], buffer
);
278 print_named_value(f
, "num vertex elements",
279 dctx
->velems
->state
.velems
.count
);
280 for (i
= 0; i
< dctx
->velems
->state
.velems
.count
; i
++) {
282 DUMP_I(vertex_element
, &dctx
->velems
->state
.velems
.velems
[i
], i
);
286 print_named_value(f
, "num stream output targets", dctx
->num_so_targets
);
287 for (i
= 0; i
< dctx
->num_so_targets
; i
++)
288 if (dctx
->so_targets
[i
]) {
289 DUMP_I(stream_output_target
, dctx
->so_targets
[i
], i
);
290 DUMP_M(resource
, dctx
->so_targets
[i
], buffer
);
291 fprintf(f
, " offset = %i\n", dctx
->so_offsets
[i
]);
295 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
296 if (sh
== PIPE_SHADER_COMPUTE
)
299 if (sh
== PIPE_SHADER_TESS_CTRL
&&
300 !dctx
->shaders
[PIPE_SHADER_TESS_CTRL
] &&
301 dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
302 fprintf(f
, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
303 "default_inner_level = {%f, %f}}\n",
304 dctx
->tess_default_levels
[0],
305 dctx
->tess_default_levels
[1],
306 dctx
->tess_default_levels
[2],
307 dctx
->tess_default_levels
[3],
308 dctx
->tess_default_levels
[4],
309 dctx
->tess_default_levels
[5]);
311 if (sh
== PIPE_SHADER_FRAGMENT
)
313 unsigned num_viewports
= dd_num_active_viewports(dctx
);
315 if (dctx
->rs
->state
.rs
.clip_plane_enable
)
316 DUMP(clip_state
, &dctx
->clip_state
);
318 for (i
= 0; i
< num_viewports
; i
++)
319 DUMP_I(viewport_state
, &dctx
->viewports
[i
], i
);
321 if (dctx
->rs
->state
.rs
.scissor
)
322 for (i
= 0; i
< num_viewports
; i
++)
323 DUMP_I(scissor_state
, &dctx
->scissors
[i
], i
);
325 DUMP(rasterizer_state
, &dctx
->rs
->state
.rs
);
327 if (dctx
->rs
->state
.rs
.poly_stipple_enable
)
328 DUMP(poly_stipple
, &dctx
->polygon_stipple
);
332 if (!dctx
->shaders
[sh
])
335 fprintf(f
, COLOR_SHADER
"begin shader: %s" COLOR_RESET
"\n", shader_str
[sh
]);
336 DUMP(shader_state
, &dctx
->shaders
[sh
]->state
.shader
);
338 for (i
= 0; i
< PIPE_MAX_CONSTANT_BUFFERS
; i
++)
339 if (dctx
->constant_buffers
[sh
][i
].buffer
||
340 dctx
->constant_buffers
[sh
][i
].user_buffer
) {
341 DUMP_I(constant_buffer
, &dctx
->constant_buffers
[sh
][i
], i
);
342 if (dctx
->constant_buffers
[sh
][i
].buffer
)
343 DUMP_M(resource
, &dctx
->constant_buffers
[sh
][i
], buffer
);
346 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
347 if (dctx
->sampler_states
[sh
][i
])
348 DUMP_I(sampler_state
, &dctx
->sampler_states
[sh
][i
]->state
.sampler
, i
);
350 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
351 if (dctx
->sampler_views
[sh
][i
]) {
352 DUMP_I(sampler_view
, dctx
->sampler_views
[sh
][i
], i
);
353 DUMP_M(resource
, dctx
->sampler_views
[sh
][i
], texture
);
356 /* TODO: print shader images */
357 /* TODO: print shader buffers */
359 fprintf(f
, COLOR_SHADER
"end shader: %s" COLOR_RESET
"\n\n", shader_str
[sh
]);
363 DUMP(depth_stencil_alpha_state
, &dctx
->dsa
->state
.dsa
);
364 DUMP(stencil_ref
, &dctx
->stencil_ref
);
367 DUMP(blend_state
, &dctx
->blend
->state
.blend
);
368 DUMP(blend_color
, &dctx
->blend_color
);
370 print_named_value(f
, "min_samples", dctx
->min_samples
);
371 print_named_xvalue(f
, "sample_mask", dctx
->sample_mask
);
374 DUMP(framebuffer_state
, &dctx
->framebuffer_state
);
375 for (i
= 0; i
< dctx
->framebuffer_state
.nr_cbufs
; i
++)
376 if (dctx
->framebuffer_state
.cbufs
[i
]) {
377 fprintf(f
, " " COLOR_STATE
"cbufs[%i]:" COLOR_RESET
"\n ", i
);
378 DUMP(surface
, dctx
->framebuffer_state
.cbufs
[i
]);
380 DUMP(resource
, dctx
->framebuffer_state
.cbufs
[i
]->texture
);
382 if (dctx
->framebuffer_state
.zsbuf
) {
383 fprintf(f
, " " COLOR_STATE
"zsbuf:" COLOR_RESET
"\n ");
384 DUMP(surface
, dctx
->framebuffer_state
.zsbuf
);
386 DUMP(resource
, dctx
->framebuffer_state
.zsbuf
->texture
);
392 dd_dump_launch_grid(struct dd_context
*dctx
, struct pipe_grid_info
*info
, FILE *f
)
394 fprintf(f
, "%s:\n", __func__
+8);
399 dd_dump_resource_copy_region(struct dd_context
*dctx
,
400 struct call_resource_copy_region
*info
,
403 fprintf(f
, "%s:\n", __func__
+8);
404 DUMP_M(resource
, info
, dst
);
405 DUMP_M(uint
, info
, dst_level
);
406 DUMP_M(uint
, info
, dstx
);
407 DUMP_M(uint
, info
, dsty
);
408 DUMP_M(uint
, info
, dstz
);
409 DUMP_M(resource
, info
, src
);
410 DUMP_M(uint
, info
, src_level
);
411 DUMP_M(box
, info
, src_box
);
415 dd_dump_blit(struct dd_context
*dctx
, struct pipe_blit_info
*info
, FILE *f
)
417 fprintf(f
, "%s:\n", __func__
+8);
418 DUMP_M(resource
, info
, dst
.resource
);
419 DUMP_M(uint
, info
, dst
.level
);
420 DUMP_M_ADDR(box
, info
, dst
.box
);
421 DUMP_M(format
, info
, dst
.format
);
423 DUMP_M(resource
, info
, src
.resource
);
424 DUMP_M(uint
, info
, src
.level
);
425 DUMP_M_ADDR(box
, info
, src
.box
);
426 DUMP_M(format
, info
, src
.format
);
428 DUMP_M(hex
, info
, mask
);
429 DUMP_M(uint
, info
, filter
);
430 DUMP_M(uint
, info
, scissor_enable
);
431 DUMP_M_ADDR(scissor_state
, info
, scissor
);
432 DUMP_M(uint
, info
, render_condition_enable
);
434 if (info
->render_condition_enable
)
435 dd_dump_render_condition(dctx
, f
);
439 dd_dump_generate_mipmap(struct dd_context
*dctx
, FILE *f
)
441 fprintf(f
, "%s:\n", __func__
+8);
446 dd_dump_flush_resource(struct dd_context
*dctx
, struct pipe_resource
*res
,
449 fprintf(f
, "%s:\n", __func__
+8);
454 dd_dump_clear(struct dd_context
*dctx
, struct call_clear
*info
, FILE *f
)
456 fprintf(f
, "%s:\n", __func__
+8);
457 DUMP_M(uint
, info
, buffers
);
458 DUMP_M(color_union
, info
, color
);
459 DUMP_M(double, info
, depth
);
460 DUMP_M(hex
, info
, stencil
);
464 dd_dump_clear_buffer(struct dd_context
*dctx
, struct call_clear_buffer
*info
,
468 const char *value
= (const char*)info
->clear_value
;
470 fprintf(f
, "%s:\n", __func__
+8);
471 DUMP_M(resource
, info
, res
);
472 DUMP_M(uint
, info
, offset
);
473 DUMP_M(uint
, info
, size
);
474 DUMP_M(uint
, info
, clear_value_size
);
476 fprintf(f
, " clear_value:");
477 for (i
= 0; i
< info
->clear_value_size
; i
++)
478 fprintf(f
, " %02x", value
[i
]);
483 dd_dump_clear_render_target(struct dd_context
*dctx
, FILE *f
)
485 fprintf(f
, "%s:\n", __func__
+8);
490 dd_dump_clear_depth_stencil(struct dd_context
*dctx
, FILE *f
)
492 fprintf(f
, "%s:\n", __func__
+8);
497 dd_dump_driver_state(struct dd_context
*dctx
, FILE *f
, unsigned flags
)
499 if (dctx
->pipe
->dump_debug_state
) {
500 fprintf(f
,"\n\n**************************************************"
501 "***************************\n");
502 fprintf(f
, "Driver-specific state:\n\n");
503 dctx
->pipe
->dump_debug_state(dctx
->pipe
, f
, flags
);
508 dd_dump_call(struct dd_context
*dctx
, struct dd_call
*call
, unsigned flags
)
510 FILE *f
= dd_get_file_stream(dctx
);
515 switch (call
->type
) {
517 dd_dump_draw_vbo(dctx
, &call
->info
.draw_vbo
, f
);
519 case CALL_LAUNCH_GRID
:
520 dd_dump_launch_grid(dctx
, &call
->info
.launch_grid
, f
);
522 case CALL_RESOURCE_COPY_REGION
:
523 dd_dump_resource_copy_region(dctx
, &call
->info
.resource_copy_region
, f
);
526 dd_dump_blit(dctx
, &call
->info
.blit
, f
);
528 case CALL_FLUSH_RESOURCE
:
529 dd_dump_flush_resource(dctx
, call
->info
.flush_resource
, f
);
532 dd_dump_clear(dctx
, &call
->info
.clear
, f
);
534 case CALL_CLEAR_BUFFER
:
535 dd_dump_clear_buffer(dctx
, &call
->info
.clear_buffer
, f
);
537 case CALL_CLEAR_RENDER_TARGET
:
538 dd_dump_clear_render_target(dctx
, f
);
540 case CALL_CLEAR_DEPTH_STENCIL
:
541 dd_dump_clear_depth_stencil(dctx
, f
);
543 case CALL_GENERATE_MIPMAP
:
544 dd_dump_generate_mipmap(dctx
, f
);
548 dd_dump_driver_state(dctx
, f
, flags
);
549 dd_close_file_stream(f
);
553 dd_kill_process(void)
556 fprintf(stderr
, "dd: Aborting the process...\n");
563 dd_flush_and_check_hang(struct dd_context
*dctx
,
564 struct pipe_fence_handle
**flush_fence
,
565 unsigned flush_flags
)
567 struct pipe_fence_handle
*fence
= NULL
;
568 struct pipe_context
*pipe
= dctx
->pipe
;
569 struct pipe_screen
*screen
= pipe
->screen
;
570 uint64_t timeout_ms
= dd_screen(dctx
->base
.screen
)->timeout_ms
;
573 assert(timeout_ms
> 0);
575 pipe
->flush(pipe
, &fence
, flush_flags
);
577 screen
->fence_reference(screen
, flush_fence
, fence
);
581 idle
= screen
->fence_finish(screen
, fence
, timeout_ms
* 1000000);
582 screen
->fence_reference(screen
, &fence
, NULL
);
584 fprintf(stderr
, "dd: GPU hang detected!\n");
589 dd_flush_and_handle_hang(struct dd_context
*dctx
,
590 struct pipe_fence_handle
**fence
, unsigned flags
,
593 if (dd_flush_and_check_hang(dctx
, fence
, flags
)) {
594 FILE *f
= dd_get_file_stream(dctx
);
597 fprintf(f
, "dd: %s.\n", cause
);
598 dd_dump_driver_state(dctx
, f
, PIPE_DEBUG_DEVICE_IS_HUNG
);
599 dd_close_file_stream(f
);
602 /* Terminate the process to prevent future hangs. */
608 dd_context_flush(struct pipe_context
*_pipe
,
609 struct pipe_fence_handle
**fence
, unsigned flags
)
611 struct dd_context
*dctx
= dd_context(_pipe
);
612 struct pipe_context
*pipe
= dctx
->pipe
;
614 switch (dd_screen(dctx
->base
.screen
)->mode
) {
615 case DD_DETECT_HANGS
:
616 dd_flush_and_handle_hang(dctx
, fence
, flags
,
617 "GPU hang detected in pipe->flush()");
619 case DD_DUMP_ALL_CALLS
:
620 case DD_DUMP_APITRACE_CALL
:
621 pipe
->flush(pipe
, fence
, flags
);
629 dd_before_draw(struct dd_context
*dctx
)
631 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
633 if (dscreen
->mode
== DD_DETECT_HANGS
&&
634 !dscreen
->no_flush
&&
635 dctx
->num_draw_calls
>= dscreen
->skip_count
)
636 dd_flush_and_handle_hang(dctx
, NULL
, 0,
637 "GPU hang most likely caused by internal "
642 dd_after_draw(struct dd_context
*dctx
, struct dd_call
*call
)
644 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
645 struct pipe_context
*pipe
= dctx
->pipe
;
647 if (dctx
->num_draw_calls
>= dscreen
->skip_count
) {
648 switch (dscreen
->mode
) {
649 case DD_DETECT_HANGS
:
650 if (!dscreen
->no_flush
&&
651 dd_flush_and_check_hang(dctx
, NULL
, 0)) {
652 dd_dump_call(dctx
, call
, PIPE_DEBUG_DEVICE_IS_HUNG
);
654 /* Terminate the process to prevent future hangs. */
658 case DD_DUMP_ALL_CALLS
:
659 if (!dscreen
->no_flush
)
660 pipe
->flush(pipe
, NULL
, 0);
661 dd_dump_call(dctx
, call
, 0);
663 case DD_DUMP_APITRACE_CALL
:
664 if (dscreen
->apitrace_dump_call
== dctx
->apitrace_call_number
) {
665 dd_dump_call(dctx
, call
, 0);
666 /* No need to continue. */
675 ++dctx
->num_draw_calls
;
676 if (dscreen
->skip_count
&& dctx
->num_draw_calls
% 10000 == 0)
677 fprintf(stderr
, "Gallium debugger reached %u draw calls.\n",
678 dctx
->num_draw_calls
);
682 dd_context_draw_vbo(struct pipe_context
*_pipe
,
683 const struct pipe_draw_info
*info
)
685 struct dd_context
*dctx
= dd_context(_pipe
);
686 struct pipe_context
*pipe
= dctx
->pipe
;
689 call
.type
= CALL_DRAW_VBO
;
690 call
.info
.draw_vbo
= *info
;
692 dd_before_draw(dctx
);
693 pipe
->draw_vbo(pipe
, info
);
694 dd_after_draw(dctx
, &call
);
698 dd_context_launch_grid(struct pipe_context
*_pipe
,
699 const struct pipe_grid_info
*info
)
701 struct dd_context
*dctx
= dd_context(_pipe
);
702 struct pipe_context
*pipe
= dctx
->pipe
;
705 call
.type
= CALL_LAUNCH_GRID
;
706 call
.info
.launch_grid
= *info
;
708 dd_before_draw(dctx
);
709 pipe
->launch_grid(pipe
, info
);
710 dd_after_draw(dctx
, &call
);
714 dd_context_resource_copy_region(struct pipe_context
*_pipe
,
715 struct pipe_resource
*dst
, unsigned dst_level
,
716 unsigned dstx
, unsigned dsty
, unsigned dstz
,
717 struct pipe_resource
*src
, unsigned src_level
,
718 const struct pipe_box
*src_box
)
720 struct dd_context
*dctx
= dd_context(_pipe
);
721 struct pipe_context
*pipe
= dctx
->pipe
;
724 call
.type
= CALL_RESOURCE_COPY_REGION
;
725 call
.info
.resource_copy_region
.dst
= dst
;
726 call
.info
.resource_copy_region
.dst_level
= dst_level
;
727 call
.info
.resource_copy_region
.dstx
= dstx
;
728 call
.info
.resource_copy_region
.dsty
= dsty
;
729 call
.info
.resource_copy_region
.dstz
= dstz
;
730 call
.info
.resource_copy_region
.src
= src
;
731 call
.info
.resource_copy_region
.src_level
= src_level
;
732 call
.info
.resource_copy_region
.src_box
= src_box
;
734 dd_before_draw(dctx
);
735 pipe
->resource_copy_region(pipe
,
736 dst
, dst_level
, dstx
, dsty
, dstz
,
737 src
, src_level
, src_box
);
738 dd_after_draw(dctx
, &call
);
742 dd_context_blit(struct pipe_context
*_pipe
, const struct pipe_blit_info
*info
)
744 struct dd_context
*dctx
= dd_context(_pipe
);
745 struct pipe_context
*pipe
= dctx
->pipe
;
748 call
.type
= CALL_BLIT
;
749 call
.info
.blit
= *info
;
751 dd_before_draw(dctx
);
752 pipe
->blit(pipe
, info
);
753 dd_after_draw(dctx
, &call
);
757 dd_context_generate_mipmap(struct pipe_context
*_pipe
,
758 struct pipe_resource
*res
,
759 enum pipe_format format
,
762 unsigned first_layer
,
765 struct dd_context
*dctx
= dd_context(_pipe
);
766 struct pipe_context
*pipe
= dctx
->pipe
;
770 call
.type
= CALL_GENERATE_MIPMAP
;
771 call
.info
.generate_mipmap
.res
= res
;
772 call
.info
.generate_mipmap
.format
= format
;
773 call
.info
.generate_mipmap
.base_level
= base_level
;
774 call
.info
.generate_mipmap
.last_level
= last_level
;
775 call
.info
.generate_mipmap
.first_layer
= first_layer
;
776 call
.info
.generate_mipmap
.last_layer
= last_layer
;
778 dd_before_draw(dctx
);
779 result
= pipe
->generate_mipmap(pipe
, res
, format
, base_level
, last_level
,
780 first_layer
, last_layer
);
781 dd_after_draw(dctx
, &call
);
786 dd_context_flush_resource(struct pipe_context
*_pipe
,
787 struct pipe_resource
*resource
)
789 struct dd_context
*dctx
= dd_context(_pipe
);
790 struct pipe_context
*pipe
= dctx
->pipe
;
793 call
.type
= CALL_FLUSH_RESOURCE
;
794 call
.info
.flush_resource
= resource
;
796 dd_before_draw(dctx
);
797 pipe
->flush_resource(pipe
, resource
);
798 dd_after_draw(dctx
, &call
);
802 dd_context_clear(struct pipe_context
*_pipe
, unsigned buffers
,
803 const union pipe_color_union
*color
, double depth
,
806 struct dd_context
*dctx
= dd_context(_pipe
);
807 struct pipe_context
*pipe
= dctx
->pipe
;
810 call
.type
= CALL_CLEAR
;
811 call
.info
.clear
.buffers
= buffers
;
812 call
.info
.clear
.color
= color
;
813 call
.info
.clear
.depth
= depth
;
814 call
.info
.clear
.stencil
= stencil
;
816 dd_before_draw(dctx
);
817 pipe
->clear(pipe
, buffers
, color
, depth
, stencil
);
818 dd_after_draw(dctx
, &call
);
822 dd_context_clear_render_target(struct pipe_context
*_pipe
,
823 struct pipe_surface
*dst
,
824 const union pipe_color_union
*color
,
825 unsigned dstx
, unsigned dsty
,
826 unsigned width
, unsigned height
)
828 struct dd_context
*dctx
= dd_context(_pipe
);
829 struct pipe_context
*pipe
= dctx
->pipe
;
832 call
.type
= CALL_CLEAR_RENDER_TARGET
;
834 dd_before_draw(dctx
);
835 pipe
->clear_render_target(pipe
, dst
, color
, dstx
, dsty
, width
, height
);
836 dd_after_draw(dctx
, &call
);
840 dd_context_clear_depth_stencil(struct pipe_context
*_pipe
,
841 struct pipe_surface
*dst
, unsigned clear_flags
,
842 double depth
, unsigned stencil
, unsigned dstx
,
843 unsigned dsty
, unsigned width
, unsigned height
)
845 struct dd_context
*dctx
= dd_context(_pipe
);
846 struct pipe_context
*pipe
= dctx
->pipe
;
849 call
.type
= CALL_CLEAR_DEPTH_STENCIL
;
851 dd_before_draw(dctx
);
852 pipe
->clear_depth_stencil(pipe
, dst
, clear_flags
, depth
, stencil
,
853 dstx
, dsty
, width
, height
);
854 dd_after_draw(dctx
, &call
);
858 dd_context_clear_buffer(struct pipe_context
*_pipe
, struct pipe_resource
*res
,
859 unsigned offset
, unsigned size
,
860 const void *clear_value
, int clear_value_size
)
862 struct dd_context
*dctx
= dd_context(_pipe
);
863 struct pipe_context
*pipe
= dctx
->pipe
;
866 call
.type
= CALL_CLEAR_BUFFER
;
867 call
.info
.clear_buffer
.res
= res
;
868 call
.info
.clear_buffer
.offset
= offset
;
869 call
.info
.clear_buffer
.size
= size
;
870 call
.info
.clear_buffer
.clear_value
= clear_value
;
871 call
.info
.clear_buffer
.clear_value_size
= clear_value_size
;
873 dd_before_draw(dctx
);
874 pipe
->clear_buffer(pipe
, res
, offset
, size
, clear_value
, clear_value_size
);
875 dd_after_draw(dctx
, &call
);
879 dd_init_draw_functions(struct dd_context
*dctx
)
883 CTX_INIT(launch_grid
);
884 CTX_INIT(resource_copy_region
);
887 CTX_INIT(clear_render_target
);
888 CTX_INIT(clear_depth_stencil
);
889 CTX_INIT(clear_buffer
);
890 CTX_INIT(flush_resource
);
891 CTX_INIT(generate_mipmap
);