Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8230a67
build: adds platform module
Drischdaan Oct 8, 2025
2b1dea2
fix(core): fixes assertion compilation issues
Drischdaan Oct 8, 2025
8621f78
fix(core): fixes core macro to define copy/move constructors
Drischdaan Oct 8, 2025
fa05a59
feat(platform): adds platform api definition #CR-16
Drischdaan Oct 8, 2025
a32d6eb
feat(platform): adds cpu detection class #CR-16
Drischdaan Oct 8, 2025
e79872f
feat(platform): adds platform class #CR-16
Drischdaan Oct 8, 2025
f2fee2c
feat(platform): adds registry class #CR-16
Drischdaan Oct 8, 2025
33e052d
Merge pull request #9 from RavenStormStudio/feature/CR-16-platform-ut…
Drischdaan Oct 8, 2025
8563b68
Merge branch 'develop' into epic/CR-15-platform-abstraction-layer
Drischdaan Oct 8, 2025
d546f0f
build: adds ignoring of warning #CR-25
Drischdaan Oct 18, 2025
67ee062
feat(core): adds windows definitions header #CR-25
Drischdaan Oct 18, 2025
304f58f
feat(core): adds text macro #CR-25
Drischdaan Oct 18, 2025
889516d
feat(core): updates exception handler with windows definitions #CR-25
Drischdaan Oct 18, 2025
3198638
feat(platform): updates registry with windows definitions #CR-25
Drischdaan Oct 18, 2025
3cecc26
feat(platform): adds monitor class #CR-25
Drischdaan Oct 18, 2025
0d8b8a8
feat(platform): adds window class #CR-25
Drischdaan Oct 18, 2025
8c85cc8
feat(platform): adds core state window behaviour class #CR-25
Drischdaan Oct 18, 2025
64fc1fb
feat(platform): adds close window behaviour class #CR-25
Drischdaan Oct 18, 2025
2295c6f
Merge pull request #10 from RavenStormStudio/feature/CR-25-window-man…
Drischdaan Oct 18, 2025
4d464b9
feat(core): adds HMODULE definition to windows definitions header #CR-29
Drischdaan Oct 18, 2025
048f6fd
feat(platform): adds loading/unloading of dynamic modules to platform…
Drischdaan Oct 18, 2025
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
3 changes: 2 additions & 1 deletion Engine/Build/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function coruvs_global_setup()
-- Global Configuration
set_targetdir('$(projectdir)/Binaries/Engine/$(plat)-$(arch)/$(mode)')
set_objectdir('$(projectdir)/Intermediates/Engine/$(plat)-$(arch)/$(mode)')
set_dependir('$(projectdir)/Engine/Build/Output/.deps')

set_warnings('error')
set_exceptions('none')
Expand Down Expand Up @@ -46,7 +47,7 @@ function coruvs_global_setup()

-- Platform Configuration
if is_plat('windows') then
add_cxflags('/EHsc', '/Zc:preprocessor', '/wd5103', {force = true})
add_cxflags('/EHsc', '/Zc:preprocessor', '/wd5103', '/wd4005', {force = true})
add_defines('WIN32_LEAN_AND_MEAN', 'NOMINMAX', 'WIN32_DEFAULT_LIBS')
end
end
1 change: 1 addition & 0 deletions Engine/Source/Applications/Editor/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ local module_name = 'Editor'

corvus_application_target(module_name)
add_deps('Core')
add_deps('Platform')
corvus_target_end()
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

#pragma once

#include "ExceptionHandler.hpp"

#include "Core/Containers/String.hpp"
#include "Core/Logging/LogChannel.hpp"
#include "Core/Utility/SourceLocation.hpp"
#include "Core/Utility/StringUtils.hpp"

struct FExceptionMetadata;
CORE_API DECLARE_LOG_CHANNEL_EXTERN(Assert)

namespace Assertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@

#pragma once

#include <Windows.h>

#include "Core/Containers/String.hpp"
#include "Core/Utility/SourceLocation.hpp"
#include "Core/Utility/WindowsDefinitions.hpp"

#define ERROR_CODE_UNKNOWN MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0001)
#define ERROR_CODE_ASSERTION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0002)
#define ERROR_CODE_UNKNOWN CREATE_HRESULT(1, 4, 0x0001)
#define ERROR_CODE_ASSERTION CREATE_HRESULT(1, 4, 0x0002)

struct CORE_API FExceptionMetadata
{
HRESULT ReportCode = ERROR_CODE_UNKNOWN;
Windows::HRESULT ReportCode = ERROR_CODE_UNKNOWN;
FString AssertionCondition; // Only valid if report code is ERROR_CODE_ASSERTION
FString Message;
HRESULT CustomCode = 0;
Windows::HRESULT CustomCode = 0;
FSourceLocation SourceLocation;
};

