Merge branch 'woa_support' of https://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-woa_support
# Conflicts: # Source/ThirdParty/assimp/config.h.in # Source/Tools/Flax.Build/Deps/Dependencies/Assimp.cs
This commit is contained in:
@@ -15,7 +15,7 @@ public:
|
||||
enum { HasSwap = false };
|
||||
|
||||
template<typename T>
|
||||
class Data
|
||||
class alignas(sizeof(void*)) Data
|
||||
{
|
||||
private:
|
||||
byte _data[Capacity * sizeof(T)];
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
enum { HasSwap = false };
|
||||
|
||||
template<typename T>
|
||||
class Data
|
||||
class alignas(sizeof(void*)) Data
|
||||
{
|
||||
private:
|
||||
typedef typename OtherAllocator::template Data<T> OtherData;
|
||||
|
||||
@@ -71,6 +71,27 @@ static bool TryCreateDevice(IDXGIAdapter* adapter, D3D_FEATURE_LEVEL maxFeatureL
|
||||
context->Release();
|
||||
return true;
|
||||
}
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
deviceFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
|
||||
if (SUCCEEDED(D3D11CreateDevice(
|
||||
adapter,
|
||||
D3D_DRIVER_TYPE_UNKNOWN,
|
||||
NULL,
|
||||
deviceFlags,
|
||||
&featureLevels[levelIndex],
|
||||
ARRAY_COUNT(featureLevels) - levelIndex,
|
||||
D3D11_SDK_VERSION,
|
||||
&device,
|
||||
featureLevel,
|
||||
&context
|
||||
)))
|
||||
{
|
||||
LOG(Warning, "Direct3D SDK debug layers were requested, but not available.");
|
||||
device->Release();
|
||||
context->Release();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
#if GRAPHICS_API_DIRECTX12
|
||||
|
||||
#include "Engine/Graphics/Config.h"
|
||||
#if USE_PIX && GPU_ALLOW_PROFILE_EVENTS
|
||||
// Include these header files before pix3
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#define NOGDI
|
||||
#define NODRAWTEXT
|
||||
//#define NOCTLMGR
|
||||
#define NOFLATSBAPIS
|
||||
#include <Windows.h>
|
||||
#include <d3d12.h>
|
||||
#include <ThirdParty/WinPixEventRuntime/pix3.h>
|
||||
#endif
|
||||
|
||||
#include "GPUContextDX12.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Viewport.h"
|
||||
@@ -22,9 +36,6 @@
|
||||
#include "Engine/Profiler/RenderStats.h"
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
#if USE_PIX && GPU_ALLOW_PROFILE_EVENTS
|
||||
#include <pix3.h>
|
||||
#endif
|
||||
|
||||
#define DX12_ENABLE_RESOURCE_BARRIERS_BATCHING 1
|
||||
#define DX12_ENABLE_RESOURCE_BARRIERS_DEBUGGING 0
|
||||
|
||||
@@ -6,10 +6,14 @@
|
||||
|
||||
// Platform description
|
||||
#define PLATFORM_DESKTOP 1
|
||||
#if defined(WIN64)
|
||||
#if defined(WIN64) && defined(_M_X64)
|
||||
#define PLATFORM_64BITS 1
|
||||
#define PLATFORM_ARCH_X64 1
|
||||
#define PLATFORM_ARCH ArchitectureType::x64
|
||||
#elif defined(WIN64) && defined(_M_ARM64)
|
||||
#define PLATFORM_64BITS 1
|
||||
#define PLATFORM_ARCH_ARM64 1
|
||||
#define PLATFORM_ARCH ArchitectureType::ARM64
|
||||
#else
|
||||
#define PLATFORM_64BITS 0
|
||||
#define PLATFORM_ARCH_X86 1
|
||||
|
||||
@@ -159,10 +159,14 @@ bool Win32Platform::Init()
|
||||
CpuInfo.PageSize = siSysInfo.dwPageSize;
|
||||
CpuInfo.ClockSpeed = ClockFrequency;
|
||||
{
|
||||
#ifdef _M_ARM64
|
||||
CpuInfo.CacheLineSize = 128;
|
||||
#else
|
||||
int args[4];
|
||||
__cpuid(args, 0x80000006);
|
||||
CpuInfo.CacheLineSize = args[2] & 0xFF;
|
||||
ASSERT(CpuInfo.CacheLineSize && Math::IsPowerOfTwo(CpuInfo.CacheLineSize));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Setup unique device ID
|
||||
@@ -229,10 +233,12 @@ void Win32Platform::MemoryBarrier()
|
||||
{
|
||||
_ReadWriteBarrier();
|
||||
#if PLATFORM_64BITS
|
||||
#ifdef _AMD64_
|
||||
#if defined(_AMD64_)
|
||||
__faststorefence();
|
||||
#elif defined(_IA64_)
|
||||
__mf();
|
||||
#elif defined(_ARM64_)
|
||||
__dmb(_ARM64_BARRIER_ISH);
|
||||
#else
|
||||
#error "Invalid platform."
|
||||
#endif
|
||||
@@ -246,7 +252,11 @@ void Win32Platform::MemoryBarrier()
|
||||
|
||||
void Win32Platform::Prefetch(void const* ptr)
|
||||
{
|
||||
#if _M_ARM64
|
||||
__prefetch((char const*)ptr);
|
||||
#else
|
||||
_mm_prefetch((char const*)ptr, _MM_HINT_T0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void* Win32Platform::Allocate(uint64 size, uint64 alignment)
|
||||
|
||||
@@ -1312,6 +1312,14 @@ Array<PlatformBase::StackFrame> WindowsPlatform::GetStackFrames(int32 skipCount,
|
||||
stack.AddrBStore.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Offset = ctx.IntSp;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
#elif _M_ARM64
|
||||
imageType = IMAGE_FILE_MACHINE_ARM64;
|
||||
stack.AddrPC.Offset = ctx.Pc;
|
||||
stack.AddrPC.Mode = AddrModeFlat;
|
||||
stack.AddrFrame.Offset = ctx.Fp;
|
||||
stack.AddrFrame.Mode = AddrModeFlat;
|
||||
stack.AddrStack.Offset = ctx.Sp;
|
||||
stack.AddrStack.Mode = AddrModeFlat;
|
||||
#else
|
||||
#error "Platform not supported!"
|
||||
#endif
|
||||
|
||||
@@ -1777,13 +1777,18 @@ bool InitHostfxr()
|
||||
{
|
||||
case PlatformType::Windows:
|
||||
case PlatformType::UWP:
|
||||
platformStr = PLATFORM_64BITS ? "Windows x64" : "Windows x86";
|
||||
if (PLATFORM_ARCH == ArchitectureType::x64)
|
||||
platformStr = "Windows x64";
|
||||
else if (PLATFORM_ARCH == ArchitectureType::ARM64)
|
||||
platformStr = "Windows ARM64";
|
||||
else
|
||||
platformStr = "Windows x86";
|
||||
break;
|
||||
case PlatformType::Linux:
|
||||
platformStr = PLATFORM_ARCH_ARM64 ? "Linux Arm64" : PLATFORM_ARCH_ARM ? "Linux Arm32" : PLATFORM_64BITS ? "Linux x64" : "Linux x86";
|
||||
platformStr = PLATFORM_ARCH_ARM64 ? "Linux ARM64" : PLATFORM_ARCH_ARM ? "Linux Arm32" : PLATFORM_64BITS ? "Linux x64" : "Linux x86";
|
||||
break;
|
||||
case PlatformType::Mac:
|
||||
platformStr = PLATFORM_ARCH_ARM || PLATFORM_ARCH_ARM64 ? "macOS Arm64" : PLATFORM_64BITS ? "macOS x64" : "macOS x86";
|
||||
platformStr = PLATFORM_ARCH_ARM || PLATFORM_ARCH_ARM64 ? "macOS ARM64" : PLATFORM_64BITS ? "macOS x64" : "macOS x86";
|
||||
break;
|
||||
default:;
|
||||
platformStr = "";
|
||||
|
||||
@@ -493,6 +493,66 @@ FORCE_INLINE int32 GetVTableIndex(void** vtable, int32 entriesCount, void* func)
|
||||
if (op == 0x20)
|
||||
return 0;
|
||||
return *(byte*)funcJmp / sizeof(void*);
|
||||
#elif defined(_MSC_VER) && PLATFORM_ARCH_ARM64
|
||||
// For MSVC ARM64, the following thunk takes a relative jump from the function pointer to the next thunk:
|
||||
// adrp xip0, offset_high
|
||||
// add xip0, xip0, offset_low
|
||||
// br xip0
|
||||
// The last thunk contains the offset to the vtable:
|
||||
// ldr xip0, [x0]
|
||||
// ldr xip0, [xip0, XXX]
|
||||
uint32_t* op = (uint32_t*)func;
|
||||
|
||||
uint32_t def = *op;
|
||||
if ((*op & 0x9F000000) == 0x90000000)
|
||||
{
|
||||
// adrp
|
||||
uint32_t imm20 = (((*op & 0x60000000) >> 29) + ((*op & 0xFFFFE0) >> 3)) << 12;
|
||||
op++;
|
||||
|
||||
// add
|
||||
def = *op;
|
||||
uint32_t imm12 = (*op & 0x3FFC00) >> 10;
|
||||
imm12 = (*op & 0x400000) != 0 ? (imm12 << 12) : imm12;
|
||||
|
||||
// br
|
||||
op = (uint32_t*)(((uintptr)func & ((uintptr)-1 << 12)) + imm20 + imm12) + 1;
|
||||
|
||||
// ldr + offset
|
||||
def = *op;
|
||||
uint32_t offset = ((*op & 0x3FFC00) >> 10) * ((*op & 0x40000000) != 0 ? 8 : 4);
|
||||
return offset / sizeof(void*);
|
||||
}
|
||||
else if ((*op & 0xBFC00000) == 0xB9400000)
|
||||
{
|
||||
// ldr + offset
|
||||
uint32_t offset = ((*op & 0x3FFC00) >> 10) * ((*op & 0x40000000) != 0 ? 8 : 4);
|
||||
op++;
|
||||
|
||||
// ldr + offset
|
||||
def = *op;
|
||||
if ((*op & 0xBFE00C00) == 0xB8400400)
|
||||
{
|
||||
// offset is stored in the register as is
|
||||
uint32_t postindex = (*op & 0x1FF000) >> 12;
|
||||
offset = postindex;
|
||||
return offset / sizeof(void*);
|
||||
}
|
||||
else if ((*op & 0xBFE00C00) == 0xB8400C00)
|
||||
{
|
||||
// offset is added to the value in base register... updated to the same register
|
||||
uint32_t preindex = (*op & 0x1FF000) >> 12;
|
||||
offset += preindex;
|
||||
return offset / sizeof(void*);
|
||||
}
|
||||
else if ((*op & 0xBFC00000) == 0xB9400000)
|
||||
{
|
||||
// 20-bit offset
|
||||
offset = ((*op & 0x3FFC00) >> 10) * ((*op & 0x40000000) != 0 ? 8 : 4);
|
||||
return offset / sizeof(void*);
|
||||
}
|
||||
CRASH;
|
||||
}
|
||||
#elif defined(__clang__)
|
||||
// On Clang member function pointer represents the offset from the vtable begin.
|
||||
return (int32)(intptr)func / sizeof(void*);
|
||||
|
||||
Reference in New Issue
Block a user