ovstage Source Extraction Internals#

This page of the Technical Guide explains how the ovstage backend, which reads USD through the ovstage runtime, turns a populated stage into clash source meshes. It covers the extraction order, instancing identity, the Default-time reads, Earliest-topology recovery, subcomponent kinds and the source diagnostics. The Architecture glossary defines the implementation terms.

It is written for maintainers of source/OvstageSceneReader*.cpp. Related topics live on these pages:

Topic

Canonical page

Which populations exist, who opens them and how long they live

Stage populations

How the numeric population moves between times

Numeric population state

Which operations take the process-wide lifecycle lock

Lifecycle lock

Default-time world-matrix read rules

Default-time transform reads

How placements share prototype geometry

Instanced stages share geometry

Extraction at a glance#

Pipeline step 1 (Finding meshes..., zero-based) extracts the source. OvstageSceneReader::populateFromFileCached() (source/OvstageSceneReader.cpp) reads from the Default-time selection population: the cached file population, or the attached stage. Its core is loadMeshGeometry() in source/OvstageSceneReaderGeometry.cpp.

Before extraction, a cached file selection joins any numeric helper and lazily prepares composed subcomponent kinds when filtering needs them. It publishes the label Reading subcomponent kinds before step 1. The preparation uses the retained USD source at Default time, without reopening the file, and publishes its new ordinal before extraction queries start. When the repopulation would add prims, the selection is reopened instead and step 3 reads the kinds (Subcomponent kinds).

The core extraction runs in this order. Each row publishes its label as the async step name Finding meshes... <label>.

#

Work

Label

Runs when

1

Query Mesh prims: usd-prim-type IN Mesh, or usd-schemas CONTAINS UsdGeomMesh when no prim has the literal type (createMeshQuery())

Querying meshes

Always

2

List the prototype roots (collectPrototypeRoots())

Querying prototypes

Always

3

Read composed kinds from a separate population (Subcomponent kinds)

Reading subcomponent kinds

Subcomponent filtering on, in a noncached file read or a cached selection whose kind repopulation was rejected; other cached selections already have their kind map

4

Scan the Default points and start the numeric helper (Earliest-topology recovery)

Scanning default geometry

File-backed selection extraction: unscoped, or starting the helper

5

Mesh census: paths, deduplication and visibility (collectMeshPaths())

Collecting mesh paths and visibility

Always

6

Read points, faceVertexIndices, faceVertexCounts, holeIndices and Default world matrices

Reading points to Reading world transforms

Always

7

Resolve the subcomponent roots of ordinary and prototype meshes

Reading subcomponent roots

Subcomponent filtering on

8

Prepare instance roots (prepareInstanceRoots())

Preparing instance roots

File-backed, Default time, the stage has prototypes

9

Recover the topology of meshes without Default points

Recovering sampled topology

A selected mesh has no Default points

10

Apply the root-layer invalid-face-count scan, freeze geometry, skip meshes without topology

Validating geometry

Always

11

Replace each prototype mesh with its placements (expandInstanceProxies())

Expanding instances

The stage has prototypes

12

Resolve the subcomponent roots of placements

(none)

Subcomponent filtering on, placements exist

Then populateFromFileCached() reads point clouds (Reading point clouds), only when OVCLASH_SETTINGS_FLAG_ENABLE_POINT_CLOUDS is set. Canonical C in the settings reference lists every flag of ovclash_settings_t (<ovclash/ovclash.h>) that this page names.

A mesh that lacks points, face indices or face counts after step 9 is skipped, not fatal. The OpenUSD backend skips it too.

Population-local instancing identity#

ovstage mirrors each instanceable reference into a synthesized prototype root such as /__Prototype_1. It reports one mesh per prototype, in prototype space. ovclash therefore keeps, per population, a map from each real instance root to its prototype root. collectPrototypeByInstanceRoot() in source/OvstageSceneReaderGeometryInstancing.cpp builds it.

Building the identity map#

  1. List the prototype roots. A file-backed population, and an engine population replayed from an attached composition, call ovstage_instancing_get_prototype_roots, which takes no ordinal. An attached, data-plane-only stage instead queries usd-schemas CONTAINS PrototypeRootAPI at the population ordinal.

  2. Read _protoPath once: one HAS _protoPath query at the population’s sealed ordinal.

  3. Keep a row as a graph edge only when its target is exactly a prototype root. Renderer proxy rows target prototype children and can outnumber the edges many times. The reader therefore decodes source paths for edge rows only.

  4. Build detail::InstancingGraph (source/InstancingGraph.h). It holds dense prototype IDs and, per prototype, the sources that instantiate it.

  5. Flatten each prototype’s instance roots through nested instances. Then sort, deduplicate and reduce them to minimal roots.

  6. Fail when one root maps to two prototypes: Ambiguous prototype association for instance root: <root>.

The _protoPath reader skips tombstones and null targets and respects the group’s row mapping. It rejects unsupported shapes, dtypes, GPU payloads and pending synchronization.

Flattening nested instances#

Example: a rack prototype contains an instanced box.

_protoPath edges (source -> target)
  /World/RackA        -> /__Prototype_1
  /World/RackB        -> /__Prototype_1
  /__Prototype_1/Box  -> /__Prototype_2

Flattened instance roots
  /__Prototype_1: /World/RackA, /World/RackB
  /__Prototype_2: /World/RackA/Box, /World/RackB/Box

The rules (InstancingGraph::flattened()):

  • A source’s owner is the deepest prototype root that is a path-component prefix of it. The prototype being flattened is excluded from that lookup.

  • An owned source expands through every instance root of its owner, with the same suffix. /__Prototype_1/Box becomes /World/RackA/Box and /World/RackB/Box.

  • A guard on the active expansion chain stops cycles.

  • Minimal-root reduction runs only on the complete answer. Outer roots /W/A and /W/A/B with the suffix /X must give both /W/A/X and /W/A/B/X. Reducing the outer list first would drop /W/A/B and lose /W/A/B/X.

Ownership and lifetime#

  • The graph lives inside one collectInstanceRoots() call. Only the root/prototype map survives.

  • The map belongs to one population. The Default selection population keeps mSelectionPrototypeByInstanceRoot. The numeric population builds its own mNumericPrototypeByInstanceRoot at its sealed ordinal. Synthetic prototype names never cross populations.

  • Default extraction reuses the selection map in prepareInstanceRoots(). It does not read _protoPath again. Lazy kind enrichment refreshes the map at its new sealed ordinal before extraction begins.

  • A reset or reopen clears the affected map. The map never stores sampled world values.

  • Never cache the graph across populations or edits. Neither the ordinal nor the layout generation can invalidate it safely.

  • validateInstanceRoots() always runs after the map is built, before visibility and transform handling. It drops roots that are not real paths.

  • Graph outputs are candidate roots, not clash mesh counts. They change neither geometry sharing nor per-sample proxy transform composition.

PrototypeRootIndex (source/OvstageSceneReaderInternal.h) is a separate membership lookup. It answers whether a path lies inside a prototype root, once per collected mesh path. It hashes the leading path prefixes instead of scanning the root list.

Scoped expansion#

With a scope, prepareInstanceRoots() keeps only the roots that can place something in it:

  • a root inside a scope;

  • a root that a scope lies below;

  • every enclosing instance root of a kept root.

Validation, visibility and root-matrix reads see only those roots. A read failure on a root that can place nothing in scope therefore does not fail a scoped run.

Example from testScopedInstanceExpansion (tests/native/InstancingGraphSourceOptimizationCases.h, fixture tests/data/scoped_placement_visibility.usda). The stage has five instance roots: /World/BoxA, /World/HiddenGroup/BoxB, /World/PileA, /World/PileA/Box and /World/PileA/HiddenBox.

Scope

Kept instance roots

Why

/World

All five

Every root lies inside the scope.

/World/HiddenGroup/BoxB/Shown

/World/HiddenGroup/BoxB

The scope lies below the root.

/World/PileA/HiddenBox

/World/PileA, /World/PileA/HiddenBox

The enclosing root stays. /World/PileA/Box places nothing in scope.

/World/Elsewhere

None

No root can place anything there.

With ignore_invisible_prims on, a scoped run filters each placement by visibility. The walk splits at the placement’s instance root:

  • Below the root, it reads the prototype mesh’s own ancestry, once per mesh.

  • From the root up to a scope, it reads once per root and scope.

  • The whole walk runs per placement when a scope lies below the root, or when another instance root lies between the root and the mesh.

testScopedInstanceExpansion compares every scoped result with the unscoped expansion and with the whole walk per placement.

An unscoped run drops hidden instance roots in prepareInstanceRoots(). It first reads every local visibility opinion those walks need in one batched query (mesh.proxy_expansion.visibility_prefetch).

ovstage static source extraction#

