Android update and small improvements
-fixed code do cross compiling to android -fixed build with GCC (workaround) -added little benchmark -several small fixes -updated meson build (demos building, working with GCC, LDC and DMD) -added some meson options -added ImGUI bind for OpenGL3
This commit is contained in:
parent
86edfa4a57
commit
66860b9042
30 changed files with 1358 additions and 173 deletions
111
tests/tests.d
111
tests/tests.d
|
|
@ -93,6 +93,13 @@ struct TestEvent2
|
|||
float a;
|
||||
}
|
||||
|
||||
static struct CPosition
|
||||
{
|
||||
mixin ECS.Component;
|
||||
float x;
|
||||
float y;
|
||||
}
|
||||
|
||||
static struct TestComp
|
||||
{
|
||||
mixin ECS.Component; //__gshared ushort component_id;
|
||||
|
|
@ -186,6 +193,52 @@ static struct TestComp5
|
|||
}
|
||||
}
|
||||
|
||||
struct EverySystem
|
||||
{
|
||||
mixin ECS.System;
|
||||
|
||||
struct EntitiesData
|
||||
{
|
||||
uint length;
|
||||
Entity[] entity;
|
||||
CPosition[] pos;
|
||||
}
|
||||
|
||||
void onUpdate(EntitiesData data)
|
||||
{
|
||||
foreach(i;0..data.length)
|
||||
{
|
||||
data.pos[i].x++;
|
||||
data.pos[i].y++;
|
||||
}
|
||||
}
|
||||
|
||||
void iterate(EntitiesData data)
|
||||
{
|
||||
foreach(i;0..data.length)
|
||||
{
|
||||
data.pos[i].x++;
|
||||
data.pos[i].y++;
|
||||
}
|
||||
}
|
||||
|
||||
void free(EntitiesData data)
|
||||
{
|
||||
foreach(i;0..data.length)
|
||||
{
|
||||
gEM.removeEntity(data.entity[i].id);
|
||||
}
|
||||
}
|
||||
|
||||
void addOne(EntitiesData data)
|
||||
{
|
||||
foreach(i;0..data.length)
|
||||
{
|
||||
gEM.addComponents(data.entity[i].id, TestComp2());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ChangeTestSystem
|
||||
{
|
||||
mixin ECS.System!16; //__gshared ushort system_id;
|
||||
|
|
@ -648,6 +701,7 @@ else:
|
|||
gEM.registerComponent!TestComp;
|
||||
gEM.registerComponent!TestComp3;
|
||||
gEM.registerComponent!TestComp5;
|
||||
gEM.registerComponent!CPosition;
|
||||
|
||||
gEM.registerEvent!TestEvent;
|
||||
gEM.registerEvent!TestEvent2;
|
||||
|
|
@ -669,6 +723,7 @@ else:
|
|||
gEM.registerSystem!EmptySystem(2);
|
||||
gEM.registerSystem!EmptyEventSystem(2);
|
||||
gEM.registerSystem!EventSystem(2);
|
||||
gEM.registerSystem!EverySystem(0);
|
||||
//gEM.registerSystem!TestSystemWithHighPriority(100);
|
||||
//gEM.registerSystem!TestSystem2(0);
|
||||
gEM.endRegister();
|
||||
|
|
@ -693,6 +748,62 @@ else:
|
|||
//dur = (MonoTime.currTime - time).total!"usecs";
|
||||
//writeln("Template allocating: ", dur, " usecs");
|
||||
printf("Template allocating: %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
|
||||
time = Time.getUSecTime();
|
||||
ushort[1] empty_ids = [CPosition.component_id];
|
||||
EntityTemplate* tmpl_empty = gEM.allocateTemplate(empty_ids);
|
||||
|
||||
gEM.commit();
|
||||
|
||||
time = Time.getUSecTime();
|
||||
|
||||
foreach(i;0..4_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
foreach(i;0..4_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
foreach(i;0..2_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
|
||||
printf("Adding 1M entities: %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
gEM.commit();
|
||||
time = Time.getUSecTime();
|
||||
gEM.callEntitiesFunction!EverySystem(&gEM.getSystem!EverySystem().iterate);
|
||||
printf("Iterate 1M entities: %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
gEM.begin();
|
||||
time = Time.getUSecTime();
|
||||
gEM.update();
|
||||
printf("Iterate 1M entities (update): %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
gEM.end();
|
||||
|
||||
time = Time.getUSecTime();
|
||||
gEM.callEntitiesFunction!EverySystem(&gEM.getSystem!EverySystem().free);
|
||||
gEM.commit();
|
||||
printf("Deleting 1M entities: %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
time = Time.getUSecTime();
|
||||
|
||||
foreach(i;0..4_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
foreach(i;0..4_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
foreach(i;0..2_000_000)gEM.addEntity(tmpl_empty);
|
||||
gEM.commit();
|
||||
|
||||
printf("Adding 1M entities (prealloc): %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
gEM.commit();
|
||||
time = Time.getUSecTime();
|
||||
gEM.callEntitiesFunction!EverySystem(&gEM.getSystem!EverySystem().addOne);
|
||||
gEM.commit();
|
||||
printf("Adding 1M component: %f usecs\n", cast(float)(Time.getUSecTime() - time));
|
||||
|
||||
gEM.commit();
|
||||
gEM.callEntitiesFunction!EverySystem(&gEM.getSystem!EverySystem().free);
|
||||
gEM.commit();
|
||||
|
||||
time = Time.getUSecTime();
|
||||
|
||||
EntityID entity;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue