Remove the depth range hack.

Ths removes the game-specific hack to workaround depth issues.
This commit is contained in:
Unknown W. Brackets 2016-01-03 12:05:59 -08:00
parent 6c38b22467
commit 18cdf9f352
9 changed files with 0 additions and 99 deletions

View File

@ -42,5 +42,4 @@ void Compatibility::Clear() {
void Compatibility::LoadIniSection(IniFile &iniFile, std::string section) {
iniFile.Get(section.c_str(), "NoDepthRounding", &flags_.NoDepthRounding, flags_.NoDepthRounding);
iniFile.Get(section.c_str(), "PixelDepthRounding", &flags_.PixelDepthRounding, flags_.PixelDepthRounding);
iniFile.Get(section.c_str(), "DepthRangeHack", &flags_.DepthRangeHack, flags_.DepthRangeHack);
}

View File

@ -47,7 +47,6 @@
struct CompatFlags {
bool NoDepthRounding;
bool PixelDepthRounding;
bool DepthRangeHack;
};
class IniFile;

View File

@ -480,11 +480,6 @@ void DIRECTX9_GPU::CheckGPUFeatures() {
features |= GPU_ROUND_DEPTH_TO_16BIT;
}
// The Phantasy Star hack :(
if (PSP_CoreParameter().compat.flags().DepthRangeHack) {
features |= GPU_USE_DEPTH_RANGE_HACK;
}
gstate_c.featureFlags = features;
}

View File

@ -342,38 +342,6 @@ void ShaderManagerDX9::VSUpdateUniforms(int dirtyUniforms) {
flippedMatrix[12] = -flippedMatrix[12];
}
// In Phantasy Star Portable 2, depth range sometimes goes negative and is clamped by glDepthRange to 0,
// causing graphics clipping glitch (issue #1788). This hack modifies the projection matrix to work around it.
if (gstate_c.Supports(GPU_USE_DEPTH_RANGE_HACK)) {
float zScale = gstate.getViewportZScale() / 65535.0f;
float zCenter = gstate.getViewportZCenter() / 65535.0f;
// if far depth range < 0
if (zCenter + zScale < 0.0f) {
// if perspective projection
if (flippedMatrix[11] < 0.0f) {
float depthMax = gstate.getDepthRangeMax() / 65535.0f;
float depthMin = gstate.getDepthRangeMin() / 65535.0f;
float a = flippedMatrix[10];
float b = flippedMatrix[14];
float n = b / (a - 1.0f);
float f = b / (a + 1.0f);
f = (n * f) / (n + ((zCenter + zScale) * (n - f) / (depthMax - depthMin)));
a = (n + f) / (n - f);
b = (2.0f * n * f) / (n - f);
if (!my_isnan(a) && !my_isnan(b)) {
flippedMatrix[10] = a;
flippedMatrix[14] = b;
}
}
}
}
const bool invertedZ = gstate_c.vpDepth < 0;
ConvertProjMatrixToD3D(flippedMatrix, invertedX, invertedY, invertedZ);

View File

@ -33,8 +33,6 @@ namespace DX9 {
class PSShader;
class VSShader;
void ConvertProjMatrixToD3D(Matrix4x4 & in);
// Pretty much full. Will need more bits for more fine grained dirty tracking for lights.
enum {
DIRTY_PROJMATRIX = (1 << 0),

View File

@ -561,11 +561,6 @@ void GLES_GPU::CheckGPUFeatures() {
}
}
// The Phantasy Star hack :(
if (PSP_CoreParameter().compat.flags().DepthRangeHack) {
features |= GPU_USE_DEPTH_RANGE_HACK;
}
#ifdef MOBILE_DEVICE
// Arguably, we should turn off GPU_IS_MOBILE on like modern Tegras, etc.
features |= GPU_IS_MOBILE;

View File

@ -437,38 +437,6 @@ void LinkedShader::UpdateUniforms(u32 vertType) {
flippedMatrix[12] = -flippedMatrix[12];
}
// In Phantasy Star Portable 2, depth range sometimes goes negative and is clamped by glDepthRange to 0,
// causing graphics clipping glitch (issue #1788). This hack modifies the projection matrix to work around it.
if (gstate_c.Supports(GPU_USE_DEPTH_RANGE_HACK)) {
float zScale = gstate.getViewportZScale() / 65535.0f;
float zCenter = gstate.getViewportZCenter() / 65535.0f;
// if far depth range < 0
if (zCenter + zScale < 0.0f) {
// if perspective projection
if (flippedMatrix[11] < 0.0f) {
float depthMax = gstate.getDepthRangeMax() / 65535.0f;
float depthMin = gstate.getDepthRangeMin() / 65535.0f;
float a = flippedMatrix[10];
float b = flippedMatrix[14];
float n = b / (a - 1.0f);
float f = b / (a + 1.0f);
f = (n * f) / (n + ((zCenter + zScale) * (n - f) / (depthMax - depthMin)));
a = (n + f) / (n - f);
b = (2.0f * n * f) / (n - f);
if (!my_isnan(a) && !my_isnan(b)) {
flippedMatrix[10] = a;
flippedMatrix[14] = b;
}
}
}
}
ScaleProjMatrix(flippedMatrix);
glUniformMatrix4fv(u_proj, 1, GL_FALSE, flippedMatrix.m);

View File

@ -453,7 +453,6 @@ enum {
GPU_SUPPORTS_UNPACK_SUBIMAGE = FLAG_BIT(3),
GPU_SUPPORTS_BLEND_MINMAX = FLAG_BIT(4),
GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5),
GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6),
GPU_SUPPORTS_VAO = FLAG_BIT(18),
GPU_SUPPORTS_ANY_COPY_IMAGE = FLAG_BIT(19),
GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH = FLAG_BIT(20),

View File

@ -111,23 +111,3 @@ PixelDepthRounding = true
# Heroes Phantasia Limited Edition Disc requires pixel depth rounding.
[ULJS00455]
PixelDepthRounding = true
# Phantasy Star Portable 2 has the same issue.
[ULJM05493]
DepthRangeHack = true
[NPJH50043]
DepthRangeHack = true
[ULJM08030]
DepthRangeHack = true
[ULES01439]
DepthRangeHack = true
[ULUS10529]
DepthRangeHack = true
[ULJM91018] # Infinity demo disc?
DepthRangeHack = true
[NPJH90157] # Infinity demo
DepthRangeHack = true
[ULJM05732]
DepthRangeHack = true
[NPJH50332]
DepthRangeHack = true