ovstage Integration#

ovclash normally opens a USD stage file itself. An application that already owns a live ovstage Stage, such as a viewer or an editor, can lend that Stage to a clash context or a Suite API runtime instead, as an attached stage. ovclash then reads the Stage’s Default-time evaluation, the Stage evaluated at USD’s Default time code, which holds the values authored without time samples, as its owner populated it. Other times come from the owner, through a callback, or from ovclash itself: when the owner also describes how it composed the Stage, ovclash evaluates those times in private populations, ovstage instances of its own that it populates from the same sources, and never moves the owner’s Stage.

This page covers both halves of that arrangement:

  • the owner-operation gate, which every process that creates its own ovstage Stage next to clash contexts uses, with or without an attachment;

  • attaching a Stage: the binding descriptor, the two ways to evaluate time and the owner’s duties while clash operations use the Stage.

Everything here is an optional extension of the ovstage backend. Released wheels and SDK archives are ovstage builds; the unpublished reference build, which reads USD through OpenUSD instead, exports none of these symbols. Threading and Ownership has the general handle and lifetime rules.

The API at a glance#

For each task, the table names the C call on the canonical API, the C call on the Suite API and the Python call:

Task

C, canonical (<ovclash/ovclash_ovstage.h>)

C, Suite (<ovclash_suite/ovclash_suite_ovstage.h>)

Python

Run owner work under the gate

ovclash_ovstage_run_owner_operation()

ovclash_suite_run_ovstage_owner_operation()

ovclash_suite.run_ovstage_owner_operation(), for both packages

Borrow a Stage

ovclash_ovstage_attach_stage()

ovclash_suite_attach_ovstage()

attach_ovstage() on ovclash.ClashRuntime and ovclash_suite.ClashDetection

Stop borrowing it

ovclash_ovstage_detach_stage()

ovclash_suite_detach_ovstage()

detach_ovstage() on both classes

Select the matrix decomposition

ovclash_ovstage_set_matrix_decomposition(), ovclash_ovstage_get_matrix_decomposition()

None

set_ovstage_matrix_decomposition(), get_ovstage_matrix_decomposition() on ovclash.ClashRuntime

C/C++ Quickstart shows how to build against these headers, and C API Conventions gives the status and string rules they follow.

Check the backend first#

Only the ovstage build of the library exports the ovclash_ovstage_* functions and the three functions of <ovclash_suite/ovclash_suite_ovstage.h>. A C program that loads the library at run time checks the backend before it resolves them. ovclash_get_backend_info() needs no context and is safe to call concurrently; Overview lists the four fields and the values that the released library reports. Add this function to the C source that loads the library, and call it before you resolve any ovclash_ovstage_* symbol.

#include <ovclash/ovclash.h>
#include <stdio.h>
#include <string.h>

/* Returns 1 for the ovstage build, which also exports the optional ovclash_ovstage_* symbols. */
static int is_ovstage_backend(void)
{
    ovclash_backend_info_t info;
    if (ovclash_get_backend_info(&info).status != OVCLASH_STATUS_SUCCESS)
    {
        return 0;
    }
    printf("backend: %.*s\n", (int)info.backend_name.length, info.backend_name.ptr);
    return info.backend_name.length == 7 && memcmp(info.backend_name.ptr, "ovstage", 7) == 0;
}

backend_name borrows a static, library-owned string; never free it. The call fails for a null pointer and, on ovstage, inside an owner operation.

In Python, ovclash.backend_info().backend_name and ovclash_suite.backend_info().backend_name report "ovstage". The Python methods on this page raise RuntimeError when the loaded library lacks the extension.

The owner-operation gate#

The ovstage backend serializes Stage creation, population, time evaluation and destruction across the whole process with one gate, the owner-operation gate. An application that owns its own ovstage Stage in a process that also has clash contexts runs that Stage work under the same gate, through one of the calls in The API at a glance.

Route this work through the gate:

  • Stage creation and destruction;

  • population and source edits;

  • inspection composition;

  • the renderer lifecycle: attach, step and detach.

The rules:

  • Lock order. Acquire the gate before any owner-local lock. An attached evaluate_time callback already holds it.

  • Synchronous and borrowed. The callback runs on the calling thread before the call returns. ovclash never retains the callback or its user data.

  • Nesting. Owner operations nest on one thread, up to 64 levels deep. Owner operations on different threads are serialized.

  • No reentry. Inside an owner operation, every guarded canonical entry point fails, destruction included, and so does every Suite function that returns ovclash_suite_result_t, even one that touches no runtime: data stores, models, export and utility helpers. The error text reads clash runtime reentry from an ovstage owner operation is prohibited.

  • What still works inside. Nested owner operations; the Suite last-error getters; ovclash_get_settings() and ovclash_get_last_error(); and the canonical version, result-string, DLPack tensor-view and ovclash_reset_* helpers. ovclash_get_backend_info() and ovclash_suite_get_backend_info() fail.

  • The gate is not a handle lock. It does not serialize calls on a clash context or runtime. Data-plane reads, which read the populated data of the ovstage Stage instance itself rather than its USD layers, and collision work do not take it.

In C, the callback returns 1 for success and any other value for failure, and it must not throw. The call succeeds when the callback returns 1. It fails for a null callback, a callback failure, excessive nesting or a native exception, and it releases the gate on every exit. Diagnostics of a failing callback remain the caller’s responsibility.

Add these two functions to the C source of the application that owns the Stage, and call run_owner_work() wherever that application creates, populates or destroys its Stage.

#include <ovclash/ovclash_ovstage.h>

typedef struct owner_state_t
{
    int rebuilds;
} owner_state_t;

/* Runs under the owner-operation gate. This example counts its runs; your callback makes the
 * ovstage calls that create, populate or destroy the application's own Stage instead.
 * It must not throw and must not call into a clash context or runtime. */
static int32_t rebuild_owner_stage(void* user_data)
{
    owner_state_t* state = (owner_state_t*)user_data;
    state->rebuilds += 1;
    return 1; /* 1 is success; any other value is a failure */
}

static int run_owner_work(owner_state_t* state)
{
    ovclash_result_t result = ovclash_ovstage_run_owner_operation(rebuild_owner_stage, state);
    return result.status == OVCLASH_STATUS_SUCCESS;
}

The gate in Python#

ovclash_suite.run_ovstage_owner_operation(operation, /, *args, **kwargs) calls operation(*args, **kwargs) under the gate. The gate is process-wide, so the same call also covers ovclash.ClashRuntime objects.

  • It returns the value of operation after it releases the gate.

  • An exception that operation raises is re-raised with its original traceback, after the gate is released.

  • It raises TypeError when operation is not callable, and RuntimeError when the library lacks the extension, when more than 64 operations nest, or when the native gate fails.

  • Inside the operation, the runtime wrappers of both packages raise RuntimeError before they change any Python state. Every other Suite call that reaches the native library fails too, ClashQuery and the other model helpers, data stores and exports included.

Close clash wrappers explicitly with destroy() or close(). A wrapper that Python garbage-collects inside an owner operation cannot release its native handle there. ovclash then keeps that wrapper, with its attachments and callbacks, until the ovclash-owner-finalizer thread has waited for the gate and run the cleanup outside it.

Note The gate also configures the reconnect window of the omni client, the client library through which the ovstage runtime reaches omniverse:// hosts. The first successful client discovery, through ovstage instance creation or this gate, reads OVCLASH_OMNI_CLIENT_RETRY_MAX_MS once per process; the policy also affects other users of that process-wide client. Environment variables describes the variable.

Attaching a Stage#

An attachment lends an already populated Stage to one context or runtime. ovclash never writes to the Stage, never evaluates it on its own and never destroys it. Several contexts may borrow the same Stage.

Default-time selection always reads the borrowed Stage. Finite times, such as the sample times of a dynamic query or the time of a static query, come from one of two sources:

Attachment

Binding

Finite times

Owner-evaluated

No composition

The owner publishes each time on its Stage, through the evaluate_time callback; see Time evaluation. ovclash opens no file and probes no file metadata.

Engine-evaluated

A composition

ovclash replays the owner’s composition into private ovstage populations and evaluates every finite time there. It never calls back into the owner and never advances the Stage; see Engine-evaluated time.

The binding descriptor#

ovclash_ovstage_binding_t carries the Stage and the metadata that the owner has resolved. Zero-initialize it, then set its fields and struct_size. The attach call copies the descriptor and borrows the Stage it names.

The descriptor names an evaluation of the Stage by its ordinal, ovstage’s sequence number of one sealed evaluation. The owner writes an evaluation at an ordinal and advances the Stage’s global write floor to it, which commits every ordinal up to the floor for reading; the Stage retains a window of recent ordinals, and an ordinal older than that window is no longer retained.

Field

C type

Required

Default or values

Meaning and rules

