Skip to content

feat(io): import ANARI Captures from the ANARI-SDK capture device - #26

Merged
jeffamstutz merged 3 commits into
mainfrom
anari_capture_io
Nov 6, 2026
Merged

jeffamstutz merged 3 commits into
mainfrom
anari_capture_io

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

Summary

Adds import_ANARI_CAPTURE(), which loads an ANARI Capture, the text snapshot the ANARI-SDK capture device writes at each render, into a VSR scene. When an application's capture-based integration test fails, you can open the capture in vsrViewer and look at the scene, rather than only reading a text diff.

  • Reads capture format versions 1 and 2, as documented in the SDK's src/devices/capture/README.md. Any other version is rejected with a clear error.
  • The world's instances become transform nodes under a node named after the file. Transform arrays become transform-array nodes, and other instance parameters stay on the node. Each group's surfaces, volumes and lights sit underneath, and instances of the same group share one set of objects.
  • The camera is added to the camera pool. It isn't made active; pick it from the viewport's Camera menu, as with PBRT imports.
  • The renderer, the frame's parameters and the version-2 API call counts are reported, not applied.
  • Objects keep VSR's seeded default parameters so they still show in the editor, but only the parameters the capture set are enabled. A device sees exactly what the application committed.
  • Anything VSR can't hold is listed in the Import Report and logged, with its path in the SDK capture diff's syntax. The rest of the file still imports. This covers pointer and callback values, motion (the first pose is kept), and missing or wrong-size blobs.
  • Arrays that name the same blob share one VSR Array.
  • Ways to select it:
    • -anari_capture on the command line;
    • ANARI_CAPTURE in the import dialog;
    • --importer anari-capture in vsrRender, which also picks it automatically for a .capture file.

Vela reads the format itself. It doesn't replay the file through anari_vsr or link the SDK's diff library; ADR 0052 explains why. anari_vsr is unchanged.

Other changes:

  • The half-float conversions move from DataTreeText.cpp into vsr/core/HalfFloat.hpp, so the capture reader can decode FLOAT16 values.
  • New glossary terms ANARI Capture and Blob in src/vsr/io/CONTEXT.md.

Test plan

  • vsr::AnariCaptureImport passes. It has 11 scenarios over hand-written captures:
    • the README example;
    • rejected input;
    • shared groups and transform arrays;
    • bad and shared blobs;
    • unknown, opaque, fixed-point and FLOAT16 values;
    • motion instances;
    • the version-2 call counts;
    • object-array slots;
    • pool growth.
  • Six real version-2 captures (a 15-surface chess scene, 776 MB of blobs) import with nothing dropped and render with vsrRender.
  • The same captures load in vsrViewer.
  • The full ctest suite passes except for vsr::RenderTools, which also fails without this change: the installed vsrRender can't find libosdCPU.so on the local machine. vsr::ImageImport and the Studio suites each failed once when the suite ran in parallel and passed on a rerun.

An ANARI Capture is the text record the SDK's `capture` device writes at a
render: the committed state of every object the frame can reach, with large
arrays in content-named blobs beside it. import_ANARI_CAPTURE() reads one
(format versions 1 and 2) into a scene, so a failed integration test leaves
something to browse in vsrViewer rather than only a text diff.

The world's instances become transform nodes under a node named for the
file, with their groups' surfaces, volumes and lights beneath; instances of
one group share its objects. The camera joins the camera pool. The renderer,
frame parameters and the version-2 call counts are reported, not applied.
Objects keep VSR's seeded default parameters for editors to show, but only
the captured ones are enabled, so a device sees exactly what the application
committed. What VSR cannot hold (opaque values, motion, bad blobs) is listed
in the Import Report under its capture-diff path and the rest still imports.

Vela reads the format itself rather than replaying through anari_vsr or
linking the SDK's diff library; see ADR 0052. Selected with -anari_capture,
the import dialog's ANARI_CAPTURE entry, or vsrRender's anari-capture
importer (a .capture extension picks it). The half-float conversions move to
vsr/core/HalfFloat.hpp so the reader can decode FLOAT16 values.
Review follow-ups to the ANARI Capture importer:

- An object array element VSR cannot hold now leaves an empty slot,
  reported at the element's own path, instead of dropping the whole array
  and orphaning the elements already imported.
- A null element in a world's or group's surface, volume, light or
  instance list is an empty slot the format allows, not something dropped,
  so it is no longer reported.
- An object ID must be <label>@<n> with a label the format defines, since
  the format treats unknown lines as errors.
- The parsed text is CaptureText, so "capture" is never used unqualified.
Importing a real ANARI Capture crashed vsrViewer. Scene pools store objects
by value and move them as they grow, but the importer cached raw Object and
Array pointers by capture ID, and held a reference to the object whose
parameters it was setting while importing what those parameters refer to.
Any capture big enough to grow a pool then dereferenced freed memory on its
second reference to an object, as the first geometry with a shared array
did in a 15-surface scene.

Arrays are now held as ArrayRef. Scene objects, which the importer creates
type-erased, are held as the type and pool index a Parameter would hold,
and looked up again after anything that could create objects.
@jeffamstutz
jeffamstutz merged commit 4c7bc56 into main Nov 6, 2026
12 checks passed
@jeffamstutz
jeffamstutz deleted the anari_capture_io branch November 6, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant