summaryrefslogtreecommitdiff
path: root/src/sna/brw/brw_wm.c
blob: bd4003dd5195f5fed87a7147f54cd9f50cc70482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
#include "brw.h"

#define X16 8
#define Y16 10

static void brw_wm_xy(struct brw_compile *p, int dw)
{
	struct brw_reg r1 = brw_vec1_grf(1, 0);
	struct brw_reg r1_uw = __retype_uw(r1);
	struct brw_reg x_uw, y_uw;

	brw_set_compression_control(p, BRW_COMPRESSION_NONE);

	if (dw == 16) {
		x_uw = brw_uw16_grf(30, 0);
		y_uw = brw_uw16_grf(28, 0);
	} else {
		x_uw = brw_uw8_grf(30, 0);
		y_uw = brw_uw8_grf(28, 0);
	}

	brw_ADD(p,
		x_uw,
		__stride(__suboffset(r1_uw, 4), 2, 4, 0),
		brw_imm_v(0x10101010));
	brw_ADD(p,
		y_uw,
		__stride(__suboffset(r1_uw, 5), 2, 4, 0),
		brw_imm_v(0x11001100));

	brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);

	brw_ADD(p, brw_vec8_grf(X16, 0), vec8(x_uw), brw_negate(r1));
	brw_ADD(p, brw_vec8_grf(Y16, 0), vec8(y_uw), brw_negate(__suboffset(r1, 1)));
}

static void brw_wm_affine_st(struct brw_compile *p, int dw,
			     int channel, int msg)
{
	int uv;

	if (dw == 16) {
		brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
		uv = p->gen >= 60 ? 6 : 3;
		uv += 2*channel;
	} else {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);
		uv = p->gen >= 60 ? 4 : 3;
		uv += channel;
	}

	msg++;
	if (p->gen >= 60) {
		brw_PLN(p,
			brw_message_reg(msg),
			brw_vec1_grf(uv, 0),
			brw_vec8_grf(2, 0));
		msg += dw/8;

		brw_PLN(p,
			brw_message_reg(msg),
			brw_vec1_grf(uv, 4),
			brw_vec8_grf(2, 0));
	} else {
		struct brw_reg r = brw_vec1_grf(uv, 0);

		brw_LINE(p, brw_null_reg(), __suboffset(r, 0), brw_vec8_grf(X16, 0));
		brw_MAC(p, brw_message_reg(msg), __suboffset(r, 1), brw_vec8_grf(Y16, 0));
		msg += dw/8;

		brw_LINE(p, brw_null_reg(), __suboffset(r, 4), brw_vec8_grf(X16, 0));
		brw_MAC(p, brw_message_reg(msg), __suboffset(r, 5), brw_vec8_grf(Y16, 0));
	}
}

static inline unsigned simd(int dw)
{
	return dw == 16 ? BRW_SAMPLER_SIMD_MODE_SIMD16 : BRW_SAMPLER_SIMD_MODE_SIMD8;
}

static inline struct brw_reg sample_result(int dw, int result)
{
	return brw_reg(BRW_GENERAL_REGISTER_FILE, result, 0,
		       BRW_REGISTER_TYPE_UW,
		       dw == 16 ? BRW_VERTICAL_STRIDE_16 : BRW_VERTICAL_STRIDE_8,
		       dw == 16 ? BRW_WIDTH_16 : BRW_WIDTH_8,
		       BRW_HORIZONTAL_STRIDE_1,
		       BRW_SWIZZLE_XYZW,
		       WRITEMASK_XYZW);
}

static int brw_wm_sample(struct brw_compile *p, int dw,
			 int channel, int msg, int result)
{
	struct brw_reg src0;
	bool header;
	int len;

	len = dw == 16 ? 4 : 2;
	if (p->gen >= 60) {
		header = false;
		src0 = brw_message_reg(++msg);
	} else {
		header = true;
		src0 = brw_vec8_grf(0, 0);
	}

	brw_SAMPLE(p, sample_result(dw, result), msg, src0,
		   channel+1, channel, WRITEMASK_XYZW, 0,
		   2*len, len+header, header, simd(dw));
	return result;
}

