mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Lunatic: fix randgen module after md4 removal, run DEFS_BC_SIZE cmd only once.
git-svn-id: https://svn.eduke32.com/eduke32@3785 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f8cc394fa3
commit
a082ec76dd
5 changed files with 27 additions and 21 deletions
|
@ -441,10 +441,14 @@ ifneq ($(LUNATIC),0)
|
||||||
endif
|
endif
|
||||||
BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC
|
BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC
|
||||||
|
|
||||||
# Determine size of defs.ilua bytecode
|
# Determine size of defs.ilua bytecode once.
|
||||||
# XXX: Runs way too many times because it's a "recursively expanded" variable.
|
ifndef DEFS_BC_SIZE
|
||||||
DEFS_BC_SIZE = $(shell $(LUAJIT) -bg -t h $(SRC)/lunatic/defs.ilua -)
|
DEFS_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs.ilua -)
|
||||||
BASECOMMONFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(word 3, $(DEFS_BC_SIZE))
|
DEFS_BC_SIZE := $(word 3, $(DEFS_BC_SIZE))
|
||||||
|
# Pass the bytecode size to the sub-makes, too.
|
||||||
|
export DEFS_BC_SIZE
|
||||||
|
endif
|
||||||
|
BASECOMMONFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(DEFS_BC_SIZE)
|
||||||
|
|
||||||
ifeq ($(PLATFORM),WINDOWS)
|
ifeq ($(PLATFORM),WINDOWS)
|
||||||
BASELIBS+= -lluajit
|
BASELIBS+= -lluajit
|
||||||
|
|
|
@ -3,6 +3,7 @@ engine_main_arrays_are_static;
|
||||||
engine_v8;
|
engine_v8;
|
||||||
|
|
||||||
saveboard_maptext;
|
saveboard_maptext;
|
||||||
|
loadboard_maptext;
|
||||||
|
|
||||||
sector;
|
sector;
|
||||||
wall;
|
wall;
|
||||||
|
|
|
@ -3,6 +3,7 @@ engine_main_arrays_are_static;
|
||||||
engine_v8;
|
engine_v8;
|
||||||
|
|
||||||
saveboard_maptext;
|
saveboard_maptext;
|
||||||
|
loadboard_maptext;
|
||||||
|
|
||||||
sector;
|
sector;
|
||||||
wall;
|
wall;
|
||||||
|
|
|
@ -20,7 +20,6 @@ typedef struct {
|
||||||
} rng_jkiss_t;
|
} rng_jkiss_t;
|
||||||
|
|
||||||
typedef union { unsigned char u[16]; double d[2]; } uchar_double_u_t;
|
typedef union { unsigned char u[16]; double d[2]; } uchar_double_u_t;
|
||||||
typedef union { unsigned char u[16]; uint32_t i[4]; } uchar_uint_u_t;
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- PRNG functions
|
-- PRNG functions
|
||||||
|
@ -28,9 +27,15 @@ decl[[
|
||||||
uint32_t rand_jkiss_u32(rng_jkiss_t *s);
|
uint32_t rand_jkiss_u32(rng_jkiss_t *s);
|
||||||
double rand_jkiss_dbl(rng_jkiss_t *s);
|
double rand_jkiss_dbl(rng_jkiss_t *s);
|
||||||
|
|
||||||
void md4once(const unsigned char *block, unsigned int len, unsigned char digest [16]);
|
uint32_t crc32once(uint8_t *blk, uint32_t len);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
local function get_rand_u32(tin)
|
||||||
|
tin.d[0] = ffiC.gethitickms() % 1
|
||||||
|
tin.d[1] = ffiC.gethitickms() % 1
|
||||||
|
return ffiC.crc32once(tin.u, 16)
|
||||||
|
end
|
||||||
|
|
||||||
local mt = {
|
local mt = {
|
||||||
__tostring = function(s)
|
__tostring = function(s)
|
||||||
return "rand.new("..s.x..","..s.y..","..s.z..","..s.c..")"
|
return "rand.new("..s.x..","..s.y..","..s.z..","..s.c..")"
|
||||||
|
@ -41,23 +46,18 @@ local mt = {
|
||||||
getdbl = ffiC.rand_jkiss_dbl,
|
getdbl = ffiC.rand_jkiss_dbl,
|
||||||
|
|
||||||
-- Initialize the JKISS PRNG using the MD4 of the lower bits of the
|
-- Initialize the JKISS PRNG using the MD4 of the lower bits of the
|
||||||
-- profiling timer
|
-- profiling timer.
|
||||||
init_time_md4 = function(s)
|
init_time_md4 = function(s)
|
||||||
local tin = ffi.new("uchar_double_u_t")
|
local tin = ffi.new("uchar_double_u_t")
|
||||||
local tout = ffi.new("uchar_uint_u_t")
|
local tout = ffi.new("uint32_t [4]")
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
tin.d[0] = ffiC.gethitickms() % 1
|
s.y = get_rand_u32()
|
||||||
tin.d[1] = ffiC.gethitickms() % 1
|
|
||||||
|
|
||||||
ffiC.md4once(tin.u, 16, tout.u)
|
|
||||||
|
|
||||||
s.y = tout.u[1]
|
|
||||||
until (s.y ~= 0) -- y must not be zero!
|
until (s.y ~= 0) -- y must not be zero!
|
||||||
|
|
||||||
s.x = tout.u[0]
|
s.x = get_rand_u32()
|
||||||
s.z = tout.u[2]
|
s.z = get_rand_u32()
|
||||||
s.c = tout.u[3] % 698769068 + 1 -- Should be less than 698769069
|
s.c = get_rand_u32() % 698769068 + 1 -- Should be less than 698769069
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ local t4 = os.clock()
|
||||||
-- x86_64 (embedded): approx. 200 ms (vs. the 100 ms of direct
|
-- x86_64 (embedded): approx. 200 ms (vs. the 100 ms of direct
|
||||||
-- ffiC.rand_jkiss_dbl()):
|
-- ffiC.rand_jkiss_dbl()):
|
||||||
-- x86: 170 ms
|
-- x86: 170 ms
|
||||||
print(1000*(t2-t1))
|
print("getdbl: ".. 1000*(t2-t1))
|
||||||
print(1000*(t3-t2)) -- x86_64: 500 ms, x86: 700 ms
|
print("genpoints: ".. 1000*(t3-t2)) -- x86_64: 500 ms, x86: 700 ms
|
||||||
print(1000*(t4-t3)) -- x86_64, x86: about 35 ms <- thanks to allocation sinking (else, about 500 ms?)
|
print("intersect: ".. 1000*(t4-t3)) -- x86_64, x86: about 35 ms <- thanks to allocation sinking (else, about 500 ms?)
|
||||||
print(v)
|
print("result: ".. tostring(v))
|
||||||
|
|
Loading…
Reference in a new issue