struct_size

uint64_t

Yes

sizeof(ovclash_ovstage_binding_t)

Two shorter sizes are also accepted: the size that ends right before capabilities means no capabilities and no composition, and the size that ends right before composition means no composition. Any other value is rejected.

stage

ovstage_instance_t*

Yes

The live Stage

Its instance bundle and version-query slot must be valid, and it must report the ovstage API major and minor version of the pinned ovstage that ovclash was built against.

committed_ordinal

uint64_t

Yes

Positive

The read ordinal of the Stage’s current evaluation. It must be retained and covered by the global write floor. With a composition, it must stay retained until the attachment ends.

time_seconds

double

Yes

Finite, or NaN for Default

The time of that evaluation, in seconds. Reads at this time use committed_ordinal without calling evaluate_time, so that publication must be as complete as one that evaluate_time makes. Must be NaN with a composition.

meters_per_unit

double

Yes

Finite and positive

The length of one stage unit, in meters. With a composition, it must equal the value that the composition resolves.

start_time_code, end_time_code

double

Yes

Finite

The timeline endpoints, in time codes.

time_codes_per_second, frames_per_second

double

Yes

Finite and positive

The stage’s rates. With a composition, time_codes_per_second must equal the rate that the composition resolves.

evaluate_time

ovclash_ovstage_evaluate_time_fn

No

Null

The time-evaluation callback; see Time evaluation. Must be null with a composition.

user_data

void*

No

Null

Passed to evaluate_time unchanged.

capabilities

uint64_t

No

0, or OVCLASH_OVSTAGE_CAP_AUTHORED_TRANSFORM_UPDATES

See Authored transform updates. Unknown bits are rejected, and a nonzero value requires evaluate_time. Must be zero with a composition.

composition

const ovclash_ovstage_composition_t*

No

Null

Null keeps the attachment owner-evaluated; a composition makes it engine-evaluated. See Engine-evaluated time.

ovclash_get_stage_timeline_data() and the Suite timeline getters report the four timeline fields of the binding. A minimal owner-evaluated C attachment of a Stage that holds its Default-time evaluation follows. Add the function to the owner’s C source, and call it with a context from ovclash_create_context() after the owner has populated the Stage and committed ordinal, in place of ovclash_open_stage():

#include <ovclash/ovclash_ovstage.h>
#include <math.h>
#include <string.h>

/* Lends the owner's populated Stage, sealed at `ordinal`, to one context. The metadata values
 * stand for the ones the owner resolved for its Stage. */
static int attach_owner_stage(ovclash_context_t* ctx, ovstage_instance_t* stage, uint64_t ordinal)
{
    ovclash_ovstage_binding_t binding;
    memset(&binding, 0, sizeof(binding));
    binding.struct_size = sizeof(binding);
    binding.stage = stage;
    binding.committed_ordinal = ordinal;
    binding.time_seconds = NAN; /* the Stage holds its Default-time evaluation */
    binding.meters_per_unit = 0.01;
    binding.start_time_code = 0.0;
    binding.end_time_code = 0.0;
    binding.time_codes_per_second = 24.0;
    binding.frames_per_second = 24.0;
    /* evaluate_time, user_data, capabilities and composition stay zero */
    return ovclash_ovstage_attach_stage(ctx, &binding).status == OVCLASH_STATUS_SUCCESS;
}

In Python, attach_ovstage(stage, committed_ordinal, **metadata) takes a live ovstage.Stage and fills the descriptor itself. The keyword arguments match the C fields, authored_transform_updates sets capabilities, and the three composition_* keywords fill the composition:

Argument

Type

Required

Default

Description

stage

ovstage.Stage

Yes, positional

None

The live Stage to borrow.

committed_ordinal

int

Yes, positional

None

A positive unsigned 64-bit ordinal; C field committed_ordinal.

time_seconds

float

No

NaN, the Default time

C field time_seconds.

meters_per_unit

float

No

0.01

C field meters_per_unit.

start_time_code, end_time_code

float

No

0.0

C fields of the same names.

time_codes_per_second, frames_per_second

float

No

24.0

C fields of the same names.

evaluate_time

Callable that takes the time in seconds and returns the new ordinal as an int, or None

No

None

C field evaluate_time; see Time evaluation.

authored_transform_updates

bool

No

False

True sets OVCLASH_OVSTAGE_CAP_AUTHORED_TRANSFORM_UPDATES in capabilities.

composition_root

str, a path-like object, or None

