77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.
Python agent-skillsai-agentsantigravityawesome-listclaude-codeclinecodexcursorgame-devgame-developmentgamedevgemini-cligithub-copilotgodotkirooh-my-piskillsunityunrealwindsurf
fix(performance-optimization): correct profiler units, Unity 6.3 APIs and batching notes
Kiro Crew1dbc520c0faa
diff --git a/skills/disciplines/performance-optimization/SKILL.md b/skills/disciplines/performance-optimization/SKILL.mdindex 37d589a..27122e6 100644--- a/skills/disciplines/performance-optimization/SKILL.md+++ b/skills/disciplines/performance-optimization/SKILL.md@@ -72,14 +72,17 @@ If one subsystem blows its slice, that's your target — not whatever you assume### 2. Measure with the engine profiler (do this before any fix)```text-Godot 4.7 : Debugger ▸ Profiler (script/physics time) and Monitors tab (FPS, draw calls, memory).- In code: Performance.get_monitor(Performance.TIME_PROCESS) and- Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME).-Unity 6.3 LTS : Profiler window (CPU/GPU/Memory/Rendering modules) + Frame Debugger for draw calls.- In code: a ProfilerRecorder tracking "CPU Main Thread Frame Time" for a HUD/log.-Unreal 5 : `stat unit` (Frame/Game/Draw/GPU ms), `stat fps`, `stat scenerendering` (draw calls);- Unreal Insights for deep traces.-# Read the split: is the Draw/GPU line the biggest, or the Game/CPU line? That decides the fix.+Godot 4.7 : Debugger ▸ Profiler (script/physics time), Visual Profiler (CPU vs GPU render time+ per pass) and Monitors tab (FPS, draw calls, memory).+ In code: Performance.get_monitor(Performance.TIME_PROCESS) returns SECONDS+ (× 1000 for ms); Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME for draw calls.+Unity 6.3 LTS : Profiler window (CPU/GPU/Memory/Rendering modules) + Frame Debugger for draw calls.+ In code: ProfilerRecorder on "CPU Main Thread Frame Time" / "GPU Frame Time"+ (release players need Frame Timing Stats enabled in Player Settings).+Unreal 5.8 : `stat unit` (Frame / Game / Draw / RHIT / GPU ms), `stat fps`,+ `stat scenerendering` (draw calls); Unreal Insights for deep traces.+# Read the split: Game = gameplay thread, Draw = render thread (both CPU), GPU = the graphics card.+# Whichever is closest to Frame is the bottleneck; that decides the fix.```### 3. Object pooling (stop allocating/freeing in hot loops)@@ -87,12 +90,12 @@ Unreal 5 : `stat unit` (Frame/Game/Draw/GPU ms), `stat fps`, `stat scenerenderi```gdscript# Bullets, particles, enemies, damage numbers: reuse a fixed set instead of instantiate()/free()# every frame — that thrashes memory and (in C#) feeds the GC.-var _pool: Array[Node] = []-func acquire() -> Node:- var n: Node = _pool.pop_back() if not _pool.is_empty() else bullet_scene.instantiate()+var _pool: Array[Node2D] = [] # Node3D for 3D; both have `visible`+func acquire() -> Node2D:+ var n: Node2D = _pool.pop_back() if not _pool.is_empty() else bullet_scene.instantiate()n.set_process(true); n.visible = truereturn n-func release(n: Node) -> void:+func release(n: Node2D) -> void:n.set_process(false); n.visible = false # disable + hide; DON'T free_pool.append(n) # back to the pool for reuse# RIGHT: pre-warm the pool at load; reuse. WRONG: instantiate()/queue_free() per shot.@@ -101,10 +104,12 @@ func release(n: Node) -> void:### 4. Cut draw calls (the most common GPU-side win)```text-Each unique material/texture/state change is roughly a draw call; thousands of them stall the GPU.+Draw calls and render-state changes (material/shader/texture/blend switches) cost CPU submit time;+thousands of them make the render thread the bottleneck. 2D batchers merge runs of sprites that+share state (most bind several textures per batch), so ordering and atlasing decide the count.- Atlas textures and share materials so sprites/meshes batch into one call.-- Identical meshes → GPU instancing (Unity), MultiMesh / MultiMeshInstance (Godot), Instanced- Static Mesh (Unreal).+- Identical meshes → GPU instancing (Unity; under URP/HDRP the SRP Batcher or GPU Resident Drawer+ takes precedence), MultiMesh / MultiMeshInstance (Godot), Instanced Static Mesh (Unreal).- Static geometry → static batching / baking; mark non-moving objects static.- Reduce overdraw: limit large overlapping transparent/particle layers (they re-shade pixels).- Fewer real-time lights/shadows; bake lighting where it doesn't move.@@ -115,12 +120,14 @@ Measure draw calls before and after — the count should drop, and so should GPU```csharp// Unity 6.3 LTS (C#). Allocating every frame fills the managed heap; the GC then stalls a frame.-// WRONG (allocates each call): foreach (var e in FindObjectsOfType<Enemy>()) ... // + LINQ, new[]+// WRONG (new array + scene walk every call):+// foreach (var e in FindObjectsByType<Enemy>(FindObjectsSortMode.None)) ... // + LINQ, new[]+// (FindObjectsOfType is obsolete in Unity 6.3; its replacement still allocates.)// RIGHT: cache references once, reuse buffers, avoid LINQ/boxing in Update.void Update() {_hits = Physics.RaycastNonAlloc(ray, _hitBuffer); // reuse a preallocated arrayfor (int i = 0; i < _hits; i++) { /* ... */ } // no per-frame allocation-}+} // hit order is undefined and a full buffer may miss the nearest hit: size it, sort if needed// Godot/GDScript: avoid building new arrays/dictionaries every frame in _process; reuse them.```@@ -140,6 +147,9 @@ void Update() {Cache and reuse.- **Draw-call explosion** from unique materials and unbatched sprites/meshes. Atlas, sharematerials, instance, batch.+- **Unity "Enable GPU Instancing" with no effect** under URP/HDRP: the SRP Batcher takes+ precedence for compatible shaders. Check the Frame Debugger; for many identical meshes use the+ GPU Resident Drawer (Forward+, compute-capable APIs, not OpenGL ES).- **Overdraw** from stacked transparents/particles/full-screen effects re-shading pixels.- **No budgets.** Without per-subsystem ms and asset ceilings, performance silently regresses;enforce them in your build/CI checks.diff --git a/skills/disciplines/performance-optimization/references/profiling-and-budgets.md b/skills/disciplines/performance-optimization/references/profiling-and-budgets.mdindex 17025f4..3b0592a 100644--- a/skills/disciplines/performance-optimization/references/profiling-and-budgets.md+++ b/skills/disciplines/performance-optimization/references/profiling-and-budgets.md@@ -22,26 +22,42 @@ calls. This split is the single most important decision in performance work.## 2. Per-engine profiler quick start**Godot 4.7**-- Editor: **Debugger ▸ Profiler** (per-function script + physics time, frame time), and the- **Monitors** tab (FPS, draw calls, video/static memory, object/node counts).-- Code: `Performance.get_monitor(Performance.TIME_PROCESS)` (process ms),- `Performance.TIME_PHYSICS_PROCESS`, `Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME`,- `Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME`, `Performance.MEMORY_STATIC`.-- Visual debugging: viewport **View Information / View Frame Time** overlays.+- Editor: **Debugger ▸ Profiler** (per-function script + physics time, frame time), **Debugger ▸+ Visual Profiler** (CPU and GPU time spent on rendering — the Profiler tab does not show GPU cost),+ and the **Monitors** tab (FPS, draw calls, video/static memory, object/node counts).+- Code: `Performance.get_monitor(Performance.TIME_PROCESS)` (frame process time in **seconds**;+ multiply by 1000 for ms), `Performance.TIME_PHYSICS_PROCESS`,+ `Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME`, `Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME`,+ `Performance.MEMORY_STATIC`.+- Visual debugging: 3D viewport **View Information / View Frame Time** overlays.+- Native-code traces: an engine built from source with `scons profiler=tracy` (or `perfetto`,+ `instruments`) streams engine zones to that profiler.**Unity 6.3 LTS**- **Profiler** window: CPU Usage, GPU Usage, Rendering, Memory modules. Use **Deep Profile**sparingly (high overhead, skews numbers).- **Frame Debugger** to step draw calls and see what breaks batching (SetPass calls, batches).-- Code: `ProfilerRecorder` tracking `"CPU Main Thread Frame Time"` (Unity 6.3 LTS000 manual) for an- in-build HUD/CSV; `FrameTimingManager` for CPU/GPU frame times.+- Code: `ProfilerRecorder` on the built-in counters `"CPU Main Thread Frame Time"`,+ `"GPU Frame Time"` (release players need **Frame Timing Stats** enabled) and+ `"GC Allocated In Frame"` (development players only) for an in-build HUD/CSV;+ `FrameTimingManager` for CPU/GPU frame times.- **Profile a Development build on device** (`Autoconnect Profiler`), not just the editor.+- **Project Auditor** (`com.unity.project-auditor` package) statically flags costly code and+ settings before you profile.-**Unreal 5**-- Console: `stat unit` (Frame / Game / Draw / GPU ms), `stat fps`, `stat scenerendering`- (draw calls, primitives), `stat game`, `stat gpu`.+**Unreal 5.8**+- Console: `stat unit` (Frame / Game / Draw / RHIT / GPU ms — Game is the game thread, Draw the+ render thread, both CPU), `stat fps`, `stat scenerendering` (draw calls, primitives),+ `stat game`, `stat gpu`, `stat hitches` (logs frames over `t.HitchFrameTimeThreshold`).- **Unreal Insights** for full timeline traces; `ProfileGPU` (Ctrl+Shift+,) for a GPU breakdown.+**External tools (engine-agnostic)**+- **RenderDoc** (1.46 at last check): GPU frame capture for Vulkan, D3D11/12 and OpenGL/ES on+ Windows, Linux and Android; no Metal. On Apple platforms use the Xcode Metal debugger and+ Instruments; on Windows D3D12, PIX.+- **Tracy** (0.14.1 at last check): instrumented CPU/GPU timeline for native code; keep the+ client library and the viewer on the same release, because the network protocol can change.+## 3. Pooling manager (generic)```text@@ -62,9 +78,13 @@ decide an overflow policy (grow, or recycle the oldest).- **What breaks a batch:** a different material, texture, or render state between objects. Sharematerials and **atlas** textures so runs of objects submit as one draw call.- **Identical meshes, many instances** → GPU instancing: Unity (enable *GPU Instancing* on the- material) / Godot `MultiMesh` + `MultiMeshInstance2D/3D` / Unreal Instanced Static Mesh or- Hierarchical ISM.-- **Static geometry** → static batching (Unity), mark static; bake where possible.+ material — but under URP/HDRP an SRP Batcher-compatible shader is drawn by the SRP Batcher+ instead; for large counts enable the **GPU Resident Drawer**, which needs the Forward+ path and+ a compute-capable graphics API other than OpenGL ES) / Godot `MultiMesh` ++ `MultiMeshInstance2D/3D` / Unreal Instanced Static Mesh or Hierarchical ISM.+- **Static geometry** → static batching (Unity), mark static; bake where possible. Unity's+ dynamic batching is no longer recommended outside low-end devices: its CPU cost can exceed the+ draw calls it saves.- **2D** → texture atlases + a shared material batch sprites; avoid per-sprite materials.- **UI** → minimize canvas rebuilds (Unity: split static/dynamic canvases); a changing elementshouldn't dirty the whole canvas.