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"
38 CALL_RESOURCE_COPY_REGION
,
43 CALL_CLEAR_RENDER_TARGET
,
44 CALL_CLEAR_DEPTH_STENCIL
,
47 struct call_resource_copy_region
49 struct pipe_resource
*dst
;
51 unsigned dstx
, dsty
, dstz
;
52 struct pipe_resource
*src
;
54 const struct pipe_box
*src_box
;
60 const union pipe_color_union
*color
;
65 struct call_clear_buffer
67 struct pipe_resource
*res
;
70 const void *clear_value
;
79 struct pipe_draw_info draw_vbo
;
80 struct call_resource_copy_region resource_copy_region
;
81 struct pipe_blit_info blit
;
82 struct pipe_resource
*flush_resource
;
83 struct call_clear clear
;
84 struct call_clear_buffer clear_buffer
;
89 dd_get_file_stream(struct dd_context
*dctx
)
91 struct pipe_screen
*screen
= dctx
->pipe
->screen
;
92 FILE *f
= dd_get_debug_file();
96 fprintf(f
, "Driver vendor: %s\n", screen
->get_vendor(screen
));
97 fprintf(f
, "Device vendor: %s\n", screen
->get_device_vendor(screen
));
98 fprintf(f
, "Device name: %s\n\n", screen
->get_name(screen
));
103 dd_close_file_stream(FILE *f
)
109 dd_num_active_viewports(struct dd_context
*dctx
)
111 struct tgsi_shader_info info
;
112 const struct tgsi_token
*tokens
;
114 if (dctx
->shaders
[PIPE_SHADER_GEOMETRY
])
115 tokens
= dctx
->shaders
[PIPE_SHADER_GEOMETRY
]->state
.shader
.tokens
;
116 else if (dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
117 tokens
= dctx
->shaders
[PIPE_SHADER_TESS_EVAL
]->state
.shader
.tokens
;
118 else if (dctx
->shaders
[PIPE_SHADER_VERTEX
])
119 tokens
= dctx
->shaders
[PIPE_SHADER_VERTEX
]->state
.shader
.tokens
;
123 tgsi_scan_shader(tokens
, &info
);
124 return info
.writes_viewport_index
? PIPE_MAX_VIEWPORTS
: 1;
127 #define COLOR_RESET "\033[0m"
128 #define COLOR_SHADER "\033[1;32m"
129 #define COLOR_STATE "\033[1;33m"
131 #define DUMP(name, var) do { \
132 fprintf(f, COLOR_STATE #name ": " COLOR_RESET); \
133 util_dump_##name(f, var); \
137 #define DUMP_I(name, var, i) do { \
138 fprintf(f, COLOR_STATE #name " %i: " COLOR_RESET, i); \
139 util_dump_##name(f, var); \
143 #define DUMP_M(name, var, member) do { \
144 fprintf(f, " " #member ": "); \
145 util_dump_##name(f, (var)->member); \
149 #define DUMP_M_ADDR(name, var, member) do { \
150 fprintf(f, " " #member ": "); \
151 util_dump_##name(f, &(var)->member); \
156 print_named_value(FILE *f
, const char *name
, int value
)
158 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = %i\n", name
, value
);
162 print_named_xvalue(FILE *f
, const char *name
, int value
)
164 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = 0x%08x\n", name
, value
);
168 util_dump_uint(FILE *f
, unsigned i
)
174 util_dump_hex(FILE *f
, unsigned i
)
176 fprintf(f
, "0x%x", i
);
180 util_dump_double(FILE *f
, double d
)
186 util_dump_format(FILE *f
, enum pipe_format format
)
188 fprintf(f
, "%s", util_format_name(format
));
192 util_dump_color_union(FILE *f
, const union pipe_color_union
*color
)
194 fprintf(f
, "{f = {%f, %f, %f, %f}, ui = {%u, %u, %u, %u}",
195 color
->f
[0], color
->f
[1], color
->f
[2], color
->f
[3],
196 color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
200 util_dump_query(FILE *f
, struct dd_query
*query
)
202 if (query
->type
>= PIPE_QUERY_DRIVER_SPECIFIC
)
203 fprintf(f
, "PIPE_QUERY_DRIVER_SPECIFIC + %i",
204 query
->type
- PIPE_QUERY_DRIVER_SPECIFIC
);
206 fprintf(f
, "%s", util_dump_query_type(query
->type
, false));
210 dd_dump_render_condition(struct dd_context
*dctx
, FILE *f
)
212 if (dctx
->render_cond
.query
) {
213 fprintf(f
, "render condition:\n");
214 DUMP_M(query
, &dctx
->render_cond
, query
);
215 DUMP_M(uint
, &dctx
->render_cond
, condition
);
216 DUMP_M(uint
, &dctx
->render_cond
, mode
);
222 dd_dump_draw_vbo(struct dd_context
*dctx
, struct pipe_draw_info
*info
, FILE *f
)
225 const char *shader_str
[PIPE_SHADER_TYPES
];
227 shader_str
[PIPE_SHADER_VERTEX
] = "VERTEX";
228 shader_str
[PIPE_SHADER_TESS_CTRL
] = "TESS_CTRL";
229 shader_str
[PIPE_SHADER_TESS_EVAL
] = "TESS_EVAL";
230 shader_str
[PIPE_SHADER_GEOMETRY
] = "GEOMETRY";
231 shader_str
[PIPE_SHADER_FRAGMENT
] = "FRAGMENT";
232 shader_str
[PIPE_SHADER_COMPUTE
] = "COMPUTE";
234 DUMP(draw_info
, info
);
236 DUMP(index_buffer
, &dctx
->index_buffer
);
237 if (dctx
->index_buffer
.buffer
)
238 DUMP_M(resource
, &dctx
->index_buffer
, buffer
);
240 if (info
->count_from_stream_output
)
241 DUMP_M(stream_output_target
, info
,
242 count_from_stream_output
);
244 DUMP_M(resource
, info
, indirect
);
247 /* TODO: dump active queries */
249 dd_dump_render_condition(dctx
, f
);
251 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++)
252 if (dctx
->vertex_buffers
[i
].buffer
||
253 dctx
->vertex_buffers
[i
].user_buffer
) {
254 DUMP_I(vertex_buffer
, &dctx
->vertex_buffers
[i
], i
);
255 if (dctx
->vertex_buffers
[i
].buffer
)
256 DUMP_M(resource
, &dctx
->vertex_buffers
[i
], buffer
);
260 print_named_value(f
, "num vertex elements",
261 dctx
->velems
->state
.velems
.count
);
262 for (i
= 0; i
< dctx
->velems
->state
.velems
.count
; i
++) {
264 DUMP_I(vertex_element
, &dctx
->velems
->state
.velems
.velems
[i
], i
);
268 print_named_value(f
, "num stream output targets", dctx
->num_so_targets
);
269 for (i
= 0; i
< dctx
->num_so_targets
; i
++)
270 if (dctx
->so_targets
[i
]) {
271 DUMP_I(stream_output_target
, dctx
->so_targets
[i
], i
);
272 DUMP_M(resource
, dctx
->so_targets
[i
], buffer
);
273 fprintf(f
, " offset = %i\n", dctx
->so_offsets
[i
]);
277 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
278 if (sh
== PIPE_SHADER_COMPUTE
)
281 if (sh
== PIPE_SHADER_TESS_CTRL
&&
282 !dctx
->shaders
[PIPE_SHADER_TESS_CTRL
] &&
283 dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
284 fprintf(f
, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
285 "default_inner_level = {%f, %f}}\n",
286 dctx
->tess_default_levels
[0],
287 dctx
->tess_default_levels
[1],
288 dctx
->tess_default_levels
[2],
289 dctx
->tess_default_levels
[3],
290 dctx
->tess_default_levels
[4],
291 dctx
->tess_default_levels
[5]);
293 if (sh
== PIPE_SHADER_FRAGMENT
)
295 unsigned num_viewports
= dd_num_active_viewports(dctx
);
297 if (dctx
->rs
->state
.rs
.clip_plane_enable
)
298 DUMP(clip_state
, &dctx
->clip_state
);
300 for (i
= 0; i
< num_viewports
; i
++)
301 DUMP_I(viewport_state
, &dctx
->viewports
[i
], i
);
303 if (dctx
->rs
->state
.rs
.scissor
)
304 for (i
= 0; i
< num_viewports
; i
++)
305 DUMP_I(scissor_state
, &dctx
->scissors
[i
], i
);
307 DUMP(rasterizer_state
, &dctx
->rs
->state
.rs
);
309 if (dctx
->rs
->state
.rs
.poly_stipple_enable
)
310 DUMP(poly_stipple
, &dctx
->polygon_stipple
);
314 if (!dctx
->shaders
[sh
])
317 fprintf(f
, COLOR_SHADER
"begin shader: %s" COLOR_RESET
"\n", shader_str
[sh
]);
318 DUMP(shader_state
, &dctx
->shaders
[sh
]->state
.shader
);
320 for (i
= 0; i
< PIPE_MAX_CONSTANT_BUFFERS
; i
++)
321 if (dctx
->constant_buffers
[sh
][i
].buffer
||
322 dctx
->constant_buffers
[sh
][i
].user_buffer
) {
323 DUMP_I(constant_buffer
, &dctx
->constant_buffers
[sh
][i
], i
);
324 if (dctx
->constant_buffers
[sh
][i
].buffer
)
325 DUMP_M(resource
, &dctx
->constant_buffers
[sh
][i
], buffer
);
328 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
329 if (dctx
->sampler_states
[sh
][i
])
330 DUMP_I(sampler_state
, &dctx
->sampler_states
[sh
][i
]->state
.sampler
, i
);
332 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
333 if (dctx
->sampler_views
[sh
][i
]) {
334 DUMP_I(sampler_view
, dctx
->sampler_views
[sh
][i
], i
);
335 DUMP_M(resource
, dctx
->sampler_views
[sh
][i
], texture
);
338 /* TODO: print shader images */
339 /* TODO: print shader buffers */
341 fprintf(f
, COLOR_SHADER
"end shader: %s" COLOR_RESET
"\n\n", shader_str
[sh
]);
345 DUMP(depth_stencil_alpha_state
, &dctx
->dsa
->state
.dsa
);
346 DUMP(stencil_ref
, &dctx
->stencil_ref
);
349 DUMP(blend_state
, &dctx
->blend
->state
.blend
);
350 DUMP(blend_color
, &dctx
->blend_color
);
352 print_named_value(f
, "min_samples", dctx
->min_samples
);
353 print_named_xvalue(f
, "sample_mask", dctx
->sample_mask
);
356 DUMP(framebuffer_state
, &dctx
->framebuffer_state
);
357 for (i
= 0; i
< dctx
->framebuffer_state
.nr_cbufs
; i
++)
358 if (dctx
->framebuffer_state
.cbufs
[i
]) {
359 fprintf(f
, " " COLOR_STATE
"cbufs[%i]:" COLOR_RESET
"\n ", i
);
360 DUMP(surface
, dctx
->framebuffer_state
.cbufs
[i
]);
362 DUMP(resource
, dctx
->framebuffer_state
.cbufs
[i
]->texture
);
364 if (dctx
->framebuffer_state
.zsbuf
) {
365 fprintf(f
, " " COLOR_STATE
"zsbuf:" COLOR_RESET
"\n ");
366 DUMP(surface
, dctx
->framebuffer_state
.zsbuf
);
368 DUMP(resource
, dctx
->framebuffer_state
.zsbuf
->texture
);
374 dd_dump_resource_copy_region(struct dd_context
*dctx
,
375 struct call_resource_copy_region
*info
,
378 fprintf(f
, "%s:\n", __func__
+8);
379 DUMP_M(resource
, info
, dst
);
380 DUMP_M(uint
, info
, dst_level
);
381 DUMP_M(uint
, info
, dstx
);
382 DUMP_M(uint
, info
, dsty
);
383 DUMP_M(uint
, info
, dstz
);
384 DUMP_M(resource
, info
, src
);
385 DUMP_M(uint
, info
, src_level
);
386 DUMP_M(box
, info
, src_box
);
390 dd_dump_blit(struct dd_context
*dctx
, struct pipe_blit_info
*info
, FILE *f
)
392 fprintf(f
, "%s:\n", __func__
+8);
393 DUMP_M(resource
, info
, dst
.resource
);
394 DUMP_M(uint
, info
, dst
.level
);
395 DUMP_M_ADDR(box
, info
, dst
.box
);
396 DUMP_M(format
, info
, dst
.format
);
398 DUMP_M(resource
, info
, src
.resource
);
399 DUMP_M(uint
, info
, src
.level
);
400 DUMP_M_ADDR(box
, info
, src
.box
);
401 DUMP_M(format
, info
, src
.format
);
403 DUMP_M(hex
, info
, mask
);
404 DUMP_M(uint
, info
, filter
);
405 DUMP_M(uint
, info
, scissor_enable
);
406 DUMP_M_ADDR(scissor_state
, info
, scissor
);
407 DUMP_M(uint
, info
, render_condition_enable
);
409 if (info
->render_condition_enable
)
410 dd_dump_render_condition(dctx
, f
);
414 dd_dump_flush_resource(struct dd_context
*dctx
, struct pipe_resource
*res
,
417 fprintf(f
, "%s:\n", __func__
+8);
422 dd_dump_clear(struct dd_context
*dctx
, struct call_clear
*info
, FILE *f
)
424 fprintf(f
, "%s:\n", __func__
+8);
425 DUMP_M(uint
, info
, buffers
);
426 DUMP_M(color_union
, info
, color
);
427 DUMP_M(double, info
, depth
);
428 DUMP_M(hex
, info
, stencil
);
432 dd_dump_clear_buffer(struct dd_context
*dctx
, struct call_clear_buffer
*info
,
436 const char *value
= (const char*)info
->clear_value
;
438 fprintf(f
, "%s:\n", __func__
+8);
439 DUMP_M(resource
, info
, res
);
440 DUMP_M(uint
, info
, offset
);
441 DUMP_M(uint
, info
, size
);
442 DUMP_M(uint
, info
, clear_value_size
);
444 fprintf(f
, " clear_value:");
445 for (i
= 0; i
< info
->clear_value_size
; i
++)
446 fprintf(f
, " %02x", value
[i
]);
451 dd_dump_clear_render_target(struct dd_context
*dctx
, FILE *f
)
453 fprintf(f
, "%s:\n", __func__
+8);
458 dd_dump_clear_depth_stencil(struct dd_context
*dctx
, FILE *f
)
460 fprintf(f
, "%s:\n", __func__
+8);
465 dd_dump_driver_state(struct dd_context
*dctx
, FILE *f
, unsigned flags
)
467 if (dctx
->pipe
->dump_debug_state
) {
468 fprintf(f
,"\n\n**************************************************"
469 "***************************\n");
470 fprintf(f
, "Driver-specific state:\n\n");
471 dctx
->pipe
->dump_debug_state(dctx
->pipe
, f
, flags
);
476 dd_dump_call(struct dd_context
*dctx
, struct dd_call
*call
, unsigned flags
)
478 FILE *f
= dd_get_file_stream(dctx
);
483 switch (call
->type
) {
485 dd_dump_draw_vbo(dctx
, &call
->info
.draw_vbo
, f
);
487 case CALL_RESOURCE_COPY_REGION
:
488 dd_dump_resource_copy_region(dctx
, &call
->info
.resource_copy_region
, f
);
491 dd_dump_blit(dctx
, &call
->info
.blit
, f
);
493 case CALL_FLUSH_RESOURCE
:
494 dd_dump_flush_resource(dctx
, call
->info
.flush_resource
, f
);
497 dd_dump_clear(dctx
, &call
->info
.clear
, f
);
499 case CALL_CLEAR_BUFFER
:
500 dd_dump_clear_buffer(dctx
, &call
->info
.clear_buffer
, f
);
502 case CALL_CLEAR_RENDER_TARGET
:
503 dd_dump_clear_render_target(dctx
, f
);
505 case CALL_CLEAR_DEPTH_STENCIL
:
506 dd_dump_clear_depth_stencil(dctx
, f
);
509 dd_dump_driver_state(dctx
, f
, flags
);
510 dd_close_file_stream(f
);
514 dd_kill_process(void)
517 fprintf(stderr
, "dd: Aborting the process...\n");
524 dd_flush_and_check_hang(struct dd_context
*dctx
,
525 struct pipe_fence_handle
**flush_fence
,
526 unsigned flush_flags
)
528 struct pipe_fence_handle
*fence
= NULL
;
529 struct pipe_context
*pipe
= dctx
->pipe
;
530 struct pipe_screen
*screen
= pipe
->screen
;
531 uint64_t timeout_ms
= dd_screen(dctx
->base
.screen
)->timeout_ms
;
534 assert(timeout_ms
> 0);
536 pipe
->flush(pipe
, &fence
, flush_flags
);
538 screen
->fence_reference(screen
, flush_fence
, fence
);
542 idle
= screen
->fence_finish(screen
, fence
, timeout_ms
* 1000000);
543 screen
->fence_reference(screen
, &fence
, NULL
);
545 fprintf(stderr
, "dd: GPU hang detected!\n");
550 dd_flush_and_handle_hang(struct dd_context
*dctx
,
551 struct pipe_fence_handle
**fence
, unsigned flags
,
554 if (dd_flush_and_check_hang(dctx
, fence
, flags
)) {
555 FILE *f
= dd_get_file_stream(dctx
);
558 fprintf(f
, "dd: %s.\n", cause
);
559 dd_dump_driver_state(dctx
, f
, PIPE_DEBUG_DEVICE_IS_HUNG
);
560 dd_close_file_stream(f
);
563 /* Terminate the process to prevent future hangs. */
569 dd_context_flush(struct pipe_context
*_pipe
,
570 struct pipe_fence_handle
**fence
, unsigned flags
)
572 struct dd_context
*dctx
= dd_context(_pipe
);
573 struct pipe_context
*pipe
= dctx
->pipe
;
575 switch (dd_screen(dctx
->base
.screen
)->mode
) {
576 case DD_DETECT_HANGS
:
577 dd_flush_and_handle_hang(dctx
, fence
, flags
,
578 "GPU hang detected in pipe->flush()");
580 case DD_DUMP_ALL_CALLS
:
581 pipe
->flush(pipe
, fence
, flags
);
589 dd_before_draw(struct dd_context
*dctx
)
591 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
593 if (dscreen
->mode
== DD_DETECT_HANGS
&&
594 !dscreen
->no_flush
&&
595 dctx
->num_draw_calls
>= dscreen
->skip_count
)
596 dd_flush_and_handle_hang(dctx
, NULL
, 0,
597 "GPU hang most likely caused by internal "
602 dd_after_draw(struct dd_context
*dctx
, struct dd_call
*call
)
604 struct dd_screen
*dscreen
= dd_screen(dctx
->base
.screen
);
606 if (dctx
->num_draw_calls
>= dscreen
->skip_count
) {
607 switch (dscreen
->mode
) {
608 case DD_DETECT_HANGS
:
609 if (!dscreen
->no_flush
&&
610 dd_flush_and_check_hang(dctx
, NULL
, 0)) {
611 dd_dump_call(dctx
, call
, PIPE_DEBUG_DEVICE_IS_HUNG
);
613 /* Terminate the process to prevent future hangs. */
617 case DD_DUMP_ALL_CALLS
:
618 dd_dump_call(dctx
, call
, 0);
625 ++dctx
->num_draw_calls
;
629 dd_context_draw_vbo(struct pipe_context
*_pipe
,
630 const struct pipe_draw_info
*info
)
632 struct dd_context
*dctx
= dd_context(_pipe
);
633 struct pipe_context
*pipe
= dctx
->pipe
;
636 call
.type
= CALL_DRAW_VBO
;
637 call
.info
.draw_vbo
= *info
;
639 dd_before_draw(dctx
);
640 pipe
->draw_vbo(pipe
, info
);
641 dd_after_draw(dctx
, &call
);
645 dd_context_resource_copy_region(struct pipe_context
*_pipe
,
646 struct pipe_resource
*dst
, unsigned dst_level
,
647 unsigned dstx
, unsigned dsty
, unsigned dstz
,
648 struct pipe_resource
*src
, unsigned src_level
,
649 const struct pipe_box
*src_box
)
651 struct dd_context
*dctx
= dd_context(_pipe
);
652 struct pipe_context
*pipe
= dctx
->pipe
;
655 call
.type
= CALL_RESOURCE_COPY_REGION
;
656 call
.info
.resource_copy_region
.dst
= dst
;
657 call
.info
.resource_copy_region
.dst_level
= dst_level
;
658 call
.info
.resource_copy_region
.dstx
= dstx
;
659 call
.info
.resource_copy_region
.dsty
= dsty
;
660 call
.info
.resource_copy_region
.dstz
= dstz
;
661 call
.info
.resource_copy_region
.src
= src
;
662 call
.info
.resource_copy_region
.src_level
= src_level
;
663 call
.info
.resource_copy_region
.src_box
= src_box
;
665 dd_before_draw(dctx
);
666 pipe
->resource_copy_region(pipe
,
667 dst
, dst_level
, dstx
, dsty
, dstz
,
668 src
, src_level
, src_box
);
669 dd_after_draw(dctx
, &call
);
673 dd_context_blit(struct pipe_context
*_pipe
, const struct pipe_blit_info
*info
)
675 struct dd_context
*dctx
= dd_context(_pipe
);
676 struct pipe_context
*pipe
= dctx
->pipe
;
679 call
.type
= CALL_BLIT
;
680 call
.info
.blit
= *info
;
682 dd_before_draw(dctx
);
683 pipe
->blit(pipe
, info
);
684 dd_after_draw(dctx
, &call
);
688 dd_context_flush_resource(struct pipe_context
*_pipe
,
689 struct pipe_resource
*resource
)
691 struct dd_context
*dctx
= dd_context(_pipe
);
692 struct pipe_context
*pipe
= dctx
->pipe
;
695 call
.type
= CALL_FLUSH_RESOURCE
;
696 call
.info
.flush_resource
= resource
;
698 dd_before_draw(dctx
);
699 pipe
->flush_resource(pipe
, resource
);
700 dd_after_draw(dctx
, &call
);
704 dd_context_clear(struct pipe_context
*_pipe
, unsigned buffers
,
705 const union pipe_color_union
*color
, double depth
,
708 struct dd_context
*dctx
= dd_context(_pipe
);
709 struct pipe_context
*pipe
= dctx
->pipe
;
712 call
.type
= CALL_CLEAR
;
713 call
.info
.clear
.buffers
= buffers
;
714 call
.info
.clear
.color
= color
;
715 call
.info
.clear
.depth
= depth
;
716 call
.info
.clear
.stencil
= stencil
;
718 dd_before_draw(dctx
);
719 pipe
->clear(pipe
, buffers
, color
, depth
, stencil
);
720 dd_after_draw(dctx
, &call
);
724 dd_context_clear_render_target(struct pipe_context
*_pipe
,
725 struct pipe_surface
*dst
,
726 const union pipe_color_union
*color
,
727 unsigned dstx
, unsigned dsty
,
728 unsigned width
, unsigned height
)
730 struct dd_context
*dctx
= dd_context(_pipe
);
731 struct pipe_context
*pipe
= dctx
->pipe
;
734 call
.type
= CALL_CLEAR_RENDER_TARGET
;
736 dd_before_draw(dctx
);
737 pipe
->clear_render_target(pipe
, dst
, color
, dstx
, dsty
, width
, height
);
738 dd_after_draw(dctx
, &call
);
742 dd_context_clear_depth_stencil(struct pipe_context
*_pipe
,
743 struct pipe_surface
*dst
, unsigned clear_flags
,
744 double depth
, unsigned stencil
, unsigned dstx
,
745 unsigned dsty
, unsigned width
, unsigned height
)
747 struct dd_context
*dctx
= dd_context(_pipe
);
748 struct pipe_context
*pipe
= dctx
->pipe
;
751 call
.type
= CALL_CLEAR_DEPTH_STENCIL
;
753 dd_before_draw(dctx
);
754 pipe
->clear_depth_stencil(pipe
, dst
, clear_flags
, depth
, stencil
,
755 dstx
, dsty
, width
, height
);
756 dd_after_draw(dctx
, &call
);
760 dd_context_clear_buffer(struct pipe_context
*_pipe
, struct pipe_resource
*res
,
761 unsigned offset
, unsigned size
,
762 const void *clear_value
, int clear_value_size
)
764 struct dd_context
*dctx
= dd_context(_pipe
);
765 struct pipe_context
*pipe
= dctx
->pipe
;
768 call
.type
= CALL_CLEAR_BUFFER
;
769 call
.info
.clear_buffer
.res
= res
;
770 call
.info
.clear_buffer
.offset
= offset
;
771 call
.info
.clear_buffer
.size
= size
;
772 call
.info
.clear_buffer
.clear_value
= clear_value
;
773 call
.info
.clear_buffer
.clear_value_size
= clear_value_size
;
775 dd_before_draw(dctx
);
776 pipe
->clear_buffer(pipe
, res
, offset
, size
, clear_value
, clear_value_size
);
777 dd_after_draw(dctx
, &call
);
781 dd_init_draw_functions(struct dd_context
*dctx
)
785 CTX_INIT(resource_copy_region
);
788 CTX_INIT(clear_render_target
);
789 CTX_INIT(clear_depth_stencil
);
790 CTX_INIT(clear_buffer
);
791 CTX_INIT(flush_resource
);