Skip to content
Permalink
Browse files

Merge pull request #1785 from rextimmy/mac_port_clean

MacOS platform support
  • Loading branch information...
Areloch committed Oct 12, 2016
2 parents c0482b1 + 7281c2e commit 1131ed15df42e190b36720dd1aa6079694171e12
Showing with 1,360 additions and 4,922 deletions.
  1. +12 −9 Engine/lib/sdl/CMakeLists.txt
  2. +0 −24 Engine/source/cinterface/cinterface.cpp
  3. +1 −1 Engine/source/console/engineTypes.h
  4. +5 −0 Engine/source/core/util/uuid.cpp
  5. +1 −1 Engine/source/environment/waterPlane.cpp
  6. +11 −0 Engine/source/gfx/gfxCardProfile.cpp
  7. +4 −20 Engine/source/gfx/gl/gfxGLCardProfiler.cpp
  8. +5 −29 Engine/source/gfx/gl/gfxGLDevice.cpp
  9. +0 −343 Engine/source/gfx/gl/gfxGLDevice.mac.mm
  10. +60 −29 Engine/source/gfx/gl/gfxGLShader.cpp
  11. +1 −1 Engine/source/gfx/gl/gfxGLTextureTarget.cpp
  12. +4 −1 Engine/source/gfx/gl/gfxGLWindowTarget.cpp
  13. +2 −0 Engine/source/gfx/gl/gfxGLWindowTarget.h
  14. +9 −4 Engine/source/gfx/gl/sdl/gfxGLDevice.sdl.cpp
  15. +13 −0 Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp
  16. +0 −11 Engine/source/gui/3d/guiTSControl.cpp
  17. +0 −136 Engine/source/math/mMathAltivec.cpp
  18. +0 −10 Engine/source/platform/types.gcc.h
  19. +0 −79 Engine/source/platformMac/macApplication.mm
  20. +63 −56 Engine/source/platformMac/{osxCPUInfo.mm → macCPU.mm}
  21. +0 −64 Engine/source/platformMac/macCarbAsync.cpp
  22. +0 −449 Engine/source/platformMac/macCarbFont.cpp
  23. +0 −500 Engine/source/platformMac/macCarbInput.cpp
  24. +0 −97 Engine/source/platformMac/macCarbMutex.cpp
  25. +0 −65 Engine/source/platformMac/macCarbProcessControl.cpp
  26. +0 −68 Engine/source/platformMac/macCarbSemaphore.cpp
  27. +0 −65 Engine/source/platformMac/macCarbUtil.cpp
  28. +0 −623 Engine/source/platformMac/macCocoaDialogs.mm
  29. +0 −244 Engine/source/platformMac/macCocoaPlatform.mm
  30. +0 −78 Engine/source/platformMac/macDLibrary.cpp
  31. +251 −170 Engine/source/platformMac/{macCarbFileio.mm → macFileIO.mm}
  32. +27 −38 Engine/source/platformMac/{macCarbFont.h → macFont.h}
  33. +258 −0 Engine/source/platformMac/macFont.mm
  34. +0 −78 Engine/source/platformMac/macGLUtils.h
  35. +45 −150 Engine/source/platformMac/macMain.mm
  36. +8 −20 Engine/source/platformMac/{macCarbMath.cpp → macMath.mm}
  37. +10 −10 Engine/source/platformMac/{macCarbMemory.cpp → macMemory.mm}
  38. +0 −180 Engine/source/platformMac/macMsgBox.mm
  39. +153 −0 Engine/source/platformMac/macPlatform.mm
  40. +14 −14 Engine/source/platformMac/{macCarbStrings.cpp → macString.mm}
  41. +16 −16 Engine/source/platformMac/{macCarbTime.cpp → macTime.mm}
  42. +2 −7 Engine/source/platformMac/{macCarbVolume.h → macVolume.h}
  43. +5 −11 Engine/source/platformMac/{macCarbVolume.cpp → macVolume.mm}
  44. +0 −30 Engine/source/platformMac/menus/mainMenu.nib/classes.nib
  45. +0 −20 Engine/source/platformMac/menus/mainMenu.nib/info.nib
  46. BIN Engine/source/platformMac/menus/mainMenu.nib/keyedobjects.nib
  47. +0 −303 Engine/source/platformMac/menus/menuBarMac.cpp
  48. +0 −439 Engine/source/platformMac/menus/popupMenu.cpp
  49. +0 −175 Engine/source/platformMac/platformMacCarb.h
  50. BIN Engine/source/platformMac/torqueDemo.icns
  51. +3 −6 Engine/source/platformSDL/sdlPlatformGL.cpp
  52. +39 −10 Engine/source/{platformMac/macApplication.h → platformSDL/threads/mutex.cpp}
  53. +87 −0 Engine/source/platformSDL/threads/semaphore.cpp
  54. +15 −19 Engine/source/{platformMac/macCarbThread.cpp → platformSDL/threads/thread.cpp}
  55. 0 Engine/source/platformWin32/{winSemaphore.cpp → threads/semaphore.cpp}
  56. +0 −5 Engine/source/postFx/postEffectManager.cpp
  57. +2 −1 Engine/source/sfx/openal/sfxALDevice.cpp
  58. +4 −5 Engine/source/shaderGen/shaderGen.cpp
  59. BIN Templates/Empty/buildFiles/Xcode/torqueDemo.icns
  60. +1 −0 Templates/Empty/game/shaders/.gitignore
  61. +0 −8 Templates/Empty/game/shaders/common/gl/scatterSkyP.glsl
  62. +0 −2 Templates/Empty/game/shaders/common/gl/scatterSkyV.glsl
  63. +1 −1 Templates/Empty/game/shaders/common/lighting/advanced/deferredShadingP.hlsl
  64. +3 −3 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgColorBufferP.glsl
  65. +1 −1 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl
  66. +2 −3 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgGlowVisualizeP.glsl
  67. +3 −4 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl
  68. +2 −3 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl
  69. +2 −2 Templates/Empty/game/shaders/common/lighting/advanced/gl/dbgSpecMapVisualizeP.glsl
  70. +1 −1 Templates/Empty/game/shaders/common/lighting/advanced/gl/deferredShadingP.glsl
  71. +12 −2 Templates/Empty/game/shaders/common/lighting/advanced/gl/pointLightP.glsl
  72. +12 −2 Templates/Empty/game/shaders/common/lighting/advanced/gl/spotLightP.glsl
  73. +12 −2 Templates/Empty/game/shaders/common/lighting/advanced/gl/vectorLightP.glsl
  74. +11 −2 Templates/Empty/game/shaders/common/lighting/advanced/pointLightP.hlsl
  75. +12 −2 Templates/Empty/game/shaders/common/lighting/advanced/spotLightP.hlsl
  76. +11 −2 Templates/Empty/game/shaders/common/lighting/advanced/vectorLightP.hlsl
  77. +1 −1 Templates/Empty/game/shaders/common/postFx/fogP.hlsl
  78. +1 −1 Templates/Empty/game/shaders/common/postFx/gl/fogP.glsl
  79. +0 −26 Templates/Full/buildFiles/Xcode/Info.plist
  80. +0 −8 Templates/Full/game/shaders/common/gl/scatterSkyP.glsl
  81. +0 −2 Templates/Full/game/shaders/common/gl/scatterSkyV.glsl
  82. +3 −3 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgColorBufferP.glsl
  83. +1 −1 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl
  84. +2 −3 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgGlowVisualizeP.glsl
  85. +3 −4 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl
  86. +2 −3 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl
  87. +2 −2 Templates/Full/game/shaders/common/lighting/advanced/gl/dbgSpecMapVisualizeP.glsl
  88. +2 −8 Templates/Empty/buildFiles/Xcode/Info.plist → Tools/CMake/Info.plist.in
  89. +28 −3 Tools/CMake/basics.cmake
  90. +2 −2 Tools/CMake/libraries/epoxy.cmake
  91. BIN Templates/Full/buildFiles/Xcode/torqueDemo.icns → Tools/CMake/torque.icns
  92. +97 −101 Tools/CMake/torque3d.cmake
@@ -183,8 +183,8 @@ endif()
set(SDL_LIBS "-lSDL2")
set(SDL_CFLAGS "")

# Emscripten toolchain has a nonempty default value for this, and the checks
# in this file need to change that, so remember the original value, and
# Emscripten toolchain has a nonempty default value for this, and the checks
# in this file need to change that, so remember the original value, and
# restore back to that afterwards. For check_function_exists() to work in
# Emscripten, this value must be at its default value.
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
@@ -212,7 +212,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
set(OPT_DEF_ASM TRUE)
if(EMSCRIPTEN)
# Set up default values for the currently supported set of subsystems:
# Emscripten/Javascript does not have assembly support, a dynamic library
# Emscripten/Javascript does not have assembly support, a dynamic library
# loading architecture, low-level CPU inspection or multithreading.
set(OPT_DEF_ASM FALSE)
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
@@ -387,11 +387,14 @@ if(USE_GCC OR USE_CLANG)
list(APPEND EXTRA_CFLAGS "-Wshadow")
endif()

set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_NO_UNDEFINED)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
# --no-undefined is unsupported with clang
if(NOT USE_CLANG)
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_NO_UNDEFINED)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
endif()
endif()
endif()

@@ -836,7 +839,7 @@ elseif(UNIX AND NOT APPLE)
#include <linux/kd.h>
#include <linux/keyboard.h>
int main(int argc, char **argv)
int main(int argc, char **argv)
{
struct kbentry kbe;
kbe.kb_table = KG_CTRL;
@@ -43,17 +43,6 @@ extern void createFontShutdown(void);

static HashTable<StringTableEntry,StringTableEntry> gSecureScript;

#ifdef TORQUE_OS_MAC

// ObjC hooks for shared library support
// See: macMain.mm

void torque_mac_engineinit(S32 argc, const char **argv);
void torque_mac_enginetick();
void torque_mac_engineshutdown();

#endif

extern bool LinkConsoleFunctions;

extern "C" {
@@ -78,10 +67,6 @@ extern "C" {
createFontInit();
#endif


#ifdef TORQUE_OS_MAC
torque_mac_engineinit(argc, argv);
#endif
// Initialize the subsystems.
StandardMainLoop::init();

@@ -113,11 +98,6 @@ extern "C" {
__try {
#endif


#ifdef TORQUE_OS_MAC
torque_mac_enginetick();
#endif

bool ret = StandardMainLoop::doMainLoop();
return ret;

@@ -159,10 +139,6 @@ extern "C" {
createFontShutdown();
#endif

#ifdef TORQUE_OS_MAC
torque_mac_engineshutdown();
#endif

#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
}

@@ -613,7 +613,7 @@ namespace _Private {

///
#define FIELD( fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.

///
#define FIELD_AS( type, fieldName, exportName, numElements, doc ) \
@@ -60,6 +60,7 @@
** this software for any purpose.
*/

#include "platform/platform.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -68,7 +69,11 @@

#include "core/util/md5.h"

#if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64)
typedef unsigned int unsigned32;
#else
typedef unsigned long unsigned32;
#endif
typedef unsigned short unsigned16;
typedef unsigned char unsigned8;

@@ -533,7 +533,7 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
1, // Top
-(S32)gridStride, // Right
-1, // Bottom
gridStride, // Left
(S32)gridStride, // Left
};

const U32 firstBorderVert = gridStride * gridSize + gridStride;
@@ -232,3 +232,14 @@ DefineEngineStaticMethod( GFXCardProfilerAPI, queryProfile, S32, ( const char *n
{
return (S32)GFX->getCardProfiler()->queryProfile( name, (U32)defaultValue );
}


DefineEngineStaticMethod( GFXCardProfilerAPI, getBestDepthFormat, String, (),,
"Returns the card name." )
{
if (GFX->getCardProfiler()->queryProfile("GL::Workaround::intel_mac_depth", false))
return "GFXFormatD16";
else
return "GFXFormatD24S8";
}

@@ -27,26 +27,9 @@
void GFXGLCardProfiler::init()
{
mChipSet = reinterpret_cast<const char*>(glGetString(GL_VENDOR));

// get the major and minor parts of the GL version. These are defined to be
// in the order "[major].[minor] [other]|[major].[minor].[release] [other] in the spec
const char *versionStart = reinterpret_cast<const char*>(glGetString(GL_VERSION));
const char *versionEnd = versionStart;
// get the text for the version "x.x.xxxx "
for( S32 tok = 0; tok < 2; ++tok )
{
char *text = dStrdup( versionEnd );
dStrtok(text, ". ");
versionEnd += dStrlen( text ) + 1;
dFree( text );
}

mRendererString = "GL";
mRendererString += String::SpanToString(versionStart, versionEnd - 1);

mRendererString = "OpenGL";
mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));

mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory();

Parent::init();
@@ -85,7 +68,8 @@ void GFXGLCardProfiler::setupCardCapabilities()
setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image));

// Check for vertex attrib binding
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));

}

bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult)
@@ -103,27 +103,6 @@ void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLs
Con::printf("AMDOPENGL: %s", message);
}


// >>>> OPENGL INTEL WORKAROUND @todo OPENGL INTEL remove
PFNGLBINDFRAMEBUFFERPROC __openglBindFramebuffer = NULL;

void STDCALL _t3d_glBindFramebuffer(GLenum target, GLuint framebuffer)
{
if( target == GL_FRAMEBUFFER )
{
if( GFXGL->getOpenglCache()->getCacheBinded( GL_DRAW_FRAMEBUFFER ) == framebuffer
&& GFXGL->getOpenglCache()->getCacheBinded( GL_READ_FRAMEBUFFER ) == framebuffer )
return;
}
else if( GFXGL->getOpenglCache()->getCacheBinded( target ) == framebuffer )
return;

__openglBindFramebuffer(target, framebuffer);
GFXGL->getOpenglCache()->setCacheBinded( target, framebuffer);
}
// <<<< OPENGL INTEL WORKAROUND


void GFXGLDevice::initGLState()
{
// We don't currently need to sync device state with a known good place because we are
@@ -156,14 +135,11 @@ void GFXGLDevice::initGLState()
String vendorStr = (const char*)glGetString( GL_VENDOR );
if( vendorStr.find("NVIDIA", 0, String::NoCase | String::Left) != String::NPos)
mUseGlMap = false;


if( vendorStr.find("INTEL", 0, String::NoCase | String::Left ) != String::NPos)
{
// @todo OPENGL INTEL - This is a workaround for a warning spam or even crashes with actual framebuffer code, remove when implemented TGL layer.
__openglBindFramebuffer = glBindFramebuffer;
glBindFramebuffer = &_t3d_glBindFramebuffer;
}

// Workaround for all Mac's, has a problem using glMap* with volatile buffers
#ifdef TORQUE_OS_MAC
mUseGlMap = false;
#endif

#if TORQUE_DEBUG
if( gglHasExtension(ARB_debug_output) )

0 comments on commit 1131ed1

Please sign in to comment.
You can’t perform that action at this time.