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

Materials refresh too aggressively, causing lag #3832

Open
cawney4 opened this issue Jun 18, 2024 · 2 comments
Open

Materials refresh too aggressively, causing lag #3832

cawney4 opened this issue Jun 18, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@cawney4
Copy link

cawney4 commented Jun 18, 2024

Describe the bug

When multiple viewports are visible - some with hardware textures on and some with textures off - we experience lagging after each tumble in the viewport.

I did some preliminary debugging. It seems like materials are being marked dirty and refreshed after tumbling. It thinks that we are switching to textured mode all the time:

// if switching to textured mode, we need to update materials
const bool neededTexturedMaterials = _needTexturedMaterials;
_needTexturedMaterials
= _combinedDisplayStyles.find(HdReprTokens->smoothHull) != _combinedDisplayStyles.end();
if (_needTexturedMaterials && !neededTexturedMaterials) {
auto materials = _renderIndex->GetSprimSubtree(
HdPrimTypeTokens->material, SdfPath::AbsoluteRootPath());
for (auto material : materials) {
changeTracker.MarkSprimDirty(material, HdMaterial::DirtyParams);
// Tell all the Rprims associated with this material to recompute primvars
HdVP2Material* vp2material = static_cast<HdVP2Material*>(
_renderIndex->GetSprim(HdPrimTypeTokens->material, material));
vp2material->MaterialChanged(_sceneDelegate.get());
}
}

It’s using _combinedDisplayStyles to determine whether textures are required. However, styles get erased if they haven’t been used for over 8 frames.

_combinedDisplayStyles.erase(curIt);

When I tumble in a non-textured viewport, it exceeds the 8 frame limit and removes “smoothHull” from _combinedDisplayStyles.

When it moves on to a textured viewport, it sees that “smoothHull” is not in _combinedDisplayStyles and believes textures are being turned on. It refreshes all materials - even though textures were on the entire time - and that takes several seconds.

I found a similar reported issue except I'm seeing a lag, not a crash: #3400

Steps to reproduce

  1. Launch Maya and load the mayaUsd plugin
  2. Click Create -> USD -> Create from File
  3. Select the provided texture_lag.usda
  4. Press the space bar in the viewport in order to enter 4 viewport view
  5. Turn on hardware texturing for all 4 viewports
  6. Turn off hardware texturing for the persp viewport
  7. Tumble a few times in the persp viewport, one immediately after the other. Make sure to release the mouse after each tumble.
  8. After each tumble, there is a pause/lag before it draws the next tumble.

Attachments
texture_lag.zip
In the zip, there are two files:

  • texture_lag.usda: USD file with 100 Mesh cubes and 100 Materials. The cubes are all identical and at origin. The materials are identical too. My goal here was to have 100 distinct Materials.
  • green.png: The texture file for Materials.

Video of repro:
https://github.com/Autodesk/maya-usd/assets/8140553/7c8dec8f-d0bb-4ff9-9e10-5a5f7a7c02f8

Specs (if applicable):

  • Rocky Linux 9.4
  • Maya 2024.2

Additional context
I’ve noticed that turning off color management no longer lags, but we’d like to have color management on. Setting the preview_map’s source color space to “raw” also seems to alleviate it. But when it’s set to “sRGB” or “auto”, the lag happens.

@cawney4 cawney4 added the bug Something isn't working label Jun 18, 2024
@santosd santosd assigned santosd and unassigned santosg87 Jun 27, 2024
@santosd
Copy link
Collaborator

santosd commented Jun 27, 2024

Hello @cawney4,
I took a look at this issue. This is an issue that I had previously logged. We haven't specifically done work to fix this issue to this point however. I did some testing and I was able to reproduce the issue using the latest MayaUSD plugin with Maya 2025. However, I also tested our latest beta release which has a newer version of USD (24.05) https://github.com/PixarAnimationStudios/OpenUSD in the beta release version, I was no longer able to reproduce the issue. Are you part of our beta program and is it possible for you to test it out on your end?

@cawney4
Copy link
Author

cawney4 commented Jul 16, 2024

Hello @santosd, thanks for the response! Yes, I'm part of the beta program and can test it out. Do you happen to know what part contains the fix -- in Maya beta, mayaUSD, or the new USD version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants