Choosing an API#
Several ovstage calls reach the same data by different routes. This page compares them by the inputs you have and the result you need. The semantics of each call live in the Queries, Writing Attributes, and Reading Attributes pages; Limitations and Current Behavior lists the behaviors that can change between releases.
Writing Values#
Call |
Use when |
Avoid when |
Usage notes |
|---|---|---|---|
|
You already hold the values in an array. You need |
You generate every value in place for the whole query and want to skip your own buffer (see |
Keep input data valid and unchanged until the operation completes. |
|
Several attributes change in one step, or you create prims with several attributes at once. |
You need all-or-nothing results. Validation is all-or-nothing, but execution is not. |
One operation writes multiple entries. If a later entry fails during execution, earlier entries stay written at the submitted ordinal, and the failed entry may leave data visible to a |
|
You compute values on the CPU for every prim in the query and can write them straight into an ovstage-owned CPU buffer. |
Only some prims change; the values already live in a NumPy, Warp, or Torch array; the source is on the GPU. |
There is no |
In Python, a with block around a ovstage.Map calls unmap on exit, including when an exception is propagating, so a half-filled buffer can be committed. Fill and verify before leaving the block.
Both write forms need an ordinal above the attribute’s watermark (write floor in the API) and an ovstage.Stage.advance_write_floor() before readers can see the data. See ovstage Overview.
Addressing Rows and Prims#
These options apply to write_attribute (and each write_attributes entry). index_map selects source rows; mask and count select target prims.
Option |
Use when |
Avoid when |
Usage notes |
|---|---|---|---|
Dense (no option; one source row per query prim) |
Every prim in the query gets its own value. |
Only a few prims change. |
Supply one source row per target prim. CPU and CUDA source tensors are supported. |
|
Several prims share a row, or rows must be reordered. The payload may hold fewer rows than prims. |
You want to choose which prims are written; |
Python defaults |
|
A subset of a query changes and the values are already positioned per prim. |
You want to save bandwidth: the payload still carries a row for every prim up to |
Reduces the write set, not the payload. In C, supply at least |
|
Only the leading |
The query comes from a filter. Filter-query order is unspecified, so “leading” has no useful meaning there. |
Meaningful for |
Smaller query |
The same subset changes repeatedly. |
The subset changes shape every frame. |
Build a |
Reading Values#
The table describes the default history_latest implementation. Retaining
earlier values requires experimental Earlier Values of Selected Pairs.
Read form |
Use when |
Avoid when |
Usage notes |
|---|---|---|---|
Latest read |
You need current values for the selected prims. |
You need only what changed since your last read. |
Returns the latest committed payload; the end ordinal does not select an older value. Fails with |
Ordinal-range read |
A consumer wants to know which prims and attributes changed in an interval, and then wants their current values. Changes are sparse. |
You need the value as of an old ordinal. Reads do not provide arbitrary historical values. |
Selects changed (prim, attribute) pairs in the inclusive interval, then returns their latest payload or a deletion marker ( |
Use a latest read for current derived metadata (usd-path, usd-parent,
and usd-children). Range reads of usd-parent and usd-children return
no groups; usd-path range reads can return whole-prim deletion tombstones
and require sealing through the range end. See Reading Built-in Metadata.
A consumer that must see attribute deletions also needs a range read; a latest
read of a deleted attribute returns nothing for those prims.
Selecting Prims#
Call |
Use when |
Avoid when |
Usage notes |
|---|---|---|---|
|
The set is defined by stage state: prim type, applied schema, subtree, or has-attribute. |
You already know the paths, or the prims do not exist yet. A filter cannot match absent prims. You need value comparisons ( |
Membership is a snapshot taken when the query runs. Order is unspecified. |
|
You hold the path list, you need a stable order, you will upsert prims that do not exist yet, or you want a subset of an earlier query. |
You want ovstage to discover the prims for you. |
Synchronous. Keep the path list valid while using the query. Existence is not checked. Only paths from this instance’s path dictionary are accepted. |
Release queries you no longer use.
Getting Data In#
Approach |
Use when |
Avoid when |
Usage notes |
|---|---|---|---|
Author directly ( |
The application or simulation already owns the data, or it creates prims that have no USD source. |
You want USD composition, references, and time samples resolved for you. |
You control ordinals and the layout of every column. |
Populate from USD ( |
You start from a USD scene and a consumer needs its prims and values. Population selects composed values at one time; it does not copy layers. |
You need history or multiple USD times in memory at once. |
Wait for population with its population-specific wait function. Population does not advance the watermark; do that yourself after the population operation completes. Provisional API; see Population (USD → ovstage). |
Add or remove a USD reference |
You grow or shrink the USD source after the first load. |
You have not opened a scene yet. |
Edits the USD source only; call |
|
USD edits happened after population (authoring, references). |
You only advanced time. |
Do not share its ordinal with |
|
Time-sampled USD values must be re-sampled at a new time. |
The scene has few time-varying values and you drive them yourself. |
Rewrites every in-scope time-varying property on each call, even when the time is unchanged. |
Values written by either route are ordinary stage data. Runtime writes do not edit USD layers, and a type conflict between populated and application-written data for the same attribute fails the write. Use Exporting ovstage to USD for the reverse direction.
Tracking Changes with Several Consumers#
Each consumer keeps its own cursor (the last ordinal it has processed) and asks for what changed since.
Complete and check every producer write for the update, repairing any failure before continuing. Advance the watermark and check its completion (producers, or the application on their behalf). See Recovering from a Failed Write.
Read the current watermark with
ovstage.Stage.get_attribute_write_floor(). PassingNonereturns the global value, the global watermark (global write floorin the API).Read the change range
(last, watermark], which isOrdinalRange.between(last + 1, watermark)in Python, and consume the groups.Release the groups, then store
watermarkas the new cursor.
Before step 3, compare last + 1 with ovstage.Stage.get_oldest_preserved_ordinal(). If the cursor is older, the consumer has fallen behind: change membership for that interval may have been combined or discarded. Do a full latest read to resynchronize, then resume range reads.
If a range read fails with ErrorCode.OUT_OF_RANGE, a selected pair changed again after your end ordinal. Retry with a later end ordinal that the watermark has reached, or resynchronize with a latest read.
See When to Use a Change-Range Read for the cursor pattern and a tested example in C and Python.
Two points apply to every consumer:
While you hold a read group, writes, maps, and deletes that overlap its (attribute, prim) set fail with
ErrorCode.OP_FAILED, and so does any operation, including a clone, that would giveomni:fabric:worldMatrixto a prim the group covers: a hierarchy parent or ancestor of the operation’s prims, or a prim with a transform input between one of them and a descendant that carries it (see Transforms). A slow consumer therefore holds up producers. Copy what you need and release promptly.A read that overlaps an unfinished write or open map on the same data also fails. Order the steps: write, wait, advance the watermark, wait, then read.
The watermark does not retain a step for a consumer that falls behind; see ovstage Overview.
C and Python#
Both languages expose the same operations. Python wraps the C API; it adds convenience but no separate capabilities. Differences to expect:
Topic |
C |
Python |
|---|---|---|
Operation results |
Each enqueue returns a status and an |
|
Handles |
Release query, read, group, map, and ordinal-query handles explicitly. |
|
Population |
Enqueue returns a population operation id; wait with |
|
Write inputs |
Tensors or managed tensors ( |
NumPy arrays, DLPack producers, or |
Ranges |
|
|
|
|
Defaults to the full query, or to |
Errors |
Status codes and |
|
Data layout, ordinals, watermarks, and the limits in Limitations and Current Behavior are identical. For blocking rules and handle lifetime across threads, see Threading, Blocking, and Lifetime.