perf(scene3d): cap render loop at ~60 FPS to keep UI responsive
This commit is contained in:
1 parent
65ad527eeb
commit
3cd28b9925
1 file changed
+12
-1
+12
-1
@@ -3,8 +3,19 @@ import vpsdk.process as process
|
||||
import vpsdk.vpui as vpui
|
||||
import string
|
||||
from stdint import *
|
||||
import vpsdk.syscall as syscall
|
||||
import gfx
|
||||
|
||||
class _Timespec:
|
||||
tv_sec: int64
|
||||
tv_nsec: int64
|
||||
|
||||
def _sleep_ms(ms: int):
|
||||
ts: _Timespec
|
||||
ts.tv_sec = int64(ms / 1000)
|
||||
ts.tv_nsec = int64((ms % 1000) * 1000000)
|
||||
syscall.nanosleep(&ts, None)
|
||||
|
||||
define SCENE_W = 640
|
||||
define SCENE_H = 360
|
||||
|
||||
@@ -35,7 +46,7 @@ def _render_thread(arg: rawptr):
|
||||
_time_val += float(0.02)
|
||||
if _time_val >= TIME_WRAP: _time_val = _time_val - TIME_WRAP
|
||||
root.update()
|
||||
process.yield_cpu()
|
||||
_sleep_ms(16)
|
||||
_render_done = 1
|
||||
# 窗口已被 explorer 回收:显式 THREAD_EXIT,绝不 return —— 用户线程的 return 会落到
|
||||
# 出口跳板(旧调用号 34,而 THREAD_EXIT=60)⇒ Ring3 `jmp $` 空转、全机不再调度。
|
||||
|
||||
Reference in new issue
Block a user