From a10339145307c0c27f78bdfd83f650388e23051a Mon Sep 17 00:00:00 2001 From: Er2 Date: Mon, 14 Aug 2023 14:02:28 +0300 Subject: [PATCH] it runs --- common/sse2neon.h | 44 --- engine/gl_lightmap.cpp | 2 + engine/sys_engine.cpp | 2 +- game/client/client_virtualreality.cpp | 2 +- inputsystem/inputsystem.cpp | 4 - inputsystem/inputsystem.h | 9 - inputsystem/joystick_win32.cpp | 370 -------------------------- inputsystem/wscript | 8 +- launcher/launcher.cpp | 10 +- launcher_main/wscript | 2 +- lib | 2 +- mathlib/sse.cpp | 16 +- public/materialsystem/imesh.h | 18 +- public/mathlib/mathlib.h | 4 +- public/mathlib/simdvectormatrix.h | 6 +- public/mathlib/ssemath.h | 12 +- public/mathlib/vmatrix.h | 2 +- public/shaderapi/ishaderapi.h | 4 - public/tier0/commonmacros.h | 2 +- public/tier0/platform.h | 19 +- public/tier0/threadtools.h | 6 +- public/tier0/tslist.h | 9 +- studiorender/r_studiodraw.cpp | 2 +- studiorender/r_studiolight.cpp | 4 +- studiorender/r_studiolight.h | 5 +- studiorender/studiorender.h | 3 - tier0/PMELib.cpp | 2 +- tier0/cpu.cpp | 2 +- tier0/stacktools.cpp | 6 +- tier0/threadtools.cpp | 8 +- tier0/wscript | 4 +- tier1/processor_detect.cpp | 2 +- vstdlib/coroutine.cpp | 6 +- wscript | 20 +- 34 files changed, 100 insertions(+), 517 deletions(-) delete mode 100644 inputsystem/joystick_win32.cpp diff --git a/common/sse2neon.h b/common/sse2neon.h index 4e54e11e..c20215b2 100644 --- a/common/sse2neon.h +++ b/common/sse2neon.h @@ -9182,50 +9182,6 @@ FORCE_INLINE void _sse2neon_mm_set_denormals_zero_mode(unsigned int flag) } #endif -// Return the current 64-bit value of the processor's time-stamp counter. -// https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=rdtsc -FORCE_INLINE uint64_t _rdtsc(void) -{ -#if defined(__aarch64__) || defined(_M_ARM64) - uint64_t val; - - /* According to ARM DDI 0487F.c, from Armv8.0 to Armv8.5 inclusive, the - * system counter is at least 56 bits wide; from Armv8.6, the counter - * must be 64 bits wide. So the system counter could be less than 64 - * bits wide and it is attributed with the flag 'cap_user_time_short' - * is true. - */ -#if defined(_MSC_VER) - val = _ReadStatusReg(ARM64_SYSREG(3, 3, 14, 0, 2)); -#else - __asm__ __volatile__("mrs %0, cntvct_el0" : "=r"(val)); -#endif - - return val; -#elif defined(_M_ARM) - uint32_t val = _MoveFromCoprocessor(15,0, 9,13,0); - return ((uint64_t)val) << 6; -#else - uint32_t pmccntr, pmuseren, pmcntenset; - // Read the user mode Performance Monitoring Unit (PMU) - // User Enable Register (PMUSERENR) access permissions. - __asm__ __volatile__("mrc p15, 0, %0, c9, c14, 0" : "=r"(pmuseren)); - if (pmuseren & 1) { // Allows reading PMUSERENR for user mode code. - __asm__ __volatile__("mrc p15, 0, %0, c9, c12, 1" : "=r"(pmcntenset)); - if (pmcntenset & 0x80000000UL) { // Is it counting? - __asm__ __volatile__("mrc p15, 0, %0, c9, c13, 0" : "=r"(pmccntr)); - // The counter is set up to count every 64th cycle - return (uint64_t) (pmccntr) << 6; - } - } - - // Fallback to syscall as we can't enable PMUSERENR in user mode. - struct timeval tv; - gettimeofday(&tv, NULL); - return (uint64_t) (tv.tv_sec) * 1000000 + tv.tv_usec; -#endif -} - #if defined(__GNUC__) || defined(__clang__) #pragma pop_macro("ALIGN_STRUCT") #pragma pop_macro("FORCE_INLINE") diff --git a/engine/gl_lightmap.cpp b/engine/gl_lightmap.cpp index 5619120c..8336afba 100644 --- a/engine/gl_lightmap.cpp +++ b/engine/gl_lightmap.cpp @@ -1333,6 +1333,7 @@ void CacheAndUnloadLightmapData() host_state.worldbrush->unloadedlightmaps = true; } +#pragma optimize("", off) //sorts the surfaces in place static void SortSurfacesByLightmapID( SurfaceHandle_t *pToSort, int iSurfaceCount ) { @@ -1448,6 +1449,7 @@ void R_RedownloadAllLightmaps() g_RebuildLightmaps = false; } +#pragma optimize("", on) //----------------------------------------------------------------------------- // Purpose: flag the lightmaps as needing to be rebuilt (gamma change) diff --git a/engine/sys_engine.cpp b/engine/sys_engine.cpp index f0ef97d3..f70805fc 100644 --- a/engine/sys_engine.cpp +++ b/engine/sys_engine.cpp @@ -104,7 +104,7 @@ extern ConVar host_timer_spin_ms; extern float host_nexttick; extern IVEngineClient *engineClient; -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) static void cpu_frequency_monitoring_callback( IConVar *var, const char *pOldValue, float flOldValue ) { // Set the specified interval for CPU frequency monitoring diff --git a/game/client/client_virtualreality.cpp b/game/client/client_virtualreality.cpp index af52b56e..842c4941 100644 --- a/game/client/client_virtualreality.cpp +++ b/game/client/client_virtualreality.cpp @@ -152,7 +152,7 @@ CON_COMMAND( vr_toggle, "Toggles VR mode" ) // -------------------------------------------------------------------- // Purpose: Returns true if the matrix is orthonormal // -------------------------------------------------------------------- -bool IsOrthonormal ( VMatrix Mat, float fTolerance ) +bool IsOrthonormal ( VMatrix& Mat, float fTolerance ) { float LenFwd = Mat.GetForward().Length(); float LenUp = Mat.GetUp().Length(); diff --git a/inputsystem/inputsystem.cpp b/inputsystem/inputsystem.cpp index f948b5ce..44a0c785 100644 --- a/inputsystem/inputsystem.cpp +++ b/inputsystem/inputsystem.cpp @@ -167,10 +167,8 @@ InitReturnVal_t CInputSystem::Init() joy_xcontroller_found.SetValue( 0 ); -#ifdef USE_SDL if( !m_bConsoleTextMode ) InitializeTouch(); -#endif if ( IsPC() && !m_bConsoleTextMode ) { @@ -977,9 +975,7 @@ void CInputSystem::SetPrimaryUserId( int userId ) //----------------------------------------------------------------------------- void CInputSystem::SetRumble( float fLeftMotor, float fRightMotor, int userId ) { -#ifdef USE_SDL SetXDeviceRumble( fLeftMotor, fRightMotor, userId ); -#endif } diff --git a/inputsystem/inputsystem.h b/inputsystem/inputsystem.h index 490d6f33..c369851e 100644 --- a/inputsystem/inputsystem.h +++ b/inputsystem/inputsystem.h @@ -145,16 +145,10 @@ public: struct JoystickInfo_t { -#ifdef USE_SDL void *m_pDevice; // Really an SDL_GameController*, NULL if not present. void *m_pHaptic; // Really an SDL_Haptic* float m_fCurrentRumble; bool m_bRumbleEnabled; -#elif defined(_WIN32) - JOYINFOEX m_JoyInfoEx; -#else -#error -#endif int m_nButtonCount; int m_nAxisFlags; int m_nDeviceId; @@ -277,9 +271,6 @@ public: //Added called and set to true when binding input and set to false once bound void SetNovintPure( bool bPure ); -#ifndef USE_SDL - unsigned int AxisValue( JoystickAxis_t axis, JOYINFOEX& ji ); -#endif #else void SetNovintPure( bool bPure ) {} // to satify the IInput virtual interface #endif diff --git a/inputsystem/joystick_win32.cpp b/inputsystem/joystick_win32.cpp deleted file mode 100644 index 9dd1176e..00000000 --- a/inputsystem/joystick_win32.cpp +++ /dev/null @@ -1,370 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: PC Joystick implementation for inputsystem.dll -// -//===========================================================================// - -/* For force feedback testing. */ -#include "inputsystem.h" -#include "tier1/convar.h" -#include "tier0/icommandline.h" - -//----------------------------------------------------------------------------- -// Joystick helpers -//----------------------------------------------------------------------------- -#define JOY_POVFWDRIGHT ( ( JOY_POVFORWARD + JOY_POVRIGHT ) >> 1 ) // 4500 -#define JOY_POVRIGHTBACK ( ( JOY_POVRIGHT + JOY_POVBACKWARD ) >> 1 ) // 13500 -#define JOY_POVFBACKLEFT ( ( JOY_POVBACKWARD + JOY_POVLEFT ) >> 1 ) // 22500 -#define JOY_POVLEFTFWD ( ( JOY_POVLEFT + JOY_POVFORWARD ) >> 1 ) // 31500 - -ConVar joy_wwhack1( "joy_wingmanwarrior_centerhack", "0", FCVAR_ARCHIVE, "Wingman warrior centering hack." ); -ConVar joy_axisbutton_threshold( "joy_axisbutton_threshold", "0.3", FCVAR_ARCHIVE, "Analog axis range before a button press is registered." ); - -//----------------------------------------------------------------------------- -// Initialize all joysticks -//----------------------------------------------------------------------------- -void CInputSystem::InitializeJoysticks( void ) -{ - // assume no joystick - m_nJoystickCount = 0; - - // abort startup if user requests no joystick - if ( CommandLine()->FindParm("-nojoy" ) ) - return; - - // verify joystick driver is present - int nMaxJoysticks = joyGetNumDevs(); - if ( nMaxJoysticks > MAX_JOYSTICKS ) - { - nMaxJoysticks = MAX_JOYSTICKS; - } - else if ( nMaxJoysticks <= 0 ) - { - DevMsg( 1, "joystick not found -- driver not present\n"); - return; - } - - // cycle through the joysticks looking for valid ones - MMRESULT mmr; - for ( int i=0; i < nMaxJoysticks; i++ ) - { - JOYINFOEX ji; - Q_memset( &ji, 0, sizeof( ji ) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = JOY_RETURNCENTERED; - mmr = joyGetPosEx( i, &ji ); - if ( mmr != JOYERR_NOERROR ) - continue; - - // get the capabilities of the selected joystick - // abort startup if command fails - JOYCAPS jc; - Q_memset( &jc, 0, sizeof( jc ) ); - mmr = joyGetDevCaps( i, &jc, sizeof( jc ) ); - if ( mmr != JOYERR_NOERROR ) - continue; - - JoystickInfo_t &info = m_pJoystickInfo[m_nJoystickCount]; - info.m_nDeviceId = i; - info.m_JoyInfoEx = ji; - info.m_nButtonCount = (int)jc.wNumButtons; - info.m_bHasPOVControl = ( jc.wCaps & JOYCAPS_HASPOV ) ? true : false; - info.m_bDiagonalPOVControlEnabled = false; - info.m_nFlags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNX | JOY_RETURNY; - info.m_nAxisFlags = 0; - if ( jc.wNumAxes >= 2 ) - { - info.m_nAxisFlags |= 0x3; - } - if ( info.m_bHasPOVControl ) - { - info.m_nFlags |= JOY_RETURNPOV; - } - if ( jc.wCaps & JOYCAPS_HASZ ) - { - info.m_nFlags |= JOY_RETURNZ; - info.m_nAxisFlags |= 0x4; - } - if ( jc.wCaps & JOYCAPS_HASR ) - { - info.m_nFlags |= JOY_RETURNR; - info.m_nAxisFlags |= 0x8; - } - if ( jc.wCaps & JOYCAPS_HASU ) - { - info.m_nFlags |= JOY_RETURNU; - info.m_nAxisFlags |= 0x10; - } - if ( jc.wCaps & JOYCAPS_HASV ) - { - info.m_nFlags |= JOY_RETURNV; - info.m_nAxisFlags |= 0x20; - } - info.m_nLastPolledButtons = 0; - info.m_nLastPolledAxisButtons = 0; - info.m_nLastPolledPOVState = 0; - memset( info.m_pLastPolledAxes, 0, sizeof(info.m_pLastPolledAxes) ); - ++m_nJoystickCount; - - EnableJoystickInput( i, true ); - } -} - -void CInputSystem::ShutdownJoysticks() -{ -} - -//----------------------------------------------------------------------------- -// Process the event -//----------------------------------------------------------------------------- -void CInputSystem::JoystickButtonEvent( ButtonCode_t button, int sample ) -{ - // package the key - if ( sample ) - { - PostButtonPressedEvent( IE_ButtonPressed, m_nLastSampleTick, button, button ); - } - else - { - PostButtonReleasedEvent( IE_ButtonReleased, m_nLastSampleTick, button, button ); - } -} - - -//----------------------------------------------------------------------------- -// Update the joystick button state -//----------------------------------------------------------------------------- -void CInputSystem::UpdateJoystickButtonState( int nJoystick ) -{ - JoystickInfo_t &info = m_pJoystickInfo[nJoystick]; - JOYINFOEX& ji = info.m_JoyInfoEx; - - // Standard joystick buttons - unsigned int buttons = ji.dwButtons ^ info.m_nLastPolledButtons; - if ( buttons ) - { - for ( int j = 0 ; j < info.m_nButtonCount ; ++j ) - { - int mask = buttons & ( 1 << j ); - if ( !mask ) - continue; - - ButtonCode_t code = (ButtonCode_t)JOYSTICK_BUTTON( nJoystick, j ); - if ( mask & ji.dwButtons ) - { - // down event - JoystickButtonEvent( code, MAX_BUTTONSAMPLE ); - } - else - { - // up event - JoystickButtonEvent( code, 0 ); - } - } - - info.m_nLastPolledButtons = (unsigned int)ji.dwButtons; - } - - // Analog axis buttons - const float minValue = joy_axisbutton_threshold.GetFloat() * MAX_BUTTONSAMPLE; - for ( int j = 0 ; j < MAX_JOYSTICK_AXES; ++j ) - { - if ( ( info.m_nAxisFlags & (1 << j) ) == 0 ) - continue; - - // Positive side of the axis - int mask = ( 1 << (j << 1) ); - ButtonCode_t code = JOYSTICK_AXIS_BUTTON( nJoystick, (j << 1) ); - float value = GetAnalogValue( JOYSTICK_AXIS( nJoystick, j ) ); - - if ( value > minValue && !(info.m_nLastPolledAxisButtons & mask) ) - { - info.m_nLastPolledAxisButtons |= mask; - JoystickButtonEvent( code, MAX_BUTTONSAMPLE ); - } - if ( value <= minValue && (info.m_nLastPolledAxisButtons & mask) ) - { - info.m_nLastPolledAxisButtons &= ~mask; - JoystickButtonEvent( code, 0 ); - } - - // Negative side of the axis - mask <<= 1; - code = (ButtonCode_t)( code + 1 ); - if ( value < -minValue && !(info.m_nLastPolledAxisButtons & mask) ) - { - info.m_nLastPolledAxisButtons |= mask; - JoystickButtonEvent( code, MAX_BUTTONSAMPLE ); - } - if ( value >= -minValue && (info.m_nLastPolledAxisButtons & mask) ) - { - info.m_nLastPolledAxisButtons &= ~mask; - JoystickButtonEvent( code, 0 ); - } - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Get raw joystick sample along axis -//----------------------------------------------------------------------------- -unsigned int CInputSystem::AxisValue( JoystickAxis_t axis, JOYINFOEX& ji ) -{ - switch (axis) - { - case JOY_AXIS_X: - return (unsigned int)ji.dwXpos; - case JOY_AXIS_Y: - return (unsigned int)ji.dwYpos; - case JOY_AXIS_Z: - return (unsigned int)ji.dwZpos; - case JOY_AXIS_R: - return (unsigned int)ji.dwRpos; - case JOY_AXIS_U: - return (unsigned int)ji.dwUpos; - case JOY_AXIS_V: - return (unsigned int)ji.dwVpos; - } - // FIX: need to do some kind of error - return (unsigned int)ji.dwXpos; -} - - -//----------------------------------------------------------------------------- -// Update the joystick POV control -//----------------------------------------------------------------------------- -void CInputSystem::UpdateJoystickPOVControl( int nJoystick ) -{ - JoystickInfo_t &info = m_pJoystickInfo[nJoystick]; - JOYINFOEX& ji = info.m_JoyInfoEx; - - if ( !info.m_bHasPOVControl ) - return; - - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - unsigned int povstate = 0; - - if ( ji.dwPOV != JOY_POVCENTERED ) - { - if (ji.dwPOV == JOY_POVFORWARD) // 0 - { - povstate |= 0x01; - } - if (ji.dwPOV == JOY_POVRIGHT) // 9000 - { - povstate |= 0x02; - } - if (ji.dwPOV == JOY_POVBACKWARD) // 18000 - { - povstate |= 0x04; - } - if (ji.dwPOV == JOY_POVLEFT) // 27000 - { - povstate |= 0x08; - } - - // Deal with diagonals if user wants them - if ( info.m_bDiagonalPOVControlEnabled ) - { - if (ji.dwPOV == JOY_POVFWDRIGHT) // 4500 - { - povstate |= ( 0x01 | 0x02 ); - } - if (ji.dwPOV == JOY_POVRIGHTBACK) // 13500 - { - povstate |= ( 0x02 | 0x04 ); - } - if (ji.dwPOV == JOY_POVFBACKLEFT) // 22500 - { - povstate |= ( 0x04 | 0x08 ); - } - if (ji.dwPOV == JOY_POVLEFTFWD) // 31500 - { - povstate |= ( 0x08 | 0x01 ); - } - } - } - - // determine which bits have changed and key an auxillary event for each change - unsigned int buttons = povstate ^ info.m_nLastPolledPOVState; - if ( buttons ) - { - for ( int i = 0; i < JOYSTICK_POV_BUTTON_COUNT; ++i ) - { - unsigned int mask = buttons & ( 1 << i ); - if ( !mask ) - continue; - - ButtonCode_t code = (ButtonCode_t)JOYSTICK_POV_BUTTON( nJoystick, i ); - - if ( mask & povstate ) - { - // Keydown on POV buttons - JoystickButtonEvent( code, MAX_BUTTONSAMPLE ); - } - else - { - // KeyUp on POV buttons - JoystickButtonEvent( code, 0 ); - } - } - - // Latch old values - info.m_nLastPolledPOVState = povstate; - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Sample the joystick -//----------------------------------------------------------------------------- -void CInputSystem::PollJoystick( void ) -{ - if ( !m_JoysticksEnabled.IsAnyFlagSet() ) - return; - - InputState_t &state = m_InputState[ m_bIsPolling ]; - for ( int i = 0; i < m_nJoystickCount; ++i ) - { - if ( !m_JoysticksEnabled.IsFlagSet( 1 << i ) ) - continue; - - JoystickInfo_t &info = m_pJoystickInfo[i]; - JOYINFOEX& ji = info.m_JoyInfoEx; - Q_memset( &ji, 0, sizeof( ji ) ); - ji.dwSize = sizeof( ji ); - ji.dwFlags = (DWORD)info.m_nFlags; - - if ( joyGetPosEx( info.m_nDeviceId, &ji ) != JOYERR_NOERROR ) - continue; - - // This hack fixes a bug in the Logitech WingMan Warrior DirectInput Driver - // rather than having 32768 be the zero point, they have the zero point at 32668 - // go figure -- anyway, now we get the full resolution out of the device - if ( joy_wwhack1.GetBool() ) - { - ji.dwUpos += 100; - } - - // Poll joystick axes - for ( int j = 0; j < MAX_JOYSTICK_AXES; ++j ) - { - if ( ( info.m_nAxisFlags & ( 1 << j ) ) == 0 ) - continue; - - AnalogCode_t code = JOYSTICK_AXIS( i, j ); - int nValue = AxisValue( (JoystickAxis_t)j, ji ) - MAX_BUTTONSAMPLE; - state.m_pAnalogDelta[ code ] = nValue - state.m_pAnalogValue[ code ]; - state.m_pAnalogValue[ code ] = nValue; - if ( state.m_pAnalogDelta[ code ] != 0 ) - { - PostEvent( IE_AnalogValueChanged, m_nLastSampleTick, code, state.m_pAnalogValue[ code ], state.m_pAnalogDelta[ code ] ); - } - } - - UpdateJoystickButtonState( i ); - UpdateJoystickPOVControl( i ); - } -} diff --git a/inputsystem/wscript b/inputsystem/wscript index af1a19ca..252452aa 100755 --- a/inputsystem/wscript +++ b/inputsystem/wscript @@ -18,6 +18,8 @@ def configure(conf): def build(bld): source = [ 'inputsystem.cpp', + 'joystick_sdl.cpp', + 'touch_sdl.cpp', 'key_translation.cpp', 'steamcontroller.cpp', '../public/tier0/memoverride.cpp' @@ -39,12 +41,6 @@ def build(bld): libs = ['tier0','tier1','tier2','vstdlib','SDL2','steam_api'] - if bld.options.SDL: - source += ['joystick_sdl.cpp', 'touch_sdl.cpp'] - elif bld.env.DEST_OS == 'win32': - source += ['joystick_win32.cpp'] - libs += ['WINMM'] - if bld.env.DEST_OS == 'win32': libs += ['USER32'] diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 0b27da73..5c4c0c29 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -653,6 +653,11 @@ void ReportDirtyDiskNoMaterialSystem() //----------------------------------------------------------------------------- bool CSourceAppSystemGroup::Create() { + if ( !CommandLine()->FindParm( "-nolog" ) ) + DebugLogger()->Init("engine.log"); + else + DebugLogger()->Disable(); + IFileSystem *pFileSystem = (IFileSystem*)FindSystem( FILESYSTEM_INTERFACE_VERSION ); pFileSystem->InstallDirtyDiskReportFunc( ReportDirtyDiskNoMaterialSystem ); @@ -767,11 +772,6 @@ bool CSourceAppSystemGroup::Create() bool CSourceAppSystemGroup::PreInit() { - if ( !CommandLine()->FindParm( "-nolog" ) ) - DebugLogger()->Init("engine.log"); - else - DebugLogger()->Disable(); - CreateInterfaceFn factory = GetFactory(); ConnectTier1Libraries( &factory, 1 ); ConVar_Register( ); diff --git a/launcher_main/wscript b/launcher_main/wscript index 11f105b0..6edae872 100755 --- a/launcher_main/wscript +++ b/launcher_main/wscript @@ -15,7 +15,7 @@ def configure(conf): return def build(bld): - if bld.env.DEST_OS == 'android': + if bld.env.MOBILE and bld.env.DEST_OS=='android': return source = ['main.cpp'] diff --git a/lib b/lib index 86a66ee9..09cc8293 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit 86a66ee92d9fda0a09f54a435e850faa7ab5d0fa +Subproject commit 09cc8293779b1f2c879cca276e9a3f715ab5309d diff --git a/mathlib/sse.cpp b/mathlib/sse.cpp index 000f352c..39ea7a2b 100644 --- a/mathlib/sse.cpp +++ b/mathlib/sse.cpp @@ -91,13 +91,13 @@ float _SSE_Sqrt(float x) { Assert( s_bMathlibInitialized ); float root = 0.f; -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && !defined(_M_ARM) && !defined(_M_ARM64) _asm { sqrtss xmm0, x movss root, xmm0 } -#elif POSIX +#else _mm_store_ss( &root, _mm_sqrt_ss( _mm_load_ss( &x ) ) ); #endif return root; @@ -122,7 +122,7 @@ float _SSE_RSqrtAccurate(float x) } #else -#if POSIX || defined(_M_ARM) +#if POSIX || defined(_M_ARM) || defined(_M_ARM64) const __m128 f3 = _mm_set_ss(3.0f); // 3 as SSE value const __m128 f05 = _mm_set_ss(0.5f); // 0.5 as SSE value #endif @@ -131,7 +131,7 @@ const __m128 f05 = _mm_set_ss(0.5f); // 0.5 as SSE value float _SSE_RSqrtAccurate(float a) { -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && !defined(_M_ARM) && !defined(_M_ARM64) float x; float half = 0.5f; float three = 3.f; @@ -153,8 +153,8 @@ float _SSE_RSqrtAccurate(float a) } return x; -#elif POSIX || defined(_M_ARM) - __m128 xx = _mm_load_ss( &a ); +#else + __m128 xx = _mm_load_ss( &a ); __m128 xr = _mm_rsqrt_ss( xx ); __m128 xt; @@ -166,8 +166,6 @@ float _SSE_RSqrtAccurate(float a) _mm_store_ss( &a, xr ); return a; -#else - #error "Not Implemented" #endif } @@ -764,7 +762,7 @@ float _SSE_cos( float x ) //----------------------------------------------------------------------------- // SSE2 implementations of optimized routines: //----------------------------------------------------------------------------- -#if defined(PLATFORM_WINDOWS_PC32) && !defined(_M_ARM) +#if defined(_M_IX86) void _SSE2_SinCos(float x, float* s, float* c) // any x { #ifdef _WIN32 diff --git a/public/materialsystem/imesh.h b/public/materialsystem/imesh.h index e8f469a7..19cd83e1 100644 --- a/public/materialsystem/imesh.h +++ b/public/materialsystem/imesh.h @@ -1220,7 +1220,7 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX7_t &vertex ) Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed Assert( m_nCurrentVertex < m_nMaxVertexCount ); -#if defined( _WIN32 ) && !defined( _X360 ) && !defined( PLATFORM_64BITS ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) && defined( _M_IX86 ) const void *pRead = &vertex; void *pCurrPos = m_pCurrPosition; __asm @@ -1236,7 +1236,7 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX7_t &vertex ) movntps [edi + 16], xmm1 movntps [edi + 32], xmm2 } -#elif defined(GNUC) || defined(_WIN32) +#else const char *pRead = (char *)&vertex; char *pCurrPos = (char *)m_pCurrPosition; __m128 m1 = _mm_load_ps( (float *)pRead ); @@ -1245,8 +1245,6 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX7_t &vertex ) _mm_stream_ps( (float *)pCurrPos, m1 ); _mm_stream_ps( (float *)((intp)pCurrPos + 16), m2 ); _mm_stream_ps( (float *)((intp)pCurrPos + 32), m3 ); -#else - Error( "Implement CMeshBuilder::FastVertexSSE(dx7)" ); #endif IncrementFloatPointer( m_pCurrPosition, m_VertexSize_Position ); @@ -1267,7 +1265,7 @@ inline void CVertexBuilder::Fast4VerticesSSE( Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed Assert( m_nCurrentVertex < m_nMaxVertexCount-3 ); -#if defined( _WIN32 ) && !defined( _X360 ) && !defined( PLATFORM_64BITS ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) && defined( _M_IX86 ) void *pCurrPos = m_pCurrPosition; __asm { @@ -1309,7 +1307,7 @@ inline void CVertexBuilder::Fast4VerticesSSE( movntps [edi + 80+96], xmm5 } -#elif defined(__arm__) || defined(_WIN32) +#else const void *pReadA = &vtx_a; const void *pReadB = &vtx_b; const void *pReadC = &vtx_c; @@ -1341,8 +1339,6 @@ inline void CVertexBuilder::Fast4VerticesSSE( _mm_stream_ps( (float *)((intp)pCurrPos + 48+96), m4 ); _mm_stream_ps( (float *)((intp)pCurrPos + 64+96), m5 ); _mm_stream_ps( (float *)((intp)pCurrPos + 80+96), m6 ); -#else - Error( "Implement CMeshBuilder::Fast4VerticesSSE\n"); #endif IncrementFloatPointer( m_pCurrPosition, 4*m_VertexSize_Position ); @@ -1430,7 +1426,7 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX8_t &vertex ) Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed Assert( m_nCurrentVertex < m_nMaxVertexCount ); -#if defined( _WIN32 ) && !defined( _X360 ) && !defined( PLATFORM_64BITS ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) && defined( _M_IX86 ) const void *pRead = &vertex; void *pCurrPos = m_pCurrPosition; __asm @@ -1448,7 +1444,7 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX8_t &vertex ) movntps [edi + 32], xmm2 movntps [edi + 48], xmm3 } -#elif defined(GNUC) || defined(_WIN32) +#else const void *pRead = &vertex; void *pCurrPos = m_pCurrPosition; @@ -1460,8 +1456,6 @@ inline void CVertexBuilder::FastVertexSSE( const ModelVertexDX8_t &vertex ) _mm_stream_ps( (float *)((intp)pCurrPos + 16), m2 ); _mm_stream_ps( (float *)((intp)pCurrPos + 32), m3 ); _mm_stream_ps( (float *)((intp)pCurrPos + 48), m4 ); -#else - Error( "Implement CMeshBuilder::FastVertexSSE((dx8)" ); #endif IncrementFloatPointer( m_pCurrPosition, m_VertexSize_Position ); diff --git a/public/mathlib/mathlib.h b/public/mathlib/mathlib.h index 43f5ecda..4be9e8c9 100644 --- a/public/mathlib/mathlib.h +++ b/public/mathlib/mathlib.h @@ -405,7 +405,7 @@ void inline SinCos( float radians, float *sine, float *cosine ) { #if defined( _X360 ) XMScalarSinCos( sine, cosine, radians ); -#elif defined( PLATFORM_WINDOWS_PC64 ) || defined(_M_ARM) +#elif defined( PLATFORM_WINDOWS_PC64 ) || defined(_M_ARM) || defined(_M_ARM64) *sine = sin( radians ); *cosine = cos( radians ); #elif defined( PLATFORM_WINDOWS_PC32 ) @@ -1188,7 +1188,7 @@ inline float SimpleSplineRemapValClamped( float val, float A, float B, float C, FORCEINLINE int RoundFloatToInt(float f) { -#if defined(__i386__) || defined(_M_IX86) || defined( PLATFORM_WINDOWS_PC64 ) || defined(__x86_64__) +#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) return _mm_cvtss_si32(_mm_load_ss(&f)); #elif defined( _X360 ) #ifdef Assert diff --git a/public/mathlib/simdvectormatrix.h b/public/mathlib/simdvectormatrix.h index 88cfef02..2dab8569 100644 --- a/public/mathlib/simdvectormatrix.h +++ b/public/mathlib/simdvectormatrix.h @@ -135,8 +135,12 @@ public: Assert( m_pData ); static FourVectors value{Four_Zeros, Four_Zeros, Four_Zeros}; - for (size_t n = m_nHeight * m_nPaddedWidth; n; n--) +#if defined(_M_ARM) // fuck msvc with C2719 error + for (size_t n = m_nHeight*m_nPaddedWidth; n; n--) *(m_pData+n) = value; +#else + memutils::set( m_pData, value, m_nHeight*m_nPaddedWidth ); +#endif } void RaiseToPower( float power ); diff --git a/public/mathlib/ssemath.h b/public/mathlib/ssemath.h index d54f2487..8b0c1158 100644 --- a/public/mathlib/ssemath.h +++ b/public/mathlib/ssemath.h @@ -8,7 +8,7 @@ #if defined( _X360 ) #include -#elif defined(__arm__) || defined(__aarch64__) +#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) #include "sse2neon.h" #else #include @@ -63,7 +63,7 @@ typedef __m128 fltx4; typedef __m128 i32x4; typedef __m128 u32x4; -#ifdef _M_ARM +#if defined(_M_ARM) || defined(_M_ARM64) #define FLTX4(w, x, y, z) {(w) + (unsigned long long(x) << 32), (y) + (unsigned long long(z) << 32)} #else #define FLTX4(w, x, y, z) {w, x, y, z} @@ -1834,7 +1834,7 @@ FORCEINLINE fltx4 ReplicateX4( float flValue ) FORCEINLINE float SubFloat( const fltx4 & a, int idx ) { // NOTE: if the output goes into a register, this causes a Load-Hit-Store stall (don't mix fpu/vpu math!) -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && defined(__i386__) || defined(__x86_64__) return a.m128_f32[ idx ]; #else return (reinterpret_cast(&a))[idx]; @@ -1843,7 +1843,7 @@ FORCEINLINE float SubFloat( const fltx4 & a, int idx ) FORCEINLINE float & SubFloat( fltx4 & a, int idx ) { -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && defined(__i386__) || defined(__x86_64__) return a.m128_f32[ idx ]; #else return (reinterpret_cast(&a))[idx]; @@ -1857,7 +1857,7 @@ FORCEINLINE uint32 SubFloatConvertToInt( const fltx4 & a, int idx ) FORCEINLINE uint32 SubInt( const fltx4 & a, int idx ) { -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && defined(__i386__) || defined(__x86_64__) return a.m128_u32[ idx ]; #else return (reinterpret_cast(&a))[idx]; @@ -1866,7 +1866,7 @@ FORCEINLINE uint32 SubInt( const fltx4 & a, int idx ) FORCEINLINE uint32 & SubInt( fltx4 & a, int idx ) { -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && defined(__i386__) || defined(__x86_64__) return a.m128_u32[ idx ]; #else return (reinterpret_cast(&a))[idx]; diff --git a/public/mathlib/vmatrix.h b/public/mathlib/vmatrix.h index 408267be..b435a421 100644 --- a/public/mathlib/vmatrix.h +++ b/public/mathlib/vmatrix.h @@ -43,7 +43,7 @@ struct cplane_t; #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #endif -class VMatrix +class alignas(16) VMatrix { public: diff --git a/public/shaderapi/ishaderapi.h b/public/shaderapi/ishaderapi.h index 2044fe75..dc05fe2e 100644 --- a/public/shaderapi/ishaderapi.h +++ b/public/shaderapi/ishaderapi.h @@ -175,9 +175,7 @@ public: virtual void TexMagFilter( ShaderTexFilterMode_t texFilterMode ) = 0; virtual void TexWrap( ShaderTexCoordComponent_t coord, ShaderTexWrapMode_t wrapMode ) = 0; -#ifndef SHADERAPIDX10 virtual void CopyRenderTargetToTexture( ShaderAPITextureHandle_t textureHandle ) = 0; -#endif // Binds a particular material to render with virtual void Bind( IMaterial* pMaterial ) = 0; @@ -614,7 +612,6 @@ public: //extended clear buffers function with alpha independent from color virtual void ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth ) = 0; -#ifndef SHADERAPIDX10 // Allows copying a render target to another texture by specifying them both. virtual void CopyRenderTargetToScratchTexture( ShaderAPITextureHandle_t srcRt, ShaderAPITextureHandle_t dstTex, Rect_t *pSrcRect = NULL, Rect_t *pDstRect = NULL ) = 0; @@ -630,7 +627,6 @@ public: virtual void CopyTextureToTexture( ShaderAPITextureHandle_t srcTex, ShaderAPITextureHandle_t dstTex ) = 0; -#endif }; diff --git a/public/tier0/commonmacros.h b/public/tier0/commonmacros.h index f57a6f4e..7ca6e1f5 100644 --- a/public/tier0/commonmacros.h +++ b/public/tier0/commonmacros.h @@ -68,7 +68,7 @@ inline bool IsPowerOfTwo( T value ) // From crtdefs.h #if !defined(UNALIGNED) -#if defined(_M_AMD64) || defined(_M_ARM) +#if defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64) #define UNALIGNED __unaligned #else #define UNALIGNED diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 37cf6058..1b813fa3 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -405,6 +405,18 @@ FIXME: Enable this when we no longer fear change =) #define __i386__ 1 #endif +#ifdef _M_ARM64EC +#define _M_ARM64 1 +#endif + +#ifdef _M_ARM +#define __arm__ 1 +#endif + +#ifdef _M_ARM64 +#define __aarch64__ 1 +#endif + #elif POSIX #if defined( OSX ) && defined( CARBON_WORKAROUND ) #define DWORD unsigned int @@ -1025,7 +1037,7 @@ inline T QWordSwapC( T dw ) return output; } -#elif defined( _MSC_VER ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(_M_ARM) +#elif defined( _MSC_VER ) && defined( _M_X86 ) #define WordSwap WordSwapAsm #define DWordSwap DWordSwapAsm @@ -1254,8 +1266,9 @@ inline uint64 Plat_Rdtsc() #elif defined( _M_IX86 ) _asm rdtsc #elif defined( _M_ARM ) - uint32 val = _MoveFromCoprocessor(15,0, 9,13,0); - return ((uint64)val) << 6; + return __rdpmccntr64(); + //uint32 val = _MoveFromCoprocessor(15,0, 9,13,0); + //return ((uint64)val) << 6; #elif defined( _M_ARM64 ) || defined( _M_ARM64EC ) return _ReadStatusReg(MSVC_ARM_SYSREG(3,3, 9,12,5)); #elif defined( COMPILER_MSVC ) diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index 13c6827f..c15ae5cd 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -241,7 +241,7 @@ inline void ThreadPause() _mm_pause(); #elif defined( COMPILER_MSVC32 ) __asm pause; -#elif defined(_M_ARM) +#elif defined(_M_ARM) || defined(_M_ARM64) __yield(); #elif defined( COMPILER_MSVCX360 ) YieldProcessor(); @@ -467,7 +467,7 @@ inline int64 ThreadInterlockedDecrement64( int64 volatile *p ) #endif -#ifdef COMPILER_MSVC64 +#if COMPILER_MSVC64 || _M_ARM64 // 64 bit windows can use intrinsics for these, 32-bit can't #pragma intrinsic( _InterlockedCompareExchange64 ) #pragma intrinsic( _InterlockedExchange64 ) @@ -494,7 +494,7 @@ inline bool ThreadInterlockedAssignIf( uint32 volatile *p, uint32 value, uint32 //inline bool ThreadInterlockedAssignIf( int volatile *p, int value, int comperand ) { return ThreadInterlockedAssignIf( (int32 volatile *)p, value, comperand ); } -#if defined( _WIN64 ) +#if defined( _WIN64 ) && !defined(_M_ARM64) typedef __m128i int128; inline int128 int128_zero() { return _mm_setzero_si128(); } PLATFORM_INTERFACE bool ThreadInterlockedAssignIf128( volatile int128 *pDest, const int128 &value, const int128 &comperand ) NOINLINE; diff --git a/public/tier0/tslist.h b/public/tier0/tslist.h index f5661258..90aec648 100644 --- a/public/tier0/tslist.h +++ b/public/tier0/tslist.h @@ -34,9 +34,10 @@ //----------------------------------------------------------------------------- -#if defined( PLATFORM_64BITS ) +#if defined( PLATFORM_64BITS ) && !defined(_M_ARM64) #if defined (PLATFORM_WINDOWS) +typedef __int128 int128; //typedef __m128i int128; //inline int128 int128_zero() { return _mm_setzero_si128(); } #else // PLATFORM_WINDOWS @@ -140,7 +141,7 @@ union TSLIST_HEAD_ALIGN TSLHead_t uint32 DepthAndSequence; } value32; -#ifdef PLATFORM_64BITS +#if defined(PLATFORM_64BITS) && !defined(_M_ARM64) int128 value64x128; #else int64 value64x128; @@ -194,7 +195,7 @@ public: #ifdef USE_NATIVE_SLIST InitializeSListHead( &m_Head ); -#elif defined(PLATFORM_64BITS) +#elif defined(PLATFORM_64BITS) && !defined(_M_ARM64) m_Head.value64x128 = int128_zero(); #else m_Head.value64x128 = (int64)0; @@ -720,7 +721,7 @@ public: intp sequence; } value; -#ifdef PLATFORM_64BITS +#if defined(PLATFORM_64BITS) && !defined(_M_ARM64) int128 value64x128; #else int64 value64x128; diff --git a/studiorender/r_studiodraw.cpp b/studiorender/r_studiodraw.cpp index 444dc832..c39b4326 100644 --- a/studiorender/r_studiodraw.cpp +++ b/studiorender/r_studiodraw.cpp @@ -907,7 +907,7 @@ inline void CStudioRender::R_ComputeLightAtPoint3( const Vector &pos, const Vect // define SPECIAL_SSE_MESH_PROCESSOR to enable code which contains a special optimized SSE lighting loop, significantly // improving software vertex processing performace. -#if defined( _WIN32 ) && !defined( _X360 ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) #define SPECIAL_SSE_MESH_PROCESSOR #endif diff --git a/studiorender/r_studiolight.cpp b/studiorender/r_studiolight.cpp index 19847897..f9066f18 100644 --- a/studiorender/r_studiolight.cpp +++ b/studiorender/r_studiolight.cpp @@ -66,13 +66,13 @@ void R_LightAmbient_4D( const Vector& normal, Vector4D* pLightBoxColor, Vector & VectorMA( lv, normal[2]*normal[2], normal[2] > 0.f ? pLightBoxColor[4].AsVector3D() : pLightBoxColor[5].AsVector3D(), lv ); } -#if defined( _WIN32 ) && !defined( _X360 ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) void R_LightAmbient_4D( const FourVectors& normal, Vector4D* pLightBoxColor, FourVectors &lv ) { // VPROF( "R_LightAmbient" ); // !!speed!! compute ambient color cube in sse format - static fltx4 FourZeros={0.,0.,0.,.0}; + static fltx4 FourZeros=FLTX4(0.,0.,0.,.0); // find the contributions from each axis fltx4 NegMask=CmpLtSIMD(normal.x,FourZeros); diff --git a/studiorender/r_studiolight.h b/studiorender/r_studiolight.h index 1ac1eeba..aa363b5e 100644 --- a/studiorender/r_studiolight.h +++ b/studiorender/r_studiolight.h @@ -12,8 +12,9 @@ #include "tier0/platform.h" +#include "mathlib/ssemath.h" -#if defined( _WIN32 ) && !defined( _X360 ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) && (defined(_M_IX86) || defined(_M_AMD64)) #include #endif @@ -40,7 +41,7 @@ float FASTCALL R_WorldLightDistanceFalloff( const LightDesc_t *wl, const Vector& // Copies lighting state into a buffer, returns number of lights copied int CopyLocalLightingState( int nMaxLights, LightDesc_t *pDest, int nLightCount, const LightDesc_t *pSrc ); -#if defined( _WIN32 ) && !defined( _X360 ) && !defined(_M_ARM) +#if defined( _WIN32 ) && !defined( _X360 ) // SSE optimized versions void R_LightAmbient_4D( const FourVectors& normal, Vector4D* pLightBoxColor, FourVectors &lv ); __m128 FASTCALL R_WorldLightDistanceFalloff( const LightDesc_t *wl, const FourVectors& delta ); diff --git a/studiorender/studiorender.h b/studiorender/studiorender.h index fa83ba64..399e8dff 100644 --- a/studiorender/studiorender.h +++ b/studiorender/studiorender.h @@ -22,9 +22,6 @@ #include "flexrenderdata.h" #include "mathlib/compressed_vector.h" #include "r_studiolight.h" -#if defined( _WIN32 ) && !defined( _X360 ) && !defined(_M_ARM) -#include -#endif #include "tier0/dbg.h" diff --git a/tier0/PMELib.cpp b/tier0/PMELib.cpp index e37acd2d..b0e1ec06 100644 --- a/tier0/PMELib.cpp +++ b/tier0/PMELib.cpp @@ -6,7 +6,7 @@ // //===========================================================================// -#if defined(_WIN32) && !defined(_M_ARM) +#if defined(_WIN32) && !defined(_M_ARM) && !defined(_M_ARM64) #include #pragma warning( disable : 4530 ) // warning: exception handler -GX option diff --git a/tier0/cpu.cpp b/tier0/cpu.cpp index 0a1d84be..92467c0d 100644 --- a/tier0/cpu.cpp +++ b/tier0/cpu.cpp @@ -22,7 +22,7 @@ const tchar* GetProcessorVendorId(); static bool cpuid(uint32 function, uint32& out_eax, uint32& out_ebx, uint32& out_ecx, uint32& out_edx) { -#if defined (__arm__) || defined (__aarch64__) || defined( _X360 ) +#if !defined(__i386__) && !defined(__x86_64) || defined( _X360 ) return false; #elif defined(GNUC) diff --git a/tier0/stacktools.cpp b/tier0/stacktools.cpp index 8c4aeab0..c458135e 100644 --- a/tier0/stacktools.cpp +++ b/tier0/stacktools.cpp @@ -175,7 +175,7 @@ int GetCallStack_Fast( void **pReturnAddressesOut, int iArrayCount, int iSkipCou { //Only tested in windows. This function won't work with frame pointer omission enabled. "vpc /nofpo" all projects #if (defined( TIER0_FPO_DISABLED ) || defined( _DEBUG )) &&\ - (defined( WIN32 ) && !defined( _X360 ) && !defined(_M_X64)) + (defined( WIN32 ) && !defined( _X360 ) && defined(_M_X86)) void *pStackCrawlEBP; __asm { @@ -1467,7 +1467,7 @@ CStackTop_CopyParentStack::CStackTop_CopyParentStack( void * const *pParentStack #if defined( ENABLE_RUNTIME_STACK_TRANSLATION ) //miniature version of GetCallStack_Fast() #if (defined( TIER0_FPO_DISABLED ) || defined( _DEBUG )) &&\ - (defined( WIN32 ) && !defined( _X360 ) && !defined(_M_X64)) + (defined( WIN32 ) && !defined( _X360 ) && defined(_M_X86)) void *pStackCrawlEBP; __asm { @@ -1525,7 +1525,7 @@ CStackTop_ReferenceParentStack::CStackTop_ReferenceParentStack( void * const *pP #if defined( ENABLE_RUNTIME_STACK_TRANSLATION ) //miniature version of GetCallStack_Fast() #if (defined( TIER0_FPO_DISABLED ) || defined( _DEBUG )) &&\ - (defined( WIN32 ) && !defined( _X360 ) && !defined(_M_X64)) + (defined( WIN32 ) && !defined( _X360 ) && defined(_M_X86)) void *pStackCrawlEBP; __asm { diff --git a/tier0/threadtools.cpp b/tier0/threadtools.cpp index b856916c..ba2fd9d8 100644 --- a/tier0/threadtools.cpp +++ b/tier0/threadtools.cpp @@ -1740,7 +1740,7 @@ bool ThreadInterlockedAssignIf( int32 volatile *pDest, int32 value, int32 comper { Assert( (size_t)pDest % 4 == 0 ); -#if !(defined(_WIN64) || defined (_X360) || defined(_M_ARM)) +#ifdef _M_IX86 __asm { mov eax,comperand @@ -1773,7 +1773,7 @@ void *ThreadInterlockedCompareExchangePointer( void * volatile *pDest, void *val bool ThreadInterlockedAssignPointerIf( void * volatile *pDest, void *value, void *comperand ) { Assert( (size_t)pDest % 4 == 0 ); -#if !(defined(_WIN64) || defined (_X360) || defined(_M_ARM)) +#ifdef _M_IX86 __asm { mov eax,comperand @@ -1819,7 +1819,7 @@ bool ThreadInterlockedAssignIf64(volatile int64 *pDest, int64 value, int64 compe { Assert( (size_t)pDest % 8 == 0 ); -#if defined(_X360) || defined(_WIN64) || defined(_M_ARM) +#if defined(_X360) || defined(_WIN64) || defined(_M_ARM) || defined(_M_ARM64) return ( ThreadInterlockedCompareExchange64( pDest, value, comperand ) == comperand ); #else __asm @@ -1839,7 +1839,7 @@ bool ThreadInterlockedAssignIf64(volatile int64 *pDest, int64 value, int64 compe #endif } -#ifdef _WIN64 +#if defined(_WIN64) && !defined(_M_ARM64) bool ThreadInterlockedAssignIf128( volatile int128 *pDest, const int128 &value, const int128 &comperand ) { DbgAssert( ( (size_t)pDest % 16 ) == 0 ); diff --git a/tier0/wscript b/tier0/wscript index 57a49064..f376af51 100755 --- a/tier0/wscript +++ b/tier0/wscript @@ -22,8 +22,8 @@ def build(bld): 'assert_dialog.cpp', 'commandline.cpp', 'cpu.cpp', - 'cpu_usage.cpp', 'cpumonitoring.cpp', + 'cpu_usage.cpp', 'dbg.cpp', 'dynfunction.cpp', 'fasttimer.cpp', @@ -57,7 +57,7 @@ def build(bld): 'vcrmode.cpp', 'win32consoleio.cpp' ] - if bld.env.DEST_CPU == 'arm': + if bld.env.DEST_CPU in ['arm', 'arm64']: source += ['pme_posix.cpp'] else: source += ['pme.cpp'] diff --git a/tier1/processor_detect.cpp b/tier1/processor_detect.cpp index 91bb6d51..de6f9e4d 100644 --- a/tier1/processor_detect.cpp +++ b/tier1/processor_detect.cpp @@ -6,7 +6,7 @@ // $NoKeywords: $ //=============================================================================// -#if defined( _X360 ) || defined( WIN64 ) || defined(_M_ARM) +#if defined( _X360 ) || defined( WIN64 ) || defined(_M_ARM) || defined(_M_ARM64) bool CheckMMXTechnology(void) { return false; } bool CheckSSETechnology(void) { return false; } diff --git a/vstdlib/coroutine.cpp b/vstdlib/coroutine.cpp index eff744e7..8c608bd1 100644 --- a/vstdlib/coroutine.cpp +++ b/vstdlib/coroutine.cpp @@ -218,7 +218,7 @@ extern "C" byte *GetStackPtr64(); #define GetStackPtr( pStackPtr) byte *pStackPtr = GetStackPtr64(); #else #ifdef WIN32 -# ifdef _M_ARM +# if defined(_M_ARM) || defined(_M_ARM64) # define GetStackPtr( pStackPtr ) byte x; byte *pStackPtr = &x # else # define GetStackPtr( pStackPtr ) byte *pStackPtr; __asm mov pStackPtr, esp @@ -653,7 +653,7 @@ bool Internal_Coroutine_Continue( HCoroutine hCoroutine, const char *pchDebugMsg bool bInCoroutineAlready = GCoroutineMgr().IsAnyCoroutineActive(); #ifdef _WIN32 -#if !defined( _WIN64 ) && !defined( _M_ARM ) +#ifdef _M_IX86 // make sure nobody has a try/catch block and then yielded // because we hate that and we will crash uint32 topofexceptionchain; @@ -901,7 +901,7 @@ void Coroutine_YieldToMain() CoroutineDbgMsg( g_fmtstr.sprintf( "Coroutine_YieldToMain() %s#%x -> %s#%x\n", coroutine.m_pchName, coroutine.m_hCoroutine, coroutinePrev.m_pchName, coroutinePrev.m_hCoroutine ) ); #ifdef _WIN32 -#if !defined( _WIN64 ) && !defined( _M_ARM ) +#ifdef _M_IX86 // make sure nobody has a try/catch block and then yielded // because we hate that and we will crash uint32 topofexceptionchain; diff --git a/wscript b/wscript index fafdccec..171cccce 100644 --- a/wscript +++ b/wscript @@ -223,8 +223,6 @@ def define_platform(conf): '_ALLOW_MSC_VER_MISMATCH', 'NO_X360_XDK' ]) - if conf.env.DEST_CPU == 'arm': - conf.env.append_unique('DEFINES', ['__arm__=1']) elif conf.env.DEST_OS == 'darwin': conf.env.append_unique('DEFINES', [ 'OSX=1', '_OSX=1', @@ -387,9 +385,11 @@ def check_deps(conf): conf.check(lib='opus', uselib_store='OPUS') if conf.env.DEST_OS == 'win32': - if conf.env.DEST_CPU == 'arm': + if conf.env.DEST_CPU in ['arm', 'arm64']: conf.check(lib='d3d9', uselib_store='D3D9') conf.check(lib='d3dcompiler', uselib_store='D3DCOMPILER') + conf.check(lib='d3dx9', uselib_store='D3DX9') + conf.check(lib='SDL2', uselib_store='SDL2') else: conf.check(lib='libz', uselib_store='ZLIB', define_name='USE_ZLIB') conf.check(lib='SDL2', uselib_store='SDL2') @@ -520,7 +520,7 @@ def configure(conf): '/TP', '/EHsc' ] - if conf.env.DEST_CPU != 'arm': + if conf.env.DEST_CPU in ['x86', 'x86_64', 'amd64']: cflags += ['/arch:SSE' if conf.env.DEST_CPU == 'x86' else '/arch:AVX'] if conf.options.BUILD_TYPE == 'debug': @@ -601,11 +601,19 @@ def configure(conf): def build(bld): os.environ["CCACHE_DIR"] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU) - if bld.env.SDL and bld.env.DEST_OS in ['win32', 'android']: + base_lib_path = os.path.join('lib', bld.env.DEST_OS, bld.env.DEST_CPU) + if bld.env.DEST_OS in ['win32', 'android']: sdl_name = 'SDL2.dll' if bld.env.DEST_OS == 'win32' else 'libSDL2.so' - sdl_path = os.path.join('lib', bld.env.DEST_OS, bld.env.DEST_CPU, sdl_name) + sdl_path = os.path.join(base_lib_path, sdl_name) bld.install_files(bld.env.LIBDIR, [sdl_path]) + if bld.env.DEST_OS == 'win32' and bld.env.DEST_CPU in ['arm', 'arm64']: + # because Windows ARM doesn't have D3DX and it is deprecated since Windows 8 + bld.install_files(bld.env.LIBDIR, [ + os.path.join(base_lib_path, 'd3dx9.dll'), + os.path.join(base_lib_path, 'd3dxof.dll'), + ]) + if bld.env.DEST_OS == 'win32': projects['game'] += ['utils/bzip2'] projects['dedicated'] += ['utils/bzip2']