Repository navigation
fix(anari_vsr): honor KHR_INSTANCE_TRANSFORM_ARRAY instead of crashing - #33
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The VSR device advertises
KHR_INSTANCE_TRANSFORM_ARRAY(its queries come fromexperimental_device.json), but an instance whosetransformis an array crashed invsr_device::Instance::finalize()duringanariRenderFrame.Instanceread the parameter withgetParamObject<helium::Array1D>. helium only checks the type tag, which isANARI_ARRAY1D, so the check passes. But the device's non-object arrays arevsr_device::Array, which derives fromhelium::BaseArraydirectly.finalize()then calledtotalSize()andbeginAs()on an object of the wrong type. Even without the crash,World::updateLayer()only usedinst->xfm(), so only the first transform would have been rendered.Fix
Instancereadstransformas avsr_device::Arrayand copies the matrices out of the underlyingvsr::scene::Arrayinfinalize(). If the array isn't anARRAY1DofFLOAT32_MAT4, it warns and falls back to the singlemat4. The unused inverse-transform copy is gone.Arraygets avsrArray()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
vsrlibrary with the helide backend, and queries the world'sbounds:There's no in-repo test, since nothing in
src/testsexercisesanari_vsryet. A test would need the device linked intovsrTestsand gating onVSR_TEST_WITH_HELIDE.Not changed
World::updateLayer()still callsinst->group()without checking it, so an instance with nogroupwill still crash there.