mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-16 03:38:30 +12:00
Initial macOS port bringup (#52)
This commit is contained in:
parent
a2abffd37b
commit
974edaa649
84 changed files with 157 additions and 122 deletions
|
@ -364,7 +364,7 @@ void cemu_initForGame()
|
|||
time_t theTime = (time(NULL) - 946684800);
|
||||
{
|
||||
tm* lt = localtime(&theTime);
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
theTime = _mkgmtime(lt);
|
||||
#else
|
||||
theTime = timegm(lt);
|
||||
|
|
|
@ -1029,7 +1029,7 @@ bool FSTVerifier::VerifyContentFile(FileStream* fileContent, const NCrypto::AesK
|
|||
SHA256_Init(&sha256Ctx);
|
||||
while (remainingBytes > 0)
|
||||
{
|
||||
uint32 bytesToRead = (uint32)std::min(remainingBytes, buffer.size());
|
||||
uint32 bytesToRead = (uint32)std::min(remainingBytes, (uint64)buffer.size());
|
||||
uint32 bytesToReadPadded = ((bytesToRead + 0xF) & ~0xF);
|
||||
uint32 bytesRead = fileContent->readData(buffer.data(), bytesToReadPadded);
|
||||
if (bytesRead != bytesToReadPadded)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "Cafe/OS/libs/coreinit/coreinit.h"
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
|
@ -158,7 +158,7 @@ void debugger_updateMemoryBreakpoint(DebuggerBreakpoint* bp)
|
|||
{
|
||||
std::vector<std::thread::native_handle_type> schedulerThreadHandles = coreinit::OSGetSchedulerThreads();
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
debuggerState.activeMemoryBreakpoint = bp;
|
||||
for (auto& hThreadNH : schedulerThreadHandles)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "util/helpers/fspinlock.h"
|
||||
#include "util/highresolutiontimer/HighResolutionTimer.h"
|
||||
|
||||
#if BOOST_OS_LINUX > 0
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
static __inline__
|
||||
unsigned __int64 _umul128(unsigned __int64,
|
||||
unsigned __int64,
|
||||
|
@ -113,7 +113,7 @@ uint64 PPCTimer_microsecondsToTsc(uint64 us)
|
|||
uint64 PPCTimer_tscToMicroseconds(uint64 us)
|
||||
{
|
||||
uint128_t r{};
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
r.low = _umul128(us, 1000000ULL, &r.high);
|
||||
#else
|
||||
r.low = _umul128(us, 1000000ULL, (unsigned long long*)&r.high);
|
||||
|
@ -153,7 +153,7 @@ uint64 PPCTimer_getFromRDTSC()
|
|||
rdtscDif = rdtscDif & ~(uint64)((sint64)rdtscDif >> 63);
|
||||
|
||||
uint128_t diff{};
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, &diff.high);
|
||||
#else
|
||||
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, (unsigned long long*)&diff.high);
|
||||
|
@ -163,7 +163,7 @@ uint64 PPCTimer_getFromRDTSC()
|
|||
_rdtscLastMeasure = rdtscCurrentMeasure; // only travel forward in time
|
||||
|
||||
uint8 c = 0;
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
c = _addcarry_u64(c, _rdtscAcc.low, diff.low, &_rdtscAcc.low);
|
||||
_addcarry_u64(c, _rdtscAcc.high, diff.high, &_rdtscAcc.high);
|
||||
#else
|
||||
|
|
|
@ -72,7 +72,7 @@ void PPCRecompiler_recompileIfUnvisited(uint32 enterAddress)
|
|||
|
||||
void PPCRecompiler_enter(PPCInterpreter_t* hCPU, PPCREC_JUMP_ENTRY funcPtr)
|
||||
{
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
uint32 prevState = _controlfp(0, 0);
|
||||
_controlfp(_RC_NEAR, _MCW_RC);
|
||||
PPCRecompiler_enterRecompilerCode((uint64)funcPtr, (uint64)hCPU);
|
||||
|
|
|
@ -284,7 +284,7 @@ void LatteIndices_generateAutoLineLoopIndices(void* indexDataOutput, uint32 coun
|
|||
indexMax = std::max(count, 1u) - 1;
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
|
||||
#endif
|
||||
|
||||
|
@ -352,11 +352,11 @@ void LatteIndices_fastConvertU16_AVX2(const void* indexDataInput, void* indexDat
|
|||
indexMin = std::min(indexMin, _minIndex);
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
|
||||
#endif
|
||||
|
||||
|
@ -423,11 +423,11 @@ void LatteIndices_fastConvertU16_SSE41(const void* indexDataInput, void* indexDa
|
|||
indexMin = std::min(indexMin, _minIndex);
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
|
||||
#endif
|
||||
|
||||
|
@ -497,7 +497,7 @@ void LatteIndices_fastConvertU32_AVX2(const void* indexDataInput, void* indexDat
|
|||
indexMin = std::min(indexMin, _minIndex);
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
#include <psapi.h>
|
||||
#endif
|
||||
|
||||
|
@ -189,7 +189,7 @@ void LatteShaderCache_load()
|
|||
|
||||
const auto timeLoadStart = now_cached();
|
||||
// remember current amount of committed memory
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
PROCESS_MEMORY_COUNTERS pmc1;
|
||||
GetProcessMemoryInfo(GetCurrentProcess(), &pmc1, sizeof(PROCESS_MEMORY_COUNTERS));
|
||||
LONGLONG totalMem1 = pmc1.PagefileUsage;
|
||||
|
@ -285,7 +285,7 @@ void LatteShaderCache_load()
|
|||
|
||||
LatteShaderCache_updateCompileQueue(0);
|
||||
// write load time and RAM usage to log file (in dev build)
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
const auto timeLoadEnd = now_cached();
|
||||
const auto timeLoad = std::chrono::duration_cast<std::chrono::milliseconds>(timeLoadEnd - timeLoadStart).count();
|
||||
PROCESS_MEMORY_COUNTERS pmc2;
|
||||
|
|
|
@ -145,7 +145,7 @@ uint32 LatteTexture_CalculateTextureDataHash(LatteTexture* hostTexture)
|
|||
bool isCompressedFormat = hostTexture->IsCompressedFormat();
|
||||
if( isCompressedFormat == false )
|
||||
{
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
if (_cpuExtension_AVX2)
|
||||
{
|
||||
__m256i h256 = { 0 };
|
||||
|
|
|
@ -7,7 +7,7 @@ using namespace Latte;
|
|||
namespace LatteAddrLib
|
||||
{
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask)
|
||||
{
|
||||
if (!_Mask)
|
||||
|
|
|
@ -95,7 +95,7 @@ OpenGLRenderer::OpenGLRenderer()
|
|||
glRendererState.uploadIndex = 0;
|
||||
}
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
try
|
||||
{
|
||||
m_dxgi_wrapper = std::make_unique<DXGIWrapper>();
|
||||
|
@ -191,7 +191,7 @@ void OpenGLRenderer::DeleteFontTextures()
|
|||
|
||||
typedef void(*GL_IMPORT)();
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
GL_IMPORT _GetOpenGLFunction(HMODULE hLib, const char* name)
|
||||
{
|
||||
GL_IMPORT r = (GL_IMPORT)wglGetProcAddress(name);
|
||||
|
@ -207,7 +207,7 @@ void LoadOpenGLImports()
|
|||
#include "Common/GLInclude/glFunctions.h"
|
||||
#undef GLFUNC
|
||||
}
|
||||
#else
|
||||
#elif BOOST_OS_LINUX
|
||||
GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name)
|
||||
{
|
||||
GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name);
|
||||
|
@ -233,6 +233,11 @@ void LoadOpenGLImports()
|
|||
#include "Common/GLInclude/glFunctions.h"
|
||||
#undef GLFUNC
|
||||
}
|
||||
#elif BOOST_OS_MACOS
|
||||
void LoadOpenGLImports()
|
||||
{
|
||||
cemu_assert_unimplemented();
|
||||
}
|
||||
#endif
|
||||
|
||||
void OpenGLRenderer::Initialize()
|
||||
|
@ -244,7 +249,7 @@ void OpenGLRenderer::Initialize()
|
|||
LoadOpenGLImports();
|
||||
GetVendorInformation();
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
if (wglSwapIntervalEXT)
|
||||
wglSwapIntervalEXT(0); // disable V-Sync per default
|
||||
#endif
|
||||
|
@ -349,7 +354,7 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle()
|
|||
|
||||
void OpenGLRenderer::EnableVSync(int state)
|
||||
{
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
if(wglSwapIntervalEXT)
|
||||
wglSwapIntervalEXT(state); // 1 = enabled, 0 = disabled
|
||||
#else
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define VKFUNC_DEFINE
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h"
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
|
|||
requiredExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
#if BOOST_OS_WINDOWS
|
||||
requiredExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#else
|
||||
#elif BOOST_OS_LINUX
|
||||
requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
|
@ -1143,7 +1143,7 @@ std::vector<const char*> VulkanRenderer::CheckInstanceExtensionSupport(FeatureCo
|
|||
requiredInstanceExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
#if BOOST_OS_WINDOWS
|
||||
requiredInstanceExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#else
|
||||
#elif BOOST_OS_LINUX
|
||||
requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||
#endif
|
||||
if (cafeLog_isLoggingFlagEnabled(LOG_TYPE_VULKAN_VALIDATION))
|
||||
|
@ -1319,8 +1319,11 @@ VkSurfaceKHR VulkanRenderer::CreateFramebufferSurface(VkInstance instance, struc
|
|||
{
|
||||
#if BOOST_OS_WINDOWS
|
||||
return CreateWinSurface(instance, windowInfo.hwnd);
|
||||
#else
|
||||
#elif BOOST_OS_LINUX
|
||||
return CreateXlibSurface(instance, windowInfo.xlib_display, windowInfo.xlib_window);
|
||||
#elif BOOST_OS_MACOS
|
||||
cemu_assert_unimplemented();
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,9 @@ static uint16 CPU_swapEndianU16(uint16 v)
|
|||
#elif BOOST_OS_LINUX
|
||||
#define CPU_swapEndianU64(_v) bswap_64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) bswap_32((uint32)(_v))
|
||||
#elif BOOST_OS_MACOS
|
||||
#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v))
|
||||
#endif
|
||||
|
||||
// direct memory access (no hardware interface access)
|
||||
|
|
|
@ -78,7 +78,7 @@ void CafeInit()
|
|||
rpxPathStart = 0;
|
||||
}
|
||||
|
||||
std::string_view rpxFileName = std::basic_string_view<char>(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.data() + _pathToExecutable.size());
|
||||
std::string_view rpxFileName(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.size() - rpxPathStart);
|
||||
|
||||
argStorageIndex = 0;
|
||||
_coreinitInfo->argc = 0;
|
||||
|
|
|
@ -424,7 +424,7 @@ typedef struct
|
|||
|
||||
static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#define _strcmpi strcasecmp
|
||||
#endif
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ namespace coreinit
|
|||
bool negativeAlignment = alignment < 0;
|
||||
if (negativeAlignment)
|
||||
alignment = -alignment;
|
||||
if (!std::has_single_bit<uint32>((uint32)alignment))
|
||||
uint32 bits = (uint32)alignment;
|
||||
if (bits == 0 || (bits & (bits - 1)) != 0)
|
||||
{
|
||||
cemuLog_log(LogType::APIErrors, "MEMGetAllocatableSizeForFrmHeapEx(): Invalid alignment");
|
||||
return 0;
|
||||
|
|
|
@ -455,7 +455,7 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU)
|
|||
ppcDefineParamMEMPTR(exceptionFd, wu_fd_set, 3);
|
||||
ppcDefineParamU32BEPtr(maxFd, 4);
|
||||
|
||||
#if BOOST_OS_LINUX > 0
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
cemuLog_log(LogType::Force, "curl_multi_fdset(...) - todo");
|
||||
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace save
|
|||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
std::wstringstream errorMsg;
|
||||
errorMsg << L"Couldn't move your save files!" << std::endl << std::endl;
|
||||
errorMsg << L"Error: " << ex.what() << std::endl << std::endl;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <bitset>
|
||||
#include "nsyshid.h"
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
|
||||
#include <setupapi.h>
|
||||
#include <initguid.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Common/socket.h"
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
|
||||
#define WU_AF_INET 2
|
||||
|
||||
|
@ -2085,7 +2085,7 @@ void nsysnet_load()
|
|||
osLib_addFunction("nsysnet", "NSSLExportInternalClientCertificate", nsysnet::export_NSSLExportInternalClientCertificate);
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
void nsysnet_notifyCloseSharedSocket(SOCKET existingSocket)
|
||||
{
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
#if BOOST_OS_WINDOWS
|
||||
#include <WinSock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue