Compare commits

...

2 Commits

Author SHA1 Message Date
d2d6c8c241
Bump engine submodule and move instance parameters to AoS. 2022-12-17 16:56:52 +01:00
f3bc6d6165
Update timings. 2022-12-17 14:14:11 +01:00
4 changed files with 28 additions and 27 deletions

2
engine

@ -1 +1 @@
Subproject commit 3df976c154f76351702fe9f512f09c072dd67f60 Subproject commit 5c9e10eea8059353c7bd8d48e669a9009b60c218

View File

@ -19,32 +19,34 @@ from engine import (
INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, create_batch, draw_batch, destroy_batch) INSTANCE_FLAG_SPAWNED, BATCH_MAX_SIZE, create_batch, draw_batch, destroy_batch)
class Batch: class Batch:
__slots__ = '_batch', 'max_size', 'flags', 'meshes', 'params' __slots__ = '_batch', 'max_size', 'format', 'flags', 'meshes', 'params'
def __init__(self, max_size, params_format): def __init__(self, max_size, params_format):
assert max_size <= BATCH_MAX_SIZE assert max_size <= BATCH_MAX_SIZE
self._batch = create_batch(max_size, params_format) self._batch = create_batch(max_size, params_format)
self.max_size = max_size self.max_size = max_size
self.format = params_format
self.flags = array('B') self.flags = array('B')
self.meshes = array('I') self.meshes = array('I')
self.params = [array('f') for _ in params_format] self.params = array('f')
def __del__(self): def __del__(self):
destroy_batch(self._batch) destroy_batch(self._batch)
def append(self, flags, mesh, params): def append(self, flags, mesh, params):
assert len(params) == len(self.params) assert len(params) == len(self.format)
index = len(self.flags) index = len(self.flags)
assert index < self.max_size assert index < self.max_size
self.flags.append(flags | INSTANCE_FLAG_SPAWNED) self.flags.append(flags | INSTANCE_FLAG_SPAWNED)
self.meshes.append(mesh) self.meshes.append(mesh)
for _params, param in zip(self.params, params): def append_param(param):
_params.extend(param) start = len(self.params)
return index self.params.extend(param)
return slice(start, len(self.params))
return tuple(map(append_param, params))
def set_param(self, param, index, value): def set_param(self, param, id, value):
size = len(value) self.params[id[param]] = value
self.params[param][index * size : index * size + size] = value
def draw(self): def draw(self):
draw_batch(self._batch, self.flags, self.meshes, self.params) draw_batch(self._batch, self.flags, self.meshes, self.params)

View File

@ -97,7 +97,8 @@ def main():
cube = archive.get_model('cube') cube = archive.get_model('cube')
clouds = archive.get_model('clouds') clouds = archive.get_model('clouds')
select_vertices(tests_vertices) select_vertices(tests_vertices)
tests_batch = batch.Batch(3, params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_FLOAT)) tests_batch = batch.Batch(3,
params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE))
blob_translation = vec3((-100.0, -500.0, 0.0)) blob_translation = vec3((-100.0, -500.0, 0.0))
cube_translation = vec3((100.0, -500.0, 0.0)) cube_translation = vec3((100.0, -500.0, 0.0))
cube_orientation = vec3(vec3_forward) cube_orientation = vec3(vec3_forward)
@ -150,7 +151,7 @@ def main():
draw_avg = 0.0 draw_avg = 0.0
perf_count = 0 perf_count = 0
try: try:
for x in range(10000): for frame in range(10000):
current_time = time.monotonic() - start_time current_time = time.monotonic() - start_time
begin_frame() begin_frame()
@ -219,15 +220,16 @@ def main():
frame_end = time.thread_time() frame_end = time.thread_time()
end_frame() end_frame()
draw_ms = draw_end - draw_begin if frame > 0:
draw_min = min(draw_min, draw_ms) draw_ms = draw_end - draw_begin
draw_max = max(draw_max, draw_ms) draw_min = min(draw_min, draw_ms)
draw_avg += draw_ms draw_max = max(draw_max, draw_ms)
frame_ms = frame_end - frame_begin draw_avg += draw_ms
frame_min = min(frame_min, frame_ms) frame_ms = frame_end - frame_begin
frame_max = max(frame_max, frame_ms) frame_min = min(frame_min, frame_ms)
frame_avg += frame_ms frame_max = max(frame_max, frame_ms)
perf_count += 1 frame_avg += frame_ms
perf_count += 1
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
@ -246,9 +248,9 @@ def main():
# lookat = vec3((0.0, 500.0, -500.0)) # lookat = vec3((0.0, 500.0, -500.0))
# for x in range(10000) # for x in range(10000)
# current_time = 0 # current_time = 0
# Draw * 10000 : min = 0.11 , max = 1.87 , avg = 0.16 ms # Draw * 9999 : min = 0.2 , max = 2.16 , avg = 0.26 ms
# Draw * 10000 : min = 0.11 , max = 1.75 , avg = 0.17 ms # Draw * 9999 : min = 0.2 , max = 2.77 , avg = 0.27 ms
# Draw * 10000 : min = 0.11 , max = 1.84 , avg = 0.17 ms # Draw * 9999 : min = 0.2 , max = 2.00 , avg = 0.27 ms
print("Quitting...") print("Quitting...")
del tests_batch del tests_batch

View File

@ -1,3 +0,0 @@
#!/bin/sh
me=$(whoami)
exec sudo /bin/nice --adjustment=-20 su $me -c "exec python3 -O rk_island.py"