Skip to content

fix(anari_vsr): honor KHR_INSTANCE_TRANSFORM_ARRAY instead of crashing - #33

Merged
jeffamstutz merged 1 commit into
mainfrom
fix/anari_vsr_instance_transform_array
Nov 18, 2026
Merged

jeffamstutz merged 1 commit into
mainfrom
fix/anari_vsr_instance_transform_array

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

Problem

The VSR device advertises KHR_INSTANCE_TRANSFORM_ARRAY (its queries come from experimental_device.json), but an instance whose transform is an array crashed in vsr_device::Instance::finalize() during anariRenderFrame.

Instance read the parameter with getParamObject<helium::Array1D>. helium only checks the type tag, which is ANARI_ARRAY1D, so the check passes. But the device's non-object arrays are vsr_device::Array, which derives from helium::BaseArray directly. finalize() then called totalSize() and beginAs() on an object of the wrong type. Even without the crash, World::updateLayer() only used inst->xfm(), so only the first transform would have been rendered.

Fix

  • Instance reads transform as a vsr_device::Array and copies the matrices out of the underlying vsr::scene::Array in finalize(). If the array isn't an ARRAY1D of FLOAT32_MAT4, it warns and falls back to the single mat4. The unused inverse-transform copy is gone.
  • Array gets a vsrArray() accessor for this.
  • World::updateLayer() adds one transform node per matrix, each holding the group's objects, so every copy is rendered and recorded in the live capture.

Testing

A standalone program builds one instance with three translated copies of a triangle, renders a frame through the vsr library with the helide backend, and queries the world's bounds:

  • before: segfault (exit 139)
  • after: bounds (0,0,0)–(21,1,0), which covers all three copies

There's no in-repo test, since nothing in src/tests exercises anari_vsr yet. A test would need the device linked into vsrTests and gating on VSR_TEST_WITH_HELIDE.

Not changed

World::updateLayer() still calls inst->group() without checking it, so an instance with no group will still crash there.

The device advertises KHR_INSTANCE_TRANSFORM_ARRAY, but an instance whose
"transform" is an array crashed in Instance::finalize() during
anariRenderFrame. Instance read the parameter as a helium::Array1D, whose
type tag (ANARI_ARRAY1D) matches, but the device's arrays are
vsr_device::Array, which derives from helium::BaseArray directly, so the
object was used as the wrong type.

Instance now reads "transform" as a vsr_device::Array and copies the
matrices out of the underlying vsr::scene::Array at finalize, warning and
falling back to the single mat4 if the array is not an ARRAY1D of
FLOAT32_MAT4. World::updateLayer() adds one transform node per matrix, so
every instance is rendered and recorded in the live capture rather than
only the first. The unused inverse-transform copy is dropped.
@jeffamstutz
jeffamstutz merged commit 68f78fd into main Nov 18, 2026
13 checks passed
@jeffamstutz
jeffamstutz deleted the fix/anari_vsr_instance_transform_array branch November 18, 2026 22:20
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