From 97ee888aabab3cffd2025b89d5f7e54ec65f59ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 29 May 2022 21:06:20 +0200 Subject: [PATCH 1/5] Add TODO to see if we can make better choices of time sources --- Common/TimeUtil.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Common/TimeUtil.cpp b/Common/TimeUtil.cpp index 99d3288d9914..253dbcb8e3f2 100644 --- a/Common/TimeUtil.cpp +++ b/Common/TimeUtil.cpp @@ -19,6 +19,8 @@ #endif #include +// TODO: https://github.com/floooh/sokol/blob/9a6237fcdf213e6da48e4f9201f144bcb2dcb46f/sokol_time.h#L229-L248 + static double curtime = 0; #ifdef _WIN32 From d88bcaca7872184821fcaa42e49a252aeac0358b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 9 Jun 2022 00:36:58 +0200 Subject: [PATCH 2/5] Bump gradle again, .gitignore update for VS 2022 --- .gitignore | 3 ++- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d4f7f8338d84..700122d992f4 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,7 @@ asciifont_atlas.zim.png ppge_atlas.zim.png local.properties r.sh +Windows/compileData* # For vim *.swp @@ -124,4 +125,4 @@ debian/ppsspp/ CMakeFiles # Clangd -.cache/ \ No newline at end of file +.cache/ diff --git a/build.gradle b/build.gradle index 1f50b57b8d5a..bfad5c141910 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.3' + classpath 'com.android.tools.build:gradle:7.2.1' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 47be57e213ec..0b74ce08816c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip android.useAndroidX=true android.enableJetifier=true From 493c17647ab0650b95da3f0b8c9bab75d8ec9fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Jun 2022 00:03:40 +0200 Subject: [PATCH 3/5] Take the absolute value when measuring pixel size for line expansion. Fixes issues in Echochrome. Though still doesn't look fantastic. --- GPU/Common/SoftwareTransformCommon.cpp | 8 ++++---- GPU/Math3D.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index aed79632680e..762a1d6b1278 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -758,8 +758,8 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, u16 *newInds = inds + vertexCount; u16 *indsOut = newInds; - float dx = 1.0f * gstate_c.vpWidthScale * (1.0f / gstate.getViewportXScale()); - float dy = 1.0f * gstate_c.vpHeightScale * (1.0f / gstate.getViewportYScale()); + float dx = 1.0f * gstate_c.vpWidthScale * (1.0f / fabsf(gstate.getViewportXScale())); + float dy = 1.0f * gstate_c.vpHeightScale * (1.0f / fabsf(gstate.getViewportYScale())); float du = 1.0f / gstate_c.curTextureWidth; float dv = 1.0f / gstate_c.curTextureHeight; @@ -779,8 +779,8 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, const TransformedVertex &transVtxR = transVtx1.x <= transVtx2.x ? transVtx2 : transVtx1; // Sort the points so our perpendicular will bias the right direction. - const TransformedVertex &transVtxTL = transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x ? transVtxT : transVtxB; - const TransformedVertex &transVtxBL = transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x ? transVtxB : transVtxT; + const TransformedVertex &transVtxTL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxT : transVtxB; + const TransformedVertex &transVtxBL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxB : transVtxT; // Okay, let's calculate the perpendicular. float horizontal = transVtxTL.x - transVtxBL.x; diff --git a/GPU/Math3D.cpp b/GPU/Math3D.cpp index 83d31f1d333a..7da413829f4d 100644 --- a/GPU/Math3D.cpp +++ b/GPU/Math3D.cpp @@ -23,6 +23,7 @@ namespace Math3D { template<> float Vec2::Length() const { + // Doubt this is worth it for a vec2 :/ #if defined(_M_SSE) float ret; __m128 xy = _mm_loadu_ps(&x); From c82d8a04e06c84c7774d33cef17d48ff1335f8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Jun 2022 00:20:35 +0200 Subject: [PATCH 4/5] Add centered line drawing for Echochrome. --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + GPU/Common/SoftwareTransformCommon.cpp | 162 +++++++++++++++++-------- assets/compat.ini | 9 ++ 4 files changed, 124 insertions(+), 49 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 7a27543ab4e6..f1be3b94fe04 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -80,6 +80,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "DisableRangeCulling", &flags_.DisableRangeCulling); CheckSetting(iniFile, gameID, "MpegAvcWarmUp", &flags_.MpegAvcWarmUp); CheckSetting(iniFile, gameID, "BlueToAlpha", &flags_.BlueToAlpha); + CheckSetting(iniFile, gameID, "CenteredLines", &flags_.CenteredLines); } void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index fd3e76d7435f..37173adc6dfa 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -79,6 +79,7 @@ struct CompatFlags { bool DisableRangeCulling; bool MpegAvcWarmUp; bool BlueToAlpha; + bool CenteredLines; }; class IniFile; diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 762a1d6b1278..9c2c989c0493 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -769,57 +769,121 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, } maxIndex = 4 * (vertexCount / 2); - for (int i = 0; i < vertexCount; i += 2) { - const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; - const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; - - const TransformedVertex &transVtxT = transVtx1.y <= transVtx2.y ? transVtx1 : transVtx2; - const TransformedVertex &transVtxB = transVtx1.y <= transVtx2.y ? transVtx2 : transVtx1; - const TransformedVertex &transVtxL = transVtx1.x <= transVtx2.x ? transVtx1 : transVtx2; - const TransformedVertex &transVtxR = transVtx1.x <= transVtx2.x ? transVtx2 : transVtx1; - - // Sort the points so our perpendicular will bias the right direction. - const TransformedVertex &transVtxTL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxT : transVtxB; - const TransformedVertex &transVtxBL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxB : transVtxT; - - // Okay, let's calculate the perpendicular. - float horizontal = transVtxTL.x - transVtxBL.x; - float vertical = transVtxTL.y - transVtxBL.y; - Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); - - // bottom right - trans[0] = transVtxBL; - trans[0].x += addWidth.x * dx; - trans[0].y += addWidth.y * dy; - trans[0].u += addWidth.x * du; - trans[0].v += addWidth.y * dv; - - // top right - trans[1] = transVtxTL; - trans[1].x += addWidth.x * dx; - trans[1].y += addWidth.y * dy; - trans[1].u += addWidth.x * du; - trans[1].v += addWidth.y * dv; - - // top left - trans[2] = transVtxTL; - - // bottom left - trans[3] = transVtxBL; - - // Triangle: BR-TR-TL - indsOut[0] = i * 2 + 0; - indsOut[1] = i * 2 + 1; - indsOut[2] = i * 2 + 2; - // Triangle: BL-BR-TL - indsOut[3] = i * 2 + 3; - indsOut[4] = i * 2 + 0; - indsOut[5] = i * 2 + 2; - trans += 4; - indsOut += 6; - numTrans += 6; + if (PSP_CoreParameter().compat.flags().CenteredLines) { + // Lines meant to be pretty in 3D like in Echochrome. + + // We expand them in both directions for symmetry, so we need to halve the expansion. + dx *= 0.5f; + dy *= 0.5f; + + for (int i = 0; i < vertexCount; i += 2) { + const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; + const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; + + // Okay, let's calculate the perpendicular. + float horizontal = transVtx2.x - transVtx1.x; + float vertical = transVtx2.y - transVtx1.y; + Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); + + // bottom right + trans[0] = transVtx2; + trans[0].x += addWidth.x * dx; + trans[0].y += addWidth.y * dy; + trans[0].u += addWidth.x * du; + trans[0].v += addWidth.y * dv; + + // top right + trans[1] = transVtx1; + trans[1].x += addWidth.x * dx; + trans[1].y += addWidth.y * dy; + trans[1].u += addWidth.x * du; + trans[1].v += addWidth.y * dv; + + // top left + trans[2] = transVtx1; + trans[2].x -= addWidth.x * dx; + trans[2].y -= addWidth.y * dy; + trans[2].u -= addWidth.x * du; + trans[2].v -= addWidth.y * dv; + + // bottom left + trans[3] = transVtx2; + trans[3].x -= addWidth.x * dx; + trans[3].y -= addWidth.y * dy; + trans[3].u -= addWidth.x * du; + trans[3].v -= addWidth.y * dv; + + // Triangle: BR-TR-TL + indsOut[0] = i * 2 + 0; + indsOut[1] = i * 2 + 1; + indsOut[2] = i * 2 + 2; + // Triangle: BL-BR-TL + indsOut[3] = i * 2 + 3; + indsOut[4] = i * 2 + 0; + indsOut[5] = i * 2 + 2; + trans += 4; + indsOut += 6; + + numTrans += 6; + } + } else { + // Lines meant to be as closely compatible with upscaled 2D drawing as possible. + // We use this as default. + + for (int i = 0; i < vertexCount; i += 2) { + const TransformedVertex &transVtx1 = transformed[indsIn[i + 0]]; + const TransformedVertex &transVtx2 = transformed[indsIn[i + 1]]; + + const TransformedVertex &transVtxT = transVtx1.y <= transVtx2.y ? transVtx1 : transVtx2; + const TransformedVertex &transVtxB = transVtx1.y <= transVtx2.y ? transVtx2 : transVtx1; + const TransformedVertex &transVtxL = transVtx1.x <= transVtx2.x ? transVtx1 : transVtx2; + const TransformedVertex &transVtxR = transVtx1.x <= transVtx2.x ? transVtx2 : transVtx1; + + // Sort the points so our perpendicular will bias the right direction. + const TransformedVertex &transVtxTL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxT : transVtxB; + const TransformedVertex &transVtxBL = (transVtxT.y != transVtxB.y || transVtxT.x > transVtxB.x) ? transVtxB : transVtxT; + + // Okay, let's calculate the perpendicular. + float horizontal = transVtxTL.x - transVtxBL.x; + float vertical = transVtxTL.y - transVtxBL.y; + Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); + + // bottom right + trans[0] = transVtxBL; + trans[0].x += addWidth.x * dx; + trans[0].y += addWidth.y * dy; + trans[0].u += addWidth.x * du; + trans[0].v += addWidth.y * dv; + + // top right + trans[1] = transVtxTL; + trans[1].x += addWidth.x * dx; + trans[1].y += addWidth.y * dy; + trans[1].u += addWidth.x * du; + trans[1].v += addWidth.y * dv; + + // top left + trans[2] = transVtxTL; + + // bottom left + trans[3] = transVtxBL; + + // Triangle: BR-TR-TL + indsOut[0] = i * 2 + 0; + indsOut[1] = i * 2 + 1; + indsOut[2] = i * 2 + 2; + // Triangle: BL-BR-TL + indsOut[3] = i * 2 + 3; + indsOut[4] = i * 2 + 0; + indsOut[5] = i * 2 + 2; + trans += 4; + indsOut += 6; + + numTrans += 6; + } } + inds = newInds; } diff --git a/assets/compat.ini b/assets/compat.ini index fc17e3e9b1f3..7266ee407403 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1110,3 +1110,12 @@ ULUS10107 = true ULJM05101 = true ULES00724 = true ULJM05320 = true + +[CenteredLines] +# Echochrome looks better with these. Related: #15556 +UCES01011 = true +UCAS40197 = true +NPEG00006 = true +NPUG80135 = true + +UCES From 751afde7c948007aed832c2cc7ec5f68b937cfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Jun 2022 11:22:29 +0200 Subject: [PATCH 5/5] Echochrome lines: Remove UV offsets, avoid reading the destination (much better codegen) --- GPU/Common/SoftwareTransformCommon.cpp | 30 ++++++-------------------- GPU/GPUCommon.h | 7 ++++++ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 9c2c989c0493..98b5adc0799c 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -786,33 +786,17 @@ void SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *&inds, float vertical = transVtx2.y - transVtx1.y; Vec2f addWidth = Vec2f(-vertical, horizontal).Normalized(); - // bottom right - trans[0] = transVtx2; - trans[0].x += addWidth.x * dx; - trans[0].y += addWidth.y * dy; - trans[0].u += addWidth.x * du; - trans[0].v += addWidth.y * dv; + float xoff = addWidth.x * dx; + float yoff = addWidth.y * dy; + // bottom right + trans[0].CopyFromWithOffset(transVtx2, xoff, yoff); // top right - trans[1] = transVtx1; - trans[1].x += addWidth.x * dx; - trans[1].y += addWidth.y * dy; - trans[1].u += addWidth.x * du; - trans[1].v += addWidth.y * dv; - + trans[1].CopyFromWithOffset(transVtx1, xoff, yoff); // top left - trans[2] = transVtx1; - trans[2].x -= addWidth.x * dx; - trans[2].y -= addWidth.y * dy; - trans[2].u -= addWidth.x * du; - trans[2].v -= addWidth.y * dv; - + trans[2].CopyFromWithOffset(transVtx1, -xoff, -yoff); // bottom left - trans[3] = transVtx2; - trans[3].x -= addWidth.x * dx; - trans[3].y -= addWidth.y * dy; - trans[3].u -= addWidth.x * du; - trans[3].v -= addWidth.y * dv; + trans[3].CopyFromWithOffset(transVtx2, -xoff, -yoff); // Triangle: BR-TR-TL indsOut[0] = i * 2 + 0; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 880aceab2573..623842853c88 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -57,6 +57,13 @@ struct TransformedVertex { u8 color1[4]; // prelit u32 color1_32; }; + + + void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) { + this->x = other.x + xoff; + this->y = other.y + yoff; + memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2); + } }; class GPUCommon : public GPUInterface, public GPUDebugInterface {