mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-21 21:35:46 +00:00
Shaders: Fix multiplications between 0.0 and inf
The PICA200 semantics for multiplication are so that when multiplying inf by exactly 0.0, the result is 0.0, instead of NaN, as defined by IEEE. This is relied upon by games. Fixes #1024 (missing OoT interface items)
This commit is contained in:
parent
8b0a7e7afe
commit
9a4a0cc8e0
3 changed files with 60 additions and 42 deletions
|
@ -1021,12 +1021,20 @@ struct float24 {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static float24 Zero() {
|
||||
return FromFloat32(0.f);
|
||||
}
|
||||
|
||||
// Not recommended for anything but logging
|
||||
float ToFloat32() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
float24 operator * (const float24& flt) const {
|
||||
if ((this->value == 0.f && flt.value == flt.value) ||
|
||||
(flt.value == 0.f && this->value == this->value))
|
||||
// PICA gives 0 instead of NaN when multiplying by inf
|
||||
return Zero();
|
||||
return float24::FromFloat32(ToFloat32() * flt.ToFloat32());
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1051,11 @@ struct float24 {
|
|||
}
|
||||
|
||||
float24& operator *= (const float24& flt) {
|
||||
value *= flt.ToFloat32();
|
||||
if ((this->value == 0.f && flt.value == flt.value) ||
|
||||
(flt.value == 0.f && this->value == this->value))
|
||||
// PICA gives 0 instead of NaN when multiplying by inf
|
||||
*this = Zero();
|
||||
else value *= flt.ToFloat32();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue