Browse Source
Changed memory allocation routines into a C++ plugin which will includes right into the IL2CPP build. No need for any separate dynamic libraries anymore. Also works for Game Core platforms.
Changed memory allocation routines into a C++ plugin which will includes right into the IL2CPP build. No need for any separate dynamic libraries anymore. Also works for Game Core platforms.
The only platform *not* working at the moment is PS4, because it seems Unity doesn't include the C++ file properly during build.master
7 changed files with 146 additions and 53 deletions
-
8Assets/Plugins/PS5.meta
-
BINAssets/Plugins/PS5/PS5Utils.prx
-
32Assets/Plugins/PS5/PS5Utils.prx.meta
-
52Assets/Scripts/EOSNativeHelper.cpp
-
87Assets/Scripts/EOSNativeHelper.cpp.meta
-
10Assets/Scripts/EOSNativeHelper.cs
-
10Assets/Scripts/EpicVoiceChatTest.cs
@ -1,8 +0,0 @@ |
|||||
fileFormatVersion: 2 |
|
||||
guid: 0677463dddd99144083c9a34be65a720 |
|
||||
folderAsset: yes |
|
||||
DefaultImporter: |
|
||||
externalObjects: {} |
|
||||
userData: |
|
||||
assetBundleName: |
|
||||
assetBundleVariant: |
|
||||
@ -1,32 +0,0 @@ |
|||||
fileFormatVersion: 2 |
|
||||
guid: 43fd785f2224f2745a11794c21b7e30c |
|
||||
PluginImporter: |
|
||||
externalObjects: {} |
|
||||
serializedVersion: 2 |
|
||||
iconMap: {} |
|
||||
executionOrder: {} |
|
||||
defineConstraints: [] |
|
||||
isPreloaded: 0 |
|
||||
isOverridable: 0 |
|
||||
isExplicitlyReferenced: 0 |
|
||||
validateReferences: 1 |
|
||||
platformData: |
|
||||
- first: |
|
||||
Any: |
|
||||
second: |
|
||||
enabled: 0 |
|
||||
settings: {} |
|
||||
- first: |
|
||||
Editor: Editor |
|
||||
second: |
|
||||
enabled: 0 |
|
||||
settings: |
|
||||
DefaultValueInitialized: true |
|
||||
- first: |
|
||||
PS5: PS5 |
|
||||
second: |
|
||||
enabled: 1 |
|
||||
settings: {} |
|
||||
userData: |
|
||||
assetBundleName: |
|
||||
assetBundleVariant: |
|
||||
@ -0,0 +1,52 @@ |
|||||
|
#include <stdlib.h>
|
||||
|
|
||||
|
#if defined(__ORBIS__) || defined(__PROSPERO__)
|
||||
|
#define _aligned_malloc(s,a) aligned_alloc(a,s)
|
||||
|
#define _aligned_realloc(p,s,a) reallocalign(p,s,a)
|
||||
|
#define _aligned_free(p) free(p)
|
||||
|
#else
|
||||
|
#include <malloc.h>
|
||||
|
#endif
|
||||
|
|
||||
|
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
||||
|
|
||||
|
static void *AllocateMemory(size_t size, size_t alignment) |
||||
|
{ |
||||
|
if (size == 0) |
||||
|
return nullptr; |
||||
|
|
||||
|
return _aligned_malloc(size, alignment); |
||||
|
} |
||||
|
|
||||
|
static void *ReallocateMemory(void *ptr, size_t size, size_t alignment) |
||||
|
{ |
||||
|
if (size == 0) |
||||
|
{ |
||||
|
free(ptr); |
||||
|
return nullptr; |
||||
|
} |
||||
|
|
||||
|
// EOS will sometimes request a reallocation for a null pointer, so we need to specifically handle that
|
||||
|
if (ptr == nullptr) |
||||
|
{ |
||||
|
return _aligned_malloc(size, alignment); |
||||
|
} |
||||
|
|
||||
|
return _aligned_realloc(ptr, size, alignment); |
||||
|
} |
||||
|
|
||||
|
static void ReleaseMemory(void *ptr) |
||||
|
{ |
||||
|
return _aligned_free(ptr); |
||||
|
} |
||||
|
|
||||
|
typedef void* (*AllocateMemoryFunc)(size_t, size_t); |
||||
|
typedef void* (*ReallocateMemoryFunc)(void*, size_t, size_t); |
||||
|
typedef void (*ReleaseMemoryFunc)(void*); |
||||
|
|
||||
|
DLL_EXPORT void EOS_GetMemoryFunctions(AllocateMemoryFunc *allocFunc, ReallocateMemoryFunc *reallocFunc, ReleaseMemoryFunc *releaseFunc) |
||||
|
{ |
||||
|
*allocFunc = AllocateMemory; |
||||
|
*reallocFunc = ReallocateMemory; |
||||
|
*releaseFunc = ReleaseMemory; |
||||
|
} |
||||
@ -0,0 +1,87 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 9e01755363649f24bbc946e6dd5dd6ef |
||||
|
PluginImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
iconMap: {} |
||||
|
executionOrder: {} |
||||
|
defineConstraints: [] |
||||
|
isPreloaded: 0 |
||||
|
isOverridable: 0 |
||||
|
isExplicitlyReferenced: 0 |
||||
|
validateReferences: 1 |
||||
|
platformData: |
||||
|
- first: |
||||
|
: Any |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
Exclude Editor: 1 |
||||
|
Exclude GameCoreScarlett: 0 |
||||
|
Exclude GameCoreXboxOne: 0 |
||||
|
Exclude Linux64: 1 |
||||
|
Exclude OSXUniversal: 1 |
||||
|
Exclude PS4: 0 |
||||
|
Exclude PS5: 0 |
||||
|
Exclude Win: 1 |
||||
|
Exclude Win64: 1 |
||||
|
- first: |
||||
|
Any: |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: {} |
||||
|
- first: |
||||
|
Editor: Editor |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
CPU: AnyCPU |
||||
|
DefaultValueInitialized: true |
||||
|
OS: AnyOS |
||||
|
- first: |
||||
|
GameCoreScarlett: GameCoreScarlett |
||||
|
second: |
||||
|
enabled: 1 |
||||
|
settings: {} |
||||
|
- first: |
||||
|
GameCoreXboxOne: GameCoreXboxOne |
||||
|
second: |
||||
|
enabled: 1 |
||||
|
settings: {} |
||||
|
- first: |
||||
|
PS4: PS4 |
||||
|
second: |
||||
|
enabled: 1 |
||||
|
settings: {} |
||||
|
- first: |
||||
|
PS5: PS5 |
||||
|
second: |
||||
|
enabled: 1 |
||||
|
settings: {} |
||||
|
- first: |
||||
|
Standalone: Linux64 |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
CPU: None |
||||
|
- first: |
||||
|
Standalone: OSXUniversal |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
CPU: None |
||||
|
- first: |
||||
|
Standalone: Win |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
CPU: None |
||||
|
- first: |
||||
|
Standalone: Win64 |
||||
|
second: |
||||
|
enabled: 0 |
||||
|
settings: |
||||
|
CPU: None |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue