Skip to content

Commit

Permalink
Updated Premake Integration
Browse files Browse the repository at this point in the history
- Removed Premake5.exe
- Added light wrapper utilities for typical premake operations
- Added Quill as dependency (New Logger Library)
- Updated all existing premake files to use new light wrapper utilities

Updated Submodule Engine
Updated Jolt
Removed Meshoptimizer
  • Loading branch information
NixAJ committed Jun 23, 2024
1 parent 772b280 commit 71ddbef
Show file tree
Hide file tree
Showing 353 changed files with 6,425 additions and 46,285 deletions.
17 changes: 6 additions & 11 deletions Dependencies/Dependencies.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
-- Dependencies
Game.dependencyDir = path.getabsolute("Dependencies/", Game.rootDir)

print("-- Creating Dependencies --")

Game.dependencyGroup = (Game.name .. "/Dependencies")
group (Game.dependencyGroup)
Solution.Util.Print("-- Creating Dependencies --")
Solution.Util.ClearFilter()
Solution.Util.SetGroup(Solution.DependencyGroup)

local dependencies =
{
"jolt/jolt.lua"
}

for k,v in pairs(dependencies) do
filter { }
include(v)
Solution.Util.ClearFilter()
end

filter { }
group (Game.name)

print("-- Finished with Dependencies --\n")
Solution.Util.SetGroup("")
Solution.Util.Print("-- Finished with Dependencies --\n")
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class NodeCodecQuadTreeHalfFloat
uint offset = node->mNodeProperties[i] != 0? inChildrenTrianglesStart[i] : inChildrenNodeStart[i];
if (offset & OFFSET_NON_SIGNIFICANT_MASK)
{
outError = "NodeCodecQuadTreeHalfFloat: Internal Error: Offset has non-signifiant bits set";
outError = "NodeCodecQuadTreeHalfFloat: Internal Error: Offset has non-significant bits set";
return false;
}
offset >>= OFFSET_NON_SIGNIFICANT_BITS;
Expand All @@ -168,7 +168,7 @@ class NodeCodecQuadTreeHalfFloat
uint offset = inRoot->HasChildren()? inRootNodeStart : inRootTrianglesStart;
if (offset & OFFSET_NON_SIGNIFICANT_MASK)
{
outError = "NodeCodecQuadTreeHalfFloat: Internal Error: Offset has non-signifiant bits set";
outError = "NodeCodecQuadTreeHalfFloat: Internal Error: Offset has non-significant bits set";
return false;
}
offset >>= OFFSET_NON_SIGNIFICANT_BITS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,36 @@ class TriangleCodecIndexed8BitPackSOA4Flags

static_assert(sizeof(TriangleBlockHeader) == 4, "Compiler added padding");

/// This class is used to validate that the triangle data will not be degenerate after compression
class ValidationContext
{
public:
/// Constructor
ValidationContext(const IndexedTriangleList &inTriangles, const VertexList &inVertices) :
mVertices(inVertices)
{
// Only used the referenced triangles, just like EncodingContext::Finalize does
for (const IndexedTriangle &i : inTriangles)
for (uint32 idx : i.mIdx)
mBounds.Encapsulate(Vec3(inVertices[idx]));
}

/// Test if a triangle will be degenerate after quantization
bool IsDegenerate(const IndexedTriangle &inTriangle) const
{
// Quantize the triangle in the same way as EncodingContext::Finalize does
UVec4 quantized_vertex[3];
Vec3 compress_scale = Vec3::sReplicate(COMPONENT_MASK) / Vec3::sMax(mBounds.GetSize(), Vec3::sReplicate(1.0e-20f));
for (int i = 0; i < 3; ++i)
quantized_vertex[i] = ((Vec3(mVertices[inTriangle.mIdx[i]]) - mBounds.mMin) * compress_scale + Vec3::sReplicate(0.5f)).ToInt();
return quantized_vertex[0] == quantized_vertex[1] || quantized_vertex[1] == quantized_vertex[2] || quantized_vertex[0] == quantized_vertex[2];
}

private:
const VertexList & mVertices;
AABox mBounds;
};

/// This class is used to encode and compress triangle data into a byte buffer
class EncodingContext
{
Expand Down Expand Up @@ -406,7 +436,7 @@ class TriangleCodecIndexed8BitPackSOA4Flags
return first_block[inTriangleIndex >> 2].mFlags[inTriangleIndex & 0b11];
}

