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"
33 #include "os/os_process.h"
41 CALL_RESOURCE_COPY_REGION
,
46 CALL_CLEAR_RENDER_TARGET
,
47 CALL_CLEAR_DEPTH_STENCIL
,
50 struct call_resource_copy_region
52 struct pipe_resource
*dst
;
54 unsigned dstx
, dsty
, dstz
;
55 struct pipe_resource
*src
;
57 const struct pipe_box
*src_box
;
63 const union pipe_color_union
*color
;
68 struct call_clear_buffer
70 struct pipe_resource
*res
;
73 const void *clear_value
;
82 struct pipe_draw_info draw_vbo
;
83 struct call_resource_copy_region resource_copy_region
;
84 struct pipe_blit_info blit
;
85 struct pipe_resource
*flush_resource
;
86 struct call_clear clear
;
87 struct call_clear_buffer clear_buffer
;
93 dd_get_file_stream(struct dd_context
*dctx
)
95 struct pipe_screen
*screen
= dctx
->pipe
->screen
;
96 static unsigned index
;
97 char proc_name
[128], dir
[256], name
[512];
100 if (!os_get_process_name(proc_name
, sizeof(proc_name
))) {
101 fprintf(stderr
, "dd: can't get the process name\n");
105 snprintf(dir
, sizeof(dir
), "%s/"DD_DIR
, debug_get_option("HOME", "."));
107 if (mkdir(dir
, 0774) && errno
!= EEXIST
) {
108 fprintf(stderr
, "dd: can't create a directory (%i)\n", errno
);
112 snprintf(name
, sizeof(name
), "%s/%s_%u_%08u", dir
, proc_name
, getpid(), index
++);
113 f
= fopen(name
, "w");
115 fprintf(stderr
, "dd: can't open file %s\n", name
);
119 fprintf(f
, "Driver vendor: %s\n", screen
->get_vendor(screen
));
120 fprintf(f
, "Device vendor: %s\n", screen
->get_device_vendor(screen
));
121 fprintf(f
, "Device name: %s\n\n", screen
->get_name(screen
));
126 dd_close_file_stream(FILE *f
)
132 dd_num_active_viewports(struct dd_context
*dctx
)
134 struct tgsi_shader_info info
;
135 const struct tgsi_token
*tokens
;
137 if (dctx
->shaders
[PIPE_SHADER_GEOMETRY
])
138 tokens
= dctx
->shaders
[PIPE_SHADER_GEOMETRY
]->state
.shader
.tokens
;
139 else if (dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
140 tokens
= dctx
->shaders
[PIPE_SHADER_TESS_EVAL
]->state
.shader
.tokens
;
141 else if (dctx
->shaders
[PIPE_SHADER_VERTEX
])
142 tokens
= dctx
->shaders
[PIPE_SHADER_VERTEX
]->state
.shader
.tokens
;
146 tgsi_scan_shader(tokens
, &info
);
147 return info
.writes_viewport_index
? PIPE_MAX_VIEWPORTS
: 1;
150 #define COLOR_RESET "\033[0m"
151 #define COLOR_SHADER "\033[1;32m"
152 #define COLOR_STATE "\033[1;33m"
154 #define DUMP(name, var) do { \
155 fprintf(f, COLOR_STATE #name ": " COLOR_RESET); \
156 util_dump_##name(f, var); \
160 #define DUMP_I(name, var, i) do { \
161 fprintf(f, COLOR_STATE #name " %i: " COLOR_RESET, i); \
162 util_dump_##name(f, var); \
166 #define DUMP_M(name, var, member) do { \
167 fprintf(f, " " #member ": "); \
168 util_dump_##name(f, (var)->member); \
172 #define DUMP_M_ADDR(name, var, member) do { \
173 fprintf(f, " " #member ": "); \
174 util_dump_##name(f, &(var)->member); \
179 print_named_value(FILE *f
, const char *name
, int value
)
181 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = %i\n", name
, value
);
185 print_named_xvalue(FILE *f
, const char *name
, int value
)
187 fprintf(f
, COLOR_STATE
"%s" COLOR_RESET
" = 0x%08x\n", name
, value
);
191 util_dump_uint(FILE *f
, unsigned i
)
197 util_dump_hex(FILE *f
, unsigned i
)
199 fprintf(f
, "0x%x", i
);
203 util_dump_double(FILE *f
, double d
)
209 util_dump_format(FILE *f
, enum pipe_format format
)
211 fprintf(f
, "%s", util_format_name(format
));
215 util_dump_color_union(FILE *f
, const union pipe_color_union
*color
)
217 fprintf(f
, "{f = {%f, %f, %f, %f}, ui = {%u, %u, %u, %u}",
218 color
->f
[0], color
->f
[1], color
->f
[2], color
->f
[3],
219 color
->ui
[0], color
->ui
[1], color
->ui
[2], color
->ui
[3]);
223 util_dump_query(FILE *f
, struct dd_query
*query
)
225 if (query
->type
>= PIPE_QUERY_DRIVER_SPECIFIC
)
226 fprintf(f
, "PIPE_QUERY_DRIVER_SPECIFIC + %i",
227 query
->type
- PIPE_QUERY_DRIVER_SPECIFIC
);
229 fprintf(f
, "%s", util_dump_query_type(query
->type
, false));
233 dd_dump_render_condition(struct dd_context
*dctx
, FILE *f
)
235 if (dctx
->render_cond
.query
) {
236 fprintf(f
, "render condition:\n");
237 DUMP_M(query
, &dctx
->render_cond
, query
);
238 DUMP_M(uint
, &dctx
->render_cond
, condition
);
239 DUMP_M(uint
, &dctx
->render_cond
, mode
);
245 dd_dump_draw_vbo(struct dd_context
*dctx
, struct pipe_draw_info
*info
, FILE *f
)
248 const char *shader_str
[PIPE_SHADER_TYPES
];
250 shader_str
[PIPE_SHADER_VERTEX
] = "VERTEX";
251 shader_str
[PIPE_SHADER_TESS_CTRL
] = "TESS_CTRL";
252 shader_str
[PIPE_SHADER_TESS_EVAL
] = "TESS_EVAL";
253 shader_str
[PIPE_SHADER_GEOMETRY
] = "GEOMETRY";
254 shader_str
[PIPE_SHADER_FRAGMENT
] = "FRAGMENT";
255 shader_str
[PIPE_SHADER_COMPUTE
] = "COMPUTE";
257 DUMP(draw_info
, info
);
259 DUMP(index_buffer
, &dctx
->index_buffer
);
260 if (dctx
->index_buffer
.buffer
)
261 DUMP_M(resource
, &dctx
->index_buffer
, buffer
);
263 if (info
->count_from_stream_output
)
264 DUMP_M(stream_output_target
, info
,
265 count_from_stream_output
);
267 DUMP_M(resource
, info
, indirect
);
270 /* TODO: dump active queries */
272 dd_dump_render_condition(dctx
, f
);
274 for (i
= 0; i
< PIPE_MAX_ATTRIBS
; i
++)
275 if (dctx
->vertex_buffers
[i
].buffer
||
276 dctx
->vertex_buffers
[i
].user_buffer
) {
277 DUMP_I(vertex_buffer
, &dctx
->vertex_buffers
[i
], i
);
278 if (dctx
->vertex_buffers
[i
].buffer
)
279 DUMP_M(resource
, &dctx
->vertex_buffers
[i
], buffer
);
283 print_named_value(f
, "num vertex elements",
284 dctx
->velems
->state
.velems
.count
);
285 for (i
= 0; i
< dctx
->velems
->state
.velems
.count
; i
++) {
287 DUMP_I(vertex_element
, &dctx
->velems
->state
.velems
.velems
[i
], i
);
291 print_named_value(f
, "num stream output targets", dctx
->num_so_targets
);
292 for (i
= 0; i
< dctx
->num_so_targets
; i
++)
293 if (dctx
->so_targets
[i
]) {
294 DUMP_I(stream_output_target
, dctx
->so_targets
[i
], i
);
295 DUMP_M(resource
, dctx
->so_targets
[i
], buffer
);
296 fprintf(f
, " offset = %i\n", dctx
->so_offsets
[i
]);
300 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
301 if (sh
== PIPE_SHADER_COMPUTE
)
304 if (sh
== PIPE_SHADER_TESS_CTRL
&&
305 !dctx
->shaders
[PIPE_SHADER_TESS_CTRL
] &&
306 dctx
->shaders
[PIPE_SHADER_TESS_EVAL
])
307 fprintf(f
, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
308 "default_inner_level = {%f, %f}}\n",
309 dctx
->tess_default_levels
[0],
310 dctx
->tess_default_levels
[1],
311 dctx
->tess_default_levels
[2],
312 dctx
->tess_default_levels
[3],
313 dctx
->tess_default_levels
[4],
314 dctx
->tess_default_levels
[5]);
316 if (sh
== PIPE_SHADER_FRAGMENT
)
318 unsigned num_viewports
= dd_num_active_viewports(dctx
);
320 if (dctx
->rs
->state
.rs
.clip_plane_enable
)
321 DUMP(clip_state
, &dctx
->clip_state
);
323 for (i
= 0; i
< num_viewports
; i
++)
324 DUMP_I(viewport_state
, &dctx
->viewports
[i
], i
);
326 if (dctx
->rs
->state
.rs
.scissor
)
327 for (i
= 0; i
< num_viewports
; i
++)
328 DUMP_I(scissor_state
, &dctx
->scissors
[i
], i
);
330 DUMP(rasterizer_state
, &dctx
->rs
->state
.rs
);
332 if (dctx
->rs
->state
.rs
.poly_stipple_enable
)
333 DUMP(poly_stipple
, &dctx
->polygon_stipple
);
337 if (!dctx
->shaders
[sh
])
340 fprintf(f
, COLOR_SHADER
"begin shader: %s" COLOR_RESET
"\n", shader_str
[sh
]);
341 DUMP(shader_state
, &dctx
->shaders
[sh
]->state
.shader
);
343 for (i
= 0; i
< PIPE_MAX_CONSTANT_BUFFERS
; i
++)
344 if (dctx
->constant_buffers
[sh
][i
].buffer
||
345 dctx
->constant_buffers
[sh
][i
].user_buffer
) {
346 DUMP_I(constant_buffer
, &dctx
->constant_buffers
[sh
][i
], i
);
347 if (dctx
->constant_buffers
[sh
][i
].buffer
)
348 DUMP_M(resource
, &dctx
->constant_buffers
[sh
][i
], buffer
);
351 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
352 if (dctx
->sampler_states
[sh
][i
])
353 DUMP_I(sampler_state
, &dctx
->sampler_states
[sh
][i
]->state
.sampler
, i
);
355 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++)
356 if (dctx
->sampler_views
[sh
][i
]) {
357 DUMP_I(sampler_view
, dctx
->sampler_views
[sh
][i
], i
);
358 DUMP_M(resource
, dctx
->sampler_views
[sh
][i
], texture
);
361 /* TODO: print shader images */
362 /* TODO: print shader buffers */
364 fprintf(f
, COLOR_SHADER
"end shader: %s" COLOR_RESET
"\n\n", shader_str
[sh
]);
368 DUMP(depth_stencil_alpha_state
, &dctx
->dsa
->state
.dsa
);
369 DUMP(stencil_ref
, &dctx
->stencil_ref
);
372 DUMP(blend_state
, &dctx
->blend
->state
.blend
);
373 DUMP(blend_color
, &dctx
->blend_color
);
375 print_named_value(f
, "min_samples", dctx
->min_samples
);
376 print_named_xvalue(f
, "sample_mask", dctx
->sample_mask
);
379 DUMP(framebuffer_state
, &dctx
->framebuffer_state
);
380 for (i
= 0; i
< dctx
->framebuffer_state
.nr_cbufs
; i
++)
381 if (dctx
->framebuffer_state
.cbufs
[i
]) {
382 fprintf(f
, " " COLOR_STATE
"cbufs[%i]:" COLOR_RESET
"\n ", i
);
383 DUMP(surface
, dctx
->framebuffer_state
.cbufs
[i
]);
385 DUMP(resource
, dctx
->framebuffer_state
.cbufs
[i
]->texture
);
387 if (dctx
->framebuffer_state
.zsbuf
) {
388 fprintf(f
, " " COLOR_STATE
"zsbuf:" COLOR_RESET
"\n ");
389 DUMP(surface
, dctx
->framebuffer_state
.zsbuf
);
391 DUMP(resource
, dctx
->framebuffer_state
.zsbuf
->texture
);
397 dd_dump_resource_copy_region(struct dd_context
*dctx
,
398 struct call_resource_copy_region
*info
,
401 fprintf(f
, "%s:\n", __func__
+8);
402 DUMP_M(resource
, info
, dst
);
403 DUMP_M(uint
, info
, dst_level
);
404 DUMP_M(uint
, info
, dstx
);
405 DUMP_M(uint
, info
, dsty
);
406 DUMP_M(uint
, info
, dstz
);
407 DUMP_M(resource
, info
, src
);
408 DUMP_M(uint
, info
, src_level
);
409 DUMP_M(box
, info
, src_box
);
413 dd_dump_blit(struct dd_context
*dctx
, struct pipe_blit_info
*info
, FILE *f
)
415 fprintf(f
, "%s:\n", __func__
+8);
416 DUMP_M(resource
, info
, dst
.resource
);
417 DUMP_M(uint
, info
, dst
.level
);
418 DUMP_M_ADDR(box
, info
, dst
.box
);
419 DUMP_M(format
, info
, dst
.format
);
421 DUMP_M(resource
, info
, src
.resource
);
422 DUMP_M(uint
, info
, src
.level
);
423 DUMP_M_ADDR(box
, info
, src
.box
);
424 DUMP_M(format
, info
, src
.format
);
426 DUMP_M(hex
, info
, mask
);
427 DUMP_M(uint
, info
, filter
);
428 DUMP_M(uint
, info
, scissor_enable
);
429 DUMP_M_ADDR(scissor_state
, info
, scissor
);
430 DUMP_M(uint
, info
, render_condition_enable
);
432 if (info
->render_condition_enable
)
433 dd_dump_render_condition(dctx
, f
);
437 dd_dump_flush_resource(struct dd_context
*dctx
, struct pipe_resource
*res
,
440 fprintf(f
, "%s:\n", __func__
+8);
445 dd_dump_clear(struct dd_context
*dctx
, struct call_clear
*info
, FILE *f
)
447 fprintf(f
, "%s:\n", __func__
+8);
448 DUMP_M(uint
, info
, buffers
);
449 DUMP_M(color_union
, info
, color
);
450 DUMP_M(double, info
, depth
);
451 DUMP_M(hex
, info
, stencil
);
455 dd_dump_clear_buffer(struct dd_context
*dctx
, struct call_clear_buffer
*info
,
459 const char *value
= (const char*)info
->clear_value
;
461 fprintf(f
, "%s:\n", __func__
+8);
462 DUMP_M(resource
, info
, res
);
463 DUMP_M(uint
, info
, offset
);
464 DUMP_M(uint
, info
, size
);
465 DUMP_M(uint
, info
, clear_value_size
);
467 fprintf(f
, " clear_value:");
468 for (i
= 0; i
< info
->clear_value_size
; i
++)
469 fprintf(f
, " %02x", value
[i
]);
474 dd_dump_clear_render_target(struct dd_context
*dctx
, FILE *f
)
476 fprintf(f
, "%s:\n", __func__
+8);
481 dd_dump_clear_depth_stencil(struct dd_context
*dctx
, FILE *f
)
483 fprintf(f
, "%s:\n", __func__
+8);
488 dd_dump_driver_state(struct dd_context
*dctx
, FILE *f
, unsigned flags
)
490 if (dctx
->pipe
->dump_debug_state
) {
491 fprintf(f
,"\n\n**************************************************"
492 "***************************\n");
493 fprintf(f
, "Driver-specific state:\n\n");
494 dctx
->pipe
->dump_debug_state(dctx
->pipe
, f
, flags
);
499 dd_dump_call(struct dd_context
*dctx
, struct dd_call
*call
, unsigned flags
)
501 FILE *f
= dd_get_file_stream(dctx
);
506 switch (call
->type
) {
508 dd_dump_draw_vbo(dctx
, &call
->info
.draw_vbo
, f
);
510 case CALL_RESOURCE_COPY_REGION
:
511 dd_dump_resource_copy_region(dctx
, &call
->info
.resource_copy_region
, f
);
514 dd_dump_blit(dctx
, &call
->info
.blit
, f
);
516 case CALL_FLUSH_RESOURCE
:
517 dd_dump_flush_resource(dctx
, call
->info
.flush_resource
, f
);
520 dd_dump_clear(dctx
, &call
->info
.clear
, f
);
522 case CALL_CLEAR_BUFFER
:
523 dd_dump_clear_buffer(dctx
, &call
->info
.clear_buffer
, f
);
525 case CALL_CLEAR_RENDER_TARGET
:
526 dd_dump_clear_render_target(dctx
, f
);
528 case CALL_CLEAR_DEPTH_STENCIL
:
529 dd_dump_clear_depth_stencil(dctx
, f
);
532 dd_dump_driver_state(dctx
, f
, flags
);
533 dd_close_file_stream(f
);
537 dd_kill_process(void)
540 fprintf(stderr
, "dd: Aborting the process...\n");
547 dd_flush_and_check_hang(struct dd_context
*dctx
,
548 struct pipe_fence_handle
**flush_fence
,
549 unsigned flush_flags
)
551 struct pipe_fence_handle
*fence
= NULL
;
552 struct pipe_context
*pipe
= dctx
->pipe
;
553 struct pipe_screen
*screen
= pipe
->screen
;
554 uint64_t timeout_ms
= dd_screen(dctx
->base
.screen
)->timeout_ms
;
557 assert(timeout_ms
> 0);
559 pipe
->flush(pipe
, &fence
, flush_flags
);
561 screen
->fence_reference(screen
, flush_fence
, fence
);
565 idle
= screen
->fence_finish(screen
, fence
, timeout_ms
* 1000000);
566 screen
->fence_reference(screen
, &fence
, NULL
);
568 fprintf(stderr
, "dd: GPU hang detected!\n");
573 dd_flush_and_handle_hang(struct dd_context
*dctx
,
574 struct pipe_fence_handle
**fence
, unsigned flags
,
577 if (dd_flush_and_check_hang(dctx
, fence
, flags
)) {
578 FILE *f
= dd_get_file_stream(dctx
);
581 fprintf(f
, "dd: %s.\n", cause
);
582 dd_dump_driver_state(dctx
, f
, PIPE_DEBUG_DEVICE_IS_HUNG
);
583 dd_close_file_stream(f
);
586 /* Terminate the process to prevent future hangs. */
592 dd_context_flush(struct pipe_context
*_pipe
,
593 struct pipe_fence_handle
**fence
, unsigned flags
)
595 struct dd_context
*dctx
= dd_context(_pipe
);
596 struct pipe_context
*pipe
= dctx
->pipe
;
598 switch (dd_screen(dctx
->base
.screen
)->mode
) {
599 case DD_DETECT_HANGS
:
600 dd_flush_and_handle_hang(dctx
, fence
, flags
,
601 "GPU hang detected in pipe->flush()");
603 case DD_DUMP_ALL_CALLS
:
604 pipe
->flush(pipe
, fence
, flags
);
612 dd_before_draw(struct dd_context
*dctx
)
614 if (dd_screen(dctx
->base
.screen
)->mode
== DD_DETECT_HANGS
&&
615 !dd_screen(dctx
->base
.screen
)->no_flush
)
616 dd_flush_and_handle_hang(dctx
, NULL
, 0,
617 "GPU hang most likely caused by internal "
622 dd_after_draw(struct dd_context
*dctx
, struct dd_call
*call
)
624 switch (dd_screen(dctx
->base
.screen
)->mode
) {
625 case DD_DETECT_HANGS
:
626 if (!dd_screen(dctx
->base
.screen
)->no_flush
&&
627 dd_flush_and_check_hang(dctx
, NULL
, 0)) {
628 dd_dump_call(dctx
, call
, PIPE_DEBUG_DEVICE_IS_HUNG
);
630 /* Terminate the process to prevent future hangs. */
634 case DD_DUMP_ALL_CALLS
:
635 dd_dump_call(dctx
, call
, 0);
643 dd_context_draw_vbo(struct pipe_context
*_pipe
,
644 const struct pipe_draw_info
*info
)
646 struct dd_context
*dctx
= dd_context(_pipe
);
647 struct pipe_context
*pipe
= dctx
->pipe
;
650 call
.type
= CALL_DRAW_VBO
;
651 call
.info
.draw_vbo
= *info
;
653 dd_before_draw(dctx
);
654 pipe
->draw_vbo(pipe
, info
);
655 dd_after_draw(dctx
, &call
);
659 dd_context_resource_copy_region(struct pipe_context
*_pipe
,
660 struct pipe_resource
*dst
, unsigned dst_level
,
661 unsigned dstx
, unsigned dsty
, unsigned dstz
,
662 struct pipe_resource
*src
, unsigned src_level
,
663 const struct pipe_box
*src_box
)
665 struct dd_context
*dctx
= dd_context(_pipe
);
666 struct pipe_context
*pipe
= dctx
->pipe
;
669 call
.type
= CALL_RESOURCE_COPY_REGION
;
670 call
.info
.resource_copy_region
.dst
= dst
;
671 call
.info
.resource_copy_region
.dst_level
= dst_level
;
672 call
.info
.resource_copy_region
.dstx
= dstx
;
673 call
.info
.resource_copy_region
.dsty
= dsty
;
674 call
.info
.resource_copy_region
.dstz
= dstz
;
675 call
.info
.resource_copy_region
.src
= src
;
676 call
.info
.resource_copy_region
.src_level
= src_level
;
677 call
.info
.resource_copy_region
.src_box
= src_box
;
679 dd_before_draw(dctx
);
680 pipe
->resource_copy_region(pipe
,
681 dst
, dst_level
, dstx
, dsty
, dstz
,
682 src
, src_level
, src_box
);
683 dd_after_draw(dctx
, &call
);
687 dd_context_blit(struct pipe_context
*_pipe
, const struct pipe_blit_info
*info
)
689 struct dd_context
*dctx
= dd_context(_pipe
);
690 struct pipe_context
*pipe
= dctx
->pipe
;
693 call
.type
= CALL_BLIT
;
694 call
.info
.blit
= *info
;
696 dd_before_draw(dctx
);
697 pipe
->blit(pipe
, info
);
698 dd_after_draw(dctx
, &call
);
702 dd_context_flush_resource(struct pipe_context
*_pipe
,
703 struct pipe_resource
*resource
)
705 struct dd_context
*dctx
= dd_context(_pipe
);
706 struct pipe_context
*pipe
= dctx
->pipe
;
709 call
.type
= CALL_FLUSH_RESOURCE
;
710 call
.info
.flush_resource
= resource
;
712 dd_before_draw(dctx
);
713 pipe
->flush_resource(pipe
, resource
);
714 dd_after_draw(dctx
, &call
);
718 dd_context_clear(struct pipe_context
*_pipe
, unsigned buffers
,
719 const union pipe_color_union
*color
, double depth
,
722 struct dd_context
*dctx
= dd_context(_pipe
);
723 struct pipe_context
*pipe
= dctx
->pipe
;
726 call
.type
= CALL_CLEAR
;
727 call
.info
.clear
.buffers
= buffers
;
728 call
.info
.clear
.color
= color
;
729 call
.info
.clear
.depth
= depth
;
730 call
.info
.clear
.stencil
= stencil
;
732 dd_before_draw(dctx
);
733 pipe
->clear(pipe
, buffers
, color
, depth
, stencil
);
734 dd_after_draw(dctx
, &call
);
738 dd_context_clear_render_target(struct pipe_context
*_pipe
,
739 struct pipe_surface
*dst
,
740 const union pipe_color_union
*color
,
741 unsigned dstx
, unsigned dsty
,
742 unsigned width
, unsigned height
)
744 struct dd_context
*dctx
= dd_context(_pipe
);
745 struct pipe_context
*pipe
= dctx
->pipe
;
748 call
.type
= CALL_CLEAR_RENDER_TARGET
;
750 dd_before_draw(dctx
);
751 pipe
->clear_render_target(pipe
, dst
, color
, dstx
, dsty
, width
, height
);
752 dd_after_draw(dctx
, &call
);
756 dd_context_clear_depth_stencil(struct pipe_context
*_pipe
,
757 struct pipe_surface
*dst
, unsigned clear_flags
,
758 double depth
, unsigned stencil
, unsigned dstx
,
759 unsigned dsty
, unsigned width
, unsigned height
)
761 struct dd_context
*dctx
= dd_context(_pipe
);
762 struct pipe_context
*pipe
= dctx
->pipe
;
765 call
.type
= CALL_CLEAR_DEPTH_STENCIL
;
767 dd_before_draw(dctx
);
768 pipe
->clear_depth_stencil(pipe
, dst
, clear_flags
, depth
, stencil
,
769 dstx
, dsty
, width
, height
);
770 dd_after_draw(dctx
, &call
);
774 dd_context_clear_buffer(struct pipe_context
*_pipe
, struct pipe_resource
*res
,
775 unsigned offset
, unsigned size
,
776 const void *clear_value
, int clear_value_size
)
778 struct dd_context
*dctx
= dd_context(_pipe
);
779 struct pipe_context
*pipe
= dctx
->pipe
;
782 call
.type
= CALL_CLEAR_BUFFER
;
783 call
.info
.clear_buffer
.res
= res
;
784 call
.info
.clear_buffer
.offset
= offset
;
785 call
.info
.clear_buffer
.size
= size
;
786 call
.info
.clear_buffer
.clear_value
= clear_value
;
787 call
.info
.clear_buffer
.clear_value_size
= clear_value_size
;
789 dd_before_draw(dctx
);
790 pipe
->clear_buffer(pipe
, res
, offset
, size
, clear_value
, clear_value_size
);
791 dd_after_draw(dctx
, &call
);
795 dd_init_draw_functions(struct dd_context
*dctx
)
799 CTX_INIT(resource_copy_region
);
802 CTX_INIT(clear_render_target
);
803 CTX_INIT(clear_depth_stencil
);
804 CTX_INIT(clear_buffer
);
805 CTX_INIT(flush_resource
);