news 2026/9/24 15:11:19

RenderDoc Python 模块 API 参考全览:renderdoc 模块结构与十二大接口板块导航

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
RenderDoc Python 模块 API 参考全览:renderdoc 模块结构与十二大接口板块导航
  • 开发工具
  • 调试器
  • 图形学
  • GPU

【免费下载链接】renderdoc

RenderDoc is a stand-alone graphics debugging tool.

项目地址:https://gitcode.com/gh_mirrors/re/renderdoc
点击查看免费下载

RenderDoc 在图形调试工具之外,还向 Python 暴露了完整的内部接口,使开发者可以用脚本自动完成捕获、回放、分析等任务。本文以仓库中的 docs/python_api/renderdoc/index.rst 为骨架,系统梳理renderdocPython 模块的定位、十二大 API 参考板块及各自核心成员,并结合仓库源码说明其绑定与实现路径。读完本文,你可以快速定位所需 API 所在板块,掌握嵌入式脚本与独立解释器两种使用方式的差异与生命周期约束。

renderdoc模块的定位:UI 之下的同一套底层接口

按 API 参考索引页的原始说明,renderdoc模块中的函数、类与枚举代表了 UI 构建其上的底层接口("the underlying interface that the UI is built on top of")。这意味着:

  • UI 中能看到的任何功能,原则上都能以某种方式通过 Python 访问;
  • 更高级的使用说明与脚本示例,见 docs/python_api/index.rst 的引导文档(first_stepsui_extensionside_integrationfaqexamplesin_depth等)。

在 Python 侧存在两个分工明确的模块:

模块作用域说明
renderdoc通用(UI 内嵌 Python 与独立解释器均可)底层捕获、回放、分析、资源、着色器、结构化数据等接口
qrenderdoc仅在 RenderDoc UI 内可用提供 UI 相关功能访问,参考 docs/python_api/qrenderdoc/index.rst

renderdoc模块的 API 参考共分十二个板块,索引页 docs/python_api/renderdoc/index.rst 通过toctree组织:capturingreplayoutputsanalysisformatsresourcesshaderspipelines/indexstructured_datacountersframe_statsutils。下文逐一展开。

两种使用场景:UI 内嵌脚本 vs 独立解释器加载

UI 内嵌 Python:开箱即用

在 RenderDoc UI 中,Python 脚本直接运行于内嵌的解释器(实现见 qrenderdoc/Code/pyrenderdoc/PythonContext.cpp),此时renderdocqrenderdoc两个模块都已可用,且回放系统已由 UI 初始化完毕,无需开发者手动处理生命周期。

独立解释器加载:高级用法,需自行初始化

docs/python_api/python_module.rst 详细说明了如何把renderdoc作为普通 Python 模块加载到独立解释器中。要点如下:

  • 构建模块:RenderDoc 默认不随安装包分发可加载的 Python 模块(Python 绑定与具体的大版本/小版本绑定)。需要先构建 RenderDoc 源码,构建依赖与步骤见 docs/CONTRIBUTING/Dependencies.md 与 docs/CONTRIBUTING/Compiling.md。构建产物位置因平台而异:Windows 上位于平台/构建类型下的pymodules子目录,Linux 上输出到lib目录下的renderdoc.so
  • 指定 Python 版本:Windows 在 Visual Studio 项目的 "Python Configuration" 属性页中指定解释器路径,并需要把标准库打包为python3.xx.zip(可运行 util/make_python_lib_zip.py 自动从Lib/编译生成);Linux 在 CMake 3.12+ 下使用-DFORCE_PY_VERSION=3.xx强制目标版本。
  • 加载模块:把模块所在目录加入sys.path;Windows 上 Python 3.8+ 还需os.add_dll_directory指向renderdoc.dll所在目录;Linux 上模块自带RUNPATH可默认找到同目录的librenderdoc.so,移动后需自行设置LD_LIBRARY_PATH
  • 生命周期约束:使用模块直连 API 时,必须在调用任何 API 之前调用一次renderdoc.InitialiseReplay(),在进程结束前调用renderdoc.ShutdownReplay();初始化前、关闭后调用任何 API 均非法,且关闭后不可重新初始化。UI 内嵌场景下这两个函数由 UI 自动调用,因此只有在独立使用模块时才需要手动处理。

注意:官方文档明确警告——直接使用 Python 模块属于高级用法,编写 UI 脚本或扩展时并不需要这么做。

十二大 API 板块逐一导航

以下每个板块的内容继承自对应参考页,完整成员列表由 Sphinx autodoc 从绑定接口自动生成,请以参考页为准。

1. Capturing:捕获、注入与目标控制

