返回提示词目录第 1494 页

游戏帧耗时分析与性能优化

依据性能采样定位游戏线程或显卡瓶颈,按收益与工作量排序优化措施,并制定真机复测方案。

完整提示词

<context>
The user's game misses its frame rate on {{target_platform}}. Engine: {{engine}}. The budget is 1000 ms divided by the target frame rate: 33.33 ms at 30 fps, 16.67 ms at 60, 11.11 ms at 90 (common for VR) and 8.33 ms at 120, and a healthy target leaves 10-20% headroom for spikes and thermal throttling on mobile and handhelds. Average fps hides the real problem: players feel the worst frames, so look at frame-time percentiles (p95, p99) and spikes, not the mean.

The expert's first question is what bounds the frame: the main (game) thread, the render thread, or the GPU. Optimising the GPU when the main thread is at 24 ms does nothing. Typical culprits: per-frame allocations causing garbage collection spikes, too many draw calls or state changes, overdraw from particles and transparent UI, shadows and post-processing at console settings on mobile, physics with too many active bodies or a too-small fixed step, expensive scripts in update loops, synchronous loading or shader compilation hitches, and vsync or frame pacing issues that look like drops.
</context>

<task>
<profiler_data>
{{profiler_data}}
</profiler_data>

1. State the budget, the measured frame times (average, p95, worst) and the gap in milliseconds. If the target frame rate is not stated, ask for it; until then give the verdict against both 30 and 60 fps, labelled provisional. If the capture has only an average, say that p95 and worst frames are missing and how to record them.
2. Decide what bounds the frame using the evidence: compare main-thread, render-thread and GPU times; note "wait for GPU" or "present" markers; check whether lowering resolution changes frame time (GPU or fill-rate bound) or not (CPU bound). If the capture cannot tell, say which capture or test would.
3. Break down the bounding side into hotspots with their milliseconds: scripts and gameplay systems, physics, animation, UI layout and rebuilds, garbage collection, culling, draw call submission, and on the GPU: shadows, post-processing, overdraw, shader cost, vertex count, texture bandwidth.
4. Separate steady cost (every frame) from spikes (GC, loading, shader compilation, spawning): they need different fixes (pooling, prewarming, async loading, shader variant collections or pipeline caches).
5. Propose fixes, each with expected milliseconds saved as a range and effort: batching (static, dynamic, GPU instancing, SRP batcher or equivalent), LODs and culling distances, atlasing, reducing transparent layers, shadow cascades and resolution, dynamic resolution, update frequency reduction (time-slicing AI, staggering raycasts), object pooling, removing per-frame allocations, moving work off the main thread with the engine's job system.
6. Rank by milliseconds saved per unit of effort and stop when the cumulative estimate clears the budget with headroom.
7. Give the re-measurement plan: same scene, same camera path or replay, on the target device (not the editor), with thermals settled, recording p95 and p99 frame time.
</task>

<constraints>
- Profile on the target device; editor numbers only as a hint and labelled as such.
- Savings are estimates until measured; give ranges and say what they depend on.
- Do not invent profiler numbers or engine settings not shown; ask for the missing capture (for example a GPU capture) when it decides the diagnosis.
- Do not suggest cutting visual quality that designers own without naming the trade-off.
</constraints>

<output_format>
## Budget and verdict
Budget, measured average, p95 and worst frame time, gap, and one sentence on the main problem.
## Bound by
Main thread, render thread or GPU, with the evidence.
## Hotspots
Table: system | ms per frame | steady or spike | evidence.
## Ranked fixes
Table: fix | ms saved (range) | effort | risk or trade-off. Then the cumulative estimate against the budget.
## Measure again
The repeatable capture procedure and what to record.
</output_format>

可替换内容

  • {{target_platform}}
  • {{engine}}
  • {{profiler_data}}

分类与标签

编程开发、游戏性能、帧耗时、瓶颈分析、真机测试

前往 AI 图片创作