[spirv] Avoid NaN when a conversion to f16 is emitted (#215)

Fixes black squares in Fire Emblem: Three Houses.
And fixes vertex explosions in The Legend of Zelda: Breath of the Wild shrine areas.
These were caused by NaN values from overflowed conversions to float16.

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/215
Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Co-committed-by: JPikachu <jpikachu.eden@gmail.com>
This commit is contained in:
JPikachu 2025-06-29 17:15:46 +00:00 committed by JPikachu
parent 91a662431c
commit 11b152ab58

View file

@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -148,7 +150,10 @@ Id EmitConvertU32U64(EmitContext& ctx, Id value) {
}
Id EmitConvertF16F32(EmitContext& ctx, Id value) {
return ctx.OpFConvert(ctx.F16[1], value);
const auto result = ctx.OpFConvert(ctx.F16[1], value);
const auto isOverflowing = ctx.OpIsNan(ctx.U1, result);
return ctx.OpSelect(ctx.F16[1], isOverflowing, ctx.Constant(ctx.F16[1], 0), result);
//return ctx.OpFConvert(ctx.F16[1], value);
}
Id EmitConvertF32F16(EmitContext& ctx, Id value) {