class CORE_API FExceptionHandler
{
public:
[[nodiscard]] static long HandleException(const EXCEPTION_POINTERS* ExceptionInfo);
[[nodiscard]] static long HandleException(const Windows::EXCEPTION_POINTERS* ExceptionInfo);
static void Report(const FExceptionMetadata& Metadata);
[[nodiscard]] static FString GetResultDescription(HRESULT Result);
[[nodiscard]] static FString GetResultDescription(Windows::HRESULT Result);

[[nodiscard]] static int32 GetExitCode();

private:
static int32 ExitCode;
};

[[nodiscard]] CORE_API long HandleException(const EXCEPTION_POINTERS* ExceptionInfo);
[[nodiscard]] CORE_API long HandleException(const Windows::EXCEPTION_POINTERS* ExceptionInfo);

#define TRY __try
#define CATCH() __except(HandleException(GetExceptionInformation()))
10 changes: 10 additions & 0 deletions Engine/Source/Runtime/Core/Public/Core/Containers/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ using FStringView = FWideStringView;
template <typename... TArguments>
using TFormatString = TWideFormatString<TArguments...>;
#endif

#ifndef TEXT
# if CV_USE_ANSI_STRINGS
# define INNER_TEXT(String) String
# define TEXT(String) INNER_TEXT(String)
# else
# define INNER_TEXT(String) L##String
# define TEXT(String) INNER_TEXT(String)
# endif
#endif
4 changes: 2 additions & 2 deletions Engine/Source/Runtime/Core/Public/Core/CoreDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
DEFAULT_MOVEABLE_PREFIX(Class,)

#define DEFAULT_COPY_MOVEABLE_PREFIX(Class, Prefix) \
DEFAULT_COPYABLE(Class, Prefix) \
DEFAULT_MOVEABLE(Class, Prefix)
DEFAULT_COPYABLE_PREFIX(Class, Prefix) \
DEFAULT_MOVEABLE_PREFIX(Class, Prefix)

#define INNER_APPEND(X, Y) X##Y
#define APPEND(X, Y) INNER_APPEND(X, Y)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RavenStorm Copyright @ 2025-2025

#pragma once

struct HINSTANCE__;
struct HWND__;
struct HKEY__;
struct HMONITOR__;
struct _EXCEPTION_POINTERS;
struct tagRECT;

namespace Windows
{
using LONG = long;
using DWORD = unsigned long;
using HRESULT = long;

using HANDLE = void*;
using HINSTANCE = HINSTANCE__*;
using HWND = HWND__*;
using HMONITOR = HMONITOR__*;
using RECT = tagRECT;
using HMODULE = HINSTANCE;

using EXCEPTION_POINTERS = _EXCEPTION_POINTERS;

using HKEY = HKEY__*;

using LRESULT = int64;
using WPARAM = uint64;
using LPARAM = int64;
}

#define CREATE_HRESULT(sev,fac,code) ((Windows::HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
181 changes: 181 additions & 0 deletions Engine/Source/Runtime/Platform/Private/Platform/CPUDetection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// RavenStorm Copyright @ 2025-2025

#include "Platform/CPUDetection.hpp"

#include "Core/Logging/LogChannel.hpp"
#include "Core/Logging/LogManager.hpp"

#include <Windows.h>

#include <utility>

#include "Core/Memory/Memory.hpp"

DEFINE_LOG_CHANNEL(CPUDetection, All)

namespace
{
struct FCPUIDResult
{
int32 EAX;
int32 EBX;
int32 ECX;
int32 EDX;
};

FCPUIDResult CallCPUID(const int32 FunctionId, const int32 SubFunctionId = 0)
{
FCPUIDResult Result;
int32 CPUInfo[4];
__cpuidex(CPUInfo, FunctionId, SubFunctionId);
Result.EAX = CPUInfo[0];
Result.EBX = CPUInfo[1];
Result.ECX = CPUInfo[2];
Result.EDX = CPUInfo[3];
return Result;
}
}

FCPUInfo FCPUDetection::CPUInfo = {};

void FCPUDetection::Initialize()
{
DetectVendor();
DetectBrand();
DetectCPUTopology();

CVLOG(LogCPUDetection, Info, "CPU: {}", CPUInfo.BrandString);
CVLOG(LogCPUDetection, Info, "\t- Vendor: {}", CPUInfo.VendorString);
CVLOG(LogCPUDetection, Info, "\t- Family: {}", CPUInfo.Family);
CVLOG(LogCPUDetection, Info, "\t- Model: {}", CPUInfo.Model);
CVLOG(LogCPUDetection, Info, "\t- Stepping: {}", CPUInfo.Stepping);
CVLOG(LogCPUDetection, Info, "\t- Physical Cores: {}, Logical Cores: {}", CPUInfo.PhysicalCores, CPUInfo.LogicalCores);
CVLOG(LogCPUDetection, Info, "\t- Logical Cores: {}", CPUInfo.LogicalCores);
CVLOG(LogCPUDetection, Info, "\t- Cache Line Size: {} bytes", CPUInfo.CacheLine);
CVLOG(LogCPUDetection, Info, "\t- L1 Cache: {} KB", CPUInfo.L1CacheSize / 1024);
CVLOG(LogCPUDetection, Info, "\t- L2 Cache: {} MB", CPUInfo.L2CacheSize / (1024 * 1024));
CVLOG(LogCPUDetection, Info, "\t- L3 Cache: {} MB", CPUInfo.L3CacheSize / (1024 * 1024));
}

