Browse Source

Merge branch 'Preview4_0_DevHead' into tsneo

# Conflicts:
#	Engine/source/console/consoleInternal.cpp
Jeff Hutchinson 4 years ago
parent
commit
acde0c3f0b

+ 2 - 0
Engine/lib/convexDecomp/NvThreadConfig.cpp

@@ -135,6 +135,8 @@ void tc_spinloop()
       // Pause would do nothing on the Xbox. Threads are not scheduled.
    #elif defined( _WIN64 )
       YieldProcessor( );
+   #elif (defined( __arm64__ ) && defined( __APPLE__ )) || defined( __arch64__ )
+      pthread_yield_np();
    #else
       __asm { pause };
    #endif

+ 1 - 1
Engine/source/console/codeBlock.cpp

@@ -447,7 +447,7 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
       {
          U32 ip;
          st.read(&ip);
-#ifdef TORQUE_CPU_X64
+#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64)
          *(U64*)(code + ip) = (U64)ste;
 #else
          code[ip] = *((U32 *)&ste);

+ 1 - 1
Engine/source/console/compiler.cpp

@@ -65,7 +65,7 @@ namespace Compiler
 
    void evalSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr)
    {
-#ifdef TORQUE_CPU_X64
+#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64)
       *(U64*)(ptr) = (U64)ste;
 #else
       *ptr = (U32)ste;

+ 1 - 1
Engine/source/console/compiler.h

@@ -237,7 +237,7 @@ namespace Compiler
 
    inline StringTableEntry CodeToSTE(U32 *code, U32 ip)
    {
-#ifdef TORQUE_CPU_X64
+#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64)
       return (StringTableEntry)(*((U64*)(code + ip)));
 #else
       return (StringTableEntry)(*(code + ip));

+ 1 - 1
Engine/source/console/consoleInternal.cpp

@@ -1401,7 +1401,7 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, ExprEvalSta
          result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv));
          break;
       case FloatCallbackType:
-         result.setFloat(cb.mBoolCallbackFunc(state->thisObject, argc, argv));
+         result.setFloat(cb.mFloatCallbackFunc(state->thisObject, argc, argv));
          break;
       case VoidCallbackType:
          cb.mVoidCallbackFunc(state->thisObject, argc, argv);

+ 1 - 1
Engine/source/core/util/uuid.cpp

@@ -70,7 +70,7 @@
 #include "core/util/md5.h"
 #include "console/enginePrimitives.h"
 
-#if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64)
+#if defined (TORQUE_OS_MAC) && (defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64))
 typedef unsigned int    unsigned32;
 #else
 typedef unsigned long   unsigned32;

+ 8 - 0
Engine/source/gui/core/guiCanvas.cpp

@@ -1760,7 +1760,11 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
       const char *pref = Con::getVariable( "$pref::Video::mode" );
       mode.parseFromString( pref );
       mode.antialiasLevel = 0;
+      Point2I winPos = mPlatformWindow->getPosition(); // Save position so we can put window back.
       mPlatformWindow->setVideoMode(mode);
+      // setVideoMode (above) will center the window on the display device. If the window had been positioned
+      // by the user or from script, put it back where it was before the light manager change.
+      mPlatformWindow->setPosition(winPos);
 
       Con::printf( "AntiAliasing has been disabled; it is not compatible with AdvancedLighting." );
    }
@@ -1772,7 +1776,11 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
       if ( prefAA != mode.antialiasLevel )
       {
          mode.parseFromString( pref );
+         Point2I winPos = mPlatformWindow->getPosition(); // Save position so we can put window back.
          mPlatformWindow->setVideoMode(mode);
+         // setVideoMode (above) will center the window on the display device. If the window had been positioned
+         // by the user or from script, put it back where it was before the light manager change.
+         mPlatformWindow->setPosition(winPos);
 
          Con::printf( "AntiAliasing has been enabled while running BasicLighting." );
       }

+ 5 - 0
Engine/source/platform/types.gcc.h

@@ -120,6 +120,11 @@ typedef unsigned long  U64;
 #  define TORQUE_CPU_X64
 #  define TORQUE_LITTLE_ENDIAN
 
+#elif (defined( __arm64__ ) && defined( __APPLE__ )) || defined( __arch64__ )
+#  define TORQUE_CPU_STRING "Arm 64"
+#  define TORQUE_CPU_ARM64
+#  define TORQUE_LITTLE_ENDIAN
+
 #else
 #  error "GCC: Unsupported Target CPU"
 #endif

+ 1 - 1
Engine/source/platform/types.h

@@ -128,7 +128,7 @@ static const F32 F32_MAX = F32(3.402823466e+38F);                 ///< Constant
 #endif
 
 /// Integral type matching the host's memory address width.
-#ifdef TORQUE_CPU_X64
+#if defined(TORQUE_CPU_X64) || defined(TORQUE_CPU_ARM64)
    typedef U64 MEM_ADDRESS;
 #else
    typedef U32 MEM_ADDRESS;

+ 8 - 0
Engine/source/platformMac/macMath.mm

@@ -34,21 +34,29 @@ static MRandomLCG sgPlatRandom;
 
 U32 Platform::getMathControlState()
 {
+#ifdef TORQUE_CPU_X86
    U16 cw;
    asm("fstcw %0" : "=m" (cw) :);
    return cw;
+#else
+   return 0;
+#endif
 }
 
 void Platform::setMathControlState(U32 state)
 {
+#ifdef TORQUE_CPU_X86
    U16 cw = state;
    asm("fldcw %0" : : "m" (cw));
+#endif
 }
 
 void Platform::setMathControlStateKnown()
 {
+#ifdef TORQUE_CPU_X86
    U16 cw = 0x27F;
    asm("fldcw %0" : : "m" (cw));
+#endif
 }
 
 //--------------------------------------

+ 0 - 1
Engine/source/windowManager/sdl/sdlWindow.cpp

@@ -207,7 +207,6 @@ void PlatformWindowSDL::_setVideoMode( const GFXVideoMode &mode )
          SDL_MaximizeWindow(mWindowHandle);
    }
 
-   getScreenResChangeSignal().trigger(this, true);
    mSuppressReset = false;
 }
 

+ 21 - 0
Templates/BaseGame/game/core/gui/scripts/canvas.tscript

@@ -120,6 +120,13 @@ function configureCanvas()
 
    // Actually set the new video mode
    Canvas.setVideoMode(%resX, %resY, %fs, %bpp, %rate, %aa);
+
+   // For borderless on non-windows OS, move the window into position.
+   if (($pref::Video::deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
+   {
+      %borderlessPos = getWords(Canvas.getMonitorUsableRect($pref::Video::deviceId), 0, 1);
+      Canvas.setWindowPosition(%borderlessPos);
+   }
    Canvas.setFocus();
 
    // Lock and unlock the mouse to force the position to sync with the platform window
@@ -184,6 +191,12 @@ function GuiCanvas::checkCanvasRes(%this, %mode, %deviceId, %deviceMode, %startu
 
       return true;
    }
+   else if (%deviceMode == $Video::ModeFullscreen)
+   {  // Fullscreen must match the aspect ratio of the monitor
+      %deviceRes = getWords(%this.getMonitorRect(%deviceId), 2);
+      if (mRoundColour(%resX / %resY, 2) != mRoundColour(%deviceRes.x / %deviceRes.y, 2))
+         return false;
+   }
 
    if (!%startup)
       return true;
@@ -238,5 +251,13 @@ function GuiCanvas::getBestCanvasRes(%this, %deviceId, %deviceMode)
          %bestRes = %testRes;
    }
 
+   // Borderless on non-windows OS should be the usable screen area.
+   if ((%deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
+   {
+      %deviceRect = getWords(%this.getMonitorUsableRect(%deviceId), 2);
+      %bestRes = setWord(%bestRes, $WORD::RES_X, %deviceRect.x);
+      %bestRes = setWord(%bestRes, $WORD::RES_Y, %deviceRect.y);
+   }
+
    return %bestRes;
 }

+ 7 - 0
Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript

@@ -845,6 +845,13 @@ function getScreenResolutionList(%deviceID, %deviceMode)
 {
    %returnsList = "";
 
+   // For borderless on non-windows OS only add the usable area.
+   if ((%deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
+   {
+      %borderlessRes = getWords(Canvas.getMonitorUsableRect(%newDeviceID), 2);
+      return _makePrettyResString(%borderlessRes);
+   }
+
    %resCount = Canvas.getModeCount();
    for (%i = 0; %i < %resCount; %i++)
    {

+ 7 - 2
Templates/BaseGame/game/data/ui/guis/optionsMenu.tscript

@@ -627,9 +627,14 @@ function onDisplayModeChange(%val)
    }
    %resolutionList = getScreenResolutionList(%newDeviceID, %newDeviceMode);
 
-   // If we're switching to borderless, default to monitor res
    if (%newDeviceMode == $Video::ModeBorderless)
-      %newRes = getWords(Canvas.getMonitorRect(%newDeviceID), 2);
+   {  // If we're switching to borderless, default to monitor res on Windows OS,
+      // monitor usable area for other platforms.
+      if ($platform $= "windows")
+         %newRes = getWords(Canvas.getMonitorRect(%newDeviceID), 2);
+      else
+         %newRes = getWords(Canvas.getMonitorUsableRect(%newDeviceID), 2);
+   }
    else
    {  // Otherwise, if our old resolution is still in the list, attempt to reset it.
       %oldRes = getWord(OptionsMenuSettingsList.getCurrentOption(3), 0) SPC getWord(OptionsMenuSettingsList.getCurrentOption(3), 2);

+ 5 - 0
Tools/CMake/libraries/lpng.cmake

@@ -24,6 +24,11 @@ project(lpng)
 
 # addDef(PNG_NO_ASSEMBLER_CODE)
 
+# Issues with Neon at the moment (Arm support)
+# https://sourceforge.net/p/libpng/bugs/281/
+set(PNG_ARM_NEON off CACHE STRING "")
+add_definitions(-DPNG_ARM_NEON_OPT=0)
+
 addInclude(${libDir}/zlib)
 
 finishLibrary("${libDir}/${PROJECT_NAME}")

+ 2 - 6
Tools/CMake/template.torsion.in

@@ -1,18 +1,14 @@
 <TorsionProject>
 <Name>@TORQUE_APP_NAME@</Name>
 <WorkingDir/>
-<EntryScript>main.cs</EntryScript>
+<EntryScript>main.@TORQUE_SCRIPT_EXTENSION@</EntryScript>
 <DebugHook>dbgSetParameters( #port#, "#password#", true );</DebugHook>
 <Mods>
 <Folder>core</Folder>
-<Folder>scripts</Folder>
-<Folder>art</Folder>
-<Folder>levels</Folder>
-<Folder>shaders</Folder>
 <Folder>data</Folder>
 <Folder>tools</Folder>
 </Mods>
-<ScannerExts>cs; gui; taml; module;</ScannerExts>
+<ScannerExts>@TORQUE_SCRIPT_EXTENSION@; gui; taml; module;</ScannerExts>
 <Configs>
 <Config>
 <Name>Release</Name>

+ 25 - 5
Tools/CMake/torque3d.cmake

@@ -692,8 +692,8 @@ if(WIN32)
 endif()
 
 if (APPLE)
-	addFramework("Cocoa")
-	addFramework("OpenGL")
+  addFramework("Cocoa")
+  addFramework("OpenGL")
   #These are needed by sdl2 static lib
   addFramework("CoreAudio")
   addFramework("AudioUnit")
@@ -704,9 +704,29 @@ if (APPLE)
   addFramework("Carbon")
   addFramework("AudioToolbox")
   addLib("iconv")
-  #set a few arch defaults
-  set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "OSX Architecture" FORCE)
-  set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "OSX Deployment target" FORCE)
+endif()
+
+#detect Architecture
+if (APPLE AND NOT IOS)
+  option(TORQUE_MACOS_UNIVERSAL_BINARY OFF)
+
+  # Detect architecture if not using universal
+  if (TORQUE_MACOS_UNIVERSAL_BINARY)
+    set(ARCHITECTURE_STRING_APPLE "x86_64;arm64")
+    set(DEPLOYMENT_TARGET_APPLE "10.13")
+  else()
+    check_c_compiler_flag("-arch arm64" armSupportedApple)
+    if(armSupportedApple)
+      set(ARCHITECTURE_STRING_APPLE "arm64")
+      set(DEPLOYMENT_TARGET_APPLE "11.0")
+    else()
+      set(ARCHITECTURE_STRING_APPLE "x86_64")
+      set(DEPLOYMENT_TARGET_APPLE "10.9")
+    endif() 
+  endif()
+
+  set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE_STRING_APPLE} CACHE STRING "OSX Architecture" FORCE)
+  set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET_APPLE} CACHE STRING "OSX Deployment target" FORCE)
 endif()
 
 if(UNIX AND NOT APPLE)