Reduce lag in MK8 and Need for Speed Most Wanted U

This commit is contained in:
Maschell 2023-01-26 12:55:37 +01:00
parent fe5444d2be
commit 0ba843dab7
6 changed files with 34 additions and 3 deletions

View File

@ -41,6 +41,9 @@ ON_APPLICATION_START() {
gShortNameEn = GetSanitizedNameOfCurrentApplication();
startFSIOThreads();
ApplyGameSpecificPatches();
VPADSetTVMenuInvalid(VPAD_CHAN_0, true);
}

View File

@ -20,3 +20,5 @@ bool gInProgressNotificationDisplayedTV = false;
bool gNotAvailableNotificationDisplayed = false;
NMColor COLOR_RED = {237, 28, 36, 255};
int32_t gThreadPriorityIncrease = 1;

View File

@ -23,3 +23,5 @@ extern bool gInProgressNotificationDisplayedTV;
extern bool gNotAvailableNotificationDisplayed;
extern NMColor COLOR_RED;
extern int32_t gThreadPriorityIncrease;

View File

@ -217,7 +217,7 @@ bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2Surf
bool res;
auto threadPriority = OSGetThreadPriority(OSGetCurrentThread()) + 1;
auto threadPriority = OSGetThreadPriority(OSGetCurrentThread()) + gThreadPriorityIncrease;
if (threadPriority != OSGetThreadPriority(gThreadData.thread)) {
DEBUG_FUNCTION_LINE_ERR("INFO! Set thread priority to %d", threadPriority);
if (!OSSetThreadPriority(gThreadData.thread, threadPriority)) {

View File

@ -1,5 +1,6 @@
#include "StringTools.h"
#include "logger.h"
#include "retain_vars.hpp"
#include <coreinit/title.h>
#include <malloc.h>
#include <nn/acp/client.h>
@ -76,3 +77,24 @@ std::string GetSanitizedNameOfCurrentApplication() {
}
return result;
}
void ApplyGameSpecificPatches() {
uint64_t titleID = OSGetTitleID();
// Mario Kart 8 has noticeable slowdown when taking screenshots in multiplayer
// Decrease the IO thread priority to fix this
if (titleID == 0x000500001010ED00L || // Mario Kart 8 EUR
titleID == 0x000500001010EB00L || // Mario Kart 8 JPN
titleID == 0x000500001010EC00L) { // Mario Kart 8 USA
gThreadPriorityIncrease = 2;
} else if (titleID == 0x0005000010128400L || // Need for Speed™ Most Wanted U EUR
titleID == 0x0005000010128800L || // Need for Speed™ Most Wanted U USA
titleID == 0x000500001012B700L) { // Need for Speed™ Most Wanted U JPN
gThreadPriorityIncrease = 14;
} else if (titleID == 0x0005000010101E00L || // New SUPER MARIO BROS. U EUR
titleID == 0x0005000010101D00L || // New SUPER MARIO BROS. U USA
titleID == 0x0005000010101C00L) { // NNew SUPER MARIO BROS. U JPN
gThreadPriorityIncrease = 2;
} else {
gThreadPriorityIncrease = 1;
}
}

View File

@ -15,3 +15,5 @@ inline uint8_t RGBComponentToSRGB(uint8_t ci) {
}
std::string GetSanitizedNameOfCurrentApplication();
void ApplyGameSpecificPatches();