Compare commits
No commits in common. "a91a852887adcfba66061b795492a54c40e95c15" and "baac333b44118e17e46f85fc8637aa5ff7f519fc" have entirely different histories.
a91a852887
...
baac333b44
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ cpp/math.cpp
|
||||
|
||||
OUTPUTFILE = engine.so
|
||||
|
||||
CXXFLAGS = -Wall -Werror -O2 -march=x86-64 -mtune=generic -msse2 -ffast-math -fpic -flto -fno-rtti -fno-exceptions
|
||||
CXXFLAGS = -fpic -Wall -Werror -O2 -flto -fomit-frame-pointer -ffast-math -funroll-loops -fno-rtti -fno-exceptions
|
||||
|
||||
.PHONY: all
|
||||
all: clean $(OUTPUTFILE)
|
||||
|
@ -837,32 +837,6 @@ static void rk_pack_batch(
|
||||
batch.state = RK_BATCH_STATE_PACKED;
|
||||
}
|
||||
|
||||
static bool rk_compare_replace(
|
||||
void * __restrict _dst,
|
||||
void const * __restrict _src,
|
||||
unsigned const size) {
|
||||
rk_ulong hash = 0;
|
||||
rk_ulong * dst = reinterpret_cast<rk_ulong *>(_dst);
|
||||
rk_ulong const * src = reinterpret_cast<rk_ulong const *>(_src);
|
||||
unsigned count = size / sizeof(rk_ulong);
|
||||
unsigned remain = (size - count * sizeof(rk_ulong));
|
||||
if (count) {
|
||||
do {
|
||||
hash |= *dst ^ *src;
|
||||
*dst++ = *src++;
|
||||
} while(--count > 0);
|
||||
}
|
||||
rk_ubyte * rdst = reinterpret_cast<rk_ubyte *>(dst);
|
||||
rk_ubyte const * rsrc = reinterpret_cast<rk_ubyte const *>(src);
|
||||
if (remain) {
|
||||
do {
|
||||
hash |= *rdst ^ *rsrc;
|
||||
*rdst++ = *rsrc++;
|
||||
} while(--remain > 0);
|
||||
}
|
||||
return (hash != 0);
|
||||
}
|
||||
|
||||
void rk_fill_batch(
|
||||
rk_batch_t _batch,
|
||||
rk_uint count,
|
||||
@ -887,28 +861,30 @@ void rk_fill_batch(
|
||||
}
|
||||
}
|
||||
bool const is_empty = (batch->state < RK_BATCH_STATE_FILLED);
|
||||
bool const resized = (count != batch->count);
|
||||
bool const got_everything = (flags && meshes && got_all_params);
|
||||
bool const need_sorting = (is_empty || flags || meshes || count != batch->count);
|
||||
if (is_empty && !got_everything) {
|
||||
rk_printf("rk_fill_batch(): cannot freeze and empty batch.");
|
||||
return;
|
||||
} else if (count > batch->count && !got_everything) {
|
||||
rk_printf("rk_fill_batch(): cannot grow a frozen batch.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
batch->count = count;
|
||||
bool const cmp_flags =
|
||||
(flags && rk_compare_replace(batch->flags, flags, batch->count * sizeof(rk_instance_flags)));
|
||||
bool const cmp_meshes =
|
||||
(meshes && rk_compare_replace(batch->meshes, meshes, batch->count * sizeof(rk_mesh)));
|
||||
bool const need_sorting = (cmp_flags || cmp_meshes || resized);
|
||||
}
|
||||
if (flags) {
|
||||
memcpy(batch->flags, flags, batch->count * sizeof(rk_instance_flags));
|
||||
}
|
||||
if (meshes) {
|
||||
memcpy(batch->meshes, meshes, batch->count * sizeof(rk_mesh));
|
||||
}
|
||||
if (batch->nparams) {
|
||||
rk_parameter const * const last_param = batch->params + batch->nparams;
|
||||
if (got_any_params) {
|
||||
rk_ubyte const * const * src = params;
|
||||
for (rk_parameter const * dst = batch->params; dst < last_param; ++dst, ++src) {
|
||||
dst->dirty =
|
||||
(*src && rk_compare_replace(dst->source, *src, batch->count * dst->src_size)) || need_sorting;
|
||||
dst->dirty = (need_sorting || *src);
|
||||
if (*src) {
|
||||
memcpy(dst->source, *src, batch->count * dst->src_size);
|
||||
}
|
||||
}
|
||||
} else if (need_sorting) {
|
||||
for (rk_parameter const * dst = batch->params; dst < last_param; ++dst) {
|
||||
|
Loading…
Reference in New Issue
Block a user