RenderDoc CLI 技能
針對 RenderDoc GPU 幀擷取檔案(.rdc)進行無頭式命令列分析。
功能
- 擷取檢查:後設資料、區段、縮圖、格式轉換
- 動作樹:列出/搜尋/篩選繪圖呼叫、清除、分派、標記
- 紋理操作:列出、檢查、匯出(PNG/JPG/DDS/HDR/EXR)、像素選取
- 管線狀態:在任何事件處取得完整的著色器/渲染目標/視埠狀態
- 著色器分析:匯出人類可讀形式的著色器(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 # 僅繪圖呼叫
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
預覽套件
RenderDoc 預覽支援是為了忠實的擷取檢查,而非即時的創意預覽。
# 列出預覽配方
cli-anything-renderdoc -c frame.rdc --json preview recipes
# 為目前擷取或特定事件擷取預覽套件
cli-anything-renderdoc -c frame.rdc --json preview capture --recipe quick --event-id 42
# 為兩個事件或擷取擷取差異預覽套件
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
# 回傳該擷取的最新現有套件
cli-anything-renderdoc -c frame.rdc --json preview latest --recipe quick
典型的預覽套件內容:
- 擷取縮圖
- 輸出目標影像
pipeline_state.jsonaction_summary.json
差異套件額外包含:
- A/B 縮圖
- A/B 輸出目標影像
pipeline_diff.json
RenderDoc 目前並未公開即時預覽工作階段。取而代之的是,每個擷取/差異套件會附加到一個穩定的配方層級 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 路徑 |
代理程式使用注意事項
- 使用
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來專注於實際的渲染 - 當代理程式需要一個可攜帶、忠實的檢查套件而非單純的原始重播呼叫時,請使用
preview capture或preview diff - 若需要持久的擷取/差異歷史記錄,請從預覽 JSON 中讀取
_trajectory_path - 僅在檢查/開啟已產生的套件時使用
cli-hub previews ... - 管線狀態需要來自動作清單的事件 ID
- 紋理儲存支援的格式:png, jpg, bmp, tga, hdr, exr, dds
- 緩衝區資料可以解碼為 hex、float32、uint32 或原始位元組