Compare commits

...

1 Commits

Author SHA1 Message Date
JPikachu
c7c33703c4 [spirv] Avoid NaN when a conversion to f16 is emitted
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.
2025-06-28 21:28:08 +01:00

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) {