hdEmbree Build & Debug Problems with MSVS 2022

To eventually create a Hydra render delegate for our inhouse renderer, I have taken a look at the hdEmbree example and started to gradually tweak it. However, MSVS 2022’s IntelliSense seems thoroughly confused with the recommended out-of-source build (“Go To Definition” simply never completes) and also breakpoints end up in weird spots once I try debugging my code.

https://github.com/PixarAnimationStudios/OpenUSD.git was cloned to d:\Repositories\OpenUSD\ and I successfully ran python build_scripts\build_usd.py d:\USD --build-variant relwithdebuginfo --usd-imaging --embree --examples from a MSVS 2022 developer prompt to create an installation at d:\USD\. After setting

set PYTHONPATH=d:\USD\lib\python
set PATH=%PATH%;d:\USD\bin;d:\USD\lib

I could successfully launch

usdview D:\USD\share\usd\tutorials\convertingLayerFormats\Sphere.usda

and switch to hdEmbree from there.

Next, I opened d:\USD\build\OpenUSD\pxr\imaging\plugin\hdEmbree\hdEmbree.vcxproj in MSVS 2022 to isolate hdEmbree from the numerous other projects and saved as a new solution. After switching to the RelWithDebugInfo configuration (a Debug build never worked for me), changing the output directory to d:\USD\plugin\usd\ and setting a couple debugging options, I succeeded running usdview with python.exe in a MSVS debug session.

However adding my own modifications to the code and actually hitting breakpoints turned out to be a major headache: First, the generated MSVS projects only showed a single header file: pch.h. But of course, I also needed renderDelegate.h, renderParam.h, renderPass.h and so on.

MSVS pointed me towards D:\USD\build\OpenUSD\include\pxr\imaging\plugin\hdEmbree\renderDelegate.h but there were two other versions of it, one in d:\USD\include\pxr\imaging\hdEmbree\renderDelegate.h and one in d:\Repositories\OpenUSD\pxr\imaging\plugin\hdEmbree\renderDelegate.h, these being identical and differing from the first one only by the preprocessor macro in the first line: #line 1 "D:/Repositories/OpenUSD/pxr/imaging/plugin/hdEmbree/renderDelegate.h"

Sometimes breakpoints are not hit at all (“The breakpoint will not currently be hit. The source code is different from the original version.”), sometimes they end up in weird places (D:\Repositories\OpenUSD\pxr\imaging\hdSt\renderBuffer.cpp instead of HdEmbreeRenderBuffer::Allocate() in D:\Repositories\OpenUSD\pxr\imaging\plugin\hdEmbree\renderBuffer.cpp), sometimes I have to rebuild the project to make it work.

Also, having header files and source files in entirely different locations does not make it very easy to push things into our own GIT repository. I tried building my own CMake project for hdEmbree, but that was far from easy due to macros such as pxr_plugin() to facilitate plugin registration and some serious Python magic going on.

Long story short: What’s the recommended way of working on your own derivate of the hdEmbree sample, retaining a solid build and debug process with MSVS 2022 and ideally IntelliSense support?

Any insights and recommendation highly appreciated. Thank you!