mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-21 09:09:58 -04:00
Triforce v0.5.1
Hotfix for v0.5.0: crashes (NX2navi game folder refused by Setup, heap-full retries, GTX 10 series noise pass and whole VRAM mirrors, code-patch mods kept with their code, no page file warning), graphics (DLSS with frame generation, DLSS coming back, AMD storage buffer alignment, mesh index map, shared memory barrier, shader conversions, integrated GPUs' uniform snapshot, a Mesh shaders row), controls (microphone after restart, button prompts with a mod's size table, sprint vs Hide text, native mouse camera, controller after Restart now), Setup's Preparing shaders step, and the Linux link fix.
This commit is contained in:
@@ -146,6 +146,10 @@ void TranslateF2I(TranslatorVisitor& v, u64 insn, const IR::F16F32F64& src_a) {
|
||||
}()};
|
||||
const bool is_signed{f2i.is_signed != 0};
|
||||
const auto [max_bound, min_bound] = ClampBounds(f2i.dest_format, is_signed);
|
||||
// (Fritchii eba45b151, zortos293/Lichii#1051 by myshadowww) INT32_MAX rounds up to 2^31 as an F32 bound, so an input at or
|
||||
// above it reached OpConvertFToS out of range, which is undefined. The clamp stops below 2^31 and the exact INT32_MAX is
|
||||
// selected after the conversion
|
||||
const bool signed_f32_i32{f2i.dest_format == DestFormat::I32 && f2i.src_format == SrcFormat::F32 && is_signed};
|
||||
|
||||
IR::F16F32F64 intermediate;
|
||||
switch (f2i.src_format) {
|
||||
@@ -156,7 +160,7 @@ void TranslateF2I(TranslatorVisitor& v, u64 insn, const IR::F16F32F64& src_a) {
|
||||
break;
|
||||
}
|
||||
case SrcFormat::F32: {
|
||||
const IR::F32 max_val{v.ir.Imm32(static_cast<f32>(max_bound))};
|
||||
const IR::F32 max_val{v.ir.Imm32(signed_f32_i32 ? 0x1.fffffep30f : static_cast<f32>(max_bound))};
|
||||
const IR::F32 min_val{v.ir.Imm32(static_cast<f32>(min_bound))};
|
||||
intermediate = v.ir.FPClamp(rounded_value, min_val, max_val);
|
||||
break;
|
||||
@@ -173,6 +177,10 @@ void TranslateF2I(TranslatorVisitor& v, u64 insn, const IR::F16F32F64& src_a) {
|
||||
|
||||
const size_t bitsize{std::max<size_t>(32, BitSize(f2i.dest_format))};
|
||||
IR::U16U32U64 result{v.ir.ConvertFToI(bitsize, is_signed, intermediate)};
|
||||
if (signed_f32_i32) {
|
||||
result = IR::U32{v.ir.Select(v.ir.FPGreaterThanEqual(op_a, v.ir.Imm32(0x1p31f)),
|
||||
v.ir.Imm32(static_cast<u32>((std::numeric_limits<s32>::max)())), result)};
|
||||
}
|
||||
|
||||
bool handled_special_case = false;
|
||||
const bool special_nan_cases =
|
||||
|
||||
@@ -61,6 +61,20 @@ IR::U32 SmallAbs(TranslatorVisitor& v, const IR::U32& value, int bitsize) {
|
||||
return IR::U32{v.ir.Select(is_least, value, absolute)};
|
||||
}
|
||||
|
||||
// (Fritchii, zortos293 f6a8f5132) U32 -> F32 rounded toward zero. OpConvertUToF rounds to nearest whatever the IR's rounding
|
||||
// asks, so an input of 2^24 or more could round up: 0xffffff80..0xffffffff became 2^32 instead of 0x4f7fffff (a hash times 2^-32
|
||||
// reached 1.0). The top 24 significant bits make the float, the rest are dropped; an input below 2^24 converts exactly
|
||||
IR::F32 ConvertUnsigned32ToFloatRZ(TranslatorVisitor& v, const IR::U32& source) {
|
||||
auto& ir = v.ir;
|
||||
const IR::U32 msb{ir.Select(ir.INotEqual(source, ir.Imm32(0)), ir.FindUMsb(source), ir.Imm32(0))};
|
||||
const IR::U32 shift{ir.ISub(ir.UMax(msb, ir.Imm32(23)), ir.Imm32(23))};
|
||||
const IR::U32 retained{ir.ShiftRightLogical(source, shift)};
|
||||
const IR::U32 bits{ir.BitwiseOr(ir.ShiftLeftLogical(ir.IAdd(msb, ir.Imm32(127)), ir.Imm32(23)),
|
||||
ir.BitwiseAnd(retained, ir.Imm32(0x7fffff)))};
|
||||
const IR::F32 exact{ir.ConvertIToF(32, 32, false, ir.BitwiseAnd(source, ir.Imm32(0xffffff)))};
|
||||
return IR::F32{ir.Select(ir.IGreaterThan(msb, ir.Imm32(23), false), ir.BitCast<IR::F32>(bits), exact)};
|
||||
}
|
||||
|
||||
void I2F(TranslatorVisitor& v, u64 insn, IR::U32U64 src) {
|
||||
const Encoding i2f{insn};
|
||||
if (i2f.cc != 0) {
|
||||
@@ -99,7 +113,12 @@ void I2F(TranslatorVisitor& v, u64 insn, IR::U32U64 src) {
|
||||
.rounding = CastFpRounding(i2f.fp_rounding),
|
||||
.fmz_mode = IR::FmzMode::DontCare,
|
||||
};
|
||||
auto value{v.ir.ConvertIToF(size_t(dst_bitsize), size_t(conversion_src_bitsize), is_signed, src, fp_control)};
|
||||
IR::F16F32F64 value;
|
||||
if (!is_signed && conversion_src_bitsize == 32 && dst_bitsize == 32 && i2f.fp_rounding == FpRounding::RZ) {
|
||||
value = ConvertUnsigned32ToFloatRZ(v, IR::U32{src});
|
||||
} else {
|
||||
value = v.ir.ConvertIToF(size_t(dst_bitsize), size_t(conversion_src_bitsize), is_signed, src, fp_control);
|
||||
}
|
||||
if (i2f.neg != 0) {
|
||||
if (i2f.abs != 0 || !is_signed) {
|
||||
// We know the value is positive
|
||||
|
||||
Reference in New Issue
Block a user