From f333ae6ed19d12ccdffe9f18378910fd0e1b24e8 Mon Sep 17 00:00:00 2001 From: zqh9843 <39073062+zqh9843@users.noreply.github.com> Date: Mon, 26 Feb 2024 05:16:23 +0800 Subject: [PATCH] Remove thread optimization to fix audio issues (#117) --- init_coop.lua | 59 +-------------------------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/init_coop.lua b/init_coop.lua index 9acc17a5..25deab0f 100644 --- a/init_coop.lua +++ b/init_coop.lua @@ -19,63 +19,6 @@ LOG("Client version: " .. tostring(ClientVersion)) LOG("Game version: " .. tostring(GameVersion)) LOG("Game type: " .. tostring(GameType)) -------------------------------------------------------------------------------- ---#region Adjust process affinity and prioritity - --- The rendering thread appears to pin itself to the first computing unit of --- a computer. The first computing unit is often also used by othersoftware, --- including the OS. Through empirical research the framerate of the game is a --- lot more consistent when we do not give it access to the first computing --- unit. - --- That is what this section helps us do. The game functions best when it has --- at least four computing units available. If we detect someone has 6 or more --- computing units then we take the game off the first compute unit. - --- Note that we can not make the distinction between real computing units and --- computing units that originate from technology such as hyperthreading. - -local SetProcessPriority = rawget(_G, "SetProcessPriority") -local GetProcessAffinityMask = rawget(_G, "GetProcessAffinityMask") -local SetProcessAffinityMask = rawget(_G, "SetProcessAffinityMask") - -if SetProcessPriority and GetProcessAffinityMask and SetProcessAffinityMask then - - -- priority values can be found at: - -- - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass - local success = SetProcessPriority(0x00000080) - if success then - LOG("Process - priority set to: 'high'") - else - LOG("Process - Failed to adjust process priority, this may impact your framerate") - end - - -- affinity values acts like a bit mask, we retrieve the mask and shift it if we think there are sufficient computing units - local success, processAffinityMask, systemAffinityMask = GetProcessAffinityMask(); - if success then - -- system has 6 (logical) threads or more, skip first two computing units - if systemAffinityMask >= 63 then - processAffinityMask = systemAffinityMask & (systemAffinityMask << 2) - end - - -- update the afinity mask - if processAffinityMask != systemAffinityMask then - local success = SetProcessAffinityMask(processAffinityMask); - if success then - LOG("Process - affinity set to: " .. tostring(processAffinityMask)) - else - LOG("Process - Failed to adjust the process affinity, this may impact your framerate") - end - end - else - LOG("Process - Failed to retrieve the process affinity, this may impact your framerate") - end -else - LOG("Process - Failed to find process priority and affinity related functions, this may impact your framerate") -end - ---#endregion - -- upvalued performance local dofile = dofile @@ -679,4 +622,4 @@ MountDirectory(SHGetFolderPath('LOCAL_APPDATA') .. 'Gas Powered Games/Supreme Co MountDirectory(fa_path .. "/movies", '/movies') MountDirectory(fa_path .. "/sounds", '/sounds') MountDirectory(fa_path .. "/maps", '/maps') -MountDirectory(fa_path .. "/fonts", '/fonts') \ No newline at end of file +MountDirectory(fa_path .. "/fonts", '/fonts')