trying single threaded
This commit is contained in:
parent
e625c20f07
commit
04b351e792
|
@ -15,15 +15,15 @@
|
||||||
|
|
||||||
struct handle
|
struct handle
|
||||||
{
|
{
|
||||||
u32 Generation;
|
u32 Generation;
|
||||||
u32 Index;
|
u32 Index;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Handle_IsValid(handle Handle)
|
Handle_IsValid(handle Handle)
|
||||||
{
|
{
|
||||||
bool Result = (Handle.Generation != 0);
|
bool Result = (Handle.Generation != 0);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "..\gs_libs\gs_string.h"
|
#include "..\gs_libs\gs_string.h"
|
||||||
|
@ -40,9 +40,9 @@ global debug_services* GlobalDebugServices;
|
||||||
|
|
||||||
struct platform_network_address
|
struct platform_network_address
|
||||||
{
|
{
|
||||||
s32 Family;
|
s32 Family;
|
||||||
u16 Port;
|
u16 Port;
|
||||||
u32 Address;
|
u32 Address;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef s32 platform_socket_handle;
|
typedef s32 platform_socket_handle;
|
||||||
|
@ -59,16 +59,16 @@ typedef struct context context;
|
||||||
typedef void temp_job_req_proc(gs_thread_context* Ctx, u8* Memory);
|
typedef void temp_job_req_proc(gs_thread_context* Ctx, u8* Memory);
|
||||||
struct temp_job_req
|
struct temp_job_req
|
||||||
{
|
{
|
||||||
temp_job_req_proc* Proc;
|
temp_job_req_proc* Proc;
|
||||||
u8* Memory;
|
u8* Memory;
|
||||||
};
|
};
|
||||||
// This isn't necessarily temp but I'm not sure it goes here
|
// This isn't necessarily temp but I'm not sure it goes here
|
||||||
#define PACKETS_MAX 32
|
#define PACKETS_MAX 32
|
||||||
struct packet_ringbuffer
|
struct packet_ringbuffer
|
||||||
{
|
{
|
||||||
gs_data Values[PACKETS_MAX];
|
gs_data Values[PACKETS_MAX];
|
||||||
u32 ReadHead;
|
u32 ReadHead;
|
||||||
u32 WriteHead;
|
u32 WriteHead;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INITIALIZE_APPLICATION(name) void name(context* Context)
|
#define INITIALIZE_APPLICATION(name) void name(context* Context)
|
||||||
|
@ -87,9 +87,9 @@ typedef CLEANUP_APPLICATION(cleanup_application);
|
||||||
|
|
||||||
struct window_info
|
struct window_info
|
||||||
{
|
{
|
||||||
char* Name;
|
char* Name;
|
||||||
s32 Width;
|
s32 Width;
|
||||||
s32 Height;
|
s32 Height;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct window window;
|
typedef struct window window;
|
||||||
|
@ -97,38 +97,38 @@ typedef struct window window;
|
||||||
#define PLATFORM_MEMORY_NO_ERROR 0
|
#define PLATFORM_MEMORY_NO_ERROR 0
|
||||||
enum platform_memory_error
|
enum platform_memory_error
|
||||||
{
|
{
|
||||||
PlatformMemory_NoError,
|
PlatformMemory_NoError,
|
||||||
PlatformMemory_FileNotFound,
|
PlatformMemory_FileNotFound,
|
||||||
|
|
||||||
PlatformMemory_UnknownError, // You should implement handling this when you see it
|
PlatformMemory_UnknownError, // You should implement handling this when you see it
|
||||||
};
|
};
|
||||||
|
|
||||||
struct data
|
struct data
|
||||||
{
|
{
|
||||||
u8* Base;
|
u8* Base;
|
||||||
u64 Size;
|
u64 Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct platform_memory_result
|
struct platform_memory_result
|
||||||
{
|
{
|
||||||
data Data;
|
data Data;
|
||||||
platform_memory_error Error;
|
platform_memory_error Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct system_path
|
struct system_path
|
||||||
{
|
{
|
||||||
char* Path;
|
char* Path;
|
||||||
s32 PathLength;
|
s32 PathLength;
|
||||||
s32 IndexOfLastSlash;
|
s32 IndexOfLastSlash;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct texture_buffer
|
struct texture_buffer
|
||||||
{
|
{
|
||||||
u8* Memory;
|
u8* Memory;
|
||||||
s32 Width;
|
s32 Width;
|
||||||
s32 Height;
|
s32 Height;
|
||||||
s32 Pitch;
|
s32 Pitch;
|
||||||
s32 BytesPerPixel;
|
s32 BytesPerPixel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PLATFORM_GET_GPU_TEXTURE_HANDLE(name) s32 name(u8* Memory, s32 Width, s32 Height)
|
#define PLATFORM_GET_GPU_TEXTURE_HANDLE(name) s32 name(u8* Memory, s32 Width, s32 Height)
|
||||||
|
@ -140,25 +140,25 @@ typedef PLATFORM_GET_SOCKET_HANDLE(platform_get_socket_handle);
|
||||||
// Font
|
// Font
|
||||||
struct platform_font_info
|
struct platform_font_info
|
||||||
{
|
{
|
||||||
s32 PixelHeight;
|
s32 PixelHeight;
|
||||||
s32 Ascent, Descent, Leading;
|
s32 Ascent, Descent, Leading;
|
||||||
s32 MaxCharWidth;
|
s32 MaxCharWidth;
|
||||||
s32 CodepointStart;
|
s32 CodepointStart;
|
||||||
s32 CodepointOnePastLast;
|
s32 CodepointOnePastLast;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum font_weight
|
enum font_weight
|
||||||
{
|
{
|
||||||
FontWeight_Invalid = 0,
|
FontWeight_Invalid = 0,
|
||||||
FontWeight_Thin = 100,
|
FontWeight_Thin = 100,
|
||||||
FontWeight_ExtraLight = 200,
|
FontWeight_ExtraLight = 200,
|
||||||
FontWeight_Light = 300,
|
FontWeight_Light = 300,
|
||||||
FontWeight_Normal = 400,
|
FontWeight_Normal = 400,
|
||||||
FontWeight_Medium = 500,
|
FontWeight_Medium = 500,
|
||||||
FontWeight_SemiBold = 600,
|
FontWeight_SemiBold = 600,
|
||||||
FontWeight_Bold = 700,
|
FontWeight_Bold = 700,
|
||||||
FontWeight_ExtraBold = 800,
|
FontWeight_ExtraBold = 800,
|
||||||
FontWeight_Heavy = 900,
|
FontWeight_Heavy = 900,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_FONT_INFO(name) platform_font_info name(char* FontName, s32 PixelHeight, font_weight FontWeight, b32 Italic, b32 Underline, b32 Strikeout)
|
#define GET_FONT_INFO(name) platform_font_info name(char* FontName, s32 PixelHeight, font_weight FontWeight, b32 Italic, b32 Underline, b32 Strikeout)
|
||||||
|
@ -169,19 +169,19 @@ typedef DRAW_FONT_CODEPOINT(platform_draw_font_codepoint);
|
||||||
|
|
||||||
// Worker Threads
|
// Worker Threads
|
||||||
|
|
||||||
#define PLATFORM_THREAD_COUNT 3
|
#define PLATFORM_THREAD_COUNT 0
|
||||||
|
|
||||||
RESET_WORK_QUEUE(ResetWorkQueue)
|
RESET_WORK_QUEUE(ResetWorkQueue)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < Queue->JobsMax; i++)
|
for (u32 i = 0; i < Queue->JobsMax; i++)
|
||||||
{
|
{
|
||||||
Queue->Jobs[i].Data = {0};
|
Queue->Jobs[i].Data = {0};
|
||||||
Queue->Jobs[i].WorkProc = 0;
|
Queue->Jobs[i].WorkProc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue->JobsCount = 0;
|
Queue->JobsCount = 0;
|
||||||
Queue->NextJobIndex = 0;
|
Queue->NextJobIndex = 0;
|
||||||
Queue->JobsCompleted = 0;
|
Queue->JobsCompleted = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
|
@ -189,66 +189,66 @@ RESET_WORK_QUEUE(ResetWorkQueue)
|
||||||
internal r32
|
internal r32
|
||||||
GetSecondsElapsed (s64 Start, s64 End, s64 PerformanceCountFrequency)
|
GetSecondsElapsed (s64 Start, s64 End, s64 PerformanceCountFrequency)
|
||||||
{
|
{
|
||||||
r32 Result = ((r32)(End - Start) / (r32) PerformanceCountFrequency);
|
r32 Result = ((r32)(End - Start) / (r32) PerformanceCountFrequency);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct system_time
|
typedef struct system_time
|
||||||
{
|
{
|
||||||
u64 NanosSinceEpoch;
|
u64 NanosSinceEpoch;
|
||||||
|
|
||||||
s32 Year;
|
s32 Year;
|
||||||
s32 Month;
|
s32 Month;
|
||||||
s32 Day;
|
s32 Day;
|
||||||
s32 Hour; // [0:23]
|
s32 Hour; // [0:23]
|
||||||
s32 Minute;
|
s32 Minute;
|
||||||
s32 Second;
|
s32 Second;
|
||||||
} system_time;
|
} system_time;
|
||||||
|
|
||||||
internal r64
|
internal r64
|
||||||
SecondsElapsed(system_time Start, system_time End)
|
SecondsElapsed(system_time Start, system_time End)
|
||||||
{
|
{
|
||||||
u64 N = End.NanosSinceEpoch - Start.NanosSinceEpoch;
|
u64 N = End.NanosSinceEpoch - Start.NanosSinceEpoch;
|
||||||
r64 S = (r64)N * NanosToSeconds;
|
r64 S = (r64)N * NanosToSeconds;
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct context
|
struct context
|
||||||
{
|
{
|
||||||
gs_thread_context ThreadContext;
|
gs_thread_context ThreadContext;
|
||||||
|
|
||||||
u8* MemoryBase;
|
u8* MemoryBase;
|
||||||
u32 MemorySize;
|
u32 MemorySize;
|
||||||
|
|
||||||
b32 WindowIsVisible;
|
b32 WindowIsVisible;
|
||||||
rect2 WindowBounds;
|
rect2 WindowBounds;
|
||||||
r64 TotalTime;
|
r64 TotalTime;
|
||||||
r32 DeltaTime;
|
r32 DeltaTime;
|
||||||
mouse_state Mouse;
|
mouse_state Mouse;
|
||||||
|
|
||||||
// Application Services
|
// Application Services
|
||||||
initialize_application* InitializeApplication;
|
initialize_application* InitializeApplication;
|
||||||
reload_static_data* ReloadStaticData;
|
reload_static_data* ReloadStaticData;
|
||||||
update_and_render* UpdateAndRender;
|
update_and_render* UpdateAndRender;
|
||||||
cleanup_application* CleanupApplication;
|
cleanup_application* CleanupApplication;
|
||||||
|
|
||||||
platform_thread_manager* ThreadManager;
|
platform_thread_manager* ThreadManager;
|
||||||
platform_socket_manager* SocketManager;
|
platform_socket_manager* SocketManager;
|
||||||
|
|
||||||
// Platform Services
|
// Platform Services
|
||||||
gs_work_queue* GeneralWorkQueue;
|
gs_work_queue* GeneralWorkQueue;
|
||||||
|
|
||||||
platform_get_gpu_texture_handle* PlatformGetGPUTextureHandle;
|
platform_get_gpu_texture_handle* PlatformGetGPUTextureHandle;
|
||||||
platform_get_font_info* PlatformGetFontInfo;
|
platform_get_font_info* PlatformGetFontInfo;
|
||||||
platform_draw_font_codepoint* PlatformDrawFontCodepoint;
|
platform_draw_font_codepoint* PlatformDrawFontCodepoint;
|
||||||
|
|
||||||
platform_get_socket_handle* PlatformGetSocketHandle;
|
platform_get_socket_handle* PlatformGetSocketHandle;
|
||||||
|
|
||||||
system_time SystemTime_Last;
|
system_time SystemTime_Last;
|
||||||
system_time SystemTime_Current;
|
system_time SystemTime_Current;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool Headless;
|
bool Headless;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOLDHAUS_PLATFORM_H
|
#define FOLDHAUS_PLATFORM_H
|
||||||
|
|
Loading…
Reference in New Issue