blob: e477a6168a929c526c3bd28196f256deb4c647e7 [file] [log] [blame]
Eric Anholt11dd9e92011-05-24 16:34:27 -07001/*
2 * Copyright © 2010 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 */
23
24/** @file brw_fs_emit.cpp
25 *
26 * This file supports emitting code from the FS LIR to the actual
27 * native instructions.
28 */
29
30extern "C" {
31#include "main/macros.h"
32#include "brw_context.h"
33#include "brw_eu.h"
34} /* extern "C" */
35
36#include "brw_fs.h"
Eric Anholt080b1252012-04-10 12:01:50 -070037#include "brw_fs_cfg.h"
Chad Versace2f0edc62011-08-26 13:58:41 -070038#include "glsl/ir_print_visitor.h"
Eric Anholt11dd9e92011-05-24 16:34:27 -070039
40void
41fs_visitor::generate_fb_write(fs_inst *inst)
42{
Kenneth Graunke2e5a1a22011-10-07 12:26:50 -070043 bool eot = inst->eot;
Eric Anholt11dd9e92011-05-24 16:34:27 -070044 struct brw_reg implied_header;
Eric Anholt29362872012-04-25 13:58:07 -070045 uint32_t msg_control;
Eric Anholt11dd9e92011-05-24 16:34:27 -070046
47 /* Header is 2 regs, g0 and g1 are the contents. g0 will be implied
48 * move, here's g1.
49 */
50 brw_push_insn_state(p);
51 brw_set_mask_control(p, BRW_MASK_DISABLE);
52 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
53
54 if (inst->header_present) {
55 if (intel->gen >= 6) {
56 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
57 brw_MOV(p,
58 retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD),
59 retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
60 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
61
Anuj Phogate592f7d2012-08-01 16:32:06 -070062 if (inst->target > 0 &&
63 c->key.nr_color_regions > 1 &&
64 c->key.sample_alpha_to_coverage) {
65 /* Set "Source0 Alpha Present to RenderTarget" bit in message
66 * header.
67 */
68 brw_OR(p,
69 vec1(retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD)),
70 vec1(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD)),
71 brw_imm_ud(0x1 << 11));
72 }
73
Eric Anholt11dd9e92011-05-24 16:34:27 -070074 if (inst->target > 0) {
75 /* Set the render target index for choosing BLEND_STATE. */
Eric Anholt3daa2d92011-07-25 15:39:03 -070076 brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE,
77 inst->base_mrf, 2),
Eric Anholt11dd9e92011-05-24 16:34:27 -070078 BRW_REGISTER_TYPE_UD),
79 brw_imm_ud(inst->target));
80 }
81
82 implied_header = brw_null_reg();
83 } else {
84 implied_header = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);
85
86 brw_MOV(p,
87 brw_message_reg(inst->base_mrf + 1),
88 brw_vec8_grf(1, 0));
89 }
90 } else {
91 implied_header = brw_null_reg();
92 }
93
Eric Anholt29362872012-04-25 13:58:07 -070094 if (this->dual_src_output.file != BAD_FILE)
95 msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01;
96 else if (c->dispatch_width == 16)
97 msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
98 else
99 msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
100
Eric Anholt11dd9e92011-05-24 16:34:27 -0700101 brw_pop_insn_state(p);
102
103 brw_fb_WRITE(p,
104 c->dispatch_width,
105 inst->base_mrf,
106 implied_header,
Eric Anholt29362872012-04-25 13:58:07 -0700107 msg_control,
Eric Anholt11dd9e92011-05-24 16:34:27 -0700108 inst->target,
109 inst->mlen,
110 0,
111 eot,
112 inst->header_present);
113}
114
115/* Computes the integer pixel x,y values from the origin.
116 *
117 * This is the basis of gl_FragCoord computation, but is also used
118 * pre-gen6 for computing the deltas from v0 for computing
119 * interpolation.
120 */
121void
122fs_visitor::generate_pixel_xy(struct brw_reg dst, bool is_x)
123{
124 struct brw_reg g1_uw = retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW);
125 struct brw_reg src;
126 struct brw_reg deltas;
127
128 if (is_x) {
129 src = stride(suboffset(g1_uw, 4), 2, 4, 0);
130 deltas = brw_imm_v(0x10101010);
131 } else {
132 src = stride(suboffset(g1_uw, 5), 2, 4, 0);
133 deltas = brw_imm_v(0x11001100);
134 }
135
136 if (c->dispatch_width == 16) {
137 dst = vec16(dst);
138 }
139
140 /* We do this 8 or 16-wide, but since the destination is UW we
141 * don't do compression in the 16-wide case.
142 */
143 brw_push_insn_state(p);
144 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
145 brw_ADD(p, dst, src, deltas);
146 brw_pop_insn_state(p);
147}
148
149void
150fs_visitor::generate_linterp(fs_inst *inst,
151 struct brw_reg dst, struct brw_reg *src)
152{
153 struct brw_reg delta_x = src[0];
154 struct brw_reg delta_y = src[1];
155 struct brw_reg interp = src[2];
156
157 if (brw->has_pln &&
158 delta_y.nr == delta_x.nr + 1 &&
159 (intel->gen >= 6 || (delta_x.nr & 1) == 0)) {
160 brw_PLN(p, dst, interp, delta_x);
161 } else {
162 brw_LINE(p, brw_null_reg(), interp, delta_x);
163 brw_MAC(p, dst, suboffset(interp, 1), delta_y);
164 }
165}
166
167void
Kenneth Graunkea73c65c2011-10-18 12:24:47 -0700168fs_visitor::generate_math1_gen7(fs_inst *inst,
169 struct brw_reg dst,
170 struct brw_reg src0)
171{
172 assert(inst->mlen == 0);
173 brw_math(p, dst,
174 brw_math_function(inst->opcode),
Kenneth Graunkea73c65c2011-10-18 12:24:47 -0700175 0, src0,
176 BRW_MATH_DATA_VECTOR,
177 BRW_MATH_PRECISION_FULL);
178}
179
180void
181fs_visitor::generate_math2_gen7(fs_inst *inst,
182 struct brw_reg dst,
183 struct brw_reg src0,
184 struct brw_reg src1)
185{
186 assert(inst->mlen == 0);
187 brw_math2(p, dst, brw_math_function(inst->opcode), src0, src1);
188}
189
190void
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700191fs_visitor::generate_math1_gen6(fs_inst *inst,
192 struct brw_reg dst,
193 struct brw_reg src0)
Eric Anholt11dd9e92011-05-24 16:34:27 -0700194{
Eric Anholtaf3c9802011-05-02 09:45:40 -0700195 int op = brw_math_function(inst->opcode);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700196
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700197 assert(inst->mlen == 0);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700198
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700199 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
200 brw_math(p, dst,
201 op,
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700202 0, src0,
203 BRW_MATH_DATA_VECTOR,
204 BRW_MATH_PRECISION_FULL);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700205
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700206 if (c->dispatch_width == 16) {
207 brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
208 brw_math(p, sechalf(dst),
Eric Anholt11dd9e92011-05-24 16:34:27 -0700209 op,
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700210 0, sechalf(src0),
211 BRW_MATH_DATA_VECTOR,
212 BRW_MATH_PRECISION_FULL);
213 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
214 }
215}
216
217void
218fs_visitor::generate_math2_gen6(fs_inst *inst,
219 struct brw_reg dst,
220 struct brw_reg src0,
221 struct brw_reg src1)
222{
223 int op = brw_math_function(inst->opcode);
224
225 assert(inst->mlen == 0);
226
227 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
228 brw_math2(p, dst, op, src0, src1);
229
230 if (c->dispatch_width == 16) {
231 brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
232 brw_math2(p, sechalf(dst), op, sechalf(src0), sechalf(src1));
233 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
234 }
235}
236
237void
238fs_visitor::generate_math_gen4(fs_inst *inst,
239 struct brw_reg dst,
240 struct brw_reg src)
241{
242 int op = brw_math_function(inst->opcode);
243
244 assert(inst->mlen >= 1);
245
246 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
247 brw_math(p, dst,
248 op,
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700249 inst->base_mrf, src,
250 BRW_MATH_DATA_VECTOR,
251 BRW_MATH_PRECISION_FULL);
252
253 if (c->dispatch_width == 16) {
254 brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
255 brw_math(p, sechalf(dst),
256 op,
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700257 inst->base_mrf + 1, sechalf(src),
Eric Anholt11dd9e92011-05-24 16:34:27 -0700258 BRW_MATH_DATA_VECTOR,
259 BRW_MATH_PRECISION_FULL);
260
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700261 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700262 }
263}
264
265void
266fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
267{
268 int msg_type = -1;
269 int rlen = 4;
270 uint32_t simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;
Eric Anholt7e84a642011-11-09 16:07:57 -0800271 uint32_t return_format;
272
273 switch (dst.type) {
274 case BRW_REGISTER_TYPE_D:
275 return_format = BRW_SAMPLER_RETURN_FORMAT_SINT32;
276 break;
277 case BRW_REGISTER_TYPE_UD:
278 return_format = BRW_SAMPLER_RETURN_FORMAT_UINT32;
279 break;
280 default:
281 return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
282 break;
283 }
Eric Anholt11dd9e92011-05-24 16:34:27 -0700284
285 if (c->dispatch_width == 16)
286 simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
287
288 if (intel->gen >= 5) {
289 switch (inst->opcode) {
Kenneth Graunkefebad172011-10-26 12:58:37 -0700290 case SHADER_OPCODE_TEX:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700291 if (inst->shadow_compare) {
292 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE;
293 } else {
294 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE;
295 }
296 break;
297 case FS_OPCODE_TXB:
298 if (inst->shadow_compare) {
299 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE;
300 } else {
301 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS;
302 }
303 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700304 case SHADER_OPCODE_TXL:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700305 if (inst->shadow_compare) {
306 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE;
307 } else {
308 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD;
309 }
310 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700311 case SHADER_OPCODE_TXS:
Kenneth Graunkeecf89632011-06-19 01:47:50 -0700312 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO;
313 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700314 case SHADER_OPCODE_TXD:
Kenneth Graunke6430df32011-06-10 14:48:46 -0700315 /* There is no sample_d_c message; comparisons are done manually */
Kenneth Graunke3fa910f2011-06-08 16:08:07 -0700316 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700317 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700318 case SHADER_OPCODE_TXF:
Kenneth Graunke30be2cc2011-08-25 17:13:37 -0700319 msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LD;
320 break;
Eric Anholt6034b9a2011-05-03 10:55:50 -0700321 default:
322 assert(!"not reached");
323 break;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700324 }
325 } else {
326 switch (inst->opcode) {
Kenneth Graunkefebad172011-10-26 12:58:37 -0700327 case SHADER_OPCODE_TEX:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700328 /* Note that G45 and older determines shadow compare and dispatch width
329 * from message length for most messages.
330 */
331 assert(c->dispatch_width == 8);
332 msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE;
333 if (inst->shadow_compare) {
334 assert(inst->mlen == 6);
335 } else {
336 assert(inst->mlen <= 4);
337 }
338 break;
339 case FS_OPCODE_TXB:
340 if (inst->shadow_compare) {
341 assert(inst->mlen == 6);
342 msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE;
343 } else {
344 assert(inst->mlen == 9);
345 msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
346 simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
347 }
348 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700349 case SHADER_OPCODE_TXL:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700350 if (inst->shadow_compare) {
351 assert(inst->mlen == 6);
352 msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE;
353 } else {
354 assert(inst->mlen == 9);
355 msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD;
356 simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
357 }
358 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700359 case SHADER_OPCODE_TXD:
Kenneth Graunke6430df32011-06-10 14:48:46 -0700360 /* There is no sample_d_c message; comparisons are done manually */
Kenneth Graunke6c947cf2011-06-08 16:05:34 -0700361 assert(inst->mlen == 7 || inst->mlen == 10);
362 msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700363 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700364 case SHADER_OPCODE_TXF:
Kenneth Graunke47b556f2011-09-06 16:39:01 -0700365 assert(inst->mlen == 9);
366 msg_type = BRW_SAMPLER_MESSAGE_SIMD16_LD;
367 simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
368 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700369 case SHADER_OPCODE_TXS:
Kenneth Graunke4eeb4c12011-08-17 10:45:47 -0700370 assert(inst->mlen == 3);
371 msg_type = BRW_SAMPLER_MESSAGE_SIMD16_RESINFO;
372 simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
373 break;
Eric Anholt6034b9a2011-05-03 10:55:50 -0700374 default:
375 assert(!"not reached");
376 break;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700377 }
378 }
379 assert(msg_type != -1);
380
381 if (simd_mode == BRW_SAMPLER_SIMD_MODE_SIMD16) {
382 rlen = 8;
383 dst = vec16(dst);
384 }
385
Kenneth Graunke82bfb4b2012-08-04 20:33:13 -0700386 /* Load the message header if present. If there's a texture offset,
387 * we need to set it up explicitly and load the offset bitfield.
388 * Otherwise, we can use an implied move from g0 to the first message reg.
389 */
390 if (inst->texture_offset) {
391 brw_push_insn_state(p);
392 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
393 /* Explicitly set up the message header by copying g0 to the MRF. */
394 brw_MOV(p, retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD),
395 retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
396
397 /* Then set the offset bits in DWord 2. */
398 brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE,
399 inst->base_mrf, 2), BRW_REGISTER_TYPE_UD),
400 brw_imm_ud(inst->texture_offset));
401 brw_pop_insn_state(p);
402 } else if (inst->header_present) {
403 /* Set up an implied move from g0 to the MRF. */
404 src = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);
405 }
406
Eric Anholt11dd9e92011-05-24 16:34:27 -0700407 brw_SAMPLE(p,
408 retype(dst, BRW_REGISTER_TYPE_UW),
409 inst->base_mrf,
410 src,
411 SURF_INDEX_TEXTURE(inst->sampler),
412 inst->sampler,
413 WRITEMASK_XYZW,
414 msg_type,
415 rlen,
416 inst->mlen,
Eric Anholt11dd9e92011-05-24 16:34:27 -0700417 inst->header_present,
Eric Anholt7e84a642011-11-09 16:07:57 -0800418 simd_mode,
419 return_format);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700420}
421
422
423/* For OPCODE_DDX and OPCODE_DDY, per channel of output we've got input
424 * looking like:
425 *
426 * arg0: ss0.tl ss0.tr ss0.bl ss0.br ss1.tl ss1.tr ss1.bl ss1.br
427 *
428 * and we're trying to produce:
429 *
430 * DDX DDY
431 * dst: (ss0.tr - ss0.tl) (ss0.tl - ss0.bl)
432 * (ss0.tr - ss0.tl) (ss0.tr - ss0.br)
433 * (ss0.br - ss0.bl) (ss0.tl - ss0.bl)
434 * (ss0.br - ss0.bl) (ss0.tr - ss0.br)
435 * (ss1.tr - ss1.tl) (ss1.tl - ss1.bl)
436 * (ss1.tr - ss1.tl) (ss1.tr - ss1.br)
437 * (ss1.br - ss1.bl) (ss1.tl - ss1.bl)
438 * (ss1.br - ss1.bl) (ss1.tr - ss1.br)
439 *
440 * and add another set of two more subspans if in 16-pixel dispatch mode.
441 *
442 * For DDX, it ends up being easy: width = 2, horiz=0 gets us the same result
443 * for each pair, and vertstride = 2 jumps us 2 elements after processing a
444 * pair. But for DDY, it's harder, as we want to produce the pairs swizzled
445 * between each other. We could probably do it like ddx and swizzle the right
446 * order later, but bail for now and just produce
447 * ((ss0.tl - ss0.bl)x4 (ss1.tl - ss1.bl)x4)
448 */
449void
450fs_visitor::generate_ddx(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
451{
452 struct brw_reg src0 = brw_reg(src.file, src.nr, 1,
453 BRW_REGISTER_TYPE_F,
454 BRW_VERTICAL_STRIDE_2,
455 BRW_WIDTH_2,
456 BRW_HORIZONTAL_STRIDE_0,
457 BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
458 struct brw_reg src1 = brw_reg(src.file, src.nr, 0,
459 BRW_REGISTER_TYPE_F,
460 BRW_VERTICAL_STRIDE_2,
461 BRW_WIDTH_2,
462 BRW_HORIZONTAL_STRIDE_0,
463 BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
464 brw_ADD(p, dst, src0, negate(src1));
465}
466
Paul Berry82d25962012-06-20 13:40:45 -0700467/* The negate_value boolean is used to negate the derivative computation for
468 * FBOs, since they place the origin at the upper left instead of the lower
469 * left.
470 */
Eric Anholt11dd9e92011-05-24 16:34:27 -0700471void
Paul Berry82d25962012-06-20 13:40:45 -0700472fs_visitor::generate_ddy(fs_inst *inst, struct brw_reg dst, struct brw_reg src,
473 bool negate_value)
Eric Anholt11dd9e92011-05-24 16:34:27 -0700474{
475 struct brw_reg src0 = brw_reg(src.file, src.nr, 0,
476 BRW_REGISTER_TYPE_F,
477 BRW_VERTICAL_STRIDE_4,
478 BRW_WIDTH_4,
479 BRW_HORIZONTAL_STRIDE_0,
480 BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
481 struct brw_reg src1 = brw_reg(src.file, src.nr, 2,
482 BRW_REGISTER_TYPE_F,
483 BRW_VERTICAL_STRIDE_4,
484 BRW_WIDTH_4,
485 BRW_HORIZONTAL_STRIDE_0,
486 BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
Paul Berry82d25962012-06-20 13:40:45 -0700487 if (negate_value)
488 brw_ADD(p, dst, src1, negate(src0));
489 else
490 brw_ADD(p, dst, src0, negate(src1));
Eric Anholt11dd9e92011-05-24 16:34:27 -0700491}
492
493void
494fs_visitor::generate_discard(fs_inst *inst)
495{
496 struct brw_reg f0 = brw_flag_reg();
497
498 if (intel->gen >= 6) {
499 struct brw_reg g1 = retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW);
500 struct brw_reg some_register;
501
502 /* As of gen6, we no longer have the mask register to look at,
503 * so life gets a bit more complicated.
504 */
505
506 /* Load the flag register with all ones. */
507 brw_push_insn_state(p);
508 brw_set_mask_control(p, BRW_MASK_DISABLE);
509 brw_MOV(p, f0, brw_imm_uw(0xffff));
510 brw_pop_insn_state(p);
511
512 /* Do a comparison that should always fail, to produce 0s in the flag
513 * reg where we have active channels.
514 */
515 some_register = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);
516 brw_CMP(p, retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
517 BRW_CONDITIONAL_NZ, some_register, some_register);
518
519 /* Undo CMP's whacking of predication*/
520 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
521
522 brw_push_insn_state(p);
523 brw_set_mask_control(p, BRW_MASK_DISABLE);
524 brw_AND(p, g1, f0, g1);
525 brw_pop_insn_state(p);
526 } else {
527 struct brw_reg g0 = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
528
529 brw_push_insn_state(p);
530 brw_set_mask_control(p, BRW_MASK_DISABLE);
531 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
532
533 /* Unlike the 965, we have the mask reg, so we just need
534 * somewhere to invert that (containing channels to be disabled)
535 * so it can be ANDed with the mask of pixels still to be
536 * written. Use the flag reg for consistency with gen6+.
537 */
538 brw_NOT(p, f0, brw_mask_reg(1)); /* IMASK */
539 brw_AND(p, g0, f0, g0);
540
541 brw_pop_insn_state(p);
542 }
543}
544
545void
546fs_visitor::generate_spill(fs_inst *inst, struct brw_reg src)
547{
548 assert(inst->mlen != 0);
549
550 brw_MOV(p,
551 retype(brw_message_reg(inst->base_mrf + 1), BRW_REGISTER_TYPE_UD),
552 retype(src, BRW_REGISTER_TYPE_UD));
553 brw_oword_block_write_scratch(p, brw_message_reg(inst->base_mrf), 1,
554 inst->offset);
555}
556
557void
558fs_visitor::generate_unspill(fs_inst *inst, struct brw_reg dst)
559{
560 assert(inst->mlen != 0);
561
562 /* Clear any post destination dependencies that would be ignored by
563 * the block read. See the B-Spec for pre-gen5 send instruction.
564 *
565 * This could use a better solution, since texture sampling and
566 * math reads could potentially run into it as well -- anywhere
567 * that we have a SEND with a destination that is a register that
568 * was written but not read within the last N instructions (what's
569 * N? unsure). This is rare because of dead code elimination, but
570 * not impossible.
571 */
572 if (intel->gen == 4 && !intel->is_g4x)
573 brw_MOV(p, brw_null_reg(), dst);
574
575 brw_oword_block_read_scratch(p, dst, brw_message_reg(inst->base_mrf), 1,
576 inst->offset);
577
578 if (intel->gen == 4 && !intel->is_g4x) {
579 /* gen4 errata: destination from a send can't be used as a
580 * destination until it's been read. Just read it so we don't
581 * have to worry.
582 */
583 brw_MOV(p, brw_null_reg(), dst);
584 }
585}
586
587void
Eric Anholt454dc832012-06-20 15:41:14 -0700588fs_visitor::generate_pull_constant_load(fs_inst *inst, struct brw_reg dst,
589 struct brw_reg index,
590 struct brw_reg offset)
Eric Anholt11dd9e92011-05-24 16:34:27 -0700591{
592 assert(inst->mlen != 0);
593
594 /* Clear any post destination dependencies that would be ignored by
595 * the block read. See the B-Spec for pre-gen5 send instruction.
596 *
597 * This could use a better solution, since texture sampling and
598 * math reads could potentially run into it as well -- anywhere
599 * that we have a SEND with a destination that is a register that
600 * was written but not read within the last N instructions (what's
601 * N? unsure). This is rare because of dead code elimination, but
602 * not impossible.
603 */
604 if (intel->gen == 4 && !intel->is_g4x)
605 brw_MOV(p, brw_null_reg(), dst);
606
Eric Anholt454dc832012-06-20 15:41:14 -0700607 assert(index.file == BRW_IMMEDIATE_VALUE &&
608 index.type == BRW_REGISTER_TYPE_UD);
609 uint32_t surf_index = index.dw1.ud;
610
611 assert(offset.file == BRW_IMMEDIATE_VALUE &&
612 offset.type == BRW_REGISTER_TYPE_UD);
613 uint32_t read_offset = offset.dw1.ud;
614
Eric Anholt11dd9e92011-05-24 16:34:27 -0700615 brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf),
Eric Anholt454dc832012-06-20 15:41:14 -0700616 read_offset, surf_index);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700617
618 if (intel->gen == 4 && !intel->is_g4x) {
619 /* gen4 errata: destination from a send can't be used as a
620 * destination until it's been read. Just read it so we don't
621 * have to worry.
622 */
623 brw_MOV(p, brw_null_reg(), dst);
624 }
625}
626
Paul Berry3f929ef2012-06-18 14:50:04 -0700627
628/**
629 * Cause the current pixel/sample mask (from R1.7 bits 15:0) to be transferred
630 * into the flags register (f0.0).
631 *
632 * Used only on Gen6 and above.
633 */
634void
635fs_visitor::generate_mov_dispatch_to_flags()
636{
637 struct brw_reg f0 = brw_flag_reg();
638 struct brw_reg g1 = retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW);
639
640 assert (intel->gen >= 6);
641 brw_push_insn_state(p);
642 brw_set_mask_control(p, BRW_MASK_DISABLE);
643 brw_MOV(p, f0, g1);
644 brw_pop_insn_state(p);
645}
646
647
Eric Anholta3b8c5e2011-11-23 10:13:39 -0800648static uint32_t brw_file_from_reg(fs_reg *reg)
649{
650 switch (reg->file) {
651 case ARF:
652 return BRW_ARCHITECTURE_REGISTER_FILE;
653 case GRF:
654 return BRW_GENERAL_REGISTER_FILE;
655 case MRF:
656 return BRW_MESSAGE_REGISTER_FILE;
657 case IMM:
658 return BRW_IMMEDIATE_VALUE;
659 default:
660 assert(!"not reached");
661 return BRW_GENERAL_REGISTER_FILE;
662 }
663}
664
Eric Anholt11dd9e92011-05-24 16:34:27 -0700665static struct brw_reg
666brw_reg_from_fs_reg(fs_reg *reg)
667{
668 struct brw_reg brw_reg;
669
670 switch (reg->file) {
671 case GRF:
672 case ARF:
673 case MRF:
674 if (reg->smear == -1) {
Eric Anholta3b8c5e2011-11-23 10:13:39 -0800675 brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700676 } else {
Eric Anholta3b8c5e2011-11-23 10:13:39 -0800677 brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, reg->smear);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700678 }
679 brw_reg = retype(brw_reg, reg->type);
680 if (reg->sechalf)
681 brw_reg = sechalf(brw_reg);
682 break;
683 case IMM:
684 switch (reg->type) {
685 case BRW_REGISTER_TYPE_F:
686 brw_reg = brw_imm_f(reg->imm.f);
687 break;
688 case BRW_REGISTER_TYPE_D:
689 brw_reg = brw_imm_d(reg->imm.i);
690 break;
691 case BRW_REGISTER_TYPE_UD:
692 brw_reg = brw_imm_ud(reg->imm.u);
693 break;
694 default:
695 assert(!"not reached");
696 brw_reg = brw_null_reg();
697 break;
698 }
699 break;
700 case FIXED_HW_REG:
701 brw_reg = reg->fixed_hw_reg;
702 break;
703 case BAD_FILE:
704 /* Probably unused. */
705 brw_reg = brw_null_reg();
706 break;
707 case UNIFORM:
708 assert(!"not reached");
709 brw_reg = brw_null_reg();
710 break;
711 default:
712 assert(!"not reached");
713 brw_reg = brw_null_reg();
714 break;
715 }
716 if (reg->abs)
717 brw_reg = brw_abs(brw_reg);
718 if (reg->negate)
719 brw_reg = negate(brw_reg);
720
721 return brw_reg;
722}
723
724void
725fs_visitor::generate_code()
726{
Eric Anholtf2bd3e72012-02-03 11:50:42 +0100727 int last_native_insn_offset = p->next_insn_offset;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700728 const char *last_annotation_string = NULL;
729 ir_instruction *last_annotation_ir = NULL;
730
Eric Anholt11dd9e92011-05-24 16:34:27 -0700731 if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
732 printf("Native code for fragment shader %d (%d-wide dispatch):\n",
Eric Anholt0653c452011-05-27 09:50:34 -0700733 prog->Name, c->dispatch_width);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700734 }
735
Eric Anholt080b1252012-04-10 12:01:50 -0700736 fs_cfg *cfg = NULL;
737 if (unlikely(INTEL_DEBUG & DEBUG_WM))
738 cfg = new(mem_ctx) fs_cfg(this);
739
Eric Anholt44ffb4a2011-07-29 11:52:39 -0700740 foreach_list(node, &this->instructions) {
741 fs_inst *inst = (fs_inst *)node;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700742 struct brw_reg src[3], dst;
743
744 if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
Eric Anholt080b1252012-04-10 12:01:50 -0700745 foreach_list(node, &cfg->block_list) {
746 fs_bblock_link *link = (fs_bblock_link *)node;
747 fs_bblock *block = link->block;
748
749 if (block->start == inst) {
750 printf(" START B%d", block->block_num);
751 foreach_list(predecessor_node, &block->parents) {
752 fs_bblock_link *predecessor_link =
753 (fs_bblock_link *)predecessor_node;
754 fs_bblock *predecessor_block = predecessor_link->block;
755 printf(" <-B%d", predecessor_block->block_num);
756 }
757 printf("\n");
758 }
759 }
760
Eric Anholt11dd9e92011-05-24 16:34:27 -0700761 if (last_annotation_ir != inst->ir) {
762 last_annotation_ir = inst->ir;
763 if (last_annotation_ir) {
764 printf(" ");
765 last_annotation_ir->print();
766 printf("\n");
767 }
768 }
769 if (last_annotation_string != inst->annotation) {
770 last_annotation_string = inst->annotation;
771 if (last_annotation_string)
772 printf(" %s\n", last_annotation_string);
773 }
774 }
775
776 for (unsigned int i = 0; i < 3; i++) {
777 src[i] = brw_reg_from_fs_reg(&inst->src[i]);
Eric Anholt73b0a282011-10-03 15:12:10 -0700778
779 /* The accumulator result appears to get used for the
780 * conditional modifier generation. When negating a UD
781 * value, there is a 33rd bit generated for the sign in the
782 * accumulator value, so now you can't check, for example,
783 * equality with a 32-bit value. See piglit fs-op-neg-uvec4.
784 */
785 assert(!inst->conditional_mod ||
786 inst->src[i].type != BRW_REGISTER_TYPE_UD ||
787 !inst->src[i].negate);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700788 }
789 dst = brw_reg_from_fs_reg(&inst->dst);
790
791 brw_set_conditionalmod(p, inst->conditional_mod);
792 brw_set_predicate_control(p, inst->predicated);
793 brw_set_predicate_inverse(p, inst->predicate_inverse);
794 brw_set_saturate(p, inst->saturate);
795
796 if (inst->force_uncompressed || c->dispatch_width == 8) {
797 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
798 } else if (inst->force_sechalf) {
799 brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
800 } else {
801 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
802 }
803
804 switch (inst->opcode) {
805 case BRW_OPCODE_MOV:
806 brw_MOV(p, dst, src[0]);
807 break;
808 case BRW_OPCODE_ADD:
809 brw_ADD(p, dst, src[0], src[1]);
810 break;
811 case BRW_OPCODE_MUL:
812 brw_MUL(p, dst, src[0], src[1]);
813 break;
Eric Anholt3f78f712011-08-15 22:36:18 -0700814 case BRW_OPCODE_MACH:
815 brw_set_acc_write_control(p, 1);
816 brw_MACH(p, dst, src[0], src[1]);
817 brw_set_acc_write_control(p, 0);
818 break;
Eric Anholt11dd9e92011-05-24 16:34:27 -0700819
Eric Anholt7d55f372012-02-07 00:59:11 +0100820 case BRW_OPCODE_MAD:
821 brw_set_access_mode(p, BRW_ALIGN_16);
822 if (c->dispatch_width == 16) {
823 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
824 brw_MAD(p, dst, src[0], src[1], src[2]);
825 brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
826 brw_MAD(p, sechalf(dst), sechalf(src[0]), sechalf(src[1]), sechalf(src[2]));
827 brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
828 } else {
829 brw_MAD(p, dst, src[0], src[1], src[2]);
830 }
831 brw_set_access_mode(p, BRW_ALIGN_1);
832 break;
833
Eric Anholt11dd9e92011-05-24 16:34:27 -0700834 case BRW_OPCODE_FRC:
835 brw_FRC(p, dst, src[0]);
836 break;
837 case BRW_OPCODE_RNDD:
838 brw_RNDD(p, dst, src[0]);
839 break;
840 case BRW_OPCODE_RNDE:
841 brw_RNDE(p, dst, src[0]);
842 break;
843 case BRW_OPCODE_RNDZ:
844 brw_RNDZ(p, dst, src[0]);
845 break;
846
847 case BRW_OPCODE_AND:
848 brw_AND(p, dst, src[0], src[1]);
849 break;
850 case BRW_OPCODE_OR:
851 brw_OR(p, dst, src[0], src[1]);
852 break;
853 case BRW_OPCODE_XOR:
854 brw_XOR(p, dst, src[0], src[1]);
855 break;
856 case BRW_OPCODE_NOT:
857 brw_NOT(p, dst, src[0]);
858 break;
859 case BRW_OPCODE_ASR:
860 brw_ASR(p, dst, src[0], src[1]);
861 break;
862 case BRW_OPCODE_SHR:
863 brw_SHR(p, dst, src[0], src[1]);
864 break;
865 case BRW_OPCODE_SHL:
866 brw_SHL(p, dst, src[0], src[1]);
867 break;
868
869 case BRW_OPCODE_CMP:
870 brw_CMP(p, dst, inst->conditional_mod, src[0], src[1]);
871 break;
872 case BRW_OPCODE_SEL:
873 brw_SEL(p, dst, src[0], src[1]);
874 break;
875
876 case BRW_OPCODE_IF:
877 if (inst->src[0].file != BAD_FILE) {
878 /* The instruction has an embedded compare (only allowed on gen6) */
879 assert(intel->gen == 6);
880 gen6_IF(p, inst->conditional_mod, src[0], src[1]);
881 } else {
882 brw_IF(p, c->dispatch_width == 16 ? BRW_EXECUTE_16 : BRW_EXECUTE_8);
883 }
Eric Anholt11dd9e92011-05-24 16:34:27 -0700884 break;
885
886 case BRW_OPCODE_ELSE:
887 brw_ELSE(p);
888 break;
889 case BRW_OPCODE_ENDIF:
890 brw_ENDIF(p);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700891 break;
892
893 case BRW_OPCODE_DO:
Eric Anholtce6be332011-12-06 12:30:03 -0800894 brw_DO(p, BRW_EXECUTE_8);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700895 break;
896
897 case BRW_OPCODE_BREAK:
Eric Anholtf1d89632011-12-06 12:44:41 -0800898 brw_BREAK(p);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700899 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
900 break;
901 case BRW_OPCODE_CONTINUE:
902 /* FINISHME: We need to write the loop instruction support still. */
903 if (intel->gen >= 6)
Eric Anholt9f881472011-12-06 12:09:58 -0800904 gen6_CONT(p);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700905 else
Eric Anholtf1d89632011-12-06 12:44:41 -0800906 brw_CONT(p);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700907 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
908 break;
909
Eric Anholtce6be332011-12-06 12:30:03 -0800910 case BRW_OPCODE_WHILE:
Eric Anholtce6be332011-12-06 12:30:03 -0800911 brw_WHILE(p);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700912 break;
913
Eric Anholt65b5cbb2011-08-05 12:38:58 -0700914 case SHADER_OPCODE_RCP:
915 case SHADER_OPCODE_RSQ:
916 case SHADER_OPCODE_SQRT:
917 case SHADER_OPCODE_EXP2:
918 case SHADER_OPCODE_LOG2:
Eric Anholt65b5cbb2011-08-05 12:38:58 -0700919 case SHADER_OPCODE_SIN:
920 case SHADER_OPCODE_COS:
Kenneth Graunkea73c65c2011-10-18 12:24:47 -0700921 if (intel->gen >= 7) {
922 generate_math1_gen7(inst, dst, src[0]);
923 } else if (intel->gen == 6) {
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700924 generate_math1_gen6(inst, dst, src[0]);
925 } else {
926 generate_math_gen4(inst, dst, src[0]);
927 }
928 break;
Kenneth Graunkeff8f2722011-09-28 17:37:54 -0700929 case SHADER_OPCODE_INT_QUOTIENT:
930 case SHADER_OPCODE_INT_REMAINDER:
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700931 case SHADER_OPCODE_POW:
Kenneth Graunkedceb2022011-11-07 12:07:44 -0800932 if (intel->gen >= 7) {
Kenneth Graunkea73c65c2011-10-18 12:24:47 -0700933 generate_math2_gen7(inst, dst, src[0], src[1]);
934 } else if (intel->gen == 6) {
Kenneth Graunke74e927b2011-08-18 11:55:42 -0700935 generate_math2_gen6(inst, dst, src[0], src[1]);
936 } else {
937 generate_math_gen4(inst, dst, src[0]);
938 }
Eric Anholt11dd9e92011-05-24 16:34:27 -0700939 break;
940 case FS_OPCODE_PIXEL_X:
941 generate_pixel_xy(dst, true);
942 break;
943 case FS_OPCODE_PIXEL_Y:
944 generate_pixel_xy(dst, false);
945 break;
946 case FS_OPCODE_CINTERP:
947 brw_MOV(p, dst, src[0]);
948 break;
949 case FS_OPCODE_LINTERP:
950 generate_linterp(inst, dst, src);
951 break;
Kenneth Graunkefebad172011-10-26 12:58:37 -0700952 case SHADER_OPCODE_TEX:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700953 case FS_OPCODE_TXB:
Kenneth Graunkefebad172011-10-26 12:58:37 -0700954 case SHADER_OPCODE_TXD:
955 case SHADER_OPCODE_TXF:
956 case SHADER_OPCODE_TXL:
957 case SHADER_OPCODE_TXS:
Eric Anholt11dd9e92011-05-24 16:34:27 -0700958 generate_tex(inst, dst, src[0]);
959 break;
960 case FS_OPCODE_DISCARD:
961 generate_discard(inst);
962 break;
963 case FS_OPCODE_DDX:
964 generate_ddx(inst, dst, src[0]);
965 break;
966 case FS_OPCODE_DDY:
Paul Berryd08fdac2012-06-20 13:40:45 -0700967 /* Make sure fp->UsesDFdy flag got set (otherwise there's no
968 * guarantee that c->key.render_to_fbo is set).
969 */
970 assert(fp->UsesDFdy);
Paul Berry82d25962012-06-20 13:40:45 -0700971 generate_ddy(inst, dst, src[0], c->key.render_to_fbo);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700972 break;
973
974 case FS_OPCODE_SPILL:
975 generate_spill(inst, src[0]);
976 break;
977
978 case FS_OPCODE_UNSPILL:
979 generate_unspill(inst, dst);
980 break;
981
982 case FS_OPCODE_PULL_CONSTANT_LOAD:
Eric Anholt454dc832012-06-20 15:41:14 -0700983 generate_pull_constant_load(inst, dst, src[0], src[1]);
Eric Anholt11dd9e92011-05-24 16:34:27 -0700984 break;
985
986 case FS_OPCODE_FB_WRITE:
987 generate_fb_write(inst);
988 break;
Paul Berry3f929ef2012-06-18 14:50:04 -0700989
990 case FS_OPCODE_MOV_DISPATCH_TO_FLAGS:
991 generate_mov_dispatch_to_flags();
992 break;
993
Eric Anholt11dd9e92011-05-24 16:34:27 -0700994 default:
995 if (inst->opcode < (int)ARRAY_SIZE(brw_opcodes)) {
996 _mesa_problem(ctx, "Unsupported opcode `%s' in FS",
997 brw_opcodes[inst->opcode].name);
998 } else {
999 _mesa_problem(ctx, "Unsupported opcode %d in FS", inst->opcode);
1000 }
1001 fail("unsupported opcode in FS\n");
1002 }
1003
1004 if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
Eric Anholtf2bd3e72012-02-03 11:50:42 +01001005 brw_dump_compile(p, stdout,
1006 last_native_insn_offset, p->next_insn_offset);
Eric Anholt080b1252012-04-10 12:01:50 -07001007
1008 foreach_list(node, &cfg->block_list) {
1009 fs_bblock_link *link = (fs_bblock_link *)node;
1010 fs_bblock *block = link->block;
1011
1012 if (block->end == inst) {
1013 printf(" END B%d", block->block_num);
1014 foreach_list(successor_node, &block->children) {
1015 fs_bblock_link *successor_link =
1016 (fs_bblock_link *)successor_node;
1017 fs_bblock *successor_block = successor_link->block;
1018 printf(" ->B%d", successor_block->block_num);
1019 }
1020 printf("\n");
1021 }
1022 }
Eric Anholt11dd9e92011-05-24 16:34:27 -07001023 }
1024
Eric Anholtf2bd3e72012-02-03 11:50:42 +01001025 last_native_insn_offset = p->next_insn_offset;
Eric Anholt11dd9e92011-05-24 16:34:27 -07001026 }
1027
1028 if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
1029 printf("\n");
1030 }
1031
Eric Anholt11dd9e92011-05-24 16:34:27 -07001032 brw_set_uip_jip(p);
1033
1034 /* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
1035 * emit issues, it doesn't get the jump distances into the output,
1036 * which is often something we want to debug. So this is here in
1037 * case you're doing that.
1038 */
1039 if (0) {
Eric Anholtf2bd3e72012-02-03 11:50:42 +01001040 brw_dump_compile(p, stdout, 0, p->next_insn_offset);
Eric Anholt11dd9e92011-05-24 16:34:27 -07001041 }
1042}