static int brw_wm_sample__alpha(struct brw_compile *p, int dw,
				int channel, int msg, int result)
{
	struct brw_reg src0;
	int mlen, rlen;

	if (dw == 8) {
		/* SIMD8 sample return is not masked */
		mlen = 3;
		rlen = 4;
	} else {
		mlen = 5;
		rlen = 2;
	}

	if (p->gen >= 60)
		src0 = brw_message_reg(msg);
	else
		src0 = brw_vec8_grf(0, 0);

	brw_SAMPLE(p, sample_result(dw, result), msg, src0,
		   channel+1, channel, WRITEMASK_W, 0,
		   rlen, mlen, true, simd(dw));

	if (dw == 8)
		result += 3;

	return result;
}

static int brw_wm_affine(struct brw_compile *p, int dw,
			 int channel, int msg, int result)
{
	brw_wm_affine_st(p, dw, channel, msg);
	return brw_wm_sample(p, dw, channel, msg, result);
}

static int brw_wm_affine__alpha(struct brw_compile *p, int dw,
				int channel, int msg, int result)
{
	brw_wm_affine_st(p, dw, channel, msg);
	return brw_wm_sample__alpha(p, dw, channel, msg, result);
}

static inline struct brw_reg null_result(int dw)
{
	return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE, BRW_ARF_NULL, 0,
		       BRW_REGISTER_TYPE_UW,
		       dw == 16 ? BRW_VERTICAL_STRIDE_16 : BRW_VERTICAL_STRIDE_8,
		       dw == 16 ? BRW_WIDTH_16 : BRW_WIDTH_8,
		       BRW_HORIZONTAL_STRIDE_1,
		       BRW_SWIZZLE_XYZW,
		       WRITEMASK_XYZW);
}

static void brw_fb_write(struct brw_compile *p, int dw)
{
	struct brw_instruction *insn;
	unsigned msg_control, msg_type, msg_len;
	struct brw_reg src0;
	bool header;

	if (dw == 16) {
		brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
		msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
		msg_len = 8;
	} else {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);
		msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
		msg_len = 4;
	}

	if (p->gen < 60) {
		brw_push_insn_state(p);
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);
		brw_set_mask_control(p, BRW_MASK_DISABLE);
		brw_MOV(p, brw_message_reg(1), brw_vec8_grf(1, 0));
		brw_pop_insn_state(p);

		msg_len += 2;
	}

	/* The execution mask is ignored for render target writes. */
	insn = brw_next_insn(p, BRW_OPCODE_SEND);
	insn->header.predicate_control = 0;
	insn->header.compression_control = BRW_COMPRESSION_NONE;

	if (p->gen >= 60) {
		msg_type = GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE;
		src0 = brw_message_reg(2);
		header = false;
	} else {
		insn->header.destreg__conditionalmod = 0;
		msg_type = BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE;
		src0 = __retype_uw(brw_vec8_grf(0, 0));
		header = true;
	}

	brw_set_dest(p, insn, null_result(dw));
	brw_set_src0(p, insn, src0);
	brw_set_dp_write_message(p, insn, 0,
				 msg_control, msg_type, msg_len,
				 header, true, 0, true, false);
}

static void brw_wm_write(struct brw_compile *p, int dw, int src)
{
	int n;

	if (dw == 8 && p->gen >= 60) {
		/* XXX pixel execution mask? */
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);

		brw_MOV(p, brw_message_reg(2), brw_vec8_grf(src+0, 0));
		brw_MOV(p, brw_message_reg(3), brw_vec8_grf(src+1, 0));
		brw_MOV(p, brw_message_reg(4), brw_vec8_grf(src+2, 0));
		brw_MOV(p, brw_message_reg(5), brw_vec8_grf(src+3, 0));
		goto done;
	}

	brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);

	for (n = 0; n < 4; n++) {
		if (p->gen >= 60) {
			brw_MOV(p,
				brw_message_reg(2 + 2*n),
				brw_vec8_grf(src + 2*n, 0));
		} else if (p->gen >= 45 && dw == 16) {
			brw_MOV(p,
				brw_message_reg(2 + n + BRW_MRF_COMPR4),
				brw_vec8_grf(src + 2*n, 0));
		} else {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_MOV(p,
				brw_message_reg(2 + n),
				brw_vec8_grf(src + 2*n, 0));

			if (dw == 16) {
				brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
				brw_MOV(p,
					brw_message_reg(2 + n + 4),
					brw_vec8_grf(src + 2*n+1, 0));
			}
		}
	}