对应 docs/python_api/renderdoc/capturing.rst,分三组:

  • Execution & Injection(执行与注入)ExecuteAndInject(启动并注入目标进程)、InjectIntoProcess(向已运行进程注入);相关配置类CaptureOptionsEnvironmentModificationEnvModEnvSep,以及返回结果ExecuteResult。其中环境修改相关结构用于在捕获时对目标进程注入/修改环境变量,UI 的捕获选项中即有对应图形化配置。
  • Global Hooking(全局挂钩)StartGlobalHookStopGlobalHookIsGlobalHookActiveCanGlobalHook,用于对系统全局图形 API 调用进行挂钩。
  • Target Control(目标控制)EnumerateRemoteTargetsCreateTargetControl,配合TargetControlTargetControlMessageTargetControlMessageTypeNewCaptureDataAPIUseDataBusyDataNewChildData等,实现与目标进程/设备建立受控连接并收取捕获数据。

2. Replay Control:初始化、打开捕获文件与回放控制器

对应 docs/python_api/renderdoc/replay.rst,这是使用最频繁的板块之一,分六组:

  • Initialisation and Shutdown(初始化与关闭)InitialiseReplayShutdownReplayGlobalEnvironmentResultCodeResultDetails用于状态传递与错误描述。
  • Capture File Access(捕获文件访问)OpenCaptureFileCaptureAccessCaptureFileReplaySupportCaptureFileFormatSectionPropertiesSectionTypeSectionFlagsThumbnailCaptureFile是打开.rdc文件后的主要操作入口,例如读取文件头、枚举节(Section)、获取缩略图并创建回放控制器。
  • GPU Enumeration(GPU 枚举)GPUDeviceGPUVendorGPUVendorFromPCIVendorGraphicsAPIIsD3DGetDriverInformationDriverInformation,用于查询设备与驱动信息。
  • Replay Controller(回放控制器)ReplayController及其配置ReplayOptionsReplayOptimisationLevelAPIPropertiesReplayController是回放、分析、取帧的核心对象。
  • Device Protocols(设备协议)DeviceProtocolControllerGetSupportedDeviceProtocolsGetDeviceProtocolController
  • Remote Servers(远程服务器)RemoteServerCreateRemoteServerConnectionCheckRemoteServerConnectionBecomeRemoteServer,以及文件浏览相关的PathEntryPathProperty

3. Replay Outputs:回放输出(纹理、网格等视图)

对应 docs/python_api/renderdoc/outputs.rst:

  • GeneralReplayOutputReplayOutputType(如 Texture / Mesh 输出类型)、SetColors
  • Window Configuration(窗口配置)WindowingDataWindowingSystem,以及平台相关的构造函数CreateHeadlessWindowingDataCreateWin32WindowingDataCreateXlibWindowingDataCreateXCBWindowingDataCreateWaylandWindowingDataCreateAndroidWindowingDataCreateMacOSWindowingData——这些函数把不同平台的窗口句柄统一封装为WindowingData,供回放输出呈现使用。
  • Texture View(纹理视图)TextureDisplayDebugOverlay,控制纹理显示方式与调试叠加层。
  • Mesh View(网格视图)MeshDisplayMeshDataStageMeshletSizeTaskGroupSizeMeshFormatVisualisationCameraCameraTypeAxisMapping,以及相机初始化辅助函数InitCamera

4. Replay Analysis:帧、动作、调试消息与像素历史

对应 docs/python_api/renderdoc/analysis.rst:

  • Frame and Actions(帧与动作)FrameDescriptionActionDescriptionActionFlagsAPIEvent,用于枚举帧内 drawcall/dispatch 等事件动作。
  • Debug Messages(调试消息)DebugMessageMessageCategoryMessageSeverityMessageSource
  • Resource Usage(资源使用)EventUsageResourceUsage,以及便捷构造函数ResUsageRWResUsageCBUsage,用于描述资源在某事件上的读写用途。
  • Texture Saving(纹理保存)TextureSaveFileTypeAlphaMappingTextureComponentMappingTextureSampleMappingTextureSliceMapping,控制纹理导出为 PNG/EXR 等格式时的通道与切片映射。
  • Pixel History(像素历史)PixelModificationModificationValuePixelValue,用于查询某像素在帧内各事件作用下的变化过程。
  • Shader Debugging(着色器调试)DebugPixelInputs,像素着色器逐片元调试的输入描述。

5. Formats:资源格式描述

对应 docs/python_api/renderdoc/formats.rst:ResourceFormatResourceFormatTypeCompType。这是描述纹理/缓冲底层数据排布的基础类型,被资源、纹理视图等板块广泛引用。

6. Resources:资源枚举与描述

对应 docs/python_api/renderdoc/resources.rst:

  • GeneralResourceIdResourceDescriptionResourceTypeDescriptorStoreDescription
  • Textures(纹理)TextureDescriptionTextureTypeTextureCategorySubresource
  • Buffers(缓冲)BufferDescriptionBufferCategory