A static ovstage run spends serial time outside the collision kernel: population, source extraction (step 1), full-detail report capture, SQLite writes and population destruction. The narrow phase is already parallel, so more collision workers do not shorten these phases.

Population destruction runs under the lifecycle lock. Retiring a population earlier lowers retained memory, but it does not remove the cost. OvstageSceneReader::reset() destroys the numeric population first: while the selection population still holds the shared composition, the numeric destroy is cheaper.

Requirements for a source-side optimization:

  • Prove complete pair, frame and payload parity against the unchanged OpenUSD computation.

  • Keep load diagnostics, such as failed cooks and unavailable payloads, in the comparison. Silently loading less content looks faster.

  • Measure whole phases with the source diagnostics.

Mesh collection and Default transforms#

Census (collectMeshPaths()):

  • Paths are deduplicated by path handle. The path dictionary interns one handle per path.

  • An unscoped selection extraction first tries the packed census (tryCollectPackedMeshPaths()). It reads the virtual usd-path column of the literal-type query. It uses the result only after it checks row metadata, handle identity, uniqueness and complete coverage.

  • Schema-origin queries, and malformed or unsupported packed responses, use the ordinary census over the usd-prim-type rows (or the usd-schemas rows of a schema-only population).

  • Path strings are decoded per read group, not per row: one primPathsToStrings() call per nonempty group (source/OvstageSceneReaderQueries.cpp).

  • A scoped census keeps prototype-space meshes, which no scope can match. Expansion applies the scope to their placements.

Visibility (with ignore_invisible_prims):

  • Unscoped: one bulk _worldVisibility read. A mesh without a row falls back to its local visibility opinions. One batched read covers all such meshes and their ancestors. A path without an opinion counts as visible, for this extraction only.

  • Scoped: the walk reads local opinions only from the mesh up to the matching scope. A hidden ancestor above the scope does not hide the mesh. A mesh that several scopes match stays when any of them leaves it visible.

  • Prototype-space meshes skip this filter. Expansion filters each placement instead.

Default read cache (unscoped file-backed selection extraction):

  • The census keeps raw path handles beside its owned paths (DefaultMeshReadCache).

  • Points, topology and Default world rows route through those handles to the selected mesh slots. No row path is decoded again.

  • The cache owns Default points only when their visibility is known. A row of unknown world visibility, or a points-less row outside the selection, discards the owned points. The ordinary reads then run.

Scoped extraction:

  • It keeps no such cache.

  • When the scope selects fewer meshes than the query, the points, topology and world reads go through a query of the selected handles (createQueryFromHandles()). A malformed mesh outside the scope cannot fail the run, as on OpenUSD. A malformed selected mesh still fails it.

Default world matrices (copyWorldMatrices() in source/OvstageSceneReaderTransforms.cpp):

  • Read the published world rows: omni:fabric:worldMatrix, then worldMatrix. The first valid row wins.

  • Coverage is tracked per selected mesh. Equal row counts never prove coverage.

  • Only meshes without a published world row, plus prototype meshes, read their ancestry. One shared query covers all of them. Each ancestor walk stops at a path already collected (collectTransformPathsForPrimPaths()).

  • Local matrices (omni:fabric:localMatrix, then omni:xform) are read only when a mesh lacks a world row. Reset flags (omni:resetXformStack) are read for the whole ancestry, because prototype meshes need them.

Group metadata: every value read checks its group’s metadata before any row callback (validateReadGroupMetadata()). It rejects a group with both an index map and a mask, a map or mask whose count differs from the row count, and pending CUDA synchronization.

Earliest-topology recovery#

A mesh can author its points only as time samples. Its Default points are then empty. On a file-backed stage, ovstage takes such a mesh’s points and topology from its earliest authored samples, as OpenUSD does (copyDefaultMissingMeshTopologyFromEarliestSamples() in source/OvstageSceneReaderGeometry.cpp).

  • Recovery reads only the affected paths. Default selection, visibility and worlds stay. Sampled visibility or worlds never replace Default inputs.

  • Default and sample prototype identities are remapped independently.

  • Path predicates cannot match native-instance contents. A request for ordinary meshes only uses exact-path topology selectors. A request that includes prototype content uses the full RENDERING domain description.

  • An attached caller-owned stage gets no recovery, with or without a composition: its Default geometry always comes from the owner’s Stage. A pipeline run, or an immediate depth or depenetration query, that extracts a mesh without Default points from it fails with this error:

    Attached ovstage mesh topology is unavailable at Default; the owner must supply complete geometry
    

