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_gen8(const struct ilo_render
*render
,
192 const struct ilo_state_vector
*vec
);
195 ilo_render_get_draw_commands_len(const struct ilo_render
*render
,
196 const struct ilo_state_vector
*vec
)
198 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(8))
199 return ilo_render_get_draw_commands_len_gen8(render
, vec
);
200 else if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
201 return ilo_render_get_draw_commands_len_gen7(render
, vec
);
203 return ilo_render_get_draw_commands_len_gen6(render
, vec
);
207 ilo_render_emit_draw_commands_gen6(struct ilo_render
*render
,
208 const struct ilo_state_vector
*vec
,
209 struct ilo_render_draw_session
*session
);
212 ilo_render_emit_draw_commands_gen7(struct ilo_render
*render
,
213 const struct ilo_state_vector
*vec
,
214 struct ilo_render_draw_session
*session
);
217 ilo_render_emit_draw_commands_gen8(struct ilo_render
*render
,
218 const struct ilo_state_vector
*vec
,
219 struct ilo_render_draw_session
*session
);
222 ilo_render_emit_draw_commands(struct ilo_render
*render
,
223 const struct ilo_state_vector
*vec
,
224 struct ilo_render_draw_session
*session
)
226 const unsigned batch_used
= ilo_builder_batch_used(render
->builder
);
228 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(8))
229 ilo_render_emit_draw_commands_gen8(render
, vec
, session
);
230 else if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
231 ilo_render_emit_draw_commands_gen7(render
, vec
, session
);
233 ilo_render_emit_draw_commands_gen6(render
, vec
, session
);
235 assert(ilo_builder_batch_used(render
->builder
) <= batch_used
+
236 ilo_render_get_draw_commands_len(render
, vec
));
240 ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render
*render
,
241 const struct ilo_blitter
*blitter
);
244 ilo_render_get_rectlist_commands_len_gen8(const struct ilo_render
*render
,
245 const struct ilo_blitter
*blitter
);
248 ilo_render_get_rectlist_commands_len(const struct ilo_render
*render
,
249 const struct ilo_blitter
*blitter
)
251 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(8))
252 return ilo_render_get_rectlist_commands_len_gen8(render
, blitter
);
254 return ilo_render_get_rectlist_commands_len_gen6(render
, blitter
);
258 ilo_render_emit_rectlist_commands_gen6(struct ilo_render
*r
,
259 const struct ilo_blitter
*blitter
,
260 const struct ilo_render_rectlist_session
*session
);
263 ilo_render_emit_rectlist_commands_gen7(struct ilo_render
*r
,
264 const struct ilo_blitter
*blitter
,
265 const struct ilo_render_rectlist_session
*session
);
268 ilo_render_emit_rectlist_commands_gen8(struct ilo_render
*r
,
269 const struct ilo_blitter
*blitter
,
270 const struct ilo_render_rectlist_session
*session
);
273 ilo_render_emit_rectlist_commands(struct ilo_render
*render
,
274 const struct ilo_blitter
*blitter
,
275 const struct ilo_render_rectlist_session
*session
)
277 const unsigned batch_used
= ilo_builder_batch_used(render
->builder
);
279 if (ilo_dev_gen(render
->dev
) >= ILO_GEN(8))
280 ilo_render_emit_rectlist_commands_gen8(render
, blitter
, session
);
281 else if (ilo_dev_gen(render
->dev
) >= ILO_GEN(7))
282 ilo_render_emit_rectlist_commands_gen7(render
, blitter
, session
);
284 ilo_render_emit_rectlist_commands_gen6(render
, blitter
, session
);
286 assert(ilo_builder_batch_used(render
->builder
) <= batch_used
+
287 ilo_render_get_rectlist_commands_len(render
, blitter
));
291 ilo_render_get_launch_grid_commands_len(const struct ilo_render
*render
,
292 const struct ilo_state_vector
*vec
);
295 ilo_render_emit_launch_grid_commands(struct ilo_render
*render
,
296 const struct ilo_state_vector
*vec
,
297 const struct ilo_render_launch_grid_session
*session
);
300 ilo_render_get_draw_dynamic_states_len(const struct ilo_render
*render
,
301 const struct ilo_state_vector
*vec
);
304 ilo_render_emit_draw_dynamic_states(struct ilo_render
*render
,
305 const struct ilo_state_vector
*vec
,
306 struct ilo_render_draw_session
*session
);
309 ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render
*render
,
310 const struct ilo_blitter
*blitter
);
313 ilo_render_emit_rectlist_dynamic_states(struct ilo_render
*render
,
314 const struct ilo_blitter
*blitter
,
315 struct ilo_render_rectlist_session
*session
);
318 ilo_render_get_launch_grid_dynamic_states_len(const struct ilo_render
*render
,
319 const struct ilo_state_vector
*vec
);
322 ilo_render_emit_launch_grid_dynamic_states(struct ilo_render
*render
,
323 const struct ilo_state_vector
*vec
,
324 struct ilo_render_launch_grid_session
*session
);
327 ilo_render_get_draw_surface_states_len(const struct ilo_render
*render
,
328 const struct ilo_state_vector
*vec
);
331 ilo_render_emit_draw_surface_states(struct ilo_render
*render
,
332 const struct ilo_state_vector
*vec
,
333 struct ilo_render_draw_session
*session
);
336 ilo_render_get_launch_grid_surface_states_len(const struct ilo_render
*render
,
337 const struct ilo_state_vector
*vec
);
340 ilo_render_emit_launch_grid_surface_states(struct ilo_render
*render
,
341 const struct ilo_state_vector
*vec
,
342 struct ilo_render_launch_grid_session
*session
);
345 gen6_wa_pre_pipe_control(struct ilo_render
*r
, uint32_t dw1
);
348 gen6_draw_common_select(struct ilo_render
*r
,
349 const struct ilo_state_vector
*ilo
,
350 struct ilo_render_draw_session
*session
);
353 gen6_draw_common_sip(struct ilo_render
*r
,
354 const struct ilo_state_vector
*ilo
,
355 struct ilo_render_draw_session
*session
);
358 gen6_draw_common_base_address(struct ilo_render
*r
,
359 const struct ilo_state_vector
*ilo
,
360 struct ilo_render_draw_session
*session
);
363 gen6_draw_vf(struct ilo_render
*r
,
364 const struct ilo_state_vector
*ilo
,
365 struct ilo_render_draw_session
*session
);
368 gen6_draw_vf_statistics(struct ilo_render
*r
,
369 const struct ilo_state_vector
*ilo
,
370 struct ilo_render_draw_session
*session
);
373 gen6_draw_vs(struct ilo_render
*r
,
374 const struct ilo_state_vector
*ilo
,
375 struct ilo_render_draw_session
*session
);
378 gen6_draw_clip(struct ilo_render
*r
,
379 const struct ilo_state_vector
*ilo
,
380 struct ilo_render_draw_session
*session
);
383 gen6_draw_sf_rect(struct ilo_render
*r
,
384 const struct ilo_state_vector
*ilo
,
385 struct ilo_render_draw_session
*session
);
388 gen6_draw_wm_raster(struct ilo_render
*r
,
389 const struct ilo_state_vector
*ilo
,
390 struct ilo_render_draw_session
*session
);
393 gen7_draw_common_pcb_alloc(struct ilo_render
*r
,
394 const struct ilo_state_vector
*vec
,
395 struct ilo_render_draw_session
*session
);
398 gen7_draw_common_pointers_1(struct ilo_render
*r
,
399 const struct ilo_state_vector
*vec
,
400 struct ilo_render_draw_session
*session
);
403 gen7_draw_common_urb(struct ilo_render
*r
,
404 const struct ilo_state_vector
*vec
,
405 struct ilo_render_draw_session
*session
);
408 gen7_draw_common_pointers_2(struct ilo_render
*r
,
409 const struct ilo_state_vector
*vec
,
410 struct ilo_render_draw_session
*session
);
413 gen7_draw_vs(struct ilo_render
*r
,
414 const struct ilo_state_vector
*vec
,
415 struct ilo_render_draw_session
*session
);
418 gen7_draw_ds(struct ilo_render
*r
,
419 const struct ilo_state_vector
*vec
,
420 struct ilo_render_draw_session
*session
);
423 gen7_draw_te(struct ilo_render
*r
,
424 const struct ilo_state_vector
*vec
,
425 struct ilo_render_draw_session
*session
);
428 gen7_draw_hs(struct ilo_render
*r
,
429 const struct ilo_state_vector
*vec
,
430 struct ilo_render_draw_session
*session
);
433 gen7_draw_gs(struct ilo_render
*r
,
434 const struct ilo_state_vector
*vec
,
435 struct ilo_render_draw_session
*session
);
438 gen7_draw_sol(struct ilo_render
*r
,
439 const struct ilo_state_vector
*vec
,
440 struct ilo_render_draw_session
*session
);
442 #endif /* ILO_RENDER_GEN_H */