Backends#

ovclash builds one shared library, ovclash, against one of two scene-access backends. The backend is chosen at build time.

Backend

Role

ovstage

The product backend. It reads the scene through ovstage, a separate runtime package. Every released wheel and SDK archive is an ovstage build.

OpenUSD

A permanently retained reference implementation on the OpenUSD library. It is never published.

The OpenUSD build gives the same public contract a second, independent implementation, which runs against the same tests. Every ovclash CI pipeline builds and tests it. Its wheel and SDK archive are developer artifacts, and release verification rejects them.

Parity requirement. For the same stage and settings, the two backends must report the same overlap pairs, counts, face indices, distances and depths. This holds with ovstage in its default OPENUSD matrix-decomposition mode. The only exceptions are report order and the differences recorded on this page. Any other difference is a parity defect: correct the ovstage result, and do not change the OpenUSD reference to make a comparison pass.

The OVCLASH matrix-decomposition mode is an opt-in ovstage mode for comparison. It uses the original ovclash decomposition math. It can change clash membership and report payloads. It keeps ovstage scene access and does not switch backends. See Comparing ovstage matrix decompositions.

The consumer documentation describes the ovstage backend only. This page is the one place that describes OpenUSD behavior.

Selecting a backend#

You do not select a backend at run time. It is a compile-time property of the library you loaded:

  • The CMake option OVCLASH_OVSTAGE_ONLY fixes it at build time.

  • build_ovstage.* and build_openusd.* set the option for you. They install into _build/install/ovstage/ and _build/install/openusd/; see Backends and trees.

  • No environment variable or API call switches a library that is already loaded. To use the other backend, load the other library.

  • For the Python packages, set OVCLASH_SUITE_LIB or OVCLASH_LIB to the library’s absolute path before the first import.

  • OVCLASH_BACKEND and ovclash_suite.ClashDetection(backend=...) look like backend switches and are not. Environment variables describes both.

Variable

Values

Required

Default

Effect

OVCLASH_OVSTAGE_ONLY (CMake option)

ON, OFF

No

OFF

ON builds the ovstage backend, OFF the OpenUSD backend. The build wrappers set it.

OVCLASH_SUITE_LIB (environment)

The absolute path of a native library

With the SDK archive’s Python packages

Unset: the wheel loads the library it bundles

Both Python packages load this library. It wins when both variables are set. A relative path raises OSError.

OVCLASH_LIB (environment)

The absolute path of a native library

As OVCLASH_SUITE_LIB

Unset

Read when OVCLASH_SUITE_LIB is unset, with the same effect.

The two backends link OpenUSD, the library that reads USD (Universal Scene Description) scenes, differently:

  • ovstage has no direct OpenUSD linkage. The build forces OVCLASH_USE_NAMESPACED_USD off for it and prints its USD mode as none. Scene access goes through the ovstage API.

  • OpenUSD requires OVCLASH_USE_NAMESPACED_USD on, and links namespaced, Python-free OpenUSD. Its wheel and SDK archive bundle that OpenUSD closure; the ovstage packages depend on the pinned ovstage distribution instead.

To ask a loaded library which backend it is, call backend_info; Identifying the loaded library describes the fields. Backend markers lists the files that record the backend in an install tree and in each package, and Package identity gives the version, contents and publication status of each backend’s packages. USD coexistence describes the plugin-path variables that matter when another OpenUSD build shares the process.

What the backend changes#

This table lists the recorded divergences that a caller can observe. Equal aggregate clash counts alone do not prove that per-pair payloads match.

Area

Behavior

Consequence

Overlap-report buffer ownership

ovstage hands out borrowed views into context-owned storage. The OpenUSD engine allocates buffers per report, and ovclash_release_overlap_report is the only call that frees them.

Release every report, and never hold one across a pipeline step or run. That is correct on both backends. On OpenUSD a skipped release leaks, and releasing the context does not recover the buffers.

Cancellation scope

ovstage’s cancel flag is a per-context atomic. OpenUSD’s is a process-global volatile flag; the backend has no per-context cancellation. ovclash_async_is_cancelled therefore answers for the whole process on OpenUSD. On ovstage it answers for the context, and reports 0 for a null handle.

On OpenUSD, cancelling one context can abort another context’s run in the same process, and a set flag makes later ovclash_run_pipeline_step calls fail on every context. A stop at the limit of the broad phase (the step that pairs meshes by their world bounds) counts as a cancellation, so it blocks the stepped runs of every context until a reset. Finishing, resetting or releasing any context clears the flag for all of them. The Python AsyncPipeline and ClashRuntime request cancellation when their with block exits on an exception, including KeyboardInterrupt, so on OpenUSD that cleanup reaches every context as well. A single-context program is not affected.

Out-of-memory flag

ovstage records an allocation failure per context, and the call that hit it fails with OVCLASH_STATUS_ERROR. OpenUSD’s flag is process-global and written without synchronization. An OpenUSD run that ran out of memory can report zero overlaps with a success status.

