Skip to content

Commit 09c9b02

Browse files
HnMesh: moved geometry budget check to UpdateRepr()
1 parent 05af0b7 commit 09c9b02

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

Hydrogent/interface/HnMesh.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Diligent Graphics LLC
2+
* Copyright 2023-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ class HnMesh final : public pxr::HdMesh
154154
struct StagingIndexData;
155155
struct StagingVertexData;
156156

157-
void UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
157+
bool UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
158158
pxr::HdRenderParam* RenderParam,
159159
pxr::HdDirtyBits& DirtyBits,
160160
const pxr::TfToken& ReprToken);

Hydrogent/src/HnMesh.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Diligent Graphics LLC
2+
* Copyright 2023-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -198,17 +198,7 @@ void HnMesh::Sync(pxr::HdSceneDelegate* Delegate,
198198
}
199199
bool UpdateCullMode = pxr::HdChangeTracker::IsTransformDirty(*DirtyBits, Id) || m_CullMode == CULL_MODE_UNDEFINED;
200200

201-
202-
HnRenderDelegate* RenderDelegate = static_cast<HnRenderDelegate*>(Delegate->GetRenderIndex().GetRenderDelegate());
203-
HnGeometryPool& GeometryPool = RenderDelegate->GetGeometryPool();
204-
const Int64 PendingGeometrySize = GeometryPool.GetPendingVertexDataSize() + GeometryPool.GetPendingIndexDataSize();
205-
const Uint64 GeometryLoadBudget = static_cast<HnRenderParam*>(RenderParam)->GetConfig().GeometryLoadBudget;
206-
bool ReprUpdated = false;
207-
if (GeometryLoadBudget == 0 || static_cast<Uint64>(PendingGeometrySize) < GeometryLoadBudget)
208-
{
209-
UpdateRepr(*Delegate, RenderParam, *DirtyBits, ReprToken);
210-
ReprUpdated = true;
211-
}
201+
const bool ReprUpdated = UpdateRepr(*Delegate, RenderParam, *DirtyBits, ReprToken);
212202

213203
if (UpdateMaterials)
214204
{
@@ -332,16 +322,24 @@ struct HnMesh::StagingVertexData
332322
std::map<pxr::TfToken, std::shared_ptr<pxr::HdBufferSource>> Sources;
333323
};
334324

335-
void HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
325+
bool HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
336326
pxr::HdRenderParam* RenderParam,
337327
pxr::HdDirtyBits& DirtyBits,
338328
const pxr::TfToken& ReprToken)
339329
{
340330
const pxr::HdReprSharedPtr& CurrRepr = _GetRepr(ReprToken);
341331
if (!CurrRepr)
342-
return;
332+
return true;
343333

344-
HnRenderDelegate* RenderDelegate = static_cast<HnRenderDelegate*>(SceneDelegate.GetRenderIndex().GetRenderDelegate());
334+
HnRenderDelegate* RenderDelegate = static_cast<HnRenderDelegate*>(SceneDelegate.GetRenderIndex().GetRenderDelegate());
335+
HnGeometryPool& GeometryPool = RenderDelegate->GetGeometryPool();
336+
const Int64 PendingGeometrySize = GeometryPool.GetPendingVertexDataSize() + GeometryPool.GetPendingIndexDataSize();
337+
const Uint64 GeometryLoadBudget = static_cast<HnRenderParam*>(RenderParam)->GetConfig().GeometryLoadBudget;
338+
if (GeometryLoadBudget > 0 && static_cast<Uint64>(PendingGeometrySize) > GeometryLoadBudget)
339+
{
340+
// Pending geometry size exceeds the budget, skip updating the repr
341+
return false;
342+
}
345343

346344
const pxr::SdfPath& Id = GetId();
347345

@@ -407,7 +405,6 @@ void HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
407405
Uint32 BakedStartVertex = (!UseNativeStartVertex && m_VertexHandle) ? m_VertexHandle->GetStartVertex() : 0;
408406
if (!StagingVerts.Sources.empty())
409407
{
410-
HnGeometryPool& GeometryPool = RenderDelegate->GetGeometryPool();
411408
// When native start vertex is not supported, start vertex needs to be baked into the index data, and
412409
// we need to know the start vertex now, so we have to disallow pool allocation reuse (with pool allocation reuse
413410
// enabled, the allocation initialization is delayed until the GeometryPool.Commit() is called later).
@@ -432,8 +429,6 @@ void HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
432429
StagingIndexData StagingInds;
433430
UpdateIndexData(StagingInds, StagingVerts.Points, RenderDelegate->AllowPrimitiveRestart());
434431

435-
HnGeometryPool& GeometryPool = RenderDelegate->GetGeometryPool();
436-
437432
GeometryPool.AllocateIndices(Id.GetString() + " - faces", pxr::VtValue::Take(StagingInds.FaceIndices), BakedStartVertex, m_IndexData.Faces);
438433
GeometryPool.AllocateIndices(Id.GetString() + " - edges", pxr::VtValue::Take(StagingInds.EdgeIndices), BakedStartVertex, m_IndexData.Edges);
439434
GeometryPool.AllocateIndices(Id.GetString() + " - points", pxr::VtValue::Take(StagingInds.PointIndices), BakedStartVertex, m_IndexData.Points);
@@ -483,6 +478,8 @@ void HnMesh::UpdateRepr(pxr::HdSceneDelegate& SceneDelegate,
483478
}
484479

485480
DirtyBits &= ~pxr::HdChangeTracker::NewRepr;
481+
482+
return true;
486483
}
487484

488485
void HnMesh::UpdateDrawItemsForGeometrySubsets(pxr::HdSceneDelegate& SceneDelegate,

0 commit comments

Comments
 (0)