godot-performance-optimizer
Godot engine expert for performance profiling, memory optimization, and screen resolution adaptation.
Install
mkdir -p .claude/skills/godot-performance-optimizer && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18101" && unzip -o skill.zip -d .claude/skills/godot-performance-optimizer && rm skill.zipInstalls to .claude/skills/godot-performance-optimizer
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Godot 性能优化与适配专家,支持自然语言描述自动完成分辨率适配、性能分析、内存优化、帧率提升等优化工作Key capabilities
- →Adapt to different screen resolutions and aspect ratios
- →Detect and scale UI based on DPI
- →Monitor FPS and analyze performance
- →Track memory usage and suggest optimizations
- →Manage object pools and memory recycling
- →Optimize rendering by reducing Draw calls
How it works
The skill analyzes Godot game performance metrics, formulates optimization strategies, and automatically implements adjustments for resolution, memory, and rendering.
Inputs & outputs
When to use godot-performance-optimizer
- →Optimize frame rate
- →Analyze memory usage
- →Adapt UI resolution
- →Detect performance bottlenecks
About this skill
Godot 性能优化专家技能
技能概述
godot-performance-optimizer 是专门用于 Godot 游戏性能优化和平台适配的智能化技能,能够根据用户的自然语言描述自动完成分辨率适配、性能分析、内存优化、帧率提升、平台适配等全面的性能优化工作。
核心功能
📱 分辨率适配系统
- 多分辨率支持:自动适配不同屏幕分辨率和比例
- DPI缩放:智能DPI检测和UI缩放
- 横竖屏切换:动态横竖屏布局适配
- 平台特定优化:针对不同平台的显示优化
⚡ 性能分析工具
- 帧率监控:实时FPS监控和分析
- 内存分析:内存使用情况追踪和优化建议
- 渲染分析:Draw call、Overdraw等渲染性能分析
- 瓶颈检测:自动检测性能瓶颈和热点代码
🧠 内存优化系统
- 对象池管理:智能对象池和内存回收
- 资源压缩:纹理、音频等资源的智能压缩
- 垃圾回收优化:GC策略优化和内存碎片整理
- 流式加载:大型资源的流式加载和卸载
🎮 渲染优化
- 批处理优化:减少Draw call和渲染批次
- LOD系统:细节层次距离优化
- 遮挡剔除:智能遮挡剔除和视锥剔除
- 着色器优化:GPU着色器性能优化
使用方法
分辨率适配优化
用户: "我的游戏在不同手机上显示不正常,需要适配各种屏幕尺寸"
系统: 自动实现:
- 检测目标设备分辨率范围
- 设计响应式布局系统
- 配置自动缩放和锚点
- 优化UI元素大小和间距
- 测试各种分辨率下的显示效果
性能分析和优化
用户: "游戏在低端设备上运行卡顿,需要优化到60FPS"
系统: 智能优化:
- 全面性能分析和瓶颈检测
- 优化渲染管线和Draw call
- 减少物理计算开销
- 优化脚本执行效率
- 调整画质设置和特效等级
内存使用优化
用户: "游戏内存占用过高,经常闪退,需要优化内存使用"
系统: 全面优化:
- 分析内存使用热点
- 实现智能对象池系统
- 优化资源加载和卸载策略
- 压缩纹理和音频资源
- 配置垃圾回收策略
平台性能适配
用户: "需要为PC、移动、主机三个平台优化性能"
系统: 多平台优化:
- 针对不同平台的性能策略
- 平台特定的渲染设置
- 输入和UI适配优化
- 性能分级和质量设置
工作流程
1. 性能分析阶段
# 全面性能检测
- 帧率和稳定性分析
- 内存使用情况检测
- 渲染性能瓶颈识别
- CPU和GPU使用率分析
2. 优化策略制定
# 制定优化方案
- 确定优化优先级
- 选择合适的优化技术
- 平衡画质和性能
- 制定分阶段优化计划
3. 自动优化实施
# 执行优化操作
- 自动调整渲染设置
- 优化代码和算法
- 配置资源压缩
- 实现内存管理策略
4. 效果验证
# 验证优化效果
- 对比优化前后性能
- 测试不同设备表现
- 验证稳定性改善
- 生成优化报告
MCP 工具集成
性能分析工具
get_performance_metrics- 获取性能指标analyze_memory_usage- 分析内存使用profile_render_performance- 分析渲染性能detect_performance_bottlenecks- 检测性能瓶颈
优化操作工具
optimize_render_settings- 优化渲染设置compress_textures- 压缩纹理资源configure_object_pools- 配置对象池adjust_quality_settings- 调整画质设置
平台适配工具
detect_platform_capabilities- 检测平台能力configure_platform_settings- 配置平台设置optimize_for_platform- 针对平台优化test_platform_performance- 测试平台性能
监控调试工具
create_performance_monitor- 创建性能监控器setup_debug_overlay- 设置调试界面log_performance_data- 记录性能数据generate_performance_report- 生成性能报告
分辨率适配系统
智能布局管理器
# 响应式布局管理器
class_name ResponsiveLayoutManager extends Control
@export var base_resolution: Vector2 = Vector2(1920, 1080)
@export var support_orientations: bool = true
var current_scale: float = 1.0
var current_resolution: Vector2
func _ready() -> void:
get_tree().get_window().size_changed.connect(_on_window_resized)
_on_window_resized()
func _on_window_resized() -> void:
var window_size = get_tree().get_window().size
current_resolution = window_size
current_scale = _calculate_scale_factor(window_size)
_apply_scaling()
func _calculate_scale_factor(window_size: Vector2) -> float:
var scale_x = window_size.x / base_resolution.x
var scale_y = window_size.y / base_resolution.y
# 使用最小缩放比例确保内容完全可见
return min(scale_x, scale_y)
func _apply_scaling() -> void:
# 应用缩放到所有子控件
for child in get_children():
if child is Control:
_scale_control_recursive(child, current_scale)
DPI适配系统
# DPI适配管理器
class_name DPIAdapter extends Node
var base_dpi: float = 96.0 # 标准DPI
var current_dpi: float = 96.0
var scale_factor: float = 1.0
func _ready() -> void:
_detect_dpi()
_apply_dpi_scaling()
func _detect_dpi() -> void:
var screen = DisplayServer.screen_get_screen_rect()
var physical_size = DisplayServer.screen_get_size()
# 计算DPI
var diagonal_pixels = sqrt(physical_size.x^2 + physical_size.y^2)
var diagonal_inches = sqrt(screen.size.x^2 + screen.size.y^2) / base_dpi
current_dpi = diagonal_pixels / diagonal_inches
scale_factor = current_dpi / base_dpi
func _apply_dpi_scaling() -> void:
# 调整字体大小
var theme = get_tree().current_scene.get_theme()
if theme:
_scale_font_sizes(theme, scale_factor)
# 调整UI元素间距
_scale_ui_spacing(scale_factor)
性能分析系统
实时性能监控器
# 性能监控器
class_name PerformanceMonitor extends Node
@export var monitoring_interval: float = 1.0
@export var enable_debug_overlay: bool = true
var fps_history: Array[float] = []
var memory_history: Array[float] = []
var draw_call_history: Array[int] = []
var debug_overlay: Control
func _ready() -> void:
if enable_debug_overlay:
_create_debug_overlay()
var timer = Timer.new()
timer.timeout.connect(_update_metrics)
timer.wait_time = monitoring_interval
timer.autostart = true
add_child(timer)
func _update_metrics() -> void:
# 收集性能指标
var current_fps = Engine.get_frames_per_second()
var memory_usage = OS.get_static_memory_usage_by_type()
var draw_calls = RenderingServer.get_rendering_info(RenderingServer.RENDERING_INFO_DRAW_CALLS_IN_FRAME)
# 更新历史数据
fps_history.append(current_fps)
memory_history.append(memory_usage[OS.MEMORY_TYPE_STATIC] / 1024.0 / 1024.0) # MB
draw_call_history.append(draw_calls)
# 保持历史数据在合理范围内
if fps_history.size() > 60:
fps_history.pop_front()
memory_history.pop_front()
draw_call_history.pop_front()
# 更新调试界面
if debug_overlay:
_update_debug_overlay()
func get_performance_summary() -> Dictionary:
var avg_fps = 0.0
if fps_history.size() > 0:
avg_fps = fps_history.reduce(func(sum, fps): return sum + fps, 0.0) / fps_history.size()
return {
"average_fps": avg_fps,
"min_fps": fps_history.min() if fps_history.size() > 0 else 0,
"max_fps": fps_history.max() if fps_history.size() > 0 else 0,
"memory_usage_mb": memory_history[-1] if memory_history.size() > 0 else 0,
"draw_calls": draw_calls[-1] if draw_calls.size() > 0 else 0
}
性能瓶颈检测器
# 性能瓶颈检测器
class_name PerformanceBottleneckDetector extends Node
@export var analysis_duration: float = 5.0
@export var fps_threshold: float = 30.0
@export var memory_threshold_mb: float = 500.0
var analysis_active: bool = false
var analysis_start_time: float = 0.0
func start_analysis() -> void:
analysis_active = true
analysis_start_time = Time.get_time_dict_from_system().hour * 3600 + \
Time.get_time_dict_from_system().minute * 60 + \
Time.get_time_dict_from_system().second
func _process(delta: float) -> void:
if not analysis_active:
return
var current_time = Time.get_time_dict_from_system().hour * 3600 + \
Time.get_time_dict_from_system().minute * 60 + \
Time.get_time_dict_from_system().second
if current_time - analysis_start_time >= analysis_duration:
_analyze_and_report()
analysis_active = false
func _analyze_and_report() -> void:
var report = {}
# 检测FPS问题
var fps = Engine.get_frames_per_second()
if fps < fps_threshold:
report["fps_issue"] = {
"current_fps": fps,
"threshold": fps_threshold,
"suggestions": _get_fps_optimization_suggestions(fps)
}
# 检测内存问题
var memory_mb = OS.get_static_memory_usage_by_type()[OS.MEMORY_TYPE_STATIC] / 1024.0 / 1024.0
if memory_mb > memory_threshold_mb:
report["memory_issue"] = {
"current_memory_mb": memory_mb,
"threshold_mb": memory_threshold_mb,
"suggestions": _get_memory_optimization_suggestions(memory_mb)
}
# 输出报告
_output_performance_report(report)
内存优化系统
智能对象池
# 智能对象池管理器
class_name SmartObjectPool extends Node
var pools: Dictionary = {}
@export var max_pool_size: int = 100
@export var cleanup_interval: float = 30.0
func _ready() -> void:
var cleanup_timer = Timer.new()
cleanup_timer.timeout.connect(_cleanup_unused_objects)
cleanup_timer.wait_time = cleanup_interval
cleanup_timer.autostart = true
add_child(cleanup_timer)
func get_object(object_scene: PackedScene) -> Node:
var scene_path = object_scene.resource_path
var pool = pools.get(scene_path)
if not pool:
pool = []
pools[scene_path] = pool
# 从池中获取对象
if pool.size() > 0:
var obj = pool.pop_back()
obj.visible = true
obj.set_process(true)
return obj
# 池中没有可用对象,创建新对象
return object_scene.instantiate()
func return_object(obj: Node) -> void:
var scene_path = obj.scene_file_path
var pool = pools.get(scene_path)
if not pool:
pool = []
pools[scene_path] = pool
# 如果池未满,将对象返回池中
if pool.size() < max_pool_size:
obj.visible = false
obj.set_process(false)
obj.get_parent().remove_child(obj)
pool.append(obj)
else:
# 池已满,直接删除对象
obj.queue_free()
func _cleanup_unused_objects() -> void:
for scene_path in pools.keys():
var pool = pools[scene_path]
# 清理池中一半的对象
var cleanup_count = pool.size() / 2
for i in range(cleanup_count):
pool.pop_front().queue_free()
资源压缩优化器
# 资源压缩优化器
class_name AssetCompressionOptimizer extends Node
func optimize_textures_recursively(folder_path: String) -> void:
var dir = DirAccess.open(folder_path)
if not dir:
push_error("Cannot open folder: " + folder_path)
return
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
var full_path = folder_path + "/" + file_name
if dir.current_is_dir():
# 递归处理子文件夹
optimize_textures_recursively(full_path)
elif file_name.ends_with(".png") or file_name.ends_with(".jpg"):
# 优化纹理文件
optimize_texture(full_path)
file_name = dir.get_next()
func optimize_texture(file_path: String) -> void:
var texture = load(file_path)
if not texture:
return
var image = texture.get_image()
if not image:
return
# 检测是否可以压缩
if image.get_format() != Image.FORMAT_DXT1 or image.get_format() != Image.FORMAT_DXT5:
# 转换为压缩格式
var com
---
*Content truncated.*
When not to use it
- →When hardware limitations prevent further optimization
- →When functional trade-offs are not acceptable
- →When platform-specific optimization strategies are not needed
Limitations
- →Optimization space is limited by low-end hardware
- →Some optimizations may affect functionality
- →Different platforms require different optimization strategies
How it compares
This skill automates Godot performance optimization and platform adaptation based on natural language, providing a structured workflow that contrasts with manual, iterative debugging and optimization.
Compared to similar skills
godot-performance-optimizer side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| godot-performance-optimizer (this skill) | 0 | 8mo | Review | Advanced |
| analyzing-logs | 14 | 10d | Review | Beginner |
| obsidian-observability | 5 | 10d | Review | Intermediate |
| instruments-profiling | 3 | 2mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
analyzing-logs
jeremylongshore
Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.
obsidian-observability
jeremylongshore
Set up comprehensive logging and monitoring for Obsidian plugins. Use when implementing debug logging, tracking plugin performance, or setting up error reporting for your Obsidian plugin. Trigger with phrases like "obsidian logging", "obsidian monitoring", "obsidian debug", "track obsidian plugin".
instruments-profiling
steipete
Use when profiling native macOS or iOS apps with Instruments/xctrace. Covers correct binary selection, CLI arguments, exports, and common gotchas.
worker-benchmarks
ruvnet
Run comprehensive worker system benchmarks and performance analysis
sentry-rate-limits
jeremylongshore
Manage Sentry rate limits and quota optimization. Use when hitting rate limits, optimizing event volume, or managing Sentry costs. Trigger with phrases like "sentry rate limit", "sentry quota", "reduce sentry events", "sentry 429".
agent-benchmark-suite
ruvnet
Agent skill for benchmark-suite - invoke with $agent-benchmark-suite