H1: make bench, render budgets, and a third of the figure draw calls
make bench (tools/bench.sh, tools/bench_report.gd) measures the server's p50/p99/max tick with 24 bots on three seeds over a whole match, and the client's draw calls, primitives, objects, nodes and memory at six moments of a match rendered in the capture container. It fails on anything over the budgets now recorded in docs/ARCHITECTURE.md: p99 tick 12 ms, 2,000 draw calls and 2,000,000 primitives per frame (all passes), 1 GiB video and 512 MiB static memory. Every capture now reports its frame's render counts in a "render" field. The first run put the barge, with 24 figures together, at 2,197 draw calls. Each figure part had one surface per colour (about 43 per figure, drawn again for shadows). FigureRig now merges a part's surfaces into one per finish (coat, gilt, plain) and carries the Palette colours as vertex colours, with shared materials. The barge is down to 1,207 draw calls, with the same triangles and the same look. Frame rates on a real GPU are not measured here; that stays with R6. Closes #54 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ continuity.
|
||||
| `tools/capture.sh canopy captures/canopy.png` | H11: the shoulder camera on a player against a pine, with canopies in the way hidden (`canopy_before` puts them back). |
|
||||
| `make style-captures` | Renders a hamlet and a dock with and without the woodcut print pass (`captures/style_*.png`). Needs Docker. |
|
||||
| `make soak` | The 24-client network soak (N8): a real server and 24 headless `SoakPlayer` clients in three processes, each behind a `UdpRelay` adding 60 ms, +/-20 ms jitter and 2% loss each way, for two whole matches in real time (about 30 min, under `nice`). Fails on a world-hash mismatch, errors, unreadable packets, a client that didn't play every match, memory growth between matches, or a p99 tick over budget. `SOAK_MATCHES`, `SOAK_CLIENTS`, `SOAK_PROCS`, `SOAK_LATENCY`, `SOAK_JITTER`, `SOAK_LOSS` scale it. Results in `build/soak/report.txt`. |
|
||||
| `make bench` | H1: the server's p50/p99/max tick with 24 bots on three seeds, and the client's draw calls, triangles, objects and memory at six moments of a match (about 3 min, needs Docker). Fails on anything over the budgets in docs/ARCHITECTURE.md. Report in `build/bench/report.txt`. `BENCH_SEEDS`, `BENCH_TICKS`, `BENCH_CLIENT=0` scale it. |
|
||||
| `make soak-selfcheck` | About a minute: tampers with one client's world and checks the soak's comparison catches it and only it. |
|
||||
| `make server-package-check` | Builds the server image with `packaging/docker/compose.yaml`, waits for it to be healthy, checks it is non-root and read-only, joins it with a headless client and stops it with SIGTERM (N7, about 1.5 min). Needs Docker. See `packaging/README.md`. |
|
||||
| `make models` | Rebuilds every item model (`assets/models/items/*.obj`, with grip data in `.json`) and icon (`assets/icons/items/*.png`) from `tools/models/items.py` in headless Blender on the CPU. Materials are named after `Palette` colours; `ItemModels` paints them. |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Tidewall build entry points. Everything runs headless with the repo-local engine.
|
||||
GODOT := tools/godot.sh
|
||||
|
||||
.PHONY: build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check
|
||||
.PHONY: bench build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check
|
||||
|
||||
## A8: regenerates every sound in assets/audio/ from tools/audio/ (about 6 s).
|
||||
audio: import
|
||||
@@ -41,6 +41,11 @@ sea-captures: import
|
||||
item-captures: import
|
||||
@for stage in held shoulder ground tiers; do tools/capture.sh items_$$stage captures/items_$$stage.png; done
|
||||
|
||||
## H1: server tick times and client draw calls, triangles and memory against the budgets
|
||||
## in docs/ARCHITECTURE.md (about 3 minutes; the client half needs Docker).
|
||||
bench: import
|
||||
@tools/bench.sh
|
||||
|
||||
## Everything that must pass before a push.
|
||||
check: verify-engine binaries parse test test-selfcheck smoke
|
||||
|
||||
|
||||
+23
-1
@@ -518,8 +518,30 @@ client is connecting, in the lobby or watching.
|
||||
| Server tick | Under **12 ms** with 24 players, including the network's share (`make soak` checks the p99) |
|
||||
| Client | **60 fps** on a GTX 1060-class GPU at medium settings |
|
||||
| Terrain streaming | Under **8 ms** of main-thread work in any frame (measured headless; GPU upload unmeasured) |
|
||||
| Client draw calls | At most **2,000** per frame, every pass counted (shadows included) |
|
||||
| Client primitives | At most **2,000,000** triangles per frame, every pass counted |
|
||||
| Client memory | At most **1 GiB** of video memory and **512 MiB** of the engine's static memory |
|
||||
|
||||
Software rendering in CI can't verify the client budget. It needs a real GPU playtest.
|
||||
Software rendering in CI can't verify the frame-rate budget. It needs a real GPU playtest
|
||||
(R6). What it can count is what a frame asks the GPU to do, so the draw-call, triangle
|
||||
and memory budgets stand in for it until then. They are set for the GTX 1060 class with
|
||||
room left for effects and the HUD.
|
||||
|
||||
`make bench` (`tools/bench.sh`, H1) measures both sides and fails when a number is over
|
||||
budget:
|
||||
|
||||
- **Server:** the headless server with 24 bots, unthrottled, for 12,000 ticks (a whole
|
||||
match and the start of the next) on three seeds, reporting p50, p99 and max tick time.
|
||||
The max includes one long tick per match: unthrottled, the 15 s results screen passes
|
||||
in a fraction of a second, so the main thread waits for the worker still building the
|
||||
next island. At the real 30 Hz the worker finishes long before the lobby opens.
|
||||
- **Client:** the match `make match` saved, rendered at the whole island, the barge (24
|
||||
figures together, the worst case for draw calls), landed, a build and the final
|
||||
players, and a crowded pine forest. Each capture reports its frame's draw calls,
|
||||
primitives, objects, nodes and memory (`tools/capture.gd`'s `render` field).
|
||||
|
||||
Results go to `build/bench/report.txt` and `report.json`. The numbers from each pass are
|
||||
in the DEVLOG.
|
||||
|
||||
## Soak testing
|
||||
|
||||
|
||||
@@ -66,8 +66,15 @@ const SPEED_FOLLOW: float = 10.0
|
||||
## How much of the look's pitch the chest takes; the held item takes all of it.
|
||||
const SPINE_PITCH: float = 0.35
|
||||
|
||||
## A part's surfaces, by how they're lit (see _merged()).
|
||||
const FINISH_COAT: String = "FINISH_COAT"
|
||||
const FINISH_GILT: String = "FINISH_GILT"
|
||||
const FINISH_PLAIN: String = "FINISH_PLAIN"
|
||||
const FINISHES: Array[String] = [FINISH_COAT, FINISH_GILT, FINISH_PLAIN]
|
||||
|
||||
static var _layout: Dictionary = {}
|
||||
static var _meshes: Dictionary = {}
|
||||
static var _finishes: Dictionary = {}
|
||||
static var _library: AnimationLibrary = null
|
||||
|
||||
var coat: Color = Palette.OILSKIN
|
||||
@@ -148,23 +155,73 @@ static func part_mesh(part: String, coat_colour: Color) -> ArrayMesh:
|
||||
if ResourceLoader.exists(path):
|
||||
var source: Mesh = load(path) as Mesh
|
||||
if source != null:
|
||||
made = ArrayMesh.new()
|
||||
for surface: int in source.get_surface_count():
|
||||
var material: Material = source.surface_get_material(surface)
|
||||
var name: String = material.resource_name if material != null else ""
|
||||
made.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, source.surface_get_arrays(surface))
|
||||
var paint: StandardMaterial3D = StandardMaterial3D.new()
|
||||
paint.albedo_color = colour_of(name, coat_colour)
|
||||
paint.roughness = 0.6 if name.begins_with("COAT") else 0.88
|
||||
if name == "GILT":
|
||||
paint.metallic = 0.35
|
||||
made.surface_set_material(made.get_surface_count() - 1, paint)
|
||||
made.surface_set_name(made.get_surface_count() - 1, name)
|
||||
made = _merged(source, coat_colour)
|
||||
made.resource_name = key
|
||||
_meshes[key] = made
|
||||
return made
|
||||
|
||||
|
||||
## H1: one surface per finish instead of one per colour, with each Palette colour
|
||||
## carried as a vertex colour. The model's surfaces are separate draw calls in every
|
||||
## pass, and 24 figures crowded on the barge passed the draw-call budget; merged, a
|
||||
## figure costs a third of the draws and looks the same. Each surface is named after
|
||||
## its finish: FINISH_COAT, FINISH_GILT or FINISH_PLAIN.
|
||||
static func _merged(source: Mesh, coat_colour: Color) -> ArrayMesh:
|
||||
var tools: Dictionary = {}
|
||||
for surface: int in source.get_surface_count():
|
||||
var material: Material = source.surface_get_material(surface)
|
||||
var name: String = material.resource_name if material != null else ""
|
||||
var finish: String = finish_of(name)
|
||||
if not tools.has(finish):
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
tools[finish] = tool
|
||||
var arrays: Array = source.surface_get_arrays(surface)
|
||||
var count: int = (arrays[Mesh.ARRAY_VERTEX] as PackedVector3Array).size()
|
||||
var colours: PackedColorArray = PackedColorArray()
|
||||
colours.resize(count)
|
||||
colours.fill(colour_of(name, coat_colour))
|
||||
arrays[Mesh.ARRAY_COLOR] = colours
|
||||
(tools[finish] as SurfaceTool).append_from(_array_mesh(arrays), 0, Transform3D.IDENTITY)
|
||||
var made: ArrayMesh = ArrayMesh.new()
|
||||
for finish: String in FINISHES:
|
||||
if not tools.has(finish):
|
||||
continue
|
||||
(tools[finish] as SurfaceTool).commit(made)
|
||||
made.surface_set_material(made.get_surface_count() - 1, finish_material(finish))
|
||||
made.surface_set_name(made.get_surface_count() - 1, finish)
|
||||
return made
|
||||
|
||||
|
||||
static func _array_mesh(arrays: Array) -> ArrayMesh:
|
||||
var mesh: ArrayMesh = ArrayMesh.new()
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
|
||||
return mesh
|
||||
|
||||
|
||||
## How a model material is lit: oilskin coat, gilt, or everything else.
|
||||
static func finish_of(material_name: String) -> String:
|
||||
if material_name.begins_with("COAT"):
|
||||
return FINISH_COAT
|
||||
if material_name == "GILT":
|
||||
return FINISH_GILT
|
||||
return FINISH_PLAIN
|
||||
|
||||
|
||||
## The shared material for a finish; the colour comes from the vertices.
|
||||
static func finish_material(finish: String) -> StandardMaterial3D:
|
||||
if not _finishes.has(finish):
|
||||
var paint: StandardMaterial3D = StandardMaterial3D.new()
|
||||
paint.vertex_color_use_as_albedo = true
|
||||
paint.vertex_color_is_srgb = true
|
||||
paint.roughness = 0.6 if finish == FINISH_COAT else 0.88
|
||||
if finish == FINISH_GILT:
|
||||
paint.metallic = 0.35
|
||||
paint.resource_name = finish
|
||||
_finishes[finish] = paint
|
||||
return _finishes[finish]
|
||||
|
||||
|
||||
## The Palette colour of a part's material, with COAT the player's own.
|
||||
static func colour_of(material_name: String, coat_colour: Color) -> Color:
|
||||
if material_name == "COAT":
|
||||
@@ -186,6 +243,7 @@ static func library() -> AnimationLibrary:
|
||||
|
||||
static func clear() -> void:
|
||||
_meshes.clear()
|
||||
_finishes.clear()
|
||||
_layout.clear()
|
||||
_library = null
|
||||
|
||||
|
||||
@@ -34,9 +34,32 @@ func test_every_part_is_built_from_the_generated_models() -> void:
|
||||
assert_not_null(mesh, "%s has a model" % part)
|
||||
if mesh == null:
|
||||
continue
|
||||
for surface: int in mesh.get_surface_count():
|
||||
var name: String = mesh.surface_get_name(surface)
|
||||
var source: Mesh = load("%s/%s.obj" % [FigureRig.MODEL_DIR, part]) as Mesh
|
||||
var wanted: Dictionary = {}
|
||||
var finishes: Dictionary = {}
|
||||
for surface: int in source.get_surface_count():
|
||||
var name: String = source.surface_get_material(surface).resource_name
|
||||
assert_true(name.begins_with("COAT") or FigureRig.COLOURS.has(name), "%s's %s is a Palette colour" % [part, name])
|
||||
wanted[FigureRig.colour_of(name, Palette.OILSKIN)] = true
|
||||
finishes[FigureRig.finish_of(name)] = true
|
||||
# H1: merged to one surface per finish, the colours carried by the vertices.
|
||||
assert_eq(mesh.get_surface_count(), finishes.size(), "%s has one surface per finish" % part)
|
||||
var seen: Dictionary = {}
|
||||
for surface: int in mesh.get_surface_count():
|
||||
assert_true(FigureRig.FINISHES.has(mesh.surface_get_name(surface)))
|
||||
var paint: StandardMaterial3D = mesh.surface_get_material(surface) as StandardMaterial3D
|
||||
assert_true(paint.vertex_color_use_as_albedo and paint.vertex_color_is_srgb, "%s is painted by its vertices" % part)
|
||||
var arrays: Array = mesh.surface_get_arrays(surface)
|
||||
for colour: Color in arrays[Mesh.ARRAY_COLOR] as PackedColorArray:
|
||||
seen[colour.to_html()] = colour
|
||||
# Vertex colours are stored with less precision than a Color.
|
||||
assert_eq(seen.size(), wanted.size(), "%s keeps every colour" % part)
|
||||
for colour: Color in wanted:
|
||||
var found: bool = false
|
||||
for kept: Color in seen.values():
|
||||
found = found or (absf(kept.r - colour.r) < 0.01 and absf(kept.g - colour.g) < 0.01 and absf(kept.b - colour.b) < 0.01)
|
||||
assert_true(found, "%s still has colour %s" % [part, colour.to_html()])
|
||||
assert_eq(mesh.get_faces().size(), source.get_faces().size(), "%s keeps every triangle" % part)
|
||||
assert_eq(FigureRig.colour_of("COAT", Palette.SEA_PAINT), Palette.SEA_PAINT, "the coat is the player's own")
|
||||
assert_eq(FigureRig.colour_of("SKIN", Palette.SEA_PAINT), Palette.SKIN)
|
||||
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# H1: repeatable performance benchmark.
|
||||
#
|
||||
# Server: runs the headless server with 24 bots, unthrottled, for BENCH_TICKS ticks on
|
||||
# each of BENCH_SEEDS seeds, and reads its p50/p99/max tick time.
|
||||
# Client: renders the moments of the match `make match` saved (whole island, barge,
|
||||
# landed, a build, the final players) and a crowded pine forest in the capture
|
||||
# container, and reads each frame's draw calls, primitives, objects and memory.
|
||||
#
|
||||
# tools/bench_report.gd checks every number against the budgets in
|
||||
# docs/ARCHITECTURE.md and writes build/bench/report.txt and report.json.
|
||||
#
|
||||
# Software rendering counts what is drawn, not how fast: frame rates on a real GPU are
|
||||
# left to the hands-on playtest (R6).
|
||||
#
|
||||
# tools/bench.sh about 3 minutes; needs Docker for the client
|
||||
# BENCH_SEEDS="2 7" BENCH_TICKS=6000 tools/bench.sh
|
||||
# BENCH_CLIENT=0 tools/bench.sh the server only
|
||||
set -uo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
seeds="${BENCH_SEEDS:-2 7 20261109}"
|
||||
ticks="${BENCH_TICKS:-12000}"
|
||||
client="${BENCH_CLIENT:-1}"
|
||||
[[ "$ticks" =~ ^[0-9]+$ ]] || { echo "bench FAIL: bad BENCH_TICKS '$ticks'"; exit 2; }
|
||||
out="build/bench"
|
||||
mkdir -p "$out"
|
||||
rm -f "$out"/*.jsonl
|
||||
status=0
|
||||
|
||||
for seed in $seeds; do
|
||||
[[ "$seed" =~ ^[0-9]+$ ]] || { echo "bench FAIL: bad seed '$seed'"; exit 2; }
|
||||
echo "bench: server, seed $seed, $ticks ticks, 24 bots" >&2
|
||||
raw="$(timeout --signal=KILL 900 nice -n 15 tools/godot.sh -- --server --seed="$seed" --bots=24 --ticks="$ticks" --unthrottled 2>&1)"
|
||||
code=$?
|
||||
line="$(grep -m1 '"event":"stats"' <<<"$raw" || true)"
|
||||
if [[ "$code" -ne 0 || -z "$line" ]]; then
|
||||
echo "bench FAIL: the server on seed $seed exited $code"
|
||||
grep -v '^{' <<<"$raw" | tail -n 10
|
||||
status=1
|
||||
continue
|
||||
fi
|
||||
echo "$line" >>"$out/server.jsonl"
|
||||
done
|
||||
|
||||
if [[ "$client" == "1" ]]; then
|
||||
if [[ ! -f build/match/match.tclog ]]; then
|
||||
echo "bench: no saved match yet; playing one (make match)" >&2
|
||||
tools/match.sh >/dev/null || { echo "bench FAIL: make match failed"; exit 1; }
|
||||
fi
|
||||
for stage in match_lobby match_barge match_landed match_built match_final props_forest; do
|
||||
echo "bench: client, $stage" >&2
|
||||
if ! report="$(tools/capture.sh "$stage" "captures/bench_$stage.png" 2>/dev/null)"; then
|
||||
echo "bench FAIL: the $stage capture failed"
|
||||
status=1
|
||||
continue
|
||||
fi
|
||||
echo "$report" | grep -m1 '^{' >>"$out/client.jsonl"
|
||||
done
|
||||
fi
|
||||
|
||||
tools/godot.sh --script res://tools/bench_report.gd -- --dir="res://$out" --client="$client" || status=1
|
||||
exit "$status"
|
||||
@@ -0,0 +1,130 @@
|
||||
## H1: reads what tools/bench.sh measured, checks it against the performance budgets in
|
||||
## docs/ARCHITECTURE.md, and writes report.txt and report.json beside the logs.
|
||||
##
|
||||
## tools/godot.sh --script res://tools/bench_report.gd -- --dir=res://build/bench [--client=0]
|
||||
##
|
||||
## Exits 0 when everything is within budget, 1 when something isn't or nothing was
|
||||
## measured, 2 on a bad command line.
|
||||
extends SceneTree
|
||||
|
||||
## Server: the 99th percentile simulation tick, with 24 players (ServerLoop's budget).
|
||||
const SERVER_P99_USEC: int = ServerLoop.TICK_BUDGET_USEC
|
||||
## Client, per frame, every pass counted (shadows included). Set for a mid-range desktop
|
||||
## GPU from 2018 on, with room left for effects and the HUD.
|
||||
const CLIENT_DRAW_CALLS: int = 2000
|
||||
const CLIENT_PRIMITIVES: int = 2_000_000
|
||||
## Video memory the renderer reports using: fits a 2 GB card with room to spare.
|
||||
const CLIENT_VIDEO_MEM_BYTES: int = 1024 * 1024 * 1024
|
||||
## The engine's own static memory on the CPU side.
|
||||
const CLIENT_STATIC_MEM_BYTES: int = 512 * 1024 * 1024
|
||||
|
||||
var _failures: Array[String] = []
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var dir: String = ""
|
||||
var want_client: bool = true
|
||||
for arg: String in OS.get_cmdline_user_args():
|
||||
if arg.begins_with("--dir="):
|
||||
dir = arg.trim_prefix("--dir=")
|
||||
elif arg.begins_with("--client="):
|
||||
want_client = arg.trim_prefix("--client=") != "0"
|
||||
else:
|
||||
printerr("bench_report: unknown argument '%s'" % arg)
|
||||
quit(2)
|
||||
return
|
||||
if dir.is_empty():
|
||||
printerr("bench_report: --dir is needed")
|
||||
quit(2)
|
||||
return
|
||||
var result: Dictionary = check(_read(dir.path_join("server.jsonl")), _read(dir.path_join("client.jsonl")), want_client)
|
||||
var text: String = describe(result)
|
||||
for failure: String in _failures:
|
||||
text += "bench FAIL: %s\n" % failure
|
||||
if _failures.is_empty():
|
||||
text += "bench: ok (everything within budget)\n"
|
||||
print(text.strip_edges())
|
||||
_write(dir.path_join("report.txt"), text)
|
||||
result["failures"] = _failures
|
||||
_write(dir.path_join("report.json"), JSON.stringify(result, "\t") + "\n")
|
||||
quit(0 if _failures.is_empty() else 1)
|
||||
|
||||
|
||||
## Checks parsed server "stats" lines and client capture reports. Returns the
|
||||
## measurements; failures go in `_failures`.
|
||||
func check(server: Array[Dictionary], client: Array[Dictionary], want_client: bool) -> Dictionary:
|
||||
var result: Dictionary = {"server": [], "client": []}
|
||||
if server.is_empty():
|
||||
_fail("no server runs were measured")
|
||||
for stats: Dictionary in server:
|
||||
var row: Dictionary = {
|
||||
"seed": int(stats.get("seed", -1)), "ticks": int(stats.get("ticks", 0)),
|
||||
"p50_us": int(stats.get("p50_us", -1)), "p99_us": int(stats.get("p99_us", -1)),
|
||||
"max_us": int(stats.get("max_us", -1)), "over_budget": int(stats.get("over_budget", 0)),
|
||||
}
|
||||
(result["server"] as Array).append(row)
|
||||
if row["p99_us"] < 0 or row["p99_us"] > SERVER_P99_USEC:
|
||||
_fail("server seed %d: p99 tick %d us is over the %d us budget" % [row["seed"], row["p99_us"], SERVER_P99_USEC])
|
||||
if want_client and client.is_empty():
|
||||
_fail("no client frames were measured")
|
||||
for capture: Dictionary in client:
|
||||
var render: Dictionary = capture.get("render", {})
|
||||
var row: Dictionary = {"scene": String(capture.get("scene", "?")).get_file().get_basename()}
|
||||
for key: String in ["draw_calls", "primitives", "objects", "visible_draw_calls", "visible_primitives", "shadow_draw_calls", "video_mem_bytes", "static_mem_bytes", "nodes"]:
|
||||
row[key] = int(render.get(key, -1))
|
||||
(result["client"] as Array).append(row)
|
||||
_limit(row, "draw_calls", CLIENT_DRAW_CALLS)
|
||||
_limit(row, "primitives", CLIENT_PRIMITIVES)
|
||||
_limit(row, "video_mem_bytes", CLIENT_VIDEO_MEM_BYTES)
|
||||
_limit(row, "static_mem_bytes", CLIENT_STATIC_MEM_BYTES)
|
||||
result["budgets"] = {
|
||||
"server_p99_us": SERVER_P99_USEC, "draw_calls": CLIENT_DRAW_CALLS, "primitives": CLIENT_PRIMITIVES,
|
||||
"video_mem_bytes": CLIENT_VIDEO_MEM_BYTES, "static_mem_bytes": CLIENT_STATIC_MEM_BYTES,
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
## The measurements as a plain table.
|
||||
func describe(result: Dictionary) -> String:
|
||||
var text: String = "Server (24 bots, unthrottled; budget p99 %d us)\n" % SERVER_P99_USEC
|
||||
text += " %-10s %7s %8s %8s %8s %6s\n" % ["seed", "ticks", "p50 us", "p99 us", "max us", "over"]
|
||||
for row: Dictionary in result["server"]:
|
||||
text += " %-10d %7d %8d %8d %8d %6d\n" % [row["seed"], row["ticks"], row["p50_us"], row["p99_us"], row["max_us"], row["over_budget"]]
|
||||
if not (result["client"] as Array).is_empty():
|
||||
text += "Client frame (software rendering: counts, not speed; budgets %d draw calls, %d primitives, %d MiB video, %d MiB static)\n" % [
|
||||
CLIENT_DRAW_CALLS, CLIENT_PRIMITIVES, CLIENT_VIDEO_MEM_BYTES >> 20, CLIENT_STATIC_MEM_BYTES >> 20]
|
||||
text += " %-14s %6s %6s %9s %8s %7s %8s %8s %6s\n" % ["frame", "draws", "shadow", "prims", "objects", "visible", "video MB", "static MB", "nodes"]
|
||||
for row: Dictionary in result["client"]:
|
||||
text += " %-14s %6d %6d %9d %8d %7d %8d %8d %6d\n" % [
|
||||
row["scene"], row["draw_calls"], row["shadow_draw_calls"], row["primitives"], row["objects"],
|
||||
row["visible_draw_calls"], row["video_mem_bytes"] >> 20, row["static_mem_bytes"] >> 20, row["nodes"]]
|
||||
return text
|
||||
|
||||
|
||||
func _limit(row: Dictionary, key: String, budget: int) -> void:
|
||||
var value: int = row[key]
|
||||
if value < 0:
|
||||
_fail("%s: no %s was reported" % [row["scene"], key])
|
||||
elif value > budget:
|
||||
_fail("%s: %s %d is over the %d budget" % [row["scene"], key, value, budget])
|
||||
|
||||
|
||||
func _fail(message: String) -> void:
|
||||
_failures.append(message)
|
||||
|
||||
|
||||
func _read(path: String) -> Array[Dictionary]:
|
||||
var lines: Array[Dictionary] = []
|
||||
if not FileAccess.file_exists(path):
|
||||
return lines
|
||||
for line: String in FileAccess.get_file_as_string(path).split("\n", false):
|
||||
var parsed: Variant = JSON.parse_string(line)
|
||||
if parsed is Dictionary:
|
||||
lines.append(parsed)
|
||||
return lines
|
||||
|
||||
|
||||
func _write(path: String, text: String) -> void:
|
||||
var file: FileAccess = FileAccess.open(path, FileAccess.WRITE)
|
||||
if file != null:
|
||||
file.store_string(text)
|
||||
@@ -0,0 +1 @@
|
||||
uid://h25fcqsxrse1
|
||||
@@ -57,5 +57,26 @@ func _capture() -> void:
|
||||
stats["adapter"] = RenderingServer.get_video_adapter_name()
|
||||
stats["blank"] = blank
|
||||
stats["saved"] = error == OK
|
||||
stats["render"] = render_counts()
|
||||
print("CAPTURE " + JSON.stringify(stats))
|
||||
quit(0 if error == OK and (not blank or _allow_blank) else 1)
|
||||
|
||||
|
||||
## H1: what the last frame cost to draw. "draw_calls", "primitives" and "objects" cover
|
||||
## every pass (shadows included); "visible_*" only the main camera pass. Memory is in
|
||||
## bytes. Counts, not timings: software rendering says nothing about real frame rates.
|
||||
func render_counts() -> Dictionary:
|
||||
var counts: Dictionary = {
|
||||
"draw_calls": int(Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME)),
|
||||
"primitives": int(Performance.get_monitor(Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME)),
|
||||
"objects": int(Performance.get_monitor(Performance.RENDER_TOTAL_OBJECTS_IN_FRAME)),
|
||||
"visible_draw_calls": root.get_render_info(Viewport.RENDER_INFO_TYPE_VISIBLE, Viewport.RENDER_INFO_DRAW_CALLS_IN_FRAME),
|
||||
"visible_primitives": root.get_render_info(Viewport.RENDER_INFO_TYPE_VISIBLE, Viewport.RENDER_INFO_PRIMITIVES_IN_FRAME),
|
||||
"shadow_draw_calls": root.get_render_info(Viewport.RENDER_INFO_TYPE_SHADOW, Viewport.RENDER_INFO_DRAW_CALLS_IN_FRAME),
|
||||
"video_mem_bytes": int(Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED)),
|
||||
"texture_mem_bytes": int(Performance.get_monitor(Performance.RENDER_TEXTURE_MEM_USED)),
|
||||
"buffer_mem_bytes": int(Performance.get_monitor(Performance.RENDER_BUFFER_MEM_USED)),
|
||||
"static_mem_bytes": OS.get_static_memory_usage(),
|
||||
"nodes": int(Performance.get_monitor(Performance.OBJECT_NODE_COUNT)),
|
||||
}
|
||||
return counts
|
||||
|
||||
Reference in New Issue
Block a user