配合ReplayControllerGetResources/GetTexture等接口(详见 replay 板块),即可遍历帧内全部 GPU 资源并读取其描述与内容。

7. Shaders:描述符、反射、调试与变量

对应 docs/python_api/renderdoc/shaders.rst,这是内容最多的板块之一,分六组:

  • Descriptors(描述符)DescriptorSamplerDescriptorDescriptorFlagsDescriptorCategoryDescriptorTypeDescriptorLogicalLocationDescriptorRangeDescriptorAccess;辅助函数CategoryForDescriptorTypeIsConstantBlockDescriptorIsReadOnlyDescriptorIsReadWriteDescriptorIsSamplerDescriptor
  • Reflection(着色器反射)ShaderReflectionShaderStageShaderStageMaskMaskForStageFirstStageForMaskSigParameterShaderBuiltinConstantBlockShaderSamplerShaderResource
  • Debug Info(调试信息)ShaderDebugInfoShaderEncodingKnownShaderToolToolExecutableToolInputToolOutputIsTextRepresentationShaderEntryPointShaderSourceFileShaderCompileFlagsShaderCompileFlagShaderSourcePrefix
  • Shader Constants(着色器常量)ShaderConstantShaderConstantTypeShaderVariableFlagsVarTypeVarTypeByteSizeVarTypeCompType
  • Shader Debugging(着色器调试)ShaderDebugTraceShaderDebuggerSourceVariableMappingDebugVariableReferenceDebugVariableTypeLineColumnInfoInstructionSourceInfoShaderDebugStateShaderEventsShaderVariableChange
  • Shader Variables(着色器变量)ShaderVariableShaderValuePointerValShaderBindIndexShaderDirectAccess

8. Pipelines:按图形 API 划分的管线状态参考

对应 docs/python_api/renderdoc/pipelines/index.rst 目录,从仓库文件命名看,管线状态相关类型按通用与各图形 API 分类组织:

  • 通用部分:pipelines/common.rst
  • 各 API 专属部分:pipelines/d3d11.rst、pipelines/d3d12.rst、pipelines/gl.rst、pipelines/vulkan.rst

该板块与 UI 的 Pipeline State 窗口(源码位于 qrenderdoc/Windows/PipelineState/)相对应,用于在回放中读取各阶段完整绑定状态。

9. Structured Data:结构化捕获数据

对应 docs/python_api/renderdoc/structured_data.rst:

  • Type information(类型信息)SDTypeSDBasicSDTypeFlags
  • Objects(对象)SDObjectSDObjectDataSDObjectPODData
  • Chunks(块)SDChunkSDChunkMetaDataSDChunkFlags
  • Structured File(结构化文件)SDFile
  • Creation Helper Functions(创建辅助函数)makeSDArraymakeSDBoolmakeSDEnummakeSDFloatmakeSDInt32makeSDInt64makeSDResourceIdmakeSDStringmakeSDStructmakeSDUInt32makeSDUInt64

结构化数据让脚本可以遍历捕获文件中每个事件的参数(对应 UI 的 Event Browser 参数视图)。

10. Performance Counters:GPU 性能计数器

对应 docs/python_api/renderdoc/counters.rst:

  • Counters(计数器描述)CounterDescriptionCounterUnitUuid
  • Counter Types(计数器类型)GPUCounter及厂商/类别判定函数IsAMDCounterIsARMCounterIsGenericCounterIsIntelCounterIsNvidiaCounterIsVulkanExtendedCounter
  • Results(结果)CounterResultCounterValue

11. Frame Statistics:帧级统计

对应 docs/python_api/renderdoc/frame_stats.rst:

  • 入口结构FrameStatistics
  • Resource Statistics(资源统计)ResourceUpdateStatsBucketRecordType
  • Drawcall Statistics(绘制调用统计)DrawcallStatsDispatchStats
  • Shader Statistics(着色器统计)ConstantBindStatsSamplerBindStatsResourceBindStatsShaderChangeStats
  • Fixed Function Statistics(固定功能统计)IndexBindStatsVertexBindStatsLayoutBindStatsBlendStatsDepthStencilStatsRasterizationStatsOutputTargetStats

12. Utilities:数学、日志、版本、设置与自托管捕获

对应 docs/python_api/renderdoc/utils.rst:

  • Maths(数学)FloatVectorHalfToFloatFloatToHalf
  • Logging & Versioning(日志与版本)LogMessageSetDebugLogFileGetLogFileGetCurrentProcessMemoryUsageDumpObjectLogType;版本信息GetVersionStringGetCommitHashIsReleaseBuild
  • Settings(设置)GetConfigSettingSetConfigSettingSaveConfigSettings,可在脚本中读写并持久化配置项。
  • Self-hosted captures(自托管捕获)CanSelfHostedCaptureStartSelfHostCaptureEndSelfHostCapture,支持由应用自身发起捕获的托管流程。

