Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
# renderdoc_parser
Direct-call Python interface for RenderDoc capture analysis. No MCP protocol required — import and call functions directly.
**Requires Python 3.6** (the `renderdoc.pyd` extension module is compiled for Python 3.6).
## Quick Start
```python
import sys
sys.path.insert(0, "engine/tools")
from renderdoc_parser import open_capture, get_capture_info, get_frame_overview
open_capture("frame.rdc")
print(get_capture_info())
print(get_frame_overview())
```
## Requirements
- Python 3.6
- `renderdoc.pyd` and `renderdoc.dll` in `engine/third_party/renderdoc/`
- Supported APIs: D3D12, D3D11, Vulkan, OpenGL ES, OpenGL, Metal
## API Reference
### Session (4 functions)
| Function | Description |
|----------|-------------|
| `open_capture(filepath)` | Open a `.rdc` capture file. Returns API type, action/resource counts. |
| `close_capture()` | Close the current capture and free resources. |
| `get_capture_info()` | Capture metadata: API, resolution, texture/buffer counts, GPU quirks. |
| `get_frame_overview()` | Frame stats: draw calls, clears, dispatches, memory usage, render targets. |
### Event Navigation (5 functions)
| Function | Description |
|----------|-------------|
| `list_actions(max_depth=2, filter_flags=None, filter=None, event_type=None)` | Draw call/action tree. `max_depth` limits recursion. `filter_flags` accepts `["Drawcall", "Clear", "Dispatch"]` . `event_type` shorthand: `"draw"` , `"dispatch"` , `"clear"` . |
| `get_action(event_id)` | Get a single ActionDescription by event ID. |
| `set_event(event_id)` | Navigate to a specific event. |
| `search_actions(name_pattern=None, flags=None)` | Search actions by name substring or ActionFlags. |
2026-03-23 18:50:16 +08:00
| `find_draws(blend=None, min_vertices=None, texture_id=None, shader_id=None, render_target_id=None, max_results=50)` | Find draw calls matching criteria. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Pipeline State (4 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `get_pipeline_state(event_id=None)` | Full pipeline state at an event: shaders, viewports, scissors, blend, stencil, output targets. |
| `get_shader_bindings(stage, event_id=None)` | Shader resource bindings. `stage` is required: `"vertex"` , `"hull"` , `"domain"` , `"geometry"` , `"pixel"` , `"compute"` . |
| `get_vertex_inputs(event_id=None)` | Vertex input layout (format, semantic, register, stride). |
| `get_draw_call_state(event_id=None)` | Summary of the draw call at an event (indices, instances, topology, textures, shaders). |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Resources (4 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `list_textures(filter_format=None, min_width=0)` | All textures with dimensions, format, mip levels. |
| `list_buffers(min_size=0)` | All buffers with length and creation flags. |
| `list_resources(type_filter=None, name_pattern=None)` | All resources (textures + buffers) unified. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
| `get_resource_usage(resource_id)` | Which events use a given resource and how. |
### Data Reading (8 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `save_texture(resource_id, output_path, file_type=None, mip=0, event_id=None)` | Save a texture to file. `file_type` accepts `"png"` , `"jpg"` , `"bmp"` , `"tga"` , `"hdr"` , `"exr"` , `"dds"` . |
| `get_buffer_data(resource_id, offset=0, length=None, format=None)` | Raw bytes of a buffer. |
| `pick_pixel(resource_id, x, y, event_id=None)` | RGBA value at a pixel. |
| `get_texture_stats(resource_id, event_id=None, all_slices=False)` | Min/max/avg values for a texture. |
| `read_texture_pixels(resource_id, x, y, width, height, mip_level=0, array_slice=0, event_id=None)` | Pixel region as a 2D list of RGBA values. |
| `export_draw_textures(event_id, output_dir, skip_small=True)` | Save all render targets at a draw call to image files. |
| `save_render_target(event_id, output_path, save_depth=False)` | Save a specific render target to file. |
| `export_mesh(event_id, output_path=None)` | Export mesh data (positions, normals, UVs, indices) as a structured dict. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Shader Analysis (3 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `disassemble_shader(stage, target=None, event_id=None, line_range=None, search=None)` | Disassembled shader code. `stage` is required. `target` is a disassembly backend (e.g. `"DXBC/DXIL"` ). |
| `get_shader_reflection(stage, event_id=None)` | Shader reflection: inputs, outputs, cbuffers, textures, samplers. |
| `get_cbuffer_contents(stage, cbuffer_index, event_id=None, filter=None)` | Contents of a constant buffer slot for a given stage. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Advanced (6 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `pixel_history(resource_id, x, y, event_id=None)` | All events that wrote to or modified a pixel, with before/after values. |
| `get_post_vs_data(stage="vertex", max_vertices=None, event_id=None)` | Post-vertex-shader data (positions, clip positions, cull distances). |
| `diff_draw_calls(eid1, eid2)` | Diff two draw calls: state differences and likely causes. |
| `analyze_render_passes()` | Render pass grouping: which draw calls contribute to which render targets. |
| `sample_pixel_region(event_id=None, resource_id=None, region=None, sample_count=64, anomaly_threshold=0.5)` | Sample all pixels in a region. Returns NaN/Inf/negative/bright pixel counts. |
| `debug_shader_at_pixel(event_id=None, pixel_x=None, pixel_y=None, stage=None, watch_variables=None)` | Step-by-step shader debug at a pixel. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Performance (4 functions)
| Function | Description |
|----------|-------------|
| `get_pass_timing(granularity="pass", top_n=20)` | GPU timing per pass or per draw call. |
2026-03-23 18:50:16 +08:00
| `analyze_overdraw(pass_name=None, region=None, sample_count=64)` | Overdraw analysis: draw counts per render target. |
| `analyze_bandwidth(breakdown_by=None)` | Estimated memory bandwidth: texture reads, render target writes, buffer traffic. |
| `analyze_state_changes(pass_name=None, change_types=None)` | Track state changes between draw calls. `change_types` accepts `["blend", "depth", "cull", "shader", "vertex", "index", "render_target"]` . |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
### Diagnostics (4 functions)
| Function | Description |
|----------|-------------|
2026-03-23 18:50:16 +08:00
| `diagnose_negative_values(check_targets=None, trace_depth=100)` | Detect render targets receiving negative values. Operates on current event. |
| `diagnose_precision_issues(focus=None, threshold=None)` | Detect potential half-float precision issues. |
| `diagnose_reflection_mismatch(reflection_pass_hint=None, object_hint=None)` | Detect shader resource counts/types that differ from pipeline state. |
| `diagnose_mobile_risks(check_categories=None, severity_filter="all")` | Mobile GPU-specific risks based on detected driver (Adreno, Mali, PowerVR, Apple). Operates on current event. |
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
## Return Format
All functions return a Python `dict` . On error, all functions return:
```python
{"error": "human-readable message", "code": "ERROR_CODE"}
```
Successful calls return a non-empty `dict` with function-specific data.
## File Structure
```
engine/tools/renderdoc_parser/
├── __init __ .py # Re-exports all 42 functions at package level
├── session.py # RenderDoc session singleton
├── util.py # load_renderdoc(), serialization helpers, enum maps
└── tools/
├── __init __ .py # Re-exports all functions by module
2026-03-23 18:50:16 +08:00
├── session_tools.py # open_capture, close_capture, get_capture_info, get_frame_overview
├── event_tools.py # list_actions, get_action, set_event, search_actions, find_draws
├── pipeline_tools.py # get_pipeline_state, get_shader_bindings, get_vertex_inputs, get_draw_call_state
├── resource_tools.py # list_textures, list_buffers, list_resources, get_resource_usage
├── data_tools.py # save_texture, get_buffer_data, pick_pixel, get_texture_stats, ...
├── shader_tools.py # disassemble_shader, get_shader_reflection, get_cbuffer_contents
├── advanced_tools.py # pixel_history, get_post_vs_data, diff_draw_calls, ...
├── performance_tools.py # get_pass_timing, analyze_overdraw, analyze_bandwidth, analyze_state_changes
└── diagnostic_tools.py # diagnose_negative_values, diagnose_precision_issues, ...
Add renderdoc_parser: direct-call Python interface for RenderDoc capture analysis
- Convert from MCP protocol layer to direct Python function calls
- 42 functions across 9 modules: session, event, pipeline, resource, data, shader, advanced, performance, diagnostic
- Requires Python 3.6 (renderdoc.pyd is compiled for Python 3.6)
- Fix renderdoc API calls: GetColorBlends, GetStencilFaces, GetViewport(i), GetScissor(i)
- Remove Python 3.10+ type annotations for Python 3.6 compatibility
- Add README.md with full API documentation
- Includes test.py for basic smoke testing
2026-03-23 18:46:20 +08:00
```
## GPU Quirks
`get_capture_info()` automatically detects the GPU/driver and returns known quirks:
- **Adreno**: mediump precision issues, R11G11B10_FLOAT signed behavior, textureLod bugs
- **Mali**: R11G11B10_FLOAT undefined negative writes, discard early-Z interactions, mediump accumulation
- **PowerVR**: tile-based deferred rendering considerations, sampler binding limits
- **Apple GPU**: tile memory bandwidth, float16 performance recommendations
- **OpenGL ES**: precision qualifier correctness, extension compatibility