rishflab
(rishflab)
November 19, 2024, 5:33am
1
I am getting a segfault when call the execute() method on HD engine. The only weird thing I am noticing is the render delegate display name is GL instead of Metal?.
_hgi = Hgi::CreatePlatformDefaultHgi();
// hgi name: Metal
std::cout << "hgi name: " << _hgi.get()->GetAPIName() << std::endl;
_hgiDriver = HdDriver{HgiTokens->renderDriver, VtValue(_hgi.get())};
// current renderer plugin: HdStormRendererPlugin
std::cout << "current renderer plugin: " << _curRendererPlugin << std::endl;
// first task: /defaultTaskController/simpleLightTask
std::cout << "first task: " << tasks.front()->GetId() << std::endl;
// renderer display name: GL
std::cout << "renderer display name: " << _renderIndex->GetRenderDelegate()->GetRendererDisplayName() << std::endl;
// renderer display name: renderDriver
std::cout << "renderer display name: " << _renderIndex->GetDrivers().front()->name << std::endl;
// segfaults here !
_engine.Execute(_renderIndex, &tasks);
I think for macOS/Clang, this is still an issue, the external Hgi does’t work, but only GLEngine created Hgi would work internally, because of RTTI issue according to some old posts.
rishflab
(rishflab)
November 26, 2024, 4:08am
3
ImGui Hydra Editor is a USD editor written in c++ with the ImGui and OpenUSD frameworks.
I built this and it loads and displays a model from a USD file. It seems to be using Metal on MacOS but I am not sure if this is via OpenGL emulation
nporcino
(Nick Porcino)
November 27, 2024, 11:21pm
4
IImGuiHydraEditor uses Metal directly, not GL emulation, nor the GL/OpenGL interop implemented by the imaging GL engine.
The platform hgi is created here:
#include <pxr/imaging/hd/rendererPlugin.h>
#include <pxr/imaging/hd/rendererPluginRegistry.h>
#include <pxr/imaging/hdx/pickTask.h>
#include <pxr/imaging/hgi/tokens.h>
PXR_NAMESPACE_OPEN_SCOPE
Engine::Engine(HdSceneIndexBaseRefPtr sceneIndex, TfToken plugin)
: _sceneIndex(sceneIndex),
_curRendererPlugin(plugin),
_hgi(Hgi::CreatePlatformDefaultHgi()),
_hgiDriver{HgiTokens->renderDriver, VtValue(_hgi.get())},
_engine(),
_renderDelegate(nullptr),
_renderIndex(nullptr),
_taskController(nullptr),
_taskControllerId("/defaultTaskController")
{
_width = 512;
_height = 512;
Actually I’d like to try 3 Hgi backends on macOS, to make comparison, but it seems that only Metal is possible.
dhruvgovil
(Dhruv Govil)
November 28, 2024, 5:04am
6
You can definitely access the Metal renderer without the GL interop.
But if you’re looking to compare backends, you cannot compare all three on the same platform. Metal is the only option on macOS. GL and Vulkan on other platforms.
rishflab
(rishflab)
November 29, 2024, 1:17am
7
I found the problem. The HdEngine::render() seems to require a window to be initialised.
I added the following and it is no longer crashing due to segfault.
GarchGLDebugWindow window("Hdx Test", 256, 256);
window.Init();