-
Notifications
You must be signed in to change notification settings - Fork 14
HYDRA-1626: Hydra Primitive Scene Stats #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,10 @@ | |
| #include <pxr/imaging/hd/rendererPluginRegistry.h> | ||
| #include <pxr/imaging/hd/rprim.h> | ||
| #include <pxr/imaging/hd/sceneIndexPluginRegistry.h> | ||
| #include <pxr/imaging/hd/dataSource.h> | ||
| #include <pxr/imaging/hd/basisCurvesTopology.h> | ||
| #include <pxr/imaging/hd/meshTopology.h> | ||
| #include <pxr/imaging/hd/sceneIndexPrimView.h> | ||
| #include <pxr/imaging/hdx/selectionTask.h> | ||
| #include <pxr/imaging/hdx/colorizeSelectionTask.h> | ||
| #include <pxr/imaging/hdx/pickTask.h> | ||
|
|
@@ -440,6 +444,77 @@ int MtohRenderOverride::GetUsedGPUMemory() | |
| return totalGPUMemory / (1024*1024); | ||
| } | ||
|
|
||
| std::map<std::string, int> MtohRenderOverride::GetSceneStatistics() | ||
| { | ||
| std::map<std::string, int> stats = { | ||
| {"primitives", 0}, | ||
| {"mesh", 0}, | ||
| {"mesh.points", 0}, | ||
| {"mesh.faces", 0}, | ||
| {"curve", 0}, | ||
| {"curve.points", 0}, | ||
| {"point", 0}, | ||
| }; | ||
|
|
||
| MtohRenderOverride* instance = nullptr; | ||
| { | ||
| std::lock_guard<std::mutex> lock(_allInstancesMutex); | ||
| for (auto* inst : _allInstances) { | ||
| if (inst->_initializationSucceeded && inst->_renderIndex) { | ||
| instance = inst; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!instance || !instance->_renderIndex) { | ||
| return stats; | ||
| } | ||
|
|
||
| auto* renderIndex = instance->_renderIndex; | ||
| auto primIds = renderIndex->GetRprimIds(); | ||
|
|
||
| for (const auto& primId : primIds) { | ||
| auto* rprim = renderIndex->GetRprim(primId); | ||
| if (!rprim) { | ||
| continue; | ||
| } | ||
|
|
||
| stats["primitives"]++; | ||
|
|
||
| HdSceneIndexPrim prim; | ||
| TfToken primType; | ||
| if (instance->_mayaHydraSceneIndex) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to find a common way to query the primtype, it could come from any SceneIndex
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One way might be check the type of auto* rprim = renderIndex->GetRprim(primId);, if it could be dynamically casted to HdMesh, we will assume it's a mesh prim. |
||
| prim = instance->_mayaHydraSceneIndex->GetPrim(primId); | ||
| primType = prim.primType; | ||
| } | ||
|
|
||
| if (primType.IsEmpty()) { | ||
| continue; | ||
| } | ||
|
|
||
| if (primType == HdPrimTypeTokens->mesh) { | ||
| stats["mesh"]++; | ||
| if (instance->_mayaHydraSceneIndex && prim.dataSource) { | ||
| HdMeshTopology meshTopology = instance->_mayaHydraSceneIndex->GetMeshTopology(primId); | ||
| stats["mesh.points"] += meshTopology.GetNumPoints(); | ||
| stats["mesh.faces"] += meshTopology.GetNumFaces(); | ||
| } | ||
| } | ||
| else if (primType == HdPrimTypeTokens->basisCurves) { | ||
| stats["curve"]++; | ||
| if (instance->_mayaHydraSceneIndex && prim.dataSource) { | ||
| HdBasisCurvesTopology curvesTopology = instance->_mayaHydraSceneIndex->GetBasisCurvesTopology(primId); | ||
| stats["curve.points"] += curvesTopology.GetNumPoints(); | ||
| } | ||
| } | ||
| else if (primType == HdPrimTypeTokens->points) { | ||
| stats["point"]++; | ||
| } | ||
| } | ||
| return stats; | ||
| } | ||
|
|
||
| std::vector<MString> MtohRenderOverride::AllActiveRendererNames() | ||
| { | ||
| std::vector<MString> renderers; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.