ilo: add ILO_3D_PIPELINE_WRITE_STATISTICS
[mesa.git] / src / gallium / drivers / ilo / ilo_3d_pipeline.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2013 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_3D_PIPELINE_H
29 #define ILO_3D_PIPELINE_H
30
31 #include "ilo_common.h"
32 #include "ilo_gpe.h"
33
34 struct intel_bo;
35 struct ilo_blitter;
36 struct ilo_cp;
37 struct ilo_context;
38
39 enum ilo_3d_pipeline_invalidate_flags {
40 ILO_3D_PIPELINE_INVALIDATE_HW = 1 << 0,
41 ILO_3D_PIPELINE_INVALIDATE_BATCH_BO = 1 << 1,
42 ILO_3D_PIPELINE_INVALIDATE_STATE_BO = 1 << 2,
43 ILO_3D_PIPELINE_INVALIDATE_KERNEL_BO = 1 << 3,
44
45 ILO_3D_PIPELINE_INVALIDATE_ALL = 0xffffffff,
46 };
47
48 enum ilo_3d_pipeline_action {
49 ILO_3D_PIPELINE_DRAW,
50 ILO_3D_PIPELINE_FLUSH,
51 ILO_3D_PIPELINE_WRITE_TIMESTAMP,
52 ILO_3D_PIPELINE_WRITE_DEPTH_COUNT,
53 ILO_3D_PIPELINE_WRITE_STATISTICS,
54 ILO_3D_PIPELINE_RECTLIST,
55 };
56
57 /**
58 * 3D pipeline.
59 */
60 struct ilo_3d_pipeline {
61 struct ilo_cp *cp;
62 const struct ilo_dev_info *dev;
63
64 uint32_t invalidate_flags;
65
66 struct intel_bo *workaround_bo;
67
68 uint32_t packed_sample_position_1x;
69 uint32_t packed_sample_position_4x;
70 uint32_t packed_sample_position_8x[2];
71
72 int (*estimate_size)(struct ilo_3d_pipeline *pipeline,
73 enum ilo_3d_pipeline_action action,
74 const void *arg);
75
76 void (*emit_draw)(struct ilo_3d_pipeline *pipeline,
77 const struct ilo_context *ilo);
78
79 void (*emit_flush)(struct ilo_3d_pipeline *pipeline);
80
81 void (*emit_write_timestamp)(struct ilo_3d_pipeline *pipeline,
82 struct intel_bo *bo, int index);
83
84 void (*emit_write_depth_count)(struct ilo_3d_pipeline *pipeline,
85 struct intel_bo *bo, int index);
86
87 void (*emit_write_statistics)(struct ilo_3d_pipeline *pipeline,
88 struct intel_bo *bo, int index);
89
90 void (*emit_rectlist)(struct ilo_3d_pipeline *pipeline,
91 const struct ilo_blitter *blitter);
92
93 /**
94 * HW states.
95 */
96 struct ilo_3d_pipeline_state {
97 bool has_gen6_wa_pipe_control;
98
99 bool primitive_restart;
100 int reduced_prim;
101 int so_num_vertices, so_max_vertices;
102
103 uint32_t SF_VIEWPORT;
104 uint32_t CLIP_VIEWPORT;
105 uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */
106 uint32_t CC_VIEWPORT;
107
108 uint32_t COLOR_CALC_STATE;
109 uint32_t BLEND_STATE;
110 uint32_t DEPTH_STENCIL_STATE;
111
112 uint32_t SCISSOR_RECT;
113
114 struct {
115 uint32_t BINDING_TABLE_STATE;
116 int BINDING_TABLE_STATE_size;
117 uint32_t SURFACE_STATE[ILO_MAX_VS_SURFACES];
118 uint32_t SAMPLER_STATE;
119 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
120 uint32_t PUSH_CONSTANT_BUFFER;
121 int PUSH_CONSTANT_BUFFER_size;
122 } vs;
123
124 struct {
125 uint32_t BINDING_TABLE_STATE;
126 int BINDING_TABLE_STATE_size;
127 uint32_t SURFACE_STATE[ILO_MAX_GS_SURFACES];
128 bool active;
129 } gs;
130
131 struct {
132 uint32_t BINDING_TABLE_STATE;
133 int BINDING_TABLE_STATE_size;
134 uint32_t SURFACE_STATE[ILO_MAX_WM_SURFACES];
135 uint32_t SAMPLER_STATE;
136 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
137 uint32_t PUSH_CONSTANT_BUFFER;
138 int PUSH_CONSTANT_BUFFER_size;
139 } wm;
140 } state;
141 };
142
143 struct ilo_3d_pipeline *
144 ilo_3d_pipeline_create(struct ilo_cp *cp, const struct ilo_dev_info *dev);
145
146 void
147 ilo_3d_pipeline_destroy(struct ilo_3d_pipeline *pipeline);
148
149
150 static inline void
151 ilo_3d_pipeline_invalidate(struct ilo_3d_pipeline *p, uint32_t flags)
152 {
153 p->invalidate_flags |= flags;
154 }
155
156 /**
157 * Estimate the size of an action.
158 */
159 static inline int
160 ilo_3d_pipeline_estimate_size(struct ilo_3d_pipeline *pipeline,
161 enum ilo_3d_pipeline_action action,
162 const void *arg)
163 {
164 return pipeline->estimate_size(pipeline, action, arg);
165 }
166
167 bool
168 ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
169 const struct ilo_context *ilo,
170 int *prim_generated, int *prim_emitted);
171
172 void
173 ilo_3d_pipeline_emit_flush(struct ilo_3d_pipeline *p);
174
175 void
176 ilo_3d_pipeline_emit_write_timestamp(struct ilo_3d_pipeline *p,
177 struct intel_bo *bo, int index);
178
179 void
180 ilo_3d_pipeline_emit_write_depth_count(struct ilo_3d_pipeline *p,
181 struct intel_bo *bo, int index);
182
183 void
184 ilo_3d_pipeline_emit_write_statistics(struct ilo_3d_pipeline *p,
185 struct intel_bo *bo, int index);
186
187 void
188 ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
189 const struct ilo_blitter *blitter);
190
191 void
192 ilo_3d_pipeline_get_sample_position(struct ilo_3d_pipeline *p,
193 unsigned sample_count,
194 unsigned sample_index,
195 float *x, float *y);
196
197 void
198 ilo_3d_pipeline_dump(struct ilo_3d_pipeline *p);
199
200 #endif /* ILO_3D_PIPELINE_H */