On OpenUSD, check ovclash_is_out_of_memory after every run, and read it only after the pipeline has finished. One context’s out-of-memory state reaches every context in the process, and releasing any context clears it. Do not drive OpenUSD contexts concurrently.

Async progress polling

ovstage returns a locked snapshot clamped to the counted work. The OpenUSD engine reads its progress counters without synchronization. The Suite API, the product layer, forwards progress unclamped.

An OpenUSD ovclash_get_pipeline_step_data_async poll can briefly report progress or stepProgress outside [0.0, 1.0], or a non-finite value. Clamp it, and treat a non-finite value as unknown. Results are unaffected.

Async launch and completion

OpenUSD rejects ovclash_run_pipeline_async when a pipeline was created but no stage is open. ovstage launches that run, and ovclash_finish_pipeline then reports the missing stage. On OpenUSD, a handle launched without a pipeline reports finished while ovclash_is_pipeline_running still reports true. ovclash_release_context with a live handle finishes the run and frees the handle on OpenUSD; ovstage joins the worker.

Open the stage before you launch. Decide completion from ovclash_is_pipeline_running, never from finished. Releasing a context blocks until its run completes on both backends.

Pipeline status fidelity

On ovstage, ovclash_run_pipeline_step and ovclash_finish_pipeline return OVCLASH_STATUS_ERROR when a phase fails, and the reason is in the context’s last error. On OpenUSD, ovclash_run_pipeline_step succeeds once the phase was invoked, and ovclash_finish_pipeline succeeds once the worker was joined and the run was not cancelled.

On OpenUSD a failed phase can still report success and leave incomplete results. Cross-check ovclash_is_out_of_memory and the result counts there. On both backends, run the steps in order. Neither backend diagnoses an out-of-order step. The ovstage final step reports success without doing its work when earlier steps have not completed.

Uniform per-point widths

ovstage collapses a per-point width array whose values are all equal back to that single width. The OpenUSD engine keys off the array length alone and reports 0.0.

ovclash_overlap_report_t::pointSize0 differs between backends for a point cloud authored with one equal width per point. A genuinely varying array reports 0.0 on both.

Point size changed between the steps of one run

ovstage tests and reports a new ovclash_set_point_size value from the run’s next sample on. OpenUSD keeps the size it computed before the run’s first sample.

Results differ for that run’s later samples. Change the point size between runs, not between steps.

Subcomponent filtering changed between the steps of one run

ovstage fixes the ovclash_set_subcomponent_filtering value when the run selects meshes. OpenUSD applies a change to the run’s remaining steps.

Results differ for the rest of that run. Change the setting between runs, not between steps.

Threading controls

single_threaded, new_task_manager and nb_tasks choose the scheduler and worker budget differently on each backend; see Threading controls on each backend. On OpenUSD, with multithreading active, the default new task manager returns overlaps in a run-dependent order. ovstage keeps the same order under every setting.

Report order only. Counts, membership and per-pair data do not change on either backend. See Overlap ordering is not contractual.

Instanced point clouds

ovstage sees a UsdGeomPoints prim inside an instanceable reference only in prototype space, the shared /__Prototype_<id> copy that USD composes once for all placements. It has no point-cloud equivalent of mesh instance-proxy expansion, which replaces a prototype-space mesh with one mesh (an instance proxy) per placement, so it drops those clouds during collection. OpenUSD collides every placement.

Results differ for callers that enable OVCLASH_SETTINGS_FLAG_ENABLE_POINT_CLOUDS (off by default). On tests/data/instanced_points.usda, OpenUSD finds 4 pairs and ovstage 1. The drop is deliberate. ovstage regenerates the /__Prototype_<id> root names on every population, each load of the stage into ovstage. A time-sampled run would therefore lose a selected prototype-space cloud at the next population and fail, losing every result.

Unresolved transform animation

ovstage sometimes cannot prove from authored data whether a mesh’s transform is animated, for example when an active transform operation has no initial value. It then treats the mesh as non-static.

With ovclash_set_purge_permanent_static_overlaps on (the default), ovstage can keep a pair that OpenUSD purges. ovstage never purges a pair on an unproven static classification.

Cooked-mesh counter

ovclash_stats_t::nbCookedMeshes from ovclash_get_query_stats counts successful cooks on ovstage and attempted cooks on OpenUSD.

A failed cook lowers the count only on ovstage. Comparing it with nbMeshes minus nbSharedMeshes therefore detects dropped geometry only on ovstage.

omniverse:// assets

ovstage resolves omniverse:// URLs through the omni client of its runtime, the client library for the asset servers of NVIDIA Omniverse, NVIDIA’s platform for OpenUSD-based 3D applications. OVCLASH_OMNI_CLIENT_RETRY_MAX_MS sets that client’s reconnect window: optional, an unsigned 32-bit decimal number of milliseconds, 0 (fail at once) by default; Environment variables defines it. The OpenUSD backend cannot resolve them.

On OpenUSD, payloads, references and MDL (Material Definition Language) assets on a Nucleus host, an Omniverse asset server, fail to load, so their geometry is missing from the results. Use local copies of those assets. On both backends the stage itself must be a local file.

Query memory

On ovstage, ovclash_release_memory frees the current query’s source data, meshes, point clouds, results, dynamic state and broad-phase bounding volume hierarchy (BVH). On OpenUSD it frees no query memory and keeps every result; ovclash_reset_context is the call that frees it.

In a long-lived OpenUSD process, reset the context between queries to return memory.

The C API Reference documents smaller per-call differences on each function. Examples:

  • which rejections record last-error text;

  • what ovclash_set_sort_mode and ovclash_set_point_clouds_experimental do on each backend. On OpenUSD the latter selects another multithreaded point-vs-mesh path when point clouds are enabled and multithreading is active; ovstage stores it and never reads it;

  • that ovstage ignores the stageId argument of ovclash_set_scope;

  • which steps a duplicate-only run (ovclash_set_only_find_duplicates) skips. OpenUSD stops its narrow phase, the exact test of each candidate pair, after the duplicate test; ovstage skips the BVH, broad-phase and narrow-phase steps;

  • when per-pair details go stale. OpenUSD reports them stale when a prim of the pair no longer exists (... result details are stale because a prim of the pair no longer exists (stage replaced or prim removed); run the pipeline again). ovstage reports them stale when their mesh selection was replaced, by a new stage, the mesh-selection step of a new run or a failed ovclash_get_prim_matrix read (... result details are stale because their mesh selection was replaced; run the pipeline again);

  • the rejection text of ovclash_create_overlap_meshes, which fails on both backends: ovclash_create_overlap_meshes: not supported by the ovclash OpenUSD backend on OpenUSD;

  • that the Python ClashRuntime.set_ovstage_dynamic_matrix_cache() raises RuntimeError on OpenUSD, which does not export the setter.

Mesh instancing is not a backend difference. On ovstage, expandInstanceProxies() replaces each prototype-space mesh with one mesh per placement. Instanced meshes, including mesh-typed instance roots and nested placements, are therefore collided at their world placements on both backends. tests/python_tests/test_typed_instance_roots.py and tests/python_tests/test_nested_instance_visibility.py cover these cases.

Threading controls on each backend#

None of the three controls changes which pairs overlap or what is reported about them; testThreadingControlsDoNotChangeOverlapSet checks this on both backends. Performance describes the product behavior and the defaults.

Carbonite is NVIDIA’s plugin and runtime framework; its carb.tasking scheduler is one of the worker sources that these settings choose between. Each setting is optional and has the same type and fresh-context default on both backends.

Setting

Type

Default

OpenUSD backend

ovstage backend

ovclash_set_single_threaded

bool

false

Forces serial execution. Multithreading also requires the Carbonite tasking interface.

Forces serial execution of every parallel phase. Also disables sampled-matrix prefetch and the helper thread that populates static transforms.

ovclash_set_new_task_manager

bool

true

Selects between two Carbonite broad-phase and narrow-phase implementations. Matters only when multithreading is active. With multithreading active, the new manager returns overlaps in a run-dependent order.

True selects Carbonite and its scheduler budget and ignores nb_tasks. False selects bounded std::thread workers. The order is the same under every setting.

ovclash_set_nb_tasks

uint32_t; any value is accepted and clamped to 256

128

Read only by the legacy task manager, as its task split. The new manager takes its worker count from Carbonite.

Read only by the std::thread manager: at most min(max(nb_tasks, 1), hardware concurrency, available work) workers.

After detection, the same controls choose the workers for native report extraction and for fetch-and-save frame preparation on both backends. new_task_manager=false selects std::thread workers bounded by nb_tasks on OpenUSD as well.

Not backend differences#

These behaviors are often mistaken for ovstage limitations. They are limitations of the standalone product and behave the same on both backends; see Limitations.

  • ovclash_create_overlap_meshes always fails.

  • ovclash_release_overlap_meshes and ovclash_delete_duplicate_meshes are no-ops.

  • ovclash_get_timeline_data reports a fixed host timeline.

To read the open stage’s own timeline, call ovclash_get_stage_timeline_data. Both backends answer it from the stage’s root-layer metadata. A stage attached with ovclash_ovstage_attach_stage reports its binding’s values. An attachment with a composition also checks metersPerUnit and timeCodesPerSecond against that composition at its first finite-time read.

Overlap ordering is not contractual#

The index passed to ovclash_get_overlap_data is an identifier, not a rank. Overlap index order is not contractual states the consumer rule and shows how to sort. The order differs between the backends, and on OpenUSD it can differ from run to run (see Threading controls on each backend).

The order comes from the shared clash engine, so sorting in the OpenUSD adapter would not make the backends agree. A deterministic order would have to be a product feature, specified in the header and applied on both backends.

See also#