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:
Mergul 2020-06-01 11:24:50 +02:00
parent 86edfa4a57
commit 66860b9042
30 changed files with 1358 additions and 173 deletions

View file

@ -15,7 +15,7 @@ struct IDManager
/************************************************************************************************************************
Get new ID.
*/
pragma(inline, false) EntityID getNewID() nothrow @nogc
EntityID getNewID() nothrow @nogc
{
int current = m_stack_top.atomicOp!"-="(1) + 1;
if (current < 0)

View file

@ -906,7 +906,8 @@ export struct EntityManager
input_data.thread_id = cast(typeof(input_data.thread_id))threadID();
}//*/
static foreach (iii, comp_info; components_info.req)
///FIXME: should be "components_info.req()" but it's not compile with GCC
static foreach (iii, comp_info; components_info.m_req[0 .. components_info.m_req_counter])
{
__traits(getMember, input_data, comp_info.name) = (cast(ForeachType!(typeof(__traits(getMember,
Sys.EntitiesData, comp_info.name)))*)(
@ -914,7 +915,7 @@ export struct EntityManager
.. entities_count];
}
static foreach (iii, comp_info; components_info.optional)
static foreach (iii, comp_info; components_info.m_optional[0 .. components_info.m_optional_counter])
{
if (system.m_optional_components[iii] < info.deltas.length
&& info.deltas[system.m_optional_components[iii]] != 0)
@ -1344,9 +1345,9 @@ export struct EntityManager
"Can't call function with system which hasn't EntitesData structure.");
static assert(__traits(hasMember, Sys, "onUpdate"),
"Can't call function with system which hasn't onUpdate function callback.");
static assert(is(SetFunctionAttributes!(T, functionLinkage!(s.onUpdate),
functionAttributes!(s.onUpdate)) == typeof(&s.onUpdate)),
"Function must match system update function.");
// static assert(is(SetFunctionAttributes!(T, functionLinkage!(s.onUpdate),
// functionAttributes!(s.onUpdate)) == typeof(&s.onUpdate)),
// "Function must match system update function."); FIXME: It's lead to crash on android build
static assert(__traits(hasMember, Sys, "system_id"), "Sys must be system type.");
System* system = getSystem(Sys.system_id);
@ -3105,7 +3106,7 @@ export struct EntityManager
// has_work |= removeEntities();
has_work |= updateEvents();
//id_manager.optimize();
id_manager.optimize();
has_work |= updateBlocks();
has_work |= changeEntities();
has_work |= removeEntities();

View file

@ -112,7 +112,7 @@ else version (D_BetterC)
{
private const uint max_alloca = 10000;
private __gshared byte[max_alloca] alloca_array;
private uint alloca_pos = 0;
private __gshared uint alloca_pos = 0;
export extern (C) void* __alloca(size_t length) @nogc nothrow
{
if (alloca_pos + length > max_alloca)
@ -158,7 +158,32 @@ static struct Mallocator
static if (__traits(isPOD, T))
{
static immutable T init = T.init;
__gshared immutable T init = T.init;
foreach (i; 0 .. ret.length)
{
memcpy(&ret[i], &init, T.sizeof);
}
}
else
{
static import std.conv;
foreach (i; 0 .. ret.length)
{
std.conv.emplace(&ret[i]);
}
}
return ret;
}
static T[] alignMakeArray(T)(size_t length, size_t alignment) nothrow @nogc
{
T[] ret = (cast(T*) alignAlloc(T.sizeof * length, alignment))[0 .. length];
static if (__traits(isPOD, T))
{
__gshared immutable T init = T.init;
foreach (i; 0 .. ret.length)
{
@ -206,7 +231,7 @@ static struct Mallocator
static if (__traits(isPOD, T))
{
static immutable T init = T.init;
__gshared immutable T init = T.init;
memcpy(ret, &init, T.sizeof);
}
else static if (is(T == struct))