mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Eliminate inf values resulting from depth range computation.
Fixes #17981
This commit is contained in:
parent
8d0582659f
commit
6d3c34ecd5
4 changed files with 11 additions and 6 deletions
|
@ -124,6 +124,10 @@ inline bool my_isnanorinf(float f) {
|
|||
return ((f2u.u & 0x7F800000) == 0x7F800000);
|
||||
}
|
||||
|
||||
inline float InfToZero(float f) {
|
||||
return my_isinf(f) ? 0.0f : f;
|
||||
}
|
||||
|
||||
inline int is_even(float d) {
|
||||
float int_part;
|
||||
modff(d / 2.0f, &int_part);
|
||||
|
|
|
@ -248,8 +248,9 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
|||
float vpZCenter = gstate.getViewportZCenter();
|
||||
|
||||
// These are just the reverse of the formulas in GPUStateUtils.
|
||||
float halfActualZRange = gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f;
|
||||
float inverseDepthScale = gstate_c.vpDepthScale != 0.0f ? 1.0f / gstate_c.vpDepthScale : 0.0f;
|
||||
float halfActualZRange = InfToZero(gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f);
|
||||
float inverseDepthScale = InfToZero(gstate_c.vpDepthScale != 0.0f ? 1.0f / gstate_c.vpDepthScale : 0.0f);
|
||||
|
||||
float minz = -((gstate_c.vpZOffset * halfActualZRange) - vpZCenter) - halfActualZRange;
|
||||
float viewZScale = halfActualZRange * 2.0f;
|
||||
float viewZCenter = minz;
|
||||
|
|
|
@ -460,11 +460,11 @@ void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
|||
float vpZCenter = gstate.getViewportZCenter();
|
||||
|
||||
// These are just the reverse of the formulas in GPUStateUtils.
|
||||
float halfActualZRange = gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f;
|
||||
float halfActualZRange = InfToZero(gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f);
|
||||
float minz = -((gstate_c.vpZOffset * halfActualZRange) - vpZCenter) - halfActualZRange;
|
||||
float viewZScale = halfActualZRange * 2.0f;
|
||||
float viewZCenter = minz;
|
||||
float reverseScale = gstate_c.vpDepthScale != 0.0f ? 2.0f * (1.0f / gstate_c.vpDepthScale) : 0.0f;
|
||||
float reverseScale = InfToZero(gstate_c.vpDepthScale != 0.0f ? 2.0f * (1.0f / gstate_c.vpDepthScale) : 0.0f);
|
||||
float reverseTranslate = gstate_c.vpZOffset * 0.5f + 0.5f;
|
||||
|
||||
float data[4] = { viewZScale, viewZCenter, reverseTranslate, reverseScale };
|
||||
|
|
|
@ -591,8 +591,8 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
|
|||
float vpZCenter = gstate.getViewportZCenter();
|
||||
|
||||
// These are just the reverse of the formulas in GPUStateUtils.
|
||||
float halfActualZRange = gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f;
|
||||
float inverseDepthScale = gstate_c.vpDepthScale != 0.0f ? 1.0f / gstate_c.vpDepthScale : 0.0f;
|
||||
float halfActualZRange = InfToZero(gstate_c.vpDepthScale != 0.0f ? vpZScale / gstate_c.vpDepthScale : 0.0f);
|
||||
float inverseDepthScale = InfToZero(gstate_c.vpDepthScale != 0.0f ? 1.0f / gstate_c.vpDepthScale : 0.0f);
|
||||
float minz = -((gstate_c.vpZOffset * halfActualZRange) - vpZCenter) - halfActualZRange;
|
||||
float viewZScale = halfActualZRange;
|
||||
float viewZCenter = minz + halfActualZRange;
|
||||
|
|
Loading…
Add table
Reference in a new issue