Compare commits

..
Author SHA1 Message Date
codegirl007 98f56833a0 Add set_sprite_clip_def for pre-resolved clip switches 2026-08-14 23:19:30 -07:00
codegirl007 3cc4797a72 Test draw_sprite MAX_SPRITES enqueue capacity 2026-08-14 23:19:07 -07:00
codegirl007 f295aedf04 Merge master into draw-sprite-max-sprites-guard.
Resolve batching_test.odin by keeping master tests and the MAX_SPRITES guard test.
2026-08-14 23:17:48 -07:00
codegirl007 ba0b25980c Speed group_texture_runs for two-texture batches 2026-08-14 23:13:29 -07:00
codegirl007 71c76f180e Add crowd_batch, crowd_overdraw, and clip_thrash stress examples 2026-08-14 23:12:58 -07:00
codegirl007 00ba400d15 Add crowd_batch, crowd_overdraw, and clip_thrash stress examples. 2026-08-14 23:08:03 -07:00
codegirl007 c97a17f85b Speed group_texture_runs for two-texture batches. 2026-08-14 23:08:00 -07:00
codegirl007 a24f547709 Add set_sprite_clip_def for pre-resolved clip switches. 2026-08-14 23:07:58 -07:00
codegirl007 9df98ef73d Merge pull request #31 from Codegirl-Games/test-sprite-clip-cache
Test sprite clip_def cache on set_sprite_clip
2026-08-14 22:44:52 -07:00
codegirl007 f65b0354df Test that set_sprite_clip caches clip_def on sprites.
Locks spawn/switch cache fill and that a bad clip name leaves the prior cache intact.
2026-08-14 22:43:42 -07:00
codegirl007 cc196afd2e Cache sprite clip defs to cut per-frame map lookups 2026-08-14 22:42:15 -07:00
codegirl007 8d9faaaee0 Drop verbose comments from the clip-cache change. 2026-08-14 22:40:42 -07:00
codegirl007 41fb0a3d5a Cache clip defs on sprites to avoid per-frame map lookups.
Crowd stress (128 sprites) showed Clip_Def string map_get as the top engine cost; cache on set_sprite_clip and use it in update/draw.
2026-08-14 22:32:28 -07:00
codegirl007 dcf5ea29b0 Texture batching with prepare_draw_batches test coverage 2026-08-14 22:20:08 -07:00
codegirl007 70784b0f1b Test DXIL shader runtime preference without MSL 2026-08-14 22:19:16 -07:00
codegirl007 fb63ee21f4 Test draw_sprite refuses to exceed MAX_SPRITES.
Locks the enqueue capacity guard so a full draw_list cannot grow past the vertex buffer budget.
2026-08-14 22:18:42 -07:00
codegirl007 deef204bd3 Test DXIL preference when MSL is unavailable.
Locks the MSL > DXIL > SPIRV shader runtime order so Windows paths cannot silently fall through to Vulkan.
2026-08-14 22:16:58 -07:00
10 changed files with 513 additions and 44 deletions
+17 -2
View File
@@ -1,7 +1,7 @@
.PHONY: shaders-vulkan shaders-d3d12 shaders-metal shaders-all bake toad hello_sprite crowd camera_sandbox clips check test help
.PHONY: shaders-vulkan shaders-d3d12 shaders-metal shaders-all bake toad hello_sprite crowd crowd_batch crowd_overdraw clip_thrash camera_sandbox clips check test help
.PHONY: flame flame-build flame-record flame-svg flame-report flame-tools
# Flamegraph profiling (needs: pacman -S perf). Example: make flame or make flame FLAME_EXAMPLE=toad
# Flamegraph profiling (needs: pacman -S perf). Example: make flame or make flame FLAME_EXAMPLE=crowd_batch
FLAME_EXAMPLE ?= crowd
FLAME_BIN := $(FLAME_EXAMPLE)_perf
FLAMEGRAPH_DIR ?= tools/FlameGraph
@@ -24,6 +24,9 @@ help:
@echo " toad Run the toad example (full demo)"
@echo " hello_sprite Minimal load + draw"
@echo " crowd Many sprites, one Character_Data"
@echo " crowd_batch Multi-texture batching stress (two toad loads)"
@echo " crowd_overdraw Stacked sprites overdraw stress"
@echo " clip_thrash Per-frame idle/walk clip flip stress"
@echo " camera_sandbox Pan camera / Space toggles follow"
@echo " clips Keys 1/2 switch idle/walk"
@echo " flame Build+record+SVG+JPG+text report (FLAME_EXAMPLE=$(FLAME_EXAMPLE))"
@@ -54,6 +57,9 @@ check:
odin check examples/toad -collection:pkg=.
odin check examples/hello_sprite -collection:pkg=.
odin check examples/crowd -collection:pkg=.
odin check examples/crowd_batch -collection:pkg=.
odin check examples/crowd_overdraw -collection:pkg=.
odin check examples/clip_thrash -collection:pkg=.
odin check examples/camera_sandbox -collection:pkg=.
odin check examples/clips -collection:pkg=.
@@ -66,6 +72,15 @@ hello_sprite:
crowd:
odin run examples/crowd -collection:pkg=.
crowd_batch:
odin run examples/crowd_batch -collection:pkg=.
crowd_overdraw:
odin run examples/crowd_overdraw -collection:pkg=.
clip_thrash:
odin run examples/clip_thrash -collection:pkg=.
camera_sandbox:
odin run examples/camera_sandbox -collection:pkg=.
+57
View File
@@ -118,6 +118,63 @@ set_sprite_clip_switch_and_guards :: proc(t: ^testing.T) {
testing.expect_value(t, sprite.time, f32(0.09))
}
@(test)
set_sprite_clip_caches_clip_def :: proc(t: ^testing.T) {
data := make_test_character()
defer destroy_test_character(&data)
sprite := spawn_sprite(&data, {}, "idle", 0)
testing.expect(t, sprite.has_clip, "spawn should cache a valid clip")
testing.expect_value(t, sprite.clip, "idle")
testing.expect(t, sprite.clip_def.loop, "idle clip loops")
testing.expect_value(t, sprite.clip_def.fps, f32(10))
testing.expect_value(t, len(sprite.clip_def.frames), 3)
set_sprite_clip(&sprite, "once")
testing.expect(t, sprite.has_clip, "switch should refresh cache")
testing.expect_value(t, sprite.clip, "once")
testing.expect(t, !sprite.clip_def.loop, "once clip does not loop")
testing.expect_value(t, sprite.clip_def.fps, f32(10))
testing.expect_value(t, len(sprite.clip_def.frames), 3)
set_sprite_clip(&sprite, "nope")
testing.expect(t, sprite.has_clip, "bad clip must leave cache intact")
testing.expect_value(t, sprite.clip, "once")
testing.expect(t, !sprite.clip_def.loop, "cached once clip preserved")
testing.expect_value(t, len(sprite.clip_def.frames), 3)
}
@(test)
set_sprite_clip_def_applies_and_guards :: proc(t: ^testing.T) {
data := make_test_character()
defer destroy_test_character(&data)
sprite := spawn_sprite(&data, {}, "idle", 0)
sprite.frame = 2
sprite.time = 0.05
once := data.def.clips["once"]
set_sprite_clip_def(&sprite, "once", once)
testing.expect_value(t, sprite.clip, "once")
testing.expect(t, sprite.has_clip, "def apply should mark clip present")
testing.expect_value(t, sprite.frame, 0)
testing.expect_value(t, sprite.time, f32(0))
testing.expect(t, !sprite.clip_def.loop, "once clip does not loop")
testing.expect_value(t, len(sprite.clip_def.frames), 3)
sprite.frame = 1
sprite.time = 0.09
set_sprite_clip_def(&sprite, "once", once)
testing.expect_value(t, sprite.frame, 1)
testing.expect_value(t, sprite.time, f32(0.09))
set_sprite_clip_def(&sprite, "empty", Clip_Def{loop = true, fps = 10, frames = nil})
testing.expect_value(t, sprite.clip, "once")
testing.expect_value(t, sprite.frame, 1)
set_sprite_clip_def(nil, "once", once)
}
@(test)
spawn_sprite_valid_and_invalid :: proc(t: ^testing.T) {
data := make_test_character()
+72 -13
View File
@@ -504,19 +504,78 @@ group_texture_runs :: proc(list: []Queued_Sprite) {
end += 1
}
// Stable insertion sort is sufficient while MAX_SPRITES is 128.
for i in start + 1 ..< end {
item := list[i]
j := i
for j > start {
if uintptr(list[j - 1].texture) <= uintptr(item.texture) {
break
}
list[j] = list[j - 1]
j -= 1
}
list[j] = item
}
stable_group_by_texture(list[start:end])
start = end
}
}
// Stably orders window by texture pointer. Fast path for 12 textures
// (common); insertion sort for 3+.
stable_group_by_texture :: proc(window: []Queued_Sprite) {
n := len(window)
if n <= 1 do return
already := true
for i in 1 ..< n {
if uintptr(window[i].texture) < uintptr(window[i - 1].texture) {
already = false
break
}
}
if already do return
first := uintptr(window[0].texture)
second: uintptr
has_second := false
third := false
for i in 1 ..< n {
t := uintptr(window[i].texture)
if t == first do continue
if !has_second {
second = t
has_second = true
continue
}
if t != second {
third = true
break
}
}
if !has_second do return
if third {
for i in 1 ..< n {
item := window[i]
j := i
for j > 0 {
if uintptr(window[j - 1].texture) <= uintptr(item.texture) {
break
}
window[j] = window[j - 1]
j -= 1
}
window[j] = item
}
return
}
lo, hi := first, second
if lo > hi do lo, hi = hi, lo
tmp: [MAX_SPRITES]Queued_Sprite
w := 0
for q in window {
if uintptr(q.texture) == lo {
tmp[w] = q
w += 1
}
}
for q in window {
if uintptr(q.texture) == hi {
tmp[w] = q
w += 1
}
}
copy(window, tmp[:w])
}
+63
View File
@@ -190,6 +190,51 @@ group_texture_runs_already_optimal :: proc(t: ^testing.T) {
testing.expect_value(t, marker_of(list[3]), f32(40))
}
@(test)
group_texture_runs_alternating_many_stable :: proc(t: ^testing.T) {
// Characterization: large alternating group must collapse to two runs
// while preserving same-texture submission order (markers).
N :: 64
list := make([]Queued_Sprite, N)
defer delete(list)
for i in 0 ..< N {
tex: uintptr = 2 if (i % 2) == 0 else 1
list[i] = queued(tex, 1, f32(i + 1))
}
testing.expect_value(t, texture_run_count(list), N)
group_texture_runs(list)
testing.expect_value(t, texture_run_count(list), 2)
testing.expect(t, list[0].texture == fake_tex(1))
testing.expect(t, list[N / 2 - 1].texture == fake_tex(1))
testing.expect(t, list[N / 2].texture == fake_tex(2))
testing.expect(t, list[N - 1].texture == fake_tex(2))
for i in 0 ..< N / 2 {
testing.expect_value(t, marker_of(list[i]), f32(2 * i + 2)) // odd markers: 2,4,...,N
testing.expect_value(t, marker_of(list[N / 2 + i]), f32(2 * i + 1)) // even markers: 1,3,...,N-1
}
}
@(test)
group_texture_runs_three_textures_stable :: proc(t: ^testing.T) {
list := []Queued_Sprite {
queued(3, 1, 1),
queued(1, 1, 2),
queued(2, 1, 3),
queued(3, 1, 4),
queued(1, 1, 5),
queued(2, 1, 6),
}
testing.expect_value(t, texture_run_count(list), 6)
group_texture_runs(list)
testing.expect_value(t, texture_run_count(list), 3)
testing.expect_value(t, marker_of(list[0]), f32(2))
testing.expect_value(t, marker_of(list[1]), f32(5))
testing.expect_value(t, marker_of(list[2]), f32(3))
testing.expect_value(t, marker_of(list[3]), f32(6))
testing.expect_value(t, marker_of(list[4]), f32(1))
testing.expect_value(t, marker_of(list[5]), f32(4))
}
@(test)
group_texture_runs_noncontiguous_same_group_id :: proc(t: ^testing.T) {
// Same nonzero id split by group 0: each window regroups alone.
@@ -280,6 +325,24 @@ draw_sprite_stamps_batch_group_zero :: proc(t: ^testing.T) {
testing.expect(t, app.draw_list[0].texture == data.texture)
}
@(test)
draw_sprite_at_max_sprites_does_not_append :: proc(t: ^testing.T) {
app := make_test_draw_app()
defer destroy_test_draw_app(&app)
data := make_test_draw_character()
defer destroy_test_draw_character(&data)
for _ in 0 ..< MAX_SPRITES {
append(&app.draw_list, Queued_Sprite{texture = data.texture})
}
testing.expect_value(t, len(app.draw_list), MAX_SPRITES)
sprite := spawn_sprite(&data, {100, 200}, "idle", 0)
draw_sprite(&app, &sprite)
testing.expect_value(t, len(app.draw_list), MAX_SPRITES)
}
@(test)
draw_sprite_batched_stamps_batch_group :: proc(t: ^testing.T) {
app := make_test_draw_app()
+9
View File
@@ -27,6 +27,15 @@ choose_shader_runtime_prefers_msl :: proc(t: ^testing.T) {
testing.expect_value(t, rt.format, sdl.GPUShaderFormat{.MSL})
}
@(test)
choose_shader_runtime_prefers_dxil_without_msl :: proc(t: ^testing.T) {
rt, ok := choose_shader_runtime_from_formats({.DXIL, .SPIRV})
testing.expect(t, ok, "should pick a runtime when DXIL is available")
testing.expect_value(t, rt.backend, Shader_Backend.DSD12_DXIL)
testing.expect_value(t, rt.shader_dir, "shaders/d3d12")
testing.expect_value(t, rt.format, sdl.GPUShaderFormat{.DXIL})
}
@(test)
choose_shader_runtime_spirv_only :: proc(t: ^testing.T) {
rt, ok := choose_shader_runtime_from_formats({.SPIRV})
+37 -23
View File
@@ -5,12 +5,14 @@ import sdl "vendor:sdl3"
Vec2 :: [2]f32
Sprite :: struct {
data: ^Character_Data,
position: Vec2,
clip: string,
frame: int,
time: f32,
flip_x: bool,
data: ^Character_Data,
position: Vec2,
clip: string,
clip_def: Clip_Def,
has_clip: bool,
frame: int,
time: f32,
flip_x: bool,
}
spawn_sprite :: proc(
@@ -24,16 +26,14 @@ spawn_sprite :: proc(
position = position,
}
set_sprite_clip(&sprite, clip)
if frame != 0 {
c, ok := character_clip(sprite.data, sprite.clip)
if ok {
if frame < 0 {
sprite.frame = 0
} else if frame >= len(c.frames) {
sprite.frame = len(c.frames) - 1
} else {
sprite.frame = frame
}
if frame != 0 && sprite.has_clip {
c := sprite.clip_def
if frame < 0 {
sprite.frame = 0
} else if frame >= len(c.frames) {
sprite.frame = len(c.frames) - 1
} else {
sprite.frame = frame
}
}
return sprite
@@ -42,9 +42,9 @@ spawn_sprite :: proc(
update_sprite :: proc(sprite: ^Sprite, dt: f32) {
if sprite == nil || sprite.data == nil do return
if dt <= 0 do return
if !sprite.has_clip do return
clip, ok := character_clip(sprite.data, sprite.clip)
if !ok do return
clip := sprite.clip_def
frame_count := len(clip.frames)
if frame_count <= 0 do return
@@ -116,12 +116,13 @@ draw_sprite_batched :: proc(app: ^App, sprite: ^Sprite, batch_group: u32) {
if len(app.draw_list) >= MAX_SPRITES {
return
}
frame, ok := character_frame(sprite.data, sprite.clip, sprite.frame)
if !ok {
if !sprite.has_clip do return
if sprite.frame < 0 || sprite.frame >= len(sprite.clip_def.frames) {
return
}
frame := sprite.clip_def.frames[sprite.frame]
src_w := f32(frame.source_size[0])
src_h := f32(frame.source_size[1])
if src_w <= 0 do src_w = f32(frame.rect[2])
@@ -177,12 +178,25 @@ draw_sprite_batched :: proc(app: ^App, sprite: ^Sprite, batch_group: u32) {
set_sprite_clip :: proc(sprite: ^Sprite, clip: string) {
if sprite == nil || sprite.data == nil do return
if sprite.clip == clip do return
if sprite.clip == clip && sprite.has_clip do return
_, ok := character_clip(sprite.data, clip)
def, ok := character_clip(sprite.data, clip)
if !ok do return
set_sprite_clip_def(sprite, clip, def)
}
// Applies a pre-resolved clip without looking up the character clip map.
// Use when callers already hold Clip_Def (e.g. thrashing between known clips).
set_sprite_clip_def :: proc(sprite: ^Sprite, clip: string, def: Clip_Def) {
if sprite == nil do return
if len(def.frames) == 0 do return
if sprite.clip == clip && sprite.has_clip do return
sprite.clip = clip
sprite.clip_def = def
sprite.has_clip = true
sprite.frame = 0
sprite.time = 0
}
+80
View File
@@ -0,0 +1,80 @@
package main
import "core:fmt"
import eng "pkg:engine"
// Clip thrash: flip every sprite between idle/walk each frame via set_sprite_clip_def.
COUNT :: eng.MAX_SPRITES
COLS :: 16
FRAME_LOG_EVERY :: 60
main :: proc() {
app: eng.App
if !eng.init(&app, "clip_thrash", 800, 600) do return
defer eng.shutdown(&app)
data, ok := eng.load_character_data(&app, "assets_baked/characters/toad/toad.char.json")
if !ok do return
defer eng.destroy_character_data(&app, &data)
idle_def, idle_ok := eng.character_clip(&data, "idle")
walk_def, walk_ok := eng.character_clip(&data, "walk")
if !idle_ok || !walk_ok do return
sprites: [COUNT]eng.Sprite
for i in 0 ..< COUNT {
col := i % COLS
row := i / COLS
pos := eng.Vec2 {
f32(40 + col * 48),
f32(80 + row * 60),
}
sprites[i] = eng.spawn_sprite(&data, pos, "idle", i % 5)
}
app.camera.position = {400, 400}
last := eng.now_seconds()
frame_i := 0
sum_ms: f64
peak_ms: f64
use_walk := false
for eng.events() {
now := eng.now_seconds()
dt := f32(now - last)
last = now
frame_ms := f64(dt) * 1000.0
sum_ms += frame_ms
if frame_ms > peak_ms do peak_ms = frame_ms
frame_i += 1
if frame_i % FRAME_LOG_EVERY == 0 {
avg := sum_ms / f64(FRAME_LOG_EVERY)
fps := 1000.0 / avg if avg > 0 else 0
fmt.printfln(
"clip_thrash frame: avg=%.2f ms (%.1f FPS) peak=%.2f ms over %d frames",
avg,
fps,
peak_ms,
FRAME_LOG_EVERY,
)
sum_ms = 0
peak_ms = 0
}
clip := "walk" if use_walk else "idle"
def := walk_def if use_walk else idle_def
use_walk = !use_walk
for &s in sprites {
eng.set_sprite_clip_def(&s, clip, def)
eng.update_sprite(&s, dt)
}
eng.begin_frame(&app)
for &s in sprites {
eng.draw_sprite(&app, &s)
}
eng.end_frame(&app)
}
}
+29 -6
View File
@@ -1,9 +1,12 @@
package main
import "core:fmt"
import eng "pkg:engine"
// Many sprites sharing one Character_Data (Flyweight) — good batching demo.
COUNT :: 24
COUNT :: eng.MAX_SPRITES
COLS :: 16
FRAME_LOG_EVERY :: 60
main :: proc() {
app: eng.App
@@ -16,25 +19,45 @@ main :: proc() {
sprites: [COUNT]eng.Sprite
for i in 0 ..< COUNT {
col := i % 8
row := i / 8
col := i % COLS
row := i / COLS
pos := eng.Vec2 {
f32(120 + col * 80),
f32(280 + row * 120),
f32(40 + col * 48),
f32(80 + row * 60),
}
clip := "idle" if (i % 2) == 0 else "walk"
sprites[i] = eng.spawn_sprite(&data, pos, clip, i % 5)
}
// Look at the middle of the grid
app.camera.position = {400, 400}
last := eng.now_seconds()
frame_i := 0
sum_ms: f64
peak_ms: f64
for eng.events() {
now := eng.now_seconds()
dt := f32(now - last)
last = now
frame_ms := f64(dt) * 1000.0
sum_ms += frame_ms
if frame_ms > peak_ms do peak_ms = frame_ms
frame_i += 1
if frame_i % FRAME_LOG_EVERY == 0 {
avg := sum_ms / f64(FRAME_LOG_EVERY)
fps := 1000.0 / avg if avg > 0 else 0
fmt.printfln(
"crowd frame: avg=%.2f ms (%.1f FPS) peak=%.2f ms over %d frames",
avg,
fps,
peak_ms,
FRAME_LOG_EVERY,
)
sum_ms = 0
peak_ms = 0
}
for &s in sprites {
eng.update_sprite(&s, dt)
+79
View File
@@ -0,0 +1,79 @@
package main
import "core:fmt"
import eng "pkg:engine"
// Multi-texture batching stress: two Character_Data (two GPU textures), alternating sprites.
COUNT :: eng.MAX_SPRITES
COLS :: 16
FRAME_LOG_EVERY :: 60
BATCH_GROUP :: u32(1)
TOAD_JSON :: "assets_baked/characters/toad/toad.char.json"
main :: proc() {
app: eng.App
if !eng.init(&app, "crowd_batch", 800, 600) do return
defer eng.shutdown(&app)
data_a, ok_a := eng.load_character_data(&app, TOAD_JSON)
if !ok_a do return
defer eng.destroy_character_data(&app, &data_a)
data_b, ok_b := eng.load_character_data(&app, TOAD_JSON)
if !ok_b do return
defer eng.destroy_character_data(&app, &data_b)
sprites: [COUNT]eng.Sprite
for i in 0 ..< COUNT {
col := i % COLS
row := i / COLS
pos := eng.Vec2 {
f32(40 + col * 48),
f32(80 + row * 60),
}
clip := "idle" if (i % 2) == 0 else "walk"
data := &data_a if (i % 2) == 0 else &data_b
sprites[i] = eng.spawn_sprite(data, pos, clip, i % 5)
}
app.camera.position = {400, 400}
last := eng.now_seconds()
frame_i := 0
sum_ms: f64
peak_ms: f64
for eng.events() {
now := eng.now_seconds()
dt := f32(now - last)
last = now
frame_ms := f64(dt) * 1000.0
sum_ms += frame_ms
if frame_ms > peak_ms do peak_ms = frame_ms
frame_i += 1
if frame_i % FRAME_LOG_EVERY == 0 {
avg := sum_ms / f64(FRAME_LOG_EVERY)
fps := 1000.0 / avg if avg > 0 else 0
fmt.printfln(
"crowd_batch frame: avg=%.2f ms (%.1f FPS) peak=%.2f ms over %d frames",
avg,
fps,
peak_ms,
FRAME_LOG_EVERY,
)
sum_ms = 0
peak_ms = 0
}
for &s in sprites {
eng.update_sprite(&s, dt)
}
eng.begin_frame(&app)
for &s in sprites {
eng.draw_sprite_batched(&app, &s, BATCH_GROUP)
}
eng.end_frame(&app)
}
}
+70
View File
@@ -0,0 +1,70 @@
package main
import "core:fmt"
import eng "pkg:engine"
// GPU overdraw stress: MAX_SPRITES stacked near one world point.
COUNT :: eng.MAX_SPRITES
FRAME_LOG_EVERY :: 60
main :: proc() {
app: eng.App
if !eng.init(&app, "crowd_overdraw", 800, 600) do return
defer eng.shutdown(&app)
data, ok := eng.load_character_data(&app, "assets_baked/characters/toad/toad.char.json")
if !ok do return
defer eng.destroy_character_data(&app, &data)
center := eng.Vec2{400, 400}
sprites: [COUNT]eng.Sprite
for i in 0 ..< COUNT {
jitter := eng.Vec2 {
f32((i % 7) - 3),
f32((i % 5) - 2),
}
clip := "idle" if (i % 2) == 0 else "walk"
sprites[i] = eng.spawn_sprite(&data, center + jitter, clip, i % 5)
}
app.camera.position = {400, 400}
last := eng.now_seconds()
frame_i := 0
sum_ms: f64
peak_ms: f64
for eng.events() {
now := eng.now_seconds()
dt := f32(now - last)
last = now
frame_ms := f64(dt) * 1000.0
sum_ms += frame_ms
if frame_ms > peak_ms do peak_ms = frame_ms
frame_i += 1
if frame_i % FRAME_LOG_EVERY == 0 {
avg := sum_ms / f64(FRAME_LOG_EVERY)
fps := 1000.0 / avg if avg > 0 else 0
fmt.printfln(
"crowd_overdraw frame: avg=%.2f ms (%.1f FPS) peak=%.2f ms over %d frames",
avg,
fps,
peak_ms,
FRAME_LOG_EVERY,
)
sum_ms = 0
peak_ms = 0
}
for &s in sprites {
eng.update_sprite(&s, dt)
}
eng.begin_frame(&app)
for &s in sprites {
eng.draw_sprite(&app, &s)
}
eng.end_frame(&app)
}
}