Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HdLight::Sync performance regression #2416

Closed
marktucker opened this issue Apr 28, 2023 · 4 comments
Closed

HdLight::Sync performance regression #2416

marktucker opened this issue Apr 28, 2023 · 4 comments

Comments

@marktucker
Copy link
Contributor

Description of Issue

This change: 1f87b7b made light syncing about 40x slower. In Houdini, our Sync function went from 0.000055s/light to 0.0023s/light. In usdview running storm, playback of the attached file with about 100 animated lights goes from 125FPS to 15FPS.

Steps to Reproduce

  1. Open lgt.usd from this zip file in usdview: lgt.zip
  2. Hit play. It is much slower after this commit than before.
  3. Changing HdSceneIndexAdapterSceneDelegate::GetLightParamValue in pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp so that it doesn't call _GetLightParamValueFromMaterial get performance basically back to where it was before.

System Information (OS, Hardware)

Tested on Linux and Windows

Package Versions

USD 23.05

@stevelavietes
Copy link
Contributor

The call to _GetLightParamValueFromMaterial was intended to cover a speculative case which in retrospect may not ever matter.

I'll see if I can speed it up for your case. If not, we can probably drop it (as you found).

Thanks for catching this.

(The case was "What if a downstream general-purpose edit was made to lights within the material resource for render delegates which use the legacy GetLightParamValue interface? If both are present, which should be used?". Longer term, I think the material resource [or rather the "material" data source] will be used for lights for all renderers. Shorter term, it seems unlikely that that speculative case will ever matter.)

@tallytalwar
Copy link
Contributor

Filed as internal issue #USD-8287

@stevelavietes
Copy link
Contributor

The fix for this is available in dev now:
f11ca5f

Removing the call to _GetLightParamValueFromMaterial restores performance. This is paired with changes to UsdImagingStageSceneIndex to also provide values for non-material-resource-based lights through the "light" data source. This provides the forwards compatibility intended by the original change but without the performance hit.

@robpieke
Copy link
Contributor

Confirmed this gets things back up to 125fps in the provided test ... much appreciated!

marktucker added a commit to sideeffects/USD that referenced this issue May 17, 2023
…Delegate::GetLightParamValue as it has significant overhead

- return light parameters within "light" data source from UsdImagingStageSceneIndex in order to satisfy render delegates which don't make use of GetMaterialResource for lights.
- add both time-varying and property change invalidation for the "light" data source within UsdImagingStageSceneIndex

Some render delegates (such as hdSt) query light parameter values through the legacy GetLightParamValue() interface. Newer delegates use the GetMaterialResource() to querylight parameters.
Front-end emulation does produce a "material" data source from GetLightParamValue calls to legacy delegates. Back-end emulation was prioritizating that "material" resource over the "light" data source in order to unify these approaches.
However, because each call to GetLightParamValue() results in the full material network being rebuilt, this introduced significant light sync performance overhead.

One goal of unifying access to be from the "material" data source was to have a single point for downstream overrides to address (regardless of which the render delegate uses).
We have not yet encountered cases where that is relevant.

UsdImagingStageSceneIndex was only providing the "material" data source form. So removing GetLightParamValue mapping alone would break hdSt cases.
Rather than enforcing the single mapping in back-end emulation, it's straightforward for UsdImagingStageSceneIndex to also provide "light" data source access (which it does for other fields already).

We can remove that once all render delegates are making using of GetMaterialResource (or directly using data sources).

Fixes PixarAnimationStudios#2416

(Internal change: 2274849)

# Conflicts:
#	pxr/usdImaging/usdImaging/primAdapter.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants