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_screen
*dscreen
, unsigned apitrace_call_number
)
104 struct pipe_screen
*screen
= dscreen
->screen
;
105 FILE *f
= dd_get_debug_file(dscreen
->verbose
);
109 fprintf(f
, "Driver vendor: %s\n", screen
->get_vendor(screen
));
110 fprintf(f
, "Device vendor: %s\n", screen
->get_device_vendor(screen
));
111 fprintf(f
, "Device name: %s\n\n", screen
->get_name(screen
));
113 if (apitrace_call_number
)
114 fprintf(f
, "Last apitrace call: %u\n\n",
115 apitrace_call_number
);
120 dd_dump_dmesg(FILE *f
)
123 FILE *p
= popen("dmesg | tail -n60", "r");
128 fprintf(f
, "\nLast 60 lines of dmesg:\n\n");
129 while (fgets(line
, sizeof(line
), p
))
136 dd_close_file_stream(FILE *f
)
142 dd_num_active_viewports(struct dd_draw_state
*dstate
)
144 struct tgsi_shader_info info
;
145 const struct tgsi_token
*tokens
;
147 if (dstate
->shaders
[PIPE_SHADER_GEOMETRY
])
148 tokens
= dstate
->shaders
[PIPE_SHADER_GEOMETRY
]->state
.shader
.tokens
;
149 else if (dstate
->shaders
[PIPE_SHADER_TESS_EVAL
])
150 tokens
= dstate
->shaders
[PIPE_SHADER_TESS_EVAL
]->state
.shader
.tokens
;
151 else if (dstate
->shaders
[PIPE_SHADER_VERTEX
])
152 tokens
= dstate
->shaders
[PIPE_SHADER_VERTEX
]->state
.shader
.tokens
;
156 tgsi_scan_shader(tokens
, &info
);
157 return info
.writes_viewport_index
? PIPE_MAX_VIEWPORTS
: 1;
160 #define COLOR_RESET "\033[0m"
161 #define COLOR_SHADER "\033[1;32m"
162 #define COLOR_STATE "\033[1;33m"
164 #define DUMP(name, var) do { \
165 fprintf(f, COLOR_STATE #name ": " COLOR_RESET); \
166 util_dump_##name(f, var); \
170 #define DUMP_I(name, var, i) do { \
171 fprintf(f, COLOR_STATE #name " %i: " COLOR_RESET, i); \
172 util_dump_##name(f, var); \
176 #define DUMP_M(name, var, member) do { \
177 fprintf(f, " " #member ": "); \
178 util_dump_##name(f, (var)->member); \
182 #define DUMP_M_ADDR(name, var, member) do { \
183 fprintf(f, " " #member ": "); \
184 util_dump_##name(f, &(var)->member); \
189 print_named_value(FILE *f
, const char *name
, int value
)
191 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = %i\n", name
, value
);
195 print_named_xvalue(FILE *f
, const char *name
, int value
)
197 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = 0x%08x\n", name
, value
);
201 util_dump_uint(FILE *f
, unsigned i
)
207 util_dump_hex(FILE *f
, unsigned i
)
209 fprintf(f
, "0x%x", i
);
213 util_dump_double(FILE *f
, double d
)
219 util_dump_format(FILE *f
, enum pipe_format format
)
221 fprintf(f
, "%s", util_format_name(format
));
225 util_dump_color_union(FILE *f
, const union pipe_color_union
*color
)
227 fprintf(f
, "{f = {%f, %f, %f, %f}, ui = {%u, %u, %u, %u}",
228 color
->f
[0], color
->f
[1], color
->f
[2], color
->f
[3],
229 color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
233 util_dump_query(FILE *f
, struct dd_query
*query
)
235 if (query
->type
>= PIPE_QUERY_DRIVER_SPECIFIC
)
236 fprintf(f
, "PIPE_QUERY_DRIVER_SPECIFIC + %i",
237 query
->type
- PIPE_QUERY_DRIVER_SPECIFIC
);
239 fprintf(f
, "%s", util_dump_query_type(query
->type
, false));
243 dd_dump_render_condition(struct dd_draw_state
*dstate
, FILE *f
)
245 if (dstate
->render_cond
.query
) {
246 fprintf(f
, "render condition:\n");
247 DUMP_M(query
, &dstate
->render_cond
, query
);
248 DUMP_M(uint
, &dstate
->render_cond
, condition
);
249 DUMP_M(uint
, &dstate
->render_cond
, mode
);
255 dd_dump_draw_vbo(struct dd_draw_state
*dstate
, struct pipe_draw_info
*info
, FILE *f
)
258 const char *shader_str
[PIPE_SHADER_TYPES
];
260 shader_str
[PIPE_SHADER_VERTEX
] = "VERTEX";
261 shader_str
[PIPE_SHADER_TESS_CTRL
] = "TESS_CTRL";
262 shader_str
[PIPE_SHADER_TESS_EVAL
] = "TESS_EVAL";
263 shader_str
[PIPE_SHADER_GEOMETRY
] = "GEOMETRY";
264 shader_str
[PIPE_SHADER_FRAGMENT
] = "FRAGMENT";
265 shader_str
[PIPE_SHADER_COMPUTE
] = "COMPUTE";
267 DUMP(draw_info
, info
);
269 DUMP(index_buffer
, &dstate
->index_buffer
);
270 if (dstate
->index_buffer
.buffer
)
271 DUMP_M(resource
, &dstate
->index_buffer
, buffer
);
273 if (info
->count_from_stream_output
)
274 DUMP_M(stream_output_target
, info
,
275 count_from_stream_output
);
277 DUMP_M(resource
, info
, indirect
);
280 /* TODO: dump active queries */
282 dd_dump_render_condition(dstate
, f
);
284 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++)
285 if (dstate
->vertex_buffers
[i
].buffer
||
286 dstate
->vertex_buffers
[i
].user_buffer
) {
287 DUMP_I(vertex_buffer
, &dstate
->vertex_buffers
[i
], i
);
288 if (dstate
->vertex_buffers
[i
].buffer
)
289 DUMP_M(resource
, &dstate
->vertex_buffers
[i
], buffer
);
292 if (dstate
->velems
) {
293 print_named_value(f
, "num vertex elements",
294 dstate
->velems
->state
.velems
.count
);
295 for (i
= 0; i
< dstate
->velems
->state
.velems
.count
; i
++) {
297 DUMP_I(vertex_element
, &dstate
->velems
->state
.velems
.velems
[i
], i
);
301 print_named_value(f
, "num stream output targets", dstate
->num_so_targets
);
302 for (i
= 0; i
< dstate
->num_so_targets
; i
++)
303 if (dstate
->so_targets
[i
]) {
304 DUMP_I(stream_output_target
, dstate
->so_targets
[i
], i
);
305 DUMP_M(resource
, dstate
->so_targets
[i
], buffer
);
306 fprintf(f
, " offset = %i\n", dstate
->so_offsets
[i
]);
310 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
311 if (sh
== PIPE_SHADER_COMPUTE
)
314 if (sh
== PIPE_SHADER_TESS_CTRL
&&
315 !dstate
->shaders
[PIPE_SHADER_TESS_CTRL
] &&
316 dstate
->shaders
[PIPE_SHADER_TESS_EVAL
])
317 fprintf(f
, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
318 "default_inner_level = {%f, %f}}\n",
319 dstate
->tess_default_levels
[0],
320 dstate
->tess_default_levels
[1],
321 dstate
->tess_default_levels
[2],
322 dstate
->tess_default_levels
[3],
323 dstate
->tess_default_levels
[4],
324 dstate
->tess_default_levels
[5]);
326 if (sh
== PIPE_SHADER_FRAGMENT
)
328 unsigned num_viewports
= dd_num_active_viewports(dstate
);
330 if (dstate
->rs
->state
.rs
.clip_plane_enable
)
331 DUMP(clip_state
, &dstate
->clip_state
);
333 for (i
= 0; i
< num_viewports
; i
++)
334 DUMP_I(viewport_state
, &dstate
->viewports
[i
], i
);
336 if (dstate
->rs
->state
.rs
.scissor
)
337 for (i
= 0; i
< num_viewports
; i
++)
338 DUMP_I(scissor_state
, &dstate
->scissors
[i
], i
);
340 DUMP(rasterizer_state
, &dstate
->rs
->state
.rs
);
342 if (dstate
->rs
->state
.rs
.poly_stipple_enable
)
343 DUMP(poly_stipple
, &dstate
->polygon_stipple
);
347 if (!dstate
->shaders
[sh
])
350 fprintf(f
, COLOR_SHADER
"begin shader: %s" COLOR_RESET
"\n", shader_str
[sh
]);
351 DUMP(shader_state
, &dstate
->shaders
[sh
]->state
.shader
);
353 for (i
= 0; i
< PIPE_MAX_CONSTANT_BUFFERS
; i
++)
354 if (dstate
->constant_buffers
[sh
][i
].buffer
||
355 dstate
->constant_buffers
[sh
][i
].user_buffer
) {
356 DUMP_I(constant_buffer
, &dstate
->constant_buffers
[sh
][i
], i
);
357 if (dstate
->constant_buffers
[sh
][i
].buffer
)
358 DUMP_M(resource
, &dstate
->constant_buffers
[sh
][i
], buffer
);
361 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
362 if (dstate
->sampler_states
[sh
][i
])
363 DUMP_I(sampler_state
, &dstate
->sampler_states
[sh
][i
]->state
.sampler
, i
);
365 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
366 if (dstate
->sampler_views
[sh
][i
]) {
367 DUMP_I(sampler_view
, dstate
->sampler_views
[sh
][i
], i
);
368 DUMP_M(resource
, dstate
->sampler_views
[sh
][i
], texture
);
371 /* TODO: print shader images */
372 /* TODO: print shader buffers */
374 fprintf(f
, COLOR_SHADER
"end shader: %s" COLOR_RESET
"\n\n", shader_str
[sh
]);
378 DUMP(depth_stencil_alpha_state
, &dstate
->dsa
->state
.dsa
);
379 DUMP(stencil_ref
, &dstate
->stencil_ref
);
382 DUMP(blend_state
, &dstate
->blend
->state
.blend
);
383 DUMP(blend_color
, &dstate
->blend_color
);
385 print_named_value(f
, "min_samples", dstate
->min_samples
);
386 print_named_xvalue(f
, "sample_mask", dstate
->sample_mask
);
389 DUMP(framebuffer_state
, &dstate
->framebuffer_state
);
390 for (i
= 0; i
< dstate
->framebuffer_state
.nr_cbufs
; i
++)
391 if (dstate
->framebuffer_state
.cbufs
[i
]) {
392 fprintf(f
, " " COLOR_STATE
"cbufs[%i]:" COLOR_RESET
"\n ", i
);
393 DUMP(surface
, dstate
->framebuffer_state
.cbufs
[i
]);
395 DUMP(resource
, dstate
->framebuffer_state
.cbufs
[i
]->texture
);
397 if (dstate
->framebuffer_state
.zsbuf
) {
398 fprintf(f
, " " COLOR_STATE
"zsbuf:" COLOR_RESET
"\n ");
399 DUMP(surface
, dstate
->framebuffer_state
.zsbuf
);
401 DUMP(resource
, dstate
->framebuffer_state
.zsbuf
->texture
);
407 dd_dump_launch_grid(struct dd_draw_state
*dstate
, struct pipe_grid_info
*info
, FILE *f
)
409 fprintf(f
, "%s:\n", __func__
+8);
414 dd_dump_resource_copy_region(struct dd_draw_state
*dstate
,
415 struct call_resource_copy_region
*info
,
418 fprintf(f
, "%s:\n", __func__
+8);
419 DUMP_M(resource
, info
, dst
);
420 DUMP_M(uint
, info
, dst_level
);
421 DUMP_M(uint
, info
, dstx
);
422 DUMP_M(uint
, info
, dsty
);
423 DUMP_M(uint
, info
, dstz
);
424 DUMP_M(resource
, info
, src
);
425 DUMP_M(uint
, info
, src_level
);
426 DUMP_M(box
, info
, src_box
);
430 dd_dump_blit(struct dd_draw_state
*dstate
, struct pipe_blit_info
*info
, FILE *f
)
432 fprintf(f
, "%s:\n", __func__
+8);
433 DUMP_M(resource
, info
, dst
.resource
);
434 DUMP_M(uint
, info
, dst
.level
);
435 DUMP_M_ADDR(box
, info
, dst
.box
);
436 DUMP_M(format
, info
, dst
.format
);
438 DUMP_M(resource
, info
, src
.resource
);
439 DUMP_M(uint
, info
, src
.level
);
440 DUMP_M_ADDR(box
, info
, src
.box
);
441 DUMP_M(format
, info
, src
.format
);
443 DUMP_M(hex
, info
, mask
);
444 DUMP_M(uint
, info
, filter
);
445 DUMP_M(uint
, info
, scissor_enable
);
446 DUMP_M_ADDR(scissor_state
, info
, scissor
);
447 DUMP_M(uint
, info
, render_condition_enable
);
449 if (info
->render_condition_enable
)
450 dd_dump_render_condition(dstate
, f
);
454 dd_dump_generate_mipmap(struct dd_draw_state
*dstate
, FILE *f
)
456 fprintf(f
, "%s:\n", __func__
+8);
461 dd_dump_flush_resource(struct dd_draw_state
*dstate
, struct pipe_resource
*res
,
464 fprintf(f
, "%s:\n", __func__
+8);
469 dd_dump_clear(struct dd_draw_state
*dstate
, struct call_clear
*info
, FILE *f
)
471 fprintf(f
, "%s:\n", __func__
+8);
472 DUMP_M(uint
, info
, buffers
);
473 DUMP_M(color_union
, info
, color
);
474 DUMP_M(double, info
, depth
);
475 DUMP_M(hex
, info
, stencil
);
479 dd_dump_clear_buffer(struct dd_draw_state
*dstate
, struct call_clear_buffer
*info
,
483 const char *value
= (const char*)info
->clear_value
;
485 fprintf(f
, "%s:\n", __func__
+8);
486 DUMP_M(resource
, info
, res
);
487 DUMP_M(uint
, info
, offset
);
488 DUMP_M(uint
, info
, size
);
489 DUMP_M(uint
, info
, clear_value_size
);
491 fprintf(f
, " clear_value:");
492 for (i
= 0; i
< info
->clear_value_size
; i
++)
493 fprintf(f
, " %02x", value
[i
]);
498 dd_dump_clear_render_target(struct dd_draw_state
*dstate
, FILE *f
)
500 fprintf(f
, "%s:\n", __func__
+8);
505 dd_dump_clear_depth_stencil(struct dd_draw_state
*dstate
, FILE *f
)
507 fprintf(f
, "%s:\n", __func__
+8);
512 dd_dump_driver_state(struct dd_context
*dctx
, FILE *f
, unsigned flags
)
514 if (dctx
->pipe
->dump_debug_state
) {
515 fprintf(f
,"\n\n**************************************************"
516 "***************************\n");
517 fprintf(f
, "Driver-specific state:\n\n");
518 dctx
->pipe
->dump_debug_state(dctx
->pipe
, f
, flags
);
523 dd_dump_call(FILE *f
, struct dd_draw_state
*state
, struct dd_call
*call
)
525 switch (call
->type
) {
527 dd_dump_draw_vbo(state
, &call
->info
.draw_vbo
, f
);
529 case CALL_LAUNCH_GRID
:
530 dd_dump_launch_grid(state
, &call
->info
.launch_grid
, f
);
532 case CALL_RESOURCE_COPY_REGION
:
533 dd_dump_resource_copy_region(state
,
534 &call
->info
.resource_copy_region
, f
);
537 dd_dump_blit(state
, &call
->info
.blit
, f
);
539 case CALL_FLUSH_RESOURCE
:
540 dd_dump_flush_resource(state
, call
->info
.flush_resource
, f
);
543 dd_dump_clear(state
, &call
->info
.clear
, f
);
545 case CALL_CLEAR_BUFFER
:
546 dd_dump_clear_buffer(state
, &call
->info
.clear_buffer
, f
);
548 case CALL_CLEAR_RENDER_TARGET
:
549 dd_dump_clear_render_target(state
, f
);
551 case CALL_CLEAR_DEPTH_STENCIL
:
552 dd_dump_clear_depth_stencil(state
, f
);
554 case CALL_GENERATE_MIPMAP
:
555 dd_dump_generate_mipmap(state
, f
);
561 dd_write_report(struct dd_context
*dctx
, struct dd_call
*call
, unsigned flags
,
564 FILE *f
= dd_get_file_stream(dd_screen(dctx
->base
.screen
),
565 dctx
->draw_state
.apitrace_call_number
);
570 dd_dump_call(f
, &dctx
->draw_state
, call
);
571 dd_dump_driver_state(dctx
, f
, flags
);
574 dd_close_file_stream(f
);
578 dd_kill_process(void)
581 fprintf(stderr
, "dd: Aborting the process...\n");
588 dd_flush_and_check_hang(struct dd_context
*dctx
,
589 struct pipe_fence_handle
**flush_fence
,
590 unsigned flush_flags
)
592 struct pipe_fence_handle
*fence
= NULL
;
593 struct pipe_context
*pipe
= dctx
->pipe
;
594 struct pipe_screen
*screen
= pipe
->screen
;
595 uint64_t timeout_ms
= dd_screen(dctx
->base
.screen
)->timeout_ms
;
598 assert(timeout_ms
> 0);
600 pipe
->flush(pipe
, &fence
, flush_flags
);
602 screen
->fence_reference(screen
, flush_fence
, fence
);
606 idle
= screen
->fence_finish(screen
, fence
, timeout_ms
* 1000000);
607 screen
->fence_reference(screen
, &fence
, NULL
);
609 fprintf(stderr
, "dd: GPU hang detected!\n");
614 dd_flush_and_handle_hang(struct dd_context
*dctx
,
615 struct pipe_fence_handle
**fence
, unsigned flags
,
618 if (dd_flush_and_check_hang(dctx
, fence
, flags
)) {
619 FILE *f
= dd_get_file_stream(dd_screen(dctx
->base
.screen
),
620 dctx
->draw_state
.apitrace_call_number
);
623 fprintf(f
, "dd: %s.\n", cause
);
624 dd_dump_driver_state(dctx
, f
,
625 PIPE_DUMP_DEVICE_STATUS_REGISTERS
|
626 PIPE_DUMP_CURRENT_STATES
|
627 PIPE_DUMP_CURRENT_SHADERS
|
628 PIPE_DUMP_LAST_COMMAND_BUFFER
);
630 dd_close_file_stream(f
);
633 /* Terminate the process to prevent future hangs. */
639 dd_context_flush(struct pipe_context
*_pipe
,
640 struct pipe_fence_handle
**fence
, unsigned flags
)
642 struct dd_context
*dctx
= dd_context(_pipe
);
643 struct pipe_context
*pipe
= dctx
->pipe
;
645 switch (dd_screen(dctx
->base
.screen
)->mode
) {
646 case DD_DETECT_HANGS
:
647 dd_flush_and_handle_hang(dctx
, fence
, flags
,
648 "GPU hang detected in pipe->flush()");
650 case DD_DUMP_ALL_CALLS
:
651 case DD_DUMP_APITRACE_CALL
:
652 pipe
->flush(pipe
, fence
, flags
);
660 dd_before_draw(struct dd_context
*dctx
)
662 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
664 if (dscreen
->mode
== DD_DETECT_HANGS
&&
665 !dscreen
->no_flush
&&
666 dctx
->num_draw_calls
>= dscreen
->skip_count
)
667 dd_flush_and_handle_hang(dctx
, NULL
, 0,
668 "GPU hang most likely caused by internal "
673 dd_after_draw(struct dd_context
*dctx
, struct dd_call
*call
)
675 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
676 struct pipe_context
*pipe
= dctx
->pipe
;
678 if (dctx
->num_draw_calls
>= dscreen
->skip_count
) {
679 switch (dscreen
->mode
) {
680 case DD_DETECT_HANGS
:
681 if (!dscreen
->no_flush
&&
682 dd_flush_and_check_hang(dctx
, NULL
, 0)) {
683 dd_write_report(dctx
, call
,
684 PIPE_DUMP_DEVICE_STATUS_REGISTERS
|
685 PIPE_DUMP_CURRENT_STATES
|
686 PIPE_DUMP_CURRENT_SHADERS
|
687 PIPE_DUMP_LAST_COMMAND_BUFFER
,
690 /* Terminate the process to prevent future hangs. */
694 case DD_DUMP_ALL_CALLS
:
695 if (!dscreen
->no_flush
)
696 pipe
->flush(pipe
, NULL
, 0);
697 dd_write_report(dctx
, call
, 0, false);
699 case DD_DUMP_APITRACE_CALL
:
700 if (dscreen
->apitrace_dump_call
==
701 dctx
->draw_state
.apitrace_call_number
) {
702 dd_write_report(dctx
, call
, 0, false);
703 /* No need to continue. */
712 ++dctx
->num_draw_calls
;
713 if (dscreen
->skip_count
&& dctx
->num_draw_calls
% 10000 == 0)
714 fprintf(stderr
, "Gallium debugger reached %u draw calls.\n",
715 dctx
->num_draw_calls
);
719 dd_context_draw_vbo(struct pipe_context
*_pipe
,
720 const struct pipe_draw_info
*info
)
722 struct dd_context
*dctx
= dd_context(_pipe
);
723 struct pipe_context
*pipe
= dctx
->pipe
;
726 call
.type
= CALL_DRAW_VBO
;
727 call
.info
.draw_vbo
= *info
;
729 dd_before_draw(dctx
);
730 pipe
->draw_vbo(pipe
, info
);
731 dd_after_draw(dctx
, &call
);
735 dd_context_launch_grid(struct pipe_context
*_pipe
,
736 const struct pipe_grid_info
*info
)
738 struct dd_context
*dctx
= dd_context(_pipe
);
739 struct pipe_context
*pipe
= dctx
->pipe
;
742 call
.type
= CALL_LAUNCH_GRID
;
743 call
.info
.launch_grid
= *info
;
745 dd_before_draw(dctx
);
746 pipe
->launch_grid(pipe
, info
);
747 dd_after_draw(dctx
, &call
);
751 dd_context_resource_copy_region(struct pipe_context
*_pipe
,
752 struct pipe_resource
*dst
, unsigned dst_level
,
753 unsigned dstx
, unsigned dsty
, unsigned dstz
,
754 struct pipe_resource
*src
, unsigned src_level
,
755 const struct pipe_box
*src_box
)
757 struct dd_context
*dctx
= dd_context(_pipe
);
758 struct pipe_context
*pipe
= dctx
->pipe
;
761 call
.type
= CALL_RESOURCE_COPY_REGION
;
762 call
.info
.resource_copy_region
.dst
= dst
;
763 call
.info
.resource_copy_region
.dst_level
= dst_level
;
764 call
.info
.resource_copy_region
.dstx
= dstx
;
765 call
.info
.resource_copy_region
.dsty
= dsty
;
766 call
.info
.resource_copy_region
.dstz
= dstz
;
767 call
.info
.resource_copy_region
.src
= src
;
768 call
.info
.resource_copy_region
.src_level
= src_level
;
769 call
.info
.resource_copy_region
.src_box
= src_box
;
771 dd_before_draw(dctx
);
772 pipe
->resource_copy_region(pipe
,
773 dst
, dst_level
, dstx
, dsty
, dstz
,
774 src
, src_level
, src_box
);
775 dd_after_draw(dctx
, &call
);
779 dd_context_blit(struct pipe_context
*_pipe
, const struct pipe_blit_info
*info
)
781 struct dd_context
*dctx
= dd_context(_pipe
);
782 struct pipe_context
*pipe
= dctx
->pipe
;
785 call
.type
= CALL_BLIT
;
786 call
.info
.blit
= *info
;
788 dd_before_draw(dctx
);
789 pipe
->blit(pipe
, info
);
790 dd_after_draw(dctx
, &call
);
794 dd_context_generate_mipmap(struct pipe_context
*_pipe
,
795 struct pipe_resource
*res
,
796 enum pipe_format format
,
799 unsigned first_layer
,
802 struct dd_context
*dctx
= dd_context(_pipe
);
803 struct pipe_context
*pipe
= dctx
->pipe
;
807 call
.type
= CALL_GENERATE_MIPMAP
;
808 call
.info
.generate_mipmap
.res
= res
;
809 call
.info
.generate_mipmap
.format
= format
;
810 call
.info
.generate_mipmap
.base_level
= base_level
;
811 call
.info
.generate_mipmap
.last_level
= last_level
;
812 call
.info
.generate_mipmap
.first_layer
= first_layer
;
813 call
.info
.generate_mipmap
.last_layer
= last_layer
;
815 dd_before_draw(dctx
);
816 result
= pipe
->generate_mipmap(pipe
, res
, format
, base_level
, last_level
,
817 first_layer
, last_layer
);
818 dd_after_draw(dctx
, &call
);
823 dd_context_flush_resource(struct pipe_context
*_pipe
,
824 struct pipe_resource
*resource
)
826 struct dd_context
*dctx
= dd_context(_pipe
);
827 struct pipe_context
*pipe
= dctx
->pipe
;
830 call
.type
= CALL_FLUSH_RESOURCE
;
831 call
.info
.flush_resource
= resource
;
833 dd_before_draw(dctx
);
834 pipe
->flush_resource(pipe
, resource
);
835 dd_after_draw(dctx
, &call
);
839 dd_context_clear(struct pipe_context
*_pipe
, unsigned buffers
,
840 const union pipe_color_union
*color
, double depth
,
843 struct dd_context
*dctx
= dd_context(_pipe
);
844 struct pipe_context
*pipe
= dctx
->pipe
;
847 call
.type
= CALL_CLEAR
;
848 call
.info
.clear
.buffers
= buffers
;
849 call
.info
.clear
.color
= color
;
850 call
.info
.clear
.depth
= depth
;
851 call
.info
.clear
.stencil
= stencil
;
853 dd_before_draw(dctx
);
854 pipe
->clear(pipe
, buffers
, color
, depth
, stencil
);
855 dd_after_draw(dctx
, &call
);
859 dd_context_clear_render_target(struct pipe_context
*_pipe
,
860 struct pipe_surface
*dst
,
861 const union pipe_color_union
*color
,
862 unsigned dstx
, unsigned dsty
,
863 unsigned width
, unsigned height
)
865 struct dd_context
*dctx
= dd_context(_pipe
);
866 struct pipe_context
*pipe
= dctx
->pipe
;
869 call
.type
= CALL_CLEAR_RENDER_TARGET
;
871 dd_before_draw(dctx
);
872 pipe
->clear_render_target(pipe
, dst
, color
, dstx
, dsty
, width
, height
);
873 dd_after_draw(dctx
, &call
);
877 dd_context_clear_depth_stencil(struct pipe_context
*_pipe
,
878 struct pipe_surface
*dst
, unsigned clear_flags
,
879 double depth
, unsigned stencil
, unsigned dstx
,
880 unsigned dsty
, unsigned width
, unsigned height
)
882 struct dd_context
*dctx
= dd_context(_pipe
);
883 struct pipe_context
*pipe
= dctx
->pipe
;
886 call
.type
= CALL_CLEAR_DEPTH_STENCIL
;
888 dd_before_draw(dctx
);
889 pipe
->clear_depth_stencil(pipe
, dst
, clear_flags
, depth
, stencil
,
890 dstx
, dsty
, width
, height
);
891 dd_after_draw(dctx
, &call
);
895 dd_context_clear_buffer(struct pipe_context
*_pipe
, struct pipe_resource
*res
,
896 unsigned offset
, unsigned size
,
897 const void *clear_value
, int clear_value_size
)
899 struct dd_context
*dctx
= dd_context(_pipe
);
900 struct pipe_context
*pipe
= dctx
->pipe
;
903 call
.type
= CALL_CLEAR_BUFFER
;
904 call
.info
.clear_buffer
.res
= res
;
905 call
.info
.clear_buffer
.offset
= offset
;
906 call
.info
.clear_buffer
.size
= size
;
907 call
.info
.clear_buffer
.clear_value
= clear_value
;
908 call
.info
.clear_buffer
.clear_value_size
= clear_value_size
;
910 dd_before_draw(dctx
);
911 pipe
->clear_buffer(pipe
, res
, offset
, size
, clear_value
, clear_value_size
);
912 dd_after_draw(dctx
, &call
);
916 dd_init_draw_functions(struct dd_context
*dctx
)
920 CTX_INIT(launch_grid
);
921 CTX_INIT(resource_copy_region
);
924 CTX_INIT(clear_render_target
);
925 CTX_INIT(clear_depth_stencil
);
926 CTX_INIT(clear_buffer
);
927 CTX_INIT(flush_resource
);
928 CTX_INIT(generate_mipmap
);