Compare commits
No commits in common. "d2d6c8c24105b2f896ffd7fde923cb729fdc15a6" and "56d76f30e2d7ff481ab16f83c8697200f1901ce3" have entirely different histories.
d2d6c8c241
...
56d76f30e2
2
engine
2
engine
@ -1 +1 @@
|
|||||||
Subproject commit 5c9e10eea8059353c7bd8d48e669a9009b60c218
|
Subproject commit 3df976c154f76351702fe9f512f09c072dd67f60
|
@ -19,34 +19,32 @@ 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', 'format', 'flags', 'meshes', 'params'
|
__slots__ = '_batch', 'max_size', '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')
|
self.params = [array('f') for _ in params_format]
|
||||||
|
|
||||||
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.format)
|
assert len(params) == len(self.params)
|
||||||
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)
|
||||||
def append_param(param):
|
for _params, param in zip(self.params, params):
|
||||||
start = len(self.params)
|
_params.extend(param)
|
||||||
self.params.extend(param)
|
return index
|
||||||
return slice(start, len(self.params))
|
|
||||||
return tuple(map(append_param, params))
|
|
||||||
|
|
||||||
def set_param(self, param, id, value):
|
def set_param(self, param, index, value):
|
||||||
self.params[id[param]] = value
|
size = len(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)
|
||||||
|
12
game/game.py
12
game/game.py
@ -97,8 +97,7 @@ 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,
|
tests_batch = batch.Batch(3, params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_FLOAT))
|
||||||
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)
|
||||||
@ -151,7 +150,7 @@ def main():
|
|||||||
draw_avg = 0.0
|
draw_avg = 0.0
|
||||||
perf_count = 0
|
perf_count = 0
|
||||||
try:
|
try:
|
||||||
for frame in range(10000):
|
for x in range(10000):
|
||||||
current_time = time.monotonic() - start_time
|
current_time = time.monotonic() - start_time
|
||||||
|
|
||||||
begin_frame()
|
begin_frame()
|
||||||
@ -220,7 +219,6 @@ def main():
|
|||||||
frame_end = time.thread_time()
|
frame_end = time.thread_time()
|
||||||
end_frame()
|
end_frame()
|
||||||
|
|
||||||
if frame > 0:
|
|
||||||
draw_ms = draw_end - draw_begin
|
draw_ms = draw_end - draw_begin
|
||||||
draw_min = min(draw_min, draw_ms)
|
draw_min = min(draw_min, draw_ms)
|
||||||
draw_max = max(draw_max, draw_ms)
|
draw_max = max(draw_max, draw_ms)
|
||||||
@ -248,9 +246,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 * 9999 : min = 0.2 , max = 2.16 , avg = 0.26 ms
|
# Draw * 10000 : min = 0.11 , max = 1.87 , avg = 0.16 ms
|
||||||
# Draw * 9999 : min = 0.2 , max = 2.77 , avg = 0.27 ms
|
# Draw * 10000 : min = 0.11 , max = 1.75 , avg = 0.17 ms
|
||||||
# Draw * 9999 : min = 0.2 , max = 2.00 , avg = 0.27 ms
|
# Draw * 10000 : min = 0.11 , max = 1.84 , avg = 0.17 ms
|
||||||
|
|
||||||
print("Quitting...")
|
print("Quitting...")
|
||||||
del tests_batch
|
del tests_batch
|
||||||
|
3
rk_island-profile.sh
Executable file
3
rk_island-profile.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
me=$(whoami)
|
||||||
|
exec sudo /bin/nice --adjustment=-20 su $me -c "exec python3 -O rk_island.py"
|
Loading…
Reference in New Issue
Block a user