/// Unpacks triangles and flags, convencience function
/// Unpacks triangles and flags, convenience function
JPH_INLINE void Unpack(const void *inTriangleStart, uint32 inNumTriangles, Vec3 *outTriangles, uint8 *outTriangleFlags) const
{
Unpack(inTriangleStart, inNumTriangles, outTriangles);
Expand Down
3 changes: 3 additions & 0 deletions Dependencies/Jolt/Jolt/Core/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class [[nodiscard]] JPH_EXPORT_GCC_BUG_WORKAROUND Color
inline uint8 operator () (uint inIdx) const { JPH_ASSERT(inIdx < 4); return (&r)[inIdx]; }
inline uint8 & operator () (uint inIdx) { JPH_ASSERT(inIdx < 4); return (&r)[inIdx]; }

/// Multiply two colors
inline Color operator * (const Color &inRHS) const { return Color(uint8((uint32(r) * inRHS.r) >> 8), uint8((uint32(g) * inRHS.g) >> 8), uint8((uint32(b) * inRHS.b) >> 8), uint8((uint32(a) * inRHS.a) >> 8)); }

/// Convert to Vec4 with range [0, 1]
inline Vec4 ToVec4() const { return Vec4(r, g, b, a) / 255.0f; }

Expand Down
27 changes: 20 additions & 7 deletions Dependencies/Jolt/Jolt/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#pragma once

// Jolt library version
#define JPH_VERSION_MAJOR 4
#define JPH_VERSION_MAJOR 5
#define JPH_VERSION_MINOR 0
#define JPH_VERSION_PATCH 2
#define JPH_VERSION_PATCH 0

// Determine which features the library was compiled with
#ifdef JPH_DOUBLE_PRECISION
Expand Down Expand Up @@ -78,6 +78,8 @@
#define JPH_PLATFORM_ANDROID
#elif defined(__linux__)
#define JPH_PLATFORM_LINUX
#elif defined(__FreeBSD__)
#define JPH_PLATFORM_FREEBSD
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
Expand Down Expand Up @@ -179,7 +181,18 @@
#define JPH_CPU_ADDRESS_BITS 32
#define JPH_VECTOR_ALIGNMENT 16
#define JPH_DVECTOR_ALIGNMENT 32
#define JPH_DISABLE_CUSTOM_ALLOCATOR
#ifdef __wasm_simd128__
#define JPH_USE_SSE
#define JPH_USE_SSE4_1
#define JPH_USE_SSE4_2
#endif
#elif defined(__e2k__)
// Elbrus e2k architecture
#define JPH_CPU_E2K
#define JPH_CPU_ADDRESS_BITS 64
#define JPH_USE_SSE
#define JPH_VECTOR_ALIGNMENT 16
#define JPH_DVECTOR_ALIGNMENT 32
#else
#error Unsupported CPU architecture
#endif
Expand Down Expand Up @@ -294,6 +307,7 @@
JPH_GCC_SUPPRESS_WARNING("-Wcomment") \
JPH_GCC_SUPPRESS_WARNING("-Winvalid-offsetof") \
JPH_GCC_SUPPRESS_WARNING("-Wclass-memaccess") \
JPH_GCC_SUPPRESS_WARNING("-Wpedantic") \
\
JPH_MSVC_SUPPRESS_WARNING(4619) /* #pragma warning: there is no warning number 'XXXX' */ \
JPH_MSVC_SUPPRESS_WARNING(4514) /* 'X' : unreferenced inline function has been removed */ \
Expand Down Expand Up @@ -329,21 +343,20 @@
// Creating one should only be a couple of minutes of work if you have the documentation for the platform
// (you only need to define JPH_BREAKPOINT, JPH_PLATFORM_BLUE_GET_TICKS, JPH_PLATFORM_BLUE_MUTEX*, JPH_PLATFORM_BLUE_RWLOCK* and include the right header).
#include <Jolt/Core/PlatformBlue.h>
#elif defined(JPH_PLATFORM_LINUX) || defined(JPH_PLATFORM_ANDROID) || defined(JPH_PLATFORM_MACOS) || defined(JPH_PLATFORM_IOS)
#elif defined(JPH_PLATFORM_LINUX) || defined(JPH_PLATFORM_ANDROID) || defined(JPH_PLATFORM_MACOS) || defined(JPH_PLATFORM_IOS) || defined(JPH_PLATFORM_FREEBSD)
#if defined(JPH_CPU_X86)
#define JPH_BREAKPOINT __asm volatile ("int $0x3")
#elif defined(JPH_CPU_ARM)
#define JPH_BREAKPOINT __builtin_trap()
#elif defined(JPH_CPU_E2K)
#define JPH_BREAKPOINT __builtin_trap()
#endif
#elif defined(JPH_PLATFORM_WASM)
#define JPH_BREAKPOINT do { } while (false) // Not supported
#else
#error Unknown platform
#endif

// Crashes the application
#define JPH_CRASH do { int *ptr = nullptr; *ptr = 0; } while (false)

// Begin the JPH namespace
#define JPH_NAMESPACE_BEGIN \
JPH_SUPPRESS_WARNING_PUSH \
Expand Down
10 changes: 5 additions & 5 deletions Dependencies/Jolt/Jolt/Core/FPControlWord.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

JPH_NAMESPACE_BEGIN

#ifdef JPH_USE_SSE
#if defined(JPH_CPU_WASM)

// Not supported

#elif defined(JPH_USE_SSE)

/// Helper class that needs to be put on the stack to update the state of the floating point control word.
/// This state is kept per thread.
Expand Down Expand Up @@ -122,10 +126,6 @@ class FPControlWord : public NonCopyable
uint32 mPrevState;
};

