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

USDtweak crashes/doesn't render scene when opening a USD #16

Closed
ChubbyQuark opened this issue Jul 8, 2024 · 32 comments
Closed

USDtweak crashes/doesn't render scene when opening a USD #16

ChubbyQuark opened this issue Jul 8, 2024 · 32 comments

Comments

@ChubbyQuark
Copy link
Collaborator

USDtweak crashes when opening any USD file, the console repeatedly puts out the error below:

**Installed usdtweak using the windows installer

Windows 11

OpenUSD v24.05**

Link called without any attached shader objects.

Coding Error: in Execute at line 585 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hdx\colorCorrectionTask.cpp -- Failed verification: ' CreateShaderResources() '
Coding Error: in CompositeToInterop at line 310 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiInterop\opengl.cpp -- Failed verification: ' glGetError() == GL_NO_ERROR '
Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid enum, reported from cdecl pxrInternal_v0_22__pxrReserved::HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder(void)
Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid enum, reported from cdecl pxrInternal_v0_22__pxrReserved::HgiGL_ScopedStateHolder::~HgiGL_ScopedStateHolder(void)
Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid enum, reported from cdecl pxrInternal_v0_22__pxrReserved::HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder(void)
Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid enum, reported from cdecl pxrInternal_v0_22__pxrReserved::HgiGL_ScopedStateHolder::~HgiGL_ScopedStateHolder(void)
Coding Error: in HgiGLShaderProgram at line 52 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\shaderProgram.cpp -- Failed verification: ' id>0 ' -- Invalid shader provided to program
Coding Error: in HgiGLShaderProgram at line 52 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\shaderProgram.cpp -- Failed verification: ' id>0 ' -- Invalid shader provided to program
Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid value, reported from cdecl pxrInternal_v0_22__pxrReserved::HgiGLShaderProgram::HgiGLShaderProgram(const struct pxrInternal_v0_22__pxrReserved
_::HgiShaderProgramDesc &)
Coding Error: in _CreateShaderResources at line 296 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hdx\colorCorrectionTask.cpp -- Failed to create color correction shader
ERROR: 0:21: 'double' : syntax error syntax error

@cpichard
Copy link
Owner

cpichard commented Jul 9, 2024

Hi @ChubbyQuark ,
thanks for the crash report.
It looks like this is an OpenGL issue as glGetError() == GL_NO_ERROR fails.
Does your machine have one dedicated graphic card ? like nvidia/amd or does it have several cards ?
If there are several cards you might want to assign usdtweak to the dedicated graphic card, there is a similar issue here #15 , and the explanation to do it here: https://nvidia.custhelp.com/app/answers/detail/a_id/2615/%7E/how-do-i-customize-optimus-profiles-and-settings this
The next usdtweak version will normally select automatically the dedicated graphic card.

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 9, 2024 via email

@cpichard
Copy link
Owner

Hi, it could be that your graphic card doesn't support opengl 4.0, and that would be consistent with the glsl compilation error which doesn't understand 'double' (double was supported starting opengl 4.0)
Would you have the usdtweak startup log ? it normally shows the opengl version selected.
Also, you are using usdview coming with which package ? precompiled nvidia usd ? vanilla usd compiled by yourself ? houdini ? maya ?
Thanks

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 10, 2024 via email

@ChubbyQuark
Copy link
Collaborator Author

You were right, opengl version is too low on my machine, I'll see if I can upgrade it and re-try.

Intel
Intel(R) Iris(R) Xe Graphics
OpenGL 3.2.0 - Build 31.0.101.4314
GLSL 1.50 - Build 31.0.101.4314
USD 2211
Warning: in operator () at line 75 of C:\Users\cpich\installs\USD-22.11\pxr\imaging\hgiGL\hgi.cpp -- HgiGL minimum OpenGL requirements not met. Please ensure that OpenGL is initialized and supports version 4.5.
Hydra enabled
PXR_PLUGINPATH_NAME:

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 10, 2024

This is odd; the startup log for usdtweak shows a different version to the opengl extension viewer, any ideas how to target the latest version?

image

@ChubbyQuark
Copy link
Collaborator Author

Update: I've uninstalled the version from the pre built windows installer and built from cloning the repository. The app. now opens and functions well but I'm still seeing the wrong version of opengl when starting usdtweak (geometry isn't being rendered in the viewport)

@cpichard
Copy link
Owner

Hi @ChubbyQuark ,
I think I know what is happening. usdtweak uses glfw to initialize open gl and it gives a hint on the minimal version required here:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

It is set to 3.2 for various past reasons that might not apply anymore. Normally the opengl driver will use the highest version, that's what I have seen in the past, but it looks like in your case it chooses the one specified by the hint. For the record there is a discussion here about it https://stackoverflow.com/questions/27762349/why-am-i-not-getting-a-forward-compatible-opengl-context-with-glfw.

So unless there is a way to tell the driver to always use the maximum opengl version, we need to change the minimum version in usdtweak. From usd 20.11 onwards it's Opengl 4.5 on linux+windows and 4.1 on mac.
Since you already compiled usdtweak, to you want to make the change locally and double check ?
it should look like :
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);

@ChubbyQuark
Copy link
Collaborator Author

ok, thanks. I'll try that. Also noted that USD built with an earlier version, this is from the build log:

-- Found OpenGL: opengl32
-- Found OpenSubdiv: C:/USD/include (found suitable version "3.6.0", minimum required is "3")
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'PySide6'
-- Found PySide2: with C:/Users/user/AppData/Local/Programs/Python/Python39/python.exe, will use C:/Users/user/AppData/Local/Programs/Python/Python39/Scripts/pyside2-uic.exe for pyside-uic binary
-- Found PySide: True
-- Found PyOpenGL
-- Found PyOpenGL: True
-- C++ namespace configured to (external) pxr, (internal) pxrInternal_v0_24
-- Skipping validation of gf generated code because PXR_VALIDATE_GENERATED_CODE=OFF
-- Skipping validation of sdf generated code because PXR_VALIDATE_GENERATED_CODE=OFF
CMake Warning at pxr/usd/usd/CMakeLists.txt:198 (message):
Skipping building usdGenSchema due to missing dependency: Jinja2

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 11, 2024

Adjusted, getting 4.5 on startup, but still getting errors, I wonder if it's connected to the pixar issue?

PixarAnimationStudios/OpenUSD#2756

Intel(R) Iris(R) Xe Graphics
OpenGL 4.5.0 - Build 31.0.101.4314
GLSL 4.50 - Build 31.0.101.4314
USD 2405
PXR_PLUGINPATH_NAME:
Reading blueprints
Blueprints ready
Runtime Error: in GlfPostPendingGLErrors at line 84 of C:\Users\user\OpenUSD\pxr\imaging\glf\diagnostic.cpp -- GL error: invalid enum, reported from void cdecl pxrInternal_v0_24__pxrReserved::GlfDrawTarget::Unbind(void)

@cpichard
Copy link
Owner

Hi,
it is still an opengl error, but different than the original one, I don't know if we can consider that as progress, but it's a change.
I am wondering, the build of the drivers seems different from the one displayed by usdtweak (31.0.101.4314) and the one on the system (31.0.101.5592), did you reinstall the drivers after compiling usd ? may be there are several opengl libs/drivers interfering ? but it's unlikely to be the issue to be honest.
I would probably try forcing 4.6 just to double check hydra doesn't need 4.6.
I'll ask around if someone has a laptop with an Iris xe graphics that I can borrow, see if I can reproduce the issue.
Which processor do you have ?

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 13, 2024 via email

@ChubbyQuark
Copy link
Collaborator Author

Rebuilt with current drivers but no change. Drivers now match the usdtweak displayed drivers:

image

I'll re-build with PySide6, no idea if that will make any difference...

@ChubbyQuark
Copy link
Collaborator Author

Rebuilt with PySide6, getting a similar error:

Runtime Error: in HgiGLPostPendingGLErrors at line 91 of C:\Users\user\OpenUSD\pxr\imaging\hgiGL\diagnostic.cpp -- GL error: invalid enum, reported from cdecl pxrInternal_v0_24__pxrReserved::HgiGL_ScopedStateHolder::HgiGL_ScopedStateHolder(void)

@cpichard
Copy link
Owner

Thanks a lot for all those tests, this is really helpful. I managed to get a laptop with an intel card, and got the same initial error as you, the driver returns the minimum version required, so 3.2 which is not enough. By setting to 4.5, it does creates new errors as you had, and I found out it's because of the line with GLFW_FORWARD_COMPAT which should be removed to get the compatibility downward. After removing the line, on my laptop, there are no more errors but, for some unknown reason, storm doesn't render in the framebuffer, I just see the grid and the manipulators. Still investigating.

@cpichard
Copy link
Owner

If you still get opengl errors, you can add the environment variable HGIGL_DEBUG to pinpoint the issue.

@ChubbyQuark
Copy link
Collaborator Author

Sounds like progress, I'm getting the same in the viewport, just the grid. The stage outliner has populated the prims and hierarchy, they're just not visible. I'll try running with the HGIGL_DEBUG.

@cpichard
Copy link
Owner

Hi @ChubbyQuark , it's progressing indeed. I didn't get much chance to chase the bug yesterday as I ran into compilation issues with boost, python and the latest msvc2022. But I finally managed to compile a debug version without python. I'll hopefully go back to bug hunting next week-end when I'll get some free time.
I compiled usd with embree and the embree render delegate does work. So it could be a storm bug on intel drivers, or something usdtweak is not doing right.
Does storm render correctly in usdview for you ?
Thanks

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 15, 2024 via email

@cpichard
Copy link
Owner

Hi, thanks @ChubbyQuark !
Just checking, are you testing with the usdview coming from the version 24.05 you compiled ?
Normally usdtweak and usdview work pretty much the same way, so it's a bit puzzling to me.
Also there are similar issues with usdview https://forum.aousd.org/t/usdview-does-not-render-anything/1534 or PixarAnimationStudios/OpenUSD#3009
I'll try the patch they did this weekend, hopefully that will solve it, otherwise testing with older USD versions, I remember 23.08 used to work with intel gpus, that would be good to test.
For info, if you know how to compile usd with the build script, adding embree is very simple, you just have to add --embree to the command line
python build_script.py --embree /my/usd/source /my/usd/installation
Cheers,

@ChubbyQuark
Copy link
Collaborator Author

@cpichard Yes, using usdview from compile 2405. Re-built with embree, usdview now renders with both OpenGL and Embree, is there a way to change the renderer in usd tweak?

I'll try the earlier build 2308.

@cpichard
Copy link
Owner

Thanks for confirming. In usdtweak's viewport there should be a GL button, if you click on it you'll have the option to use embree normally.

@ChubbyQuark
Copy link
Collaborator Author

Got it, I think it was squeezed in the UI. Embree is available but no change to the viewprt, just the grid shown. Also noticed the mouse doesn't seem to interact with the viewports (pan, tilt zoom etc.), do you think this is linked to the GL issue?

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 18, 2024

Rebuilt with an ealier version of OpenUSD and forced OpenGL 4.5, noticed there were multiple errors when building usdtweak, not sure if it's relevant:

C:\Users\user\Repos\usdtweak\src\ImGuiHelpers.h(32,30): warning C4267: 'argument': conversion from 'size_t' to 'int',
possible loss of data [C:\Program Files\usdtweak\usdtweak.vcxproj]

Intel(R) Iris(R) Xe Graphics
OpenGL 4.5.0 - Build 31.0.101.4314
GLSL 4.50 - Build 31.0.101.4314
USD 2308

@cpichard
Copy link
Owner

Hi @ChubbyQuark ,
The mouse should alway be interacting with the viewport, this is very unexpected that it does not, at first glance I don't see a situation where it should not, I'll investigate tomorrow. The errors you are seeing are just warnings, some come from usdtweak, other from usd, I should fix them at some point.
Does it work better with 2308 ?
Thanks

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 19, 2024 via email

@cpichard
Copy link
Owner

Hi @ChubbyQuark ,
you can delete the directory, that will do.
So I have tested with several usd versions (23.05, 23.08, 23.11, 24.05) and it turns out that the reason the viewport was blank was a display driver bug, after updating it to the latest (31.101.2115 for this particular gpu), storm is now rendering correctly with all usd versions.
I am testing a different hardawre configuration than yours, I have an intel HD 515 graphic card, way older.
Regarding the mouse viewport interaction, I really don't see what could be happening, except if the file is still loading may be ? but the rest of the UI would be hanging as well. Would you be able to post a short video grab ?

I'll try to build a new release this week-end with the fixes you helped discover.
Cheers

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 20, 2024 via email

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 20, 2024

Here's the screen grab. I've tried multiple different USD files, all with the same result.

Ignore the mouse interaction comment, it is working I had the wrong mouse key combo.

usdtweak_viewport_2024-07-20.112830.2.mp4

@cpichard
Copy link
Owner

Thanks a lot for the screen grab @ChubbyQuark . Great to know that the viewport manipulation is working. It really looks like Storm is not rendering. I created a new release and had a friend test it on his intel machine, it was behaving exactly as yours. But after installing the most recent intel driver then Storm was rendering correctly.
The release is there if you want to test it: https://github.com/cpichard/usdtweak/releases/tag/2024.07.20-prealpha

@ChubbyQuark
Copy link
Collaborator Author

ChubbyQuark commented Jul 20, 2024

@cpichard Good news! It's rendering and performance is great with the Animal Logic test scene, over 30fps even with the laptop I'm using. Thank you for getting this fixed, I'll have a good explore of the app now it's rendering.

image

@ChubbyQuark ChubbyQuark changed the title USDtweak crashes when opening a USD USDtweak crashes/doesn't render scene when opening a USD Jul 20, 2024
@cpichard
Copy link
Owner

Great news ! Happy that it is working now. If you have any questions don't hesitate to open a new issue.
Cheers,

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

2 participants