Which source supplies the Earliest topology (the first matching row applies):

Run

Source

Dynamic run

A dedicated Earliest population, destroyed right after the read. Dynamic runs advance the numeric population every sample, which would resample the recovered topology.

Static run whose affected meshes include prototype content

A dedicated population. Only it can take the every-Mesh RENDERING-domain description.

Static run with OVCLASH_RETAINED_SOURCE_SNAPSHOT=1 and a capable producer

The retained source (Retained source snapshot)

Static run when the numeric population already exists

A dedicated population. The existing population keeps its time.

Any other static file-backed run

The numeric population, opened at Earliest with exact-path topology selectors

When the numeric population supplies the topology, the forward advance to the requested time then serves the run’s numeric transforms. No second population opens.

The numeric helper thread (startNumericTopologyPrefetch() in source/OvstageSceneReader.cpp):

  • It opens the numeric population at Earliest while extraction continues. It runs unless OVCLASH_SETTINGS_FLAG_SINGLE_THREADED (RunSettings.single_threaded in Python) is set.

  • A scan of the Default points predicts the affected meshes: in scope, outside prototypes, before visibility filtering. The helper starts on one std::thread as soon as the scan ends.

  • It opens the population even when the scan predicts no affected mesh. The run’s transform reads then advance it instead of opening another.

  • A failed open or a too-narrow prediction is a miss. Recovery then reopens the population with the exact set.

  • Neither scheduler nor nb_tasks governs the thread. It holds the lifecycle lock while it populates. Kind preparation completes before the helper starts.

  • The reader joins it before it reads numeric state, repopulates the selection for kinds, replaces the selection or resets the source.

  • With single_threaded, the run opens the numeric population at Earliest only when a mesh needs recovery.

Requirement: do not skip recovery on indirect evidence. A stage without time samples, clips or splines can still need it. Example: a static mesh that authors double3[] points.

def Mesh "Wide"
{
    double3[] points = [(0, 0, 0), (1, 0, 0), (0, 1, 0)]
    int[] faceVertexCounts = [3]
    int[] faceVertexIndices = [0, 1, 2]
}

ovstage publishes an empty float32 points row for it at Default and an authored float64 row at Earliest. Recovery must read that row and reject it, and step 1 fails with:

ovstage attribute has unexpected tensor dtype for points (code=2, bits=64, lanes=3)

Limitations of the pinned ovstage runtime rule out these shortcuts:

Shortcut

Why it fails

Open at Default, then apply Earliest

The producer does not create missing point slots. Sampled and clip-backed geometry is lost.

Replace RENDERING-domain membership with a generic all-prims selector

The API has no abstract/defined predicate, so class assets and their nested instances become clash placements. The lean population also loses the RENDERING domain’s lastGlobalTime, which resolves the stage rate (Direct transform queries).

Compose hierarchy worlds from selectors only

They fail across Scope and typeless parents.

Advance the RENDERING selection population to a finite time

Prototype leaf matrices stay at their Default values, so numeric transforms keep their own population (Stage populations).

Derive a separate numeric population from the loaded selection source

Repopulation updates its source instance in place; it cannot populate a second instance from that retained source. Advancing the selection to numeric time would violate its role.

Numeric population#

The numeric population serves every finite-time matrix read. Its role and time transitions are on Stage populations and Numeric population state. This section covers the topology selectors that static recovery adds (openNumericTransformPopulation() in source/OvstageSceneReaderNumericPopulation.cpp).

Selector

Prim predicate

Properties

Transforms (always)

IS_A(Mesh, Points) OR HAS_PROPERTY(xformOpOrder)

None

Topology (static recovery only)

IS_A(Mesh) AND HAS_PATH(<affected paths>)

points, faceVertexCounts, faceVertexIndices, holeIndices

The population uses domains = NONE. Prototype content never goes into the topology selector.

A population with topology selectors behaves as follows:

  • The advance from Earliest to the first finite time reuses it. So do reads at the same time.

  • Before each later finite advance, the source checks the latest sealed ordinal for raw points or topology writes (numericTopologyMayHaveUpdates()). This includes advances for direct ovclash_get_prim_matrix calls.

    • Writes observed, or the check fails: reopen a transform-only population at the new time.

    • No writes: keep the population. The next advance checks again, because the check observes writes, not sample counts.

  • A reopen retires the numeric plans and rebuilds the numeric prototype associations. The Default selection and its copied geometry stay.

