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

Fixed problems with Hydra render delegates during launch of Houdini #32

Open
wants to merge 1 commit into
base: houdini20.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/houdini/custom/USDUI/XUSD_ImagingEngineGL.C
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ _CopyRenderParams(const XUSD_ImagingRenderParams &src,
// Construction
//----------------------------------------------------------------------------

XUSD_ImagingEngineGL::XUSD_ImagingEngineGL(
XUSD_ImagingEngineGL::XUSD_ImagingEngineGL(const TfToken& rendererPluginId,
bool force_null_hgi, bool use_scene_indices)
: _hgi()
, _hgiDriver()
Expand All @@ -268,17 +268,21 @@ XUSD_ImagingEngineGL::XUSD_ImagingEngineGL(
{
RE_Wrapper wrapper(true);

if (wrapper.isOpenGLAvailable())
_InitGL();

// Hgi must be initialized before the renderer plugin is set.
_InitializeHgiIfNecessary(force_null_hgi);

// _renderIndex, _taskController, and _sceneDelegate are initialized
// by the plugin system.
if (!SetRendererPlugin(_GetDefaultRendererPluginId())) {
if (!SetRendererPlugin(!rendererPluginId.IsEmpty() ?
rendererPluginId : _GetDefaultRendererPluginId())) {
TF_CODING_ERROR("No renderer plugins found! "
"Check before creation.");
}

// GL must be initialized after the renderer plugin has been set, because
// the renderer plugin updates the GlfGLContextRegistry.
if (wrapper.isOpenGLAvailable())
_InitGL();
}

bool
Expand Down
3 changes: 2 additions & 1 deletion src/houdini/custom/USDUI/XUSD_ImagingEngineGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ TF_DECLARE_REF_PTRS(HdSceneIndexBase);
class XUSD_ImagingEngineGL : public XUSD_ImagingEngine
{
public:
XUSD_ImagingEngineGL(bool force_null_hgi, bool use_scene_indices);
XUSD_ImagingEngineGL(const TfToken& rendererPluginId,
bool force_null_hgi, bool use_scene_indices);
~XUSD_ImagingEngineGL() override;

// Check if the GL being used by USD imaging is running in core profile.
Expand Down
6 changes: 4 additions & 2 deletions src/houdini/custom/USDUI/plugin.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

#include "XUSD_ImagingEngineGL.h"
#include <UT/UT_DSOVersion.h>
#include <UT/UT_String.h>
#include <SYS/SYS_Version.h>
#include <SYS/SYS_Visibility.h>

extern "C"
{
SYS_VISIBILITY_EXPORT extern
PXR_NS::XUSD_ImagingEngine *
newImagingEngine(bool force_null_hgi, bool use_scene_indices)
newImagingEngine(const UT_StringRef &renderer,
bool force_null_hgi, bool use_scene_indices)
{
return new PXR_NS::XUSD_ImagingEngineGL(
return new PXR_NS::XUSD_ImagingEngineGL(PXR_NS::TfToken(renderer),
force_null_hgi, use_scene_indices);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/houdini/lib/H_USD/HUSD/HUSD_Imaging.C
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ HUSD_Imaging::setupRenderer(const UT_StringRef &renderer_name,
bool drawmode = theRendererInfoMap[myRendererName].drawModeSupport();

myPrivate->myImagingEngine =
XUSD_ImagingEngine::createImagingEngine(false,
XUSD_ImagingEngine::createImagingEngine(myRendererName,
false /*force_null_hgi*/,
(HoudiniGetenv(theEnableSceneIndexEnvVar) &&
SYSatoi(HoudiniGetenv(theEnableSceneIndexEnvVar)) != 0));
if (!myPrivate->myImagingEngine)
Expand Down
7 changes: 4 additions & 3 deletions src/houdini/lib/H_USD/HUSD/XUSD_ImagingEngine.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@

PXR_NAMESPACE_OPEN_SCOPE

typedef XUSD_ImagingEngine *(*XUSD_ImagingEngineCreator)(bool, bool);
typedef XUSD_ImagingEngine *(*XUSD_ImagingEngineCreator)
(const UT_StringRef&, bool, bool);

UT_UniquePtr<XUSD_ImagingEngine>
XUSD_ImagingEngine::createImagingEngine(
XUSD_ImagingEngine::createImagingEngine(const UT_StringRef& renderer,
bool force_null_hgi, bool use_scene_indices)
{
static XUSD_ImagingEngineCreator theCreator;
Expand Down Expand Up @@ -73,7 +74,7 @@ XUSD_ImagingEngine::createImagingEngine(

UT_ASSERT(theCreator);
return UT_UniquePtr<XUSD_ImagingEngine>(
theCreator(force_null_hgi, use_scene_indices));
theCreator(renderer, force_null_hgi, use_scene_indices));
}

XUSD_ImagingEngine::XUSD_ImagingEngine()
Expand Down
1 change: 1 addition & 0 deletions src/houdini/lib/H_USD/HUSD/XUSD_ImagingEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class HUSD_API XUSD_ImagingEngine
// Static function for creating XUSD_ImagingeEngine objects.
// The real implementation of this class is in $SHC/USDUI.
static UT_UniquePtr<XUSD_ImagingEngine> createImagingEngine(
const UT_StringRef& renderer,
bool force_null_hgi, bool use_scene_indices);

// Disallow copies
Expand Down