2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 /** @file brw_fs_emit.cpp
26 * This file supports emitting code from the FS LIR to the actual
27 * native instructions.
31 #include "main/macros.h"
32 #include "brw_context.h"
38 #include "glsl/ir_print_visitor.h"
40 fs_generator::fs_generator(struct brw_context
*brw
,
41 struct brw_wm_compile
*c
,
42 struct gl_shader_program
*prog
,
43 struct gl_fragment_program
*fp
,
44 bool dual_source_output
)
46 : brw(brw
), c(c
), prog(prog
), fp(fp
), dual_source_output(dual_source_output
)
51 shader
= prog
? prog
->_LinkedShaders
[MESA_SHADER_FRAGMENT
] : NULL
;
55 p
= rzalloc(mem_ctx
, struct brw_compile
);
56 brw_init_compile(brw
, p
, mem_ctx
);
59 fs_generator::~fs_generator()
64 fs_generator::patch_discard_jumps_to_fb_writes()
66 if (intel
->gen
< 6 || this->discard_halt_patches
.is_empty())
69 /* There is a somewhat strange undocumented requirement of using
70 * HALT, according to the simulator. If some channel has HALTed to
71 * a particular UIP, then by the end of the program, every channel
72 * must have HALTed to that UIP. Furthermore, the tracking is a
73 * stack, so you can't do the final halt of a UIP after starting
74 * halting to a new UIP.
76 * Symptoms of not emitting this instruction on actual hardware
77 * included GPU hangs and sparkly rendering on the piglit discard
80 struct brw_instruction
*last_halt
= gen6_HALT(p
);
81 last_halt
->bits3
.break_cont
.uip
= 2;
82 last_halt
->bits3
.break_cont
.jip
= 2;
86 foreach_list(node
, &this->discard_halt_patches
) {
87 ip_record
*patch_ip
= (ip_record
*)node
;
88 struct brw_instruction
*patch
= &p
->store
[patch_ip
->ip
];
90 assert(patch
->header
.opcode
== BRW_OPCODE_HALT
);
91 /* HALT takes a half-instruction distance from the pre-incremented IP. */
92 patch
->bits3
.break_cont
.uip
= (ip
- patch_ip
->ip
) * 2;
95 this->discard_halt_patches
.make_empty();
99 fs_generator::generate_fb_write(fs_inst
*inst
)
101 bool eot
= inst
->eot
;
102 struct brw_reg implied_header
;
103 uint32_t msg_control
;
105 /* Header is 2 regs, g0 and g1 are the contents. g0 will be implied
108 brw_push_insn_state(p
);
109 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
110 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
113 struct brw_reg pixel_mask
;
116 pixel_mask
= retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW
);
118 pixel_mask
= retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW
);
120 brw_MOV(p
, pixel_mask
, brw_flag_reg(0, 1));
123 if (inst
->header_present
) {
124 if (intel
->gen
>= 6) {
125 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
127 retype(brw_message_reg(inst
->base_mrf
), BRW_REGISTER_TYPE_UD
),
128 retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD
));
129 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
131 if (inst
->target
> 0 &&
132 c
->key
.nr_color_regions
> 1 &&
133 c
->key
.sample_alpha_to_coverage
) {
134 /* Set "Source0 Alpha Present to RenderTarget" bit in message
138 vec1(retype(brw_message_reg(inst
->base_mrf
), BRW_REGISTER_TYPE_UD
)),
139 vec1(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD
)),
140 brw_imm_ud(0x1 << 11));
143 if (inst
->target
> 0) {
144 /* Set the render target index for choosing BLEND_STATE. */
145 brw_MOV(p
, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE
,
147 BRW_REGISTER_TYPE_UD
),
148 brw_imm_ud(inst
->target
));
151 implied_header
= brw_null_reg();
153 implied_header
= retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW
);
156 brw_message_reg(inst
->base_mrf
+ 1),
160 implied_header
= brw_null_reg();
163 if (this->dual_source_output
)
164 msg_control
= BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01
;
165 else if (dispatch_width
== 16)
166 msg_control
= BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE
;
168 msg_control
= BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01
;
170 brw_pop_insn_state(p
);
181 inst
->header_present
);
184 /* Computes the integer pixel x,y values from the origin.
186 * This is the basis of gl_FragCoord computation, but is also used
187 * pre-gen6 for computing the deltas from v0 for computing
191 fs_generator::generate_pixel_xy(struct brw_reg dst
, bool is_x
)
193 struct brw_reg g1_uw
= retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW
);
195 struct brw_reg deltas
;
198 src
= stride(suboffset(g1_uw
, 4), 2, 4, 0);
199 deltas
= brw_imm_v(0x10101010);
201 src
= stride(suboffset(g1_uw
, 5), 2, 4, 0);
202 deltas
= brw_imm_v(0x11001100);
205 if (dispatch_width
== 16) {
209 /* We do this 8 or 16-wide, but since the destination is UW we
210 * don't do compression in the 16-wide case.
212 brw_push_insn_state(p
);
213 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
214 brw_ADD(p
, dst
, src
, deltas
);
215 brw_pop_insn_state(p
);
219 fs_generator::generate_linterp(fs_inst
*inst
,
220 struct brw_reg dst
, struct brw_reg
*src
)
222 struct brw_reg delta_x
= src
[0];
223 struct brw_reg delta_y
= src
[1];
224 struct brw_reg interp
= src
[2];
227 delta_y
.nr
== delta_x
.nr
+ 1 &&
228 (intel
->gen
>= 6 || (delta_x
.nr
& 1) == 0)) {
229 brw_PLN(p
, dst
, interp
, delta_x
);
231 brw_LINE(p
, brw_null_reg(), interp
, delta_x
);
232 brw_MAC(p
, dst
, suboffset(interp
, 1), delta_y
);
237 fs_generator::generate_math1_gen7(fs_inst
*inst
,
241 assert(inst
->mlen
== 0);
243 brw_math_function(inst
->opcode
),
245 BRW_MATH_DATA_VECTOR
,
246 BRW_MATH_PRECISION_FULL
);
250 fs_generator::generate_math2_gen7(fs_inst
*inst
,
255 assert(inst
->mlen
== 0);
256 brw_math2(p
, dst
, brw_math_function(inst
->opcode
), src0
, src1
);
260 fs_generator::generate_math1_gen6(fs_inst
*inst
,
264 int op
= brw_math_function(inst
->opcode
);
266 assert(inst
->mlen
== 0);
268 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
272 BRW_MATH_DATA_VECTOR
,
273 BRW_MATH_PRECISION_FULL
);
275 if (dispatch_width
== 16) {
276 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
277 brw_math(p
, sechalf(dst
),
280 BRW_MATH_DATA_VECTOR
,
281 BRW_MATH_PRECISION_FULL
);
282 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
287 fs_generator::generate_math2_gen6(fs_inst
*inst
,
292 int op
= brw_math_function(inst
->opcode
);
294 assert(inst
->mlen
== 0);
296 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
297 brw_math2(p
, dst
, op
, src0
, src1
);
299 if (dispatch_width
== 16) {
300 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
301 brw_math2(p
, sechalf(dst
), op
, sechalf(src0
), sechalf(src1
));
302 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
307 fs_generator::generate_math_gen4(fs_inst
*inst
,
311 int op
= brw_math_function(inst
->opcode
);
313 assert(inst
->mlen
>= 1);
315 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
319 BRW_MATH_DATA_VECTOR
,
320 BRW_MATH_PRECISION_FULL
);
322 if (dispatch_width
== 16) {
323 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
324 brw_math(p
, sechalf(dst
),
326 inst
->base_mrf
+ 1, sechalf(src
),
327 BRW_MATH_DATA_VECTOR
,
328 BRW_MATH_PRECISION_FULL
);
330 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
335 fs_generator::generate_tex(fs_inst
*inst
, struct brw_reg dst
, struct brw_reg src
)
339 uint32_t simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD8
;
340 uint32_t return_format
;
343 case BRW_REGISTER_TYPE_D
:
344 return_format
= BRW_SAMPLER_RETURN_FORMAT_SINT32
;
346 case BRW_REGISTER_TYPE_UD
:
347 return_format
= BRW_SAMPLER_RETURN_FORMAT_UINT32
;
350 return_format
= BRW_SAMPLER_RETURN_FORMAT_FLOAT32
;
354 if (dispatch_width
== 16)
355 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
357 if (intel
->gen
>= 5) {
358 switch (inst
->opcode
) {
359 case SHADER_OPCODE_TEX
:
360 if (inst
->shadow_compare
) {
361 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE
;
363 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE
;
367 if (inst
->shadow_compare
) {
368 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE
;
370 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS
;
373 case SHADER_OPCODE_TXL
:
374 if (inst
->shadow_compare
) {
375 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE
;
377 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_LOD
;
380 case SHADER_OPCODE_TXS
:
381 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO
;
383 case SHADER_OPCODE_TXD
:
384 if (inst
->shadow_compare
) {
385 /* Gen7.5+. Otherwise, lowered by brw_lower_texture_gradients(). */
386 assert(intel
->is_haswell
);
387 msg_type
= HSW_SAMPLER_MESSAGE_SAMPLE_DERIV_COMPARE
;
389 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS
;
392 case SHADER_OPCODE_TXF
:
393 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_LD
;
395 case SHADER_OPCODE_TXF_MS
:
397 msg_type
= GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DMS
;
399 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_LD
;
401 case SHADER_OPCODE_LOD
:
402 msg_type
= GEN5_SAMPLER_MESSAGE_LOD
;
405 assert(!"not reached");
409 switch (inst
->opcode
) {
410 case SHADER_OPCODE_TEX
:
411 /* Note that G45 and older determines shadow compare and dispatch width
412 * from message length for most messages.
414 assert(dispatch_width
== 8);
415 msg_type
= BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE
;
416 if (inst
->shadow_compare
) {
417 assert(inst
->mlen
== 6);
419 assert(inst
->mlen
<= 4);
423 if (inst
->shadow_compare
) {
424 assert(inst
->mlen
== 6);
425 msg_type
= BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE
;
427 assert(inst
->mlen
== 9);
428 msg_type
= BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS
;
429 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
432 case SHADER_OPCODE_TXL
:
433 if (inst
->shadow_compare
) {
434 assert(inst
->mlen
== 6);
435 msg_type
= BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE
;
437 assert(inst
->mlen
== 9);
438 msg_type
= BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD
;
439 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
442 case SHADER_OPCODE_TXD
:
443 /* There is no sample_d_c message; comparisons are done manually */
444 assert(inst
->mlen
== 7 || inst
->mlen
== 10);
445 msg_type
= BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS
;
447 case SHADER_OPCODE_TXF
:
448 assert(inst
->mlen
== 9);
449 msg_type
= BRW_SAMPLER_MESSAGE_SIMD16_LD
;
450 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
452 case SHADER_OPCODE_TXS
:
453 assert(inst
->mlen
== 3);
454 msg_type
= BRW_SAMPLER_MESSAGE_SIMD16_RESINFO
;
455 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
458 assert(!"not reached");
462 assert(msg_type
!= -1);
464 if (simd_mode
== BRW_SAMPLER_SIMD_MODE_SIMD16
) {
469 /* Load the message header if present. If there's a texture offset,
470 * we need to set it up explicitly and load the offset bitfield.
471 * Otherwise, we can use an implied move from g0 to the first message reg.
473 if (inst
->texture_offset
) {
474 brw_push_insn_state(p
);
475 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
476 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
477 /* Explicitly set up the message header by copying g0 to the MRF. */
478 brw_MOV(p
, retype(brw_message_reg(inst
->base_mrf
), BRW_REGISTER_TYPE_UD
),
479 retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD
));
481 /* Then set the offset bits in DWord 2. */
482 brw_MOV(p
, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE
,
483 inst
->base_mrf
, 2), BRW_REGISTER_TYPE_UD
),
484 brw_imm_ud(inst
->texture_offset
));
485 brw_pop_insn_state(p
);
486 } else if (inst
->header_present
) {
487 /* Set up an implied move from g0 to the MRF. */
488 src
= retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW
);
492 retype(dst
, BRW_REGISTER_TYPE_UW
),
495 SURF_INDEX_TEXTURE(inst
->sampler
),
500 inst
->header_present
,
506 /* For OPCODE_DDX and OPCODE_DDY, per channel of output we've got input
509 * arg0: ss0.tl ss0.tr ss0.bl ss0.br ss1.tl ss1.tr ss1.bl ss1.br
511 * and we're trying to produce:
514 * dst: (ss0.tr - ss0.tl) (ss0.tl - ss0.bl)
515 * (ss0.tr - ss0.tl) (ss0.tr - ss0.br)
516 * (ss0.br - ss0.bl) (ss0.tl - ss0.bl)
517 * (ss0.br - ss0.bl) (ss0.tr - ss0.br)
518 * (ss1.tr - ss1.tl) (ss1.tl - ss1.bl)
519 * (ss1.tr - ss1.tl) (ss1.tr - ss1.br)
520 * (ss1.br - ss1.bl) (ss1.tl - ss1.bl)
521 * (ss1.br - ss1.bl) (ss1.tr - ss1.br)
523 * and add another set of two more subspans if in 16-pixel dispatch mode.
525 * For DDX, it ends up being easy: width = 2, horiz=0 gets us the same result
526 * for each pair, and vertstride = 2 jumps us 2 elements after processing a
527 * pair. But for DDY, it's harder, as we want to produce the pairs swizzled
528 * between each other. We could probably do it like ddx and swizzle the right
529 * order later, but bail for now and just produce
530 * ((ss0.tl - ss0.bl)x4 (ss1.tl - ss1.bl)x4)
533 fs_generator::generate_ddx(fs_inst
*inst
, struct brw_reg dst
, struct brw_reg src
)
535 struct brw_reg src0
= brw_reg(src
.file
, src
.nr
, 1,
537 BRW_VERTICAL_STRIDE_2
,
539 BRW_HORIZONTAL_STRIDE_0
,
540 BRW_SWIZZLE_XYZW
, WRITEMASK_XYZW
);
541 struct brw_reg src1
= brw_reg(src
.file
, src
.nr
, 0,
543 BRW_VERTICAL_STRIDE_2
,
545 BRW_HORIZONTAL_STRIDE_0
,
546 BRW_SWIZZLE_XYZW
, WRITEMASK_XYZW
);
547 brw_ADD(p
, dst
, src0
, negate(src1
));
550 /* The negate_value boolean is used to negate the derivative computation for
551 * FBOs, since they place the origin at the upper left instead of the lower
555 fs_generator::generate_ddy(fs_inst
*inst
, struct brw_reg dst
, struct brw_reg src
,
558 struct brw_reg src0
= brw_reg(src
.file
, src
.nr
, 0,
560 BRW_VERTICAL_STRIDE_4
,
562 BRW_HORIZONTAL_STRIDE_0
,
563 BRW_SWIZZLE_XYZW
, WRITEMASK_XYZW
);
564 struct brw_reg src1
= brw_reg(src
.file
, src
.nr
, 2,
566 BRW_VERTICAL_STRIDE_4
,
568 BRW_HORIZONTAL_STRIDE_0
,
569 BRW_SWIZZLE_XYZW
, WRITEMASK_XYZW
);
571 brw_ADD(p
, dst
, src1
, negate(src0
));
573 brw_ADD(p
, dst
, src0
, negate(src1
));
577 fs_generator::generate_discard_jump(fs_inst
*inst
)
579 assert(intel
->gen
>= 6);
581 /* This HALT will be patched up at FB write time to point UIP at the end of
582 * the program, and at brw_uip_jip() JIP will be set to the end of the
583 * current block (or the program).
585 this->discard_halt_patches
.push_tail(new(mem_ctx
) ip_record(p
->nr_insn
));
587 brw_push_insn_state(p
);
588 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
590 brw_pop_insn_state(p
);
594 fs_generator::generate_spill(fs_inst
*inst
, struct brw_reg src
)
596 assert(inst
->mlen
!= 0);
599 retype(brw_message_reg(inst
->base_mrf
+ 1), BRW_REGISTER_TYPE_UD
),
600 retype(src
, BRW_REGISTER_TYPE_UD
));
601 brw_oword_block_write_scratch(p
, brw_message_reg(inst
->base_mrf
), 1,
606 fs_generator::generate_unspill(fs_inst
*inst
, struct brw_reg dst
)
608 assert(inst
->mlen
!= 0);
610 brw_oword_block_read_scratch(p
, dst
, brw_message_reg(inst
->base_mrf
), 1,
615 fs_generator::generate_uniform_pull_constant_load(fs_inst
*inst
,
617 struct brw_reg index
,
618 struct brw_reg offset
)
620 assert(inst
->mlen
!= 0);
622 assert(index
.file
== BRW_IMMEDIATE_VALUE
&&
623 index
.type
== BRW_REGISTER_TYPE_UD
);
624 uint32_t surf_index
= index
.dw1
.ud
;
626 assert(offset
.file
== BRW_IMMEDIATE_VALUE
&&
627 offset
.type
== BRW_REGISTER_TYPE_UD
);
628 uint32_t read_offset
= offset
.dw1
.ud
;
630 brw_oword_block_read(p
, dst
, brw_message_reg(inst
->base_mrf
),
631 read_offset
, surf_index
);
635 fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst
*inst
,
637 struct brw_reg index
,
638 struct brw_reg offset
)
640 assert(inst
->mlen
== 0);
642 assert(index
.file
== BRW_IMMEDIATE_VALUE
&&
643 index
.type
== BRW_REGISTER_TYPE_UD
);
644 uint32_t surf_index
= index
.dw1
.ud
;
646 assert(offset
.file
== BRW_GENERAL_REGISTER_FILE
);
647 /* Reference just the dword we need, to avoid angering validate_reg(). */
648 offset
= brw_vec1_grf(offset
.nr
, 0);
650 brw_push_insn_state(p
);
651 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
652 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
653 struct brw_instruction
*send
= brw_next_insn(p
, BRW_OPCODE_SEND
);
654 brw_pop_insn_state(p
);
656 /* We use the SIMD4x2 mode because we want to end up with 4 components in
657 * the destination loaded consecutively from the same offset (which appears
658 * in the first component, and the rest are ignored).
660 dst
.width
= BRW_WIDTH_4
;
661 brw_set_dest(p
, send
, dst
);
662 brw_set_src0(p
, send
, offset
);
663 brw_set_sampler_message(p
, send
,
665 0, /* LD message ignores sampler unit */
666 GEN5_SAMPLER_MESSAGE_SAMPLE_LD
,
669 false, /* no header */
670 BRW_SAMPLER_SIMD_MODE_SIMD4X2
,
675 fs_generator::generate_varying_pull_constant_load(fs_inst
*inst
,
677 struct brw_reg index
)
679 assert(intel
->gen
< 7); /* Should use the gen7 variant. */
680 assert(inst
->header_present
);
682 assert(index
.file
== BRW_IMMEDIATE_VALUE
&&
683 index
.type
== BRW_REGISTER_TYPE_UD
);
684 uint32_t surf_index
= index
.dw1
.ud
;
686 uint32_t msg_type
, msg_control
, rlen
;
688 msg_type
= GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ
;
689 else if (intel
->gen
== 5 || intel
->is_g4x
)
690 msg_type
= G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ
;
692 msg_type
= BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ
;
694 if (dispatch_width
== 16) {
695 msg_control
= BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS
;
698 msg_control
= BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS
;
702 struct brw_reg header
= brw_vec8_grf(0, 0);
703 gen6_resolve_implied_move(p
, &header
, inst
->base_mrf
);
705 struct brw_instruction
*send
= brw_next_insn(p
, BRW_OPCODE_SEND
);
706 brw_set_dest(p
, send
, dst
);
707 brw_set_src0(p
, send
, header
);
709 send
->header
.destreg__conditionalmod
= inst
->base_mrf
;
710 brw_set_dp_read_message(p
, send
,
714 BRW_DATAPORT_READ_TARGET_DATA_CACHE
,
716 inst
->header_present
,
721 fs_generator::generate_varying_pull_constant_load_gen7(fs_inst
*inst
,
723 struct brw_reg index
,
724 struct brw_reg offset
)
726 assert(intel
->gen
>= 7);
727 /* Varying-offset pull constant loads are treated as a normal expression on
728 * gen7, so the fact that it's a send message is hidden at the IR level.
730 assert(!inst
->header_present
);
733 assert(index
.file
== BRW_IMMEDIATE_VALUE
&&
734 index
.type
== BRW_REGISTER_TYPE_UD
);
735 uint32_t surf_index
= index
.dw1
.ud
;
737 uint32_t simd_mode
, rlen
, mlen
;
738 if (dispatch_width
== 16) {
741 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD16
;
745 simd_mode
= BRW_SAMPLER_SIMD_MODE_SIMD8
;
748 struct brw_instruction
*send
= brw_next_insn(p
, BRW_OPCODE_SEND
);
749 brw_set_dest(p
, send
, dst
);
750 brw_set_src0(p
, send
, offset
);
751 brw_set_sampler_message(p
, send
,
753 0, /* LD message ignores sampler unit */
754 GEN5_SAMPLER_MESSAGE_SAMPLE_LD
,
757 false, /* no header */
763 * Cause the current pixel/sample mask (from R1.7 bits 15:0) to be transferred
764 * into the flags register (f0.0).
766 * Used only on Gen6 and above.
769 fs_generator::generate_mov_dispatch_to_flags(fs_inst
*inst
)
771 struct brw_reg flags
= brw_flag_reg(0, inst
->flag_subreg
);
772 struct brw_reg dispatch_mask
;
775 dispatch_mask
= retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW
);
777 dispatch_mask
= retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW
);
779 brw_push_insn_state(p
);
780 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
781 brw_MOV(p
, flags
, dispatch_mask
);
782 brw_pop_insn_state(p
);
786 static uint32_t brw_file_from_reg(fs_reg
*reg
)
790 return BRW_ARCHITECTURE_REGISTER_FILE
;
792 return BRW_GENERAL_REGISTER_FILE
;
794 return BRW_MESSAGE_REGISTER_FILE
;
796 return BRW_IMMEDIATE_VALUE
;
798 assert(!"not reached");
799 return BRW_GENERAL_REGISTER_FILE
;
803 static struct brw_reg
804 brw_reg_from_fs_reg(fs_reg
*reg
)
806 struct brw_reg brw_reg
;
812 if (reg
->smear
== -1) {
813 brw_reg
= brw_vec8_reg(brw_file_from_reg(reg
), reg
->reg
, 0);
815 brw_reg
= brw_vec1_reg(brw_file_from_reg(reg
), reg
->reg
, reg
->smear
);
817 brw_reg
= retype(brw_reg
, reg
->type
);
819 brw_reg
= sechalf(brw_reg
);
823 case BRW_REGISTER_TYPE_F
:
824 brw_reg
= brw_imm_f(reg
->imm
.f
);
826 case BRW_REGISTER_TYPE_D
:
827 brw_reg
= brw_imm_d(reg
->imm
.i
);
829 case BRW_REGISTER_TYPE_UD
:
830 brw_reg
= brw_imm_ud(reg
->imm
.u
);
833 assert(!"not reached");
834 brw_reg
= brw_null_reg();
839 brw_reg
= reg
->fixed_hw_reg
;
842 /* Probably unused. */
843 brw_reg
= brw_null_reg();
846 assert(!"not reached");
847 brw_reg
= brw_null_reg();
850 assert(!"not reached");
851 brw_reg
= brw_null_reg();
855 brw_reg
= brw_abs(brw_reg
);
857 brw_reg
= negate(brw_reg
);
863 * Sets the first word of a vgrf for gen7+ simd4x2 uniform pull constant
864 * sampler LD messages.
866 * We don't want to bake it into the send message's code generation because
867 * that means we don't get a chance to schedule the instructions.
870 fs_generator::generate_set_simd4x2_offset(fs_inst
*inst
,
872 struct brw_reg value
)
874 assert(value
.file
== BRW_IMMEDIATE_VALUE
);
876 brw_push_insn_state(p
);
877 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
878 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
879 brw_MOV(p
, retype(brw_vec1_reg(dst
.file
, dst
.nr
, 0), value
.type
), value
);
880 brw_pop_insn_state(p
);
884 * Change the register's data type from UD to W, doubling the strides in order
885 * to compensate for halving the data type width.
887 static struct brw_reg
888 ud_reg_to_w(struct brw_reg r
)
890 assert(r
.type
== BRW_REGISTER_TYPE_UD
);
891 r
.type
= BRW_REGISTER_TYPE_W
;
893 /* The BRW_*_STRIDE enums are defined so that incrementing the field
894 * doubles the real stride.
905 fs_generator::generate_pack_half_2x16_split(fs_inst
*inst
,
910 assert(intel
->gen
>= 7);
911 assert(dst
.type
== BRW_REGISTER_TYPE_UD
);
912 assert(x
.type
== BRW_REGISTER_TYPE_F
);
913 assert(y
.type
== BRW_REGISTER_TYPE_F
);
915 /* From the Ivybridge PRM, Vol4, Part3, Section 6.27 f32to16:
917 * Because this instruction does not have a 16-bit floating-point type,
918 * the destination data type must be Word (W).
920 * The destination must be DWord-aligned and specify a horizontal stride
921 * (HorzStride) of 2. The 16-bit result is stored in the lower word of
922 * each destination channel and the upper word is not modified.
924 struct brw_reg dst_w
= ud_reg_to_w(dst
);
926 /* Give each 32-bit channel of dst the form below , where "." means
930 brw_F32TO16(p
, dst_w
, y
);
935 brw_SHL(p
, dst
, dst
, brw_imm_ud(16u));
937 /* And, finally the form of packHalf2x16's output:
940 brw_F32TO16(p
, dst_w
, x
);
944 fs_generator::generate_unpack_half_2x16_split(fs_inst
*inst
,
948 assert(intel
->gen
>= 7);
949 assert(dst
.type
== BRW_REGISTER_TYPE_F
);
950 assert(src
.type
== BRW_REGISTER_TYPE_UD
);
952 /* From the Ivybridge PRM, Vol4, Part3, Section 6.26 f16to32:
954 * Because this instruction does not have a 16-bit floating-point type,
955 * the source data type must be Word (W). The destination type must be
958 struct brw_reg src_w
= ud_reg_to_w(src
);
960 /* Each channel of src has the form of unpackHalf2x16's input: 0xhhhhllll.
961 * For the Y case, we wish to access only the upper word; therefore
962 * a 16-bit subregister offset is needed.
964 assert(inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X
||
965 inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
);
966 if (inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
)
969 brw_F16TO32(p
, dst
, src_w
);
973 fs_generator::generate_shader_time_add(fs_inst
*inst
,
974 struct brw_reg payload
,
975 struct brw_reg offset
,
976 struct brw_reg value
)
978 assert(intel
->gen
>= 7);
979 brw_push_insn_state(p
);
980 brw_set_mask_control(p
, true);
982 assert(payload
.file
== BRW_GENERAL_REGISTER_FILE
);
983 struct brw_reg payload_offset
= retype(brw_vec1_grf(payload
.nr
, 0),
985 struct brw_reg payload_value
= retype(brw_vec1_grf(payload
.nr
+ 1, 0),
988 assert(offset
.file
== BRW_IMMEDIATE_VALUE
);
989 if (value
.file
== BRW_GENERAL_REGISTER_FILE
) {
990 value
.width
= BRW_WIDTH_1
;
991 value
.hstride
= BRW_HORIZONTAL_STRIDE_0
;
992 value
.vstride
= BRW_VERTICAL_STRIDE_0
;
994 assert(value
.file
== BRW_IMMEDIATE_VALUE
);
997 /* Trying to deal with setup of the params from the IR is crazy in the FS8
998 * case, and we don't really care about squeezing every bit of performance
999 * out of this path, so we just emit the MOVs from here.
1001 brw_MOV(p
, payload_offset
, offset
);
1002 brw_MOV(p
, payload_value
, value
);
1003 brw_shader_time_add(p
, payload
, SURF_INDEX_WM_SHADER_TIME
);
1004 brw_pop_insn_state(p
);
1008 fs_generator::generate_code(exec_list
*instructions
)
1010 int last_native_insn_offset
= p
->next_insn_offset
;
1011 const char *last_annotation_string
= NULL
;
1012 const void *last_annotation_ir
= NULL
;
1014 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1016 printf("Native code for fragment shader %d (%d-wide dispatch):\n",
1017 prog
->Name
, dispatch_width
);
1019 printf("Native code for fragment program %d (%d-wide dispatch):\n",
1020 fp
->Base
.Id
, dispatch_width
);
1025 if (unlikely(INTEL_DEBUG
& DEBUG_WM
))
1026 cfg
= new(mem_ctx
) cfg_t(mem_ctx
, instructions
);
1028 foreach_list(node
, instructions
) {
1029 fs_inst
*inst
= (fs_inst
*)node
;
1030 struct brw_reg src
[3], dst
;
1032 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1033 foreach_list(node
, &cfg
->block_list
) {
1034 bblock_link
*link
= (bblock_link
*)node
;
1035 bblock_t
*block
= link
->block
;
1037 if (block
->start
== inst
) {
1038 printf(" START B%d", block
->block_num
);
1039 foreach_list(predecessor_node
, &block
->parents
) {
1040 bblock_link
*predecessor_link
=
1041 (bblock_link
*)predecessor_node
;
1042 bblock_t
*predecessor_block
= predecessor_link
->block
;
1043 printf(" <-B%d", predecessor_block
->block_num
);
1049 if (last_annotation_ir
!= inst
->ir
) {
1050 last_annotation_ir
= inst
->ir
;
1051 if (last_annotation_ir
) {
1054 ((ir_instruction
*)inst
->ir
)->print();
1056 const prog_instruction
*fpi
;
1057 fpi
= (const prog_instruction
*)inst
->ir
;
1058 printf("%d: ", (int)(fpi
- fp
->Base
.Instructions
));
1059 _mesa_fprint_instruction_opt(stdout
,
1061 0, PROG_PRINT_DEBUG
, NULL
);
1066 if (last_annotation_string
!= inst
->annotation
) {
1067 last_annotation_string
= inst
->annotation
;
1068 if (last_annotation_string
)
1069 printf(" %s\n", last_annotation_string
);
1073 for (unsigned int i
= 0; i
< 3; i
++) {
1074 src
[i
] = brw_reg_from_fs_reg(&inst
->src
[i
]);
1076 /* The accumulator result appears to get used for the
1077 * conditional modifier generation. When negating a UD
1078 * value, there is a 33rd bit generated for the sign in the
1079 * accumulator value, so now you can't check, for example,
1080 * equality with a 32-bit value. See piglit fs-op-neg-uvec4.
1082 assert(!inst
->conditional_mod
||
1083 inst
->src
[i
].type
!= BRW_REGISTER_TYPE_UD
||
1084 !inst
->src
[i
].negate
);
1086 dst
= brw_reg_from_fs_reg(&inst
->dst
);
1088 brw_set_conditionalmod(p
, inst
->conditional_mod
);
1089 brw_set_predicate_control(p
, inst
->predicate
);
1090 brw_set_predicate_inverse(p
, inst
->predicate_inverse
);
1091 brw_set_flag_reg(p
, 0, inst
->flag_subreg
);
1092 brw_set_saturate(p
, inst
->saturate
);
1093 brw_set_mask_control(p
, inst
->force_writemask_all
);
1095 if (inst
->force_uncompressed
|| dispatch_width
== 8) {
1096 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1097 } else if (inst
->force_sechalf
) {
1098 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1100 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1103 switch (inst
->opcode
) {
1104 case BRW_OPCODE_MOV
:
1105 brw_MOV(p
, dst
, src
[0]);
1107 case BRW_OPCODE_ADD
:
1108 brw_ADD(p
, dst
, src
[0], src
[1]);
1110 case BRW_OPCODE_MUL
:
1111 brw_MUL(p
, dst
, src
[0], src
[1]);
1113 case BRW_OPCODE_MACH
:
1114 brw_set_acc_write_control(p
, 1);
1115 brw_MACH(p
, dst
, src
[0], src
[1]);
1116 brw_set_acc_write_control(p
, 0);
1119 case BRW_OPCODE_MAD
:
1120 brw_set_access_mode(p
, BRW_ALIGN_16
);
1121 if (dispatch_width
== 16) {
1122 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1123 brw_MAD(p
, dst
, src
[0], src
[1], src
[2]);
1124 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1125 brw_MAD(p
, sechalf(dst
), sechalf(src
[0]), sechalf(src
[1]), sechalf(src
[2]));
1126 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1128 brw_MAD(p
, dst
, src
[0], src
[1], src
[2]);
1130 brw_set_access_mode(p
, BRW_ALIGN_1
);
1133 case BRW_OPCODE_LRP
:
1134 brw_set_access_mode(p
, BRW_ALIGN_16
);
1135 if (dispatch_width
== 16) {
1136 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1137 brw_LRP(p
, dst
, src
[0], src
[1], src
[2]);
1138 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1139 brw_LRP(p
, sechalf(dst
), sechalf(src
[0]), sechalf(src
[1]), sechalf(src
[2]));
1140 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1142 brw_LRP(p
, dst
, src
[0], src
[1], src
[2]);
1144 brw_set_access_mode(p
, BRW_ALIGN_1
);
1147 case BRW_OPCODE_FRC
:
1148 brw_FRC(p
, dst
, src
[0]);
1150 case BRW_OPCODE_RNDD
:
1151 brw_RNDD(p
, dst
, src
[0]);
1153 case BRW_OPCODE_RNDE
:
1154 brw_RNDE(p
, dst
, src
[0]);
1156 case BRW_OPCODE_RNDZ
:
1157 brw_RNDZ(p
, dst
, src
[0]);
1160 case BRW_OPCODE_AND
:
1161 brw_AND(p
, dst
, src
[0], src
[1]);
1164 brw_OR(p
, dst
, src
[0], src
[1]);
1166 case BRW_OPCODE_XOR
:
1167 brw_XOR(p
, dst
, src
[0], src
[1]);
1169 case BRW_OPCODE_NOT
:
1170 brw_NOT(p
, dst
, src
[0]);
1172 case BRW_OPCODE_ASR
:
1173 brw_ASR(p
, dst
, src
[0], src
[1]);
1175 case BRW_OPCODE_SHR
:
1176 brw_SHR(p
, dst
, src
[0], src
[1]);
1178 case BRW_OPCODE_SHL
:
1179 brw_SHL(p
, dst
, src
[0], src
[1]);
1181 case BRW_OPCODE_F32TO16
:
1182 brw_F32TO16(p
, dst
, src
[0]);
1184 case BRW_OPCODE_F16TO32
:
1185 brw_F16TO32(p
, dst
, src
[0]);
1187 case BRW_OPCODE_CMP
:
1188 brw_CMP(p
, dst
, inst
->conditional_mod
, src
[0], src
[1]);
1190 case BRW_OPCODE_SEL
:
1191 brw_SEL(p
, dst
, src
[0], src
[1]);
1195 if (inst
->src
[0].file
!= BAD_FILE
) {
1196 /* The instruction has an embedded compare (only allowed on gen6) */
1197 assert(intel
->gen
== 6);
1198 gen6_IF(p
, inst
->conditional_mod
, src
[0], src
[1]);
1200 brw_IF(p
, dispatch_width
== 16 ? BRW_EXECUTE_16
: BRW_EXECUTE_8
);
1204 case BRW_OPCODE_ELSE
:
1207 case BRW_OPCODE_ENDIF
:
1212 brw_DO(p
, BRW_EXECUTE_8
);
1215 case BRW_OPCODE_BREAK
:
1217 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1219 case BRW_OPCODE_CONTINUE
:
1220 /* FINISHME: We need to write the loop instruction support still. */
1221 if (intel
->gen
>= 6)
1225 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1228 case BRW_OPCODE_WHILE
:
1232 case SHADER_OPCODE_RCP
:
1233 case SHADER_OPCODE_RSQ
:
1234 case SHADER_OPCODE_SQRT
:
1235 case SHADER_OPCODE_EXP2
:
1236 case SHADER_OPCODE_LOG2
:
1237 case SHADER_OPCODE_SIN
:
1238 case SHADER_OPCODE_COS
:
1239 if (intel
->gen
>= 7) {
1240 generate_math1_gen7(inst
, dst
, src
[0]);
1241 } else if (intel
->gen
== 6) {
1242 generate_math1_gen6(inst
, dst
, src
[0]);
1244 generate_math_gen4(inst
, dst
, src
[0]);
1247 case SHADER_OPCODE_INT_QUOTIENT
:
1248 case SHADER_OPCODE_INT_REMAINDER
:
1249 case SHADER_OPCODE_POW
:
1250 if (intel
->gen
>= 7) {
1251 generate_math2_gen7(inst
, dst
, src
[0], src
[1]);
1252 } else if (intel
->gen
== 6) {
1253 generate_math2_gen6(inst
, dst
, src
[0], src
[1]);
1255 generate_math_gen4(inst
, dst
, src
[0]);
1258 case FS_OPCODE_PIXEL_X
:
1259 generate_pixel_xy(dst
, true);
1261 case FS_OPCODE_PIXEL_Y
:
1262 generate_pixel_xy(dst
, false);
1264 case FS_OPCODE_CINTERP
:
1265 brw_MOV(p
, dst
, src
[0]);
1267 case FS_OPCODE_LINTERP
:
1268 generate_linterp(inst
, dst
, src
);
1270 case SHADER_OPCODE_TEX
:
1272 case SHADER_OPCODE_TXD
:
1273 case SHADER_OPCODE_TXF
:
1274 case SHADER_OPCODE_TXF_MS
:
1275 case SHADER_OPCODE_TXL
:
1276 case SHADER_OPCODE_TXS
:
1277 case SHADER_OPCODE_LOD
:
1278 generate_tex(inst
, dst
, src
[0]);
1281 generate_ddx(inst
, dst
, src
[0]);
1284 /* Make sure fp->UsesDFdy flag got set (otherwise there's no
1285 * guarantee that c->key.render_to_fbo is set).
1287 assert(fp
->UsesDFdy
);
1288 generate_ddy(inst
, dst
, src
[0], c
->key
.render_to_fbo
);
1291 case FS_OPCODE_SPILL
:
1292 generate_spill(inst
, src
[0]);
1295 case FS_OPCODE_UNSPILL
:
1296 generate_unspill(inst
, dst
);
1299 case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD
:
1300 generate_uniform_pull_constant_load(inst
, dst
, src
[0], src
[1]);
1303 case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7
:
1304 generate_uniform_pull_constant_load_gen7(inst
, dst
, src
[0], src
[1]);
1307 case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD
:
1308 generate_varying_pull_constant_load(inst
, dst
, src
[0]);
1311 case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7
:
1312 generate_varying_pull_constant_load_gen7(inst
, dst
, src
[0], src
[1]);
1315 case FS_OPCODE_FB_WRITE
:
1316 generate_fb_write(inst
);
1319 case FS_OPCODE_MOV_DISPATCH_TO_FLAGS
:
1320 generate_mov_dispatch_to_flags(inst
);
1323 case FS_OPCODE_DISCARD_JUMP
:
1324 generate_discard_jump(inst
);
1327 case SHADER_OPCODE_SHADER_TIME_ADD
:
1328 generate_shader_time_add(inst
, src
[0], src
[1], src
[2]);
1331 case FS_OPCODE_SET_SIMD4X2_OFFSET
:
1332 generate_set_simd4x2_offset(inst
, dst
, src
[0]);
1335 case FS_OPCODE_PACK_HALF_2x16_SPLIT
:
1336 generate_pack_half_2x16_split(inst
, dst
, src
[0], src
[1]);
1339 case FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X
:
1340 case FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
:
1341 generate_unpack_half_2x16_split(inst
, dst
, src
[0]);
1344 case FS_OPCODE_PLACEHOLDER_HALT
:
1345 /* This is the place where the final HALT needs to be inserted if
1346 * we've emitted any discards. If not, this will emit no code.
1348 patch_discard_jumps_to_fb_writes();
1352 if (inst
->opcode
< (int) ARRAY_SIZE(opcode_descs
)) {
1353 _mesa_problem(ctx
, "Unsupported opcode `%s' in FS",
1354 opcode_descs
[inst
->opcode
].name
);
1356 _mesa_problem(ctx
, "Unsupported opcode %d in FS", inst
->opcode
);
1361 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1362 brw_dump_compile(p
, stdout
,
1363 last_native_insn_offset
, p
->next_insn_offset
);
1365 foreach_list(node
, &cfg
->block_list
) {
1366 bblock_link
*link
= (bblock_link
*)node
;
1367 bblock_t
*block
= link
->block
;
1369 if (block
->end
== inst
) {
1370 printf(" END B%d", block
->block_num
);
1371 foreach_list(successor_node
, &block
->children
) {
1372 bblock_link
*successor_link
=
1373 (bblock_link
*)successor_node
;
1374 bblock_t
*successor_block
= successor_link
->block
;
1375 printf(" ->B%d", successor_block
->block_num
);
1382 last_native_insn_offset
= p
->next_insn_offset
;
1385 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1391 /* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
1392 * emit issues, it doesn't get the jump distances into the output,
1393 * which is often something we want to debug. So this is here in
1394 * case you're doing that.
1397 brw_dump_compile(p
, stdout
, 0, p
->next_insn_offset
);
1402 fs_generator::generate_assembly(exec_list
*simd8_instructions
,
1403 exec_list
*simd16_instructions
,
1404 unsigned *assembly_size
)
1407 generate_code(simd8_instructions
);
1409 if (simd16_instructions
) {
1410 /* We have to do a compaction pass now, or the one at the end of
1411 * execution will squash down where our prog_offset start needs
1414 brw_compact_instructions(p
);
1416 /* align to 64 byte boundary. */
1417 while ((p
->nr_insn
* sizeof(struct brw_instruction
)) % 64) {
1421 /* Save off the start of this 16-wide program */
1422 c
->prog_data
.prog_offset_16
= p
->nr_insn
* sizeof(struct brw_instruction
);
1424 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1426 dispatch_width
= 16;
1427 generate_code(simd16_instructions
);
1430 return brw_get_program(p
, assembly_size
);