Reading Render Output
When to Use
Use this skill when the user asks to get pixels, read an image, save a PNG, display rendered output, or access render var data.
Inputs
Resolve inputs in this order: existing repository files and referenced snippets, explicit user request, then broader agent context.
- Target API surface: Python, C/C++, USD, or a combination.
- RenderProduct path, a unique returned prim name (Python), full RenderVar prim path or reserved synthetic output name, and whether the output is single-tensor or composite.
- Mapping target: CPU pixels, linear CUDA tensor, or C CUDA array mapping.
- Image/tensor shape, dtype, channel order, synchronization requirements, and whether the data must outlive the mapping.
- Repository source snippets referenced below. Treat these snippets as the API source of truth.
Prerequisites
- Use an ovrtx checkout that contains the referenced examples and docs tests.
- Read the relevant
> **Source:**snippet before writing or explaining API usage. - Confirm the RenderProduct already requests the desired RenderVar; use
camera-outputs-rt2when the question is which camera output to add. - Use
reading-sensor-pointcloudsfor lidar/radarPointCloudcomposite tensors.
Instructions
- Identify the RenderProduct path, RenderVar key (a unique returned prim name or full path in Python), target device, and whether the caller needs CPU pixels, CUDA tensors, or CUDA arrays.
- Read the matching map/unmap snippet before choosing Python
frame.render_vars[...]access or Covrtx_map_render_var_output(). - Preserve dtype, shape, channel order, and ownership rules for the selected output.
- Always unmap C outputs, and keep CUDA synchronization aligned with the CUDA interop skill when reading on GPU.
- When changing code, run the camera sensor or minimal example snippet that owns the readback path whenever practical.
Output Format
- For explanations, cite the relevant API names, source snippets, and caveats.
- For code changes, summarize the files changed, snippets affected, and validation run.
Scripts
This skill has no scripts.
Limitations
- The referenced snippets remain the source of truth; update or add tested snippets before documenting new API usage.
Overview
This skill is the hands-on counterpart to the conceptual reference at docs/sensors/common/sensor_outputs.rst, which describes what a render variable output is and how its tensors and params are laid out. Use this skill for how to map and read one; use the conceptual page when the question is about what the structure carries or why it is shaped the way it is.
After stepping the renderer and fetching results, each RenderVarOutput is identified by its full RenderVar prim path (for example /Render/Camera/LdrColor) and must be mapped to access its data. Python frame.render_vars also accepts a prim name unique among the outputs returned in that RenderProduct's frame. This is the final path component, not source_name. Ambiguous indexing raises KeyError; get returns its default and containment is false. Missing outputs remain missing. Exact full paths and reserved synthetic names take precedence.
Short-name lookup scans the current returned dictionary keys on demand; configured targets that produced no output do not count toward ambiguity. It returns the same output object as full-path lookup. Continue using render_var_path for identity and application maps; dictionary iteration, counts and mutations retain exact canonical keys. Adding or removing canonical entries updates name resolution. Later scene edits do not change an earlier result's returned keys, including when fetched later. Lookup uses the existing released native API with no extra capability requirement. The C API enumerates full-path outputs and maps handles.
A rendered frame has an output for every RenderVar the RenderProduct lists (a DLSS-G interpolated frame has outputs only for its color RenderVars), including one OVRTX could not produce, such as a RenderVar with an invalid ovrtx:compression:* setting or an unsupported sensor sourceName. Check its status before mapping: such an output has status EventStatus.FAILURE (C: OVRTX_EVENT_FAILURE in ovrtx_render_product_render_var_output_t::status) and says why in error_message, and mapping it fails with that message. The RenderProduct's other outputs are unaffected.
A render variable carries zero or more named tensors and zero or more named params.
For a single-tensor render variable, consume the mapping directly with DLPack;
address individual tensors by name and read params independently through params.
CameraParams has no tensors and 23 CPU params, so read its params without indexing a tensor or
passing the mapping itself to DLPack. Its scalar params, and those of
InstanceIdTokenMapSD and point-cloud outputs, use shape (1,).
Inspect each descriptor's shape. Both tensors and params expose the DLPack protocol
for zero-copy access by compatible consumers and devices. The snippets below copy
the arrays so they remain usable after the mapping is released.
Source (single-tensor readback):
tests/docs/python/test_camera_aovs.pysnippetdoc-sd-map-image-python.
Source (named tensors and CPU params):
tests/docs/python/test_camera_aovs.pysnippetdoc-sd-map-structured-python.
Source (parameter-only output):
tests/docs/python/test_camera_aovs.pysnippetdoc-sd-camera-python.
- In Python, render-var mapping supports
device=Device.CPU,device=Device.CUDA, anddevice=Device.CUDA_ARRAY(fromfrom ovrtx import Device). Device.CUDA_ARRAY/OVRTX_MAP_DEVICE_TYPE_CUDA_ARRAYis the zero-copy image path. It yields an opaque CUDA array handle rather than readable memory, so it is outside the DLPack workflow described here — see thecuda-interopskill.
After reading/processing, unmap to release the mapped buffer.
Python
Map to CPU and read as NumPy
Source:
examples/python/minimal/main.pysnippetread-render-output
Save as PNG with Pillow
Source:
tests/docs/python/test_camera_sensors.pysnippetdoc-step-and-map-camera-outputs
Source (save-to-PNG example):
examples/python/projectors/main.pysnippetprojectors-save-png
Record Path Tracing LPE outputs with Rerun
Source:
examples/python/lpes/main.pysnippetdoc-read-lpe-outputs
Copy composite Generic WPM contributions and filter valid slots
Source:
examples/python/generic-wpm/main.pysnippetsdoc-generic-wpm-copy-contributions,doc-generic-wpm-read-output
Map to CUDA for GPU processing
Source:
tests/docs/python/test_camera_sensors.pysnippetdoc-map-render-output-cuda
C
Map to CPU
Source:
examples/c/minimal/main.cppsnippetmap-rendered-output-cpu
Copy composite Generic WPM contributions and filter valid slots
Source:
examples/c/generic-wpm/main.cppsnippetsdoc-generic-wpm-read-output-c,doc-generic-wpm-valid-slots-c
Map to linear CUDA memory
Source:
tests/docs/c/test_camera_sensors.cppsnippetdoc-map-render-output-cuda-c
Map to CUDA array (zero-copy)
Source:
tests/docs/c/test_camera_sensors.cppsnippetdoc-map-render-output-cuda-array-c
Find a specific render var in C
This helper is not part of the ovrtx API; define it in your own code (see examples/c/minimal/main.cpp):
Source:
examples/c/minimal/main.cppsnippetfind-output-helper
The minimal example's helper searches every RenderProduct and frame and returns
the first matching RenderVar. It does not let the caller select a frame. When a
product can return several frames, select the intended product and frame before
looking up its RenderVar; otherwise the helper can return an earlier exposure or
an interpolated frame. See dlss-frame-generation for selecting interpolated and
simulated frames.
Key Types / Functions
| Python | C |
|--------|---|
| rv = render_var.map(device=Device.CPU) | ovrtx_map_render_var_output(renderer, handle, &desc, timeout, &output) |
| np.from_dlpack(rv) (single-tensor) | *rendered_output.tensors[0].dl (DLTensor) |
| np.from_dlpack(rv["TensorName"]) (multi-tensor) | iterate rendered_output.tensors[i] |
| np.from_dlpack(rv.params["paramName"]) | iterate rendered_output.params[i] |
| last DLPack consumer dropping the tensor | ovrtx_unmap_render_var_output(renderer, map_handle, sync) |
| rv.unmap(stream=...) | ovrtx_unmap_render_var_output with cuda_sync.stream / cuda_sync.wait_event |
Device types (Python: from ovrtx import Device; C: OVRTX_MAP_DEVICE_TYPE_*):
Device.CPU-- read back to host memory (sync + copy)Device.CUDA-- linear CUDA device memory (may copy)Device.CUDA_ARRAY-- zero-copy for image outputs; an opaque CUDA array handle, not DLPack-readable. Readtensor.cuda_arrayand consume it with Warp 1.15+, CuPy, or your own CUDA wrapper (seecuda-interop)Device.DEFAULT-- auto-selects the most efficient format; returns a CUDA array for image outputs, avoiding an extra copy
Common render variables:
LdrColor-- single-tensor, RGBA uint8, sRGB color spaceHdrColor-- single-tensor, RGBA float16, linear color space- Render variables may also carry multiple tensors plus params (e.g. a point-cloud render variable producing
Coordinates+Intensitytensors alongsideframeId/hitCountparams); address those by name.
Troubleshooting
- Consumer owns lifetime. A mapping's C buffer stays alive for exactly as long as DLPack consumers (NumPy, Warp, etc.) reference it via
np.from_dlpack/wp.from_dlpack. Drop those views (viadel, rebind, or scope exit) to free the resource. If you need data beyond that, take an independent copy:np.from_dlpack(var).copy(). - Mind Python's deferred reclamation. A
MappedRenderVarand anyRenderVarTensor/RenderVarParam/ DLPack array minted from it stays alive in its local-variable slot until that name is rebound or the enclosing scope ends. Awithblock releases interest in the mapping (the C unmap fires once the last view is dropped), but the Python names can outlive thewith— most commonly the loop variable bound inside aforloop survives until the next iteration rebinds it, or until the loop exits. When you're done with a mapping but the owning name will outlive that interest,delit explicitly so renderer resources are reclaimed promptly instead of waiting on garbage collection. - Mapping lifetime is independent of the owning
productsobject. Droppingproducts(or its C-levelovrtx_destroy_results) does not invalidate live mappings — consumer references are what keep their buffers alive. - For
CUDA_ARRAYmapping, you must wait for the producer before accessing the data: in C, onrendered_output.cuda_sync.wait_event; in Python, viarv.wait()orrv.wait_on(stream). - For explicit CUDA sync in Python, call
var.unmap(stream=...)orvar.unmap(event=...)— these record the sync hint used when ovrtx reclaims the buffer.
References
- Use the
> **Source:**directives in this skill to locate tested snippets before reusing API patterns. - Keep related skills, docs, and snippets synchronized when changing the workflow.