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 msg_control
, rlen
, mlen
;
738 if (dispatch_width
== 16) {
739 msg_control
= BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS
;
742 msg_control
= BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS
;
746 struct brw_instruction
*send
= brw_next_insn(p
, BRW_OPCODE_SEND
);
747 brw_set_dest(p
, send
, dst
);
748 brw_set_src0(p
, send
, offset
);
750 send
->header
.destreg__conditionalmod
= inst
->base_mrf
;
751 brw_set_dp_read_message(p
, send
,
754 GEN7_DATAPORT_DC_DWORD_SCATTERED_READ
,
755 BRW_DATAPORT_READ_TARGET_DATA_CACHE
,
757 inst
->header_present
,
762 * Cause the current pixel/sample mask (from R1.7 bits 15:0) to be transferred
763 * into the flags register (f0.0).
765 * Used only on Gen6 and above.
768 fs_generator::generate_mov_dispatch_to_flags(fs_inst
*inst
)
770 struct brw_reg flags
= brw_flag_reg(0, inst
->flag_subreg
);
771 struct brw_reg dispatch_mask
;
774 dispatch_mask
= retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW
);
776 dispatch_mask
= retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW
);
778 brw_push_insn_state(p
);
779 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
780 brw_MOV(p
, flags
, dispatch_mask
);
781 brw_pop_insn_state(p
);
785 static uint32_t brw_file_from_reg(fs_reg
*reg
)
789 return BRW_ARCHITECTURE_REGISTER_FILE
;
791 return BRW_GENERAL_REGISTER_FILE
;
793 return BRW_MESSAGE_REGISTER_FILE
;
795 return BRW_IMMEDIATE_VALUE
;
797 assert(!"not reached");
798 return BRW_GENERAL_REGISTER_FILE
;
802 static struct brw_reg
803 brw_reg_from_fs_reg(fs_reg
*reg
)
805 struct brw_reg brw_reg
;
811 if (reg
->smear
== -1) {
812 brw_reg
= brw_vec8_reg(brw_file_from_reg(reg
), reg
->reg
, 0);
814 brw_reg
= brw_vec1_reg(brw_file_from_reg(reg
), reg
->reg
, reg
->smear
);
816 brw_reg
= retype(brw_reg
, reg
->type
);
818 brw_reg
= sechalf(brw_reg
);
822 case BRW_REGISTER_TYPE_F
:
823 brw_reg
= brw_imm_f(reg
->imm
.f
);
825 case BRW_REGISTER_TYPE_D
:
826 brw_reg
= brw_imm_d(reg
->imm
.i
);
828 case BRW_REGISTER_TYPE_UD
:
829 brw_reg
= brw_imm_ud(reg
->imm
.u
);
832 assert(!"not reached");
833 brw_reg
= brw_null_reg();
838 brw_reg
= reg
->fixed_hw_reg
;
841 /* Probably unused. */
842 brw_reg
= brw_null_reg();
845 assert(!"not reached");
846 brw_reg
= brw_null_reg();
849 assert(!"not reached");
850 brw_reg
= brw_null_reg();
854 brw_reg
= brw_abs(brw_reg
);
856 brw_reg
= negate(brw_reg
);
862 * Sets the first word of a vgrf for gen7+ simd4x2 uniform pull constant
863 * sampler LD messages.
865 * We don't want to bake it into the send message's code generation because
866 * that means we don't get a chance to schedule the instructions.
869 fs_generator::generate_set_simd4x2_offset(fs_inst
*inst
,
871 struct brw_reg value
)
873 assert(value
.file
== BRW_IMMEDIATE_VALUE
);
875 brw_push_insn_state(p
);
876 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
877 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
878 brw_MOV(p
, retype(brw_vec1_reg(dst
.file
, dst
.nr
, 0), value
.type
), value
);
879 brw_pop_insn_state(p
);
883 * Change the register's data type from UD to W, doubling the strides in order
884 * to compensate for halving the data type width.
886 static struct brw_reg
887 ud_reg_to_w(struct brw_reg r
)
889 assert(r
.type
== BRW_REGISTER_TYPE_UD
);
890 r
.type
= BRW_REGISTER_TYPE_W
;
892 /* The BRW_*_STRIDE enums are defined so that incrementing the field
893 * doubles the real stride.
904 fs_generator::generate_pack_half_2x16_split(fs_inst
*inst
,
909 assert(intel
->gen
>= 7);
910 assert(dst
.type
== BRW_REGISTER_TYPE_UD
);
911 assert(x
.type
== BRW_REGISTER_TYPE_F
);
912 assert(y
.type
== BRW_REGISTER_TYPE_F
);
914 /* From the Ivybridge PRM, Vol4, Part3, Section 6.27 f32to16:
916 * Because this instruction does not have a 16-bit floating-point type,
917 * the destination data type must be Word (W).
919 * The destination must be DWord-aligned and specify a horizontal stride
920 * (HorzStride) of 2. The 16-bit result is stored in the lower word of
921 * each destination channel and the upper word is not modified.
923 struct brw_reg dst_w
= ud_reg_to_w(dst
);
925 /* Give each 32-bit channel of dst the form below , where "." means
929 brw_F32TO16(p
, dst_w
, y
);
934 brw_SHL(p
, dst
, dst
, brw_imm_ud(16u));
936 /* And, finally the form of packHalf2x16's output:
939 brw_F32TO16(p
, dst_w
, x
);
943 fs_generator::generate_unpack_half_2x16_split(fs_inst
*inst
,
947 assert(intel
->gen
>= 7);
948 assert(dst
.type
== BRW_REGISTER_TYPE_F
);
949 assert(src
.type
== BRW_REGISTER_TYPE_UD
);
951 /* From the Ivybridge PRM, Vol4, Part3, Section 6.26 f16to32:
953 * Because this instruction does not have a 16-bit floating-point type,
954 * the source data type must be Word (W). The destination type must be
957 struct brw_reg src_w
= ud_reg_to_w(src
);
959 /* Each channel of src has the form of unpackHalf2x16's input: 0xhhhhllll.
960 * For the Y case, we wish to access only the upper word; therefore
961 * a 16-bit subregister offset is needed.
963 assert(inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X
||
964 inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
);
965 if (inst
->opcode
== FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
)
968 brw_F16TO32(p
, dst
, src_w
);
972 fs_generator::generate_shader_time_add(fs_inst
*inst
,
973 struct brw_reg payload
,
974 struct brw_reg offset
,
975 struct brw_reg value
)
977 assert(intel
->gen
>= 7);
978 brw_push_insn_state(p
);
979 brw_set_mask_control(p
, true);
981 assert(payload
.file
== BRW_GENERAL_REGISTER_FILE
);
982 struct brw_reg payload_offset
= retype(brw_vec1_grf(payload
.nr
, 0),
984 struct brw_reg payload_value
= retype(brw_vec1_grf(payload
.nr
+ 1, 0),
987 assert(offset
.file
== BRW_IMMEDIATE_VALUE
);
988 if (value
.file
== BRW_GENERAL_REGISTER_FILE
) {
989 value
.width
= BRW_WIDTH_1
;
990 value
.hstride
= BRW_HORIZONTAL_STRIDE_0
;
991 value
.vstride
= BRW_VERTICAL_STRIDE_0
;
993 assert(value
.file
== BRW_IMMEDIATE_VALUE
);
996 /* Trying to deal with setup of the params from the IR is crazy in the FS8
997 * case, and we don't really care about squeezing every bit of performance
998 * out of this path, so we just emit the MOVs from here.
1000 brw_MOV(p
, payload_offset
, offset
);
1001 brw_MOV(p
, payload_value
, value
);
1002 brw_shader_time_add(p
, payload
, SURF_INDEX_WM_SHADER_TIME
);
1003 brw_pop_insn_state(p
);
1007 fs_generator::generate_code(exec_list
*instructions
)
1009 int last_native_insn_offset
= p
->next_insn_offset
;
1010 const char *last_annotation_string
= NULL
;
1011 const void *last_annotation_ir
= NULL
;
1013 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1015 printf("Native code for fragment shader %d (%d-wide dispatch):\n",
1016 prog
->Name
, dispatch_width
);
1018 printf("Native code for fragment program %d (%d-wide dispatch):\n",
1019 fp
->Base
.Id
, dispatch_width
);
1024 if (unlikely(INTEL_DEBUG
& DEBUG_WM
))
1025 cfg
= new(mem_ctx
) cfg_t(mem_ctx
, instructions
);
1027 foreach_list(node
, instructions
) {
1028 fs_inst
*inst
= (fs_inst
*)node
;
1029 struct brw_reg src
[3], dst
;
1031 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1032 foreach_list(node
, &cfg
->block_list
) {
1033 bblock_link
*link
= (bblock_link
*)node
;
1034 bblock_t
*block
= link
->block
;
1036 if (block
->start
== inst
) {
1037 printf(" START B%d", block
->block_num
);
1038 foreach_list(predecessor_node
, &block
->parents
) {
1039 bblock_link
*predecessor_link
=
1040 (bblock_link
*)predecessor_node
;
1041 bblock_t
*predecessor_block
= predecessor_link
->block
;
1042 printf(" <-B%d", predecessor_block
->block_num
);
1048 if (last_annotation_ir
!= inst
->ir
) {
1049 last_annotation_ir
= inst
->ir
;
1050 if (last_annotation_ir
) {
1053 ((ir_instruction
*)inst
->ir
)->print();
1055 const prog_instruction
*fpi
;
1056 fpi
= (const prog_instruction
*)inst
->ir
;
1057 printf("%d: ", (int)(fpi
- fp
->Base
.Instructions
));
1058 _mesa_fprint_instruction_opt(stdout
,
1060 0, PROG_PRINT_DEBUG
, NULL
);
1065 if (last_annotation_string
!= inst
->annotation
) {
1066 last_annotation_string
= inst
->annotation
;
1067 if (last_annotation_string
)
1068 printf(" %s\n", last_annotation_string
);
1072 for (unsigned int i
= 0; i
< 3; i
++) {
1073 src
[i
] = brw_reg_from_fs_reg(&inst
->src
[i
]);
1075 /* The accumulator result appears to get used for the
1076 * conditional modifier generation. When negating a UD
1077 * value, there is a 33rd bit generated for the sign in the
1078 * accumulator value, so now you can't check, for example,
1079 * equality with a 32-bit value. See piglit fs-op-neg-uvec4.
1081 assert(!inst
->conditional_mod
||
1082 inst
->src
[i
].type
!= BRW_REGISTER_TYPE_UD
||
1083 !inst
->src
[i
].negate
);
1085 dst
= brw_reg_from_fs_reg(&inst
->dst
);
1087 brw_set_conditionalmod(p
, inst
->conditional_mod
);
1088 brw_set_predicate_control(p
, inst
->predicate
);
1089 brw_set_predicate_inverse(p
, inst
->predicate_inverse
);
1090 brw_set_flag_reg(p
, 0, inst
->flag_subreg
);
1091 brw_set_saturate(p
, inst
->saturate
);
1092 brw_set_mask_control(p
, inst
->force_writemask_all
);
1094 if (inst
->force_uncompressed
|| dispatch_width
== 8) {
1095 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1096 } else if (inst
->force_sechalf
) {
1097 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1099 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1102 switch (inst
->opcode
) {
1103 case BRW_OPCODE_MOV
:
1104 brw_MOV(p
, dst
, src
[0]);
1106 case BRW_OPCODE_ADD
:
1107 brw_ADD(p
, dst
, src
[0], src
[1]);
1109 case BRW_OPCODE_MUL
:
1110 brw_MUL(p
, dst
, src
[0], src
[1]);
1112 case BRW_OPCODE_MACH
:
1113 brw_set_acc_write_control(p
, 1);
1114 brw_MACH(p
, dst
, src
[0], src
[1]);
1115 brw_set_acc_write_control(p
, 0);
1118 case BRW_OPCODE_MAD
:
1119 brw_set_access_mode(p
, BRW_ALIGN_16
);
1120 if (dispatch_width
== 16) {
1121 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1122 brw_MAD(p
, dst
, src
[0], src
[1], src
[2]);
1123 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1124 brw_MAD(p
, sechalf(dst
), sechalf(src
[0]), sechalf(src
[1]), sechalf(src
[2]));
1125 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1127 brw_MAD(p
, dst
, src
[0], src
[1], src
[2]);
1129 brw_set_access_mode(p
, BRW_ALIGN_1
);
1132 case BRW_OPCODE_LRP
:
1133 brw_set_access_mode(p
, BRW_ALIGN_16
);
1134 if (dispatch_width
== 16) {
1135 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1136 brw_LRP(p
, dst
, src
[0], src
[1], src
[2]);
1137 brw_set_compression_control(p
, BRW_COMPRESSION_2NDHALF
);
1138 brw_LRP(p
, sechalf(dst
), sechalf(src
[0]), sechalf(src
[1]), sechalf(src
[2]));
1139 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1141 brw_LRP(p
, dst
, src
[0], src
[1], src
[2]);
1143 brw_set_access_mode(p
, BRW_ALIGN_1
);
1146 case BRW_OPCODE_FRC
:
1147 brw_FRC(p
, dst
, src
[0]);
1149 case BRW_OPCODE_RNDD
:
1150 brw_RNDD(p
, dst
, src
[0]);
1152 case BRW_OPCODE_RNDE
:
1153 brw_RNDE(p
, dst
, src
[0]);
1155 case BRW_OPCODE_RNDZ
:
1156 brw_RNDZ(p
, dst
, src
[0]);
1159 case BRW_OPCODE_AND
:
1160 brw_AND(p
, dst
, src
[0], src
[1]);
1163 brw_OR(p
, dst
, src
[0], src
[1]);
1165 case BRW_OPCODE_XOR
:
1166 brw_XOR(p
, dst
, src
[0], src
[1]);
1168 case BRW_OPCODE_NOT
:
1169 brw_NOT(p
, dst
, src
[0]);
1171 case BRW_OPCODE_ASR
:
1172 brw_ASR(p
, dst
, src
[0], src
[1]);
1174 case BRW_OPCODE_SHR
:
1175 brw_SHR(p
, dst
, src
[0], src
[1]);
1177 case BRW_OPCODE_SHL
:
1178 brw_SHL(p
, dst
, src
[0], src
[1]);
1180 case BRW_OPCODE_F32TO16
:
1181 brw_F32TO16(p
, dst
, src
[0]);
1183 case BRW_OPCODE_F16TO32
:
1184 brw_F16TO32(p
, dst
, src
[0]);
1186 case BRW_OPCODE_CMP
:
1187 brw_CMP(p
, dst
, inst
->conditional_mod
, src
[0], src
[1]);
1189 case BRW_OPCODE_SEL
:
1190 brw_SEL(p
, dst
, src
[0], src
[1]);
1194 if (inst
->src
[0].file
!= BAD_FILE
) {
1195 /* The instruction has an embedded compare (only allowed on gen6) */
1196 assert(intel
->gen
== 6);
1197 gen6_IF(p
, inst
->conditional_mod
, src
[0], src
[1]);
1199 brw_IF(p
, dispatch_width
== 16 ? BRW_EXECUTE_16
: BRW_EXECUTE_8
);
1203 case BRW_OPCODE_ELSE
:
1206 case BRW_OPCODE_ENDIF
:
1211 brw_DO(p
, BRW_EXECUTE_8
);
1214 case BRW_OPCODE_BREAK
:
1216 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1218 case BRW_OPCODE_CONTINUE
:
1219 /* FINISHME: We need to write the loop instruction support still. */
1220 if (intel
->gen
>= 6)
1224 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1227 case BRW_OPCODE_WHILE
:
1231 case SHADER_OPCODE_RCP
:
1232 case SHADER_OPCODE_RSQ
:
1233 case SHADER_OPCODE_SQRT
:
1234 case SHADER_OPCODE_EXP2
:
1235 case SHADER_OPCODE_LOG2
:
1236 case SHADER_OPCODE_SIN
:
1237 case SHADER_OPCODE_COS
:
1238 if (intel
->gen
>= 7) {
1239 generate_math1_gen7(inst
, dst
, src
[0]);
1240 } else if (intel
->gen
== 6) {
1241 generate_math1_gen6(inst
, dst
, src
[0]);
1243 generate_math_gen4(inst
, dst
, src
[0]);
1246 case SHADER_OPCODE_INT_QUOTIENT
:
1247 case SHADER_OPCODE_INT_REMAINDER
:
1248 case SHADER_OPCODE_POW
:
1249 if (intel
->gen
>= 7) {
1250 generate_math2_gen7(inst
, dst
, src
[0], src
[1]);
1251 } else if (intel
->gen
== 6) {
1252 generate_math2_gen6(inst
, dst
, src
[0], src
[1]);
1254 generate_math_gen4(inst
, dst
, src
[0]);
1257 case FS_OPCODE_PIXEL_X
:
1258 generate_pixel_xy(dst
, true);
1260 case FS_OPCODE_PIXEL_Y
:
1261 generate_pixel_xy(dst
, false);
1263 case FS_OPCODE_CINTERP
:
1264 brw_MOV(p
, dst
, src
[0]);
1266 case FS_OPCODE_LINTERP
:
1267 generate_linterp(inst
, dst
, src
);
1269 case SHADER_OPCODE_TEX
:
1271 case SHADER_OPCODE_TXD
:
1272 case SHADER_OPCODE_TXF
:
1273 case SHADER_OPCODE_TXF_MS
:
1274 case SHADER_OPCODE_TXL
:
1275 case SHADER_OPCODE_TXS
:
1276 case SHADER_OPCODE_LOD
:
1277 generate_tex(inst
, dst
, src
[0]);
1280 generate_ddx(inst
, dst
, src
[0]);
1283 /* Make sure fp->UsesDFdy flag got set (otherwise there's no
1284 * guarantee that c->key.render_to_fbo is set).
1286 assert(fp
->UsesDFdy
);
1287 generate_ddy(inst
, dst
, src
[0], c
->key
.render_to_fbo
);
1290 case FS_OPCODE_SPILL
:
1291 generate_spill(inst
, src
[0]);
1294 case FS_OPCODE_UNSPILL
:
1295 generate_unspill(inst
, dst
);
1298 case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD
:
1299 generate_uniform_pull_constant_load(inst
, dst
, src
[0], src
[1]);
1302 case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7
:
1303 generate_uniform_pull_constant_load_gen7(inst
, dst
, src
[0], src
[1]);
1306 case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD
:
1307 generate_varying_pull_constant_load(inst
, dst
, src
[0]);
1310 case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7
:
1311 generate_varying_pull_constant_load_gen7(inst
, dst
, src
[0], src
[1]);
1314 case FS_OPCODE_FB_WRITE
:
1315 generate_fb_write(inst
);
1318 case FS_OPCODE_MOV_DISPATCH_TO_FLAGS
:
1319 generate_mov_dispatch_to_flags(inst
);
1322 case FS_OPCODE_DISCARD_JUMP
:
1323 generate_discard_jump(inst
);
1326 case SHADER_OPCODE_SHADER_TIME_ADD
:
1327 generate_shader_time_add(inst
, src
[0], src
[1], src
[2]);
1330 case FS_OPCODE_SET_SIMD4X2_OFFSET
:
1331 generate_set_simd4x2_offset(inst
, dst
, src
[0]);
1334 case FS_OPCODE_PACK_HALF_2x16_SPLIT
:
1335 generate_pack_half_2x16_split(inst
, dst
, src
[0], src
[1]);
1338 case FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X
:
1339 case FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y
:
1340 generate_unpack_half_2x16_split(inst
, dst
, src
[0]);
1343 case FS_OPCODE_PLACEHOLDER_HALT
:
1344 /* This is the place where the final HALT needs to be inserted if
1345 * we've emitted any discards. If not, this will emit no code.
1347 patch_discard_jumps_to_fb_writes();
1351 if (inst
->opcode
< (int) ARRAY_SIZE(opcode_descs
)) {
1352 _mesa_problem(ctx
, "Unsupported opcode `%s' in FS",
1353 opcode_descs
[inst
->opcode
].name
);
1355 _mesa_problem(ctx
, "Unsupported opcode %d in FS", inst
->opcode
);
1360 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1361 brw_dump_compile(p
, stdout
,
1362 last_native_insn_offset
, p
->next_insn_offset
);
1364 foreach_list(node
, &cfg
->block_list
) {
1365 bblock_link
*link
= (bblock_link
*)node
;
1366 bblock_t
*block
= link
->block
;
1368 if (block
->end
== inst
) {
1369 printf(" END B%d", block
->block_num
);
1370 foreach_list(successor_node
, &block
->children
) {
1371 bblock_link
*successor_link
=
1372 (bblock_link
*)successor_node
;
1373 bblock_t
*successor_block
= successor_link
->block
;
1374 printf(" ->B%d", successor_block
->block_num
);
1381 last_native_insn_offset
= p
->next_insn_offset
;
1384 if (unlikely(INTEL_DEBUG
& DEBUG_WM
)) {
1390 /* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
1391 * emit issues, it doesn't get the jump distances into the output,
1392 * which is often something we want to debug. So this is here in
1393 * case you're doing that.
1396 brw_dump_compile(p
, stdout
, 0, p
->next_insn_offset
);
1401 fs_generator::generate_assembly(exec_list
*simd8_instructions
,
1402 exec_list
*simd16_instructions
,
1403 unsigned *assembly_size
)
1406 generate_code(simd8_instructions
);
1408 if (simd16_instructions
) {
1409 /* We have to do a compaction pass now, or the one at the end of
1410 * execution will squash down where our prog_offset start needs
1413 brw_compact_instructions(p
);
1415 /* align to 64 byte boundary. */
1416 while ((p
->nr_insn
* sizeof(struct brw_instruction
)) % 64) {
1420 /* Save off the start of this 16-wide program */
1421 c
->prog_data
.prog_offset_16
= p
->nr_insn
* sizeof(struct brw_instruction
);
1423 brw_set_compression_control(p
, BRW_COMPRESSION_COMPRESSED
);
1425 dispatch_width
= 16;
1426 generate_code(simd16_instructions
);
1429 return brw_get_program(p
, assembly_size
);