Demo update and start counting tests times

-Fixed performance issue with multithreading and rendering
-start making better shaders (by using many macros)
-speed up rendeing when maximum objects count was reached
-remove map rendering form Snake demo, and render entities by themself
-start adding depth and color rendering parameters
-added properly names to jobs (for debugging purpses)
-starts adding multithreaded rendering
-added some math to vectors
-changes execute() to willExecute(). Probably should have different name.
This commit is contained in:
Mergul 2020-05-07 14:07:07 +02:00
parent 46aba822d0
commit 4bd5a37b5d
13 changed files with 429 additions and 198 deletions

View file

@ -9,7 +9,7 @@ import bubel.ecs.atomic;
//import std.stdio;
import std.algorithm : map;
version = MM_NO_LOGS; // Disable log creation
//version = MM_NO_LOGS; // Disable log creation
//version = MM_USE_POSIX_THREADS; // Use posix threads insted of standard library, required for betterC
version (Posix)version = MM_USE_POSIX_THREADS;
@ -1141,17 +1141,19 @@ public:
foreach (ref log; logs)
{
size += log.name.length; // size of name
size += log.name.length + 1; // size of name
}
char* buffer = cast(char*) malloc(size);
foreach (ref log; logs)
{
char[100] name_buffer;
name_buffer[0 .. log.name.length] = log.name;
name_buffer[log.name.length] = 0;
size_t charWritten = snprintf(buffer + used, size - used,
`{"name":"%s", "pid":1, "tid":%lld, "ph":"X", "ts":%lld, "dur":%lld }, %s`,
log.name.ptr, threadData.threadId + 1, log.time, log.duration, "\n".ptr);
name_buffer.ptr, threadData.threadId + 1, log.time, log.duration, "\n".ptr);
used += charWritten;
}
@ -1447,7 +1449,21 @@ private void threadFunc(ThreadData* threadData)
if (data is null)
{
// Thread does not have own job and can not steal it, so wait for a job
bool ok = threadData.semaphore.timedWait(1_000 + !acceptJobs * 10_000);
int tryWait = 0;
//bool ok = threadData.semaphore.timedWait(1_000 + !acceptJobs * 10_000);
bool ok = true;
while(!threadData.semaphore.tryWait())
{
tryWait++;
if(tryWait>5000)
{
ok = false;
break;
}
static foreach(i;0..10)instructionPause();
}
if(!ok)ok = threadData.semaphore.timedWait(1_000 + !acceptJobs * 10_000);
if (ok)
{