RenderDoc CLI 技能
对 RenderDoc GPU 帧捕获文件(.rdc)进行无头命令行分析。
功能
- 捕获检查:元数据、段、缩略图、格式转换
- 动作树:列出/搜索/过滤 draw call、清除操作、调度、标记
- 纹理操作:列出、检查、导出(PNG/JPG/DDS/HDR/EXR)、像素拾取
- 管线状态:任意事件处的完整着色器/RT/视口状态
- 着色器分析:以人类可读形式(HLSL/GLSL/反汇编)导出着色器,常量缓冲区回读
- 资源检查:缓冲区/纹理枚举、原始数据读取
- 网格数据:顶点着色器输入/输出解码
- GPU 计数器:枚举并获取硬件性能计数器
命令组
capture
cli-anything-renderdoc -c frame.rdc capture info # 元数据 + 段
cli-anything-renderdoc -c frame.rdc capture thumb -o t.png # 提取缩略图
cli-anything-renderdoc -c frame.rdc capture convert -o out.rdc --format rdc
actions
cli-anything-renderdoc -c frame.rdc actions list # 所有动作
cli-anything-renderdoc -c frame.rdc actions list --draws-only # 仅 draw call
cli-anything-renderdoc -c frame.rdc actions summary # 按类型统计
cli-anything-renderdoc -c frame.rdc actions find "Shadow" # 按名称搜索
cli-anything-renderdoc -c frame.rdc actions get 42 # 单个动作
textures
cli-anything-renderdoc -c frame.rdc textures list
cli-anything-renderdoc -c frame.rdc textures get <id>
cli-anything-renderdoc -c frame.rdc textures save <id> -o out.png --format png
cli-anything-renderdoc -c frame.rdc textures save-outputs 42 -o ./renders/
cli-anything-renderdoc -c frame.rdc textures pick <id> 100 200
pipeline
cli-anything-renderdoc -c frame.rdc pipeline state 42
# 以人类可读形式导出着色器
# 文本着色器(GLSL/HLSL)→ 直接保存
# 二进制着色器(DXBC/SPIR-V)→ 嵌入源码(HLSL/GLSL)或反汇编
cli-anything-renderdoc -c frame.rdc pipeline shader-export 42 --stage Fragment
cli-anything-renderdoc -c frame.rdc pipeline shader-export 42 --stage Vertex -o ./shaders/
cli-anything-renderdoc -c frame.rdc pipeline cbuffer 42 --stage Vertex --index 0
# 比较两个事件之间的管线状态
# 默认输出:捕获文件所在目录;使用 -o 覆盖
cli-anything-renderdoc -c a.rdc pipeline diff 100 200 -b b.rdc
cli-anything-renderdoc -c frame.rdc pipeline diff 100 200 # 同一捕获
cli-anything-renderdoc -c a.rdc pipeline diff 100 200 -b b.rdc -o result.json
cli-anything-renderdoc -c a.rdc pipeline diff 100 200 -b b.rdc --no-compact
resources
cli-anything-renderdoc -c frame.rdc resources list
cli-anything-renderdoc -c frame.rdc resources buffers
cli-anything-renderdoc -c frame.rdc resources read-buffer <id> --format float32
mesh
cli-anything-renderdoc -c frame.rdc mesh inputs 42 --max-vertices 10
cli-anything-renderdoc -c frame.rdc mesh outputs 42
counters
cli-anything-renderdoc -c frame.rdc counters list
cli-anything-renderdoc -c frame.rdc counters fetch --ids 1,2,3
预览 Bundle
RenderDoc 预览支持用于真实捕获检查,而非实时创意预览。
# 列出预览方案
cli-anything-renderdoc -c frame.rdc --json preview recipes
# 为当前捕获或特定事件捕获预览 bundle
cli-anything-renderdoc -c frame.rdc --json preview capture --recipe quick --event-id 42
# 为两个事件或捕获捕获差异预览 bundle
cli-anything-renderdoc -c frame.rdc --json preview diff 100 200
cli-anything-renderdoc -c a.rdc --json preview diff 100 200 --capture-b b.rdc
# 返回捕获的最新现有 bundle
cli-anything-renderdoc -c frame.rdc --json preview latest --recipe quick
典型预览 bundle 内容:
- 捕获缩略图
- 输出目标图像
pipeline_state.jsonaction_summary.json
差异 bundle 额外包含:
- A/B 缩略图
- A/B 输出目标图像
pipeline_diff.json
RenderDoc 目前不提供实时预览会话。相反,每个捕获/差异 bundle 都会追加到稳定的方案级 trajectory.json 中。
查看器命令:
cli-hub previews inspect /path/to/bundle
cli-hub previews html /path/to/bundle -o page.html
cli-hub previews open /path/to/bundle
JSON 模式
所有命令均支持 --json 以输出机器可读格式:
cli-anything-renderdoc -c frame.rdc --json actions summary
环境变量
| 变量 | 描述 |
|---|---|
RENDERDOC_CAPTURE | 默认捕获文件路径 |
PYTHONPATH | 必须包含 RenderDoc 路径 |
Agent 使用注意事项
- 使用
pipeline shader-export提取着色器 — 对于二进制着色器(DXBC/SPIR-V),它会自动导出嵌入的 HLSL/GLSL 源码或回退到反汇编;对于文本着色器(GLSL/HLSL),它直接保存原始源代码 - 不同捕获 API 的着色器格式:
- D3D11 → DXBC 二进制,导出为嵌入的 HLSL 源码(
.hlsl)或字节码汇编(.dxbc.asm) - OpenGL/GLES → GLSL 源码文本(
.glsl),人类可读 - Vulkan → SPIR-V 二进制,导出为嵌入的 GLSL 源码(
.glsl)或 SPIR-V 汇编(.spv.asm)
- D3D11 → DXBC 二进制,导出为嵌入的 HLSL 源码(
- 使用
pipeline diff比较两个事件 — 它写入一个 JSON 文件并只打印路径;使用-b指定第二个捕获文件 - 始终指定
--json以便程序化消费 - 首先使用
actions summary了解捕获的复杂度 - 使用
actions list --draws-only聚焦实际渲染 - 当 agent 需要可移植、可靠的检查 bundle 而不是仅依靠原始回放调用时,使用
preview capture或preview diff - 如需持久的捕获/差异历史,请从预览 JSON 中读取
_trajectory_path cli-hub previews ...仅用于检查/打开已生成的 bundle- 管线状态需要动作列表中的事件 ID
- 纹理保存支持格式:png, jpg, bmp, tga, hdr, exr, dds
- 缓冲区数据可以解码为 hex, float32, uint32 或原始字节