From 4e0b6ac3ecb6069373873bfc782b35ddca2524d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 14 May 2025 10:04:22 +0200 Subject: [PATCH] More misc cleanup --- Common/TimeUtil.cpp | 5 ++++- Core/HLE/sceKernel.cpp | 4 ++-- Core/System.cpp | 16 +++++++++------- GPU/Common/VertexDecoderCommon.cpp | 2 +- GPU/GPUState.cpp | 23 +++++++++++++++++++++-- GPU/GPUState.h | 8 +------- GPU/Vulkan/PipelineManagerVulkan.cpp | 3 +-- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Common/TimeUtil.cpp b/Common/TimeUtil.cpp index 8522109d66..5169f71afc 100644 --- a/Common/TimeUtil.cpp +++ b/Common/TimeUtil.cpp @@ -289,7 +289,10 @@ void sleep_precise(double seconds) { LARGE_INTEGER due; due.QuadPart = -(sleepTicks > maxTicks ? maxTicks : sleepTicks); // Note: SetWaitableTimerEx is not available on Vista. - SetWaitableTimer(Timer, &due, 0, NULL, NULL, FALSE); + if (!SetWaitableTimer(Timer, &due, 0, NULL, NULL, FALSE)) { + _dbg_assert_(false); + break; + } WaitForSingleObject(Timer, INFINITE); QueryPerformanceCounter(&qpc); } diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index a20ba965a2..1596ebe618 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -360,11 +360,11 @@ u32 sceKernelDevkitVersion() } u32 sceKernelRegisterKprintfHandler() { - return hleLogError(Log::sceKernel, 0, "UNIMPL"); + return hleLogWarning(Log::sceKernel, 0, "UNIMPL"); } int sceKernelRegisterDefaultExceptionHandler() { - return hleLogError(Log::sceKernel, 0, "UNIMPL"); + return hleLogWarning(Log::sceKernel, 0, "UNIMPL"); } void sceKernelSetGPO(u32 ledBits) { diff --git a/Core/System.cpp b/Core/System.cpp index 4ca9d52a01..88e1a99228 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -582,19 +582,21 @@ bool PSP_InitStart(const CoreParameter &coreParam) { } BootState PSP_InitUpdate(std::string *error_string) { - if (g_bootState == BootState::Booting || g_bootState == BootState::Off) { + const BootState bootState = g_bootState; + + if (bootState == BootState::Booting || bootState == BootState::Off) { // Nothing to do right now. - _dbg_assert_(g_bootState == BootState::Booting || !g_loadingThread.joinable()); - return g_bootState; + _dbg_assert_(bootState == BootState::Booting || !g_loadingThread.joinable()); + return bootState; } - _dbg_assert_(g_bootState == BootState::Complete || g_bootState == BootState::Failed); + _dbg_assert_(bootState == BootState::Complete || bootState == BootState::Failed); // Since we load on a background thread, wait for startup to complete. - _assert_msg_(g_loadingThread.joinable(), "bootstate: %d", (int)g_bootState); + _assert_msg_(g_loadingThread.joinable(), "bootstate: %d", (int)bootState); g_loadingThread.join(); - if (g_bootState == BootState::Failed) { + if (bootState == BootState::Failed) { // Failed! (Note: PSP_Shutdown was already called on the loader thread). Core_NotifyLifecycle(CoreLifecycle::START_COMPLETE); *error_string = g_CoreParameter.errorString; @@ -627,7 +629,7 @@ BootState PSP_InitUpdate(std::string *error_string) { Core_NotifyLifecycle(CoreLifecycle::START_COMPLETE); // The thread should have set it at this point. - _dbg_assert_(g_bootState == BootState::Complete); + _dbg_assert_(bootState == BootState::Complete); return BootState::Complete; } diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 460f18c119..11a75d1269 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -107,7 +107,7 @@ void DecVtxFormat::InitializeFromID(uint32_t id) { void GetIndexBounds(const void *inds, int count, u32 vertType, u16 *indexLowerBound, u16 *indexUpperBound) { // Find index bounds. Could cache this in display lists. // Also, this could be greatly sped up with SSE2/NEON, although rarely a bottleneck, and some compilers - // autovectorize this just fine. + // autovectorize this just fine. (Though, it should be noted, MSVC generates really crap code here...). u32 idx = vertType & GE_VTYPE_IDX_MASK; if (idx == GE_VTYPE_IDX_16BIT) { uint16_t upperBound = 0; diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index 1049b8be96..010430c597 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -362,7 +362,7 @@ void GPUStateCache::DoState(PointerWrap &p) { gstate_c.Dirty(DIRTY_CULL_PLANES); } -static const char *const gpuUseFlagNames[32] = { +static const char *const g_gpuUseFlagNames[32] = { "GPU_USE_DUALSOURCE_BLEND", "GPU_USE_LIGHT_UBERSHADER", "GPU_USE_FRAGMENT_TEST_CACHE", @@ -399,8 +399,27 @@ static const char *const gpuUseFlagNames[32] = { const char *GpuUseFlagToString(int useFlag) { if ((u32)useFlag < 32) { - return gpuUseFlagNames[useFlag]; + return g_gpuUseFlagNames[useFlag]; } else { return "N/A"; } } + +bool GPUStateCache::SetUseFlags(const u32 newFlags) { + if (newFlags != useFlags_) { + if (useFlags_ != 0 && newFlags != 0) { + INFO_LOG(Log::G3D, "Shader useflags changed from %08x to %08x:", useFlags_, newFlags); + for (int i = 0; i < 32; i++) { + const int mask = 1 << i; + bool oldVal = (useFlags_ & mask) != 0; + bool newVal = (newFlags & mask) != 0; + if (oldVal != newVal) { + INFO_LOG(Log::G3D, "%s changed from %d to %d", g_gpuUseFlagNames[i], (int)oldVal, (int)newVal); + } + } + useFlagsChanged = true; + } + useFlags_ = newFlags; + } + return useFlagsChanged; +} diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 0cb0517028..b7427b7d1f 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -578,13 +578,7 @@ struct GPUStateCache { Dirty(DIRTY_UVSCALEOFFSET); } } - void SetUseFlags(u32 newFlags) { - if (newFlags != useFlags_) { - if (useFlags_ != 0) - useFlagsChanged = true; - useFlags_ = newFlags; - } - } + bool SetUseFlags(u32 newFlags); // When checking for a single flag, use Use()/UseAll(). u32 GetUseFlags() const { diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 06cbcc83c6..4954087149 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -833,7 +833,6 @@ bool PipelineManagerVulkan::LoadPipelineCache(FILE *file, bool loadRawPipelineCa rm->NudgeCompilerThread(); - NOTICE_LOG(Log::G3D, "Recreated Vulkan pipeline cache (%d pipelines, %d failed).", (int)size, pipelineCreateFailCount); - // We just ignore any failures. + // The rest of the work is async, we can't know here if it'll succeed. return true; }