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:
Mergul 2020-05-13 15:34:24 +02:00
parent dd491302af
commit 3647fa4b86
6 changed files with 98 additions and 16 deletions

View file

@ -810,6 +810,46 @@ private:
JobData[4] resumeJobs; /// Dummu jobs to resume some thread
public:
static int getCPUCoresCount()
{
version(Windows)
{
import core.sys.windows.winbase : SYSTEM_INFO, GetSystemInfo;
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
}
else version (linux)
{
version(D_BetterC)
{
import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf;
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
}
else
{
import core.sys.linux.sched : CPU_COUNT, cpu_set_t, sched_getaffinity;
import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf;
cpu_set_t set = void;
if (sched_getaffinity(0, cpu_set_t.sizeof, &set) == 0)
{
int count = CPU_COUNT(&set);
if (count > 0)
return cast(uint) count;
}
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
}
}
else version(Posix)
{
import core.sys.posix.unistd;
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
}
else return -1;
}
int jobsDoneCount()
{
int sum;