No

None, no composition

The exact path, URL or USDA text that the owner opened the Stage from. USDA is USD’s text format.

composition_layers

Sequence of str

No

()

The USDA texts of the owner’s root merges, earliest first.

composition_root_is_usda

bool

No

False

True when composition_root is USDA text.

It raises TypeError when stage is not a live ovstage.Stage, an argument has the wrong type or a keyword is unknown. composition_root must be a str or path-like object, and a str with composition_root_is_usda; composition_layers must be an ordered sequence that holds only str, not a str itself and not a set, whose iteration order would decide the layer strength. It raises ValueError when:

  • committed_ordinal is not a positive unsigned 64-bit integer;

  • authored_transform_updates is set without evaluate_time;

  • composition_layers or composition_root_is_usda is given without composition_root;

  • the root or a layer is empty or contains NUL;

  • composition_root is combined with evaluate_time, with authored_transform_updates=True or with a time_seconds other than NaN.

It raises RuntimeError when the extension is missing, an async handle, the handle of an async pipeline, is alive or the native attachment fails. The runtime keeps the encoded composition until the attachment ends, and passes a path-like root through os.fspath() without resolving it. Open the Stage from an absolute path or a URL and pass that string; Engine-evaluated time gives the reason.

What an attachment changes#

  • Scope and error text. A successful attachment, first or replacement, clears the scope, and on the canonical API the last error. Set the scope after you attach.

  • Results. A replacement attachment invalidates geometry, results and pipelines. In Python, ClashRuntime.attach_ovstage() also closes open overlap reports.

  • Full-scene traversal. A non-empty scope turns the engine’s full-scene traversal off.

    • Canonical: attaching does not turn it back on, as ovclash_open_stage() does not. Set a scope after attaching, or call ovclash_set_full_scene(context, true) for an unscoped run. Otherwise the run selects nothing.

    • Suite: a successful attachment turns it back on when the run settings in effect enable enable_full_scene. Those are the settings last applied with ovclash_suite_set_run_settings() or, before any apply, the defaults, which enable it.

  • Active work. Attaching is rejected while an async handle is alive, including a completed handle that is not yet released. The Suite API also rejects a live fetch, a fetch-and-save operation that has begun and is not yet destroyed.

  • Failure. A failed attachment keeps the previous attachment and scope.

ovclash reads the Stage as its owner populated it. For example, subcomponent filtering needs the composed kind values, the USD prim metadata that marks a prim as a subcomponent: when the owner’s population holds none, every mesh resolves to the empty root, and enabling the filter drops every pair. An engine-evaluated attachment reads kinds from the Stage too, not from its private populations.

Ending an attachment#

None of these calls destroys the Stage:

Surface

Calls that end the attachment

C, canonical

ovclash_ovstage_detach_stage(), ovclash_reset_context(), an ovclash_open_stage() call that passes argument validation, a replacement attachment, ovclash_release_context()

C, Suite

ovclash_suite_detach_ovstage(), ovclash_suite_reset_runtime(), ovclash_suite_open_stage(), a replacement attachment, ovclash_suite_destroy_runtime()

Python, ovclash.ClashRuntime

detach_ovstage(), reset(), another attachment, open_stage() with a non-empty path (even when the open then fails), destroy()

Python, ovclash_suite.ClashDetection

detach_ovstage(), reset(), another attachment, open_stage() or set_stage_path() with a non-empty path (even when the open then fails), destroy()

  • Ending an engine-evaluated attachment also destroys its private populations and drops its composition.

  • ovclash_release_memory() keeps the attachment, with its composition. It destroys the private populations of an engine-evaluated attachment, and the next finite-time read replays the composition again, unless a detected units or rate mismatch already fails it.

  • Detaching invalidates results and pipelines, and ovclash_ovstage_detach_stage() also clears the last error. Detaching is rejected while an async handle, or on the Suite API a fetch, is alive.

  • ovclash_ovstage_detach_stage() on a context without an attachment also succeeds. It still clears the results and forgets a stage opened with ovclash_open_stage().

  • An attached Stage has no stored path. After a reset, attach it again before the next run.

Time evaluation#

An owner-evaluated attachment, one without a composition, reads every time from the Stage. evaluate_time(user_data, seconds, &ordinal, &error) asks the owner to evaluate the Stage at a time in seconds. NaN means the Default time. ovclash never calls it for an attachment with a composition.

  • Success. Before it returns 1, the callback publishes the complete sampled canonical local transforms and reset-stack opinions, the resetXformStack flags that stop a prim from inheriting its parent’s transform. That includes invisible instance placements, the transforms of hidden instances, and prototype operands, the prims inside the prototypes that instances share. The callback then seals a new ordinal. It writes that ordinal to ordinal. Each new ordinal must be greater than the previous one and fit the ordinal type of the ovstage implementation.

  • Failure. Any other return value, conventionally 0, fails the evaluation. The callback may set error to a UTF-8 diagnostic, which must stay valid until the enclosing ovclash call returns. That text becomes the clash error.

  • Thread. The callback runs on the pipeline thread, which can be a native worker. It runs as an owner operation: the thread already holds the gate, nested owner operations are allowed, and owner locks come after the gate. It must not throw or enter a clash runtime. It must never wait for another thread that takes the gate, because that deadlocks.

  • Serialization. One context invokes its callback serially. The owner serializes callbacks and every external use of a Stage that several contexts share.

Without a callback, only the evaluation in the descriptor is available. A read at time_seconds, and a Default-time selection, use that frozen snapshot. Any other time fails, so a dynamic query on such an attachment needs evaluate_time.

In Python, evaluate_time(seconds) returns the new ordinal as an int. An exception it raises, or an ordinal that is not a positive unsigned 64-bit integer, fails the evaluation with the exception text as the error.

Engine-evaluated time#

A composition tells ovclash how the owner built its Stage’s USD source, so that ovclash can evaluate time itself. A dynamic query then never republishes the owner’s Stage and never moves the time that the owner renders. Set composition in the binding to an ovclash_ovstage_composition_t, or pass the composition_* keywords in Python. The attach call copies the composition and every string it names.

Field

C type

Required

Default or values

Meaning and rules

struct_size

uint64_t

Yes

sizeof(ovclash_ovstage_composition_t)

Any other value is rejected.

root

ovclash_string_t

Yes

Non-empty UTF-8

The exact string that the owner opened its USD source from: the path or omniverse:// URL it passed to ovstage_population_open_usd_from_file or ovstage_population_open_usd_from_file_with_desc (Python open_usd or open_usd_with_desc), or the USDA text it passed to ovstage_population_open_usd_from_string or ovstage_population_open_usd_from_string_with_desc (Python open_usd_from_string or open_usd_from_string_with_desc). The replay does not depend on which of them the owner called. ovclash passes the string to ovstage unchanged and never resolves it, so a relative path resolves against the process working directory at each replay.

root_kind

uint32_t

Yes

OVCLASH_OVSTAGE_COMPOSITION_ROOT_FILE (0) or OVCLASH_OVSTAGE_COMPOSITION_ROOT_USDA (1)

OVCLASH_OVSTAGE_COMPOSITION_ROOT_FILE for a path or URL, OVCLASH_OVSTAGE_COMPOSITION_ROOT_USDA for USDA text. Any other value is rejected.

nb_layers

uint32_t

Yes

0 or more

The number of entries in layers.

layers

const ovclash_string_t*

When nb_layers is not 0

Null when nb_layers is 0

The USDA texts of the owner’s surviving ovstage_population_add_usd_reference_from_string(stage, text, "/") merges, in the order the owner added them, earliest first. Leave out a merge that the owner removed, for example to mute it. May be null only when nb_layers is 0.

root and every layer are non-empty UTF-8 without an embedded NUL. The binding must also set time_seconds to NaN, because the Stage holds its Default-time evaluation at committed_ordinal, and leave evaluate_time null and capabilities zero, so no owner callback ever runs. Attaching fails otherwise.

Each read has one source:

Read

Source

Default selection, mesh geometry, visibility and subcomponent kinds

The Stage at committed_ordinal

Immediate depth and depenetration queries, and matrix queries at the Default time

The Stage at committed_ordinal

Units and the timeline

The binding

Transforms at every sample time, and at the time of a static query

A private population of the composition

Static and dynamic classification, which enables static-pair pruning: the purge of permanent static overlaps, which drops pairs of two transform-static meshes

A private population of the composition

Matrix prefetch, and matrix queries at finite time codes

A private population of the composition