与仓库源码的对应关系

renderdoc模块并不是独立的另一套实现,而是对 C++ 回放接口的 Python 绑定:

  • SWIG 绑定层:模块由 SWIG 接口文件 qrenderdoc/Code/pyrenderdoc/renderdoc.i 定义,将底层 C++ 类型与函数导出为 Python 的renderdoc模块;UI 内嵌运行时由 qrenderdoc/Code/pyrenderdoc/PythonContext.cpp 维护。
  • C++ 实现层:回放控制器与驱动实现位于 renderdoc/replay/(如 replay_controller.h、replay_driver.h、app_api.cpp),公开 API 头文件集中在 renderdoc/api/replay/;参考页中大量结构体(如ResourceFormatShaderReflectionReplayOptions)即来源于这些头文件的声明,经 SWIG 与 autodoc 自动生成文档。
  • 测试佐证:仓库的自动化测试大量直接使用 Python 模块完成捕获、回放与分析(测试框架位于 util/test/rdtest/,用例位于 util/test/tests/),这与 docs/python_api/python_module.rst 中"直接使用模块的复杂示例可参考自动测试脚本"的说明一致;此外 docs/check_stubs.py、docs/verify-docstrings.py、docs/stubgen.py 等脚本用于生成与校验 API 文档/类型桩,保证参考页与实际绑定一致。

常见任务 → API 板块速查

目标任务首选板块关键类型/函数
启动并注入进程、配置捕获环境变量CapturingExecuteAndInjectCaptureOptionsEnvironmentModification
初始化回放系统、打开.rdc文件Replay ControlInitialiseReplayOpenCaptureFileCaptureFileShutdownReplay
创建回放控制器并逐帧/逐事件分析Replay Control / AnalysisReplayControllerFrameDescriptionActionDescription
查看纹理/网格并导出图片Replay Outputs / AnalysisReplayOutputTextureDisplayMeshDisplayTextureSave
遍历 GPU 资源与纹理信息Resources / FormatsResourceDescriptionTextureDescriptionResourceFormat
读取着色器反射与调试变量ShadersShaderReflectionShaderDebugTraceShaderVariable
查询像素历史与逐片元调试Analysis / ShadersPixelModificationDebugPixelInputsShaderDebugger
采集性能计数器与帧统计Counters / Frame StatisticsGPUCounterCounterResultFrameStatistics
遍历事件参数(结构化数据)Structured DataSDFileSDChunkSDObject
读写设置、查询版本、输出日志UtilitiesGetConfigSettingGetVersionStringLogMessage

深入阅读路径

  • 各板块完整 autodoc 参考:见 docs/python_api/renderdoc/ 目录下全部.rst文件(含 capturing.rst、replay.rst、outputs.rst、analysis.rst、shaders.rst、structured_data.rst 等)。
  • 入门与 UI 扩展: docs/python_api/first_steps.rst、docs/python_api/ui_extensions.rst、docs/python_api/ide_integration.rst、docs/python_api/faq.rst,以及 examples/ 与 in_depth/ 中的示例与深度主题。
  • UI 侧接口: docs/python_api/qrenderdoc/index.rst。
  • 构建与依赖: docs/CONTRIBUTING/Compiling.md、docs/CONTRIBUTING/Dependencies.md,Python 模块的独立加载细节见 docs/python_api/python_module.rst。

简而言之,renderdoc模块的 API 参考以十二大板块完整覆盖了从捕获、回放、输出到分析、着色器与统计的全链路能力;无论是编写一次性分析脚本、长期运行的自动化测试,还是在 UI 中做个性化扩展,都可以从本文的板块导航出发,直接进入对应参考页查阅由 autodoc 生成的最新签名与成员说明。

  • 开发工具
  • 调试器
  • 图形学
  • GPU

【免费下载链接】renderdoc

RenderDoc is a stand-alone graphics debugging tool.

项目地址:https://gitcode.com/gh_mirrors/re/renderdoc
点击查看免费下载

相关推荐

上一篇:Transformer模型可解释性:如何理解AI决策的完整方法指南
下一篇:Terraform-docs插件开发实战:打造自定义输出格式

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/24 15:01:43

Flowable 监听器使用指南

Flowable 监听器使用指南 在 Flowable 流程引擎中,监听器(Listener)是扩展流程行为的核心机制之一。它允许开发者在流程执行的特定时刻插入自定义逻辑,而无需修改 BPMN 流程图本身。Flowable 主要提供两种监听器:执行监…

作者头像 李华