Skip to content

Pair AiArrayMapConst with AiArrayUnmapConst in prim writer#2660

Merged
sebastienblor merged 1 commit into
masterfrom
kikou/fix-array-unmap-const-mismatch
May 25, 2026
Merged

Pair AiArrayMapConst with AiArrayUnmapConst in prim writer#2660
sebastienblor merged 1 commit into
masterfrom
kikou/fix-array-unmap-const-mismatch

Conversation

@kikou
Copy link
Copy Markdown
Collaborator

@kikou kikou commented May 22, 2026

Summary

  • In UsdArnoldPrimWriter::_WriteArnoldParameters, the per-type branches read array data via AiArrayMapConst(array) but seven branches unmapped it with the non-const AiArrayUnmap(array): AI_TYPE_BYTE, AI_TYPE_BOOLEAN, AI_TYPE_RGB, AI_TYPE_VECTOR, AI_TYPE_RGBA, AI_TYPE_VECTOR2, AI_TYPE_MATRIX.
  • The remaining branches (AI_TYPE_INT, AI_TYPE_UINT, AI_TYPE_FLOAT) already used the matching AiArrayUnmapConst.
  • Mismatching the const / non-const pair flags the array as modified even though it was only read, which can trigger spurious copies or write-backs on shared array data.
  • Switched the seven mismatched sites to AiArrayUnmapConst. The only remaining non-const AiArrayMap/AiArrayUnmap pair in the file (the shidxs write site) is unchanged.

Test plan

  • Export a scene that exercises the affected attribute types (byte/bool/rgb/vec/rgba/vec2/matrix arrays — e.g. instance visibility, color/normal/uv arrays, instance matrices) via the USD writer and confirm the written values match what's written today.
  • No new warnings/asserts from the Arnold core around array map/unmap.

UsdArnoldPrimWriter::_WriteArnoldParameters mapped array data with
AiArrayMapConst but unmapped seven of the type branches with the
non-const AiArrayUnmap (AI_TYPE_BYTE, BOOLEAN, RGB, VECTOR, RGBA,
VECTOR2, MATRIX). The remaining type branches already used the
const variant.

Mismatching the const/non-const map+unmap pair flags the array as
modified even though it was only read, which can trigger spurious
copies / writebacks.
@sebastienblor sebastienblor merged commit dd9d814 into master May 25, 2026
9 checks passed
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.

2 participants