intel/fs: Make alpha test work with MRT and sample mask

Fix the order of src0_alpha and sample mask in fb payload.
From SKL PRM Volume 7, "Data Payload Register Order
for Render Target Write Messages":
 Type   S0A  oM  sZ  oS  M2     M3       M4
 SIMD8   1   1   0   0   s0A    oM       R
 SIMD16  1   1   0   0   1/0s0A 3/2s0A   oM

It also fixes working of alpha to coverage with sample mask
on GEN6 since now they are in correct order.

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by:  Francisco Jerez <currojerez@riseup.net>
This commit is contained in:
Danylo Piliaiev 2019-02-27 17:10:42 +02:00 committed by Francisco Jerez
parent c8abe03f3b
commit e0db0c74b9

View file

@ -4281,6 +4281,23 @@ lower_fb_write_logical_send(const fs_builder &bld, fs_inst *inst,
length++;
}
if (src0_alpha.file != BAD_FILE) {
for (unsigned i = 0; i < bld.dispatch_width() / 8; i++) {
const fs_builder &ubld = bld.exec_all().group(8, i)
.annotate("FB write src0 alpha");
const fs_reg tmp = ubld.vgrf(BRW_REGISTER_TYPE_F);
ubld.MOV(tmp, horiz_offset(src0_alpha, i * 8));
setup_color_payload(ubld, key, &sources[length], tmp, 1);
length++;
}
} else if (prog_data->replicate_alpha && inst->target != 0) {
/* Handle the case when fragment shader doesn't write to draw buffer
* zero. No need to call setup_color_payload() for src0_alpha because
* alpha value will be undefined.
*/
length += bld.dispatch_width() / 8;
}
if (sample_mask.file != BAD_FILE) {
sources[length] = fs_reg(VGRF, bld.shader->alloc.allocate(1),
BRW_REGISTER_TYPE_UD);
@ -4304,24 +4321,6 @@ lower_fb_write_logical_send(const fs_builder &bld, fs_inst *inst,
payload_header_size = length;
if (src0_alpha.file != BAD_FILE) {
/* FIXME: This is being passed at the wrong location in the payload and
* doesn't work when gl_SampleMask and MRTs are used simultaneously.
* It's supposed to be immediately before oMask but there seems to be no
* reasonable way to pass them in the correct order because LOAD_PAYLOAD
* requires header sources to form a contiguous segment at the beginning
* of the message and src0_alpha has per-channel semantics.
*/
setup_color_payload(bld, key, &sources[length], src0_alpha, 1);
length++;
} else if (prog_data->replicate_alpha && inst->target != 0) {
/* Handle the case when fragment shader doesn't write to draw buffer
* zero. No need to call setup_color_payload() for src0_alpha because
* alpha value will be undefined.
*/
length++;
}
setup_color_payload(bld, key, &sources[length], color0, components);
length += 4;