2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
25 * Chia-I Wu <olv@lunarg.com>
28 #ifndef ILO_RENDER_GEN_H
29 #define ILO_RENDER_GEN_H
31 #include "ilo_common.h"
32 #include "ilo_builder.h"
33 #include "ilo_state.h"
34 #include "ilo_render.h"
39 struct ilo_state_vector
;
45 const struct ilo_dev_info
*dev
;
46 struct ilo_builder
*builder
;
48 struct intel_bo
*workaround_bo
;
50 uint32_t sample_pattern_1x
;
51 uint32_t sample_pattern_2x
;
52 uint32_t sample_pattern_4x
;
53 uint32_t sample_pattern_8x
[2];
54 uint32_t sample_pattern_16x
[4];
59 * Any state that involves resources needs to be re-emitted when the
60 * batch bo changed. This is because we do not pin the resources and
61 * their offsets (or existence) may change between batch buffers.
63 bool batch_bo_changed
;
64 bool state_bo_changed
;
65 bool instruction_bo_changed
;
70 struct ilo_render_state
{
72 * When a WA is needed before some command, we always emit the WA right
73 * before the command. Knowing what have already been done since last
74 * 3DPRIMITIVE allows us to skip some WAs.
76 uint32_t current_pipe_control_dw1
;
79 * When a WA is needed after some command, we may have the WA follow the
80 * command immediately or defer it. If this is non-zero, a PIPE_CONTROL
81 * will be emitted before 3DPRIMITIVE.
83 uint32_t deferred_pipe_control_dw1
;
85 bool primitive_restart
;
90 uint32_t CLIP_VIEWPORT
;
91 uint32_t SF_CLIP_VIEWPORT
; /* GEN7+ */
94 uint32_t COLOR_CALC_STATE
;
96 uint32_t DEPTH_STENCIL_STATE
;
98 uint32_t SCISSOR_RECT
;
101 uint32_t BINDING_TABLE_STATE
;
102 uint32_t SURFACE_STATE
[ILO_MAX_SURFACES
];
103 uint32_t SAMPLER_STATE
;
104 uint32_t SAMPLER_BORDER_COLOR_STATE
[ILO_MAX_SAMPLERS
];
105 uint32_t PUSH_CONSTANT_BUFFER
;
106 int PUSH_CONSTANT_BUFFER_size
;
110 uint32_t BINDING_TABLE_STATE
;
111 uint32_t SURFACE_STATE
[ILO_MAX_SURFACES
];
116 uint32_t BINDING_TABLE_STATE
;
117 uint32_t SURFACE_STATE
[ILO_MAX_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
;
125 uint32_t BINDING_TABLE_STATE
;
126 uint32_t SURFACE_STATE
[ILO_MAX_SURFACES
];
127 uint32_t SAMPLER_STATE
;
128 uint32_t SAMPLER_BORDER_COLOR_STATE
[ILO_MAX_SAMPLERS
];
129 uint32_t PUSH_CONSTANT_BUFFER
;
130 int PUSH_CONSTANT_BUFFER_size
;
135 struct ilo_render_draw_session
{
142 bool primitive_restart_changed
;
145 bool viewport_changed
;
146 bool scissor_changed
;
152 bool sampler_vs_changed
;
153 bool sampler_gs_changed
;
154 bool sampler_fs_changed
;
161 bool binding_table_vs_changed
;
162 bool binding_table_gs_changed
;
163 bool binding_table_fs_changed
;
166 struct ilo_render_rectlist_session
{
171 struct ilo_render_launch_grid_session
{
172 const unsigned *thread_group_offset
;
173 const unsigned *thread_group_dim
;
174 unsigned thread_group_size
;
175 const struct pipe_constant_buffer
*input
;
183 ilo_render_get_draw_commands_len_gen6(const struct ilo_render
*render
,
184 const struct ilo_state_vector
*vec
);
187 ilo_render_get_draw_commands_len_gen7(const struct ilo_render
*render
,
188 const struct ilo_state_vector
*vec
);
191 ilo_render_get_draw_commands_len(const struct ilo_render
*render
,
192 const struct ilo_state_vector
*vec
)
194 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
195 return ilo_render_get_draw_commands_len_gen7(render
, vec
);
197 return ilo_render_get_draw_commands_len_gen6(render
, vec
);
201 ilo_render_emit_draw_commands_gen6(struct ilo_render
*render
,
202 const struct ilo_state_vector
*vec
,
203 struct ilo_render_draw_session
*session
);
206 ilo_render_emit_draw_commands_gen7(struct ilo_render
*render
,
207 const struct ilo_state_vector
*vec
,
208 struct ilo_render_draw_session
*session
);
211 ilo_render_emit_draw_commands(struct ilo_render
*render
,
212 const struct ilo_state_vector
*vec
,
213 struct ilo_render_draw_session
*session
)
215 const unsigned batch_used
= ilo_builder_batch_used(render
->builder
);
217 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
218 ilo_render_emit_draw_commands_gen7(render
, vec
, session
);
220 ilo_render_emit_draw_commands_gen6(render
, vec
, session
);
222 assert(ilo_builder_batch_used(render
->builder
) <= batch_used
+
223 ilo_render_get_draw_commands_len(render
, vec
));
227 ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render
*render
,
228 const struct ilo_blitter
*blitter
);
231 ilo_render_get_rectlist_commands_len(const struct ilo_render
*render
,
232 const struct ilo_blitter
*blitter
)
234 return ilo_render_get_rectlist_commands_len_gen6(render
, blitter
);
238 ilo_render_emit_rectlist_commands_gen6(struct ilo_render
*r
,
239 const struct ilo_blitter
*blitter
,
240 const struct ilo_render_rectlist_session
*session
);
243 ilo_render_emit_rectlist_commands_gen7(struct ilo_render
*r
,
244 const struct ilo_blitter
*blitter
,
245 const struct ilo_render_rectlist_session
*session
);
248 ilo_render_emit_rectlist_commands(struct ilo_render
*render
,
249 const struct ilo_blitter
*blitter
,
250 const struct ilo_render_rectlist_session
*session
)
252 const unsigned batch_used
= ilo_builder_batch_used(render
->builder
);
254 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
255 ilo_render_emit_rectlist_commands_gen7(render
, blitter
, session
);
257 ilo_render_emit_rectlist_commands_gen6(render
, blitter
, session
);
259 assert(ilo_builder_batch_used(render
->builder
) <= batch_used
+
260 ilo_render_get_rectlist_commands_len(render
, blitter
));
264 ilo_render_get_launch_grid_commands_len(const struct ilo_render
*render
,
265 const struct ilo_state_vector
*vec
);
268 ilo_render_emit_launch_grid_commands(struct ilo_render
*render
,
269 const struct ilo_state_vector
*vec
,
270 const struct ilo_render_launch_grid_session
*session
);
273 ilo_render_get_draw_dynamic_states_len(const struct ilo_render
*render
,
274 const struct ilo_state_vector
*vec
);
277 ilo_render_emit_draw_dynamic_states(struct ilo_render
*render
,
278 const struct ilo_state_vector
*vec
,
279 struct ilo_render_draw_session
*session
);
282 ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render
*render
,
283 const struct ilo_blitter
*blitter
);
286 ilo_render_emit_rectlist_dynamic_states(struct ilo_render
*render
,
287 const struct ilo_blitter
*blitter
,
288 struct ilo_render_rectlist_session
*session
);
291 ilo_render_get_launch_grid_dynamic_states_len(const struct ilo_render
*render
,
292 const struct ilo_state_vector
*vec
);
295 ilo_render_emit_launch_grid_dynamic_states(struct ilo_render
*render
,
296 const struct ilo_state_vector
*vec
,
297 struct ilo_render_launch_grid_session
*session
);
300 ilo_render_get_draw_surface_states_len(const struct ilo_render
*render
,
301 const struct ilo_state_vector
*vec
);
304 ilo_render_emit_draw_surface_states(struct ilo_render
*render
,
305 const struct ilo_state_vector
*vec
,
306 struct ilo_render_draw_session
*session
);
309 ilo_render_get_launch_grid_surface_states_len(const struct ilo_render
*render
,
310 const struct ilo_state_vector
*vec
);
313 ilo_render_emit_launch_grid_surface_states(struct ilo_render
*render
,
314 const struct ilo_state_vector
*vec
,
315 struct ilo_render_launch_grid_session
*session
);
318 gen6_wa_pre_pipe_control(struct ilo_render
*r
, uint32_t dw1
);
321 gen6_draw_common_select(struct ilo_render
*r
,
322 const struct ilo_state_vector
*ilo
,
323 struct ilo_render_draw_session
*session
);
326 gen6_draw_common_sip(struct ilo_render
*r
,
327 const struct ilo_state_vector
*ilo
,
328 struct ilo_render_draw_session
*session
);
331 gen6_draw_common_base_address(struct ilo_render
*r
,
332 const struct ilo_state_vector
*ilo
,
333 struct ilo_render_draw_session
*session
);
336 gen6_draw_vf(struct ilo_render
*r
,
337 const struct ilo_state_vector
*ilo
,
338 struct ilo_render_draw_session
*session
);
341 gen6_draw_vf_statistics(struct ilo_render
*r
,
342 const struct ilo_state_vector
*ilo
,
343 struct ilo_render_draw_session
*session
);
346 gen6_draw_vs(struct ilo_render
*r
,
347 const struct ilo_state_vector
*ilo
,
348 struct ilo_render_draw_session
*session
);
351 gen6_draw_clip(struct ilo_render
*r
,
352 const struct ilo_state_vector
*ilo
,
353 struct ilo_render_draw_session
*session
);
356 gen6_draw_sf_rect(struct ilo_render
*r
,
357 const struct ilo_state_vector
*ilo
,
358 struct ilo_render_draw_session
*session
);
361 gen6_draw_wm_raster(struct ilo_render
*r
,
362 const struct ilo_state_vector
*ilo
,
363 struct ilo_render_draw_session
*session
);
365 #endif /* ILO_RENDER_GEN_H */