diff --git a/docs/building.md b/docs/building.md index 0a3284077f..c430de6fa6 100755 --- a/docs/building.md +++ b/docs/building.md @@ -11,7 +11,7 @@ Python and Boost are optional if USD was build without Python support. | Name | Version | Optional | | --- | --- | --- | -| Arnold | 5.4+ | | +| Arnold | 6.0.3+ | | | USD | v19.05 - dev | | | Python | 2.7 | x | | Boost | 1.55 (Linux), 1.61 (Mac, Windows VS 2015), 1.65.1 (Windows VS 2017) or 1.66.0 (VFX platform) | x | diff --git a/render_delegate/CMakeLists.txt b/render_delegate/CMakeLists.txt index f48eb07340..69d0c02a39 100644 --- a/render_delegate/CMakeLists.txt +++ b/render_delegate/CMakeLists.txt @@ -31,6 +31,7 @@ set(HDR config.h constant_strings.h debug_codes.h + rprim.h hdarnold.h instancer.h light.h diff --git a/render_delegate/basis_curves.cpp b/render_delegate/basis_curves.cpp index 658e029952..ed22be2735 100644 --- a/render_delegate/basis_curves.cpp +++ b/render_delegate/basis_curves.cpp @@ -143,45 +143,45 @@ inline bool _RemapVertexPrimvar( HdArnoldBasisCurves::HdArnoldBasisCurves( HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId) - : HdBasisCurves(id, instancerId), _shape(str::curves, delegate, id, GetPrimId()), _interpolation(HdTokens->linear) + : HdArnoldRprim(str::curves, delegate, id, instancerId), _interpolation(HdTokens->linear) { } void HdArnoldBasisCurves::Sync( - HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) { TF_UNUSED(reprToken); auto* param = reinterpret_cast(renderParam); const auto& id = GetId(); // Points can either come through accessing HdTokens->points, or driven by UsdSkel. - const auto dirtyPrimvars = HdArnoldGetComputedPrimvars(delegate, id, *dirtyBits, _primvars) || + const auto dirtyPrimvars = HdArnoldGetComputedPrimvars(sceneDelegate, id, *dirtyBits, _primvars) || (*dirtyBits & HdChangeTracker::DirtyPrimvar); if (_primvars.count(HdTokens->points) == 0 && HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->points)) { param->Interrupt(); - HdArnoldSetPositionFromPrimvar(_shape.GetShape(), id, delegate, str::points); + HdArnoldSetPositionFromPrimvar(GetArnoldNode(), id, sceneDelegate, str::points); } if (HdChangeTracker::IsTopologyDirty(*dirtyBits, id)) { param->Interrupt(); - const auto topology = GetBasisCurvesTopology(delegate); + const auto topology = GetBasisCurvesTopology(sceneDelegate); const auto curveBasis = topology.GetCurveBasis(); const auto curveType = topology.GetCurveType(); if (curveType == HdTokens->linear) { - AiNodeSetStr(_shape.GetShape(), str::basis, str::linear); + AiNodeSetStr(GetArnoldNode(), str::basis, str::linear); _interpolation = HdTokens->linear; } else { if (curveBasis == HdTokens->bezier) { - AiNodeSetStr(_shape.GetShape(), str::basis, str::bezier); + AiNodeSetStr(GetArnoldNode(), str::basis, str::bezier); _interpolation = HdTokens->bezier; } else if (curveBasis == HdTokens->bSpline) { - AiNodeSetStr(_shape.GetShape(), str::basis, str::b_spline); + AiNodeSetStr(GetArnoldNode(), str::basis, str::b_spline); _interpolation = HdTokens->bSpline; } else if (curveBasis == HdTokens->catmullRom) { - AiNodeSetStr(_shape.GetShape(), str::basis, str::catmull_rom); + AiNodeSetStr(GetArnoldNode(), str::basis, str::catmull_rom); _interpolation = HdTokens->catmullRom; } else { - AiNodeSetStr(_shape.GetShape(), str::basis, str::linear); + AiNodeSetStr(GetArnoldNode(), str::basis, str::linear); _interpolation = HdTokens->linear; } } @@ -200,37 +200,37 @@ void HdArnoldBasisCurves::Sync( return static_cast(i); }); AiArrayUnmap(numPointsArray); - AiNodeSetArray(_shape.GetShape(), str::num_points, numPointsArray); + AiNodeSetArray(GetArnoldNode(), str::num_points, numPointsArray); } if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { param->Interrupt(); - _UpdateVisibility(delegate, dirtyBits); - _shape.SetVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); + _UpdateVisibility(sceneDelegate, dirtyBits); + SetShapeVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); } auto transformDirtied = false; if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) { param->Interrupt(); - HdArnoldSetTransform(_shape.GetShape(), delegate, GetId()); + HdArnoldSetTransform(GetArnoldNode(), sceneDelegate, GetId()); transformDirtied = true; } if (*dirtyBits & HdChangeTracker::DirtyMaterialId) { param->Interrupt(); const auto* material = reinterpret_cast( - delegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, delegate->GetMaterialId(id))); + sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, sceneDelegate->GetMaterialId(id))); if (material != nullptr) { - AiNodeSetPtr(_shape.GetShape(), str::shader, material->GetSurfaceShader()); + AiNodeSetPtr(GetArnoldNode(), str::shader, material->GetSurfaceShader()); } else { - AiNodeSetPtr(_shape.GetShape(), str::shader, _shape.GetDelegate()->GetFallbackShader()); + AiNodeSetPtr(GetArnoldNode(), str::shader, GetRenderDelegate()->GetFallbackShader()); } } if (dirtyPrimvars) { - HdArnoldGetPrimvars(delegate, id, *dirtyBits, false, _primvars); + HdArnoldGetPrimvars(sceneDelegate, id, *dirtyBits, false, _primvars); param->Interrupt(); - auto visibility = _shape.GetVisibility(); + auto visibility = GetShapeVisibility(); const auto vstep = _interpolation == HdTokens->bezier ? 3 : 1; const auto vmin = _interpolation == HdTokens->linear ? 2 : 4; // TODO(pal): Should we cache these? @@ -265,16 +265,16 @@ void HdArnoldBasisCurves::Sync( setArnoldVertexCounts(); // Remapping the per vertex parameters to match the arnold requirements. _RemapVertexPrimvar(value, _vertexCounts, arnoldVertexCounts, numPerVertex); - HdArnoldSetRadiusFromValue(_shape.GetShape(), value); + HdArnoldSetRadiusFromValue(GetArnoldNode(), value); } else { - HdArnoldSetRadiusFromValue(_shape.GetShape(), desc.value); + HdArnoldSetRadiusFromValue(GetArnoldNode(), desc.value); } // For constant and } else if (desc.interpolation == HdInterpolationConstant) { // We skip reading the basis for now as it would require remapping the vertices, widths and // all the primvars. if (primvar.first != _tokens->basis) { - HdArnoldSetConstantPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value, &visibility); + HdArnoldSetConstantPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value, &visibility); } } else if (desc.interpolation == HdInterpolationUniform) { if (primvar.first == str::t_uv || primvar.first == str::t_st) { @@ -282,7 +282,7 @@ void HdArnoldBasisCurves::Sync( if (desc.value.IsHolding()) { const auto& v = desc.value.UncheckedGet(); AiNodeSetArray( - _shape.GetShape(), str::uvs, AiArrayConvert(v.size(), 1, AI_TYPE_VECTOR2, v.data())); + GetArnoldNode(), str::uvs, AiArrayConvert(v.size(), 1, AI_TYPE_VECTOR2, v.data())); } else if (desc.value.IsHolding()) { const auto& v = desc.value.UncheckedGet(); auto* arr = AiArrayAllocate(v.size(), 1, AI_TYPE_VECTOR2); @@ -292,20 +292,20 @@ void HdArnoldBasisCurves::Sync( return {in[0], in[1]}; }); AiArrayUnmap(arr); - AiNodeSetArray(_shape.GetShape(), str::uvs, arr); + AiNodeSetArray(GetArnoldNode(), str::uvs, arr); } else { // If it's an unsupported type, just set it as user data. - HdArnoldSetUniformPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value); + HdArnoldSetUniformPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value); } } else { - HdArnoldSetUniformPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value); + HdArnoldSetUniformPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value); } } else if (desc.interpolation == HdInterpolationVertex) { if (primvar.first == HdTokens->points) { - HdArnoldSetPositionFromValue(_shape.GetShape(), str::curves, desc.value); + HdArnoldSetPositionFromValue(GetArnoldNode(), str::curves, desc.value); } else if (primvar.first == HdTokens->normals) { // This should be the same number as points. - HdArnoldSetPositionFromValue(_shape.GetShape(), str::orientations, desc.value); + HdArnoldSetPositionFromValue(GetArnoldNode(), str::orientations, desc.value); } else { auto value = desc.value; if (_interpolation != HdTokens->linear) { @@ -315,16 +315,16 @@ void HdArnoldBasisCurves::Sync( bool, VtUCharArray::value_type, unsigned int, int, float, GfVec2f, GfVec3f, GfVec4f, std::string, TfToken, SdfAssetPath>(value, _vertexCounts, arnoldVertexCounts, numPerVertex); } - HdArnoldSetVertexPrimvar(_shape.GetShape(), primvar.first, desc.role, value); + HdArnoldSetVertexPrimvar(GetArnoldNode(), primvar.first, desc.role, value); } } else if (desc.interpolation == HdInterpolationVarying) { - HdArnoldSetVertexPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value); + HdArnoldSetVertexPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value); } } - _shape.SetVisibility(visibility); + SetShapeVisibility(visibility); } - _shape.Sync(this, *dirtyBits, delegate, param, transformDirtied); + SyncShape(*dirtyBits, sceneDelegate, param, transformDirtied); *dirtyBits = HdChangeTracker::Clean; } @@ -333,19 +333,8 @@ HdDirtyBits HdArnoldBasisCurves::GetInitialDirtyBitsMask() const { return HdChangeTracker::Clean | HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyTransform | HdChangeTracker::DirtyVisibility | HdChangeTracker::DirtyPrimvar | - HdChangeTracker::DirtyNormals | HdChangeTracker::DirtyWidths | HdChangeTracker::DirtyInstancer | - HdChangeTracker::DirtyMaterialId; -} - -HdDirtyBits HdArnoldBasisCurves::_PropagateDirtyBits(HdDirtyBits bits) const -{ - return bits & HdChangeTracker::AllDirty; -} - -void HdArnoldBasisCurves::_InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) -{ - TF_UNUSED(reprToken); - TF_UNUSED(dirtyBits); + HdChangeTracker::DirtyNormals | HdChangeTracker::DirtyWidths | HdChangeTracker::DirtyMaterialId | + HdArnoldShape::GetInitialDirtyBitsMask(); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/basis_curves.h b/render_delegate/basis_curves.h index 75a1d15efc..1a56772567 100644 --- a/render_delegate/basis_curves.h +++ b/render_delegate/basis_curves.h @@ -24,24 +24,30 @@ #include -#include "shape.h" +#include "rprim.h" #include "utils.h" PXR_NAMESPACE_OPEN_SCOPE -class HdArnoldBasisCurves : public HdBasisCurves { +class HdArnoldBasisCurves : public HdArnoldRprim { public: HDARNOLD_API HdArnoldBasisCurves(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); + /// Destructor for HdArnoldBasisCurves. + /// + /// Destory all Arnold curves and ginstances. + ~HdArnoldBasisCurves() override = default; + /// Syncs the Hydra Basis Curves to the Arnold Curves. /// /// @param sceneDelegate Pointer to the Scene Delegate. - /// @param renderPaaram Pointer to a HdArnoldRenderParam instance. + /// @param renderParam Pointer to a HdArnoldRenderParam instance. /// @param dirtyBits Dirty Bits to sync. /// @param reprToken Token describing the representation of the mesh. - void Sync(HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) - override; + void Sync( + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, + const TfToken& reprToken) override; /// Returns the initial Dirty Bits for the Primitive. /// @@ -49,21 +55,6 @@ class HdArnoldBasisCurves : public HdBasisCurves { HdDirtyBits GetInitialDirtyBitsMask() const override; protected: - /// Allows setting additional Dirty Bits based on the ones already set. - /// - /// @param bits The current Dirty Bits. - /// @return The new set of Dirty Bits which replace the original one. - HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override; - - /// Initialize a given representation for the curves. - /// - /// @param reprName Name of the representation to initialize. - /// @param dirtyBits In/Out HdDirtyBits value, that allows the _InitRepr - /// function to set additional Dirty Bits if required for a given - /// representation. - void _InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) override; - - HdArnoldShape _shape; ///< Utility class for the curves and instances. HdArnoldPrimvarMap _primvars; ///< Precomputed list of primvars. TfToken _interpolation; ///< Interpolation of the curve. VtIntArray _vertexCounts; ///< Stored vertex counts for curves. diff --git a/render_delegate/camera.cpp b/render_delegate/camera.cpp index c78c5f4e71..6170c27dcf 100644 --- a/render_delegate/camera.cpp +++ b/render_delegate/camera.cpp @@ -26,10 +26,10 @@ TF_DEFINE_PRIVATE_TOKENS(_tokens, ); // clang-format on -HdArnoldCamera::HdArnoldCamera(HdArnoldRenderDelegate* delegate, const SdfPath& id) : HdCamera(id) +HdArnoldCamera::HdArnoldCamera(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) : HdCamera(id) { // We create a persp_camera by default and optionally replace the node in ::Sync. - _camera = AiNode(delegate->GetUniverse(), str::persp_camera); + _camera = AiNode(renderDelegate->GetUniverse(), str::persp_camera); if (!id.IsEmpty()) { AiNodeSetStr(_camera, str::name, id.GetText()); } diff --git a/render_delegate/camera.h b/render_delegate/camera.h index 189173dd5e..eb9b57cf93 100644 --- a/render_delegate/camera.h +++ b/render_delegate/camera.h @@ -31,10 +31,10 @@ class HdArnoldCamera : public HdCamera { public: /// Constructor for HdArnoldCamera. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the material. HDARNOLD_API - HdArnoldCamera(HdArnoldRenderDelegate* delegate, const SdfPath& id); + HdArnoldCamera(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Destructor for HdArnoldCamera. /// diff --git a/render_delegate/constant_strings.h b/render_delegate/constant_strings.h index 76e1fa400c..862664c48f 100644 --- a/render_delegate/constant_strings.h +++ b/render_delegate/constant_strings.h @@ -209,6 +209,7 @@ ASTR(interactive_target_fps); ASTR(interactive_target_fps_min); ASTR(ior); ASTR(latlong); +ASTR(light_group); ASTR(light_path_expressions); ASTR(linear); ASTR(log_file); @@ -272,16 +273,17 @@ ASTR(roughness); ASTR(scale); ASTR(shade_mode); ASTR(shader); +ASTR(shadow_group); ASTR(shidxs); ASTR(shutter_end); ASTR(shutter_start); ASTR(sidedness); ASTR(skydome_light); ASTR(specular); -ASTR(specularColor); -ASTR(specular_IOR); ASTR(specular_color); +ASTR(specular_IOR); ASTR(specular_roughness); +ASTR(specularColor); ASTR(spot_light); ASTR(st); ASTR(standard_surface); @@ -302,12 +304,14 @@ ASTR(thread_priority); ASTR(threads); ASTR(total_progress); ASTR(translation); -ASTR(useSpecularWorkflow); +ASTR(use_light_group); +ASTR(use_shadow_group); ASTR(user_data_float); ASTR(user_data_int); ASTR(user_data_rgb); ASTR(user_data_rgba); ASTR(user_data_string); +ASTR(useSpecularWorkflow); ASTR(utility); ASTR(uv); ASTR(uvcoords); diff --git a/render_delegate/hdarnold.h b/render_delegate/hdarnold.h index cd049891c5..458ec0ae54 100755 --- a/render_delegate/hdarnold.h +++ b/render_delegate/hdarnold.h @@ -44,8 +44,3 @@ /// Not blitting to a hardware buffer anymore, following the example of HdEmbree. #define USD_DO_NOT_BLIT #endif - -#if AI_VERSION_NUMBER >= 60003 -/// Using the core instancer procedural instead of inline instances. -#define HDARNOLD_USE_INSTANCER -#endif diff --git a/render_delegate/instancer.cpp b/render_delegate/instancer.cpp index 2a05f2e35f..c6f47c3e10 100644 --- a/render_delegate/instancer.cpp +++ b/render_delegate/instancer.cpp @@ -50,7 +50,7 @@ inline const VtArray& _LookupInstancePrimvar(const HdArnoldPrimvarMap& primva HdArnoldInstancer::HdArnoldInstancer( HdArnoldRenderDelegate* renderDelegate, HdSceneDelegate* sceneDelegate, const SdfPath& id, const SdfPath& parentInstancerId) - : HdInstancer(sceneDelegate, id, parentInstancerId), _delegate(renderDelegate) + : HdInstancer(sceneDelegate, id, parentInstancerId) { } diff --git a/render_delegate/instancer.h b/render_delegate/instancer.h index 739a61609f..b8252ad46c 100755 --- a/render_delegate/instancer.h +++ b/render_delegate/instancer.h @@ -77,9 +77,7 @@ class HdArnoldInstancer : public HdInstancer { HDARNOLD_API void _SyncPrimvars(); - HdArnoldRenderDelegate* _delegate; ///< The active render delegate. - std::mutex _mutex; ///< Mutex to safe-guard calls to _SyncPrimvars. - + std::mutex _mutex; ///< Mutex to safe-guard calls to _SyncPrimvars. HdArnoldPrimvarMap _primvars; ///< Unordered map to store all the primvars. }; diff --git a/render_delegate/light.cpp b/render_delegate/light.cpp index e7f8b65fcc..4f8f45608a 100644 --- a/render_delegate/light.cpp +++ b/render_delegate/light.cpp @@ -64,6 +64,7 @@ TF_DEFINE_PRIVATE_TOKENS( (barndoortopedge) (filters) (treatAsPoint) + ((emptyLink, "__arnold_empty_link__")) ); // clang-format on @@ -332,19 +333,31 @@ class HdArnoldGenericLight : public HdLight { /// @param value Value holding an SdfAssetPath to the texture. void SetupTexture(const VtValue& value); + /// Returns the stored arnold light node. + /// + /// @return The arnold light node stored. + AtNode* GetLightNode() const; + private: SyncParams _syncParams; ///< Function object to sync light parameters. HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate. AtNode* _light; ///< Pointer to the Arnold Light. AtNode* _texture = nullptr; ///< Pointer to the Arnold Texture Shader. AtNode* _filter = nullptr; ///< Pointer to the Arnold Light filter for barndoor effects. + TfToken _lightLink; ///< Light Link collection the light belongs to. + TfToken _shadowLink; ///< Shadow Link collection the light belongs to. bool _supportsTexture = false; ///< Value indicating texture support. }; HdArnoldGenericLight::HdArnoldGenericLight( HdArnoldRenderDelegate* delegate, const SdfPath& id, const AtString& arnoldType, const HdArnoldGenericLight::SyncParams& sync, bool supportsTexture) - : HdLight(id), _syncParams(sync), _delegate(delegate), _supportsTexture(supportsTexture) + : HdLight(id), + _syncParams(sync), + _delegate(delegate), + _supportsTexture(supportsTexture), + _lightLink(_tokens->emptyLink), + _shadowLink(_tokens->emptyLink) { _light = AiNode(_delegate->GetUniverse(), arnoldType); if (id.IsEmpty()) { @@ -356,6 +369,12 @@ HdArnoldGenericLight::HdArnoldGenericLight( HdArnoldGenericLight::~HdArnoldGenericLight() { + if (_lightLink != _tokens->emptyLink) { + _delegate->DeregisterLightLinking(_lightLink, this, false); + } + if (_shadowLink != _tokens->emptyLink) { + _delegate->DeregisterLightLinking(_shadowLink, this, true); + } AiNodeDestroy(_light); if (_texture != nullptr) { AiNodeDestroy(_texture); @@ -370,10 +389,10 @@ void HdArnoldGenericLight::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* r auto* param = reinterpret_cast(renderParam); TF_UNUSED(sceneDelegate); TF_UNUSED(dirtyBits); + const auto& id = GetId(); if (*dirtyBits & HdLight::DirtyParams) { // If the params have changed, we need to see if any of the shaping parameters were applied to the // sphere light. - const auto id = GetId(); const auto* nentry = AiNodeGetNodeEntry(_light); const auto lightType = AiNodeEntryGetNameAtString(nentry); auto interrupted = false; @@ -394,6 +413,14 @@ void HdArnoldGenericLight::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* r } else { _syncParams = photometricLightSync; } + if (_lightLink != _tokens->emptyLink) { + _delegate->DeregisterLightLinking(_shadowLink, this, false); + _lightLink = _tokens->emptyLink; + } + if (_shadowLink != _tokens->emptyLink) { + _delegate->DeregisterLightLinking(_shadowLink, this, true); + _shadowLink = _tokens->emptyLink; + } } } // We need to force dirtying the transform, because AiNodeReset resets the transformation. @@ -442,9 +469,27 @@ void HdArnoldGenericLight::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* r if (*dirtyBits & HdLight::DirtyTransform) { param->Interrupt(); - HdArnoldSetTransform(_light, sceneDelegate, GetId()); + HdArnoldSetTransform(_light, sceneDelegate, id); } + // TODO(pal): Test if there is a separate dirty bits for this, maybe DirtyCollection? + auto updateLightLinking = [&](TfToken& currentLink, const TfToken& linkName, bool isShadow) { + auto linkValue = sceneDelegate->GetLightParamValue(id, linkName); + if (linkValue.IsHolding()) { + const auto& link = linkValue.UncheckedGet(); + if (currentLink != link) { + // The empty link value only exists when creating the class, so link can never match emptyLink. + if (currentLink != _tokens->emptyLink) { + _delegate->DeregisterLightLinking(currentLink, this, isShadow); + } + _delegate->RegisterLightLinking(link, this, isShadow); + currentLink = link; + } + } + }; + updateLightLinking(_lightLink, HdTokens->lightLink, false); + updateLightLinking(_shadowLink, HdTokens->shadowLink, true); + *dirtyBits = HdLight::Clean; } @@ -487,6 +532,8 @@ HdDirtyBits HdArnoldGenericLight::GetInitialDirtyBitsMask() const return HdLight::DirtyParams | HdLight::DirtyTransform; } +AtNode* HdArnoldGenericLight::GetLightNode() const { return _light; } + class HdArnoldSimpleLight : public HdLight { public: /// Internal constructor for creating HdArnoldSimpleLight. @@ -543,34 +590,34 @@ HdDirtyBits HdArnoldSimpleLight::GetInitialDirtyBitsMask() const namespace HdArnoldLight { -HdLight* CreatePointLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreatePointLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::point_light, pointLightSync); + return new HdArnoldGenericLight(renderDelegate, id, str::point_light, pointLightSync); } -HdLight* CreateDistantLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreateDistantLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::distant_light, distantLightSync); + return new HdArnoldGenericLight(renderDelegate, id, str::distant_light, distantLightSync); } -HdLight* CreateDiskLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreateDiskLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::disk_light, diskLightSync); + return new HdArnoldGenericLight(renderDelegate, id, str::disk_light, diskLightSync); } -HdLight* CreateRectLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreateRectLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::quad_light, rectLightSync, true); + return new HdArnoldGenericLight(renderDelegate, id, str::quad_light, rectLightSync, true); } -HdLight* CreateCylinderLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreateCylinderLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::cylinder_light, cylinderLightSync); + return new HdArnoldGenericLight(renderDelegate, id, str::cylinder_light, cylinderLightSync); } -HdLight* CreateDomeLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) +HdLight* CreateDomeLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) { - return new HdArnoldGenericLight(delegate, id, str::skydome_light, domeLightSync, true); + return new HdArnoldGenericLight(renderDelegate, id, str::skydome_light, domeLightSync, true); } HdLight* CreateSimpleLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) @@ -578,6 +625,13 @@ HdLight* CreateSimpleLight(HdArnoldRenderDelegate* delegate, const SdfPath& id) return new HdArnoldSimpleLight(delegate, id); } +AtNode* GetLightNode(const HdLight* light) +{ + if (Ai_unlikely(light == nullptr)) + return nullptr; + return static_cast(light)->GetLightNode(); +} + } // namespace HdArnoldLight PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/light.h b/render_delegate/light.h index 74005af73e..4b71b50413 100755 --- a/render_delegate/light.h +++ b/render_delegate/light.h @@ -45,59 +45,65 @@ namespace HdArnoldLight { /// Returns an instance of HdArnoldLight for handling point lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreatePointLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreatePointLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling distant lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreateDistantLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreateDistantLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling disk lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreateDiskLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreateDiskLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling rect lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreateRectLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreateRectLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling cylinder lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreateCylinderLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreateCylinderLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling dome lights. /// -/// @param delegate Pointer to the Render Delegate. +/// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. HDARNOLD_API -HdLight* CreateDomeLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +HdLight* CreateDomeLight(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Returns an instance of HdArnoldLight for handling simple lights. /// /// @param delegate Pointer to the Render Delegate. /// @param id Path to the Hydra Primitive. /// @return Instance of HdArnoldLight. -HDARNOLD_API -HdLight* CreateSimpleLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); +// HDARNOLD_API +// HdLight* CreateSimpleLight(HdArnoldRenderDelegate* delegate, const SdfPath& id); + +/// Returns the Arnold light node for any HdLight. +/// +/// @param light Pointer to the HdLight. +/// @return Pointer to the Arnold Light, can be nullptr. +AtNode* GetLightNode(const HdLight* light); } // namespace HdArnoldLight diff --git a/render_delegate/material.cpp b/render_delegate/material.cpp index 0425d006cf..f4d080804d 100644 --- a/render_delegate/material.cpp +++ b/render_delegate/material.cpp @@ -404,11 +404,11 @@ void _RemapNetwork(HdMaterialNetwork& network, bool isDisplacement) } // namespace -HdArnoldMaterial::HdArnoldMaterial(HdArnoldRenderDelegate* delegate, const SdfPath& id) - : HdMaterial(id), _delegate(delegate) +HdArnoldMaterial::HdArnoldMaterial(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) + : HdMaterial(id), _renderDelegate(renderDelegate) { - _surface = _delegate->GetFallbackShader(); - _volume = _delegate->GetFallbackVolumeShader(); + _surface = _renderDelegate->GetFallbackShader(); + _volume = _renderDelegate->GetFallbackVolumeShader(); } HdArnoldMaterial::~HdArnoldMaterial() @@ -456,9 +456,9 @@ void HdArnoldMaterial::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* rende volumeEntry = readNetwork(volumeNetwork, false); ClearUnusedNodes(surfaceEntry, displacementEntry, volumeEntry); } - _surface = surfaceEntry == nullptr ? _delegate->GetFallbackShader() : surfaceEntry; + _surface = surfaceEntry == nullptr ? _renderDelegate->GetFallbackShader() : surfaceEntry; _displacement = displacementEntry; - _volume = volumeEntry == nullptr ? _delegate->GetFallbackVolumeShader() : volumeEntry; + _volume = volumeEntry == nullptr ? _renderDelegate->GetFallbackVolumeShader() : volumeEntry; } *dirtyBits = HdMaterial::Clean; } @@ -610,7 +610,7 @@ AtNode* HdArnoldMaterial::GetLocalNode(const SdfPath& path, const AtString& node return nodeIt->second.node; } } - auto* ret = AiNode(_delegate->GetUniverse(), nodeType); + auto* ret = AiNode(_renderDelegate->GetUniverse(), nodeType); _nodes.emplace(path, MaterialData{ret, true}); if (ret == nullptr) { TF_DEBUG(HDARNOLD_MATERIAL).Msg(" unable to create node of type %s - aborting\n", nodeType.c_str()); diff --git a/render_delegate/material.h b/render_delegate/material.h index d7704dbea7..360faa1f30 100755 --- a/render_delegate/material.h +++ b/render_delegate/material.h @@ -48,10 +48,10 @@ class HdArnoldMaterial : public HdMaterial { public: /// Constructor for HdArnoldMaterial. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the material. HDARNOLD_API - HdArnoldMaterial(HdArnoldRenderDelegate* delegate, const SdfPath& id); + HdArnoldMaterial(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Destructor for HdArnoldMaterial. /// @@ -76,7 +76,7 @@ class HdArnoldMaterial : public HdMaterial { /// /// Currently does nothing. HDARNOLD_API - void Reload() { } + void Reload() {} /// Returns the Entry Point to the Surface Shader Network. /// @@ -174,7 +174,7 @@ class HdArnoldMaterial : public HdMaterial { /// Storage for nodes created by HdArnoldMaterial. std::unordered_map _nodes; - HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate. + HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Render Delegate. /// Pointer to the entry point to the Surface Shader Network. AtNode* _surface = nullptr; /// Pointer to the entry point to the Displacement Shader Network. diff --git a/render_delegate/mesh.cpp b/render_delegate/mesh.cpp index 9e16cc587b..7f592558fe 100644 --- a/render_delegate/mesh.cpp +++ b/render_delegate/mesh.cpp @@ -143,34 +143,34 @@ inline void _ConvertFaceVaryingPrimvarToBuiltin( } // namespace -HdArnoldMesh::HdArnoldMesh(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId) - : HdMesh(id, instancerId), _shape(str::polymesh, delegate, id, GetPrimId()) +HdArnoldMesh::HdArnoldMesh(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId) + : HdArnoldRprim(str::polymesh, renderDelegate, id, instancerId) { // The default value is 1, which won't work well in a Hydra context. - AiNodeSetByte(_shape.GetShape(), str::subdiv_iterations, 0); + AiNodeSetByte(GetArnoldNode(), str::subdiv_iterations, 0); } void HdArnoldMesh::Sync( - HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) { TF_UNUSED(reprToken); auto* param = reinterpret_cast(renderParam); const auto& id = GetId(); - const auto dirtyPrimvars = HdArnoldGetComputedPrimvars(delegate, id, *dirtyBits, _primvars) || + const auto dirtyPrimvars = HdArnoldGetComputedPrimvars(sceneDelegate, id, *dirtyBits, _primvars) || (*dirtyBits & HdChangeTracker::DirtyPrimvar); if (_primvars.count(HdTokens->points) != 0) { _numberOfPositionKeys = 1; } else if (HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->points)) { param->Interrupt(); - _numberOfPositionKeys = HdArnoldSetPositionFromPrimvar(_shape.GetShape(), id, delegate, str::vlist); + _numberOfPositionKeys = HdArnoldSetPositionFromPrimvar(GetArnoldNode(), id, sceneDelegate, str::vlist); } const auto dirtyTopology = HdChangeTracker::IsTopologyDirty(*dirtyBits, id); if (dirtyTopology) { param->Interrupt(); - const auto topology = GetMeshTopology(delegate); + const auto topology = GetMeshTopology(sceneDelegate); // We have to flip the orientation if it's left handed. const auto isLeftHanded = topology.GetOrientation() == PxOsdOpenSubdivTokens->leftHanded; _vertexCounts = topology.GetFaceVertexCounts(); @@ -182,6 +182,8 @@ void HdArnoldMesh::Sync( auto* nsides = static_cast(AiArrayMap(nsidesArray)); auto* vidxs = static_cast(AiArrayMap(vidxsArray)); _vertexCountSum = 0; + // We are manually calculating the sum of the vertex counts here, because we are filtering for negative values + // from the vertex indices array. if (isLeftHanded) { for (auto i = decltype(numFaces){0}; i < numFaces; ++i) { const auto vertexCount = _vertexCounts[i]; @@ -197,6 +199,8 @@ void HdArnoldMesh::Sync( } } else { // We still need _vertexCountSum as it is used to validate primvars. + // We are manually calculating the sum of the vertex counts here, because we are filtering for negative + // values from the vertex indices array. std::transform(_vertexCounts.begin(), _vertexCounts.end(), nsides, [&](const int i) -> uint32_t { if (Ai_unlikely(i <= 0)) { return 0; @@ -210,39 +214,38 @@ void HdArnoldMesh::Sync( }); _vertexCounts = {}; // We don't need this anymore. } - AiNodeSetArray(_shape.GetShape(), str::nsides, nsidesArray); - AiNodeSetArray(_shape.GetShape(), str::vidxs, vidxsArray); + AiNodeSetArray(GetArnoldNode(), str::nsides, nsidesArray); + AiNodeSetArray(GetArnoldNode(), str::vidxs, vidxsArray); const auto scheme = topology.GetScheme(); if (scheme == PxOsdOpenSubdivTokens->catmullClark || scheme == _tokens->catmark) { - AiNodeSetStr(_shape.GetShape(), str::subdiv_type, str::catclark); + AiNodeSetStr(GetArnoldNode(), str::subdiv_type, str::catclark); } else { - AiNodeSetStr(_shape.GetShape(), str::subdiv_type, str::none); + AiNodeSetStr(GetArnoldNode(), str::subdiv_type, str::none); } - AiNodeSetArray( - _shape.GetShape(), str::shidxs, HdArnoldGetShidxs(topology.GetGeomSubsets(), numFaces, _subsets)); + AiNodeSetArray(GetArnoldNode(), str::shidxs, HdArnoldGetShidxs(topology.GetGeomSubsets(), numFaces, _subsets)); } if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { param->Interrupt(); - _UpdateVisibility(delegate, dirtyBits); - _shape.SetVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); + _UpdateVisibility(sceneDelegate, dirtyBits); + SetShapeVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); } if (HdChangeTracker::IsDisplayStyleDirty(*dirtyBits, id)) { - const auto displayStyle = GetDisplayStyle(delegate); + const auto displayStyle = GetDisplayStyle(sceneDelegate); AiNodeSetByte( - _shape.GetShape(), str::subdiv_iterations, static_cast(std::max(0, displayStyle.refineLevel))); + GetArnoldNode(), str::subdiv_iterations, static_cast(std::max(0, displayStyle.refineLevel))); } auto transformDirtied = false; if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) { param->Interrupt(); - HdArnoldSetTransform(_shape.GetShape(), delegate, GetId()); + HdArnoldSetTransform(GetArnoldNode(), sceneDelegate, GetId()); transformDirtied = true; } if (HdChangeTracker::IsSubdivTagsDirty(*dirtyBits, id)) { - const auto subdivTags = GetSubdivTags(delegate); + const auto subdivTags = GetSubdivTags(sceneDelegate); const auto& cornerIndices = subdivTags.GetCornerIndices(); const auto& cornerWeights = subdivTags.GetCornerWeights(); const auto& creaseIndices = subdivTags.GetCreaseIndices(); @@ -282,8 +285,8 @@ void HdArnoldMesh::Sync( jj += creaseLength; } - AiNodeSetArray(_shape.GetShape(), str::crease_idxs, creaseIdxsArray); - AiNodeSetArray(_shape.GetShape(), str::crease_sharpness, creaseSharpnessArray); + AiNodeSetArray(GetArnoldNode(), str::crease_idxs, creaseIdxsArray); + AiNodeSetArray(GetArnoldNode(), str::crease_sharpness, creaseSharpnessArray); } auto materialsAssigned = false; @@ -303,10 +306,10 @@ void HdArnoldMesh::Sync( auto setMaterial = [&](const SdfPath& materialId, size_t arrayId) { const auto* material = reinterpret_cast( - delegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, materialId)); + sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, materialId)); if (material == nullptr) { - shader[arrayId] = isVolume ? _shape.GetDelegate()->GetFallbackVolumeShader() - : _shape.GetDelegate()->GetFallbackShader(); + shader[arrayId] = isVolume ? GetRenderDelegate()->GetFallbackVolumeShader() + : GetRenderDelegate()->GetFallbackShader(); dispMap[arrayId] = nullptr; } else { shader[arrayId] = isVolume ? material->GetVolumeShader() : material->GetSurfaceShader(); @@ -316,18 +319,18 @@ void HdArnoldMesh::Sync( for (auto subset = decltype(numSubsets){0}; subset < numSubsets; ++subset) { setMaterial(_subsets[subset], subset); } - setMaterial(delegate->GetMaterialId(id), numSubsets); + setMaterial(sceneDelegate->GetMaterialId(id), numSubsets); AiArrayUnmap(shaderArray); AiArrayUnmap(dispMapArray); - AiNodeSetArray(_shape.GetShape(), str::shader, shaderArray); - AiNodeSetArray(_shape.GetShape(), str::disp_map, dispMapArray); + AiNodeSetArray(GetArnoldNode(), str::shader, shaderArray); + AiNodeSetArray(GetArnoldNode(), str::disp_map, dispMapArray); }; if (dirtyPrimvars) { - HdArnoldGetPrimvars(delegate, id, *dirtyBits, _numberOfPositionKeys > 1, _primvars); + HdArnoldGetPrimvars(sceneDelegate, id, *dirtyBits, _numberOfPositionKeys > 1, _primvars); param->Interrupt(); const auto isVolume = _IsVolume(); - auto visibility = _shape.GetVisibility(); + auto visibility = GetShapeVisibility(); for (const auto& primvar : _primvars) { const auto& desc = primvar.second; if (!desc.dirtied) { @@ -335,55 +338,55 @@ void HdArnoldMesh::Sync( } if (desc.interpolation == HdInterpolationConstant) { - HdArnoldSetConstantPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value, &visibility); + HdArnoldSetConstantPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value, &visibility); } else if (desc.interpolation == HdInterpolationVertex) { if (primvar.first == _tokens->st || primvar.first == _tokens->uv) { _ConvertVertexPrimvarToBuiltin( - _shape.GetShape(), desc.value, str::uvlist, str::uvidxs); + GetArnoldNode(), desc.value, str::uvlist, str::uvidxs); } else if (primvar.first == HdTokens->normals) { if (desc.value.IsEmpty()) { HdArnoldSampledPrimvarType sample; - delegate->SamplePrimvar(id, primvar.first, &sample); + sceneDelegate->SamplePrimvar(id, primvar.first, &sample); sample.count = _numberOfPositionKeys; _ConvertVertexPrimvarToBuiltin( - _shape.GetShape(), sample, str::nlist, str::nidxs); + GetArnoldNode(), sample, str::nlist, str::nidxs); } else { _ConvertVertexPrimvarToBuiltin( - _shape.GetShape(), desc.value, str::nlist, str::nidxs); + GetArnoldNode(), desc.value, str::nlist, str::nidxs); } } else { // If we get to points here, it's a computed primvar, so we need to use a different function. if (primvar.first == HdTokens->points) { - HdArnoldSetPositionFromValue(_shape.GetShape(), str::vlist, desc.value); + HdArnoldSetPositionFromValue(GetArnoldNode(), str::vlist, desc.value); } else { - HdArnoldSetVertexPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value); + HdArnoldSetVertexPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value); } } } else if (desc.interpolation == HdInterpolationUniform) { - HdArnoldSetUniformPrimvar(_shape.GetShape(), primvar.first, desc.role, desc.value); + HdArnoldSetUniformPrimvar(GetArnoldNode(), primvar.first, desc.role, desc.value); } else if (desc.interpolation == HdInterpolationFaceVarying) { if (primvar.first == _tokens->st || primvar.first == _tokens->uv) { _ConvertFaceVaryingPrimvarToBuiltin( - _shape.GetShape(), desc.value, str::uvlist, str::uvidxs, &_vertexCounts, &_vertexCountSum); + GetArnoldNode(), desc.value, str::uvlist, str::uvidxs, &_vertexCounts, &_vertexCountSum); } else if (primvar.first == HdTokens->normals) { if (desc.value.IsEmpty()) { HdArnoldSampledPrimvarType sample; - delegate->SamplePrimvar(id, primvar.first, &sample); + sceneDelegate->SamplePrimvar(id, primvar.first, &sample); sample.count = _numberOfPositionKeys; _ConvertFaceVaryingPrimvarToBuiltin( - _shape.GetShape(), sample, str::nlist, str::nidxs, &_vertexCounts, &_vertexCountSum); + GetArnoldNode(), sample, str::nlist, str::nidxs, &_vertexCounts, &_vertexCountSum); } else { _ConvertFaceVaryingPrimvarToBuiltin( - _shape.GetShape(), desc.value, str::nlist, str::nidxs, &_vertexCounts, &_vertexCountSum); + GetArnoldNode(), desc.value, str::nlist, str::nidxs, &_vertexCounts, &_vertexCountSum); } } else { HdArnoldSetFaceVaryingPrimvar( - _shape.GetShape(), primvar.first, desc.role, desc.value, &_vertexCounts, &_vertexCountSum); + GetArnoldNode(), primvar.first, desc.role, desc.value, &_vertexCounts, &_vertexCountSum); } } } - _shape.SetVisibility(visibility); + SetShapeVisibility(visibility); // The mesh has changed, so we need to reassign materials. if (isVolume != _IsVolume()) { assignMaterials(); @@ -396,7 +399,7 @@ void HdArnoldMesh::Sync( assignMaterials(); } - _shape.Sync(this, *dirtyBits, delegate, param, transformDirtied); + SyncShape(*dirtyBits, sceneDelegate, param, transformDirtied); *dirtyBits = HdChangeTracker::Clean; } @@ -405,18 +408,9 @@ HdDirtyBits HdArnoldMesh::GetInitialDirtyBitsMask() const { return HdChangeTracker::Clean | HdChangeTracker::InitRepr | HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyTransform | HdChangeTracker::DirtyMaterialId | - HdChangeTracker::DirtyPrimID | HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyInstanceIndex | - HdChangeTracker::DirtyVisibility; + HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyVisibility | HdArnoldShape::GetInitialDirtyBitsMask(); } -HdDirtyBits HdArnoldMesh::_PropagateDirtyBits(HdDirtyBits bits) const { return bits & HdChangeTracker::AllDirty; } - -void HdArnoldMesh::_InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) -{ - TF_UNUSED(reprToken); - TF_UNUSED(dirtyBits); -} - -bool HdArnoldMesh::_IsVolume() const { return AiNodeGetFlt(_shape.GetShape(), str::step_size) > 0.0f; } +bool HdArnoldMesh::_IsVolume() const { return AiNodeGetFlt(GetArnoldNode(), str::step_size) > 0.0f; } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/mesh.h b/render_delegate/mesh.h index 9ff793d09b..3defc4ac51 100755 --- a/render_delegate/mesh.h +++ b/render_delegate/mesh.h @@ -40,21 +40,21 @@ #include "hdarnold.h" #include "render_delegate.h" -#include "shape.h" +#include "rprim.h" #include "utils.h" PXR_NAMESPACE_OPEN_SCOPE /// Utility class for translating Hydra Mesh to Arnold Polymesh. -class HdArnoldMesh : public HdMesh { +class HdArnoldMesh : public HdArnoldRprim { public: /// Constructor for HdArnoldMesh. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the mesh. /// @param instancerId Path to the Point Instancer for this mesh. HDARNOLD_API - HdArnoldMesh(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); + HdArnoldMesh(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); /// Destructor for HdArnoldMesh. /// @@ -64,12 +64,13 @@ class HdArnoldMesh : public HdMesh { /// Syncs the Hydra Mesh to the Arnold Polymesh. /// /// @param sceneDelegate Pointer to the Scene Delegate. - /// @param renderPaaram Pointer to a HdArnoldRenderParam instance. + /// @param renderParam Pointer to a HdArnoldRenderParam instance. /// @param dirtyBits Dirty Bits to sync. /// @param reprToken Token describing the representation of the mesh. HDARNOLD_API - void Sync(HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) - override; + void Sync( + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, + const TfToken& reprToken) override; /// Returns the initial Dirty Bits for the Primitive. /// @@ -78,29 +79,12 @@ class HdArnoldMesh : public HdMesh { HdDirtyBits GetInitialDirtyBitsMask() const override; protected: - /// Allows setting additional Dirty Bits based on the ones already set. - /// - /// @param bits The current Dirty Bits. - /// @return The new set of Dirty Bits which replace the original one. - HDARNOLD_API - HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override; - - /// Initialize a given representation for the mesh. - /// - /// @param reprName Name of the representation to initialize. - /// @param dirtyBits In/Out HdDirtyBits value, that allows the _InitRepr - /// function to set additional Dirty Bits if required for a given - /// representation. - HDARNOLD_API - void _InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) override; - /// Returns true if step size is bigger than zero, false otherwise. /// /// @return True if polymesh is a volume boundary. HDARNOLD_API bool _IsVolume() const; - HdArnoldShape _shape; ///< Utility class for the mesh and instances. HdArnoldPrimvarMap _primvars; ///< Precomputed list of primvars. HdArnoldSubsets _subsets; ///< Material ids from subsets. VtIntArray _vertexCounts; ///< Vertex Counts array for reversing vertex and primvar polygon order. diff --git a/render_delegate/openvdb_asset.cpp b/render_delegate/openvdb_asset.cpp index 4f529c3d40..0e8eb8b938 100644 --- a/render_delegate/openvdb_asset.cpp +++ b/render_delegate/openvdb_asset.cpp @@ -32,9 +32,9 @@ PXR_NAMESPACE_OPEN_SCOPE -HdArnoldOpenvdbAsset::HdArnoldOpenvdbAsset(HdArnoldRenderDelegate* delegate, const SdfPath& id) : HdField(id) +HdArnoldOpenvdbAsset::HdArnoldOpenvdbAsset(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id) : HdField(id) { - TF_UNUSED(delegate); + TF_UNUSED(renderDelegate); } void HdArnoldOpenvdbAsset::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits) diff --git a/render_delegate/openvdb_asset.h b/render_delegate/openvdb_asset.h index f780a00a20..ac3f7c3d4b 100755 --- a/render_delegate/openvdb_asset.h +++ b/render_delegate/openvdb_asset.h @@ -50,10 +50,10 @@ class HdArnoldOpenvdbAsset : public HdField { public: /// Constructor for HdArnoldOpenvdbAsset /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the OpenVDB Asset. HDARNOLD_API - HdArnoldOpenvdbAsset(HdArnoldRenderDelegate* delegate, const SdfPath& id); + HdArnoldOpenvdbAsset(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id); /// Syncing the Hydra Openvdb Asset to the Arnold Volume. /// diff --git a/render_delegate/points.cpp b/render_delegate/points.cpp index 80e049965b..e4202760d6 100644 --- a/render_delegate/points.cpp +++ b/render_delegate/points.cpp @@ -19,96 +19,86 @@ PXR_NAMESPACE_OPEN_SCOPE -HdArnoldPoints::HdArnoldPoints(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId) - : HdPoints(id, instancerId), _shape(str::points, delegate, id, GetPrimId()) +HdArnoldPoints::HdArnoldPoints(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId) + : HdArnoldRprim(str::points, renderDelegate, id, instancerId) { } -HdArnoldPoints::~HdArnoldPoints() {} - HdDirtyBits HdArnoldPoints::GetInitialDirtyBitsMask() const { return HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyTransform | HdChangeTracker::DirtyVisibility | HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyWidths | HdChangeTracker::DirtyMaterialId | - HdChangeTracker::DirtyInstanceIndex; + HdArnoldShape::GetInitialDirtyBitsMask(); } void HdArnoldPoints::Sync( - HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) { auto* param = reinterpret_cast(renderParam); const auto& id = GetId(); if (HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->points)) { param->Interrupt(); - HdArnoldSetPositionFromPrimvar(_shape.GetShape(), id, delegate, str::points); + HdArnoldSetPositionFromPrimvar(GetArnoldNode(), id, sceneDelegate, str::points); // HdPrman exports points like this, but this method does not support // motion blurred points. } else if (*dirtyBits & HdChangeTracker::DirtyPoints) { param->Interrupt(); - const auto pointsValue = delegate->Get(id, HdTokens->points); + const auto pointsValue = sceneDelegate->Get(id, HdTokens->points); if (!pointsValue.IsEmpty() && pointsValue.IsHolding()) { const auto& points = pointsValue.UncheckedGet(); auto* arr = AiArrayAllocate(points.size(), 1, AI_TYPE_VECTOR); AiArraySetKey(arr, 0, points.data()); - AiNodeSetArray(_shape.GetShape(), str::points, arr); + AiNodeSetArray(GetArnoldNode(), str::points, arr); } } if (HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->widths)) { param->Interrupt(); - HdArnoldSetRadiusFromPrimvar(_shape.GetShape(), id, delegate); + HdArnoldSetRadiusFromPrimvar(GetArnoldNode(), id, sceneDelegate); } if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { param->Interrupt(); - _UpdateVisibility(delegate, dirtyBits); - AiNodeSetByte(_shape.GetShape(), str::visibility, _sharedData.visible ? AI_RAY_ALL : uint8_t{0}); + _UpdateVisibility(sceneDelegate, dirtyBits); + AiNodeSetByte(GetArnoldNode(), str::visibility, _sharedData.visible ? AI_RAY_ALL : uint8_t{0}); } if (*dirtyBits & HdChangeTracker::DirtyMaterialId) { param->Interrupt(); const auto* material = reinterpret_cast( - delegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, delegate->GetMaterialId(id))); + sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, sceneDelegate->GetMaterialId(id))); if (material != nullptr) { - AiNodeSetPtr(_shape.GetShape(), str::shader, material->GetSurfaceShader()); + AiNodeSetPtr(GetArnoldNode(), str::shader, material->GetSurfaceShader()); } else { - AiNodeSetPtr(_shape.GetShape(), str::shader, _shape.GetDelegate()->GetFallbackShader()); + AiNodeSetPtr(GetArnoldNode(), str::shader, GetRenderDelegate()->GetFallbackShader()); } } if (*dirtyBits & HdChangeTracker::DirtyPrimvar) { param->Interrupt(); - for (const auto& primvar : delegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationConstant)) { - HdArnoldSetConstantPrimvar(_shape.GetShape(), id, delegate, primvar); + for (const auto& primvar : sceneDelegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationConstant)) { + HdArnoldSetConstantPrimvar(GetArnoldNode(), id, sceneDelegate, primvar); } auto convertToUniformPrimvar = [&](const HdPrimvarDescriptor& primvar) { if (primvar.name != HdTokens->points && primvar.name != HdTokens->widths) { - HdArnoldSetUniformPrimvar(_shape.GetShape(), id, delegate, primvar); + HdArnoldSetUniformPrimvar(GetArnoldNode(), id, sceneDelegate, primvar); } }; - for (const auto& primvar : delegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationUniform)) { + for (const auto& primvar : sceneDelegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationUniform)) { convertToUniformPrimvar(primvar); } - for (const auto& primvar : delegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationVertex)) { + for (const auto& primvar : sceneDelegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationVertex)) { // Per vertex attributes are uniform on points. convertToUniformPrimvar(primvar); } } - _shape.Sync(this, *dirtyBits, delegate, param); + SyncShape(*dirtyBits, sceneDelegate, param); *dirtyBits = HdChangeTracker::Clean; } -HdDirtyBits HdArnoldPoints::_PropagateDirtyBits(HdDirtyBits bits) const { return bits & HdChangeTracker::AllDirty; } - -void HdArnoldPoints::_InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) -{ - TF_UNUSED(reprToken); - TF_UNUSED(dirtyBits); -} - PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/points.h b/render_delegate/points.h index 1a95270f15..2c4cad6eb2 100755 --- a/render_delegate/points.h +++ b/render_delegate/points.h @@ -25,26 +25,25 @@ #include #include "render_delegate.h" -#include "shape.h" +#include "rprim.h" PXR_NAMESPACE_OPEN_SCOPE /// Utility class to handle point primitives. -class HdArnoldPoints : public HdPoints { +class HdArnoldPoints : public HdArnoldRprim { public: /// Constructor for HdArnoldPoints. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the points. /// @param instancerId Path to the Point Instancer for this points. HDARNOLD_API - HdArnoldPoints(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); + HdArnoldPoints(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); /// Destructor for HdArnoldPoints. /// /// Destory all Arnold Points and Ginstances. - HDARNOLD_API - ~HdArnoldPoints(); + ~HdArnoldPoints() = default; /// Returns the initial Dirty Bits for the Primitive. /// @@ -59,27 +58,9 @@ class HdArnoldPoints : public HdPoints { /// @param dirtyBits Dirty Bits to sync. /// @param reprToken Token describing the representation of the points. HDARNOLD_API - void Sync(HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) - override; - -protected: - /// Allows setting additional Dirty Bits based on the ones already set. - /// - /// @param bits The current Dirty Bits. - /// @return The new set of Dirty Bits which replace the original one. - HDARNOLD_API - HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override; - - /// Initialize a given representation for the points. - /// - /// @param reprName Name of the representation to initialize. - /// @param dirtyBits In/Out HdDirtyBits value, that allows the _InitRepr - /// function to set additional Dirty Bits if required for a given - /// representation. - HDARNOLD_API - void _InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) override; - - HdArnoldShape _shape; ///< Utility class for the points and the instances. + void Sync( + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, + const TfToken& reprToken) override; }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/render_buffer.cpp b/render_delegate/render_buffer.cpp index 7634c6dbc5..09bf0bd2cb 100644 --- a/render_delegate/render_buffer.cpp +++ b/render_delegate/render_buffer.cpp @@ -129,8 +129,7 @@ inline void _WriteBucket( const auto toStep = width * componentCount; const auto fromStep = bucketWidth * bucketComponentCount; - const auto copyOp = [](const typename HdFormatType::type& in) -> typename HdFormatType::type - { + const auto copyOp = [](const typename HdFormatType::type& in) -> typename HdFormatType::type { return _ConvertType::type, typename HdFormatType::type>(in); }; const auto dataWidth = xe - xo; diff --git a/render_delegate/render_delegate.cpp b/render_delegate/render_delegate.cpp index 02f0e57a80..00f0a87d7b 100644 --- a/render_delegate/render_delegate.cpp +++ b/render_delegate/render_delegate.cpp @@ -136,8 +136,8 @@ void _SetNodeParam(AtNode* node, const TfToken& key, const VtValue& value) inline const TfTokenVector& _SupportedRprimTypes() { - static const TfTokenVector r{HdPrimTypeTokens->mesh, HdPrimTypeTokens->volume, HdPrimTypeTokens->points, - HdPrimTypeTokens->basisCurves}; + static const TfTokenVector r{ + HdPrimTypeTokens->mesh, HdPrimTypeTokens->volume, HdPrimTypeTokens->points, HdPrimTypeTokens->basisCurves}; return r; } @@ -323,6 +323,7 @@ HdResourceRegistrySharedPtr HdArnoldRenderDelegate::_resourceRegistry; HdArnoldRenderDelegate::HdArnoldRenderDelegate() { + _lightLinkingChanged.store(false, std::memory_order_release); _id = SdfPath(TfToken(TfStringPrintf("/HdArnoldRenderDelegate_%p", this))); if (AiUniverseIsActive()) { TF_CODING_ERROR("There is already an active Arnold universe!"); @@ -386,7 +387,9 @@ HdArnoldRenderDelegate::~HdArnoldRenderDelegate() HdRenderParam* HdArnoldRenderDelegate::GetRenderParam() const { return _renderParam.get(); } -void HdArnoldRenderDelegate::CommitResources(HdChangeTracker* tracker) { TF_UNUSED(tracker); } +void HdArnoldRenderDelegate::CommitResources(HdChangeTracker* tracker) +{ +} const TfTokenVector& HdArnoldRenderDelegate::GetSupportedRprimTypes() const { return _SupportedRprimTypes(); } @@ -736,4 +739,114 @@ HdAovDescriptor HdArnoldRenderDelegate::GetDefaultAovDescriptor(const TfToken& n } } +void HdArnoldRenderDelegate::RegisterLightLinking(const TfToken& name, HdLight* light, bool isShadow) +{ + std::lock_guard guard(_lightLinkingMutex); + auto& links = isShadow ? _shadowLinks : _lightLinks; + auto it = links.find(name); + if (it == links.end()) { + if (!name.IsEmpty() || !links.empty()) { + _lightLinkingChanged.store(true, std::memory_order_release); + } + links.emplace(name, std::vector{light}); + } else { + if (std::find(it->second.begin(), it->second.end(), light) == it->second.end()) { + // We only trigger the change if we are registering a non-empty collection, or there are more than one + // collections. + if (!name.IsEmpty() || links.size() > 1) { + _lightLinkingChanged.store(true, std::memory_order_release); + } + it->second.push_back(light); + } + } +} + +void HdArnoldRenderDelegate::DeregisterLightLinking(const TfToken& name, HdLight* light, bool isShadow) +{ + std::lock_guard guard(_lightLinkingMutex); + auto& links = isShadow ? _shadowLinks : _lightLinks; + auto it = links.find(name); + if (it != links.end()) { + // We only trigger updates if either deregistering a named collection, or deregistering the empty + // collection and there are other collection. + if (!name.IsEmpty() || links.size() > 1) { + _lightLinkingChanged.store(true, std::memory_order_release); + } + it->second.erase(std::remove(it->second.begin(), it->second.end(), light), it->second.end()); + if (it->second.empty()) { + links.erase(name); + } + } +} + +void HdArnoldRenderDelegate::ApplyLightLinking(AtNode* shape, const VtArray& categories) +{ + std::lock_guard guard(_lightLinkingMutex); + // We need to reset the parameter if either there are no light links, or the only light link is the default + // group. + const auto lightEmpty = _lightLinks.empty() || (_lightLinks.size() == 1 && _lightLinks.count(TfToken{}) == 1); + const auto shadowEmpty = _shadowLinks.empty() || (_shadowLinks.size() == 1 && _shadowLinks.count(TfToken{}) == 1); + if (lightEmpty) { + AiNodeResetParameter(shape, str::use_light_group); + AiNodeResetParameter(shape, str::light_group); + } + if (shadowEmpty) { + AiNodeResetParameter(shape, str::use_shadow_group); + AiNodeResetParameter(shape, str::shadow_group); + } + if (lightEmpty && shadowEmpty) { + return; + } + auto applyGroups = [&](const AtString& group, const AtString& useGroup, const LightLinkingMap& links) { + std::vector lights; + for (const auto& category : categories) { + auto it = links.find(category); + if (it != links.end()) { + for (auto* light : it->second) { + auto* arnoldLight = HdArnoldLight::GetLightNode(light); + if (arnoldLight != nullptr) { + lights.push_back(arnoldLight); + } + } + } + } + // Add the lights with an empty collection to the list. + auto it = links.find(TfToken{}); + if (it != links.end()) { + for (auto* light : it->second) { + auto* arnoldLight = HdArnoldLight::GetLightNode(light); + if (arnoldLight != nullptr) { + lights.push_back(arnoldLight); + } + } + } + // TODO(pal): We should be able to remove this check. + if (lights.empty()) { + AiNodeResetParameter(shape, group); + AiNodeResetParameter(shape, useGroup); + } else { + AiNodeSetArray( + shape, group, AiArrayConvert(static_cast(lights.size()), 1, AI_TYPE_NODE, lights.data())); + AiNodeSetBool(shape, useGroup, true); + } + }; + if (!lightEmpty) { + applyGroups(str::light_group, str::use_light_group, _lightLinks); + } + if (!shadowEmpty) { + applyGroups(str::shadow_group, str::use_shadow_group, _shadowLinks); + } +} + +bool HdArnoldRenderDelegate::ShouldSkipIteration(HdRenderIndex* renderIndex) +{ + // If Light Linking have changed, we have to dirty the categories on all rprims to force updating the + // the light linking information. + if (_lightLinkingChanged.exchange(false, std::memory_order_acq_rel)) { + renderIndex->GetChangeTracker().MarkAllRprimsDirty(HdChangeTracker::DirtyCategories); + return true; + } + return false; +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/render_delegate.h b/render_delegate/render_delegate.h index 2bf8fc9eb2..a56345f809 100755 --- a/render_delegate/render_delegate.h +++ b/render_delegate/render_delegate.h @@ -33,6 +33,7 @@ #include #include "api.h" +#include #include #include #include @@ -181,8 +182,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate { /// Commits resources to the Render Delegate. /// /// This is a callback for a Render Delegate to move, update memory for - /// resources. It currently does nothing, as Arnold handles resource updates - /// during renders. + /// resources. /// /// @param tracker Pointer to the Change Tracker. HDARNOLD_API @@ -241,6 +241,38 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate { HDARNOLD_API HdAovDescriptor GetDefaultAovDescriptor(const TfToken& name) const override; + /// Registers a light in a light linking collection. + /// + /// @param name Name of the collection. + /// @param light Pointer to the Hydra Light object. + /// @param isShadow If the clection is for shadow or light linking. + HDARNOLD_API + void RegisterLightLinking(const TfToken& name, HdLight* light, bool isShadow = false); + + /// Deregisters a light in a light linking collection. + /// + /// @param name Name of the collection. + /// @param light Pointer to the Hydra Light object. + /// @param isShadow If the clection is for shadow or light linking. + HDARNOLD_API + void DeregisterLightLinking(const TfToken& name, HdLight* light, bool isShadow = false); + + /// Apply light linking to a shape. + /// + /// @param shape Pointer to the Arnold Shape. + /// @param categories List of categories the shape belongs to. + HDARNOLD_API + void ApplyLightLinking(AtNode* shape, const VtArray& categories); + + /// Tells whether or not the current convergence iteration should be skipped. + /// + /// This function can be used to skip calling the render function in HdRenderPass, so a sync step will be enforced + /// before the next iteration. + /// + /// @param renderIndex Pointer to the Hydra Render Index. + /// @return True if the iteration should be skipped. + bool ShouldSkipIteration(HdRenderIndex* renderIndex); + private: HdArnoldRenderDelegate(const HdArnoldRenderDelegate&) = delete; HdArnoldRenderDelegate& operator=(const HdArnoldRenderDelegate&) = delete; @@ -254,6 +286,12 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate { /// Pointer to the shared Resource Registry. static HdResourceRegistrySharedPtr _resourceRegistry; + using LightLinkingMap = std::unordered_map, TfToken::HashFunctor>; + + std::mutex _lightLinkingMutex; ///< Mutex to lock all light linking operations. + LightLinkingMap _lightLinks; ///< Light Link categories. + LightLinkingMap _shadowLinks; ///< Shadow Link categories. + std::atomic _lightLinkingChanged; ///< Whether or not Light Linking have changed. /// Pointer to an instance of HdArnoldRenderParam. /// /// This is shared with all the primitives, so they can control the flow of diff --git a/render_delegate/render_pass.cpp b/render_delegate/render_pass.cpp index dc5be25757..0f24c42a7b 100644 --- a/render_delegate/render_pass.cpp +++ b/render_delegate/render_pass.cpp @@ -121,12 +121,12 @@ struct ArnoldAOVType { } }; -const ArnoldAOVType AOVTypeINT {"INT", str::aov_write_int, str::user_data_int}; -const ArnoldAOVType AOVTypeFLOAT {"FLOAT", str::aov_write_float, str::user_data_float}; -const ArnoldAOVType AOVTypeVECTOR {"VECTOR", str::aov_write_vector, str::user_data_rgb}; -const ArnoldAOVType AOVTypeVECTOR2 {"VECTOR2", str::aov_write_vector, str::user_data_rgb}; -const ArnoldAOVType AOVTypeRGB {"RGB", str::aov_write_rgb, str::user_data_rgb}; -const ArnoldAOVType AOVTypeRGBA {"RGBA", str::aov_write_rgba, str::user_data_rgba}; +const ArnoldAOVType AOVTypeINT{"INT", str::aov_write_int, str::user_data_int}; +const ArnoldAOVType AOVTypeFLOAT{"FLOAT", str::aov_write_float, str::user_data_float}; +const ArnoldAOVType AOVTypeVECTOR{"VECTOR", str::aov_write_vector, str::user_data_rgb}; +const ArnoldAOVType AOVTypeVECTOR2{"VECTOR2", str::aov_write_vector, str::user_data_rgb}; +const ArnoldAOVType AOVTypeRGB{"RGB", str::aov_write_rgb, str::user_data_rgb}; +const ArnoldAOVType AOVTypeRGBA{"RGBA", str::aov_write_rgba, str::user_data_rgba}; // The rules here: // - Anything with 4 components -> RGBA @@ -254,17 +254,17 @@ const TfToken& _GetTokenFromRenderBufferType(const HdRenderBuffer* buffer) } // namespace HdArnoldRenderPass::HdArnoldRenderPass( - HdArnoldRenderDelegate* delegate, HdRenderIndex* index, const HdRprimCollection& collection) + HdArnoldRenderDelegate* renderDelegate, HdRenderIndex* index, const HdRprimCollection& collection) : HdRenderPass(index, collection), - _delegate(delegate), + _renderDelegate(renderDelegate), _fallbackColor(SdfPath::EmptyPath()), _fallbackDepth(SdfPath::EmptyPath()), _fallbackPrimId(SdfPath::EmptyPath()) { - auto* universe = _delegate->GetUniverse(); + auto* universe = _renderDelegate->GetUniverse(); _camera = AiNode(universe, str::persp_camera); AiNodeSetPtr(AiUniverseGetOptions(universe), str::camera, _camera); - AiNodeSetStr(_camera, str::name, _delegate->GetLocalNodeName(str::renderPassCamera)); + AiNodeSetStr(_camera, str::name, _renderDelegate->GetLocalNodeName(str::renderPassCamera)); const auto defaultFilter = TfGetEnvSetting(HDARNOLD_default_filter); const auto defaultFilterAttributes = TfGetEnvSetting(HDARNOLD_default_filter_attributes); _defaultFilter = AiNode(universe, defaultFilter.c_str()); @@ -275,11 +275,11 @@ HdArnoldRenderPass::HdArnoldRenderPass( if (!defaultFilterAttributes.empty()) { AiNodeSetAttributes(_defaultFilter, defaultFilterAttributes.c_str()); } - AiNodeSetStr(_defaultFilter, str::name, _delegate->GetLocalNodeName(str::renderPassFilter)); + AiNodeSetStr(_defaultFilter, str::name, _renderDelegate->GetLocalNodeName(str::renderPassFilter)); _closestFilter = AiNode(universe, str::closest_filter); - AiNodeSetStr(_closestFilter, str::name, _delegate->GetLocalNodeName(str::renderPassClosestFilter)); + AiNodeSetStr(_closestFilter, str::name, _renderDelegate->GetLocalNodeName(str::renderPassClosestFilter)); _mainDriver = AiNode(universe, str::HdArnoldDriverMain); - AiNodeSetStr(_mainDriver, str::name, _delegate->GetLocalNodeName(str::renderPassMainDriver)); + AiNodeSetStr(_mainDriver, str::name, _renderDelegate->GetLocalNodeName(str::renderPassMainDriver)); // Even though we are not displaying the prim id buffer, we still need it to detect background pixels. // clang-format off @@ -318,23 +318,23 @@ HdArnoldRenderPass::~HdArnoldRenderPass() void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassState, const TfTokenVector& renderTags) { TF_UNUSED(renderTags); - auto* renderParam = reinterpret_cast(_delegate->GetRenderParam()); + auto* renderParam = reinterpret_cast(_renderDelegate->GetRenderParam()); const auto vp = renderPassState->GetViewport(); const auto* currentUniverseCamera = - static_cast(AiNodeGetPtr(AiUniverseGetOptions(_delegate->GetUniverse()), str::camera)); + static_cast(AiNodeGetPtr(AiUniverseGetOptions(_renderDelegate->GetUniverse()), str::camera)); const auto* camera = reinterpret_cast(renderPassState->GetCamera()); const auto useOwnedCamera = camera == nullptr; // If camera is nullptr from the render pass state, we are using a camera created by the renderpass. if (useOwnedCamera) { if (currentUniverseCamera != _camera) { renderParam->Interrupt(); - AiNodeSetPtr(AiUniverseGetOptions(_delegate->GetUniverse()), str::camera, _camera); + AiNodeSetPtr(AiUniverseGetOptions(_renderDelegate->GetUniverse()), str::camera, _camera); } } else { if (currentUniverseCamera != camera->GetCamera()) { renderParam->Interrupt(); - AiNodeSetPtr(AiUniverseGetOptions(_delegate->GetUniverse()), str::camera, camera->GetCamera()); + AiNodeSetPtr(AiUniverseGetOptions(_renderDelegate->GetUniverse()), str::camera, camera->GetCamera()); } } @@ -359,7 +359,7 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt renderParam->Interrupt(false); _width = width; _height = height; - auto* options = _delegate->GetOptions(); + auto* options = _renderDelegate->GetOptions(); AiNodeSetInt(options, str::xres, _width); AiNodeSetInt(options, str::yres, _height); } @@ -416,7 +416,7 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt // stick to UNorm8. if (!_usingFallbackBuffers) { renderParam->Interrupt(false); - AiNodeSetArray(_delegate->GetOptions(), str::outputs, AiArrayCopy(_fallbackOutputs)); + AiNodeSetArray(_renderDelegate->GetOptions(), str::outputs, AiArrayCopy(_fallbackOutputs)); _usingFallbackBuffers = true; AiNodeSetPtr(_mainDriver, str::aov_pointer, &_fallbackBuffers); AiNodeSetPtr(_mainDriver, str::color_pointer, &_fallbackColor); @@ -475,11 +475,11 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt if (filterType.empty()) { return nullptr; } - buffer.filter = AiNode(_delegate->GetUniverse(), filterType.c_str()); + buffer.filter = AiNode(_renderDelegate->GetUniverse(), filterType.c_str()); if (buffer.filter == nullptr) { return nullptr; } - const auto filterNameStr = _delegate->GetLocalNodeName( + const auto filterNameStr = _renderDelegate->GetLocalNodeName( AtString{TfStringPrintf("HdArnoldRenderPass_filter_%p", buffer.filter).c_str()}); AiNodeSetStr(buffer.filter, str::name, filterNameStr); const auto* nodeEntry = AiNodeGetNodeEntry(buffer.filter); @@ -541,8 +541,8 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt const auto format = _GetOptionalSetting( binding.aovSettings, _tokens->dataType, _GetTokenFromRenderBufferType(buffer.buffer)); // Creating a separate driver for each aov. - buffer.driver = AiNode(_delegate->GetUniverse(), str::HdArnoldDriverAOV); - const auto driverNameStr = _delegate->GetLocalNodeName( + buffer.driver = AiNode(_renderDelegate->GetUniverse(), str::HdArnoldDriverAOV); + const auto driverNameStr = _renderDelegate->GetLocalNodeName( AtString{TfStringPrintf("HdArnoldRenderPass_aov_driver_%p", buffer.driver).c_str()}); AiNodeSetStr(buffer.driver, str::name, driverNameStr); AiNodeSetPtr(buffer.driver, str::aov_pointer, buffer.buffer); @@ -558,18 +558,18 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt aovName = binding.aovName.GetText(); // We need to add a aov write shader to the list of aov_shaders on the options node. Each // of this shader will be executed on every surface. - buffer.writer = AiNode(_delegate->GetUniverse(), arnoldTypes.writer); + buffer.writer = AiNode(_renderDelegate->GetUniverse(), arnoldTypes.writer); if (sourceName == "st" || sourceName == "uv") { // st and uv are written to the built-in UV - buffer.reader = AiNode(_delegate->GetUniverse(), str::utility); + buffer.reader = AiNode(_renderDelegate->GetUniverse(), str::utility); AiNodeSetStr(buffer.reader, str::color_mode, str::uv); AiNodeSetStr(buffer.reader, str::shade_mode, str::flat); } else { - buffer.reader = AiNode(_delegate->GetUniverse(), arnoldTypes.reader); + buffer.reader = AiNode(_renderDelegate->GetUniverse(), arnoldTypes.reader); AiNodeSetStr(buffer.reader, str::attribute, sourceName.c_str()); } - const auto writerName = _delegate->GetLocalNodeName( + const auto writerName = _renderDelegate->GetLocalNodeName( AtString{TfStringPrintf("HdArnoldRenderPass_aov_writer_%p", buffer.writer).c_str()}); - const auto readerName = _delegate->GetLocalNodeName( + const auto readerName = _renderDelegate->GetLocalNodeName( AtString{TfStringPrintf("HdArnoldRenderPass_aov_reader_%p", buffer.reader).c_str()}); AiNodeSetStr(buffer.writer, str::name, writerName); AiNodeSetStr(buffer.reader, str::name, readerName); @@ -588,15 +588,15 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt outputs += 1; } AiArrayUnmap(outputsArray); - AiNodeSetArray(_delegate->GetOptions(), str::outputs, outputsArray); + AiNodeSetArray(_renderDelegate->GetOptions(), str::outputs, outputsArray); AiNodeSetArray( - _delegate->GetOptions(), str::light_path_expressions, + _renderDelegate->GetOptions(), str::light_path_expressions, lightPathExpressions.empty() ? AiArray(0, 1, AI_TYPE_STRING) : AiArrayConvert( static_cast(lightPathExpressions.size()), 1, AI_TYPE_STRING, lightPathExpressions.data())); AiNodeSetArray( - _delegate->GetOptions(), str::aov_shaders, + _renderDelegate->GetOptions(), str::aov_shaders, aovShaders.empty() ? AiArray(0, 1, AI_TYPE_NODE) : AiArrayConvert(static_cast(aovShaders.size()), 1, AI_TYPE_NODE, aovShaders.data())); @@ -606,7 +606,11 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt } #endif - const auto renderStatus = renderParam->Render(); + // We skip an iteration step if the render delegate tells us to do so, this is the easiest way to force + // a sync step before calling the render function. Currently, this is used to trigger light linking updates. + const auto renderStatus = _renderDelegate->ShouldSkipIteration(GetRenderIndex()) + ? HdArnoldRenderParam::Status::Converging + : renderParam->Render(); _isConverged = renderStatus != HdArnoldRenderParam::Status::Converging; // We need to set the converged status of the render buffers. diff --git a/render_delegate/render_pass.h b/render_delegate/render_pass.h index 5465bb67e5..d36d7e3d9a 100755 --- a/render_delegate/render_pass.h +++ b/render_delegate/render_pass.h @@ -53,11 +53,12 @@ class HdArnoldRenderPass : public HdRenderPass { public: /// Constructor for HdArnoldRenderPass. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param index Pointer to the Render Index. /// @param collection RPrim Collection to bind for rendering. HDARNOLD_API - HdArnoldRenderPass(HdArnoldRenderDelegate* delegate, HdRenderIndex* index, const HdRprimCollection& collection); + HdArnoldRenderPass( + HdArnoldRenderDelegate* renderDelegate, HdRenderIndex* index, const HdRprimCollection& collection); /// Destructor for HdArnoldRenderPass. HDARNOLD_API ~HdArnoldRenderPass() override; @@ -96,11 +97,11 @@ class HdArnoldRenderPass : public HdRenderPass { HdArnoldRenderBuffer _fallbackPrimId; ///< Prim ID buffer if there are no aov bindings. AtArray* _fallbackOutputs; ///< AtArray storing the fallback outputs definitions. - HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate. - AtNode* _camera = nullptr; ///< Pointer to the Arnold Camera. - AtNode* _defaultFilter = nullptr; ///< Pointer to the default Arnold Filter. - AtNode* _closestFilter = nullptr; ///< Pointer to the closest Arnold Filter. - AtNode* _mainDriver = nullptr; ///< Pointer to the Arnold Driver writing color, position and depth. + HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Render Delegate. + AtNode* _camera = nullptr; ///< Pointer to the Arnold Camera. + AtNode* _defaultFilter = nullptr; ///< Pointer to the default Arnold Filter. + AtNode* _closestFilter = nullptr; ///< Pointer to the closest Arnold Filter. + AtNode* _mainDriver = nullptr; ///< Pointer to the Arnold Driver writing color, position and depth. #ifndef USD_DO_NOT_BLIT #ifdef USD_HAS_FULLSCREEN_SHADER diff --git a/render_delegate/rprim.h b/render_delegate/rprim.h new file mode 100644 index 0000000000..b02d685d64 --- /dev/null +++ b/render_delegate/rprim.h @@ -0,0 +1,115 @@ +// Copyright 2021 Autodesk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/// @file gprim.h +/// +/// Utilities for handling common gprim behavior. +#pragma once + +#include "api.h" + +#include + +#include + +#include + +#include "render_delegate.h" +#include "shape.h" + +PXR_NAMESPACE_OPEN_SCOPE + +template +class HdArnoldRprim : public HydraType { +public: + /// Constructor for HdArnoldRprim. + /// + /// @param shapeType AtString storing the type of the Arnold Shape node. + /// @param renderDelegate Pointer to the Render Delegate. + /// @param id Path to the primitive. + /// @param instancerId Path to the point instancer. + HDARNOLD_API + HdArnoldRprim( + const AtString& shapeType, HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, + const SdfPath& instancerId) + : HydraType(id, instancerId), + _renderDelegate(renderDelegate), + _shape(shapeType, renderDelegate, id, HydraType::GetPrimId()) + { + } + + /// Destructor for HdArnoldRprim. + /// + /// Frees the shape and all the ginstances created. + virtual ~HdArnoldRprim() = default; + /// Gets the Arnold Shape. + /// + /// @return Reference to the Arnold Shape. + HdArnoldShape& GetShape() { return _shape; } + /// Gets the Arnold Shape. + /// + /// @return Constant reference to the Arnold Shape. + const HdArnoldShape& GetShape() const { return _shape; } + /// Gets the Arnold Node from the shape. + /// + /// @return Pointer to the Arnold Node. + AtNode* GetArnoldNode() { return _shape.GetShape(); } + /// Gets the Arnold Node from the shape. + /// + /// @return Pointer to the Arnold Node. + const AtNode* GetArnoldNode() const { return _shape.GetShape(); } + /// Gets the Render Delegate. + /// + /// @return Pointer to the Render Delegate. + HdArnoldRenderDelegate* GetRenderDelegate() { return _renderDelegate; } + /// Syncs internal data and arnold state with hydra. + HDARNOLD_API + void SyncShape( + HdDirtyBits dirtyBits, HdSceneDelegate* sceneDelegate, HdArnoldRenderParam* param, bool force = false) + { + _shape.Sync(this, dirtyBits, _renderDelegate, sceneDelegate, param, force); + } + /// Sets the internal visibility parameter. + /// + /// @param visibility New value for visibility. + HDARNOLD_API + void SetShapeVisibility(uint8_t visibility) { _shape.SetVisibility(visibility); } + /// Gets the internal visibility parameter. + /// + /// @return Visibility of the shape. + uint8_t GetShapeVisibility() const { return _shape.GetVisibility(); } + /// Allows setting additional Dirty Bits based on the ones already set. + /// + /// @param bits The current Dirty Bits. + /// @return The new set of Dirty Bits which replace the original one. + HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override { return bits & HdChangeTracker::AllDirty; } + /// Initialize a given representation for the rprim. + /// + /// Currently unused. + /// + /// @param reprName Name of the representation to initialize. + /// @param dirtyBits In/Out HdDirtyBits value, that allows the _InitRepr + /// function to set additional Dirty Bits if required for a given + /// representation. + void _InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) override + { + TF_UNUSED(reprToken); + TF_UNUSED(dirtyBits); + } + +protected: + HdArnoldShape _shape; ///< HdArnoldShape to handle instances and shape creation. + HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Arnold Render Delegate. +}; + +PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/render_delegate/shape.cpp b/render_delegate/shape.cpp index 8c21fe272a..f77d062ea8 100644 --- a/render_delegate/shape.cpp +++ b/render_delegate/shape.cpp @@ -20,10 +20,9 @@ PXR_NAMESPACE_OPEN_SCOPE HdArnoldShape::HdArnoldShape( - const AtString& shapeType, HdArnoldRenderDelegate* delegate, const SdfPath& id, const int32_t primId) - : _delegate(delegate) + const AtString& shapeType, HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const int32_t primId) { - _shape = AiNode(delegate->GetUniverse(), shapeType); + _shape = AiNode(renderDelegate->GetUniverse(), shapeType); AiNodeSetStr(_shape, str::name, id.GetText()); _SetPrimId(primId); } @@ -31,36 +30,30 @@ HdArnoldShape::HdArnoldShape( HdArnoldShape::~HdArnoldShape() { AiNodeDestroy(_shape); -#ifdef HDARNOLD_USE_INSTANCER if (_instancer != nullptr) { AiNodeDestroy(_instancer); } -#else - for (auto* instance : _instances) { - AiNodeDestroy(instance); - } -#endif } void HdArnoldShape::Sync( - HdRprim* rprim, HdDirtyBits dirtyBits, HdSceneDelegate* sceneDelegate, HdArnoldRenderParam* param, bool force) + HdRprim* rprim, HdDirtyBits dirtyBits, HdArnoldRenderDelegate* renderDelegate, HdSceneDelegate* sceneDelegate, + HdArnoldRenderParam* param, bool force) { auto& id = rprim->GetId(); if (HdChangeTracker::IsPrimIdDirty(dirtyBits, id)) { _SetPrimId(rprim->GetPrimId()); } - _SyncInstances(dirtyBits, sceneDelegate, param, id, rprim->GetInstancerId(), force); + if (dirtyBits | HdChangeTracker::DirtyCategories) { + renderDelegate->ApplyLightLinking(_shape, sceneDelegate->GetCategories(id)); + } + _SyncInstances(dirtyBits, renderDelegate, sceneDelegate, param, id, rprim->GetInstancerId(), force); } void HdArnoldShape::SetVisibility(uint8_t visibility) { // Either the shape is not instanced or the instances are not yet created. In either case we can set the visibility // on the shape. -#ifdef HDARNOLD_USE_INSTANCER if (_instancer == nullptr) { -#else - if (_instances.empty()) { -#endif AiNodeSetByte(_shape, str::visibility, visibility); } _visibility = visibility; @@ -77,8 +70,8 @@ void HdArnoldShape::_SetPrimId(int32_t primId) } void HdArnoldShape::_SyncInstances( - HdDirtyBits dirtyBits, HdSceneDelegate* sceneDelegate, HdArnoldRenderParam* param, const SdfPath& id, - const SdfPath& instancerId, bool force) + HdDirtyBits dirtyBits, HdArnoldRenderDelegate* renderDelegate, HdSceneDelegate* sceneDelegate, + HdArnoldRenderParam* param, const SdfPath& id, const SdfPath& instancerId, bool force) { // The primitive is not instanced. Instancer IDs are not supposed to be changed during the lifetime of the shape. if (instancerId.IsEmpty()) { @@ -90,30 +83,17 @@ void HdArnoldShape::_SyncInstances( if (!HdChangeTracker::IsInstancerDirty(dirtyBits, id) && !HdChangeTracker::IsInstanceIndexDirty(dirtyBits, id) && !force) { // Visibility still could have changed outside the shape. -#ifdef HDARNOLD_USE_INSTANCER _UpdateInstanceVisibility(1, param); -#else - _UpdateInstanceVisibility(_instances.size(), param); -#endif return; } param->Interrupt(); // We need to hide the source mesh. AiNodeSetByte(_shape, str::visibility, 0); -#ifndef HDARNOLD_USE_INSTANCER -#if 1 // Forcing the re-creation of instances. - for (auto* instance : _instances) { - AiNodeDestroy(instance); - } - _instances.clear(); -#endif -#endif auto& renderIndex = sceneDelegate->GetRenderIndex(); auto* instancer = static_cast(renderIndex.GetInstancer(instancerId)); const auto instanceMatrices = instancer->CalculateInstanceMatrices(id); -#ifdef HDARNOLD_USE_INSTANCER if (_instancer == nullptr) { - _instancer = AiNode(_delegate->GetUniverse(), str::instancer); + _instancer = AiNode(renderDelegate->GetUniverse(), str::instancer); std::stringstream ss; ss << AiNodeGetName(_shape) << "_instancer"; AiNodeSetStr(_instancer, str::name, ss.str().c_str()); @@ -136,33 +116,10 @@ void HdArnoldShape::_SyncInstances( AiNodeSetArray(_instancer, str::node_idxs, nodeIdxsArray); AiNodeSetArray(_instancer, str::instance_visibility, AiArray(1, 1, AI_TYPE_BYTE, _visibility)); instancer->SetPrimvars(_instancer, id, instanceMatrices.size()); -#else - const auto oldSize = _instances.size(); - const auto newSize = instanceMatrices.size(); - for (auto i = newSize; i < oldSize; ++i) { - AiNodeDestroy(_instances[i]); - } - - _instances.resize(newSize); - for (auto i = oldSize; i < newSize; ++i) { - auto* instance = AiNode(_delegate->GetUniverse(), str::ginstance); - AiNodeSetByte(instance, str::visibility, _visibility); - AiNodeSetPtr(instance, str::node, _shape); - _instances[i] = instance; - std::stringstream ss; - ss << AiNodeGetName(_shape) << "_instance_" << i; - AiNodeSetStr(instance, str::name, ss.str().c_str()); - } - _UpdateInstanceVisibility(oldSize); - for (auto i = decltype(newSize){0}; i < newSize; ++i) { - AiNodeSetMatrix(_instances[i], str::matrix, HdArnoldConvertMatrix(instanceMatrices[i])); - } -#endif } void HdArnoldShape::_UpdateInstanceVisibility(size_t count, HdArnoldRenderParam* param) { -#ifdef HDARNOLD_USE_INSTANCER if (_instancer == nullptr) { return; } @@ -177,26 +134,6 @@ void HdArnoldShape::_UpdateInstanceVisibility(size_t count, HdArnoldRenderParam* param->Interrupt(); } AiNodeSetArray(_instancer, str::instance_visibility, AiArray(1, 1, AI_TYPE_BYTE, _visibility)); -#else - if (count == 0 || _instances.empty()) { - return; - } - // The instance visibilities should be kept in sync all the time, so it's okay to check against the first - // instance's visibility to see if anything has changed. - const auto currentVisibility = AiNodeGetByte(_instances.front(), str::visibility); - // No need to update anything. - if (currentVisibility == _visibility) { - return; - } - // If param is not nullptr, we have to stop the rendering process and signal that we have to changed something. - if (param != nullptr) { - param->Interrupt(); - } - count = std::min(count, _instances.size()); - for (auto index = decltype(count){0}; index < count; index += 1) { - AiNodeSetByte(_instances[index], str::visibility, _visibility); - } -#endif } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/shape.h b/render_delegate/shape.h index 4368eac69f..4b6f7a251a 100755 --- a/render_delegate/shape.h +++ b/render_delegate/shape.h @@ -36,10 +36,12 @@ class HdArnoldShape { /// Constructor for HdArnoldShape. /// /// @param shapeType AtString storing the type of the Arnold Shape node. - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the primitive. + /// @param primId Integer ID of the primitive used for the primID pass. HDARNOLD_API - HdArnoldShape(const AtString& shapeType, HdArnoldRenderDelegate* delegate, const SdfPath& id, const int32_t primId); + HdArnoldShape( + const AtString& shapeType, HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const int32_t primId); /// Destructor for HdArnoldShape. /// @@ -58,16 +60,11 @@ class HdArnoldShape { /// /// @return Constant pointer to the Arnold Shape. const AtNode* GetShape() const { return _shape; } - /// Gets the Render Delegate. - /// - /// @return Pointer to the Render Delegate. - HdArnoldRenderDelegate* GetDelegate() { return _delegate; } /// Syncs internal data and arnold state with hydra. HDARNOLD_API void Sync( - HdRprim* rprim, HdDirtyBits dirtyBits, HdSceneDelegate* sceneDelegate, HdArnoldRenderParam* param, - bool force = false); - + HdRprim* rprim, HdDirtyBits dirtyBits, HdArnoldRenderDelegate* renderDelegate, HdSceneDelegate* sceneDelegate, + HdArnoldRenderParam* param, bool force = false); /// Sets the internal visibility parameter. /// /// @param visibility New value for visibility. @@ -77,7 +74,16 @@ class HdArnoldShape { /// Gets the internal visibility parameter. /// /// @return Visibility of the shape. - uint8_t GetVisibility() { return _visibility; } + uint8_t GetVisibility() const { return _visibility; } + + /// Returns the Initial Dirty Bits handled by HdArnoldShape. + /// + /// @return The initial dirty bit mask. + static HdDirtyBits GetInitialDirtyBitsMask() + { + return HdChangeTracker::DirtyInstancer | HdChangeTracker::DirtyInstanceIndex | + HdChangeTracker::DirtyCategories | HdChangeTracker::DirtyPrimID; + } protected: /// Sets a new hydra-provided primId. @@ -95,22 +101,17 @@ class HdArnoldShape { /// @param instancerId Path to the Point Instancer. /// @param force Forces updating of the instances even if they are not dirtied. void _SyncInstances( - HdDirtyBits dirtyBits, HdSceneDelegate* sceneDelegate, HdArnoldRenderParam* param, const SdfPath& id, - const SdfPath& instancerId, bool force); + HdDirtyBits dirtyBits, HdArnoldRenderDelegate* renderDelegate, HdSceneDelegate* sceneDelegate, + HdArnoldRenderParam* param, const SdfPath& id, const SdfPath& instancerId, bool force); /// Checks if existing instance visibility for the first @param count instances. /// /// @param count Number of instance visibilities to update. /// @param param HdArnoldRenderParam to stop rendering if it's not nullptr. void _UpdateInstanceVisibility(size_t count, HdArnoldRenderParam* param = nullptr); -#ifdef HDARNOLD_USE_INSTANCER - AtNode* _instancer = nullptr; ///< Pointer to the Arnold Instancer. -#else - std::vector _instances; ///< Storing Pointers to the ginstances. -#endif - AtNode* _shape; ///< Pointer to the Arnold Shape. - HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate. - uint8_t _visibility = AI_RAY_ALL; ///< Visibility of the mesh. + AtNode* _instancer = nullptr; ///< Pointer to the Arnold Instancer. + AtNode* _shape; ///< Pointer to the Arnold Shape. + uint8_t _visibility = AI_RAY_ALL; ///< Visibility of the mesh. }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/render_delegate/utils.cpp b/render_delegate/utils.cpp index bdbbf970cd..5b0fd351cf 100644 --- a/render_delegate/utils.cpp +++ b/render_delegate/utils.cpp @@ -625,12 +625,12 @@ GfMatrix4f HdArnoldConvertMatrix(const AtMatrix& in) return out; } -void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* delegate, const SdfPath& id) +void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* sceneDelegate, const SdfPath& id) { // For now this is hardcoded to two samples and 0.0 / 1.0 sample times. constexpr size_t maxSamples = 2; HdTimeSampleArray xf{}; - delegate->SampleTransform(id, &xf); + sceneDelegate->SampleTransform(id, &xf); if (Ai_unlikely(xf.count == 0)) { AiNodeSetArray(node, str::matrix, AiArray(1, 1, AI_TYPE_MATRIX, AiM4Identity())); AiNodeResetParameter(node, str::motion_start); @@ -653,11 +653,11 @@ void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* delegate, const SdfPath } } -void HdArnoldSetTransform(const std::vector& nodes, HdSceneDelegate* delegate, const SdfPath& id) +void HdArnoldSetTransform(const std::vector& nodes, HdSceneDelegate* sceneDelegate, const SdfPath& id) { constexpr size_t maxSamples = 3; HdTimeSampleArray xf{}; - delegate->SampleTransform(id, &xf); + sceneDelegate->SampleTransform(id, &xf); const auto nodeCount = nodes.size(); if (Ai_unlikely(xf.count == 0)) { for (auto i = decltype(nodeCount){1}; i < nodeCount; ++i) { @@ -856,11 +856,11 @@ void HdArnoldSetConstantPrimvar( } void HdArnoldSetConstantPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc, + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc, uint8_t* visibility) { HdArnoldSetConstantPrimvar( - node, primvarDesc.name, primvarDesc.role, delegate->Get(id, primvarDesc.name), visibility); + node, primvarDesc.name, primvarDesc.role, sceneDelegate->Get(id, primvarDesc.name), visibility); } void HdArnoldSetUniformPrimvar(AtNode* node, const TfToken& name, const TfToken& role, const VtValue& value) @@ -882,10 +882,10 @@ void HdArnoldSetVertexPrimvar(AtNode* node, const TfToken& name, const TfToken& } void HdArnoldSetVertexPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc) + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc) { _DeclareAndAssignFromArray( - node, primvarDesc.name, _tokens->varying, delegate->Get(id, primvarDesc.name), + node, primvarDesc.name, _tokens->varying, sceneDelegate->Get(id, primvarDesc.name), primvarDesc.role == HdPrimvarRoleTokens->color); } @@ -905,11 +905,12 @@ void HdArnoldSetFaceVaryingPrimvar( } void HdArnoldSetFaceVaryingPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc, + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc, const VtIntArray* vertexCounts, const size_t* vertexCountSum) { HdArnoldSetFaceVaryingPrimvar( - node, primvarDesc.name, primvarDesc.role, delegate->Get(id, primvarDesc.name), vertexCounts, vertexCountSum); + node, primvarDesc.name, primvarDesc.role, sceneDelegate->Get(id, primvarDesc.name), vertexCounts, + vertexCountSum); } void HdArnoldSetInstancePrimvar( @@ -921,10 +922,10 @@ void HdArnoldSetInstancePrimvar( } size_t HdArnoldSetPositionFromPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const AtString& paramName) + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const AtString& paramName) { HdArnoldSampledPrimvarType xf; - delegate->SamplePrimvar(id, HdTokens->points, &xf); + sceneDelegate->SamplePrimvar(id, HdTokens->points, &xf); if (xf.count == 0 || #ifdef USD_HAS_UPDATED_TIME_SAMPLE_ARRAY xf.values.empty() || @@ -962,10 +963,10 @@ void HdArnoldSetPositionFromValue(AtNode* node, const AtString& paramName, const AiNodeSetArray(node, paramName, AiArrayConvert(values.size(), 1, AI_TYPE_VECTOR, values.data())); } -void HdArnoldSetRadiusFromPrimvar(AtNode* node, const SdfPath& id, HdSceneDelegate* delegate) +void HdArnoldSetRadiusFromPrimvar(AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate) { HdArnoldSampledPrimvarType xf; - delegate->SamplePrimvar(id, HdTokens->widths, &xf); + sceneDelegate->SamplePrimvar(id, HdTokens->widths, &xf); if (xf.count == 0 || #ifdef USD_HAS_UPDATED_TIME_SAMPLE_ARRAY xf.values.empty() || diff --git a/render_delegate/utils.h b/render_delegate/utils.h index 907c3cfa71..2adc768997 100644 --- a/render_delegate/utils.h +++ b/render_delegate/utils.h @@ -76,17 +76,17 @@ GfMatrix4f HdArnoldConvertMatrix(const AtMatrix& in); /// Sets the transform on an Arnold node from a Hydra Primitive. /// /// @param node Pointer to the Arnold Node. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @param id Path to the primitive. HDARNOLD_API -void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* delegate, const SdfPath& id); +void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* sceneDelegate, const SdfPath& id); /// Sets the transform on multiple Arnold nodes from a single Hydra Primitive. /// /// @param node Vector holding all the Arnold Nodes. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @param id Path to the primitive. HDARNOLD_API -void HdArnoldSetTransform(const std::vector& nodes, HdSceneDelegate* delegate, const SdfPath& id); +void HdArnoldSetTransform(const std::vector& nodes, HdSceneDelegate* sceneDelegate, const SdfPath& id); /// Sets a Parameter on an Arnold Node from a VtValue. /// /// @param node Pointer to the Arnold Node. @@ -139,12 +139,12 @@ void HdArnoldSetConstantPrimvar( /// /// @param node Pointer to an Arnold Node. /// @param id Path to the Primitive. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @param primvarDesc Description of the primvar. /// @param visibility Pointer to the output visibility parameter. HDARNOLD_API void HdArnoldSetConstantPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc, + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc, uint8_t* visibility = nullptr); /// Sets a Uniform scope Primvar on an Arnold node from a Hydra Primitive. /// @@ -175,11 +175,11 @@ void HdArnoldSetVertexPrimvar(AtNode* node, const TfToken& name, const TfToken& /// /// @param node Pointer to an Arnold Node. /// @param id Path to the Primitive. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @param primvarDesc Primvar Descriptor for the Primvar to be set. HDARNOLD_API void HdArnoldSetVertexPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc); + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc); /// Sets a Face-Varying scope Primvar on an Arnold node from a Hydra Primitive. If @p vertexCounts is not a nullptr /// and it is not empty, it is used to reverse the order of the generated face vertex indices, to support /// left handed topologies. The total sum of the @p vertexCounts array is expected to be the same as the number values @@ -202,13 +202,13 @@ void HdArnoldSetFaceVaryingPrimvar( /// /// @param node Pointer to an Arnold Node. /// @param id Path to the Primitive. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @param primvarDesc Primvar Descriptor for the Primvar to be set. /// @param vertexCounts Optional pointer to the VtIntArray holding the face vertex counts for the mesh. /// @param vertexCountSum Optional size_t with sum of the vertexCounts. HDARNOLD_API void HdArnoldSetFaceVaryingPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const HdPrimvarDescriptor& primvarDesc, + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const HdPrimvarDescriptor& primvarDesc, const VtIntArray* vertexCounts = nullptr, const size_t* vertexCountSum = nullptr); /// Sets instance primvars on an instancer node. /// @@ -225,11 +225,11 @@ void HdArnoldSetInstancePrimvar( /// @param node Pointer to an Arnold node. /// @param paramName Name of the positions parameter on the Arnold node. /// @param id Path to the Hydra Primitive. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. /// @return Number of keys for the position. HDARNOLD_API size_t HdArnoldSetPositionFromPrimvar( - AtNode* node, const SdfPath& id, HdSceneDelegate* delegate, const AtString& paramName); + AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const AtString& paramName); /// Sets positions attribute on an Arnold shape from a VtValue holding VtVec3fArray. /// /// @param node Pointer to an Arnold node. @@ -244,9 +244,9 @@ void HdArnoldSetPositionFromValue(AtNode* node, const AtString& paramName, const /// @param node Pointer to an Arnold node. /// @param paramName Name of the positions parameter on the Arnold node. /// @param id Path to the Hydra Primitive. -/// @param delegate Pointer to the Scene Delegate. +/// @param sceneDelegate Pointer to the Scene Delegate. HDARNOLD_API -void HdArnoldSetRadiusFromPrimvar(AtNode* node, const SdfPath& id, HdSceneDelegate* delegate); +void HdArnoldSetRadiusFromPrimvar(AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate); /// Sets radius attribute on an Arnold shape from a VtValue holding VtFloatArray. We expect this to be a width value, /// so a (*0.5) function will be applied to the values. /// diff --git a/render_delegate/volume.cpp b/render_delegate/volume.cpp index 2c7de08458..e8fd90d874 100644 --- a/render_delegate/volume.cpp +++ b/render_delegate/volume.cpp @@ -172,8 +172,8 @@ TF_DEFINE_PRIVATE_TOKENS(_tokens, ); // clang-format on -HdArnoldVolume::HdArnoldVolume(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId) - : HdVolume(id, instancerId), _delegate(delegate) +HdArnoldVolume::HdArnoldVolume(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId) + : HdVolume(id, instancerId), _renderDelegate(renderDelegate) { } @@ -183,7 +183,7 @@ HdArnoldVolume::~HdArnoldVolume() } void HdArnoldVolume::Sync( - HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) { TF_UNUSED(reprToken); auto* param = reinterpret_cast(renderParam); @@ -191,28 +191,29 @@ void HdArnoldVolume::Sync( auto volumesChanged = false; if (HdChangeTracker::IsTopologyDirty(*dirtyBits, id)) { param->Interrupt(); - _CreateVolumes(id, delegate); + _CreateVolumes(id, sceneDelegate); volumesChanged = true; } if (volumesChanged || (*dirtyBits & HdChangeTracker::DirtyMaterialId)) { param->Interrupt(); const auto* material = reinterpret_cast( - delegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, delegate->GetMaterialId(id))); - auto* volumeShader = material != nullptr ? material->GetVolumeShader() : _delegate->GetFallbackVolumeShader(); + sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, sceneDelegate->GetMaterialId(id))); + auto* volumeShader = + material != nullptr ? material->GetVolumeShader() : _renderDelegate->GetFallbackVolumeShader(); _ForEachVolume([&](HdArnoldShape* s) { AiNodeSetPtr(s->GetShape(), str::shader, volumeShader); }); } auto transformDirtied = false; if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) { param->Interrupt(); - _ForEachVolume([&](HdArnoldShape* s) { HdArnoldSetTransform(s->GetShape(), delegate, GetId()); }); + _ForEachVolume([&](HdArnoldShape* s) { HdArnoldSetTransform(s->GetShape(), sceneDelegate, GetId()); }); transformDirtied = true; } if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { param->Interrupt(); - _UpdateVisibility(delegate, dirtyBits); + _UpdateVisibility(sceneDelegate, dirtyBits); _ForEachVolume([&](HdArnoldShape* s) { s->SetVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); }); } @@ -224,32 +225,34 @@ void HdArnoldVolume::Sync( } else if (!_inMemoryVolumes.empty()) { visibility = _inMemoryVolumes.front()->GetVisibility(); } - for (const auto& primvar : delegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationConstant)) { + for (const auto& primvar : sceneDelegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationConstant)) { _ForEachVolume([&](HdArnoldShape* s) { - HdArnoldSetConstantPrimvar(s->GetShape(), id, delegate, primvar, &visibility); + HdArnoldSetConstantPrimvar(s->GetShape(), id, sceneDelegate, primvar, &visibility); }); } _ForEachVolume([&](HdArnoldShape* s) { s->SetVisibility(visibility); }); } - _ForEachVolume([&](HdArnoldShape* shape) { shape->Sync(this, *dirtyBits, delegate, param, transformDirtied); }); + _ForEachVolume([&](HdArnoldShape* shape) { + shape->Sync(this, *dirtyBits, _renderDelegate, sceneDelegate, param, transformDirtied); + }); *dirtyBits = HdChangeTracker::Clean; } -void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate) +void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* sceneDelegate) { std::unordered_map> openvdbs; std::unordered_map> houVdbs; - const auto fieldDescriptors = delegate->GetVolumeFieldDescriptors(id); + const auto fieldDescriptors = sceneDelegate->GetVolumeFieldDescriptors(id); for (const auto& field : fieldDescriptors) { auto* openvdbAsset = dynamic_cast( - delegate->GetRenderIndex().GetBprim(_tokens->openvdbAsset, field.fieldId)); + sceneDelegate->GetRenderIndex().GetBprim(_tokens->openvdbAsset, field.fieldId)); if (openvdbAsset == nullptr) { continue; } openvdbAsset->TrackVolumePrimitive(id); - const auto vv = delegate->Get(field.fieldId, _tokens->filePath); + const auto vv = sceneDelegate->Get(field.fieldId, _tokens->filePath); if (vv.IsHolding()) { const auto& assetPath = vv.UncheckedGet(); auto path = assetPath.GetResolvedPath(); @@ -293,7 +296,7 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate } } if (volume == nullptr) { - auto* shape = new HdArnoldShape(str::volume, _delegate, id, GetPrimId()); + auto* shape = new HdArnoldShape(str::volume, _renderDelegate, id, GetPrimId()); volume = shape->GetShape(); AiNodeSetStr(volume, str::filename, openvdb.first.c_str()); AiNodeSetStr(volume, str::name, TfStringPrintf("%s_p_%p", id.GetText(), volume).c_str()); @@ -339,7 +342,7 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate continue; } - auto* shape = new HdArnoldShape(str::volume, _delegate, id, GetPrimId()); + auto* shape = new HdArnoldShape(str::volume, _renderDelegate, id, GetPrimId()); auto* volume = shape->GetShape(); AiNodeSetStr(volume, str::name, TfStringPrintf("%s_p_%p", id.GetText(), volume).c_str()); htoaFnSet.convertPrimVdbToArnold(volume, static_cast(gridVec.size()), gridVec.data()); diff --git a/render_delegate/volume.h b/render_delegate/volume.h index 2e5684a421..0100b51c27 100644 --- a/render_delegate/volume.h +++ b/render_delegate/volume.h @@ -50,11 +50,11 @@ class HdArnoldVolume : public HdVolume { public: /// Constructor for HdArnoldVolume. /// - /// @param delegate Pointer to the Render Delegate. + /// @param renderDelegate Pointer to the Render Delegate. /// @param id Path to the Primitive. /// @param instancerId Path to the Point Instancer. HDARNOLD_API - HdArnoldVolume(HdArnoldRenderDelegate* delegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); + HdArnoldVolume(HdArnoldRenderDelegate* renderDelegate, const SdfPath& id, const SdfPath& instancerId = SdfPath()); /// Destructor for HdArnoldVolume. /// @@ -69,8 +69,9 @@ class HdArnoldVolume : public HdVolume { /// @param dirtyBits Dirty Bits to sync. /// @param reprToken Token describing the representation of the volume. HDARNOLD_API - void Sync(HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) - override; + void Sync( + HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, + const TfToken& reprToken) override; /// Returns the initial Dirty Bits for the Primitive. /// @@ -104,9 +105,9 @@ class HdArnoldVolume : public HdVolume { /// primitives for each file loaded. /// /// @param id Path to the Primitive. - /// @param delegate Pointer to the Scene Delegate. + /// @param sceneDelegate Pointer to the Scene Delegate. HDARNOLD_API - void _CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate); + void _CreateVolumes(const SdfPath& id, HdSceneDelegate* sceneDelegate); /// Iterates through all available volumes and calls a function on each of them. /// @@ -123,7 +124,7 @@ class HdArnoldVolume : public HdVolume { } } - HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate. + HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Render Delegate. std::vector _volumes; ///< Vector storing all the Volumes created. std::vector _inMemoryVolumes; ///< Vectoring storing all the Volumes for in-memory VDB storage. };