FCPUInfo FCPUDetection::GetCPUInfo() noexcept
{
return CPUInfo;
}

void FCPUDetection::DetectVendor()
{
const FCPUIDResult Result = CallCPUID(0, 0);

char Vendor[13] = {};
*reinterpret_cast<int32*>(Vendor) = Result.EBX;
*reinterpret_cast<int32*>(Vendor + 4) = Result.EDX;
*reinterpret_cast<int32*>(Vendor + 8) = Result.ECX;
Vendor[12] = '\0';

CPUInfo.VendorString = FAnsiString(Vendor);
CPUInfo.IsIntel = CPUInfo.VendorString == "GenuineIntel";
CPUInfo.IsAMD = CPUInfo.VendorString == "AuthenticAMD";
}

void FCPUDetection::DetectBrand()
{
char Brand[49] = {};

const FCPUIDResult Result = CallCPUID(static_cast<int32>(0x80000000), 0);
if (Result.EAX >= static_cast<int32>(0x80000004))
{
const FCPUIDResult Brand0 = CallCPUID(static_cast<int32>(0x80000002), 0);
const FCPUIDResult Brand1 = CallCPUID(static_cast<int32>(0x80000003), 0);
const FCPUIDResult Brand2 = CallCPUID(static_cast<int32>(0x80000004), 0);

std::memcpy(Brand, &Brand0, 16);
std::memcpy(Brand + 16, &Brand1, 16);
std::memcpy(Brand + 32, &Brand2, 16);
Brand[48] = '\0';

// Trim leading spaces
char* Start = Brand;
while (*Start == ' ') ++Start;

CPUInfo.BrandString = FAnsiString(Start);
}
}

void FCPUDetection::DetectCPUTopology()
{
const FCPUIDResult Result1 = CallCPUID(1, 0);
CPUInfo.Family = ((Result1.EAX >> 8) & 0xF) + ((Result1.EAX >> 20) & 0xFF);
CPUInfo.Model = ((Result1.EAX >> 4) & 0xF) | ((Result1.EAX >> 12) & 0xF0);
CPUInfo.Stepping = Result1.EAX & 0xF;

SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
CPUInfo.LogicalCores = static_cast<int32>(SystemInfo.dwNumberOfProcessors);

DWORD BufferSize = 0;
GetLogicalProcessorInformation(nullptr, &BufferSize);
if (BufferSize > 0)
{
const PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer = static_cast<PSYSTEM_LOGICAL_PROCESSOR_INFORMATION>(FMemory::Allocate(BufferSize));
if (GetLogicalProcessorInformation(Buffer, &BufferSize))
{
const DWORD NumEntries = BufferSize / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
int32 PhysicalCores = 0;
int32 CacheLine = 0;
int32 L1CacheSize = 0;
int32 L2CacheSize = 0;
int32 L3CacheSize = 0;
for (DWORD Index = 0; Index < NumEntries; ++Index)
{
if (Buffer[Index].Relationship == RelationProcessorCore)
{
++PhysicalCores;
}
else if (Buffer[Index].Relationship == RelationCache)
{
if (const CACHE_DESCRIPTOR& Cache = Buffer[Index].Cache; Cache.Level == 1)
{
if (CacheLine == 0)
{
CacheLine = static_cast<int32>(Cache.LineSize);
}
if (Cache.Type == CacheData || Cache.Type == CacheUnified)
{
L1CacheSize += static_cast<int32>(Cache.Size);
}
else if (Cache.Type == CacheInstruction)
{
L1CacheSize += static_cast<int32>(Cache.Size);
}
}
else if (Cache.Level == 2)
{
L2CacheSize += static_cast<int32>(Cache.Size);
}
else if (Cache.Level == 3)
{
if (L3CacheSize == 0)
{
L3CacheSize = static_cast<int32>(Cache.Size);
}
}
}
}
CPUInfo.PhysicalCores = PhysicalCores;
CPUInfo.CacheLine = CacheLine > 0 ? CacheLine : 64;
CPUInfo.L1CacheSize = L1CacheSize;
CPUInfo.L2CacheSize = L2CacheSize;
CPUInfo.L3CacheSize = L3CacheSize;
}
FMemory::Free(Buffer);
}
else
{
CPUInfo.PhysicalCores = CPUInfo.LogicalCores;
CPUInfo.CacheLine = 64;
CPUInfo.L1CacheSize = 0;
CPUInfo.L2CacheSize = 0;
CPUInfo.L3CacheSize = 0;
}
CPUInfo.IsHyperThreaded = CPUInfo.LogicalCores > CPUInfo.PhysicalCores;
}
Loading
Loading