Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [windows-latest, ubuntu-24.04]
name: [windows-latest, ubuntu-24.04, macos-latest]
include:
- name: windows-latest
os: windows-latest
Expand All @@ -34,6 +34,13 @@ jobs:
physx: linux
physxkey: linux
gpulang: linux
anyfx: anyfxcompiler-linux
- name: macos-latest
os: macos-latest
config: darwin-ninja-debug
physx: linux
physxkey: linux
anyfx: anyfxcompiler-macos

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
43 changes: 31 additions & 12 deletions code/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# Foundation
#-------------------------------------------------------------------------------

if(FIPS_LINUX OR FIPS_MACOS)
if(FIPS_LINUX OR FIPS_OSX)
FIND_PACKAGE(CURL)
endif()

if(FIPS_OSX)
find_library(COCOA_LIBRARY Cocoa)
endif()

if (EXISTS "${NROOT}/syswork/export.zip")
create_resource("${NROOT}/syswork/" "${NROOT}/syswork/export.zip" system_resources)
set_target_properties(system_resources PROPERTIES FOLDER Resources)
Expand All @@ -18,6 +22,9 @@ nebula_begin_module(foundation)
if(FIPS_LINUX)
fips_libs(uuid stdc++fs)
endif()
if (FIPS_OSX)
fips_libs(${COCOA_LIBRARY})
endif()
target_include_directories(foundation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
fips_deps(nebula-libs zlib tinyxml nflatbuffer)
if(TARGET system_resources)
Expand Down Expand Up @@ -525,12 +532,12 @@ nebula_begin_module(foundation)
jobs2.cc
jobs2.h
)
fips_dir(fibers)
fips_files(
fiber.h
fibers.cc
fibers.h
)
#fips_dir(fibers)
#fips_files(
# fiber.h
# fibers.cc
# fibers.h
#)
fips_dir(framesync)
fips_files(
framesynctimer.cc
Expand Down Expand Up @@ -611,10 +618,10 @@ nebula_begin_module(foundation)
win32/win32systeminfo.cc
win32/win32systeminfo.h
)
fips_dir(fibers GROUP "fibers/win32")
fips_files(
win32/win32fiber.cc
)
#fips_dir(fibers GROUP "fibers/win32")
# fips_files(
# win32/win32fiber.cc
# )
fips_dir(.)
endif()
if (FIPS_POSIX)
Expand All @@ -623,7 +630,7 @@ nebula_begin_module(foundation)
core/posix/posixsingleton.h
core/posix/posixsysfunc.cc
core/posix/posixsysfunc.h
fibers/posix/posixfiber.cc
#fibers/posix/posixfiber.cc
memory/posix/posixmemory.h
memory/posix/posixheap.cc
memory/posix/posixheap.h
Expand Down Expand Up @@ -688,6 +695,18 @@ nebula_begin_module(foundation)
)
fips_dir(threading/gcc GROUP "threading/gcc")
fips_files(gccinterlocked.cc)
elseif(FIPS_MACOS)
fips_dir(threading/posix GROUP "threading/posix")
fips_files(
posixbarrier.h
posixcriticalsection.h
posixevent.h

posixthread.cc
posixthread.h
)
fips_dir(threading/gcc GROUP "threading/gcc")
fips_files(gccinterlocked.cc)
else()
fips_dir(threading/posix GROUP "threading/posix")
fips_files(
Expand Down
4 changes: 0 additions & 4 deletions code/foundation/core/posix/posixsysfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ SysFunc::Setup()
if (!SetupCalled)
{
SetupCalled = true;
#if !__MAYA__
//Threading::Thread::SetMyThreadName("MainThread");
#endif
Memory::SetupHeaps();
Memory::Heap::Setup();
Blob::Setup();
#if !__MAYA__
Net::Socket::InitNetwork();
#endif

globalStringAtomTable = new Util::GlobalStringAtomTable;
#if NEBULA_ENABLE_THREADLOCAL_STRINGATOM_TABLES
Expand Down
6 changes: 5 additions & 1 deletion code/foundation/core/posix/precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define CORE_POSIX_PRECOMPILED_H
//------------------------------------------------------------------------------
/**
@file core/win32/precompiled.h
@file core/posix/precompiled.h

Contains precompiled headers on the Posix platform.

Expand All @@ -28,12 +28,16 @@
#include <limits.h>

// sse intrinsics
#ifdef __linux__
#if __SSE2__ || __SSE4_1__ || __AVX2__
#include <emmintrin.h>
#include <immintrin.h>
#elif __aarc64__
#include <arm_neon.h>
#endif
#elif __APPLE__
#include <sse2neon.h>
#endif

//------------------------------------------------------------------------------
#endif
4 changes: 1 addition & 3 deletions code/foundation/core/singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
*/
#if __WIN32__
#include "core/win32/win32singleton.h"
#elif __OSX__
#include "core/osx/osxsingleton.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "core/posix/posixsingleton.h"
#else
#error "IMPLEMENT ME!"
Expand Down
7 changes: 4 additions & 3 deletions code/foundation/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;
typedef unsigned char ubyte;
typedef signed char byte;

typedef uintptr_t uintptr;
typedef ptrdiff_t ptrdiff;
Expand Down Expand Up @@ -109,7 +110,7 @@ OnlyBits(const FLAGS flags, const BITS bits)
#define BITS_TO_BYTES(x) (((x)+7)>>3)
#define BYTES_TO_BITS(x) ((x)<<3)

#if (__OSX__ || __linux__)
#if (__APPLE__ || __linux__)
inline ushort _byteswap_ushort(ushort x) { return ((x>>8) | (x<<8)); }
inline ulong _byteswap_ulong(ulong x) { return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
inline unsigned long long _byteswap_uint64(unsigned long long x) { return ((((unsigned long long)_byteswap_ulong((ulong)(x & 0xffffffff))) << 32) | ((unsigned long long)_byteswap_ulong((ulong)(x >> 32)))); }
Expand All @@ -121,7 +122,7 @@ typedef unsigned char byte;
#if __WIN32__
#define n_stricmp stricmp
#define n_snprintf StringCchPrintf
#elif (__OSX__ || __APPLE__ || __linux__ )
#elif __APPLE__ || __linux__
#define n_stricmp strcasecmp
#define n_snprintf sprintf
#else
Expand All @@ -132,7 +133,7 @@ typedef unsigned char byte;
#define ThreadLocal __declspec(thread)
#elif __linux__
#define ThreadLocal __thread
#elif (__OSX__ || __APPLE__)
#elif __APPLE__
#define ThreadLocal thread_local
#else
#error "Unsupported platform!"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
__ImplementClass(IO::Archive, 'ARCV', IO::ZipArchive);
#else
#error "IO::Archive not implemented on this platform!"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(C) 2009 Radon Labs GmbH
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
#include "io/zipfs/ziparchive.h"
namespace IO
{
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archivefilesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
__ImplementClass(IO::ArchiveFileSystem, 'ARFS', IO::ZipFileSystem);
__ImplementInterfaceSingleton(IO::ArchiveFileSystem);
#else
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archivefilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(C) 2009 Radon Labs GmbH
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
#include "io/zipfs/zipfilesystem.h"
namespace IO
{
Expand Down
8 changes: 2 additions & 6 deletions code/foundation/io/console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "threading/thread.h"
#if __WIN32__
#include "io/win32/win32consolehandler.h"
#elif __OSX__
#include "io/osx/osxconsolehandler.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/posixconsolehandler.h"
#endif

Expand Down Expand Up @@ -59,9 +57,7 @@ Console::Open()
// create default console handlers
#if __WIN32__
Ptr<ConsoleHandler> consoleHandler = Win32::Win32ConsoleHandler::Create();
#elif __OSX__
Ptr<ConsoleHandler> consoleHandler = OSX::OSXConsoleHandler::Create();
#elif __linux__
#elif __linux__ || __APPLE__
Ptr<ConsoleHandler> consoleHandler = Posix::PosixConsoleHandler::Create();
#endif
this->AttachHandler(consoleHandler);
Expand Down
8 changes: 1 addition & 7 deletions code/foundation/io/filetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ namespace IO
{
typedef Win32::Win32FileTime FileTime;
}
#elif __OSX__
#include "io/osx/osxfiletime.h"
namespace IO
{
typedef OSX::OSXFileTime FileTime;
}
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/posixfiletime.h"
namespace IO
{
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/filewatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "util/bitfield.h"
#if __WIN32__
#include "io/win32/win32filewatcher.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/linuxfilewatcher.h"
#else
#error "not implemented"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/gamecontentserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if (__WIN32__ || __OSX__ || __linux__)
#if (__WIN32__ || __APPLE__ || __linux__)
__ImplementClass(IO::GameContentServer, 'IGCS', Base::GameContentServerBase);
#else
#error "IO::GameContentServer not implemented on this platform!"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/gamecontentserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#include "core/config.h"
#if (__WIN32__ || __OSX__ || __linux__)
#if (__WIN32__ || __APPLE__ || __linux__)
#include "io/base/gamecontentserverbase.h"
namespace IO
{
Expand Down
6 changes: 3 additions & 3 deletions code/foundation/math/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ point::storeu(scalar* ptr) const
__forceinline void
point::store3(scalar* ptr) const
{
__m128 v = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 v = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_storel_epi64(reinterpret_cast<__m128i*>(ptr), _mm_castps_si128(this->vec));
_mm_store_ss(&ptr[2], v);
}
Expand All @@ -243,8 +243,8 @@ point::store3(scalar* ptr) const
__forceinline void
point::storeu3(scalar* ptr) const
{
__m128 t1 = _mm_permute_ps(this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 t1 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_store_ss(&ptr[0], this->vec);
_mm_store_ss(&ptr[1], t1);
_mm_store_ss(&ptr[2], t2);
Expand Down
9 changes: 8 additions & 1 deletion code/foundation/math/sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
(C) 2018 Individual contributors, see AUTHORS file
*/
//------------------------------------------------------------------------------

#ifdef __WIN32__ || __linux__
#include <xmmintrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
#include <immintrin.h>
#elif __APPLE__
#include <sse2neon.h>
#endif

namespace Math
{
Expand Down
11 changes: 8 additions & 3 deletions code/foundation/math/vec4.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ vec4::storeu(scalar* ptr) const
__forceinline void
vec4::store3(scalar* ptr) const
{
__m128 vv = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 vv = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_storel_epi64(reinterpret_cast<__m128i*>(ptr), _mm_castps_si128(this->vec));
_mm_store_ss(&ptr[2], vv);
}
Expand All @@ -222,8 +222,8 @@ vec4::store3(scalar* ptr) const
__forceinline void
vec4::storeu3(scalar* ptr) const
{
__m128 t1 = _mm_permute_ps(this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 t1 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_store_ss(&ptr[0], this->vec);
_mm_store_ss(&ptr[1], t1);
_mm_store_ss(&ptr[2], t2);
Expand Down Expand Up @@ -1073,8 +1073,13 @@ permute(const vec4& v0, const vec4& v1, unsigned int i0, unsigned int i1, unsign
__m128i vSelect = _mm_cmpgt_epi32(vControl, three);
vControl = _mm_and_si128(vControl, three);

#if N_USE_NEON
__m128 shuffled1 = vbslq_f32(vreinterpretq_u32_f32(vControl), v0.vec, v0.vec);
__m128 shuffled2 = vbslq_f32(vreinterpretq_u32_f32(vControl), v1.vec, v1.vec);
#elif N_USE_AVX
__m128 shuffled1 = _mm_permutevar_ps(v0.vec, vControl);
__m128 shuffled2 = _mm_permutevar_ps(v1.vec, vControl);
#endif

__m128 masked1 = _mm_andnot_ps(_mm_castsi128_ps(vSelect), shuffled1);
__m128 masked2 = _mm_and_ps(_mm_castsi128_ps(vSelect), shuffled2);
Expand Down
6 changes: 3 additions & 3 deletions code/foundation/math/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ vector::loadu(const scalar* ptr)
__forceinline void
vector::store(scalar* ptr) const
{
__m128 v = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 v = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_storel_epi64(reinterpret_cast<__m128i*>(ptr), _mm_castps_si128(this->vec));
_mm_store_ss(&ptr[2], v);
}
Expand All @@ -191,8 +191,8 @@ vector::store(scalar* ptr) const
__forceinline void
vector::storeu(scalar* ptr) const
{
__m128 t1 = _mm_permute_ps(this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 t1 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_store_ss(&ptr[0], this->vec);
_mm_store_ss(&ptr[1], t1);
_mm_store_ss(&ptr[2], t2);
Expand Down
Loading
Loading