Demos update
-added functionality to detect host CPU threads count -fixed some memory leaks -now textures free memory corectly -added support for up to 32 threads
This commit is contained in:
parent
dd491302af
commit
3647fa4b86
6 changed files with 98 additions and 16 deletions
|
|
@ -58,7 +58,7 @@ struct Launcher
|
|||
uint style = 3;
|
||||
uint entities_count;
|
||||
bool multithreading;
|
||||
int threads;
|
||||
int threads = 1;
|
||||
ulong timer_freq;
|
||||
double delta_time;
|
||||
uint fps;
|
||||
|
|
@ -103,6 +103,14 @@ struct Launcher
|
|||
manager.update("clean");
|
||||
manager.end();
|
||||
|
||||
foreach(system; manager.systems)
|
||||
{
|
||||
if(system.id != CountSystem.system_id && system.id != CleanSystem.system_id)system.disable();
|
||||
}
|
||||
|
||||
/*launcher.manager.getSystem(CountSystem.system_id).enable();
|
||||
launcher.manager.getSystem(CleanSystem.system_id).enable();//*/
|
||||
|
||||
if(start)start();
|
||||
this.loop = loop;
|
||||
this.end = end;
|
||||
|
|
@ -316,11 +324,19 @@ void mainLoop(void* arg)
|
|||
if(igMenuItemBool("Multithreading", null, launcher.multithreading, true))
|
||||
{
|
||||
launcher.multithreading = !launcher.multithreading;
|
||||
if(launcher.multithreading)
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(launcher.threads);
|
||||
}
|
||||
else
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(1);
|
||||
}
|
||||
}
|
||||
igSetNextItemWidth(0);
|
||||
igLabelText("Threads:",null);
|
||||
igSameLine(0,4);
|
||||
if(igSliderInt("##Threads",&launcher.threads, 1, 12, null))//"Multithreading", null, launcher.multithreading, true))
|
||||
if(igSliderInt("##Threads",&launcher.threads, 1, 32, null))//"Multithreading", null, launcher.multithreading, true))
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(launcher.threads);
|
||||
//launcher.threads = !launcher.multithreading;
|
||||
|
|
@ -547,13 +563,13 @@ void mainLoop(void* arg)
|
|||
launcher.renderer.clear();
|
||||
|
||||
double loop_time = launcher.getTime();
|
||||
launcher.job_updater.pool.tryWaitCount = 5000;
|
||||
launcher.job_updater.pool.tryWaitCount = 10000;
|
||||
if(launcher.loop && !launcher.loop())
|
||||
{
|
||||
quit();
|
||||
*cast(bool*)arg = false;
|
||||
}
|
||||
launcher.job_updater.pool.tryWaitCount = 10;
|
||||
launcher.job_updater.pool.tryWaitCount = 0;
|
||||
|
||||
loop_time = launcher.getTime() - loop_time;
|
||||
|
||||
|
|
@ -697,10 +713,10 @@ int main(int argc, char** argv)
|
|||
|
||||
setStyle(3);
|
||||
|
||||
launcher.job_updater = Mallocator.make!ECSJobUpdater(12);
|
||||
launcher.job_updater = Mallocator.make!ECSJobUpdater(1);
|
||||
//launcher.job_updater.onCreate();
|
||||
|
||||
EntityManager.initialize(12);
|
||||
EntityManager.initialize(32);
|
||||
launcher.manager = EntityManager.instance;
|
||||
|
||||
//launcher.manager.m_thread_id_func = &launcher.job_updater.getThreadID;
|
||||
|
|
@ -720,6 +736,10 @@ int main(int argc, char** argv)
|
|||
|
||||
launcher.renderer.initialize();
|
||||
|
||||
import mmutils.thread_pool : ThreadPool;
|
||||
launcher.threads = ThreadPool.getCPUCoresCount();
|
||||
if(launcher.threads < 2)launcher.threads = 2;
|
||||
|
||||
launcher.gui_manager = Mallocator.make!GUIManager();
|
||||
|
||||
{
|
||||
|
|
@ -752,6 +772,8 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
EntityManager.destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue