mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- syncing these files over from GZDoom
- this does not actually yet build for Windows ARM64, but it does put the framework in place to make that possible in the near future
This commit is contained in:
parent
b58b21cca0
commit
218b0cfb03
9 changed files with 113 additions and 20 deletions
BIN
bin/windows/zmusic/arm64/zmusiclite.dll
Normal file
BIN
bin/windows/zmusic/arm64/zmusiclite.dll
Normal file
Binary file not shown.
BIN
bin/windows/zmusic/arm64/zmusiclite.lib
Normal file
BIN
bin/windows/zmusic/arm64/zmusiclite.lib
Normal file
Binary file not shown.
|
@ -29,7 +29,7 @@
|
|||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM64) || defined (__aarch64__)
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|
@ -48,6 +48,8 @@ set(archdetect_c_code "
|
|||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
||||
#error cmake_ARCH armv5
|
||||
#elif defined(_M_ARM64) || defined (__aarch64__)
|
||||
#error cmake_ARCH arm64
|
||||
#else
|
||||
#error cmake_ARCH arm
|
||||
#endif
|
||||
|
@ -96,6 +98,8 @@ function(target_architecture output_var)
|
|||
set(osx_arch_x86_64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||
set(osx_arch_ppc64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "arm64")
|
||||
set(osx_arch_arm64 TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||
endif()
|
||||
|
@ -117,6 +121,10 @@ function(target_architecture output_var)
|
|||
if(osx_arch_ppc64)
|
||||
list(APPEND ARCH ppc64)
|
||||
endif()
|
||||
|
||||
if(osx_arch_arm64)
|
||||
list(APPEND ARCH arm64)
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ endif()
|
|||
target_architecture(TARGET_ARCHITECTURE)
|
||||
message(STATUS "Architecture is ${TARGET_ARCHITECTURE}")
|
||||
|
||||
if ( ${TARGET_ARCHITECTURE} MATCHES "arm64" )
|
||||
set (ARM64 aarch64)
|
||||
endif()
|
||||
|
||||
# Right now only 64 bit is supported.
|
||||
if( ${TARGET_ARCHITECTURE} MATCHES "x86_64" )
|
||||
set( X64 64 )
|
||||
|
@ -67,7 +71,6 @@ if( WIN32 )
|
|||
set( DX_dinput8_LIBRARY dinput8 )
|
||||
|
||||
set( PROJECT_LIBRARIES
|
||||
opengl32
|
||||
wsock32
|
||||
winmm
|
||||
"${DX_dinput8_LIBRARY}"
|
||||
|
@ -416,6 +419,8 @@ else()
|
|||
find_package( ZMusic REQUIRED )
|
||||
endif()
|
||||
|
||||
message("Building for target architecture: ${TARGET_ARCHITECTURE}")
|
||||
|
||||
if( MSVC AND NOT ZMUSIC_FOUND )
|
||||
# Use prebuilt library
|
||||
set( ZMUSIC_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../bin/windows/zmusic" )
|
||||
|
@ -423,6 +428,8 @@ if( MSVC AND NOT ZMUSIC_FOUND )
|
|||
set( ZMUSIC_LIBRARIES zmusiclite )
|
||||
if( X64 )
|
||||
link_directories( ${ZMUSIC_ROOT_PATH}/64bit )
|
||||
elseif( ${TARGET_ARCHITECTURE} MATCHES "arm" )
|
||||
link_directories( ${ZMUSIC_ROOT_PATH}/arm64 )
|
||||
else()
|
||||
link_directories( ${ZMUSIC_ROOT_PATH}/32bit )
|
||||
endif()
|
||||
|
@ -436,7 +443,9 @@ if( MSVC AND NOT VPX_FOUND )
|
|||
set( VPX_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../platform/Windows" )
|
||||
set( VPX_INCLUDE_DIR ${VPX_ROOT_PATH}/include )
|
||||
set( VPX_LIBRARIES libvpx libcompat-to-msvc )
|
||||
if( X64 )
|
||||
if( ARM64 )
|
||||
link_directories( ${VPX_ROOT_PATH}/lib/arm64 )
|
||||
elseif( X64 )
|
||||
link_directories( ${VPX_ROOT_PATH}/lib/64 )
|
||||
else()
|
||||
link_directories( ${VPX_ROOT_PATH}/lib/32 )
|
||||
|
@ -472,7 +481,6 @@ endif()
|
|||
set( PLAT_WIN32_SOURCES
|
||||
platform/win32/i_steam.cpp
|
||||
common/platform/win32/hardware.cpp
|
||||
common/platform/win32/i_crash.cpp
|
||||
common/platform/win32/i_input.cpp
|
||||
common/platform/win32/i_keyboard.cpp
|
||||
common/platform/win32/i_mouse.cpp
|
||||
|
@ -494,6 +502,15 @@ if (HAVE_VULKAN)
|
|||
set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} common/platform/win32/win32vulkanvideo.cpp )
|
||||
endif()
|
||||
|
||||
# todo: implement an actual crash catcher for ARM
|
||||
# for now this is purely experimental
|
||||
if (NOT ${TARGET_ARCHITECTURE} MATCHES "arm" )
|
||||
set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} common/platform/win32/i_crash.cpp )
|
||||
endif()
|
||||
if (MSVC AND ${TARGET_ARCHITECTURE} MATCHES "arm")
|
||||
add_definitions( -DNO_SSE -D__ARM__ -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN)
|
||||
endif()
|
||||
|
||||
set( PLAT_POSIX_SOURCES
|
||||
platform/posix/i_steam.cpp
|
||||
common/platform/posix/i_system_posix.cpp )
|
||||
|
|
|
@ -97,11 +97,13 @@ private:
|
|||
#else
|
||||
|
||||
// Windows and macOS
|
||||
#ifndef _M_ARM
|
||||
#include "x86.h"
|
||||
#endif
|
||||
|
||||
extern double PerfToSec, PerfToMillisec;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(_M_ARM64)
|
||||
// Trying to include intrin.h here results in some bizarre errors, so I'm just
|
||||
// going to duplicate the function prototype instead.
|
||||
//#include <intrin.h>
|
||||
|
@ -111,6 +113,12 @@ inline unsigned __int64 rdtsc()
|
|||
{
|
||||
return __rdtsc();
|
||||
}
|
||||
#elif defined(_MSC_VER) && defined(_M_ARM64)
|
||||
#include <intrin.h>
|
||||
inline unsigned __int64 rdtsc()
|
||||
{
|
||||
return _ReadStatusReg(ARM64_SYSREG(0b11, 0b011, 0b1001, 0b1101, 0b000)); //_ReadStatusReg(PMCCNTR_EL0);
|
||||
}
|
||||
#elif defined __APPLE__ && (defined __i386__ || defined __x86_64__)
|
||||
inline uint64_t rdtsc()
|
||||
{
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
extern HWND Window;
|
||||
|
||||
extern "C" PROC zd_wglGetProcAddress(LPCSTR name);
|
||||
|
||||
PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
|
||||
|
||||
//==========================================================================
|
||||
|
@ -78,15 +80,15 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) : Syst
|
|||
HDC hDC = GetDC(Window);
|
||||
const char *wglext = nullptr;
|
||||
|
||||
myWglSwapIntervalExtProc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
||||
auto myWglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
|
||||
myWglSwapIntervalExtProc = (PFNWGLSWAPINTERVALEXTPROC)zd_wglGetProcAddress("wglSwapIntervalEXT");
|
||||
auto myWglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)zd_wglGetProcAddress("wglGetExtensionsStringARB");
|
||||
if (myWglGetExtensionsStringARB)
|
||||
{
|
||||
wglext = myWglGetExtensionsStringARB(hDC);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto myWglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||
auto myWglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)zd_wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||
if (myWglGetExtensionsStringEXT)
|
||||
{
|
||||
wglext = myWglGetExtensionsStringEXT();
|
||||
|
|
|
@ -1076,10 +1076,13 @@ void CALLBACK ExitFatally (ULONG_PTR dummy)
|
|||
SetUnhandledExceptionFilter (ExitMessedUp);
|
||||
I_ShutdownGraphics ();
|
||||
RestoreConView ();
|
||||
#ifndef _M_ARM64
|
||||
DisplayCrashLog ();
|
||||
#endif
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#ifndef _M_ARM64
|
||||
//==========================================================================
|
||||
//
|
||||
// CatchAllExceptions
|
||||
|
@ -1132,6 +1135,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info)
|
|||
}
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
#endif // !_M_ARM64
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -1155,7 +1159,11 @@ static void infiniterecursion(int foo)
|
|||
// which offers the very important feature to open a debugger and see the crash in context right away.
|
||||
CUSTOM_CVAR(Bool, disablecrashlog, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
#ifndef _M_ARM64
|
||||
SetUnhandledExceptionFilter(!*self ? CatchAllExceptions : nullptr);
|
||||
#else
|
||||
SetUnhandledExceptionFilter(nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1217,7 +1225,9 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int
|
|||
#ifndef _DEBUG
|
||||
if (MainThread != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
#ifndef _M_ARM64
|
||||
SetUnhandledExceptionFilter (CatchAllExceptions);
|
||||
#endif
|
||||
|
||||
#ifdef _M_X64
|
||||
static bool setJumpResult = false;
|
||||
|
|
|
@ -55,6 +55,13 @@
|
|||
|
||||
#include "gl_framebuffer.h"
|
||||
|
||||
extern "C" {
|
||||
HGLRC zd_wglCreateContext(HDC Arg1);
|
||||
BOOL zd_wglDeleteContext(HGLRC Arg1);
|
||||
BOOL zd_wglMakeCurrent(HDC Arg1, HGLRC Arg2);
|
||||
PROC zd_wglGetProcAddress(LPCSTR name);
|
||||
}
|
||||
|
||||
EXTERN_CVAR(Int, vid_adapter)
|
||||
EXTERN_CVAR(Bool, vid_hdr)
|
||||
|
||||
|
@ -74,7 +81,7 @@ CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFI
|
|||
extern bool vid_hdr_active;
|
||||
|
||||
// these get used before GLEW is initialized so we have to use separate pointers with different names
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)zd_wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB;
|
||||
|
||||
|
||||
|
@ -224,15 +231,15 @@ bool Win32GLVideo::SetPixelFormat()
|
|||
|
||||
::SetPixelFormat(hDC, pixelFormat, &pfd);
|
||||
|
||||
hRC = wglCreateContext(hDC);
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
hRC = zd_wglCreateContext(hDC);
|
||||
zd_wglMakeCurrent(hDC, hRC);
|
||||
|
||||
myWglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
myWglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
myWglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)zd_wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
myWglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)zd_wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
// any extra stuff here?
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(hRC);
|
||||
zd_wglMakeCurrent(NULL, NULL);
|
||||
zd_wglDeleteContext(hRC);
|
||||
ReleaseDC(dummy, hDC);
|
||||
ShutdownDummy(dummy);
|
||||
|
||||
|
@ -436,7 +443,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
|
|||
|
||||
if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
|
||||
{
|
||||
m_hRC = wglCreateContext(m_hDC);
|
||||
m_hRC = zd_wglCreateContext(m_hDC);
|
||||
if (m_hRC == NULL)
|
||||
{
|
||||
I_Error("R_OPENGL: Unable to create an OpenGL render context.\n");
|
||||
|
@ -446,7 +453,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
|
|||
|
||||
if (m_hRC != NULL)
|
||||
{
|
||||
wglMakeCurrent(m_hDC, m_hRC);
|
||||
zd_wglMakeCurrent(m_hDC, m_hRC);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -465,8 +472,8 @@ void Win32GLVideo::Shutdown()
|
|||
{
|
||||
if (m_hRC)
|
||||
{
|
||||
wglMakeCurrent(0, 0);
|
||||
wglDeleteContext(m_hRC);
|
||||
zd_wglMakeCurrent(0, 0);
|
||||
zd_wglDeleteContext(m_hRC);
|
||||
}
|
||||
if (m_hDC) ReleaseDC(m_Window, m_hDC);
|
||||
}
|
||||
|
|
|
@ -67,10 +67,51 @@ static int TestPointer(const PROC pTest)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static HMODULE opengl32dll;
|
||||
static HGLRC(WINAPI* createcontext)(HDC);
|
||||
static BOOL(WINAPI* deletecontext)(HGLRC);
|
||||
static BOOL(WINAPI* makecurrent)(HDC, HGLRC);
|
||||
static PROC(WINAPI* getprocaddress)(LPCSTR name);
|
||||
static void CheckOpenGL(void)
|
||||
{
|
||||
if (opengl32dll == 0)
|
||||
{
|
||||
opengl32dll = LoadLibrary(L"OpenGL32.DLL");
|
||||
createcontext = (HGLRC(WINAPI*)(HDC)) GetProcAddress(opengl32dll, "wglCreateContext");
|
||||
deletecontext = (BOOL(WINAPI*)(HGLRC)) GetProcAddress(opengl32dll, "wglDeleteContext");
|
||||
makecurrent = (BOOL(WINAPI*)(HDC, HGLRC)) GetProcAddress(opengl32dll, "wglMakeCurrent");
|
||||
getprocaddress = (PROC(WINAPI*)(LPCSTR)) GetProcAddress(opengl32dll, "wglGetProcAddress");
|
||||
}
|
||||
}
|
||||
|
||||
HGLRC zd_wglCreateContext(HDC dc)
|
||||
{
|
||||
CheckOpenGL();
|
||||
return createcontext(dc);
|
||||
}
|
||||
|
||||
BOOL zd_wglDeleteContext(HGLRC context)
|
||||
{
|
||||
CheckOpenGL();
|
||||
return deletecontext(context);
|
||||
}
|
||||
|
||||
BOOL zd_wglMakeCurrent(HDC dc, HGLRC context)
|
||||
{
|
||||
CheckOpenGL();
|
||||
return makecurrent(dc, context);
|
||||
}
|
||||
|
||||
PROC zd_wglGetProcAddress(LPCSTR name)
|
||||
{
|
||||
CheckOpenGL();
|
||||
return getprocaddress(name);
|
||||
}
|
||||
|
||||
static PROC WinGetProcAddress(const char *name)
|
||||
{
|
||||
HMODULE glMod = NULL;
|
||||
PROC pFunc = wglGetProcAddress((LPCSTR)name);
|
||||
PROC pFunc = zd_wglGetProcAddress((LPCSTR)name);
|
||||
if(TestPointer(pFunc))
|
||||
{
|
||||
return pFunc;
|
||||
|
|
Loading…
Reference in a new issue