mirror of
https://github.com/libretro/ppsspp.git
synced 2025-03-03 22:17:08 +00:00
Merge pull request #11380 from unknownbrackets/softgpu
GPU: Handle bad fog params as large signed vals
This commit is contained in:
commit
6ffa5bdcaf
@ -1,4 +1,5 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "ShaderUniforms.h"
|
||||
#include "base/display.h"
|
||||
@ -119,22 +120,15 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
getFloat24(gstate.fog1),
|
||||
getFloat24(gstate.fog2),
|
||||
};
|
||||
if (my_isinf(fogcoef[1])) {
|
||||
// not really sure what a sensible value might be.
|
||||
fogcoef[1] = fogcoef[1] < 0.0f ? -10000.0f : 10000.0f;
|
||||
} else if (my_isnan(fogcoef[1])) {
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
// Just put the fog far away at a large finite distance.
|
||||
// Infinities and NaNs are rather unpredictable in shaders on many GPUs
|
||||
// so it's best to just make it a sane calculation.
|
||||
fogcoef[0] = 100000.0f;
|
||||
fogcoef[1] = 1.0f;
|
||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
if (my_isnanorinf(fogcoef[0])) {
|
||||
// Not really sure what a sensible value might be, but let's try 64k.
|
||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#ifndef MOBILE_DEVICE
|
||||
else if (my_isnanorinf(fogcoef[1]) || my_isnanorinf(fogcoef[0])) {
|
||||
ERROR_LOG_REPORT_ONCE(fognan, G3D, "Unhandled fog NaN/INF combo: %f %f", fogcoef[0], fogcoef[1]);
|
||||
if (my_isnanorinf(fogcoef[1])) {
|
||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#endif
|
||||
CopyFloat2(ub->fogCoef, fogcoef);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <cmath>
|
||||
#include "math/math_util.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
|
||||
@ -181,18 +182,13 @@ void SoftwareTransform(
|
||||
Lighter lighter(vertType);
|
||||
float fog_end = getFloat24(gstate.fog1);
|
||||
float fog_slope = getFloat24(gstate.fog2);
|
||||
// Same fixup as in ShaderManager.cpp
|
||||
if (my_isinf(fog_slope)) {
|
||||
// not really sure what a sensible value might be.
|
||||
fog_slope = fog_slope < 0.0f ? -10000.0f : 10000.0f;
|
||||
// Same fixup as in ShaderManagerGLES.cpp
|
||||
if (my_isnanorinf(fog_end)) {
|
||||
// Not really sure what a sensible value might be, but let's try 64k.
|
||||
fog_end = std::signbit(fog_end) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
if (my_isnan(fog_slope)) {
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
// Just put the fog far away at a large finite distance.
|
||||
// Infinities and NaNs are rather unpredictable in shaders on many GPUs
|
||||
// so it's best to just make it a sane calculation.
|
||||
fog_end = 100000.0f;
|
||||
fog_slope = 1.0f;
|
||||
if (my_isnanorinf(fog_slope)) {
|
||||
fog_slope = std::signbit(fog_slope) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
|
||||
int colorIndOffset = 0;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define SHADERLOG
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include "gfx/d3d9_shader.h"
|
||||
#include "base/logging.h"
|
||||
@ -364,22 +365,15 @@ void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
||||
getFloat24(gstate.fog1),
|
||||
getFloat24(gstate.fog2),
|
||||
};
|
||||
if (my_isinf(fogcoef[1])) {
|
||||
// not really sure what a sensible value might be.
|
||||
fogcoef[1] = fogcoef[1] < 0.0f ? -10000.0f : 10000.0f;
|
||||
} else if (my_isnan(fogcoef[1])) {
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
// Just put the fog far away at a large finite distance.
|
||||
// Infinities and NaNs are rather unpredictable in shaders on many GPUs
|
||||
// so it's best to just make it a sane calculation.
|
||||
fogcoef[0] = 100000.0f;
|
||||
fogcoef[1] = 1.0f;
|
||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
if (my_isnanorinf(fogcoef[0])) {
|
||||
// Not really sure what a sensible value might be, but let's try 64k.
|
||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#ifndef MOBILE_DEVICE
|
||||
else if (my_isnanorinf(fogcoef[1]) || my_isnanorinf(fogcoef[0])) {
|
||||
ERROR_LOG_REPORT_ONCE(fognan, G3D, "Unhandled fog NaN/INF combo: %f %f", fogcoef[0], fogcoef[1]);
|
||||
if (my_isnanorinf(fogcoef[1])) {
|
||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#endif
|
||||
VSSetFloatArray(CONST_VS_FOGCOEF, fogcoef, 2);
|
||||
}
|
||||
// TODO: Could even set all bones in one go if they're all dirty.
|
||||
|
@ -19,8 +19,9 @@
|
||||
#include "Common/CommonWindows.h"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
|
||||
#include "math/dataconv.h"
|
||||
#include "base/logging.h"
|
||||
@ -383,22 +384,15 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid) {
|
||||
getFloat24(gstate.fog1),
|
||||
getFloat24(gstate.fog2),
|
||||
};
|
||||
if (my_isinf(fogcoef[1])) {
|
||||
// not really sure what a sensible value might be.
|
||||
fogcoef[1] = fogcoef[1] < 0.0f ? -10000.0f : 10000.0f;
|
||||
} else if (my_isnan(fogcoef[1])) {
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
// Just put the fog far away at a large finite distance.
|
||||
// Infinities and NaNs are rather unpredictable in shaders on many GPUs
|
||||
// so it's best to just make it a sane calculation.
|
||||
fogcoef[0] = 100000.0f;
|
||||
fogcoef[1] = 1.0f;
|
||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||
if (my_isnanorinf(fogcoef[0])) {
|
||||
// Not really sure what a sensible value might be, but let's try 64k.
|
||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#ifndef MOBILE_DEVICE
|
||||
else if (my_isnanorinf(fogcoef[1]) || my_isnanorinf(fogcoef[0])) {
|
||||
ERROR_LOG_REPORT_ONCE(fognan, G3D, "Unhandled fog NaN/INF combo: %f %f", fogcoef[0], fogcoef[1]);
|
||||
if (my_isnanorinf(fogcoef[1])) {
|
||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
#endif
|
||||
render_->SetUniformF(&u_fogcoef, 2, fogcoef);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <cmath>
|
||||
#include "math/math_util.h"
|
||||
#include "Common/MemoryUtil.h"
|
||||
#include "Core/Config.h"
|
||||
#include "GPU/GPUState.h"
|
||||
@ -216,8 +218,17 @@ VertexData TransformUnit::ReadVertex(VertexReader& vreader)
|
||||
ModelCoords viewpos = TransformUnit::WorldToView(vertex.worldpos);
|
||||
vertex.clippos = ClipCoords(TransformUnit::ViewToClip(viewpos));
|
||||
if (gstate.isFogEnabled()) {
|
||||
// TODO: Validate inf/nan.
|
||||
vertex.fogdepth = (viewpos.z + getFloat24(gstate.fog1)) * getFloat24(gstate.fog2);
|
||||
float fog_end = getFloat24(gstate.fog1);
|
||||
float fog_slope = getFloat24(gstate.fog2);
|
||||
// Same fixup as in ShaderManagerGLES.cpp
|
||||
if (my_isnanorinf(fog_end)) {
|
||||
// Not really sure what a sensible value might be, but let's try 64k.
|
||||
fog_end = std::signbit(fog_end) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
if (my_isnanorinf(fog_slope)) {
|
||||
fog_slope = std::signbit(fog_slope) ? -65535.0f : 65535.0f;
|
||||
}
|
||||
vertex.fogdepth = (viewpos.z + fog_end) * fog_slope;
|
||||
} else {
|
||||
vertex.fogdepth = 1.0f;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user