ddebug: add an option to dump info about a specific apitrace call
[mesa.git] / src / gallium / drivers / ddebug / dd_pipe.h
1 /**************************************************************************
2 *
3 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Copyright 2008 VMware, Inc.
5 * All Rights Reserved.
6 *
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:
13 *
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
16 * Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #ifndef DD_H_
29 #define DD_H_
30
31 #include "pipe/p_context.h"
32 #include "pipe/p_state.h"
33 #include "pipe/p_screen.h"
34 #include "dd_util.h"
35
36 enum dd_mode {
37 DD_DETECT_HANGS,
38 DD_DUMP_ALL_CALLS,
39 DD_DUMP_APITRACE_CALL,
40 };
41
42 struct dd_screen
43 {
44 struct pipe_screen base;
45 struct pipe_screen *screen;
46 unsigned timeout_ms;
47 enum dd_mode mode;
48 bool no_flush;
49 bool verbose;
50 unsigned skip_count;
51 unsigned apitrace_dump_call;
52 };
53
54 struct dd_query
55 {
56 unsigned type;
57 struct pipe_query *query;
58 };
59
60 struct dd_state
61 {
62 void *cso;
63
64 union {
65 struct pipe_blend_state blend;
66 struct pipe_depth_stencil_alpha_state dsa;
67 struct pipe_rasterizer_state rs;
68 struct pipe_sampler_state sampler;
69 struct {
70 struct pipe_vertex_element velems[PIPE_MAX_ATTRIBS];
71 unsigned count;
72 } velems;
73 struct pipe_shader_state shader;
74 } state;
75 };
76
77 struct dd_context
78 {
79 struct pipe_context base;
80 struct pipe_context *pipe;
81
82 struct {
83 struct dd_query *query;
84 bool condition;
85 unsigned mode;
86 } render_cond;
87
88 struct pipe_index_buffer index_buffer;
89 struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
90
91 unsigned num_so_targets;
92 struct pipe_stream_output_target *so_targets[PIPE_MAX_SO_BUFFERS];
93 unsigned so_offsets[PIPE_MAX_SO_BUFFERS];
94
95 struct dd_state *shaders[PIPE_SHADER_TYPES];
96 struct pipe_constant_buffer constant_buffers[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
97 struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
98 struct dd_state *sampler_states[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
99 struct pipe_image_view shader_images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
100 struct pipe_shader_buffer shader_buffers[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
101
102 struct dd_state *velems;
103 struct dd_state *rs;
104 struct dd_state *dsa;
105 struct dd_state *blend;
106
107 struct pipe_blend_color blend_color;
108 struct pipe_stencil_ref stencil_ref;
109 unsigned sample_mask;
110 unsigned min_samples;
111 struct pipe_clip_state clip_state;
112 struct pipe_framebuffer_state framebuffer_state;
113 struct pipe_poly_stipple polygon_stipple;
114 struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
115 struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS];
116 float tess_default_levels[6];
117
118 unsigned num_draw_calls;
119 unsigned apitrace_call_number;
120 };
121
122
123 struct pipe_context *
124 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe);
125
126 void
127 dd_init_draw_functions(struct dd_context *dctx);
128
129
130 static inline struct dd_context *
131 dd_context(struct pipe_context *pipe)
132 {
133 return (struct dd_context *)pipe;
134 }
135
136 static inline struct dd_screen *
137 dd_screen(struct pipe_screen *screen)
138 {
139 return (struct dd_screen*)screen;
140 }
141
142
143 #define CTX_INIT(_member) \
144 dctx->base._member = dctx->pipe->_member ? dd_context_##_member : NULL
145
146 #endif /* DD_H_ */