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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user