Revert "intel/compiler: Vectorize gl_TessLevelInner/Outer[] writes"

This reverts commit abba55382f.
The assertions I added late in the process broke shader-db, and my
quick fix broke CI, so let's just revert it for now and I'll resubmit
this later when it's working better.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7385
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18895>
This commit is contained in:
Kenneth Graunke
2022-09-29 17:39:18 -07:00
parent 1a286837bc
commit b61b1d5a4c
2 changed files with 17 additions and 128 deletions

View File

@@ -44,7 +44,6 @@
.lower_ldexp = true, \
.lower_device_index_to_zero = true, \
.vectorize_io = true, \
.vectorize_tess_levels = true, \
.use_interpolated_input_intrinsics = true, \
.lower_insert_byte = true, \
.lower_insert_word = true, \

View File

@@ -35,54 +35,19 @@ remap_tess_levels(nir_builder *b, nir_intrinsic_instr *intr,
{
const int location = nir_intrinsic_base(intr);
const unsigned component = nir_intrinsic_component(intr);
bool out_of_bounds = false;
bool write = !nir_intrinsic_infos[intr->intrinsic].has_dest;
unsigned mask = write ? nir_intrinsic_write_mask(intr) : 0;
nir_ssa_def *src = NULL, *dest = NULL;
if (write) {
assert(intr->src[0].is_ssa);
assert(intr->num_components == intr->src[0].ssa->num_components);
} else {
assert(intr->dest.is_ssa);
assert(intr->num_components == intr->dest.ssa.num_components);
}
bool out_of_bounds;
if (location == VARYING_SLOT_TESS_LEVEL_INNER) {
b->cursor = write ? nir_before_instr(&intr->instr)
: nir_after_instr(&intr->instr);
switch (_primitive_mode) {
case TESS_PRIMITIVE_QUADS:
/* gl_TessLevelInner[0..1] lives at DWords 3-2 (reversed). */
nir_intrinsic_set_base(intr, 0);
if (write) {
assert(intr->src[0].ssa->num_components >= 2);
intr->num_components = 4;
nir_ssa_def *undef = nir_ssa_undef(b, 1, 32);
nir_ssa_def *x = nir_channel(b, intr->src[0].ssa, 0);
nir_ssa_def *y = nir_channel(b, intr->src[0].ssa, 1);
src = nir_vec4(b, undef, undef, y, x);
mask = !!(mask & WRITEMASK_X) << 3 | !!(mask & WRITEMASK_Y) << 2;
} else if (intr->dest.ssa.num_components > 1) {
assert(intr->dest.ssa.num_components == 2);
intr->num_components = 4;
intr->dest.ssa.num_components = 4;
unsigned wz[2] = { 3, 2 };
dest = nir_swizzle(b, &intr->dest.ssa, wz, 2);
} else {
nir_intrinsic_set_component(intr, 3 - component);
}
nir_intrinsic_set_component(intr, 3 - component);
out_of_bounds = false;
break;
case TESS_PRIMITIVE_TRIANGLES:
/* gl_TessLevelInner[0] lives at DWord 4. */
nir_intrinsic_set_base(intr, 1);
mask &= WRITEMASK_X;
out_of_bounds = component > 0;
break;
case TESS_PRIMITIVE_ISOLINES:
@@ -92,98 +57,28 @@ remap_tess_levels(nir_builder *b, nir_intrinsic_instr *intr,
unreachable("Bogus tessellation domain");
}
} else if (location == VARYING_SLOT_TESS_LEVEL_OUTER) {
b->cursor = write ? nir_before_instr(&intr->instr)
: nir_after_instr(&intr->instr);
nir_intrinsic_set_base(intr, 1);
switch (_primitive_mode) {
case TESS_PRIMITIVE_QUADS:
/* gl_TessLevelOuter[0..3] lives at DWords 7-4 (reversed). */
if (write) {
assert(intr->src[0].ssa->num_components == 4);
unsigned wzyx[4] = { 3, 2, 1, 0 };
src = nir_swizzle(b, intr->src[0].ssa, wzyx, 4);
mask = !!(mask & WRITEMASK_X) << 3 | !!(mask & WRITEMASK_Y) << 2 |
!!(mask & WRITEMASK_Z) << 1 | !!(mask & WRITEMASK_W) << 0;
} else if (intr->dest.ssa.num_components > 1) {
assert(intr->dest.ssa.num_components == 4);
unsigned wzyx[4] = { 3, 2, 1, 0 };
dest = nir_swizzle(b, &intr->dest.ssa, wzyx, 4);
} else {
nir_intrinsic_set_component(intr, 3 - component);
}
break;
case TESS_PRIMITIVE_TRIANGLES:
/* gl_TessLevelOuter[0..2] lives at DWords 7-5 (reversed). */
if (write) {
assert(intr->src[0].ssa->num_components >= 3);
intr->num_components = 4;
nir_ssa_def *x = nir_channel(b, intr->src[0].ssa, 0);
nir_ssa_def *y = nir_channel(b, intr->src[0].ssa, 1);
nir_ssa_def *z = nir_channel(b, intr->src[0].ssa, 2);
nir_ssa_def *undef = nir_ssa_undef(b, 1, 32);
src = nir_vec4(b, undef, z, y, x);
mask = !!(mask & WRITEMASK_X) << 3 | !!(mask & WRITEMASK_Y) << 2 |
!!(mask & WRITEMASK_Z) << 1;
} else if (intr->dest.ssa.num_components > 1) {
assert(intr->dest.ssa.num_components == 3);
intr->num_components = 4;
intr->dest.ssa.num_components = 4;
unsigned wzy[3] = { 3, 2, 1 };
dest = nir_swizzle(b, &intr->dest.ssa, wzy, 3);
} else {
nir_intrinsic_set_component(intr, 3 - component);
out_of_bounds = component == 3;
}
break;
case TESS_PRIMITIVE_ISOLINES:
if (_primitive_mode == TESS_PRIMITIVE_ISOLINES) {
/* gl_TessLevelOuter[0..1] lives at DWords 6-7 (in order). */
if (write) {
assert(intr->src[0].ssa->num_components >= 2);
nir_ssa_def *undef = nir_ssa_undef(b, 1, 32);
nir_ssa_def *x = nir_channel(b, intr->src[0].ssa, 0);
nir_ssa_def *y = nir_channel(b, intr->src[0].ssa, 1);
src = nir_vec4(b, undef, undef, x, y);
mask = !!(mask & WRITEMASK_X) << 2 | !!(mask & WRITEMASK_Y) << 3;
} else if (intr->dest.ssa.num_components > 1) {
assert(intr->dest.ssa.num_components == 2);
unsigned zw[2] = { 2, 3 };
dest = nir_swizzle(b, &intr->dest.ssa, zw, 2);
} else {
nir_intrinsic_set_component(intr, 2 + component);
out_of_bounds = component > 1;
}
break;
default:
unreachable("Bogus tessellation domain");
nir_intrinsic_set_base(intr, 1);
nir_intrinsic_set_component(intr, 2 + nir_intrinsic_component(intr));
out_of_bounds = component > 1;
} else {
/* Triangles use DWords 7-5 (reversed); Quads use 7-4 (reversed) */
nir_intrinsic_set_base(intr, 1);
nir_intrinsic_set_component(intr, 3 - nir_intrinsic_component(intr));
out_of_bounds = component == 3 && _primitive_mode == TESS_PRIMITIVE_TRIANGLES;
}
} else {
return false;
}
if (out_of_bounds) {
if (!write)
nir_ssa_def_rewrite_uses(&intr->dest.ssa, nir_ssa_undef(b, 1, 32));
nir_instr_remove(&intr->instr);
} else if (write) {
nir_intrinsic_set_write_mask(intr, mask);
if (src) {
nir_instr_rewrite_src(&intr->instr, &intr->src[0],
nir_src_for_ssa(src));
if (nir_intrinsic_infos[intr->intrinsic].has_dest) {
b->cursor = nir_before_instr(&intr->instr);
nir_ssa_def *undef = nir_ssa_undef(b, 1, 32);
nir_ssa_def_rewrite_uses(&intr->dest.ssa, undef);
}
} else if (dest) {
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, dest,
dest->parent_instr);
nir_instr_remove(&intr->instr);
}
return true;
@@ -1113,11 +1008,6 @@ brw_nir_link_shaders(const struct brw_compiler *compiler,
}
NIR_PASS(_, producer, nir_lower_io_to_vector, nir_var_shader_out);
if (producer->info.stage == MESA_SHADER_TESS_CTRL &&
producer->options->vectorize_tess_levels)
NIR_PASS_V(producer, nir_vectorize_tess_levels);
NIR_PASS(_, producer, nir_opt_combine_stores, nir_var_shader_out);
NIR_PASS(_, consumer, nir_lower_io_to_vector, nir_var_shader_in);