spirv2dxil: Replace not-provided inputs with zero instead of undef

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20614>
This commit is contained in:
Jesse Natalie 2023-01-05 11:30:33 -08:00 committed by Marge Bot
parent 61c391781e
commit 22eb9b1c12

View file

@ -509,10 +509,18 @@ kill_undefined_varyings(struct nir_builder *b,
return false;
b->cursor = nir_after_instr(instr);
nir_ssa_def *undef =
nir_ssa_undef(b, nir_dest_num_components(intr->dest),
nir_dest_bit_size(intr->dest));
nir_ssa_def_rewrite_uses(&intr->dest.ssa, undef);
/* Note: zero is used instead of undef, because optimization is not run here, but is
* run later on. If we load an undef here, and that undef ends up being used to store
* to position later on, that can cause some or all of the components in that position
* write to be removed, which is problematic especially in the case of all components,
* since that would remove the store instruction, and would make it tricky to satisfy
* the DXIL requirements of writing all position components.
*/
unsigned int swizzle[NIR_MAX_VEC_COMPONENTS] = { 0 };
nir_ssa_def *zero =
nir_swizzle(b, nir_imm_intN_t(b, 0, nir_dest_bit_size(intr->dest)),
swizzle, nir_dest_num_components(intr->dest));
nir_ssa_def_rewrite_uses(&intr->dest.ssa, zero);
nir_instr_remove(instr);
return true;
}