#elif defined(JPH_CPU_WASM)

// Not supported

#else

#error Unsupported CPU architecture
Expand Down
16 changes: 8 additions & 8 deletions Dependencies/Jolt/Jolt/Core/FPException.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ JPH_NAMESPACE_BEGIN

#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED

#if defined(JPH_USE_SSE)
#if defined(JPH_CPU_WASM)

// Not supported
class FPExceptionsEnable { };
class FPExceptionDisableInvalid { };
class FPExceptionDisableDivByZero { };

#elif defined(JPH_USE_SSE)

/// Enable floating point divide by zero exception and exceptions on invalid numbers
class FPExceptionsEnable : public FPControlWord<0, _MM_MASK_DIV_ZERO | _MM_MASK_INVALID> { };
Expand Down Expand Up @@ -49,13 +56,6 @@ class FPExceptionDisableInvalid : public FPControlWord<0, FP_IOE> { };
/// Disable division by zero floating point exceptions
class FPExceptionDisableDivByZero : public FPControlWord<0, FP_DZE> { };

#elif defined(JPH_CPU_WASM)

// Not supported
class FPExceptionsEnable { };
class FPExceptionDisableInvalid { };
class FPExceptionDisableDivByZero { };

#else

#error Unsupported CPU architecture
Expand Down
12 changes: 6 additions & 6 deletions Dependencies/Jolt/Jolt/Core/FPFlushDenormals.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

JPH_NAMESPACE_BEGIN

#if defined(JPH_USE_SSE)
#if defined(JPH_CPU_WASM)

// Not supported
class FPFlushDenormals { };

#elif defined(JPH_USE_SSE)

/// Helper class that needs to be put on the stack to enable flushing denormals to zero
/// This can make floating point operations much faster when working with very small numbers
Expand All @@ -27,11 +32,6 @@ static constexpr uint64 FP_FZ = 1 << 24;
/// This can make floating point operations much faster when working with very small numbers
class FPFlushDenormals : public FPControlWord<FP_FZ, FP_FZ> { };

#elif defined(JPH_CPU_WASM)

// Not supported
class FPFlushDenormals { };

#else

#error Unsupported CPU architecture
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/Jolt/Jolt/Core/Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

JPH_NAMESPACE_BEGIN

/// Factory, to create RTTI objects
/// This class is responsible for creating instances of classes based on their name or hash and is mainly used for deserialization of saved data.
class JPH_EXPORT Factory
{
public:
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/Jolt/Jolt/Core/JobSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class JPH_EXPORT JobSystem : public NonCopyable
// Releasing a reference must use release semantics...
if (mReferenceCount.fetch_sub(1, memory_order_release) == 1)
{
// ... so that we can use aquire to ensure that we see any updates from other threads that released a ref before freeing the job
// ... so that we can use acquire to ensure that we see any updates from other threads that released a ref before freeing the job
atomic_thread_fence(memory_order_acquire);
mJobSystem->FreeJob(this);
}
Expand Down
88 changes: 63 additions & 25 deletions Dependencies/Jolt/Jolt/Core/JobSystemThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

JPH_SUPPRESS_WARNING_POP
#endif
#ifdef JPH_PLATFORM_LINUX
#include <sys/prctl.h>
#endif

JPH_NAMESPACE_BEGIN

Expand Down Expand Up @@ -230,47 +233,82 @@ void JobSystemThreadPool::QueueJobs(Job **inJobs, uint inNumJobs)
mSemaphore.Release(min(inNumJobs, (uint)mThreads.size()));
}

#if defined(JPH_PLATFORM_WINDOWS) && !defined(JPH_COMPILER_MINGW) // MinGW doesn't support __try/__except

// Sets the current thread name in MSVC debugger
static void SetThreadName(const char *inName)
{
#pragma pack(push, 8)
#if defined(JPH_PLATFORM_WINDOWS)

struct THREADNAME_INFO
#if !defined(JPH_COMPILER_MINGW) // MinGW doesn't support __try/__except)
// Sets the current thread name in MSVC debugger
static void RaiseThreadNameException(const char *inName)
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
};
#pragma pack(push, 8)

struct THREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
};

#pragma pack(pop)

#pragma pack(pop)
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = inName;
info.dwThreadID = (DWORD)-1;
info.dwFlags = 0;

THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = inName;
info.dwThreadID = (DWORD)-1;
info.dwFlags = 0;
__try
{
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
#endif // !JPH_COMPILER_MINGW

__try
static void SetThreadName(const char* inName)
{
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
JPH_SUPPRESS_WARNING_PUSH

// Suppress casting warning, it's fine here as GetProcAddress doesn't really return a FARPROC
JPH_CLANG_SUPPRESS_WARNING("-Wcast-function-type") // error : cast from 'FARPROC' (aka 'long long (*)()') to 'SetThreadDescriptionFunc' (aka 'long (*)(void *, const wchar_t *)') converts to incompatible function type
JPH_CLANG_SUPPRESS_WARNING("-Wcast-function-type-strict") // error : cast from 'FARPROC' (aka 'long long (*)()') to 'SetThreadDescriptionFunc' (aka 'long (*)(void *, const wchar_t *)') converts to incompatible function type
JPH_MSVC_SUPPRESS_WARNING(4191) // reinterpret_cast' : unsafe conversion from 'FARPROC' to 'SetThreadDescriptionFunc'. Calling this function through the result pointer may cause your program to fail

using SetThreadDescriptionFunc = HRESULT(WINAPI*)(HANDLE hThread, PCWSTR lpThreadDescription);
static SetThreadDescriptionFunc SetThreadDescription = reinterpret_cast<SetThreadDescriptionFunc>(GetProcAddress(GetModuleHandleW(L"Kernel32.dll"), "SetThreadDescription"));

JPH_SUPPRESS_WARNING_POP

if (SetThreadDescription)
{
wchar_t name_buffer[64] = { 0 };
if (MultiByteToWideChar(CP_UTF8, 0, inName, -1, name_buffer, sizeof(name_buffer) / sizeof(wchar_t) - 1) == 0)
return;

SetThreadDescription(GetCurrentThread(), name_buffer);
}
#if !defined(JPH_COMPILER_MINGW)
else if (IsDebuggerPresent())
RaiseThreadNameException(inName);
#endif // !JPH_COMPILER_MINGW
}
__except(EXCEPTION_EXECUTE_HANDLER)
#elif defined(JPH_PLATFORM_LINUX)
static void SetThreadName(const char *inName)
{
JPH_ASSERT(strlen(inName) < 16); // String will be truncated if it is longer
prctl(PR_SET_NAME, inName, 0, 0, 0);
}
}

#endif // JPH_PLATFORM_WINDOWS && !JPH_COMPILER_MINGW
#endif // JPH_PLATFORM_LINUX

void JobSystemThreadPool::ThreadMain(int inThreadIndex)
{
// Name the thread
char name[64];
snprintf(name, sizeof(name), "Worker %d", int(inThreadIndex + 1));

#if defined(JPH_PLATFORM_WINDOWS) && !defined(JPH_COMPILER_MINGW)
#if defined(JPH_PLATFORM_WINDOWS) || defined(JPH_PLATFORM_LINUX)
SetThreadName(name);
#endif // JPH_PLATFORM_WINDOWS && !JPH_COMPILER_MINGW

Expand Down
Loading

0 comments on commit 71ddbef

Please sign in to comment.