From 5afc020fbdbf6e9f9139fbc4919430af3a652285 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 5 Apr 2020 16:35:13 -0700 Subject: [PATCH 1/4] x86jit: Force INF * 0 to +NAN. See #12519 - this is needed for some graphics to render properly. Seems to already happen on ARM, so no change to armjit. --- Core/MIPS/IR/IRInterpreter.cpp | 6 +++++- Core/MIPS/MIPSInt.cpp | 9 ++++++++- Core/MIPS/x86/CompFPU.cpp | 25 ++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Core/MIPS/IR/IRInterpreter.cpp b/Core/MIPS/IR/IRInterpreter.cpp index 13753c78ac..9a4e491228 100644 --- a/Core/MIPS/IR/IRInterpreter.cpp +++ b/Core/MIPS/IR/IRInterpreter.cpp @@ -708,7 +708,11 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) { mips->f[inst->dest] = mips->f[inst->src1] - mips->f[inst->src2]; break; case IROp::FMul: - mips->f[inst->dest] = mips->f[inst->src1] * mips->f[inst->src2]; + if ((my_isinf(mips->f[inst->src1]) && mips->f[inst->src2] == 0.0f) || (my_isinf(mips->f[inst->src2]) && mips->f[inst->src1] == 0.0f)) { + mips->fi[inst->dest] = 0x7fc00000; + } else { + mips->f[inst->dest] = mips->f[inst->src1] * mips->f[inst->src2]; + } break; case IROp::FDiv: mips->f[inst->dest] = mips->f[inst->src1] / mips->f[inst->src2]; diff --git a/Core/MIPS/MIPSInt.cpp b/Core/MIPS/MIPSInt.cpp index 903386a08e..93372391c8 100644 --- a/Core/MIPS/MIPSInt.cpp +++ b/Core/MIPS/MIPSInt.cpp @@ -974,7 +974,14 @@ namespace MIPSInt { case 0: F(fd) = F(fs) + F(ft); break; // add.s case 1: F(fd) = F(fs) - F(ft); break; // sub.s - case 2: F(fd) = F(fs) * F(ft); break; // mul.s + case 2: // mul.s + if ((my_isinf(F(fs)) && F(ft) == 0.0f) || (my_isinf(F(ft)) && F(fs) == 0.0f)) { + // Must be positive NAN, see #12519. + FI(fd) = 0x7fc00000; + } else { + F(fd) = F(fs) * F(ft); + } + break; case 3: F(fd) = F(fs) / F(ft); break; // div.s default: _dbg_assert_msg_(CPU,0,"Trying to interpret FPU3Op instruction that can't be interpreted"); diff --git a/Core/MIPS/x86/CompFPU.cpp b/Core/MIPS/x86/CompFPU.cpp index 1220f2a382..806d631047 100644 --- a/Core/MIPS/x86/CompFPU.cpp +++ b/Core/MIPS/x86/CompFPU.cpp @@ -50,6 +50,8 @@ namespace MIPSComp { using namespace Gen; using namespace X64JitConstants; +alignas(16) const u32 reverseQNAN[4] = { 0x803FFFFF, 0x803FFFFF, 0x803FFFFF, 0x803FFFFF }; + void Jit::CopyFPReg(X64Reg dst, OpArg src) { if (src.IsSimpleReg()) { MOVAPS(dst, src); @@ -90,7 +92,28 @@ void Jit::Comp_FPU3op(MIPSOpcode op) { switch (op & 0x3f) { case 0: CompFPTriArith(op, &XEmitter::ADDSS, false); break; //F(fd) = F(fs) + F(ft); //add case 1: CompFPTriArith(op, &XEmitter::SUBSS, true); break; //F(fd) = F(fs) - F(ft); //sub - case 2: CompFPTriArith(op, &XEmitter::MULSS, false); break; //F(fd) = F(fs) * F(ft); //mul + case 2: //F(fd) = F(fs) * F(ft); //mul + // XMM1 = !my_isnan(fs) && !my_isnan(ft) + MOVSS(XMM1, fpr.R(_FS)); + CMPORDSS(XMM1, fpr.R(_FT)); + CompFPTriArith(op, &XEmitter::MULSS, false); + + // fd must still be in a reg, save it in XMM0 for now. + MOVAPS(XMM0, fpr.R(_FD)); + // fd = my_isnan(fd) && !my_isnan(fs) && !my_isnan(ft) + CMPUNORDSS(fpr.RX(_FD), fpr.R(_FD)); + ANDPS(fpr.RX(_FD), R(XMM1)); + // At this point fd = FFFFFFFF if non-NAN inputs produced a NAN output. + // We'll AND it with the inverse QNAN bits to clear (00000000 means no change.) + if (RipAccessible(&reverseQNAN)) { + ANDPS(fpr.RX(_FD), M(&reverseQNAN)); // rip accessible + } else { + MOV(PTRBITS, R(TEMPREG), ImmPtr(&reverseQNAN)); + ANDPS(fpr.RX(_FD), MatR(TEMPREG)); + } + // ANDN is backwards, which is why we saved XMM0 to start. Now put it back. + ANDNPS(fpr.RX(_FD), R(XMM0)); + break; case 3: CompFPTriArith(op, &XEmitter::DIVSS, true); break; //F(fd) = F(fs) / F(ft); //div default: _dbg_assert_msg_(CPU,0,"Trying to compile FPU3Op instruction that can't be interpreted"); From fe72bc19a81bff6eb0aa2a8e8a79d57c3d165b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 6 Apr 2020 23:38:26 +0200 Subject: [PATCH 2/4] Update gradle again --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 17457e9c80..40261aa712 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.1' + classpath 'com.android.tools.build:gradle:3.6.2' } } From a5ede2bed3ad25b9fe142d71310660c5855aa684 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 7 Apr 2020 22:49:07 -0700 Subject: [PATCH 3/4] GLES: Re-enable non-float depal shader path. Was accidentally always detected as unsupported. --- GPU/GLES/DepalettizeShaderGLES.cpp | 4 +++- GPU/GLES/DepalettizeShaderGLES.h | 1 + GPU/GLES/GPU_GLES.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/DepalettizeShaderGLES.cpp b/GPU/GLES/DepalettizeShaderGLES.cpp index 821371a794..5abe33d77c 100644 --- a/GPU/GLES/DepalettizeShaderGLES.cpp +++ b/GPU/GLES/DepalettizeShaderGLES.cpp @@ -54,8 +54,10 @@ void main() { DepalShaderCacheGLES::DepalShaderCacheGLES(Draw::DrawContext *draw) { _assert_(draw); render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); - // Pre-build the vertex program useGL3_ = gl_extensions.GLES3 || gl_extensions.VersionGEThan(3, 3); +} + +void DepalShaderCacheGLES::Init() { if (!gstate_c.Supports(GPU_SUPPORTS_32BIT_INT_FSHADER)) { // Use the floating point path, it just can't handle the math. useGL3_ = false; diff --git a/GPU/GLES/DepalettizeShaderGLES.h b/GPU/GLES/DepalettizeShaderGLES.h index 9030d7c504..4368780ebd 100644 --- a/GPU/GLES/DepalettizeShaderGLES.h +++ b/GPU/GLES/DepalettizeShaderGLES.h @@ -49,6 +49,7 @@ public: // This also uploads the palette and binds the correct texture. DepalShader *GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat); GLRTexture *GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut); + void Init(); void Clear(); void Decimate(); std::vector DebugGetShaderIDs(DebugShaderType type); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index d21b583997..b956fcabbf 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -75,6 +75,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) framebufferManagerGL_->SetTextureCache(textureCacheGL_); framebufferManagerGL_->SetShaderManager(shaderManagerGL_); framebufferManagerGL_->SetDrawEngine(&drawEngine_); + depalShaderCache_.Init(); textureCacheGL_->SetFramebufferManager(framebufferManagerGL_); textureCacheGL_->SetDepalShaderCache(&depalShaderCache_); textureCacheGL_->SetShaderManager(shaderManagerGL_); From 580c74c3e71204a321ce185a3d8a7f7c799608e8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 7 Apr 2020 23:34:01 -0700 Subject: [PATCH 4/4] Audio: Remove latency setting. This setting only changes some internal values that are shown in tests not to match PSP behavior. Removed, it now matches how the PSP works. This setting wasn't really affecting any actual audio latency. See #11844. --- Core/Config.cpp | 1 - Core/Config.h | 1 - Core/HLE/__sceAudio.cpp | 31 ++++--------------------------- UI/GameSettingsScreen.cpp | 3 --- headless/Headless.cpp | 1 - libretro/libretro.cpp | 3 --- 6 files changed, 4 insertions(+), 36 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 31f8e26474..4096e3ca41 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -785,7 +785,6 @@ static ConfigSetting graphicsSettings[] = { static ConfigSetting soundSettings[] = { ConfigSetting("Enable", &g_Config.bEnableSound, true, true, true), ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, true, true), - ConfigSetting("AudioLatency", &g_Config.iAudioLatency, 1, true, true), ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, true, false), ConfigSetting("AudioResampler", &g_Config.bAudioResampler, true, true, true), ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true), diff --git a/Core/Config.h b/Core/Config.h index c2d3d4738f..ebc2cfbaf6 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -212,7 +212,6 @@ public: // Sound bool bEnableSound; - int iAudioLatency; // 0 = low , 1 = medium(default) , 2 = high int iAudioBackend; int iGlobalVolume; int iAltSpeedVolume; diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index b6e7179ea1..31573526ad 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -53,12 +53,6 @@ AudioDebugStats g_AudioDebugStats; // atomic locks are used on the lock. TODO: make this lock-free std::atomic_flag atomicLock_; -enum latency { - LOW_LATENCY = 0, - MEDIUM_LATENCY = 1, - HIGH_LATENCY = 2, -}; - int eventAudioUpdate = -1; int eventHostAudioUpdate = -1; int mixFrequency = 44100; @@ -110,27 +104,10 @@ void __AudioInit() { mixFrequency = 44100; srcFrequency = 0; - switch (g_Config.iAudioLatency) { - case LOW_LATENCY: - chanQueueMaxSizeFactor = 1; - chanQueueMinSizeFactor = 1; - hwBlockSize = 16; - hostAttemptBlockSize = 256; - break; - case MEDIUM_LATENCY: - chanQueueMaxSizeFactor = 2; - chanQueueMinSizeFactor = 1; - hwBlockSize = 64; - hostAttemptBlockSize = 512; - break; - case HIGH_LATENCY: - chanQueueMaxSizeFactor = 4; - chanQueueMinSizeFactor = 2; - hwBlockSize = 64; - hostAttemptBlockSize = 512; - break; - - } + chanQueueMaxSizeFactor = 2; + chanQueueMinSizeFactor = 1; + hwBlockSize = 64; + hostAttemptBlockSize = 512; __AudioCPUMHzChange(); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 2ab1e6beb5..cce96c14c0 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -542,9 +542,6 @@ void GameSettingsScreen::CreateViews() { audioSettings->Add(new CheckBox(&g_Config.bAutoAudioDevice, a->T("Switch on new audio device"))); #endif - static const char *latency[] = { "Low", "Medium", "High" }; - PopupMultiChoice *lowAudio = audioSettings->Add(new PopupMultiChoice(&g_Config.iAudioLatency, a->T("Audio Latency"), latency, 0, ARRAY_SIZE(latency), gr->GetName(), screenManager())); - lowAudio->SetEnabledPtr(&g_Config.bEnableSound); #if defined(__ANDROID__) CheckBox *extraAudio = audioSettings->Add(new CheckBox(&g_Config.bExtraAudioBuffering, a->T("AudioBufferingForBluetooth", "Bluetooth-friendly buffer (slower)"))); extraAudio->SetEnabledPtr(&g_Config.bEnableSound); diff --git a/headless/Headless.cpp b/headless/Headless.cpp index e4bf04fa66..02b65dd53c 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -392,7 +392,6 @@ int main(int argc, const char* argv[]) g_Config.bHighQualityDepth = true; g_Config.bMemStickInserted = true; g_Config.bFragmentTestCache = true; - g_Config.iAudioLatency = 1; g_Config.bEnableWlan = true; g_Config.sMACAddress = "12:34:56:78:9A:BC"; diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index ea277d64b6..4df14d381a 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -170,7 +170,6 @@ static RetroOption ppsspp_rendering_mode("ppsspp_rendering_mode", "Renderin static RetroOption ppsspp_auto_frameskip("ppsspp_auto_frameskip", "Auto Frameskip", false); static RetroOption ppsspp_frameskip("ppsspp_frameskip", "Frameskip", 0, 10); static RetroOption ppsspp_frameskiptype("ppsspp_frameskiptype", "Frameskip Type", 0, 10); -static RetroOption ppsspp_audio_latency("ppsspp_audio_latency", "Audio latency", { "low", "medium", "high" }); static RetroOption ppsspp_internal_resolution("ppsspp_internal_resolution", "Internal Resolution (restart)", 1, { "480x272", "960x544", "1440x816", "1920x1088", "2400x1360", "2880x1632", "3360x1904", "3840x2176", "4320x2448", "4800x2720" }); static RetroOption ppsspp_button_preference("ppsspp_button_preference", "Confirmation Button", { { "cross", PSP_SYSTEMPARAM_BUTTON_CROSS }, { "circle", PSP_SYSTEMPARAM_BUTTON_CIRCLE } }); static RetroOption ppsspp_fast_memory("ppsspp_fast_memory", "Fast Memory (Speedhack)", true); @@ -196,7 +195,6 @@ void retro_set_environment(retro_environment_t cb) { vars.push_back(ppsspp_auto_frameskip.GetOptions()); vars.push_back(ppsspp_frameskip.GetOptions()); vars.push_back(ppsspp_frameskiptype.GetOptions()); - vars.push_back(ppsspp_audio_latency.GetOptions()); vars.push_back(ppsspp_internal_resolution.GetOptions()); vars.push_back(ppsspp_button_preference.GetOptions()); vars.push_back(ppsspp_fast_memory.GetOptions()); @@ -265,7 +263,6 @@ static void check_variables(CoreParameter &coreParam) { ppsspp_gpu_hardware_transform.Update(&g_Config.bHardwareTransform); ppsspp_frameskip.Update(&g_Config.iFrameSkip); ppsspp_frameskiptype.Update(&g_Config.iFrameSkipType); - ppsspp_audio_latency.Update(&g_Config.iAudioLatency); ppsspp_auto_frameskip.Update(&g_Config.bAutoFrameSkip); ppsspp_block_transfer_gpu.Update(&g_Config.bBlockTransferGPU); ppsspp_texture_filtering.Update(&g_Config.iTexFiltering);