From 0a1985e481e0dfb70dbde229ba4c650c9363fffa Mon Sep 17 00:00:00 2001 From: Timothy Redaelli Date: Wed, 7 Sep 2022 16:54:48 +0200 Subject: [PATCH 1/6] Set timer milliseconds for "Controller settings" (#194) This is needed to avoid having the Controller settings window black on Linux --- src/gui/input/settings/DefaultControllerSettings.cpp | 2 +- src/gui/input/settings/WiimoteControllerSettings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/input/settings/DefaultControllerSettings.cpp b/src/gui/input/settings/DefaultControllerSettings.cpp index 1ad4d8f4..678a792d 100644 --- a/src/gui/input/settings/DefaultControllerSettings.cpp +++ b/src/gui/input/settings/DefaultControllerSettings.cpp @@ -216,7 +216,7 @@ DefaultControllerSettings::DefaultControllerSettings(wxWindow* parent, const wxP m_timer = new wxTimer(this); Bind(wxEVT_TIMER, &DefaultControllerSettings::on_timer, this); - m_timer->Start(); + m_timer->Start(100); } DefaultControllerSettings::~DefaultControllerSettings() diff --git a/src/gui/input/settings/WiimoteControllerSettings.cpp b/src/gui/input/settings/WiimoteControllerSettings.cpp index 05e0a24c..a1ea4ecf 100644 --- a/src/gui/input/settings/WiimoteControllerSettings.cpp +++ b/src/gui/input/settings/WiimoteControllerSettings.cpp @@ -234,7 +234,7 @@ WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxP m_timer = new wxTimer(this); Bind(wxEVT_TIMER, &WiimoteControllerSettings::on_timer, this); - m_timer->Start(); + m_timer->Start(100); } WiimoteControllerSettings::~WiimoteControllerSettings() From b752d2eddd6dcc149d1e3379a52d236c7b79e7af Mon Sep 17 00:00:00 2001 From: Jun Bo Bi <21069675+jambonmcyeah@users.noreply.github.com> Date: Wed, 7 Sep 2022 12:22:40 -0400 Subject: [PATCH 2/6] fix clang-cl (#202) --- src/Cafe/HW/Espresso/PPCTimer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Espresso/PPCTimer.cpp b/src/Cafe/HW/Espresso/PPCTimer.cpp index e147ac25..0ab6d77d 100644 --- a/src/Cafe/HW/Espresso/PPCTimer.cpp +++ b/src/Cafe/HW/Espresso/PPCTimer.cpp @@ -111,7 +111,7 @@ uint64 PPCTimer_tscToMicroseconds(uint64 us) uint64 remainder; -#if defined(_MSC_VER) && _MSC_VER >= 1923 +#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__) const uint64 microseconds = _udiv128(r.high, r.low, _rdtscFrequency, &remainder); #else const uint64 microseconds = udiv128(r.low, r.high, _rdtscFrequency, &remainder); @@ -159,7 +159,7 @@ uint64 PPCTimer_getFromRDTSC() #endif uint64 remainder; -#if defined(_MSC_VER) && _MSC_VER >= 1923 +#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__) uint64 elapsedTick = _udiv128(_rdtscAcc.high, _rdtscAcc.low, _rdtscFrequency, &remainder); #else uint64 elapsedTick = udiv128(_rdtscAcc.low, _rdtscAcc.high, _rdtscFrequency, &remainder); From 4d1be950e39c00d0cb62d7ad770d441e3b30c49f Mon Sep 17 00:00:00 2001 From: bslhq Date: Thu, 8 Sep 2022 01:58:56 +0800 Subject: [PATCH 3/6] Fix various issues related to title names (#192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed various issues related to title names: 1. If console language is set to non-English, the title names in Title Manager may be empty. 2. Game list do not show custom names if list style set to icon or small icon. 3. Custom title names for some languages (like JP or CN) appear confusing if re-edited. 4. Unexpected overrides of variable values in ParsedMetaXml.h --- src/Cafe/TitleList/ParsedMetaXml.h | 6 +++--- src/gui/components/wxGameList.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Cafe/TitleList/ParsedMetaXml.h b/src/Cafe/TitleList/ParsedMetaXml.h index 59cdaf87..2cb2e7a8 100644 --- a/src/Cafe/TitleList/ParsedMetaXml.h +++ b/src/Cafe/TitleList/ParsedMetaXml.h @@ -18,12 +18,12 @@ struct ParsedMetaXml std::string GetShortName(CafeConsoleLanguage languageId) const { - return m_short_name[(size_t)languageId]; + return m_short_name[(size_t)languageId].empty() ? m_short_name[(size_t)CafeConsoleLanguage::EN] : m_short_name[(size_t)languageId]; } std::string GetLongName(CafeConsoleLanguage languageId) const { - return m_long_name[(size_t)languageId]; + return m_long_name[(size_t)languageId].empty() ? m_long_name[(size_t)CafeConsoleLanguage::EN] : m_long_name[(size_t)languageId]; } TitleId GetTitleId() const @@ -134,7 +134,7 @@ private: else if (language == "ru") return (sint32)CafeConsoleLanguage::RU; else if (language == "zht") - return (sint32)CafeConsoleLanguage::ZH; + return (sint32)CafeConsoleLanguage::TW; // if return ZH here, xxx_zht values may cover xxx_zh values in function Parse() return -1; } }; diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 87eb5cdd..68dde7c6 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -536,7 +536,7 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event) std::string customName = ""; if (!GetConfig().GetGameListCustomName(title_id, customName)) customName.clear(); - wxTextEntryDialog dialog(this, wxEmptyString, L"Enter a custom game title", customName); + wxTextEntryDialog dialog(this, wxEmptyString, _("Enter a custom game title"), wxHelper::FromUtf8(customName)); if(dialog.ShowModal() == wxID_OK) { const auto custom_name = dialog.GetValue(); @@ -859,7 +859,7 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event) if(index == wxNOT_FOUND) { // entry doesn't exist - index = InsertItem(FindInsertPosition(baseTitleId), wxHelper::FromUtf8(gameInfo.GetTitleName())); + index = InsertItem(FindInsertPosition(baseTitleId), wxHelper::FromUtf8(GetNameByTitleId(baseTitleId))); SetItemPtrData(index, baseTitleId); isNewEntry = true; } From 4eaa600b57f525a5415230d27fee9e49705b6478 Mon Sep 17 00:00:00 2001 From: bitscher Date: Wed, 7 Sep 2022 11:04:32 -0700 Subject: [PATCH 4/6] Fix various compiler warnings given by Clang (#170) --- .../HW/Latte/Core/LatteGSCopyShaderParser.cpp | 2 +- .../HW/Latte/Core/LattePerformanceMonitor.h | 30 +++++++++---------- src/Cafe/IOSU/legacy/iosu_acp.cpp | 4 ++- .../OS/libs/coreinit/coreinit_Callbacks.cpp | 2 -- .../libs/coreinit/coreinit_MEM_BlockHeap.cpp | 4 +-- .../libs/coreinit/coreinit_MemoryMapping.cpp | 4 +-- src/Cafe/OS/libs/snd_core/ax_ist.cpp | 2 +- src/Cemu/Logging/CemuDebugLogging.h | 6 ++-- 8 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteGSCopyShaderParser.cpp b/src/Cafe/HW/Latte/Core/LatteGSCopyShaderParser.cpp index 58d3b635..7df5eecd 100644 --- a/src/Cafe/HW/Latte/Core/LatteGSCopyShaderParser.cpp +++ b/src/Cafe/HW/Latte/Core/LatteGSCopyShaderParser.cpp @@ -242,7 +242,7 @@ LatteParsedGSCopyShader* LatteGSCopyShaderParser_parse(uint8* programData, uint3 // verify if all registers are exported for(sint32 i=0; inumParam; i++) { - if( shaderContext->paramMapping[i].exportParam == 0xFFFF ) + if( shaderContext->paramMapping[i].exportParam == 0xFF ) debugBreakpoint(); } return shaderContext; diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h index 6cd07ee2..77554e80 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h @@ -76,23 +76,23 @@ typedef struct struct { // CPU - volatile uint64 lastCycleCount; - volatile uint64 skippedCycles; - volatile uint32 recompilerLeaveCount; // increased everytime the recompiler switches back to interpreter - volatile uint32 threadLeaveCount; // increased everytime a thread gives up it's timeslice + uint64 lastCycleCount; + uint64 skippedCycles; + uint32 recompilerLeaveCount; // increased everytime the recompiler switches back to interpreter + uint32 threadLeaveCount; // increased everytime a thread gives up it's timeslice // GPU - volatile uint32 lastUpdate; - volatile uint32 frameCounter; - volatile uint32 drawCallCounter; - volatile uint32 shaderBindCount; - volatile uint64 vertexDataUploaded; // amount of vertex data uploaded to GPU (bytes) - volatile uint64 vertexDataCached; // amount of vertex data reused from GPU cache (bytes) - volatile uint64 uniformBankUploadedData; // amount of uniform buffer data (excluding remapped uniforms) uploaded to GPU - volatile uint64 uniformBankUploadedCount; // number of separate uploads for uniformBankDataUploaded - volatile uint64 indexDataUploaded; - volatile uint64 indexDataCached; + uint32 lastUpdate; + uint32 frameCounter; + uint32 drawCallCounter; + uint32 shaderBindCount; + uint64 vertexDataUploaded; // amount of vertex data uploaded to GPU (bytes) + uint64 vertexDataCached; // amount of vertex data reused from GPU cache (bytes) + uint64 uniformBankUploadedData; // amount of uniform buffer data (excluding remapped uniforms) uploaded to GPU + uint64 uniformBankUploadedCount; // number of separate uploads for uniformBankDataUploaded + uint64 indexDataUploaded; + uint64 indexDataCached; }cycle[PERFORMANCE_MONITOR_TRACK_CYCLES]; - volatile sint32 cycleIndex; + sint32 cycleIndex; // new stats LattePerfStatTimer gpuTime_frameTime; LattePerfStatTimer gpuTime_shaderCreate; diff --git a/src/Cafe/IOSU/legacy/iosu_acp.cpp b/src/Cafe/IOSU/legacy/iosu_acp.cpp index 828044a0..8637d88d 100644 --- a/src/Cafe/IOSU/legacy/iosu_acp.cpp +++ b/src/Cafe/IOSU/legacy/iosu_acp.cpp @@ -10,6 +10,8 @@ #include "Cafe/Filesystem/fsc.h" #include "Cafe/HW/Espresso/PPCState.h" +#include + static_assert(sizeof(acpMetaXml_t) == 0x3440); static_assert(offsetof(acpMetaXml_t, title_id) == 0x0000); static_assert(offsetof(acpMetaXml_t, boss_id) == 0x0008); @@ -85,7 +87,7 @@ namespace iosu return; const char* text = subElement->GetText(); uint64 value; - if (sscanf(text, "%llx", &value) == 0) + if (sscanf(text, "%" SCNx64, &value) == 0) return; *v = _swapEndianU64(value); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Callbacks.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Callbacks.cpp index 18a36820..403bec61 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Callbacks.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Callbacks.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "util/helpers/fspinlock.h" diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.cpp index e4bc6792..33767ddf 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.cpp @@ -470,7 +470,7 @@ namespace coreinit // mark current block as free block->isFree = _swapEndianU32(1); // attempt to merge with previous block - if (_swapEndianU32(block->previousBlock) != NULL) + if (_swapEndianU32(block->previousBlock) != MPTR_NULL) { MPTR previousBlockMPTR = _swapEndianU32(block->previousBlock); MEMBlockHeapTrackDEPR* previousBlock = (MEMBlockHeapTrackDEPR*)memory_getPointerFromVirtualOffset(previousBlockMPTR); @@ -494,7 +494,7 @@ namespace coreinit } } // attempt to merge with next block - if (_swapEndianU32(block->nextBlock) != NULL) + if (_swapEndianU32(block->nextBlock) != MPTR_NULL) { MPTR nextBlockMPTR = _swapEndianU32(block->nextBlock); MEMBlockHeapTrackDEPR* nextBlock = (MEMBlockHeapTrackDEPR*)memory_getPointerFromVirtualOffset(nextBlockMPTR); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MemoryMapping.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MemoryMapping.cpp index 26acedce..fe7f4d0b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MemoryMapping.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MemoryMapping.cpp @@ -34,7 +34,7 @@ namespace coreinit { debug_printf("coreinitVirtualMemory_alloc(): Unable to allocate memory\n"); debugBreakpoint(); - return NULL; + return MPTR_NULL; } // check for overlapping regions OSVirtMemory* virtMemItr = virtualMemoryList; @@ -66,7 +66,7 @@ namespace coreinit return currentAddress; } } - return NULL; + return MPTR_NULL; } void coreinitExport_OSGetAvailPhysAddrRange(PPCInterpreter_t* hCPU) diff --git a/src/Cafe/OS/libs/snd_core/ax_ist.cpp b/src/Cafe/OS/libs/snd_core/ax_ist.cpp index a47b1974..26f975af 100644 --- a/src/Cafe/OS/libs/snd_core/ax_ist.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_ist.cpp @@ -99,7 +99,7 @@ namespace snd_core } coreinit::OSInitMutexEx(__AXAppFrameCallbackMutex.GetPtr(), NULL); for (sint32 i = 0; i < AX_DEV_COUNT; i++) - __AXDeviceFinalMixCallback[i] = NULL; + __AXDeviceFinalMixCallback[i] = MPTR_NULL; } sint32 AXRegisterAppFrameCallback(MPTR funcAddr) diff --git a/src/Cemu/Logging/CemuDebugLogging.h b/src/Cemu/Logging/CemuDebugLogging.h index 700ce23c..ac05c024 100644 --- a/src/Cemu/Logging/CemuDebugLogging.h +++ b/src/Cemu/Logging/CemuDebugLogging.h @@ -3,11 +3,9 @@ // printf-style macros that are only active in non-release builds #ifdef PUBLIC_RELEASE -#define debug_printf // -#define debug_puts // +#define debug_printf(...) static void debugBreakpoint() { } #else -#define debug_printf printf -#define debug_puts puts +#define debug_printf(...) printf(__VA_ARGS__) static void debugBreakpoint() {} #endif \ No newline at end of file From 6cdb6eed1730cde23ede99099a12092b9abe8aa3 Mon Sep 17 00:00:00 2001 From: Tom Lally Date: Thu, 8 Sep 2022 01:12:53 +0100 Subject: [PATCH 5/6] Cleanup udiv128 (#206) --- src/Cafe/HW/Espresso/PPCTimer.cpp | 11 ----------- src/Common/precompiled.h | 9 +++++++++ src/asm/x64util.h | 1 - src/asm/x64util_masm.asm | 7 ------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Cafe/HW/Espresso/PPCTimer.cpp b/src/Cafe/HW/Espresso/PPCTimer.cpp index 0ab6d77d..36198dac 100644 --- a/src/Cafe/HW/Espresso/PPCTimer.cpp +++ b/src/Cafe/HW/Espresso/PPCTimer.cpp @@ -108,14 +108,8 @@ uint64 PPCTimer_tscToMicroseconds(uint64 us) uint128_t r{}; r.low = _umul128(us, 1000000ULL, &r.high); - uint64 remainder; - -#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__) const uint64 microseconds = _udiv128(r.high, r.low, _rdtscFrequency, &remainder); -#else - const uint64 microseconds = udiv128(r.low, r.high, _rdtscFrequency, &remainder); -#endif return microseconds; } @@ -159,12 +153,7 @@ uint64 PPCTimer_getFromRDTSC() #endif uint64 remainder; -#if defined(_MSC_VER) && _MSC_VER >= 1923 && !defined(__clang__) uint64 elapsedTick = _udiv128(_rdtscAcc.high, _rdtscAcc.low, _rdtscFrequency, &remainder); -#else - uint64 elapsedTick = udiv128(_rdtscAcc.low, _rdtscAcc.high, _rdtscFrequency, &remainder); -#endif - _rdtscAcc.low = remainder; _rdtscAcc.high = 0; diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 795bc351..57929c2a 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -210,6 +210,15 @@ typedef union _LARGE_INTEGER { inline T& operator^= (T& a, T b) { return reinterpret_cast( reinterpret_cast::type&>(a) ^= static_cast::type>(b) ); } #endif +#if !defined(_MSC_VER) || defined(__clang__) // clang-cl does not have built-in _udiv128 +inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, uint64 *remainder) +{ + unsigned __int128 dividend = (((unsigned __int128)highDividend) << 64) | ((unsigned __int128)lowDividend); + *remainder = (uint64)((dividend % divisor) & 0xFFFFFFFFFFFFFFFF); + return (uint64)((dividend / divisor) & 0xFFFFFFFFFFFFFFFF); +} +#endif + #if defined(_MSC_VER) #define UNREACHABLE __assume(false) #elif defined(__GNUC__) diff --git a/src/asm/x64util.h b/src/asm/x64util.h index 654c8f4a..32669b97 100644 --- a/src/asm/x64util.h +++ b/src/asm/x64util.h @@ -1,5 +1,4 @@ #pragma once -extern "C" uint64 ATTR_MS_ABI udiv128(uint64 low, uint64 hi, uint64 divisor, uint64 *remainder); extern "C" void recompiler_fres(); extern "C" void recompiler_frsqrte(); diff --git a/src/asm/x64util_masm.asm b/src/asm/x64util_masm.asm index 14aa1ec0..2587c786 100644 --- a/src/asm/x64util_masm.asm +++ b/src/asm/x64util_masm.asm @@ -1,12 +1,5 @@ .code -udiv128 PROC - mov rax, rcx - div r8 - mov [r9], rdx - ret -udiv128 ENDP - recompiler_fres PROC ; store all modified registers push rdx From f03208890256acd6d3e6b072a125465db4364de6 Mon Sep 17 00:00:00 2001 From: Timothy Redaelli Date: Thu, 8 Sep 2022 17:05:31 +0200 Subject: [PATCH 6/6] Use _Exit instead of exit under Linux (#204) The best ExitProcess alternative for Linux is _Exit since it doesn't call exit handlers. --- src/Common/ExceptionHandler/ExceptionHandler_posix.cpp | 2 +- src/gui/CemuApp.cpp | 2 +- src/gui/MainWindow.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp index 2f18c2d7..b9ecb782 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp @@ -26,7 +26,7 @@ void handler_SIGINT(int sig) * by any mean ends up with a SIGABRT from the standard library destroying * threads. */ - exit(0); + _Exit(0); } void ExceptionHandler_init() diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index e78b30b3..8563ae2c 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -142,7 +142,7 @@ int CemuApp::OnExit() #if BOOST_OS_WINDOWS ExitProcess(0); #else - exit(0); + _Exit(0); #endif } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index ec821ce5..53363ae3 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -47,6 +47,8 @@ #if BOOST_OS_WINDOWS #define exit(__c) ExitProcess(__c) +#else +#define exit(__c) _Exit(__c) #endif #if BOOST_OS_LINUX || BOOST_OS_MACOS