mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
BPMemory: Handle fog configuration where both A and C are infinity/NaN
The console appears to behave against standard IEEE754 specification here, in particular around how NaNs are handled. NaNs appear to have no effect on the result, and are treated the same as positive or negative infinity, based on the sign bit. However, when the result would be NaN (inf - inf, or (-inf) - (-inf)), this results in a completely fogged color, or unfogged color respectively. We handle this by returning a constant zero for the A varaible, and positive or negative infinity for C depending on the sign bits of the A and C registers. This ensures that no NaN value is passed to the GPU in the first place, and that the result of the fog calculation cannot be NaN.
This commit is contained in:
@ -654,14 +654,9 @@ union BlendMode
|
||||
|
||||
union FogParam0
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 mantissa : 11;
|
||||
u32 exponent : 8;
|
||||
u32 sign : 1;
|
||||
};
|
||||
|
||||
float GetA() const;
|
||||
BitField<0, 11, u32> mant;
|
||||
BitField<11, 8, u32> exp;
|
||||
BitField<19, 1, u32> sign;
|
||||
|
||||
u32 hex;
|
||||
};
|
||||
@ -675,9 +670,6 @@ union FogParam3
|
||||
BitField<21, 3, u32> fsel; // 0 - off, 2 - linear, 4 - exp, 5 - exp2, 6 -
|
||||
// backward exp, 7 - backward exp2
|
||||
|
||||
// amount to subtract from eyespacez after range adjustment
|
||||
float GetC() const;
|
||||
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
@ -721,6 +713,13 @@ struct FogParams
|
||||
};
|
||||
|
||||
FogColor color; // 0:b 8:g 16:r - nice!
|
||||
|
||||
// Special case where a and c are infinite and the sign matches, resulting in a result of NaN.
|
||||
bool IsNaNCase() const;
|
||||
float GetA() const;
|
||||
|
||||
// amount to subtract from eyespacez after range adjustment
|
||||
float GetC() const;
|
||||
};
|
||||
|
||||
union ZMode
|
||||
|
Reference in New Issue
Block a user