done:
	brw_fb_write(p, dw);
}

static void brw_wm_write__mask(struct brw_compile *p, int dw,
			       int src, int mask)
{
	int n;

	if (dw == 8 && p->gen >= 60) {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);

		brw_MUL(p,
			brw_message_reg(2),
			brw_vec8_grf(src+0, 0),
			brw_vec8_grf(mask, 0));
		brw_MUL(p,
			brw_message_reg(3),
			brw_vec8_grf(src+1, 0),
			brw_vec8_grf(mask, 0));
		brw_MUL(p,
			brw_message_reg(4),
			brw_vec8_grf(src+2, 0),
			brw_vec8_grf(mask, 0));
		brw_MUL(p,
			brw_message_reg(5),
			brw_vec8_grf(src+3, 0),
			brw_vec8_grf(mask, 0));

		goto done;
	}

	brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);

	for (n = 0; n < 4; n++) {
		if (p->gen >= 60) {
			brw_MUL(p,
				brw_message_reg(2 + 2*n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask, 0));
		} else if (p->gen >= 45 && dw == 16) {
			brw_MUL(p,
				brw_message_reg(2 + n + BRW_MRF_COMPR4),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask, 0));
		} else {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_MUL(p,
				brw_message_reg(2 + n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask, 0));

			if (dw == 16) {
				brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
				brw_MUL(p,
					brw_message_reg(2 + n + 4),
					brw_vec8_grf(src + 2*n+1, 0),
					brw_vec8_grf(mask+1, 0));
			}
		}
	}

done:
	brw_fb_write(p, dw);
}

static void brw_wm_write__opacity(struct brw_compile *p, int dw,
				  int src, int mask)
{
	int n;

	if (dw == 8 && p->gen >= 60) {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);

		brw_MUL(p,
			brw_message_reg(2),
			brw_vec8_grf(src+0, 0),
			brw_vec1_grf(mask, 3));
		brw_MUL(p,
			brw_message_reg(3),
			brw_vec8_grf(src+1, 0),
			brw_vec1_grf(mask, 3));
		brw_MUL(p,
			brw_message_reg(4),
			brw_vec8_grf(src+2, 0),
			brw_vec1_grf(mask, 3));
		brw_MUL(p,
			brw_message_reg(5),
			brw_vec8_grf(src+3, 0),
			brw_vec1_grf(mask, 3));

		goto done;
	}

	brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);

	for (n = 0; n < 4; n++) {
		if (p->gen >= 60) {
			brw_MUL(p,
				brw_message_reg(2 + 2*n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec1_grf(mask, 3));
		} else if (p->gen >= 45 && dw == 16) {
			brw_MUL(p,
				brw_message_reg(2 + n + BRW_MRF_COMPR4),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec1_grf(mask, 3));
		} else {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_MUL(p,
				brw_message_reg(2 + n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec1_grf(mask, 3));

			if (dw == 16) {
				brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
				brw_MUL(p,
					brw_message_reg(2 + n + 4),
					brw_vec8_grf(src + 2*n+1, 0),
					brw_vec1_grf(mask, 3));
			}
		}
	}

done:
	brw_fb_write(p, dw);
}

static void brw_wm_write__mask_ca(struct brw_compile *p, int dw,
				  int src, int mask)
{
	int n;

	if (dw == 8 && p->gen >= 60) {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);

		brw_MUL(p,
			brw_message_reg(2),
			brw_vec8_grf(src  + 0, 0),
			brw_vec8_grf(mask + 0, 0));
		brw_MUL(p,
			brw_message_reg(3),
			brw_vec8_grf(src  + 1, 0),
			brw_vec8_grf(mask + 1, 0));
		brw_MUL(p,
			brw_message_reg(4),
			brw_vec8_grf(src  + 2, 0),
			brw_vec8_grf(mask + 2, 0));
		brw_MUL(p,
			brw_message_reg(5),
			brw_vec8_grf(src  + 3, 0),
			brw_vec8_grf(mask + 3, 0));

		goto done;
	}

	brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);

	for (n = 0; n < 4; n++) {
		if (p->gen >= 60) {
			brw_MUL(p,
				brw_message_reg(2 + 2*n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask + 2*n, 0));
		} else if (p->gen >= 45 && dw == 16) {
			brw_MUL(p,
				brw_message_reg(2 + n + BRW_MRF_COMPR4),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask + 2*n, 0));
		} else {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_MUL(p,
				brw_message_reg(2 + n),
				brw_vec8_grf(src + 2*n, 0),
				brw_vec8_grf(mask + 2*n, 0));

			if (dw == 16) {
				brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
				brw_MUL(p,
					brw_message_reg(2 + n + 4),
					brw_vec8_grf(src + 2*n + 1, 0),
					brw_vec8_grf(mask + 2*n + 1, 0));
			}
		}
	}

done:
	brw_fb_write(p, dw);
}

bool
brw_wm_kernel__affine(struct brw_compile *p, int dispatch)
{
	if (p->gen < 60)
		brw_wm_xy(p, dispatch);
	brw_wm_write(p, dispatch, brw_wm_affine(p, dispatch, 0, 1, 12));

	return true;
}

bool
brw_wm_kernel__affine_mask(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (dispatch == 8)
		return false; /* XXX sampler alpha retuns all 0 */

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_affine(p, dispatch, 0, 1, 12);
	mask = brw_wm_affine__alpha(p, dispatch, 1, 6, 20);
	brw_wm_write__mask(p, dispatch, src, mask);

	return true;
}

bool
brw_wm_kernel__affine_mask_ca(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_affine(p, dispatch, 0, 1, 12);
	mask = brw_wm_affine(p, dispatch, 1, 6, 20);
	brw_wm_write__mask_ca(p, dispatch, src, mask);

	return true;
}

bool
brw_wm_kernel__affine_mask_sa(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (dispatch == 8)
		return false; /* XXX sampler alpha retuns all 0 */

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_affine__alpha(p, dispatch, 0, 1, 12);
	mask = brw_wm_affine(p, dispatch, 1, 6, 16);
	brw_wm_write__mask(p, dispatch, mask, src);

	return true;
}

/* Projective variants */

static void brw_wm_projective_st(struct brw_compile *p, int dw,
				 int channel, int msg)
{
	int uv;

	if (dw == 16) {
		brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
		uv = p->gen >= 60 ? 6 : 3;
		uv += 2*channel;
	} else {
		brw_set_compression_control(p, BRW_COMPRESSION_NONE);
		uv = p->gen >= 60 ? 4 : 3;
		uv += channel;
	}

	msg++;
	if (p->gen >= 60) {
		/* First compute 1/z */
		brw_PLN(p,
			brw_message_reg(msg),
			brw_vec1_grf(uv+1, 0),
			brw_vec8_grf(2, 0));

		if (dw == 16) {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_math_invert(p, brw_vec8_grf(30, 0), brw_vec8_grf(30, 0));
			brw_math_invert(p, brw_vec8_grf(31, 0), brw_vec8_grf(31, 0));
			brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
		} else
			brw_math_invert(p, brw_vec8_grf(30, 0), brw_vec8_grf(30, 0));
		brw_PLN(p,
			brw_vec8_grf(28, 0),
			brw_vec1_grf(uv, 0),
			brw_vec8_grf(2, 0));
		brw_MUL(p,
			brw_message_reg(msg),
			brw_vec8_grf(28, 0),
			brw_vec8_grf(30, 0));
		msg += dw/8;

		brw_PLN(p,
			brw_vec8_grf(28, 0),
			brw_vec1_grf(uv, 0),
			brw_vec8_grf(4, 0));
		brw_MUL(p,
			brw_message_reg(msg),
			brw_vec8_grf(28, 0),
			brw_vec8_grf(30, 0));
	} else {
		struct brw_reg r = brw_vec1_grf(uv, 0);

		/* First compute 1/z */
		brw_LINE(p, brw_null_reg(), brw_vec1_grf(uv+1, 0), brw_vec8_grf(X16, 0));
		brw_MAC(p, brw_vec8_grf(30, 0), brw_vec1_grf(uv+1, 1), brw_vec8_grf(Y16, 0));

		if (dw == 16) {
			brw_set_compression_control(p, BRW_COMPRESSION_NONE);
			brw_math_invert(p, brw_vec8_grf(30, 0), brw_vec8_grf(30, 0));
			brw_math_invert(p, brw_vec8_grf(31, 0), brw_vec8_grf(31, 0));
			brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
		} else
			brw_math_invert(p, brw_vec8_grf(30, 0), brw_vec8_grf(30, 0));

		/* Now compute the output s,t values */
		brw_LINE(p, brw_null_reg(), __suboffset(r, 0), brw_vec8_grf(X16, 0));
		brw_MAC(p, brw_vec8_grf(28, 0), __suboffset(r, 1), brw_vec8_grf(Y16, 0));
		brw_MUL(p, brw_message_reg(msg), brw_vec8_grf(28, 0), brw_vec8_grf(30, 0));
		msg += dw/8;

		brw_LINE(p, brw_null_reg(), __suboffset(r, 4), brw_vec8_grf(X16, 0));
		brw_MAC(p, brw_vec8_grf(28, 0), __suboffset(r, 5), brw_vec8_grf(Y16, 0));
		brw_MUL(p, brw_message_reg(msg), brw_vec8_grf(28, 0), brw_vec8_grf(30, 0));
	}
}

static int brw_wm_projective(struct brw_compile *p, int dw,
			     int channel, int msg, int result)
{
	brw_wm_projective_st(p, dw, channel, msg);
	return brw_wm_sample(p, dw, channel, msg, result);
}

static int brw_wm_projective__alpha(struct brw_compile *p, int dw,
				     int channel, int msg, int result)
{
	brw_wm_projective_st(p, dw, channel, msg);
	return brw_wm_sample__alpha(p, dw, channel, msg, result);
}

bool
brw_wm_kernel__projective(struct brw_compile *p, int dispatch)
{
	if (p->gen < 60)
		brw_wm_xy(p, dispatch);
	brw_wm_write(p, dispatch, brw_wm_projective(p, dispatch, 0, 1, 12));

	return true;
}

bool
brw_wm_kernel__projective_mask(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (dispatch == 8)
		return false; /* XXX sampler alpha retuns all 0 */

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_projective(p, dispatch, 0, 1, 12);
	mask = brw_wm_projective__alpha(p, dispatch, 1, 6, 20);
	brw_wm_write__mask(p, dispatch, src, mask);

	return true;
}

bool
brw_wm_kernel__projective_mask_ca(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_projective(p, dispatch, 0, 1, 12);
	mask = brw_wm_projective(p, dispatch, 1, 6, 20);
	brw_wm_write__mask_ca(p, dispatch, src, mask);

	return true;
}

bool
brw_wm_kernel__projective_mask_sa(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (dispatch == 8)
		return false; /* XXX sampler alpha retuns all 0 */

	if (p->gen < 60)
		brw_wm_xy(p, dispatch);

	src = brw_wm_projective__alpha(p, dispatch, 0, 1, 12);
	mask = brw_wm_projective(p, dispatch, 1, 6, 16);
	brw_wm_write__mask(p, dispatch, mask, src);

	return true;
}

bool
brw_wm_kernel__affine_opacity(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (p->gen < 60) {
		brw_wm_xy(p, dispatch);
		mask = 4;
	} else
		mask = dispatch == 16 ? 8 : 6;

	src = brw_wm_affine(p, dispatch, 0, 1, 12);
	brw_wm_write__opacity(p, dispatch, src, mask);

	return true;
}

bool
brw_wm_kernel__projective_opacity(struct brw_compile *p, int dispatch)
{
	int src, mask;

	if (p->gen < 60) {
		brw_wm_xy(p, dispatch);
		mask = 4;
	} else
		mask = dispatch == 16 ? 8 : 6;

	src = brw_wm_projective(p, dispatch, 0, 1, 12);
	brw_wm_write__opacity(p, dispatch, src, mask);

	return true;
}