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

Reuse shader effect for duplicate material networks. #950

Merged

Conversation

huidong-chen
Copy link

@huidong-chen huidong-chen commented Nov 30, 2020

Implemented a shader instance cache to allow reuse of shader effect for duplicate material networks.

  • This avoids repetitive compilation of the same shader effect, and thus reduces the load time.
  • This removes a blocker for material consolidation, and thus will reduce the playback time. Maya has some other blockers for material consolidation that should be fixed separately.

@huidong-chen huidong-chen added the vp2renderdelegate Related to VP2RenderDelegate label Nov 30, 2020
@huidong-chen huidong-chen linked an issue Nov 30, 2020 that may be closed by this pull request
lib/mayaUsd/render/vp2RenderDelegate/material.cpp Outdated Show resolved Hide resolved
lib/mayaUsd/render/vp2RenderDelegate/render_delegate.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@JGamache-autodesk JGamache-autodesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will indeed save a lot of shader recompilations. Thanks!

@huidong-chen huidong-chen force-pushed the chenh/MAYA-108261/reuse-shader-effect-for-duplicate-materials branch from 13990c2 to 59ac9e6 Compare December 2, 2020 15:29
@huidong-chen
Copy link
Author

I have to rebase the branch so that it can compiled with latest UFE code. Aside from that, the new commit 59ac9e6 is to address the change proposed by @JGamache-autodesk .

@huidong-chen huidong-chen added the ready-for-merge Development process is finished, PR is ready for merge label Dec 2, 2020
@huidong-chen
Copy link
Author

@kxl-adsk Please merge.

Reasons why I commit this change:

* HdSceneDelegate::GetScenePrimPath() is not available on old USD versions.
* Even if it is available in new USD versions, it is bad to query the scene
  scene paths in the render delegate code (which should only care about the
  render index paths).
* The new approach calculates concise relative paths which not only avoids
  ambiguity but only allows better reuse of shader effects, e.g. the
  following two material networks will be able to share a shader effect:
  - file1/UVReader -> file1 -> surface1
  - UVReader -> file1 -> surface1
@huidong-chen
Copy link
Author

Another commit for this PR: 528f2c1. Click the commit link to see the reasons please.

@@ -482,7 +503,7 @@ _LoadTexture(const std::string& path, bool& isColorSpaceSRGB, MFloatArray& uvSca
#if USD_VERSION_NUM >= 2102
HioImageSharedPtr image = HioImage::OpenForReading(path);
#else
GlfImageSharedPtr image = GlfImage::OpenForReading(path);
GlfImageSharedPtr image = GlfImage::OpenForReading(path);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kxl-adsk Any idea why github clang-format-linter doesn't like this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is one more mysterious mystery about clang format. I will revert this change anyway so we don't have to wait on it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've logged the problem in the wiki.

@kxl-adsk kxl-adsk merged commit 3254881 into dev Dec 3, 2020
@kxl-adsk kxl-adsk deleted the chenh/MAYA-108261/reuse-shader-effect-for-duplicate-materials branch December 3, 2020 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants