code wiki / _hdl_build / nx_frame_budget.nx
nx_frame_budget.nx source
↩ module page · 12 lines · 1115 B
1// nx_frame_budget.nx -- Enforces a per-frame time budget based on target FPS to ensure frame work fits within device-specific performance limits.
2const K_MAGIC_1000000: i64 = 1000000
3// nx_frame_budget.nx -- P3 RESPONSIVENESS: the FLOOR-DEVICE frame-budget discipline. A target frame rate
4// gives a hard per-frame time budget; the frame's work (sim overhead + render work-units x per-unit cost)
5// must fit inside it on the weakest target device. This is how "low-end mobile plays well" becomes a
6// MEASURABLE gate, not a hope. Pairs with nx_cull_lod: culling is what brings the render work under budget.
7// Pure integer (microseconds). 100% sovereign. license_tier: ORIGINAL
8
9func fb_budget_us(fps: i64) -> i64 { return K_MAGIC_1000000 / fps } // per-frame time budget
10func fb_frame_cost_us(work_units: i64, per_unit_us: i64, overhead_us: i64) -> i64 { return work_units * per_unit_us + overhead_us }
11func fb_fits(cost_us: i64, budget_us: i64) -> i64 { if cost_us <= budget_us { return 1 } return 0 }
12func fb_headroom_us(cost_us: i64, budget_us: i64) -> i64 { return budget_us - cost_us }