Skip to content

Autodesk: Hgi Backend Selection #2736

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

Conversation

erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

So far, HgiGL has been the default render backend on Windows and Linux. Now that there is Vulkan support introduced into the stack, through this PR users can choose a render backend at initialization time. This PR provides relevant support to render delegate creation as well.

Note: This PR is child of #2553. Please refer it for more context.

Fixes Issue(s)

  • N/A
  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-8836

@brechtvl
Copy link
Contributor

We ran into this problem in Blender, where it tries to initialize OpenGL while we want Vulkan. The environment variable HGI_ENABLE_VULKAN almost lets us work around it, but it gets read on program startup before we can override it.

Is there any plan to merge this pull request, or an alternative solution? The implementation makes sense to me.

@spiffmon
Copy link
Member

@brechtvl , really wish github had a "dupe" mechanism. Internally we duplicated and closed this PR in favor of #2850, which was merged about a year ago. Can you give that a try and see if it works for you?

@spiffmon spiffmon closed this Apr 15, 2025
@brechtvl
Copy link
Contributor

Ah, thanks! Though it seems that was merged into the feature-hgi-vulkan branch, not an official release?

@brechtvl
Copy link
Contributor

Or rather, only part of the PR was merged. The part in pxr/imaging/hd/rendererPlugin.cpp where it gets HgiBackend from settingsMap is missing.

@clach
Copy link
Contributor

clach commented Apr 15, 2025

We decided not to move forward with that aspect of the change (you can even see a comment about that specific part in PR #2850 here). We did include the new function CreateNamedHgi that allows you to create a specific Hgi backend based on what token you provide, which may be of use in your situation.

@brechtvl
Copy link
Contributor

brechtvl commented Apr 15, 2025

We did try CreateNamedHgi, but it's not enough. The problem is that Storm calls Hgi::IsSupported() without specifying the backend. Since it defaults to OpenGL and we have no OpenGL context when using Vulkan, that check fails.

I could try implementing a different solution, but it's not clear how it should be done. I didn't understand the comment about doing it at the UsdImagingGLEngine level, since as far as I can tell that's not available at the moment the HdRendererPlugin::IsSupported check needs to run.

Maybe a slight improvement would be to add a settingsMap argument to HdRendererPlugin::IsSupported, instead of a hgiToken. So that it's at least easier to make it consistent with HdRendererPlugin::CreateRenderDelegate. If you wanted to force them to be consistent more strongly, it could be a required argument instead of an optional one. Perhaps the gpuEnabled argument could be replaced by an entry in settingsMap too. But then it all becomes quite API breaking.

@brechtvl
Copy link
Contributor

I proposed an alternative solution in #3604, which hopefully sidesteps the concerns.

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

Successfully merging this pull request may close these issues.

6 participants