How to log nanite stats

I am looking for a method to log Nanite stats, specifically the numbers shown with the nanitestats command. I know I can get them from a GPU dump and parsing the buffer resource but is there an easier way? Or is it possible to direct the GPU Dump to grab the one buffer?

Steps to Reproduce

Hi [mention removed]​,

nanitestats is a command that is sent directly as a shader to the GPU and drawn directly to the viewport. All the information that the buffer has is possible to extract it but you should write the PrintStats function that you have inside Nanite.cpp.

All this information is stored inside a FRDGBuffer. What I would do is to write out this information from the PrintStats function and maybe enable a compilation flag or a project settings config variable to enable or disable this, or even a console variable to enable this.

Inside the PrintStats function, eveyrhing is stored inside:

PrintStatsCS::FParameters* PassParameters

Specially in the InStatsBuffer:

PassParameters->InStatsBuffer = GraphBuilder.CreateSRV(GraphBuilder.RegisterExternalBuffer(Nanite::GGlobalResources.GetStatsBufferRef()));

This ends up being a buffer that contains the FNaniteStats that is what you are looking for:

struct FNaniteStats { UINT_TYPE NumTris; UINT_TYPE NumVerts; UINT_TYPE NumViews; UINT_TYPE NumMainInstancesPreCull; UINT_TYPE NumMainInstancesPostCull; UINT_TYPE NumMainVisitedNodes; UINT_TYPE NumMainCandidateClusters; UINT_TYPE NumPostInstancesPreCull; UINT_TYPE NumPostInstancesPostCull; UINT_TYPE NumPostVisitedNodes; UINT_TYPE NumPostCandidateClusters; UINT_TYPE NumLargePageRectClusters; UINT_TYPE NumPrimaryViews; UINT_TYPE NumTotalViews; UINT_TYPE NumTotalRasterBins; UINT_TYPE NumEmptyRasterBins; UINT_TYPE NumTotalShadingBins; UINT_TYPE NumEmptyShadingBins; UINT_TYPE NumNanitePixels; UINT_TYPE NumShadedQuads; UINT_TYPE NumShadedPixels; UINT_TYPE NumHelperLanes; UINT_TYPE NumMainPassIndirections; UINT_TYPE NumPostPassIndirections; UINT_TYPE NumMainHierarchyCellsPreCull; UINT_TYPE NumPostHierarchyCellsPreCull; UINT_TYPE NumDicedTrianglesClusters; UINT_TYPE NumDicedTrianglesPatches; UINT_TYPE NumImmediatePatches; UINT_TYPE NumCandidateSplitPatches; UINT_TYPE NumVisibleSplitPatches; };

Let me know if you need help with this :slight_smile:

Best,

Joan