2 * Mesa 3-D graphics library
4 * Copyright (C) 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 #include "genhw/genhw.h"
29 #include "core/ilo_builder_3d.h"
30 #include "core/ilo_builder_render.h"
32 #include "ilo_blitter.h"
33 #include "ilo_shader.h"
34 #include "ilo_state.h"
35 #include "ilo_render_gen.h"
38 gen7_wa_post_3dstate_push_constant_alloc_ps(struct ilo_render
*r
)
41 * From the Ivy Bridge PRM, volume 2 part 1, page 292:
43 * "A PIPE_CONTOL command with the CS Stall bit set must be programmed
44 * in the ring after this instruction
45 * (3DSTATE_PUSH_CONSTANT_ALLOC_PS)."
47 const uint32_t dw1
= GEN6_PIPE_CONTROL_CS_STALL
;
49 ILO_DEV_ASSERT(r
->dev
, 7, 7);
51 r
->state
.deferred_pipe_control_dw1
|= dw1
;
55 gen7_wa_pre_vs(struct ilo_render
*r
)
58 * From the Ivy Bridge PRM, volume 2 part 1, page 106:
60 * "A PIPE_CONTROL with Post-Sync Operation set to 1h and a depth stall
61 * needs to be sent just prior to any 3DSTATE_VS, 3DSTATE_URB_VS,
62 * 3DSTATE_CONSTANT_VS, 3DSTATE_BINDING_TABLE_POINTER_VS,
63 * 3DSTATE_SAMPLER_STATE_POINTER_VS command. Only one PIPE_CONTROL
64 * needs to be sent before any combination of VS associated 3DSTATE."
66 const uint32_t dw1
= GEN6_PIPE_CONTROL_DEPTH_STALL
|
67 GEN6_PIPE_CONTROL_WRITE_IMM
;
69 ILO_DEV_ASSERT(r
->dev
, 7, 7);
71 if ((r
->state
.current_pipe_control_dw1
& dw1
) != dw1
)
72 ilo_render_pipe_control(r
, dw1
);
76 gen7_wa_pre_3dstate_sf_depth_bias(struct ilo_render
*r
)
79 * From the Ivy Bridge PRM, volume 2 part 1, page 258:
81 * "Due to an HW issue driver needs to send a pipe control with stall
82 * when ever there is state change in depth bias related state (in
85 const uint32_t dw1
= GEN6_PIPE_CONTROL_CS_STALL
;
87 ILO_DEV_ASSERT(r
->dev
, 7, 7);
89 if ((r
->state
.current_pipe_control_dw1
& dw1
) != dw1
)
90 ilo_render_pipe_control(r
, dw1
);
94 gen7_wa_pre_3dstate_multisample(struct ilo_render
*r
)
97 * From the Ivy Bridge PRM, volume 2 part 1, page 304:
99 * "Driver must ierarchi that all the caches in the depth pipe are
100 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
101 * requires driver to send a PIPE_CONTROL with a CS stall along with a
102 * Depth Flush prior to this command.
104 const uint32_t dw1
= GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH
|
105 GEN6_PIPE_CONTROL_CS_STALL
;
107 ILO_DEV_ASSERT(r
->dev
, 7, 7.5);
109 if ((r
->state
.current_pipe_control_dw1
& dw1
) != dw1
)
110 ilo_render_pipe_control(r
, dw1
);
114 gen7_wa_pre_depth(struct ilo_render
*r
)
116 ILO_DEV_ASSERT(r
->dev
, 7, 7.5);
118 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7)) {
120 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
122 * "Driver must send a least one PIPE_CONTROL command with CS Stall
123 * and a post sync operation prior to the group of depth
124 * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
125 * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)."
127 const uint32_t dw1
= GEN6_PIPE_CONTROL_CS_STALL
|
128 GEN6_PIPE_CONTROL_WRITE_IMM
;
130 if ((r
->state
.current_pipe_control_dw1
& dw1
) != dw1
)
131 ilo_render_pipe_control(r
, dw1
);
135 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
137 * "Restriction: Prior to changing Depth/Stencil Buffer state (i.e.,
138 * any combination of 3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
139 * 3DSTATE_STENCIL_BUFFER, 3DSTATE_HIER_DEPTH_BUFFER) SW must first
140 * issue a pipelined depth stall (PIPE_CONTROL with Depth Stall bit
141 * set), followed by a pipelined depth cache flush (PIPE_CONTROL with
142 * Depth Flush Bit set, followed by another pipelined depth stall
143 * (PIPE_CONTROL with Depth Stall Bit set), unless SW can otherwise
144 * guarantee that the pipeline from WM onwards is already flushed
145 * (e.g., via a preceding MI_FLUSH)."
147 ilo_render_pipe_control(r
, GEN6_PIPE_CONTROL_DEPTH_STALL
);
148 ilo_render_pipe_control(r
, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH
);
149 ilo_render_pipe_control(r
, GEN6_PIPE_CONTROL_DEPTH_STALL
);
153 gen7_wa_pre_3dstate_ps_max_threads(struct ilo_render
*r
)
156 * From the Ivy Bridge PRM, volume 2 part 1, page 286:
158 * "If this field (Maximum Number of Threads in 3DSTATE_PS) is changed
159 * between 3DPRIMITIVE commands, a PIPE_CONTROL command with Stall at
160 * Pixel Scoreboard set is required to be issued."
162 const uint32_t dw1
= GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL
;
164 ILO_DEV_ASSERT(r
->dev
, 7, 7.5);
166 if ((r
->state
.current_pipe_control_dw1
& dw1
) != dw1
)
167 ilo_render_pipe_control(r
, dw1
);
171 gen7_wa_post_ps_and_later(struct ilo_render
*r
)
174 * From the Ivy Bridge PRM, volume 2 part 1, page 276:
176 * "The driver must make sure a PIPE_CONTROL with the Depth Stall
177 * Enable bit set after all the following states are programmed:
180 * - 3DSTATE_VIEWPORT_STATE_POINTERS_CC
181 * - 3DSTATE_CONSTANT_PS
182 * - 3DSTATE_BINDING_TABLE_POINTERS_PS
183 * - 3DSTATE_SAMPLER_STATE_POINTERS_PS
184 * - 3DSTATE_CC_STATE_POINTERS
185 * - 3DSTATE_BLEND_STATE_POINTERS
186 * - 3DSTATE_DEPTH_STENCIL_STATE_POINTERS"
188 const uint32_t dw1
= GEN6_PIPE_CONTROL_DEPTH_STALL
;
190 ILO_DEV_ASSERT(r
->dev
, 7, 7);
192 r
->state
.deferred_pipe_control_dw1
|= dw1
;
195 #define DIRTY(state) (session->pipe_dirty & ILO_DIRTY_ ## state)
198 gen7_draw_common_urb(struct ilo_render
*r
,
199 const struct ilo_state_vector
*vec
,
200 struct ilo_render_draw_session
*session
)
202 /* 3DSTATE_URB_{VS,GS,HS,DS} */
203 if (session
->urb_delta
.dirty
& (ILO_STATE_URB_3DSTATE_URB_VS
|
204 ILO_STATE_URB_3DSTATE_URB_HS
|
205 ILO_STATE_URB_3DSTATE_URB_DS
|
206 ILO_STATE_URB_3DSTATE_URB_GS
)) {
207 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
210 gen7_3DSTATE_URB_VS(r
->builder
, &vec
->urb
);
211 gen7_3DSTATE_URB_GS(r
->builder
, &vec
->urb
);
212 gen7_3DSTATE_URB_HS(r
->builder
, &vec
->urb
);
213 gen7_3DSTATE_URB_DS(r
->builder
, &vec
->urb
);
218 gen7_draw_common_pcb_alloc(struct ilo_render
*r
,
219 const struct ilo_state_vector
*vec
,
220 struct ilo_render_draw_session
*session
)
222 /* 3DSTATE_PUSH_CONSTANT_ALLOC_{VS,PS} */
223 if (session
->urb_delta
.dirty
&
224 (ILO_STATE_URB_3DSTATE_PUSH_CONSTANT_ALLOC_VS
|
225 ILO_STATE_URB_3DSTATE_PUSH_CONSTANT_ALLOC_HS
|
226 ILO_STATE_URB_3DSTATE_PUSH_CONSTANT_ALLOC_DS
|
227 ILO_STATE_URB_3DSTATE_PUSH_CONSTANT_ALLOC_GS
|
228 ILO_STATE_URB_3DSTATE_PUSH_CONSTANT_ALLOC_PS
)) {
229 gen7_3DSTATE_PUSH_CONSTANT_ALLOC_VS(r
->builder
, &vec
->urb
);
230 gen7_3DSTATE_PUSH_CONSTANT_ALLOC_GS(r
->builder
, &vec
->urb
);
231 gen7_3DSTATE_PUSH_CONSTANT_ALLOC_PS(r
->builder
, &vec
->urb
);
233 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
234 gen7_wa_post_3dstate_push_constant_alloc_ps(r
);
239 gen7_draw_common_pointers_1(struct ilo_render
*r
,
240 const struct ilo_state_vector
*vec
,
241 struct ilo_render_draw_session
*session
)
243 /* 3DSTATE_VIEWPORT_STATE_POINTERS_{CC,SF_CLIP} */
244 if (session
->viewport_changed
) {
245 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(r
->builder
,
246 r
->state
.CC_VIEWPORT
);
248 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(r
->builder
,
249 r
->state
.SF_CLIP_VIEWPORT
);
254 gen7_draw_common_pointers_2(struct ilo_render
*r
,
255 const struct ilo_state_vector
*vec
,
256 struct ilo_render_draw_session
*session
)
258 /* 3DSTATE_BLEND_STATE_POINTERS */
259 if (session
->blend_changed
) {
260 gen7_3DSTATE_BLEND_STATE_POINTERS(r
->builder
,
261 r
->state
.BLEND_STATE
);
264 /* 3DSTATE_CC_STATE_POINTERS */
265 if (session
->cc_changed
) {
266 gen7_3DSTATE_CC_STATE_POINTERS(r
->builder
,
267 r
->state
.COLOR_CALC_STATE
);
270 /* 3DSTATE_DEPTH_STENCIL_STATE_POINTERS */
271 if (ilo_dev_gen(r
->dev
) < ILO_GEN(8) && session
->dsa_changed
) {
272 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(r
->builder
,
273 r
->state
.DEPTH_STENCIL_STATE
);
278 gen7_draw_vs(struct ilo_render
*r
,
279 const struct ilo_state_vector
*vec
,
280 struct ilo_render_draw_session
*session
)
282 const bool emit_3dstate_binding_table
= session
->binding_table_vs_changed
;
283 const bool emit_3dstate_sampler_state
= session
->sampler_vs_changed
;
284 /* see gen6_draw_vs() */
285 const bool emit_3dstate_constant_vs
= session
->pcb_vs_changed
;
286 const bool emit_3dstate_vs
= (DIRTY(VS
) || r
->instruction_bo_changed
);
288 /* emit depth stall before any of the VS commands */
289 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7)) {
290 if (emit_3dstate_binding_table
|| emit_3dstate_sampler_state
||
291 emit_3dstate_constant_vs
|| emit_3dstate_vs
)
295 /* 3DSTATE_BINDING_TABLE_POINTERS_VS */
296 if (emit_3dstate_binding_table
) {
297 gen7_3DSTATE_BINDING_TABLE_POINTERS_VS(r
->builder
,
298 r
->state
.vs
.BINDING_TABLE_STATE
);
301 /* 3DSTATE_SAMPLER_STATE_POINTERS_VS */
302 if (emit_3dstate_sampler_state
) {
303 gen7_3DSTATE_SAMPLER_STATE_POINTERS_VS(r
->builder
,
304 r
->state
.vs
.SAMPLER_STATE
);
307 /* 3DSTATE_CONSTANT_VS */
308 if (emit_3dstate_constant_vs
) {
309 gen7_3DSTATE_CONSTANT_VS(r
->builder
,
310 &r
->state
.vs
.PUSH_CONSTANT_BUFFER
,
311 &r
->state
.vs
.PUSH_CONSTANT_BUFFER_size
,
316 if (ilo_dev_gen(r
->dev
) >= ILO_GEN(8)) {
317 if (emit_3dstate_vs
|| DIRTY(RASTERIZER
)) {
318 gen8_3DSTATE_VS(r
->builder
, vec
->vs
,
319 vec
->rasterizer
->state
.clip_plane_enable
);
323 gen6_3DSTATE_VS(r
->builder
, vec
->vs
);
328 gen7_draw_hs(struct ilo_render
*r
,
329 const struct ilo_state_vector
*vec
,
330 struct ilo_render_draw_session
*session
)
332 /* 3DSTATE_CONSTANT_HS and 3DSTATE_HS */
333 if (r
->hw_ctx_changed
) {
334 gen7_3DSTATE_CONSTANT_HS(r
->builder
, 0, 0, 0);
335 gen7_disable_3DSTATE_HS(r
->builder
);
338 /* 3DSTATE_BINDING_TABLE_POINTERS_HS */
339 if (r
->hw_ctx_changed
)
340 gen7_3DSTATE_BINDING_TABLE_POINTERS_HS(r
->builder
, 0);
344 gen7_draw_te(struct ilo_render
*r
,
345 const struct ilo_state_vector
*vec
,
346 struct ilo_render_draw_session
*session
)
349 if (r
->hw_ctx_changed
)
350 gen7_3DSTATE_TE(r
->builder
);
354 gen7_draw_ds(struct ilo_render
*r
,
355 const struct ilo_state_vector
*vec
,
356 struct ilo_render_draw_session
*session
)
358 /* 3DSTATE_CONSTANT_DS and 3DSTATE_DS */
359 if (r
->hw_ctx_changed
) {
360 gen7_3DSTATE_CONSTANT_DS(r
->builder
, 0, 0, 0);
361 gen7_disable_3DSTATE_DS(r
->builder
);
364 /* 3DSTATE_BINDING_TABLE_POINTERS_DS */
365 if (r
->hw_ctx_changed
)
366 gen7_3DSTATE_BINDING_TABLE_POINTERS_DS(r
->builder
, 0);
371 gen7_draw_gs(struct ilo_render
*r
,
372 const struct ilo_state_vector
*vec
,
373 struct ilo_render_draw_session
*session
)
375 /* 3DSTATE_CONSTANT_GS and 3DSTATE_GS */
376 if (r
->hw_ctx_changed
) {
377 gen7_3DSTATE_CONSTANT_GS(r
->builder
, 0, 0, 0);
378 gen7_disable_3DSTATE_GS(r
->builder
);
381 /* 3DSTATE_BINDING_TABLE_POINTERS_GS */
382 if (session
->binding_table_gs_changed
) {
383 gen7_3DSTATE_BINDING_TABLE_POINTERS_GS(r
->builder
,
384 r
->state
.gs
.BINDING_TABLE_STATE
);
389 gen7_draw_sol(struct ilo_render
*r
,
390 const struct ilo_state_vector
*vec
,
391 struct ilo_render_draw_session
*session
)
393 const struct ilo_state_sol
*sol
;
394 const struct ilo_shader_state
*shader
;
395 bool dirty_sh
= false;
399 dirty_sh
= DIRTY(GS
);
403 dirty_sh
= DIRTY(VS
);
406 sol
= ilo_shader_get_kernel_sol(shader
);
408 /* 3DSTATE_SO_BUFFER */
409 if ((DIRTY(SO
) || dirty_sh
|| r
->batch_bo_changed
) &&
411 const struct pipe_stream_output_info
*so_info
;
414 so_info
= ilo_shader_get_kernel_so_info(shader
);
416 for (i
= 0; i
< vec
->so
.count
; i
++) {
417 const int stride
= so_info
->stride
[i
] * 4; /* in bytes */
419 gen7_3DSTATE_SO_BUFFER(r
->builder
, i
, stride
, vec
->so
.states
[i
]);
423 gen7_disable_3DSTATE_SO_BUFFER(r
->builder
, i
);
426 /* 3DSTATE_SO_DECL_LIST */
427 if (dirty_sh
&& vec
->so
.enabled
)
428 gen7_3DSTATE_SO_DECL_LIST(r
->builder
, sol
);
431 * From the Ivy Bridge PRM, volume 2 part 1, page 196-197:
433 * "Anytime the SOL unit MMIO registers or non-pipeline state are
434 * written, the SOL unit needs to receive a pipeline state update with
435 * SOL unit dirty state for information programmed in MMIO/NP to get
436 * loaded into the SOL unit.
438 * The SOL unit incorrectly double buffers MMIO/NP registers and only
439 * moves them into the design for usage when control topology is
440 * received with the SOL unit dirty state.
442 * If the state does not change, need to resend the same state.
444 * Because of corruption, software must flush the whole fixed function
445 * pipeline when 3DSTATE_STREAMOUT changes state."
447 * The first and fourth paragraphs are gone on Gen7.5+.
450 /* 3DSTATE_STREAMOUT */
451 gen7_3DSTATE_STREAMOUT(r
->builder
, sol
);
455 gen7_draw_sf(struct ilo_render
*r
,
456 const struct ilo_state_vector
*vec
,
457 struct ilo_render_draw_session
*session
)
460 if (DIRTY(RASTERIZER
) || DIRTY(FS
)) {
461 gen7_3DSTATE_SBE(r
->builder
, vec
->fs
, (vec
->rasterizer
) ?
462 vec
->rasterizer
->state
.sprite_coord_mode
: 0);
466 if (session
->rs_delta
.dirty
& ILO_STATE_RASTER_3DSTATE_SF
) {
467 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
468 gen7_wa_pre_3dstate_sf_depth_bias(r
);
470 gen7_3DSTATE_SF(r
->builder
, &vec
->rasterizer
->rs
);
475 gen7_draw_wm(struct ilo_render
*r
,
476 const struct ilo_state_vector
*vec
,
477 struct ilo_render_draw_session
*session
)
480 if (DIRTY(FS
) || DIRTY(BLEND
) ||
481 (session
->rs_delta
.dirty
& ILO_STATE_RASTER_3DSTATE_WM
)) {
482 gen7_3DSTATE_WM(r
->builder
, &vec
->rasterizer
->rs
, vec
->fs
,
483 vec
->blend
->alpha_may_kill
);
486 /* 3DSTATE_BINDING_TABLE_POINTERS_PS */
487 if (session
->binding_table_fs_changed
) {
488 gen7_3DSTATE_BINDING_TABLE_POINTERS_PS(r
->builder
,
489 r
->state
.wm
.BINDING_TABLE_STATE
);
492 /* 3DSTATE_SAMPLER_STATE_POINTERS_PS */
493 if (session
->sampler_fs_changed
) {
494 gen7_3DSTATE_SAMPLER_STATE_POINTERS_PS(r
->builder
,
495 r
->state
.wm
.SAMPLER_STATE
);
498 /* 3DSTATE_CONSTANT_PS */
499 if (session
->pcb_fs_changed
) {
500 gen7_3DSTATE_CONSTANT_PS(r
->builder
,
501 &r
->state
.wm
.PUSH_CONSTANT_BUFFER
,
502 &r
->state
.wm
.PUSH_CONSTANT_BUFFER_size
,
507 if (DIRTY(FS
) || DIRTY(BLEND
) || r
->instruction_bo_changed
) {
508 const bool dual_blend
= vec
->blend
->dual_blend
;
510 if (r
->hw_ctx_changed
)
511 gen7_wa_pre_3dstate_ps_max_threads(r
);
513 gen7_3DSTATE_PS(r
->builder
, vec
->fs
, dual_blend
);
516 /* 3DSTATE_SCISSOR_STATE_POINTERS */
517 if (session
->scissor_changed
) {
518 gen6_3DSTATE_SCISSOR_STATE_POINTERS(r
->builder
,
519 r
->state
.SCISSOR_RECT
);
523 const bool emit_3dstate_ps
= (DIRTY(FS
) || DIRTY(BLEND
));
524 const bool emit_3dstate_depth_buffer
=
525 (DIRTY(FB
) || DIRTY(DSA
) || r
->state_bo_changed
);
527 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7)) {
528 /* XXX what is the best way to know if this workaround is needed? */
529 if (emit_3dstate_ps
||
530 session
->pcb_fs_changed
||
531 session
->viewport_changed
||
532 session
->binding_table_fs_changed
||
533 session
->sampler_fs_changed
||
534 session
->cc_changed
||
535 session
->blend_changed
||
536 session
->dsa_changed
)
537 gen7_wa_post_ps_and_later(r
);
540 if (emit_3dstate_depth_buffer
)
541 gen7_wa_pre_depth(r
);
544 /* 3DSTATE_DEPTH_BUFFER and 3DSTATE_CLEAR_PARAMS */
545 if (DIRTY(FB
) || r
->batch_bo_changed
) {
546 const struct ilo_state_zs
*zs
;
547 uint32_t clear_params
;
549 if (vec
->fb
.state
.zsbuf
) {
550 const struct ilo_surface_cso
*surface
=
551 (const struct ilo_surface_cso
*) vec
->fb
.state
.zsbuf
;
552 const struct ilo_texture_slice
*slice
=
553 ilo_texture_get_slice(ilo_texture(surface
->base
.texture
),
554 surface
->base
.u
.tex
.level
, surface
->base
.u
.tex
.first_layer
);
556 assert(!surface
->is_rt
);
558 clear_params
= slice
->clear_value
;
561 zs
= &vec
->fb
.null_zs
;
565 gen6_3DSTATE_DEPTH_BUFFER(r
->builder
, zs
);
566 gen6_3DSTATE_HIER_DEPTH_BUFFER(r
->builder
, zs
);
567 gen6_3DSTATE_STENCIL_BUFFER(r
->builder
, zs
);
568 gen7_3DSTATE_CLEAR_PARAMS(r
->builder
, clear_params
);
573 gen7_draw_wm_multisample(struct ilo_render
*r
,
574 const struct ilo_state_vector
*vec
,
575 struct ilo_render_draw_session
*session
)
577 /* 3DSTATE_MULTISAMPLE */
578 if (DIRTY(FB
) || (session
->rs_delta
.dirty
&
579 ILO_STATE_RASTER_3DSTATE_MULTISAMPLE
)) {
580 const uint32_t *pattern
;
583 gen7_wa_pre_3dstate_multisample(r
);
585 if (vec
->fb
.num_samples
> 4) {
586 pattern
= r
->sample_pattern_8x
;
587 pattern_len
= ARRAY_SIZE(r
->sample_pattern_8x
);
589 pattern
= (vec
->fb
.num_samples
> 1) ?
590 &r
->sample_pattern_4x
: &r
->sample_pattern_1x
;
594 gen6_3DSTATE_MULTISAMPLE(r
->builder
, &vec
->rasterizer
->rs
,
595 pattern
, pattern_len
);
598 /* 3DSTATE_SAMPLE_MASK */
599 if (session
->rs_delta
.dirty
& ILO_STATE_RASTER_3DSTATE_SAMPLE_MASK
)
600 gen6_3DSTATE_SAMPLE_MASK(r
->builder
, &vec
->rasterizer
->rs
);
604 ilo_render_emit_draw_commands_gen7(struct ilo_render
*render
,
605 const struct ilo_state_vector
*vec
,
606 struct ilo_render_draw_session
*session
)
608 ILO_DEV_ASSERT(render
->dev
, 7, 7.5);
611 * We try to keep the order of the commands match, as closely as possible,
612 * that of the classic i965 driver. It allows us to compare the command
615 gen6_draw_common_select(render
, vec
, session
);
616 gen6_draw_common_sip(render
, vec
, session
);
617 gen6_draw_vf_statistics(render
, vec
, session
);
618 gen7_draw_common_pcb_alloc(render
, vec
, session
);
619 gen6_draw_common_base_address(render
, vec
, session
);
620 gen7_draw_common_pointers_1(render
, vec
, session
);
621 gen7_draw_common_urb(render
, vec
, session
);
622 gen7_draw_common_pointers_2(render
, vec
, session
);
623 gen7_draw_wm_multisample(render
, vec
, session
);
624 gen7_draw_gs(render
, vec
, session
);
625 gen7_draw_hs(render
, vec
, session
);
626 gen7_draw_te(render
, vec
, session
);
627 gen7_draw_ds(render
, vec
, session
);
628 gen7_draw_vs(render
, vec
, session
);
629 gen7_draw_sol(render
, vec
, session
);
630 gen6_draw_clip(render
, vec
, session
);
631 gen7_draw_sf(render
, vec
, session
);
632 gen7_draw_wm(render
, vec
, session
);
633 gen6_draw_wm_raster(render
, vec
, session
);
634 gen6_draw_sf_rect(render
, vec
, session
);
635 gen6_draw_vf(render
, vec
, session
);
637 ilo_render_3dprimitive(render
, vec
->draw
, &vec
->ib
);
641 gen7_rectlist_pcb_alloc(struct ilo_render
*r
,
642 const struct ilo_blitter
*blitter
)
644 gen7_3DSTATE_PUSH_CONSTANT_ALLOC_VS(r
->builder
, &blitter
->urb
);
645 gen7_3DSTATE_PUSH_CONSTANT_ALLOC_PS(r
->builder
, &blitter
->urb
);
647 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
648 gen7_wa_post_3dstate_push_constant_alloc_ps(r
);
652 gen7_rectlist_urb(struct ilo_render
*r
,
653 const struct ilo_blitter
*blitter
)
655 gen7_3DSTATE_URB_VS(r
->builder
, &blitter
->urb
);
656 gen7_3DSTATE_URB_GS(r
->builder
, &blitter
->urb
);
657 gen7_3DSTATE_URB_HS(r
->builder
, &blitter
->urb
);
658 gen7_3DSTATE_URB_DS(r
->builder
, &blitter
->urb
);
662 gen7_rectlist_vs_to_sf(struct ilo_render
*r
,
663 const struct ilo_blitter
*blitter
)
665 gen7_3DSTATE_CONSTANT_VS(r
->builder
, NULL
, NULL
, 0);
666 gen6_disable_3DSTATE_VS(r
->builder
);
668 gen7_3DSTATE_CONSTANT_HS(r
->builder
, NULL
, NULL
, 0);
669 gen7_disable_3DSTATE_HS(r
->builder
);
671 gen7_3DSTATE_TE(r
->builder
);
673 gen7_3DSTATE_CONSTANT_DS(r
->builder
, NULL
, NULL
, 0);
674 gen7_disable_3DSTATE_DS(r
->builder
);
676 gen7_3DSTATE_CONSTANT_GS(r
->builder
, NULL
, NULL
, 0);
677 gen7_disable_3DSTATE_GS(r
->builder
);
679 gen7_3DSTATE_STREAMOUT(r
->builder
, &blitter
->sol
);
681 gen6_3DSTATE_CLIP(r
->builder
, &blitter
->fb
.rs
);
683 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
684 gen7_wa_pre_3dstate_sf_depth_bias(r
);
686 gen7_3DSTATE_SF(r
->builder
, &blitter
->fb
.rs
);
687 gen7_3DSTATE_SBE(r
->builder
, NULL
, 0);
691 gen7_rectlist_wm(struct ilo_render
*r
,
692 const struct ilo_blitter
*blitter
)
694 gen7_3DSTATE_WM(r
->builder
, &blitter
->fb
.rs
, NULL
, false);
696 gen7_3DSTATE_CONSTANT_PS(r
->builder
, NULL
, NULL
, 0);
698 gen7_wa_pre_3dstate_ps_max_threads(r
);
699 gen7_disable_3DSTATE_PS(r
->builder
);
703 gen7_rectlist_wm_depth(struct ilo_render
*r
,
704 const struct ilo_blitter
*blitter
)
706 gen7_wa_pre_depth(r
);
708 if (blitter
->uses
& (ILO_BLITTER_USE_FB_DEPTH
|
709 ILO_BLITTER_USE_FB_STENCIL
))
710 gen6_3DSTATE_DEPTH_BUFFER(r
->builder
, &blitter
->fb
.dst
.u
.zs
);
712 if (blitter
->uses
& ILO_BLITTER_USE_FB_DEPTH
) {
713 gen6_3DSTATE_HIER_DEPTH_BUFFER(r
->builder
,
714 &blitter
->fb
.dst
.u
.zs
);
717 if (blitter
->uses
& ILO_BLITTER_USE_FB_STENCIL
) {
718 gen6_3DSTATE_STENCIL_BUFFER(r
->builder
,
719 &blitter
->fb
.dst
.u
.zs
);
722 gen7_3DSTATE_CLEAR_PARAMS(r
->builder
,
723 blitter
->depth_clear_value
);
727 gen7_rectlist_wm_multisample(struct ilo_render
*r
,
728 const struct ilo_blitter
*blitter
)
730 const uint32_t *pattern
;
733 if (blitter
->fb
.num_samples
> 4) {
734 pattern
= r
->sample_pattern_8x
;
735 pattern_len
= ARRAY_SIZE(r
->sample_pattern_8x
);
737 pattern
= (blitter
->fb
.num_samples
> 1) ?
738 &r
->sample_pattern_4x
: &r
->sample_pattern_1x
;
742 gen7_wa_pre_3dstate_multisample(r
);
744 gen6_3DSTATE_MULTISAMPLE(r
->builder
, &blitter
->fb
.rs
,
745 pattern
, pattern_len
);
747 gen6_3DSTATE_SAMPLE_MASK(r
->builder
, &blitter
->fb
.rs
);
751 ilo_render_emit_rectlist_commands_gen7(struct ilo_render
*r
,
752 const struct ilo_blitter
*blitter
,
753 const struct ilo_render_rectlist_session
*session
)
755 ILO_DEV_ASSERT(r
->dev
, 7, 7.5);
757 gen7_rectlist_wm_multisample(r
, blitter
);
759 gen6_state_base_address(r
->builder
, true);
761 gen6_user_3DSTATE_VERTEX_BUFFERS(r
->builder
,
762 session
->vb_start
, session
->vb_end
,
763 sizeof(blitter
->vertices
[0]));
765 gen6_3DSTATE_VERTEX_ELEMENTS(r
->builder
, &blitter
->ve
);
767 gen7_rectlist_pcb_alloc(r
, blitter
);
769 /* needed for any VS-related commands */
770 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
773 gen7_rectlist_urb(r
, blitter
);
775 if (blitter
->uses
& ILO_BLITTER_USE_DSA
) {
776 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(r
->builder
,
777 r
->state
.DEPTH_STENCIL_STATE
);
780 if (blitter
->uses
& ILO_BLITTER_USE_CC
) {
781 gen7_3DSTATE_CC_STATE_POINTERS(r
->builder
,
782 r
->state
.COLOR_CALC_STATE
);
785 gen7_rectlist_vs_to_sf(r
, blitter
);
786 gen7_rectlist_wm(r
, blitter
);
788 if (blitter
->uses
& ILO_BLITTER_USE_VIEWPORT
) {
789 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(r
->builder
,
790 r
->state
.CC_VIEWPORT
);
793 gen7_rectlist_wm_depth(r
, blitter
);
795 gen6_3DSTATE_DRAWING_RECTANGLE(r
->builder
, 0, 0,
796 blitter
->fb
.width
, blitter
->fb
.height
);
798 if (ilo_dev_gen(r
->dev
) == ILO_GEN(7))
799 gen7_wa_post_ps_and_later(r
);
801 ilo_render_3dprimitive(r
, &blitter
->draw
, NULL
);
805 ilo_render_get_draw_commands_len_gen7(const struct ilo_render
*render
,
806 const struct ilo_state_vector
*vec
)
810 ILO_DEV_ASSERT(render
->dev
, 7, 7.5);
813 len
+= GEN7_3DSTATE_URB_ANY__SIZE
* 4;
814 len
+= GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_ANY__SIZE
* 5;
815 len
+= GEN6_3DSTATE_CONSTANT_ANY__SIZE
* 5;
816 len
+= GEN7_3DSTATE_POINTERS_ANY__SIZE
* (5 + 5 + 4);
817 len
+= GEN7_3DSTATE_SO_BUFFER__SIZE
* 4;
818 len
+= GEN6_PIPE_CONTROL__SIZE
* 5;
821 GEN6_STATE_BASE_ADDRESS__SIZE
+
822 GEN6_STATE_SIP__SIZE
+
823 GEN6_3DSTATE_VF_STATISTICS__SIZE
+
824 GEN6_PIPELINE_SELECT__SIZE
+
825 GEN6_3DSTATE_CLEAR_PARAMS__SIZE
+
826 GEN6_3DSTATE_DEPTH_BUFFER__SIZE
+
827 GEN6_3DSTATE_STENCIL_BUFFER__SIZE
+
828 GEN6_3DSTATE_HIER_DEPTH_BUFFER__SIZE
+
829 GEN6_3DSTATE_VERTEX_BUFFERS__SIZE
+
830 GEN6_3DSTATE_VERTEX_ELEMENTS__SIZE
+
831 GEN6_3DSTATE_INDEX_BUFFER__SIZE
+
832 GEN75_3DSTATE_VF__SIZE
+
833 GEN6_3DSTATE_VS__SIZE
+
834 GEN6_3DSTATE_GS__SIZE
+
835 GEN6_3DSTATE_CLIP__SIZE
+
836 GEN6_3DSTATE_SF__SIZE
+
837 GEN6_3DSTATE_WM__SIZE
+
838 GEN6_3DSTATE_SAMPLE_MASK__SIZE
+
839 GEN7_3DSTATE_HS__SIZE
+
840 GEN7_3DSTATE_TE__SIZE
+
841 GEN7_3DSTATE_DS__SIZE
+
842 GEN7_3DSTATE_STREAMOUT__SIZE
+
843 GEN7_3DSTATE_SBE__SIZE
+
844 GEN7_3DSTATE_PS__SIZE
+
845 GEN6_3DSTATE_DRAWING_RECTANGLE__SIZE
+
846 GEN6_3DSTATE_POLY_STIPPLE_OFFSET__SIZE
+
847 GEN6_3DSTATE_POLY_STIPPLE_PATTERN__SIZE
+
848 GEN6_3DSTATE_LINE_STIPPLE__SIZE
+
849 GEN6_3DSTATE_AA_LINE_PARAMETERS__SIZE
+
850 GEN6_3DSTATE_MULTISAMPLE__SIZE
+
851 GEN7_3DSTATE_SO_DECL_LIST__SIZE
+
852 GEN6_3DPRIMITIVE__SIZE
;