Skip to content

Commit 2c461b7

Browse files
Merge fix-7.3.5 to master (#2157)
* Fix handling of hydra updates in batch renders (#2155) * Fix missing updates in husk #2154 * Update changelog * Rename function for clarity * Update changelog
1 parent b15adc1 commit 2c461b7

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- SPDX-License-Identifier: Apache-2.0 -->
22
# Changelog
33

4-
## Pending feature release
4+
## Pending Feature release
55

66
### Feature
77
- [usd#2119](https://github.com/Autodesk/arnold-usd/issues/2119) - Support options shader_override attribute
@@ -15,7 +15,7 @@
1515
- [usd#2133](https://github.com/Autodesk/arnold-usd/issues/2133) - Fixed crash when the root primitive is invalid
1616
- [usd#2122](https://github.com/Autodesk/arnold-usd/issues/2122) - RectLight doesn't take width / height into account with scenes exported from Arnold
1717
- [usd#1764](https://github.com/Autodesk/arnold-usd/issues/1764) - ArnoldUsd schema was missing from Arnold SDK
18-
18+
- [usd#2154](https://github.com/Autodesk/arnold-usd/issues/2154) - Husk renders can miss scene updates
1919

2020
## [7.3.5.0] - 2024-11-08
2121

libs/render_delegate/reader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ void HydraArnoldReader::ReadStage(UsdStageRefPtr stage,
223223
arnoldRenderDelegate->SetRenderTags(purpose);
224224

225225
// The scene might not be up to date, because of light links, etc, that were generated during the first sync.
226-
// UpdateSceneChanges updates the dirtybits for a resync, this is how it works in our hydra render pass.
227-
while (arnoldRenderDelegate->UpdateSceneChanges(_renderIndex, _shutter)) {
226+
// HasPendingChanges updates the dirtybits for a resync, this is how it works in our hydra render pass.
227+
while (arnoldRenderDelegate->HasPendingChanges(_renderIndex, _shutter)) {
228228
_renderIndex->SyncAll(&_tasks, &_taskContext);
229229
}
230230
}
@@ -251,7 +251,7 @@ void HydraArnoldReader::Update()
251251
{
252252
HdArnoldRenderDelegate *arnoldRenderDelegate = static_cast<HdArnoldRenderDelegate*>(_renderDelegate);
253253
_imagingDelegate->ApplyPendingUpdates();
254-
arnoldRenderDelegate->UpdateSceneChanges(_renderIndex, _shutter);
254+
arnoldRenderDelegate->HasPendingChanges(_renderIndex, _shutter);
255255
_renderIndex->SyncAll(&_tasks, &_taskContext);
256256
}
257257

libs/render_delegate/render_delegate.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ HdArnoldRenderDelegate::HdArnoldRenderDelegate(bool isBatch, const TfToken &cont
460460
_context(context),
461461
_universe(universe),
462462
_procParent(nullptr),
463-
_renderDelegateOwnsUniverse(universe==nullptr)
463+
_renderDelegateOwnsUniverse(universe==nullptr),
464+
_renderSessionType(renderSessionType)
464465
{
465466

466467
_lightLinkingChanged.store(false, std::memory_order_release);
@@ -485,7 +486,7 @@ HdArnoldRenderDelegate::HdArnoldRenderDelegate(bool isBatch, const TfToken &cont
485486
AiADPAddProductMetadata(AI_ADP_PLUGINVERSION, AtString{AI_VERSION});
486487
AiADPAddProductMetadata(AI_ADP_HOSTNAME, AtString{"Hydra"});
487488
AiADPAddProductMetadata(AI_ADP_HOSTVERSION, AtString{PXR_VERSION_STR});
488-
AiBegin(renderSessionType);
489+
AiBegin(_renderSessionType);
489490
}
490491
_supportedRprimTypes = {HdPrimTypeTokens->mesh, HdPrimTypeTokens->volume, HdPrimTypeTokens->points,
491492
HdPrimTypeTokens->basisCurves, str::t_procedural_custom};
@@ -563,7 +564,7 @@ HdArnoldRenderDelegate::HdArnoldRenderDelegate(bool isBatch, const TfToken &cont
563564

564565
if (_renderDelegateOwnsUniverse) {
565566
_universe = AiUniverse();
566-
_renderSession = AiRenderSession(_universe, renderSessionType);
567+
_renderSession = AiRenderSession(_universe, _renderSessionType);
567568
}
568569

569570
_renderParam.reset(new HdArnoldRenderParam(this));
@@ -1532,14 +1533,15 @@ void HdArnoldRenderDelegate::ProcessConnections()
15321533
bool HdArnoldRenderDelegate::CanUpdateScene()
15331534
{
15341535
// For interactive renders, it is always possible to update the scene
1535-
if (!_isBatch)
1536+
if (_renderSessionType == AI_SESSION_INTERACTIVE)
15361537
return true;
15371538
// For batch renders, only update the scene if the render hasn't started yet,
15381539
// or if it's finished
15391540
const int status = AiRenderGetStatus(_renderSession);
15401541
return status != AI_RENDER_STATUS_RESTARTING && status != AI_RENDER_STATUS_RENDERING;
15411542
}
1542-
bool HdArnoldRenderDelegate::UpdateSceneChanges(HdRenderIndex* renderIndex, const GfVec2f& shutter)
1543+
1544+
bool HdArnoldRenderDelegate::HasPendingChanges(HdRenderIndex* renderIndex, const GfVec2f& shutter)
15431545
{
15441546
HdDirtyBits bits = HdChangeTracker::Clean;
15451547
// If Light Linking have changed, we have to dirty the categories on all rprims to force updating the

libs/render_delegate/render_delegate.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
327327
HDARNOLD_API
328328
void ApplyLightLinking(HdSceneDelegate *delegate, AtNode* node, SdfPath const& id);
329329

330-
/// Updates the eventual changes that happened in the input scene
331-
/// since the last iteration.
330+
/// Eventually mark some hydra primitives as being dirty
331+
/// in which case we'll have another sync iteration pending
332332
///
333333
/// @param renderIndex Pointer to the Hydra Render Index.
334334
/// @param shutterOpen Shutter Open value of the active camera.
335335
/// @param shutterClose Shutter Close value of the active camera.
336-
/// @return True if the iteration contains scene changes.
336+
/// @return True if hydra has pending changes.
337337
HDARNOLD_API
338-
bool UpdateSceneChanges(HdRenderIndex* renderIndex, const GfVec2f& shutter);
338+
bool HasPendingChanges(HdRenderIndex* renderIndex, const GfVec2f& shutter);
339339

340340
/// Returns whether the Arnold scene can be updated or
341341
/// if Hydra changes should be ignored.
@@ -728,6 +728,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
728728
AtNode* _fallbackShader = nullptr; ///< Pointer to the fallback Arnold Shader.
729729
AtNode* _fallbackVolumeShader = nullptr; ///< Pointer to the fallback Arnold Volume Shader.
730730
AtNode* _procParent = nullptr;
731+
AtSessionMode _renderSessionType = AI_SESSION_INTERACTIVE;
731732
std::string _logFile;
732733
std::string _statsFile;
733734
AtStatsMode _statsMode;

libs/render_delegate/render_pass.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,10 +970,16 @@ void HdArnoldRenderPass::_Execute(const HdRenderPassStateSharedPtr& renderPassSt
970970
clearBuffers(_renderBuffers);
971971
}
972972

973-
_renderDelegate->UpdateSceneChanges(
973+
// Check if hydra still has pending changes that will be processed in the next iteration.
974+
bool hasPendingChanges = _renderDelegate->HasPendingChanges(
974975
GetRenderIndex(),
975976
{AiNodeGetFlt(currentCamera, str::shutter_start), AiNodeGetFlt(currentCamera, str::shutter_end)});
976-
const auto renderStatus = renderParam->UpdateRender();
977+
978+
// If we still have pending Hydra changes, we don't want to start / update the render just yet,
979+
// as we'll receive shortly another sync. In particular in the case of batch renders, this prevents
980+
// from rendering the final scene #2154
981+
const auto renderStatus = hasPendingChanges ?
982+
HdArnoldRenderParam::Status::Converging : renderParam->UpdateRender();
977983
_isConverged = renderStatus != HdArnoldRenderParam::Status::Converging;
978984

979985
// We need to set the converged status of the render buffers.

0 commit comments

Comments
 (0)