From d7224a84019aaeaa4bc53c0af2fe4ae6c3a6414d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 1 Dec 2022 23:12:14 -0800 Subject: [PATCH 1/3] GE Debugger: Cleanup logspam on game exit. If you're stopped on a frame and quit, it was previously logging every command as it exited, thinking it was waiting on each. --- GPU/Debugger/Debugger.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GPU/Debugger/Debugger.cpp b/GPU/Debugger/Debugger.cpp index fa55ec6b8e..16143b882f 100644 --- a/GPU/Debugger/Debugger.cpp +++ b/GPU/Debugger/Debugger.cpp @@ -134,6 +134,11 @@ bool NotifyCommand(u32 pc) { if (IsBreakpoint(pc, op)) { GPUBreakpoints::ClearTempBreakpoints(); + if (coreState == CORE_POWERDOWN || !gpuDebug) { + breakNext = BreakNext::NONE; + return process; + } + auto info = gpuDebug->DissassembleOp(pc); if (lastStepTime >= 0.0) { NOTICE_LOG(G3D, "Waiting at %08x, %s (%fms)", pc, info.desc.c_str(), (time_now_d() - lastStepTime) * 1000.0); From 33abbca464114925dc06f8238726e07cc0dec264 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 1 Dec 2022 23:13:20 -0800 Subject: [PATCH 2/3] softgpu: Optimize out texture proj for UVs. Seen in NFS Most Wanted 5-1-0. --- GPU/Software/Rasterizer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 9677078805..18244fc105 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -132,7 +132,12 @@ void ComputeRasterizerState(RasterizerState *state, std::function flushF state->textureProj = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; if (state->textureProj) { // We may be able to optimize this off. This is actually kinda common. - if (gstate.tgenMatrix[2] == 0.0f && gstate.tgenMatrix[5] == 0.0f && gstate.tgenMatrix[8] == 0.0f && gstate.tgenMatrix[11] == 1.0f) { + const bool qZeroST = gstate.tgenMatrix[2] == 0.0f && gstate.tgenMatrix[5] == 0.0f; + const bool qZeroQ = gstate.tgenMatrix[8] == 0.0f; + + // Two common cases: the source q factor is zero, OR source is UV. + const bool qFactorZero = gstate.getUVProjMode() == GE_PROJMAP_UV; + if (qZeroST && (qZeroQ || qFactorZero) && gstate.tgenMatrix[11] == 1.0f) { state->textureProj = false; } } From 106d730a2053f0ea1ea7e0819c20dfa3c77d6948 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 1 Dec 2022 23:20:25 -0800 Subject: [PATCH 3/3] GPU: Optimize out common case texture proj. NFS Most Wanted 5-1-0 uses this when it could use uv scale/offset. --- GPU/Common/ShaderId.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index e572f721de..cb9b10af75 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -173,8 +173,9 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; -static bool MatrixNeedsProjection(const float m[12]) { - return m[2] != 0.0f || m[5] != 0.0f || m[8] != 0.0f || m[11] != 1.0f; +static bool MatrixNeedsProjection(const float m[12], GETexProjMapMode mode) { + // For GE_PROJMAP_UV, we can ignore m[8] since it multiplies to zero. + return m[2] != 0.0f || m[5] != 0.0f || (m[8] != 0.0f && mode != GE_PROJMAP_UV) || m[11] != 1.0f; } std::string FragmentShaderDesc(const FShaderID &id) { @@ -283,7 +284,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue(); bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue(); bool enableColorDoubling = gstate.isColorDoublingEnabled() && gstate.isTextureMapEnabled(); - bool doTextureProjection = (gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX && MatrixNeedsProjection(gstate.tgenMatrix)); + bool doTextureProjection = (gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX && MatrixNeedsProjection(gstate.tgenMatrix, gstate.getUVProjMode())); bool doTextureAlpha = gstate.isTextureAlphaUsed(); bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT;