Skip to content
Snippets Groups Projects
Commit 042b8a65 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz :lifter: Committed by Marge Bot
Browse files

brw/lower_a2c: fix for scalarized fs outputs


it's legal for a fs to write xyzw components separately,
and this pass should handle such cases

cc: mesa-stable

Reviewed-by: default avatarIvan Briano <ivan.briano@intel.com>
Part-of: <mesa/mesa!28752>
parent 4e5ed7eb
No related branches found
No related tags found
No related merge requests found
......@@ -58,8 +58,7 @@
static nir_def *
build_dither_mask(nir_builder *b, nir_def *color)
{
assert(color->num_components == 4);
nir_def *alpha = nir_channel(b, color, 3);
nir_def *alpha = nir_channel(b, color, color->num_components - 1);
nir_def *m =
nir_f2i32(b, nir_fmul_imm(b, nir_fsat(b, alpha), 16.0));
......@@ -130,6 +129,11 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader,
if (location == FRAG_RESULT_COLOR ||
location == FRAG_RESULT_DATA0) {
uint32_t mask = nir_intrinsic_write_mask(intrin) <<
nir_intrinsic_component(intrin);
/* need the w component */
if (!(mask & BITFIELD_BIT(3)))
continue;
assert(color0_write == NULL);
color0_write = intrin;
}
......@@ -137,22 +141,19 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader,
}
/* It's possible that shader_info may be out-of-date and the writes to
* either gl_SampleMask or the first color value may have been removed.
* either gl_SampleMask, or the first color value may have been removed,
* or that the w component is not written.
* This can happen if, for instance a nir_undef is written to the
* color value. In that case, just bail and don't do anything rather
* than crashing.
*/
if (color0_write == NULL || sample_mask_write == NULL)
goto skip;
/* It's possible that the color value isn't actually a vec4. In this case,
* It's also possible that the color value isn't actually a vec4. In this case,
* assuming an alpha of 1.0 and letting the sample mask pass through
* unaltered seems like the kindest thing to do to apps.
*/
nir_def *color0 = color0_write->src[0].ssa;
if (color0->num_components < 4)
if (color0_write == NULL || sample_mask_write == NULL)
goto skip;
nir_def *color0 = color0_write->src[0].ssa;
nir_def *sample_mask = sample_mask_write->src[0].ssa;
if (sample_mask_write_first) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment