mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +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
|
||||
BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC
|
||||
|
||||
# Determine size of defs.ilua bytecode
|
||||
# XXX: Runs way too many times because it's a "recursively expanded" variable.
|
||||
DEFS_BC_SIZE = $(shell $(LUAJIT) -bg -t h $(SRC)/lunatic/defs.ilua -)
|
||||
BASECOMMONFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(word 3, $(DEFS_BC_SIZE))
|
||||
# Determine size of defs.ilua bytecode once.
|
||||
ifndef DEFS_BC_SIZE
|
||||
DEFS_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs.ilua -)
|
||||
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)
|
||||
BASELIBS+= -lluajit
|
||||
|
|
|
@ -3,6 +3,7 @@ engine_main_arrays_are_static;
|
|||
engine_v8;
|
||||
|
||||
saveboard_maptext;
|
||||
loadboard_maptext;
|
||||
|
||||
sector;
|
||||
wall;
|
||||
|
|
|
@ -3,6 +3,7 @@ engine_main_arrays_are_static;
|
|||
engine_v8;
|
||||
|
||||
saveboard_maptext;
|
||||
loadboard_maptext;
|
||||
|
||||
sector;
|
||||
wall;
|
||||
|
|
|
@ -20,7 +20,6 @@ typedef struct {
|
|||
} rng_jkiss_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
|
||||
|
@ -28,9 +27,15 @@ decl[[
|
|||
uint32_t rand_jkiss_u32(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 = {
|
||||
__tostring = function(s)
|
||||
return "rand.new("..s.x..","..s.y..","..s.z..","..s.c..")"
|
||||
|
@ -41,23 +46,18 @@ local mt = {
|
|||
getdbl = ffiC.rand_jkiss_dbl,
|
||||
|
||||
-- Initialize the JKISS PRNG using the MD4 of the lower bits of the
|
||||
-- profiling timer
|
||||
-- profiling timer.
|
||||
init_time_md4 = function(s)
|
||||
local tin = ffi.new("uchar_double_u_t")
|
||||
local tout = ffi.new("uchar_uint_u_t")
|
||||
local tout = ffi.new("uint32_t [4]")
|
||||
|
||||
repeat
|
||||
tin.d[0] = ffiC.gethitickms() % 1
|
||||
tin.d[1] = ffiC.gethitickms() % 1
|
||||
|
||||
ffiC.md4once(tin.u, 16, tout.u)
|
||||
|
||||
s.y = tout.u[1]
|
||||
s.y = get_rand_u32()
|
||||
until (s.y ~= 0) -- y must not be zero!
|
||||
|
||||
s.x = tout.u[0]
|
||||
s.z = tout.u[2]
|
||||
s.c = tout.u[3] % 698769068 + 1 -- Should be less than 698769069
|
||||
s.x = get_rand_u32()
|
||||
s.z = get_rand_u32()
|
||||
s.c = get_rand_u32() % 698769068 + 1 -- Should be less than 698769069
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ local t4 = os.clock()
|
|||
-- x86_64 (embedded): approx. 200 ms (vs. the 100 ms of direct
|
||||
-- ffiC.rand_jkiss_dbl()):
|
||||
-- x86: 170 ms
|
||||
print(1000*(t2-t1))
|
||||
print(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(v)
|
||||
print("getdbl: ".. 1000*(t2-t1))
|
||||
print("genpoints: ".. 1000*(t3-t2)) -- x86_64: 500 ms, x86: 700 ms
|
||||
print("intersect: ".. 1000*(t4-t3)) -- x86_64, x86: about 35 ms <- thanks to allocation sinking (else, about 500 ms?)
|
||||
print("result: ".. tostring(v))
|
||||
|
|
Loading…
Reference in a new issue