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

View File

@ -97,7 +97,8 @@ def main():
cube = archive.get_model('cube')
clouds = archive.get_model('clouds')
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))
cube_translation = vec3((100.0, -500.0, 0.0))
cube_orientation = vec3(vec3_forward)
@ -150,7 +151,7 @@ def main():
draw_avg = 0.0
perf_count = 0
try:
for x in range(10000):
for frame in range(10000):
current_time = time.monotonic() - start_time
begin_frame()
@ -219,6 +220,7 @@ def main():
frame_end = time.thread_time()
end_frame()
if frame > 0:
draw_ms = draw_end - draw_begin
draw_min = min(draw_min, draw_ms)
draw_max = max(draw_max, draw_ms)
@ -246,9 +248,9 @@ def main():
# lookat = vec3((0.0, 500.0, -500.0))
# for x in range(10000)
# current_time = 0
# Draw * 10000 : min = 0.11 , max = 1.87 , avg = 0.16 ms
# Draw * 10000 : min = 0.11 , max = 1.75 , avg = 0.17 ms
# Draw * 10000 : min = 0.11 , max = 1.84 , avg = 0.17 ms
# Draw * 9999 : min = 0.2 , max = 2.16 , avg = 0.26 ms
# Draw * 9999 : min = 0.2 , max = 2.77 , avg = 0.27 ms
# Draw * 9999 : min = 0.2 , max = 2.00 , avg = 0.27 ms
print("Quitting...")
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"