How ovclash replays a composition:

  • It makes the same population calls with the same strings in the same order, into ovstage instances of its own: it opens the root, merges each layer at /, and then populates only what it reads. The strength order of the layers, where a later merge is stronger, and the anchoring of the inline layers therefore follow the owner’s.

  • It replays under the owner-operation gate, first at the first finite-time read. A classification population lasts for one classification. The transform population lasts until the attachment ends or ovclash_release_memory(); a read at an earlier time than the last one replays it again, as a file-backed stage reopens its file.

  • At the first finite-time read it compares the composed metersPerUnit and timeCodesPerSecond with the binding. When the stage reports a rate of 24 together with another framesPerSecond, an authored 24 and an absent rate look alike. Either value is then accepted for sampling, which works in seconds, and the first matrix query by time code first resolves the rate from the root alone.

  • A composition that ovstage cannot replay, or metadata that differs from the binding, fails that first finite-time read with one of the texts in Messages. Attaching does not open the root.

  • A detected metersPerUnit or timeCodesPerSecond mismatch fails every later finite-time read and classification on that attachment with the same message, without replaying again, also after ovclash_release_memory(), until the next attach. Once a matrix query by time code disproves an ambiguous rate, later sampling reads and classifications fail too. A replay failure that ovstage reports is not remembered, and the next finite-time read replays again.

The owner’s contract:

  • At every finite time, the canonical local transforms and reset-stack opinions of the Stage equal those of a fresh population of the composition. ovclash cannot verify this. A stale or missing layer gives wrong finite-time poses without an error; a structural difference, such as an instance root that only one of the two makes instanceable, fails the run.

  • A transform that the owner writes only into the data plane, outside its USD layers, is therefore seen by Default selection and by no finite-time read. A composition cannot express references at other target paths or file references either. An owner that relies on any of them at finite times attaches without a composition and evaluates time itself.

  • The root file and every file that the root or a layer references stay unchanged on disk until the attachment ends. ovclash reopens the root by its string at every replay, including the first finite-time read, the next finite-time read after a failed replay, the first one after ovclash_release_memory(), a read at an earlier time than the last one, each classification and, for an ambiguous rate, the first matrix query by time code. After a changed file is saved, Default selection still reads the Stage, but finite-time poses and the static and dynamic classification come from the new file: wrong poses without an error, or a failed run. A relative root resolves against the process working directory at each replay, so open the Stage from an absolute path or a URL and pass that string.

  • committed_ordinal stays retained until the attachment ends. ovclash reads the Stage there again after ovclash_release_memory().

  • The owner never holds the owner-operation gate while it waits for a clash call, because ovclash takes the gate to replay the composition.

An engine-evaluated attachment in C, for a Stage that the owner opened from a file and then merged one layer into, follows. Add the function to the owner’s C source, and call it with a context from ovclash_create_context() after the owner has committed ordinal, in place of ovclash_open_stage():

#include <ovclash/ovclash_ovstage.h>
#include <math.h>
#include <string.h>

/* The owner opened `path`, an absolute path or a URL, at the Default time, merged `layer_text`
 * at "/" and sealed `ordinal`. ovclash evaluates every finite time itself and never calls back
 * into the owner. The root file and every file that the root or a layer references stay
 * unchanged until the attachment ends. */
static int attach_composed_stage(ovclash_context_t* ctx,
                                 ovstage_instance_t* stage,
                                 uint64_t ordinal,
                                 const char* path,
                                 const char* layer_text)
{
    ovclash_string_t layers[1];
    layers[0].ptr = layer_text;
    layers[0].length = strlen(layer_text);

    ovclash_ovstage_composition_t composition;
    memset(&composition, 0, sizeof(composition));
    composition.struct_size = sizeof(composition);
    composition.root.ptr = path; /* the exact string the owner opened */
    composition.root.length = strlen(path);
    composition.root_kind = OVCLASH_OVSTAGE_COMPOSITION_ROOT_FILE;
    composition.nb_layers = 1;
    composition.layers = layers; /* earliest merge first */

    ovclash_ovstage_binding_t binding;
    memset(&binding, 0, sizeof(binding));
    binding.struct_size = sizeof(binding);
    binding.stage = stage;
    binding.committed_ordinal = ordinal; /* retained until the attachment ends */
    binding.time_seconds = NAN;          /* required with a composition */
    binding.meters_per_unit = 0.01;      /* the values the composition resolves */
    binding.start_time_code = 0.0;
    binding.end_time_code = 48.0;
    binding.time_codes_per_second = 24.0;
    binding.frames_per_second = 24.0;
    binding.composition = &composition; /* evaluate_time, user_data and capabilities stay zero */
    /* The call copies the composition and its strings, so they may go out of scope afterwards. */
    return ovclash_ovstage_attach_stage(ctx, &binding).status == OVCLASH_STATUS_SUCCESS;
}

