changed how threading might work in the readme

This commit is contained in:
Emilia(SleepeeSoftware) 2026-01-31 18:55:31 +01:00
parent 05d38d7b69
commit 5c3634a6fd
5 changed files with 22 additions and 17 deletions

View File

@ -93,3 +93,7 @@ A lot of things should be hidden to the player, the player shouldn't know everyt
-Henry Petroski -Henry Petroski
``` ```
## Threading :
Each step should have if possible an array of data, that can then be sliced and dispatched to multiple thread that do the same action (ex physique that have a thread for each local coordinate or for each entity and resolve collision later or before). maybe i could also make this work for spliting for each AI it's pathfinding into 2 but maybe not usefull??

View File

@ -12,8 +12,12 @@
#include <complex.h> #include <complex.h>
#include <math.h> #include <math.h>
#include <pthread.h>
#include <raylib.h> #include <raylib.h>
#include <raymath.h>
#include <raygui.h>
#include <extern/toml.h> #include <extern/toml.h>
#include <extern/FastNoiseLite.h> #include <extern/FastNoiseLite.h>

View File

@ -1,5 +1,4 @@
#include <engine.h> #include <engine.h>
#include <pthread.h>
/* /*
Time Manipulation Time Manipulation
@ -45,7 +44,9 @@ void DataInspector() {
/* /*
Debug Console Debug Console
INFO: may not be needed to thread this as input may only be available in main thread
*/ */
void DebugConsol() { void DebugConsole() {
__thread static char user_input[256];//need to be allocated for thread safety char user_input[256];
} }

View File

@ -44,20 +44,18 @@ void UpdateInput() {
} }
} }
//may be able to dispatch it
void GameLoop(const double tick_time) { void GameLoop(const double tick_time) {
static double time = 0; __thread static double time = 0;
time += GetFrameTime(); time += GetFrameTime();
if (time >= tick_time) { if (time >= tick_time) {
// interaction // interaction
// simulation // simulation
//dispatch all thread then
//wait all thread end
time = 0; time = 0;
} }
} }
int main(void) { int main(void) {
double tick_time = 0.4; double tick_time = 0.4;
SetTraceLogLevel(LOG_ALL); SetTraceLogLevel(LOG_ALL);
@ -66,8 +64,8 @@ int main(void) {
SetExitKey(KEY_NULL); SetExitKey(KEY_NULL);
while (!WindowShouldClose()) { while (!WindowShouldClose()) {
UpdateInput(); UpdateInput();
//DispatchWorker
ComputeIntent(); ComputeIntent();
//DispatchWorker
GameLoop(tick_time); GameLoop(tick_time);
//joinWorker //joinWorker
Rendering(); Rendering();

View File

@ -95,7 +95,7 @@ void LoadPipeline() {
rlEnableDepthTest(); rlEnableDepthTest();
rlEnableBackfaceCulling(); rlEnableBackfaceCulling();
TraceLog(LOG_INFO, "Render Pipeline Built"); TraceLog(LOG_INFO, "Render Pipeline Built");
SetTargetFPS(240);//may change SetTargetFPS(120);//may change
} }
void UnloadPipeline() { void UnloadPipeline() {
@ -127,17 +127,15 @@ void Rendering() {
//Light Pass and forward pass; //Light Pass and forward pass;
//I should build a shader that take every light in the scene and make a 3D heightmap of lighting then compute it once for all static light allowing to cheat computing everylight //I should build a shader that take every light in the scene and make a 3D heightmap of lighting then compute it once for all static light allowing to cheat computing everylight
//light is computed into a scalar field //light is computed into a scalar field
BeginShaderMode(ctx.shader.filter);
//Light Pass
//Screen Filter Pass
BeginShaderMode(ctx.shader.filter);//may be good to have this disabled for accessibility
//DrawTextureRec(); //DrawTextureRec();
EndShaderMode(); EndShaderMode();
//render ui //render ui
//if (ctx.hud_on) {
// UserInterface();
//}
//if (ctx.debug_on) {
// DebugInterface();
//}
EndDrawing(); EndDrawing();
} }