anv/meta_clear: Don't trash state if no clears are needed
[mesa.git] / src / mesa / drivers / dri / i965 / brw_fs_visitor.cpp
1 /*
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_visitor.cpp
25 *
26 * This file supports generating the FS LIR from the GLSL IR. The LIR
27 * makes it easier to do backend-specific optimizations than doing so
28 * in the GLSL IR or in the native code.
29 */
30 #include <sys/types.h>
31
32 #include "main/macros.h"
33 #include "main/shaderobj.h"
34 #include "program/prog_parameter.h"
35 #include "program/prog_print.h"
36 #include "program/prog_optimize.h"
37 #include "util/register_allocate.h"
38 #include "program/hash_table.h"
39 #include "brw_context.h"
40 #include "brw_eu.h"
41 #include "brw_wm.h"
42 #include "brw_cs.h"
43 #include "brw_vec4.h"
44 #include "brw_vec4_gs_visitor.h"
45 #include "brw_fs.h"
46 #include "main/uniforms.h"
47 #include "glsl/nir/glsl_types.h"
48 #include "glsl/ir_optimization.h"
49 #include "program/sampler.h"
50
51 using namespace brw;
52
53 fs_reg *
54 fs_visitor::emit_vs_system_value(int location)
55 {
56 fs_reg *reg = new(this->mem_ctx)
57 fs_reg(ATTR, 4 * _mesa_bitcount_64(nir->info.inputs_read),
58 BRW_REGISTER_TYPE_D);
59 brw_vs_prog_data *vs_prog_data = (brw_vs_prog_data *) prog_data;
60
61 switch (location) {
62 case SYSTEM_VALUE_BASE_VERTEX:
63 reg->reg_offset = 0;
64 vs_prog_data->uses_vertexid = true;
65 break;
66 case SYSTEM_VALUE_VERTEX_ID:
67 case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
68 reg->reg_offset = 2;
69 vs_prog_data->uses_vertexid = true;
70 break;
71 case SYSTEM_VALUE_INSTANCE_ID:
72 reg->reg_offset = 3;
73 vs_prog_data->uses_instanceid = true;
74 break;
75 default:
76 unreachable("not reached");
77 }
78
79 return reg;
80 }
81
82 fs_reg
83 fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
84 bool is_rect, uint32_t sampler)
85 {
86 bool needs_gl_clamp = true;
87 fs_reg scale_x, scale_y;
88
89 /* The 965 requires the EU to do the normalization of GL rectangle
90 * texture coordinates. We use the program parameter state
91 * tracking to get the scaling factor.
92 */
93 if (is_rect &&
94 (devinfo->gen < 6 ||
95 (devinfo->gen >= 6 && (key_tex->gl_clamp_mask[0] & (1 << sampler) ||
96 key_tex->gl_clamp_mask[1] & (1 << sampler))))) {
97 struct gl_program_parameter_list *params = prog->Parameters;
98
99
100 /* FINISHME: We're failing to recompile our programs when the sampler is
101 * updated. This only matters for the texture rectangle scale
102 * parameters (pre-gen6, or gen6+ with GL_CLAMP).
103 */
104 int tokens[STATE_LENGTH] = {
105 STATE_INTERNAL,
106 STATE_TEXRECT_SCALE,
107 prog->SamplerUnits[sampler],
108 0,
109 0
110 };
111
112 no16("rectangle scale uniform setup not supported on SIMD16\n");
113 if (dispatch_width == 16) {
114 return coordinate;
115 }
116
117 GLuint index = _mesa_add_state_reference(params,
118 (gl_state_index *)tokens);
119 /* Try to find existing copies of the texrect scale uniforms. */
120 for (unsigned i = 0; i < uniforms; i++) {
121 if (stage_prog_data->param[i] ==
122 &prog->Parameters->ParameterValues[index][0]) {
123 scale_x = fs_reg(UNIFORM, i);
124 scale_y = fs_reg(UNIFORM, i + 1);
125 break;
126 }
127 }
128
129 /* If we didn't already set them up, do so now. */
130 if (scale_x.file == BAD_FILE) {
131 scale_x = fs_reg(UNIFORM, uniforms);
132 scale_y = fs_reg(UNIFORM, uniforms + 1);
133
134 stage_prog_data->param[uniforms++] =
135 &prog->Parameters->ParameterValues[index][0];
136 stage_prog_data->param[uniforms++] =
137 &prog->Parameters->ParameterValues[index][1];
138 }
139 }
140
141 /* The 965 requires the EU to do the normalization of GL rectangle
142 * texture coordinates. We use the program parameter state
143 * tracking to get the scaling factor.
144 */
145 if (devinfo->gen < 6 && is_rect) {
146 fs_reg dst = fs_reg(VGRF, alloc.allocate(coord_components));
147 fs_reg src = coordinate;
148 coordinate = dst;
149
150 bld.MUL(dst, src, scale_x);
151 dst = offset(dst, bld, 1);
152 src = offset(src, bld, 1);
153 bld.MUL(dst, src, scale_y);
154 } else if (is_rect) {
155 /* On gen6+, the sampler handles the rectangle coordinates
156 * natively, without needing rescaling. But that means we have
157 * to do GL_CLAMP clamping at the [0, width], [0, height] scale,
158 * not [0, 1] like the default case below.
159 */
160 needs_gl_clamp = false;
161
162 for (int i = 0; i < 2; i++) {
163 if (key_tex->gl_clamp_mask[i] & (1 << sampler)) {
164 fs_reg chan = coordinate;
165 chan = offset(chan, bld, i);
166
167 set_condmod(BRW_CONDITIONAL_GE,
168 bld.emit(BRW_OPCODE_SEL, chan, chan, fs_reg(0.0f)));
169
170 /* Our parameter comes in as 1.0/width or 1.0/height,
171 * because that's what people normally want for doing
172 * texture rectangle handling. We need width or height
173 * for clamping, but we don't care enough to make a new
174 * parameter type, so just invert back.
175 */
176 fs_reg limit = vgrf(glsl_type::float_type);
177 bld.MOV(limit, i == 0 ? scale_x : scale_y);
178 bld.emit(SHADER_OPCODE_RCP, limit, limit);
179
180 set_condmod(BRW_CONDITIONAL_L,
181 bld.emit(BRW_OPCODE_SEL, chan, chan, limit));
182 }
183 }
184 }
185
186 if (coord_components > 0 && needs_gl_clamp) {
187 for (int i = 0; i < MIN2(coord_components, 3); i++) {
188 if (key_tex->gl_clamp_mask[i] & (1 << sampler)) {
189 fs_reg chan = coordinate;
190 chan = offset(chan, bld, i);
191 set_saturate(true, bld.MOV(chan, chan));
192 }
193 }
194 }
195 return coordinate;
196 }
197
198 /* Sample from the MCS surface attached to this multisample texture. */
199 fs_reg
200 fs_visitor::emit_mcs_fetch(const fs_reg &coordinate, unsigned components,
201 const fs_reg &texture)
202 {
203 const fs_reg dest = vgrf(glsl_type::uvec4_type);
204 const fs_reg srcs[] = {
205 coordinate, fs_reg(), fs_reg(), fs_reg(), fs_reg(), fs_reg(),
206 texture, texture, fs_reg(), fs_reg(components), fs_reg(0)
207 };
208 fs_inst *inst = bld.emit(SHADER_OPCODE_TXF_MCS_LOGICAL, dest, srcs,
209 ARRAY_SIZE(srcs));
210
211 /* We only care about one or two regs of response, but the sampler always
212 * writes 4/8.
213 */
214 inst->regs_written = 4 * dispatch_width / 8;
215
216 return dest;
217 }
218
219 void
220 fs_visitor::emit_texture(ir_texture_opcode op,
221 const glsl_type *dest_type,
222 fs_reg coordinate, int coord_components,
223 fs_reg shadow_c,
224 fs_reg lod, fs_reg lod2, int grad_components,
225 fs_reg sample_index,
226 fs_reg offset_value,
227 fs_reg mcs,
228 int gather_component,
229 bool is_cube_array,
230 bool is_rect,
231 uint32_t surface,
232 fs_reg surface_reg,
233 uint32_t sampler,
234 fs_reg sampler_reg)
235 {
236 fs_inst *inst = NULL;
237
238 if (op == ir_tg4) {
239 /* When tg4 is used with the degenerate ZERO/ONE swizzles, don't bother
240 * emitting anything other than setting up the constant result.
241 */
242 int swiz = GET_SWZ(key_tex->swizzles[sampler], gather_component);
243 if (swiz == SWIZZLE_ZERO || swiz == SWIZZLE_ONE) {
244
245 fs_reg res = vgrf(glsl_type::vec4_type);
246 this->result = res;
247
248 for (int i=0; i<4; i++) {
249 bld.MOV(res, fs_reg(swiz == SWIZZLE_ZERO ? 0.0f : 1.0f));
250 res = offset(res, bld, 1);
251 }
252 return;
253 }
254 }
255
256 if (op == ir_query_levels) {
257 /* textureQueryLevels() is implemented in terms of TXS so we need to
258 * pass a valid LOD argument.
259 */
260 assert(lod.file == BAD_FILE);
261 lod = fs_reg(0u);
262 }
263
264 if (coordinate.file != BAD_FILE) {
265 /* FINISHME: Texture coordinate rescaling doesn't work with non-constant
266 * samplers. This should only be a problem with GL_CLAMP on Gen7.
267 */
268 coordinate = rescale_texcoord(coordinate, coord_components, is_rect,
269 sampler);
270 }
271
272 /* Writemasking doesn't eliminate channels on SIMD8 texture
273 * samples, so don't worry about them.
274 */
275 fs_reg dst = vgrf(glsl_type::get_instance(dest_type->base_type, 4, 1));
276 const fs_reg srcs[] = {
277 coordinate, shadow_c, lod, lod2,
278 sample_index, mcs, surface_reg, sampler_reg, offset_value,
279 fs_reg(coord_components), fs_reg(grad_components)
280 };
281 enum opcode opcode;
282
283 switch (op) {
284 case ir_tex:
285 opcode = SHADER_OPCODE_TEX_LOGICAL;
286 break;
287 case ir_txb:
288 opcode = FS_OPCODE_TXB_LOGICAL;
289 break;
290 case ir_txl:
291 opcode = SHADER_OPCODE_TXL_LOGICAL;
292 break;
293 case ir_txd:
294 opcode = SHADER_OPCODE_TXD_LOGICAL;
295 break;
296 case ir_txf:
297 opcode = SHADER_OPCODE_TXF_LOGICAL;
298 break;
299 case ir_txf_ms:
300 if ((key_tex->msaa_16 & (1 << sampler)))
301 opcode = SHADER_OPCODE_TXF_CMS_W_LOGICAL;
302 else
303 opcode = SHADER_OPCODE_TXF_CMS_LOGICAL;
304 break;
305 case ir_txs:
306 case ir_query_levels:
307 opcode = SHADER_OPCODE_TXS_LOGICAL;
308 break;
309 case ir_lod:
310 opcode = SHADER_OPCODE_LOD_LOGICAL;
311 break;
312 case ir_tg4:
313 opcode = (offset_value.file != BAD_FILE && offset_value.file != IMM ?
314 SHADER_OPCODE_TG4_OFFSET_LOGICAL : SHADER_OPCODE_TG4_LOGICAL);
315 break;
316 default:
317 unreachable("Invalid texture opcode.");
318 }
319
320 inst = bld.emit(opcode, dst, srcs, ARRAY_SIZE(srcs));
321 inst->regs_written = 4 * dispatch_width / 8;
322
323 if (shadow_c.file != BAD_FILE)
324 inst->shadow_compare = true;
325
326 if (offset_value.file == IMM)
327 inst->offset = offset_value.ud;
328
329 if (op == ir_tg4) {
330 inst->offset |=
331 gather_channel(gather_component, surface, sampler) << 16; /* M0.2:16-17 */
332
333 if (devinfo->gen == 6)
334 emit_gen6_gather_wa(key_tex->gen6_gather_wa[surface], dst);
335 }
336
337 /* fixup #layers for cube map arrays */
338 if (op == ir_txs && is_cube_array) {
339 fs_reg depth = offset(dst, bld, 2);
340 fs_reg fixed_depth = vgrf(glsl_type::int_type);
341 bld.emit(SHADER_OPCODE_INT_QUOTIENT, fixed_depth, depth, fs_reg(6));
342
343 fs_reg *fixed_payload = ralloc_array(mem_ctx, fs_reg, inst->regs_written);
344 int components = inst->regs_written / (inst->exec_size / 8);
345 for (int i = 0; i < components; i++) {
346 if (i == 2) {
347 fixed_payload[i] = fixed_depth;
348 } else {
349 fixed_payload[i] = offset(dst, bld, i);
350 }
351 }
352 bld.LOAD_PAYLOAD(dst, fixed_payload, components, 0);
353 }
354
355 swizzle_result(op, dest_type->vector_elements, dst, sampler);
356 }
357
358 /**
359 * Apply workarounds for Gen6 gather with UINT/SINT
360 */
361 void
362 fs_visitor::emit_gen6_gather_wa(uint8_t wa, fs_reg dst)
363 {
364 if (!wa)
365 return;
366
367 int width = (wa & WA_8BIT) ? 8 : 16;
368
369 for (int i = 0; i < 4; i++) {
370 fs_reg dst_f = retype(dst, BRW_REGISTER_TYPE_F);
371 /* Convert from UNORM to UINT */
372 bld.MUL(dst_f, dst_f, fs_reg((float)((1 << width) - 1)));
373 bld.MOV(dst, dst_f);
374
375 if (wa & WA_SIGN) {
376 /* Reinterpret the UINT value as a signed INT value by
377 * shifting the sign bit into place, then shifting back
378 * preserving sign.
379 */
380 bld.SHL(dst, dst, fs_reg(32 - width));
381 bld.ASR(dst, dst, fs_reg(32 - width));
382 }
383
384 dst = offset(dst, bld, 1);
385 }
386 }
387
388 /**
389 * Set up the gather channel based on the swizzle, for gather4.
390 */
391 uint32_t
392 fs_visitor::gather_channel(int orig_chan, uint32_t surface, uint32_t sampler)
393 {
394 int swiz = GET_SWZ(key_tex->swizzles[sampler], orig_chan);
395 switch (swiz) {
396 case SWIZZLE_X: return 0;
397 case SWIZZLE_Y:
398 /* gather4 sampler is broken for green channel on RG32F --
399 * we must ask for blue instead.
400 */
401 if (key_tex->gather_channel_quirk_mask & (1 << surface))
402 return 2;
403 return 1;
404 case SWIZZLE_Z: return 2;
405 case SWIZZLE_W: return 3;
406 default:
407 unreachable("Not reached"); /* zero, one swizzles handled already */
408 }
409 }
410
411 /**
412 * Swizzle the result of a texture result. This is necessary for
413 * EXT_texture_swizzle as well as DEPTH_TEXTURE_MODE for shadow comparisons.
414 */
415 void
416 fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components,
417 fs_reg orig_val, uint32_t sampler)
418 {
419 if (op == ir_query_levels) {
420 /* # levels is in .w */
421 this->result = offset(orig_val, bld, 3);
422 return;
423 }
424
425 this->result = orig_val;
426
427 /* txs,lod don't actually sample the texture, so swizzling the result
428 * makes no sense.
429 */
430 if (op == ir_txs || op == ir_lod || op == ir_tg4)
431 return;
432
433 if (dest_components == 1) {
434 /* Ignore DEPTH_TEXTURE_MODE swizzling. */
435 } else if (key_tex->swizzles[sampler] != SWIZZLE_NOOP) {
436 fs_reg swizzled_result = vgrf(glsl_type::vec4_type);
437 swizzled_result.type = orig_val.type;
438
439 for (int i = 0; i < 4; i++) {
440 int swiz = GET_SWZ(key_tex->swizzles[sampler], i);
441 fs_reg l = swizzled_result;
442 l = offset(l, bld, i);
443
444 if (swiz == SWIZZLE_ZERO) {
445 bld.MOV(l, fs_reg(0.0f));
446 } else if (swiz == SWIZZLE_ONE) {
447 bld.MOV(l, fs_reg(1.0f));
448 } else {
449 bld.MOV(l, offset(orig_val, bld,
450 GET_SWZ(key_tex->swizzles[sampler], i)));
451 }
452 }
453 this->result = swizzled_result;
454 }
455 }
456
457 /** Emits a dummy fragment shader consisting of magenta for bringup purposes. */
458 void
459 fs_visitor::emit_dummy_fs()
460 {
461 int reg_width = dispatch_width / 8;
462
463 /* Everyone's favorite color. */
464 const float color[4] = { 1.0, 0.0, 1.0, 0.0 };
465 for (int i = 0; i < 4; i++) {
466 bld.MOV(fs_reg(MRF, 2 + i * reg_width, BRW_REGISTER_TYPE_F),
467 fs_reg(color[i]));
468 }
469
470 fs_inst *write;
471 write = bld.emit(FS_OPCODE_FB_WRITE);
472 write->eot = true;
473 if (devinfo->gen >= 6) {
474 write->base_mrf = 2;
475 write->mlen = 4 * reg_width;
476 } else {
477 write->header_size = 2;
478 write->base_mrf = 0;
479 write->mlen = 2 + 4 * reg_width;
480 }
481
482 /* Tell the SF we don't have any inputs. Gen4-5 require at least one
483 * varying to avoid GPU hangs, so set that.
484 */
485 brw_wm_prog_data *wm_prog_data = (brw_wm_prog_data *) this->prog_data;
486 wm_prog_data->num_varying_inputs = devinfo->gen < 6 ? 1 : 0;
487 memset(wm_prog_data->urb_setup, -1,
488 sizeof(wm_prog_data->urb_setup[0]) * VARYING_SLOT_MAX);
489
490 /* We don't have any uniforms. */
491 stage_prog_data->nr_params = 0;
492 stage_prog_data->nr_pull_params = 0;
493 stage_prog_data->curb_read_length = 0;
494 stage_prog_data->dispatch_grf_start_reg = 2;
495 wm_prog_data->dispatch_grf_start_reg_16 = 2;
496 grf_used = 1; /* Gen4-5 don't allow zero GRF blocks */
497
498 calculate_cfg();
499 }
500
501 /* The register location here is relative to the start of the URB
502 * data. It will get adjusted to be a real location before
503 * generate_code() time.
504 */
505 struct brw_reg
506 fs_visitor::interp_reg(int location, int channel)
507 {
508 assert(stage == MESA_SHADER_FRAGMENT);
509 brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
510 int regnr = prog_data->urb_setup[location] * 2 + channel / 2;
511 int stride = (channel & 1) * 4;
512
513 assert(prog_data->urb_setup[location] != -1);
514
515 return brw_vec1_grf(regnr, stride);
516 }
517
518 /** Emits the interpolation for the varying inputs. */
519 void
520 fs_visitor::emit_interpolation_setup_gen4()
521 {
522 struct brw_reg g1_uw = retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW);
523
524 fs_builder abld = bld.annotate("compute pixel centers");
525 this->pixel_x = vgrf(glsl_type::uint_type);
526 this->pixel_y = vgrf(glsl_type::uint_type);
527 this->pixel_x.type = BRW_REGISTER_TYPE_UW;
528 this->pixel_y.type = BRW_REGISTER_TYPE_UW;
529 abld.ADD(this->pixel_x,
530 fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)),
531 fs_reg(brw_imm_v(0x10101010)));
532 abld.ADD(this->pixel_y,
533 fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)),
534 fs_reg(brw_imm_v(0x11001100)));
535
536 abld = bld.annotate("compute pixel deltas from v0");
537
538 this->delta_xy[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC] =
539 vgrf(glsl_type::vec2_type);
540 const fs_reg &delta_xy = this->delta_xy[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC];
541 const fs_reg xstart(negate(brw_vec1_grf(1, 0)));
542 const fs_reg ystart(negate(brw_vec1_grf(1, 1)));
543
544 if (devinfo->has_pln && dispatch_width == 16) {
545 for (unsigned i = 0; i < 2; i++) {
546 abld.half(i).ADD(half(offset(delta_xy, abld, i), 0),
547 half(this->pixel_x, i), xstart);
548 abld.half(i).ADD(half(offset(delta_xy, abld, i), 1),
549 half(this->pixel_y, i), ystart);
550 }
551 } else {
552 abld.ADD(offset(delta_xy, abld, 0), this->pixel_x, xstart);
553 abld.ADD(offset(delta_xy, abld, 1), this->pixel_y, ystart);
554 }
555
556 abld = bld.annotate("compute pos.w and 1/pos.w");
557 /* Compute wpos.w. It's always in our setup, since it's needed to
558 * interpolate the other attributes.
559 */
560 this->wpos_w = vgrf(glsl_type::float_type);
561 abld.emit(FS_OPCODE_LINTERP, wpos_w, delta_xy,
562 interp_reg(VARYING_SLOT_POS, 3));
563 /* Compute the pixel 1/W value from wpos.w. */
564 this->pixel_w = vgrf(glsl_type::float_type);
565 abld.emit(SHADER_OPCODE_RCP, this->pixel_w, wpos_w);
566 }
567
568 /** Emits the interpolation for the varying inputs. */
569 void
570 fs_visitor::emit_interpolation_setup_gen6()
571 {
572 struct brw_reg g1_uw = retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW);
573
574 fs_builder abld = bld.annotate("compute pixel centers");
575 if (devinfo->gen >= 8 || dispatch_width == 8) {
576 /* The "Register Region Restrictions" page says for BDW (and newer,
577 * presumably):
578 *
579 * "When destination spans two registers, the source may be one or
580 * two registers. The destination elements must be evenly split
581 * between the two registers."
582 *
583 * Thus we can do a single add(16) in SIMD8 or an add(32) in SIMD16 to
584 * compute our pixel centers.
585 */
586 fs_reg int_pixel_xy(VGRF, alloc.allocate(dispatch_width / 8),
587 BRW_REGISTER_TYPE_UW);
588
589 const fs_builder dbld = abld.exec_all().group(dispatch_width * 2, 0);
590 dbld.ADD(int_pixel_xy,
591 fs_reg(stride(suboffset(g1_uw, 4), 1, 4, 0)),
592 fs_reg(brw_imm_v(0x11001010)));
593
594 this->pixel_x = vgrf(glsl_type::float_type);
595 this->pixel_y = vgrf(glsl_type::float_type);
596 abld.emit(FS_OPCODE_PIXEL_X, this->pixel_x, int_pixel_xy);
597 abld.emit(FS_OPCODE_PIXEL_Y, this->pixel_y, int_pixel_xy);
598 } else {
599 /* The "Register Region Restrictions" page says for SNB, IVB, HSW:
600 *
601 * "When destination spans two registers, the source MUST span two
602 * registers."
603 *
604 * Since the GRF source of the ADD will only read a single register, we
605 * must do two separate ADDs in SIMD16.
606 */
607 fs_reg int_pixel_x = vgrf(glsl_type::uint_type);
608 fs_reg int_pixel_y = vgrf(glsl_type::uint_type);
609 int_pixel_x.type = BRW_REGISTER_TYPE_UW;
610 int_pixel_y.type = BRW_REGISTER_TYPE_UW;
611 abld.ADD(int_pixel_x,
612 fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)),
613 fs_reg(brw_imm_v(0x10101010)));
614 abld.ADD(int_pixel_y,
615 fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)),
616 fs_reg(brw_imm_v(0x11001100)));
617
618 /* As of gen6, we can no longer mix float and int sources. We have
619 * to turn the integer pixel centers into floats for their actual
620 * use.
621 */
622 this->pixel_x = vgrf(glsl_type::float_type);
623 this->pixel_y = vgrf(glsl_type::float_type);
624 abld.MOV(this->pixel_x, int_pixel_x);
625 abld.MOV(this->pixel_y, int_pixel_y);
626 }
627
628 abld = bld.annotate("compute pos.w");
629 this->pixel_w = fs_reg(brw_vec8_grf(payload.source_w_reg, 0));
630 this->wpos_w = vgrf(glsl_type::float_type);
631 abld.emit(SHADER_OPCODE_RCP, this->wpos_w, this->pixel_w);
632
633 for (int i = 0; i < BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT; ++i) {
634 uint8_t reg = payload.barycentric_coord_reg[i];
635 this->delta_xy[i] = fs_reg(brw_vec16_grf(reg, 0));
636 }
637 }
638
639 static enum brw_conditional_mod
640 cond_for_alpha_func(GLenum func)
641 {
642 switch(func) {
643 case GL_GREATER:
644 return BRW_CONDITIONAL_G;
645 case GL_GEQUAL:
646 return BRW_CONDITIONAL_GE;
647 case GL_LESS:
648 return BRW_CONDITIONAL_L;
649 case GL_LEQUAL:
650 return BRW_CONDITIONAL_LE;
651 case GL_EQUAL:
652 return BRW_CONDITIONAL_EQ;
653 case GL_NOTEQUAL:
654 return BRW_CONDITIONAL_NEQ;
655 default:
656 unreachable("Not reached");
657 }
658 }
659
660 /**
661 * Alpha test support for when we compile it into the shader instead
662 * of using the normal fixed-function alpha test.
663 */
664 void
665 fs_visitor::emit_alpha_test()
666 {
667 assert(stage == MESA_SHADER_FRAGMENT);
668 brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
669 const fs_builder abld = bld.annotate("Alpha test");
670
671 fs_inst *cmp;
672 if (key->alpha_test_func == GL_ALWAYS)
673 return;
674
675 if (key->alpha_test_func == GL_NEVER) {
676 /* f0.1 = 0 */
677 fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
678 BRW_REGISTER_TYPE_UW));
679 cmp = abld.CMP(bld.null_reg_f(), some_reg, some_reg,
680 BRW_CONDITIONAL_NEQ);
681 } else {
682 /* RT0 alpha */
683 fs_reg color = offset(outputs[0], bld, 3);
684
685 /* f0.1 &= func(color, ref) */
686 cmp = abld.CMP(bld.null_reg_f(), color, fs_reg(key->alpha_test_ref),
687 cond_for_alpha_func(key->alpha_test_func));
688 }
689 cmp->predicate = BRW_PREDICATE_NORMAL;
690 cmp->flag_subreg = 1;
691 }
692
693 fs_inst *
694 fs_visitor::emit_single_fb_write(const fs_builder &bld,
695 fs_reg color0, fs_reg color1,
696 fs_reg src0_alpha, unsigned components)
697 {
698 assert(stage == MESA_SHADER_FRAGMENT);
699 brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
700
701 /* Hand over gl_FragDepth or the payload depth. */
702 const fs_reg dst_depth = (payload.dest_depth_reg ?
703 fs_reg(brw_vec8_grf(payload.dest_depth_reg, 0)) :
704 fs_reg());
705 fs_reg src_depth, src_stencil;
706
707 if (source_depth_to_render_target) {
708 if (nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
709 src_depth = frag_depth;
710 else
711 src_depth = fs_reg(brw_vec8_grf(payload.source_depth_reg, 0));
712 }
713
714 if (nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL))
715 src_stencil = frag_stencil;
716
717 const fs_reg sources[] = {
718 color0, color1, src0_alpha, src_depth, dst_depth, src_stencil,
719 sample_mask, fs_reg(components)
720 };
721 assert(ARRAY_SIZE(sources) - 1 == FB_WRITE_LOGICAL_SRC_COMPONENTS);
722 fs_inst *write = bld.emit(FS_OPCODE_FB_WRITE_LOGICAL, fs_reg(),
723 sources, ARRAY_SIZE(sources));
724
725 if (prog_data->uses_kill) {
726 write->predicate = BRW_PREDICATE_NORMAL;
727 write->flag_subreg = 1;
728 }
729
730 return write;
731 }
732
733 void
734 fs_visitor::emit_fb_writes()
735 {
736 assert(stage == MESA_SHADER_FRAGMENT);
737 brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
738 brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
739
740 fs_inst *inst = NULL;
741
742 if (source_depth_to_render_target && devinfo->gen == 6) {
743 /* For outputting oDepth on gen6, SIMD8 writes have to be used. This
744 * would require SIMD8 moves of each half to message regs, e.g. by using
745 * the SIMD lowering pass. Unfortunately this is more difficult than it
746 * sounds because the SIMD8 single-source message lacks channel selects
747 * for the second and third subspans.
748 */
749 no16("Missing support for simd16 depth writes on gen6\n");
750 }
751
752 if (nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
753 /* From the 'Render Target Write message' section of the docs:
754 * "Output Stencil is not supported with SIMD16 Render Target Write
755 * Messages."
756 *
757 * FINISHME: split 16 into 2 8s
758 */
759 no16("FINISHME: support 2 simd8 writes for gl_FragStencilRefARB\n");
760 }
761
762 if (do_dual_src) {
763 const fs_builder abld = bld.annotate("FB dual-source write");
764
765 inst = emit_single_fb_write(abld, this->outputs[0],
766 this->dual_src_output, reg_undef, 4);
767 inst->target = 0;
768
769 prog_data->dual_src_blend = true;
770 } else {
771 for (int target = 0; target < key->nr_color_regions; target++) {
772 /* Skip over outputs that weren't written. */
773 if (this->outputs[target].file == BAD_FILE)
774 continue;
775
776 const fs_builder abld = bld.annotate(
777 ralloc_asprintf(this->mem_ctx, "FB write target %d", target));
778
779 fs_reg src0_alpha;
780 if (devinfo->gen >= 6 && key->replicate_alpha && target != 0)
781 src0_alpha = offset(outputs[0], bld, 3);
782
783 inst = emit_single_fb_write(abld, this->outputs[target], reg_undef,
784 src0_alpha,
785 this->output_components[target]);
786 inst->target = target;
787 }
788 }
789
790 if (inst == NULL) {
791 /* Even if there's no color buffers enabled, we still need to send
792 * alpha out the pipeline to our null renderbuffer to support
793 * alpha-testing, alpha-to-coverage, and so on.
794 */
795 /* FINISHME: Factor out this frequently recurring pattern into a
796 * helper function.
797 */
798 const fs_reg srcs[] = { reg_undef, reg_undef,
799 reg_undef, offset(this->outputs[0], bld, 3) };
800 const fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_UD, 4);
801 bld.LOAD_PAYLOAD(tmp, srcs, 4, 0);
802
803 inst = emit_single_fb_write(bld, tmp, reg_undef, reg_undef, 4);
804 inst->target = 0;
805 }
806
807 inst->eot = true;
808 }
809
810 void
811 fs_visitor::setup_uniform_clipplane_values(gl_clip_plane *clip_planes)
812 {
813 const struct brw_vs_prog_key *key =
814 (const struct brw_vs_prog_key *) this->key;
815
816 for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
817 this->userplane[i] = fs_reg(UNIFORM, uniforms);
818 for (int j = 0; j < 4; ++j) {
819 stage_prog_data->param[uniforms + j] =
820 (gl_constant_value *) &clip_planes[i][j];
821 }
822 uniforms += 4;
823 }
824 }
825
826 /**
827 * Lower legacy fixed-function and gl_ClipVertex clipping to clip distances.
828 *
829 * This does nothing if the shader uses gl_ClipDistance or user clipping is
830 * disabled altogether.
831 */
832 void fs_visitor::compute_clip_distance(gl_clip_plane *clip_planes)
833 {
834 struct brw_vue_prog_data *vue_prog_data =
835 (struct brw_vue_prog_data *) prog_data;
836 const struct brw_vs_prog_key *key =
837 (const struct brw_vs_prog_key *) this->key;
838
839 /* Bail unless some sort of legacy clipping is enabled */
840 if (key->nr_userclip_plane_consts == 0)
841 return;
842
843 /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):
844 *
845 * "If a linked set of shaders forming the vertex stage contains no
846 * static write to gl_ClipVertex or gl_ClipDistance, but the
847 * application has requested clipping against user clip planes through
848 * the API, then the coordinate written to gl_Position is used for
849 * comparison against the user clip planes."
850 *
851 * This function is only called if the shader didn't write to
852 * gl_ClipDistance. Accordingly, we use gl_ClipVertex to perform clipping
853 * if the user wrote to it; otherwise we use gl_Position.
854 */
855
856 gl_varying_slot clip_vertex = VARYING_SLOT_CLIP_VERTEX;
857 if (!(vue_prog_data->vue_map.slots_valid & VARYING_BIT_CLIP_VERTEX))
858 clip_vertex = VARYING_SLOT_POS;
859
860 /* If the clip vertex isn't written, skip this. Typically this means
861 * the GS will set up clipping. */
862 if (outputs[clip_vertex].file == BAD_FILE)
863 return;
864
865 setup_uniform_clipplane_values(clip_planes);
866
867 const fs_builder abld = bld.annotate("user clip distances");
868
869 this->outputs[VARYING_SLOT_CLIP_DIST0] = vgrf(glsl_type::vec4_type);
870 this->output_components[VARYING_SLOT_CLIP_DIST0] = 4;
871 this->outputs[VARYING_SLOT_CLIP_DIST1] = vgrf(glsl_type::vec4_type);
872 this->output_components[VARYING_SLOT_CLIP_DIST1] = 4;
873
874 for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
875 fs_reg u = userplane[i];
876 fs_reg output = outputs[VARYING_SLOT_CLIP_DIST0 + i / 4];
877 output.reg_offset = i & 3;
878
879 abld.MUL(output, outputs[clip_vertex], u);
880 for (int j = 1; j < 4; j++) {
881 u.nr = userplane[i].nr + j;
882 abld.MAD(output, output, offset(outputs[clip_vertex], bld, j), u);
883 }
884 }
885 }
886
887 void
888 fs_visitor::emit_urb_writes(const fs_reg &gs_vertex_count)
889 {
890 int slot, urb_offset, length;
891 int starting_urb_offset = 0;
892 const struct brw_vue_prog_data *vue_prog_data =
893 (const struct brw_vue_prog_data *) this->prog_data;
894 const struct brw_vs_prog_key *vs_key =
895 (const struct brw_vs_prog_key *) this->key;
896 const GLbitfield64 psiz_mask =
897 VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PSIZ;
898 const struct brw_vue_map *vue_map = &vue_prog_data->vue_map;
899 bool flush;
900 fs_reg sources[8];
901
902 /* If we don't have any valid slots to write, just do a minimal urb write
903 * send to terminate the shader. This includes 1 slot of undefined data,
904 * because it's invalid to write 0 data:
905 *
906 * From the Broadwell PRM, Volume 7: 3D Media GPGPU, Shared Functions -
907 * Unified Return Buffer (URB) > URB_SIMD8_Write and URB_SIMD8_Read >
908 * Write Data Payload:
909 *
910 * "The write data payload can be between 1 and 8 message phases long."
911 */
912 if (vue_map->slots_valid == 0) {
913 fs_reg payload = fs_reg(VGRF, alloc.allocate(2), BRW_REGISTER_TYPE_UD);
914 bld.exec_all().MOV(payload, fs_reg(retype(brw_vec8_grf(1, 0),
915 BRW_REGISTER_TYPE_UD)));
916
917 fs_inst *inst = bld.emit(SHADER_OPCODE_URB_WRITE_SIMD8, reg_undef, payload);
918 inst->eot = true;
919 inst->mlen = 2;
920 inst->offset = 1;
921 return;
922 }
923
924 opcode opcode = SHADER_OPCODE_URB_WRITE_SIMD8;
925 int header_size = 1;
926 fs_reg per_slot_offsets;
927
928 if (stage == MESA_SHADER_GEOMETRY) {
929 const struct brw_gs_prog_data *gs_prog_data =
930 (const struct brw_gs_prog_data *) this->prog_data;
931
932 /* We need to increment the Global Offset to skip over the control data
933 * header and the extra "Vertex Count" field (1 HWord) at the beginning
934 * of the VUE. We're counting in OWords, so the units are doubled.
935 */
936 starting_urb_offset = 2 * gs_prog_data->control_data_header_size_hwords;
937 if (gs_prog_data->static_vertex_count == -1)
938 starting_urb_offset += 2;
939
940 /* We also need to use per-slot offsets. The per-slot offset is the
941 * Vertex Count. SIMD8 mode processes 8 different primitives at a
942 * time; each may output a different number of vertices.
943 */
944 opcode = SHADER_OPCODE_URB_WRITE_SIMD8_PER_SLOT;
945 header_size++;
946
947 /* The URB offset is in 128-bit units, so we need to multiply by 2 */
948 const int output_vertex_size_owords =
949 gs_prog_data->output_vertex_size_hwords * 2;
950
951 fs_reg offset;
952 if (gs_vertex_count.file == IMM) {
953 per_slot_offsets = fs_reg(output_vertex_size_owords *
954 gs_vertex_count.ud);
955 } else {
956 per_slot_offsets = vgrf(glsl_type::int_type);
957 bld.MUL(per_slot_offsets, gs_vertex_count,
958 fs_reg(output_vertex_size_owords));
959 }
960 }
961
962 length = 0;
963 urb_offset = starting_urb_offset;
964 flush = false;
965 for (slot = 0; slot < vue_map->num_slots; slot++) {
966 int varying = vue_map->slot_to_varying[slot];
967 switch (varying) {
968 case VARYING_SLOT_PSIZ: {
969 /* The point size varying slot is the vue header and is always in the
970 * vue map. But often none of the special varyings that live there
971 * are written and in that case we can skip writing to the vue
972 * header, provided the corresponding state properly clamps the
973 * values further down the pipeline. */
974 if ((vue_map->slots_valid & psiz_mask) == 0) {
975 assert(length == 0);
976 urb_offset++;
977 break;
978 }
979
980 fs_reg zero(VGRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD);
981 bld.MOV(zero, fs_reg(0u));
982
983 sources[length++] = zero;
984 if (vue_map->slots_valid & VARYING_BIT_LAYER)
985 sources[length++] = this->outputs[VARYING_SLOT_LAYER];
986 else
987 sources[length++] = zero;
988
989 if (vue_map->slots_valid & VARYING_BIT_VIEWPORT)
990 sources[length++] = this->outputs[VARYING_SLOT_VIEWPORT];
991 else
992 sources[length++] = zero;
993
994 if (vue_map->slots_valid & VARYING_BIT_PSIZ)
995 sources[length++] = this->outputs[VARYING_SLOT_PSIZ];
996 else
997 sources[length++] = zero;
998 break;
999 }
1000 case BRW_VARYING_SLOT_NDC:
1001 case VARYING_SLOT_EDGE:
1002 unreachable("unexpected scalar vs output");
1003 break;
1004
1005 default:
1006 /* gl_Position is always in the vue map, but isn't always written by
1007 * the shader. Other varyings (clip distances) get added to the vue
1008 * map but don't always get written. In those cases, the
1009 * corresponding this->output[] slot will be invalid we and can skip
1010 * the urb write for the varying. If we've already queued up a vue
1011 * slot for writing we flush a mlen 5 urb write, otherwise we just
1012 * advance the urb_offset.
1013 */
1014 if (varying == BRW_VARYING_SLOT_PAD ||
1015 this->outputs[varying].file == BAD_FILE) {
1016 if (length > 0)
1017 flush = true;
1018 else
1019 urb_offset++;
1020 break;
1021 }
1022
1023 if (stage == MESA_SHADER_VERTEX && vs_key->clamp_vertex_color &&
1024 (varying == VARYING_SLOT_COL0 ||
1025 varying == VARYING_SLOT_COL1 ||
1026 varying == VARYING_SLOT_BFC0 ||
1027 varying == VARYING_SLOT_BFC1)) {
1028 /* We need to clamp these guys, so do a saturating MOV into a
1029 * temp register and use that for the payload.
1030 */
1031 for (int i = 0; i < 4; i++) {
1032 fs_reg reg = fs_reg(VGRF, alloc.allocate(1), outputs[varying].type);
1033 fs_reg src = offset(this->outputs[varying], bld, i);
1034 set_saturate(true, bld.MOV(reg, src));
1035 sources[length++] = reg;
1036 }
1037 } else {
1038 for (unsigned i = 0; i < output_components[varying]; i++)
1039 sources[length++] = offset(this->outputs[varying], bld, i);
1040 for (unsigned i = output_components[varying]; i < 4; i++)
1041 sources[length++] = fs_reg(0);
1042 }
1043 break;
1044 }
1045
1046 const fs_builder abld = bld.annotate("URB write");
1047
1048 /* If we've queued up 8 registers of payload (2 VUE slots), if this is
1049 * the last slot or if we need to flush (see BAD_FILE varying case
1050 * above), emit a URB write send now to flush out the data.
1051 */
1052 int last = slot == vue_map->num_slots - 1;
1053 if (length == 8 || last)
1054 flush = true;
1055 if (flush) {
1056 fs_reg *payload_sources =
1057 ralloc_array(mem_ctx, fs_reg, length + header_size);
1058 fs_reg payload = fs_reg(VGRF, alloc.allocate(length + header_size),
1059 BRW_REGISTER_TYPE_F);
1060 payload_sources[0] =
1061 fs_reg(retype(brw_vec8_grf(1, 0), BRW_REGISTER_TYPE_UD));
1062
1063 if (opcode == SHADER_OPCODE_URB_WRITE_SIMD8_PER_SLOT)
1064 payload_sources[1] = per_slot_offsets;
1065
1066 memcpy(&payload_sources[header_size], sources,
1067 length * sizeof sources[0]);
1068
1069 abld.LOAD_PAYLOAD(payload, payload_sources, length + header_size,
1070 header_size);
1071
1072 fs_inst *inst = abld.emit(opcode, reg_undef, payload);
1073 inst->eot = last && stage == MESA_SHADER_VERTEX;
1074 inst->mlen = length + header_size;
1075 inst->offset = urb_offset;
1076 urb_offset = starting_urb_offset + slot + 1;
1077 length = 0;
1078 flush = false;
1079 }
1080 }
1081 }
1082
1083 void
1084 fs_visitor::emit_cs_terminate()
1085 {
1086 assert(devinfo->gen >= 7);
1087
1088 /* We are getting the thread ID from the compute shader header */
1089 assert(stage == MESA_SHADER_COMPUTE);
1090
1091 /* We can't directly send from g0, since sends with EOT have to use
1092 * g112-127. So, copy it to a virtual register, The register allocator will
1093 * make sure it uses the appropriate register range.
1094 */
1095 struct brw_reg g0 = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD);
1096 fs_reg payload = fs_reg(VGRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD);
1097 bld.group(8, 0).exec_all().MOV(payload, g0);
1098
1099 /* Send a message to the thread spawner to terminate the thread. */
1100 fs_inst *inst = bld.exec_all()
1101 .emit(CS_OPCODE_CS_TERMINATE, reg_undef, payload);
1102 inst->eot = true;
1103 }
1104
1105 void
1106 fs_visitor::emit_barrier()
1107 {
1108 assert(devinfo->gen >= 7);
1109
1110 /* We are getting the barrier ID from the compute shader header */
1111 assert(stage == MESA_SHADER_COMPUTE);
1112
1113 fs_reg payload = fs_reg(VGRF, alloc.allocate(1), BRW_REGISTER_TYPE_UD);
1114
1115 const fs_builder pbld = bld.exec_all().group(8, 0);
1116
1117 /* Clear the message payload */
1118 pbld.MOV(payload, fs_reg(0u));
1119
1120 /* Copy bits 27:24 of r0.2 (barrier id) to the message payload reg.2 */
1121 fs_reg r0_2 = fs_reg(retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_UD));
1122 pbld.AND(component(payload, 2), r0_2, fs_reg(0x0f000000u));
1123
1124 /* Emit a gateway "barrier" message using the payload we set up, followed
1125 * by a wait instruction.
1126 */
1127 bld.exec_all().emit(SHADER_OPCODE_BARRIER, reg_undef, payload);
1128 }
1129
1130 fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
1131 void *mem_ctx,
1132 const void *key,
1133 struct brw_stage_prog_data *prog_data,
1134 struct gl_program *prog,
1135 const nir_shader *shader,
1136 unsigned dispatch_width,
1137 int shader_time_index)
1138 : backend_shader(compiler, log_data, mem_ctx, shader, prog_data),
1139 key(key), gs_compile(NULL), prog_data(prog_data), prog(prog),
1140 dispatch_width(dispatch_width),
1141 shader_time_index(shader_time_index),
1142 bld(fs_builder(this, dispatch_width).at_end())
1143 {
1144 init();
1145 }
1146
1147 fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
1148 void *mem_ctx,
1149 struct brw_gs_compile *c,
1150 struct brw_gs_prog_data *prog_data,
1151 const nir_shader *shader,
1152 int shader_time_index)
1153 : backend_shader(compiler, log_data, mem_ctx, shader,
1154 &prog_data->base.base),
1155 key(&c->key), gs_compile(c),
1156 prog_data(&prog_data->base.base), prog(NULL),
1157 dispatch_width(8),
1158 shader_time_index(shader_time_index),
1159 bld(fs_builder(this, dispatch_width).at_end())
1160 {
1161 init();
1162 }
1163
1164
1165 void
1166 fs_visitor::init()
1167 {
1168 switch (stage) {
1169 case MESA_SHADER_FRAGMENT:
1170 key_tex = &((const brw_wm_prog_key *) key)->tex;
1171 break;
1172 case MESA_SHADER_VERTEX:
1173 key_tex = &((const brw_vs_prog_key *) key)->tex;
1174 break;
1175 case MESA_SHADER_GEOMETRY:
1176 key_tex = &((const brw_gs_prog_key *) key)->tex;
1177 break;
1178 case MESA_SHADER_COMPUTE:
1179 key_tex = &((const brw_cs_prog_key*) key)->tex;
1180 break;
1181 default:
1182 unreachable("unhandled shader stage");
1183 }
1184
1185 this->prog_data = this->stage_prog_data;
1186
1187 this->failed = false;
1188 this->simd16_unsupported = false;
1189 this->no16_msg = NULL;
1190
1191 this->nir_locals = NULL;
1192 this->nir_ssa_values = NULL;
1193
1194 memset(&this->payload, 0, sizeof(this->payload));
1195 memset(this->output_components, 0, sizeof(this->output_components));
1196 this->source_depth_to_render_target = false;
1197 this->runtime_check_aads_emit = false;
1198 this->first_non_payload_grf = 0;
1199 this->max_grf = devinfo->gen >= 7 ? GEN7_MRF_HACK_START : BRW_MAX_GRF;
1200
1201 this->virtual_grf_start = NULL;
1202 this->virtual_grf_end = NULL;
1203 this->live_intervals = NULL;
1204 this->regs_live_at_ip = NULL;
1205
1206 this->uniforms = 0;
1207 this->last_scratch = 0;
1208 this->pull_constant_loc = NULL;
1209 this->push_constant_loc = NULL;
1210
1211 this->promoted_constants = 0,
1212
1213 this->spilled_any_registers = false;
1214 this->do_dual_src = false;
1215
1216 if (dispatch_width == 8)
1217 this->param_size = rzalloc_array(mem_ctx, int, stage_prog_data->nr_params);
1218 }
1219
1220 fs_visitor::~fs_visitor()
1221 {
1222 }