Authored transform updates#

ovclash classifies each mesh as static or animated from the raw authored xformOp:* records, the USD transform-operation attributes such as xformOp:translate. Only a mesh classified as static allows static-pair pruning. An owner’s population need not publish those records, so by default ovclash classifies no mesh of an owner-evaluated attachment as static. An engine-evaluated attachment needs no capability: ovclash classifies its meshes from a private population of the composition, as it does for a file.

OVCLASH_OVSTAGE_CAP_AUTHORED_TRANSFORM_UPDATES in capabilities (authored_transform_updates=True in Python) declares that the owner meets the full contract that the flag’s declaration in <ovclash/ovclash_ovstage.h> states. In short:

  • The owner populates every composed raw xformOp:* value and the USD-default xformOpOrder:usd-metadata:default for all prims, ancestors and prototypes. A missing order must mean that no default order is authored.

  • evaluate_time may be called twice at identical finite seconds and must publish a newer ordinal both times. Between those two ordinals, the raw-op update records hold exactly the initially valued operations that have more than one effective composed USD time sample.

  • No source edits, topology changes or manual raw-op writes occur during a query, and the owner keeps the complete update interval until the callback returns.

The capability requires evaluate_time. Leave capabilities zero unless the owner meets the whole contract.

The owner’s duties while attached#

  • Keep the Stage, evaluate_time and its user data alive until the attachment ends and every operation that uses it has finished.

  • While clash operations use the Stage, exclude rendering, source edits, time changes and destruction. Let clash operations finish before you detach or destroy the Stage.

  • Serialize all calls on one context or runtime. Never reenter it from evaluate_time.

  • With a composition, keep committed_ordinal retained, keep the root file and every file that the root or a layer references unchanged on disk, and keep the composition true to the Stage, as Engine-evaluated time states. Never hold the owner-operation gate while you wait for a clash call.

  • In Python, close the clash wrappers that depend on a Stage, with destroy() or close(), before you destroy that Stage.

This Python example creates and populates a Stage as its owner, lends it for one static query and destroys it again. scene.usda stands for your stage.

from pathlib import Path

import ovstage
from ovclash_suite import ClashDetection, run_ovstage_owner_operation

usda_text = Path("scene.usda").read_text(encoding="utf-8")


def create_stage():
    stage = ovstage.Stage("clash-owner")
    # Populate at the time the attachment declares below; ovclash trusts that declaration.
    ovstage.population.open_usd_from_string(stage, usda_text, ordinal=1, time=0.0)
    stage.advance_write_floor(ordinal=1).wait()
    return stage


stage = run_ovstage_owner_operation(create_stage)  # the owner creates and populates the stage
clash = ClashDetection()
try:
    clash.attach_ovstage(stage, 1, time_seconds=0.0)  # borrows the stage at ordinal 1
    clash.run_pipeline()
    print("overlaps:", clash.get_nb_overlaps())
finally:
    clash.destroy()  # ends the attachment; the stage stays alive
    run_ovstage_owner_operation(stage.destroy)  # the owner destroys it

The same owner can merge an edit layer on top of the file and lend the Stage with its composition. ovclash then evaluates every finite time in its own populations of scene.usda plus that layer, and the owner’s Stage stays at its Default-time evaluation. The owner opens the file by its absolute path, passes that same string, and leaves the file unchanged until the attachment ends:

from pathlib import Path

import ovstage
from ovclash_suite import ClashDetection, run_ovstage_owner_operation

# Absolute, because ovclash reopens the root by this string at each replay.
scene_path = str(Path("scene.usda").resolve())
edit_layer = """#usda 1.0
over "World"
{
    over "Crate"
    {
        double3 xformOp:translate = (0, 0, 50)
    }
}
"""


def create_stage():
    stage = ovstage.Stage("clash-owner")
    ovstage.population.open_usd(stage, scene_path, ordinal=1)  # at the Default time
    stage.advance_write_floor(ordinal=1).wait()
    ovstage.population.add_usd_reference_from_string(stage, edit_layer, "/")
    ovstage.population.apply_usd_changes(stage, ordinal=2)
    stage.advance_write_floor(ordinal=2).wait()
    return stage


stage = run_ovstage_owner_operation(create_stage)
clash = ClashDetection()
try:
    clash.attach_ovstage(
        stage,
        2,  # the Default-time evaluation with the edit layer
        composition_root=scene_path,  # the exact string the owner opened
        composition_layers=[edit_layer],  # earliest merge first
    )
    clash.run_pipeline()
    print("overlaps:", clash.get_nb_overlaps())
finally:
    clash.destroy()
    run_ovstage_owner_operation(stage.destroy)

Pass the Stage’s meters_per_unit and timeline keywords as for any attachment. The first finite-time read fails when meters_per_unit or time_codes_per_second differs from what the composition resolves. The one exception is a root that reports a rate of 24 together with another framesPerSecond: either value is accepted for sampling, and the first matrix query by time code checks the rate (see Engine-evaluated time). After a detected mismatch, every later finite-time read and classification on that attachment fails with the same message, without replaying again, until the next attach; once a matrix query by time code disproves the rate, later sampling reads and classifications fail too. A replay failure that ovstage reports is not remembered, and the next finite-time read replays again.

Matrix decomposition#

On ovstage, each canonical context selects how mesh matrices are decomposed: OpenUSD-compatible math (the default) or the original ovclash math, for comparisons. The selection belongs to the context and survives a reset and a stage replacement. The Suite API has no equivalent control. Comparing ovstage matrix decompositions gives the Python and C calls and their effect on results.

Messages#

The last error, or the Python exception, of a failed integration call contains one of these texts:

Message

Cause

clash runtime reentry from an ovstage owner operation is prohibited

A clash call from inside an owner operation or an evaluate_time callback.

Invalid existing ovstage binding descriptor size

struct_size is none of the three accepted sizes: the full size, the size without composition and the size without capabilities.

Null existing ovstage binding

C: a null binding pointer.

Invalid existing ovstage binding descriptor

A null Stage, a zero or out-of-range ordinal, invalid timeline metadata or invalid capabilities.

Invalid existing ovstage binding composition: <reason>

The composition is invalid, or the binding combines it with evaluate_time, nonzero capabilities or a finite time_seconds. <reason> names the rule, for example time_seconds must be NaN or unknown root_kind; a rejected layer adds , layer <index>.

Attached ovstage ordinal is not committed

committed_ordinal, or an ordinal that evaluate_time returned, is above the Stage’s global write floor.

Attached ovstage ordinal is no longer retained

The ordinal is older than the oldest ordinal the Stage retains.

Incompatible attached ovstage API version <major>.<minor>; ovclash requires <major>.<minor>

The Stage comes from an ovstage implementation whose API major or minor version differs from that of the pinned ovstage. The first version is the Stage’s, the second the one ovclash was built against.

Incompatible attached ovstage data-plane vtable

The Stage’s instance bundle lacks entries that ovclash reads.

Attached ovstage requires an owner evaluation callback for the requested time

A read at another time on an owner-evaluated attachment without evaluate_time, such as a dynamic query.

Attached ovstage owner must return a newer committed ordinal

evaluate_time returned an ordinal that is not greater than the current one.

Attached ovstage owner evaluation failed

evaluate_time failed without setting a diagnostic.

ovstage composition root failed: <ovstage error>

A finite-time read of an engine-evaluated attachment could not open the composition’s root. The next finite-time read tries again.

ovstage composition layer <index> failed: <ovstage error>

ovstage rejected the layer at that zero-based index while replaying the composition.

ovstage composition repopulation failed: <ovstage error>

ovstage could not populate the composed source after the merges.

Attached ovstage composition resolves <field> <value>, but the binding reports <value>

The composed metersPerUnit or timeCodesPerSecond differs from the binding’s meters_per_unit or time_codes_per_second. Every later finite-time read and classification on that attachment fails with the same message until the next attach.

Attached ovstage committed ordinal is no longer retained; reattach

An engine-evaluated attachment read the Stage at committed_ordinal again, for example after ovclash_release_memory(), and the owner no longer retains that ordinal. Attach again at a retained ordinal.

A text that starts with composition_root, composition_layers or composition_root_is_usda, such as composition_root cannot be combined with evaluate_time or composition_layers must hold only str

Python: a composition keyword breaks one of the rules under The binding descriptor. The exception is a TypeError or ValueError.

Existing-stage attachment requires the ovstage backend extension

Python: the loaded library is not an ovstage build.

ovstage owner operation failed or exceeded the nesting limit of 64

Python: the gate failed, or more than 64 owner operations nest.

Troubleshooting covers the other consumer failures, and Zero overlaps, or a scoped run traverses the whole stage the scope behavior that What an attachment changes describes.