Subcomponent kinds#

Subcomponent filtering (OVCLASH_SETTINGS_FLAG_SUBCOMPONENT_FILTERING) needs each mesh’s subcomponent root: its nearest ancestor-or-self whose composed kind is subcomponent. This function turns it on in C. Put it in a C source file of your own that links the ovclash CMake target, and pass a context from ovclash_create_context; it returns 0 on success:

#include <ovclash/ovclash.h>

static int enable_subcomponent_filtering(ovclash_context_t* context)
{
    ovclash_settings_t settings;
    if (ovclash_reset_settings(&settings).status != OVCLASH_STATUS_SUCCESS)
        return -1;
    settings.flags |= OVCLASH_SETTINGS_FLAG_SUBCOMPONENT_FILTERING;
    return ovclash_set_settings(context, &settings).status == OVCLASH_STATUS_SUCCESS ? 0 : -1;
}

Cached file-backed stage:

  1. Opening the file and extracting with subcomponent filtering off do no kind preparation. The first extraction that needs kinds calls loadSelectionSubcomponentKinds() before creating extraction queries. It joins any numeric helper first and skips repopulation when there are no meshes.

  2. repopulateDefaultSubcomponentKinds() uses ovstage_population_repopulate_usd_with_desc() on the existing selection instance. A domains = NONE, HAS_KIND(subcomponent) description selects usd-metadata:kind and no properties. It reads composed kinds from retained layers and selected variants without reopening USD. The lifecycle mutex still covers enqueue, wait and write-floor advance.

  3. Preparation seals a newer selection ordinal, checks that the selection’s membership did not change (the requirement “never let enrichment change selection membership” of Subcomponent kinds), reads the kind map with a HAS query and refreshes the selection’s prototype associations. ovstage rejects IN on the kind attribute. The ordinal, associations and complete map are published together before mesh or point-cloud extraction.

  4. The map (SubcomponentKinds) stays with the selection across repeated runs, scopes and setting toggles, including an empty result. Reset or file replacement drops it. A failed preparation retires the selection rather than retaining a partially updated publication, so a retry starts from a fresh population.

Separate kind population: a noncached file read (OvstageSceneReader::populateFromFile() with subcomponent roots; the immediate-query fallback asks for none), and a cached selection whose repopulation was rejected, read kinds in step 3. populateSubcomponentKindsFromFile() opens a short-lived instance with the same narrow selector. readSubcomponentKindsFromFile() reads its map and keyKindsBySelectionPrototypes() translates prototype-local paths through the instance roots both populations share. The temporary instance is destroyed before extraction continues. A cached selection keeps that map, as it keeps a repopulated one.

Attached caller-owned stage: no kind population runs. The root walk reads kinds from the owner’s stage, one batched read per hierarchy level (readSubcomponentWalkNodes()).

Root-layer USDA text cannot supply kinds. It misses kinds that arrive through references, which is how production assets author them. It also records kinds in unselected variants.

Requirement: never let enrichment change selection membership. The narrow description requests only subcomponent kind metadata, but a selector also populates every prim it selects, with reserved type/schema fields, its ancestors and the instance links of its prototype. For a prim that the RENDERING domain already holds this adds only the kind. A selected prim that the RENDERING domain never traverses, such as one below a class, an over or a PointInstancer’s prototypes, would instead become a new clash mesh, placement or direct-query answer, and repopulation removes nothing. loadSelectionSubcomponentKinds() therefore counts every populated prim and collects the instance roots before and after the repopulation. Any difference rejects it: the reader retires the selection, reopens it and uses the separate kind population. A published enriched selection therefore keeps the mesh membership, Default poses and instance placements of the RENDERING selection, including typed Mesh roots and unrendered classes. Repopulation replaces the source’s future update scope. Never repopulate an attached owner’s stage or an advanced numeric population. Use it only on the owned Default selection, and in one other place: the replay of an attached composition repopulates a fresh engine instance whose open selected nothing, to write its rows from the merged source and set the scope of later time applications (Attached-stage populations).

Placements:

  • A prototype mesh’s root walk ends below its prototype root. A root found inside the prototype is re-rooted on each placement.

  • A placement left without a root takes the root of its instance root. copyPlacementSubcomponentRootPaths() walks each such instance root and its ancestors once.

  • That walk reads a nested instance root, or any other instance proxy, at its counterpart in the prototype of the nearest enclosing instance root. The shared engine’s UsdUtils::getSubComponentRoot() walks the parents of an instance proxy the same way.

  • Placements of one prototype can therefore resolve different roots.

Invalid face counts: ovstage population may sanitize faces with fewer than three vertices. OpenUSD rejects the whole mesh instead.

  • loadUsdaInvalidFaceCountMeshPaths() (source/UsdTextFallbacks.cpp) scans the root layer of a text stage (first line contains #usda) for such meshes.

  • Step 10 gives each such mesh a single two-vertex face, so triangulation rejects it.

  • A direct opinion beats any variant opinion. A variant opinion counts only when the root layer selects its variant.

  • The scan depends only on the file. It stays with the cached selection population and serves later selections and the immediate depth and depenetration queries.

Tests that pin this section:

Test

Executable

Pins

testSubcomponentKindsFollowSelectionPopulation

ovclash.instancing_graph.test

Lazy same-instance metadata publication without another file open, scope/toggle reuse, current-ordinal reads, and failure retiring the selection so that a retry starts from a fresh population.

testSubcomponentRepopulationPreservesInstancing

ovclash.instancing_graph.test

Enrichment preserves complete instanced geometry and hidden-source placement membership.

testSubcomponentRepopulationTypedRootsAndEmpty

ovclash.instancing_graph.test

Typed Mesh roots and unrendered classes remain distinct; a meshless file skips enrichment.

testSubcomponentRepopulationRejectsAddedPrims

ovclash.instancing_graph.test

A repopulation that would place instances below a class and an over is rejected once; the reopened selection and its separate kind population keep the concrete placement, filtering on and off.

testSubcomponentRepopulationKeepsNumericPlan

ovclash.instancing_graph.test

A prefetched numeric population and its selected-path plan survive enrichment.

testSubcomponentRepopulationKeepsPointClouds

ovclash.instancing_graph.test

Point geometry, widths and numeric playback are unchanged by enrichment.

testPlacementSubcomponentRoots

ovclash.instancing_graph.test

The root of every placement.

testInvalidFaceCountsFollowSelectionPopulation

ovclash.instancing_graph.test

The invalid-face scan is reused, and rescanned after a reset or for another file.

testInstancedKindsKeepPlacements

ovclash.native.test, both backends

Placements survive kinds on instanced_kinds_hidden_source.usda, filtering off and on.

testSubcomponentFilteringOfInstancedPlacements

ovclash.native.test, both backends

instanced_subcomponent_kinds.usda matches its instanceable = false twin. The fixture places kinds inside the asset, on a placement ancestor, on a subcomponent shared with an ordinary mesh, on the asset root, on a nested instance root, and inside an asset that only a nested instance root places.

testSubcomponentFilteringFromReferencedKinds

ovclash.native.test, both backends

Kinds that arrive through references.

testRootLayerVariantOpinions

ovclash.native.test, both backends

Variant opinions for kinds and invalid face counts.

All cases

ovclash.usda_text_fallbacks.test

The root-layer text scanner.

Source diagnostics#

These environment variables turn on source diagnostics. Each one takes effect only when it is exactly 1.

Variable

Effect

Output

OVCLASH_SOURCE_PERF

Phase timing of ovstage source work, and Suite fetch totals on both backends (source/SourcePerf.h). Read once per process.

[source-perf] lines on stdout, [fetch-perf] lines on stderr

OVCLASH_SHADOW_DEFAULT_TRANSFORMS

Audits selected-geometry numeric matrices against the Default selection population

[default-transform-shadow] lines on stdout

OVCLASH_RETAINED_SOURCE_SNAPSHOT

Private experiment: reads topology and numeric matrices from a retained source

None of its own

Phase timing#

SourcePerfScope (source/OvstageSceneReaderInternal.h) prints one line when a phase begins and one when it ends:

[source-perf] begin phase="<name>" input=<count>
[source-perf] end phase="<name>" elapsed_s=<seconds> input=<count> output=<count>

The fields of these lines (SourcePerfScope):

Field

Type

Required

Default or values

Description

phase

quoted string

Yes

A phase name, such as pipeline.finding_meshes

The measured phase

elapsed_s

number

In end lines only

Seconds, with six decimals

The time between the two lines

input

integer

Yes

An unsigned 64-bit count; 0 when the phase has no input count

The items the phase started with

output

integer

In end lines only

An unsigned 64-bit count

The items the phase produced

The phases that matter most for step 1:

Phase

Measures

input / output

pipeline.finding_meshes

All of step 1, including retained numeric preparation. Compare step 1 by this phase.

0 / 0

mesh.geometry

loadMeshGeometry() only. It excludes part of step 1.

0 / extracted meshes

numeric.prefetch.background_open

The helper’s Earliest open

predicted paths / 0

numeric.population.wait

Waiting for a numeric population

0 / 0

topology_fallback.prefetch_miss

Recovery’s check of the helper’s prediction

affected paths / 1 on a miss, 0 on a hit

topology_fallback.recovered_points

Meshes that gained points from recovery

affected paths / recovered

mesh.subcomponent.kind_population

Retained-source kind preparation, including its membership check, or a separate kind population, including its read

0 / kinds read

mesh.subcomponent.read_kinds

Kind reads from an attached stage

paths / kinds found

mesh.subcomponent.placement_roots

The placement root walk

instance roots / rooted placements

mesh.proxy_expansion.visibility_prefetch

The batched local visibility read of unscoped expansion

paths / paths

mesh.default_world.read_world_attributes

Published world-row reads

selected meshes / meshes that received a published world row

copyWorldMatrices() also prints [source-perf] default_mesh_world_fallback meshes=<n> missing_world=<n> ancestry=<n>.

[fetch-perf] lines summarize one Suite fetch. Fetch timing diagnostics explains their fields.

Worked example. Save this script as source_perf.py:

"""Run one static query and report how many meshes the source extraction selected."""

import sys

from ovclash import ClashRuntime, RunSettings

with ClashRuntime() as runtime:
    runtime.open_stage(sys.argv[1])
    runtime.set_run_settings(RunSettings())
    runtime.run_pipeline()
    stats = runtime.get_query_stats()
    print(f"meshes={stats.nb_meshes} overlaps={runtime.get_overlap_count()}")

Run it from ovclash/ with an ovstage build of ovclash importable (Running the module from a source checkout shows the setup).

Linux:

OVCLASH_SOURCE_PERF=1 python source_perf.py tests/data/source_optimization_reads.usda \
  | grep -E '^\[source-perf\] end phase="(pipeline\.finding_meshes|mesh\.geometry|numeric\.prefetch\.background_open|topology_fallback\.[a-z_]+)"|^meshes='

Windows (PowerShell):

$env:OVCLASH_SOURCE_PERF = "1"
python source_perf.py tests/data/source_optimization_reads.usda | Select-String -CaseSensitive -Pattern '^\[source-perf\] end phase="(pipeline\.finding_meshes|mesh\.geometry|numeric\.prefetch\.background_open|topology_fallback\.[a-z_]+)"|^meshes='
Remove-Item Env:OVCLASH_SOURCE_PERF

The fixture has four meshes. /World/Hidden/C is invisible, and /World/Sampled authors its points only as time samples. Output, with <seconds> in place of each measured time:

[source-perf] end phase="numeric.prefetch.background_open" elapsed_s=<seconds> input=1 output=0
[source-perf] end phase="topology_fallback.prefetch_miss" elapsed_s=<seconds> input=1 output=0
[source-perf] end phase="topology_fallback.numeric_population" elapsed_s=<seconds> input=1 output=0
[source-perf] end phase="topology_fallback.recovered_points" elapsed_s=<seconds> input=1 output=1
[source-perf] end phase="topology_fallback.prototype_paths" elapsed_s=<seconds> input=1 output=0
[source-perf] end phase="mesh.geometry" elapsed_s=<seconds> input=0 output=3
[source-perf] end phase="pipeline.finding_meshes" elapsed_s=<seconds> input=0 output=0
meshes=3 overlaps=0

How to read it:

  • The scan predicted one affected mesh, and the helper opened the numeric population with it (background_open ... input=1).

  • The prediction covered every affected path (prefetch_miss ... output=0), so recovery read the helper’s population.

  • Recovery gave points to one mesh (recovered_points ... output=1). None of the affected paths lies in a prototype (prototype_paths ... output=0).

  • Extraction kept three meshes. The invisible one was filtered out.

Default transform shadow#

OVCLASH_SHADOW_DEFAULT_TRANSFORMS=1 builds independent canonical plans for the numeric and the Default selection population during selected-geometry numeric reads. It compares:

  • the final matrices, bitwise;

  • local and reset rows;

  • the enclosing-root operand chains.

It pairs population-local prototypes through the real instance roots they share. Unknown associations, missing required rows and read failures mark the report status=incomplete. The audit adds reads and memory. It changes no result.

Example on tests/data/instance_reset_transforms.usda, with source_perf.py from Phase timing, run from ovclash/ in the same way.

Linux:

OVCLASH_SHADOW_DEFAULT_TRANSFORMS=1 python source_perf.py tests/data/instance_reset_transforms.usda

Windows (PowerShell):

$env:OVCLASH_SHADOW_DEFAULT_TRANSFORMS = "1"
python source_perf.py tests/data/instance_reset_transforms.usda
Remove-Item Env:OVCLASH_SHADOW_DEFAULT_TRANSFORMS

Output, with the middle of the report line elided:

[default-transform-shadow] status=complete time=0 numeric_ordinal=2 selection_ordinal=1 requested=10 compared=10 matrix_mismatches=0 ... missing_required_selection_rows=0 conflicting_rows=0 phase=comparison reason=""
meshes=10 overlaps=3

Up to eight [default-transform-shadow] example="..." lines follow the report line. Each names one mismatching, unpaired or conflicting path.

The report line is a diagnostic, not a stable format. It prints every field in this order, as name=value (DefaultTransformShadowReport in source/OvstageSceneReaderNumericPlan.cpp):

Field

Type

Required

Default or values

Description

status

string

Yes

complete, incomplete

complete only when both reads succeeded with equal output counts, every operand and chain normalized, every output was compared and every reader closed cleanly. A complete report can still hold mismatches.

time

number

Yes

Seconds

The finite time of the numeric read

numeric_ordinal, selection_ordinal

integer

Yes

–

The sealed ordinals that the numeric and the selection reads used

requested, compared

integer

Yes

–

Paths requested, and outputs compared with the primary result

matrix_mismatches

integer

Yes

–

Selection-population matrices that differ bitwise from the primary result

numeric_audit_mismatches

integer

Yes

–

Rebuilt numeric matrices that differ bitwise from the primary result

numeric_read_ok, selection_read_ok

integer

Yes

0, 1

Whether each read succeeded

paired_prototypes, ambiguous_prototype_pairs, unpaired_numeric_prototypes, unpaired_selection_prototypes, unpaired_operand_prefixes

integer

Yes

–

How the population-local prototypes paired through their shared instance roots

numeric_root_bindings, selection_root_bindings, root_chain_mismatches, output_chain_mismatches

integer

Yes

–

The enclosing-root bindings of each read, and the root and operand chains that differ

common_local_rows, local_value_mismatches, numeric_only_local_rows, selection_only_local_rows, selection_only_nonidentity_local_rows

integer

Yes

–

Local-matrix rows found in both populations or in one only, and the shared rows whose values differ

common_reset_rows, reset_value_mismatches, numeric_only_reset_rows, selection_only_reset_rows, selection_only_true_reset_rows, numeric_true_reset_rows, selection_true_reset_rows

integer

Yes

–

The same comparison for the reset flags

missing_required_selection_rows

integer

Yes

–

Required leaf rows that the selection population lacks

conflicting_rows

integer

Yes

–

Repeated operands of one read whose rows disagree, and duplicate root names in the selection bindings

phase

string

Yes

selection_context, numeric_prepare, selection_prepare, numeric_read, selection_read, comparison, cleanup

The step that the audit reached, or the step that failed

reason

quoted string

Yes

Empty when nothing failed

The failure text

Retained source snapshot#

OVCLASH_RETAINED_SOURCE_SNAPSHOT=1 is a private experiment (source/OvstageRetainedSource.h).

  • It takes effect only with a producer that exposes the extension ovstage.experimental.retained_source_snapshot, version 1. The packaged ovstage runtime does not.

  • Static runs recover the Earliest topology of ordinary meshes from the retained source instead of a population. Prototype content still takes a dedicated population.

  • Static runs without point clouds also read finite-time canonical local matrices and reset flags from it, during Finding meshes... Preparing retained transforms. The Default selection and the world-matrix arithmetic stay the same.

  • Its read_snapshot requests run under the lifecycle lock.

  • Its matrix cache is keyed on the stage, time, path list, source generation and floating-point control modes. Any other read uses the numeric population. An unsupported mapping falls back to the ordinary provider.

  • It serves file-backed stages only. An attached stage never uses it, and the engine populations of an attached composition read through the ordinary numeric path.

  • It adds no public ABI and no OpenUSD linkage.

ovclash.instancing_graph.test --retained-source-integration tests it against a producer closure named by OVCLASH_DIAG_PRODUCER_CLOSURE.