Skip to content

Add reusable GPU memory statistics - #49

Merged
nvhumper merged 8 commits into
NVIDIA-RTX:mainfrom
nvhumper:memory-statistics
Sep 23, 2026
Merged

nvhumper merged 8 commits into
NVIDIA-RTX:mainfrom
nvhumper:memory-statistics

Conversation

@nvhumper

Copy link
Copy Markdown
Collaborator

Single landing spot for useful memory stats that consuming applications might want to measure / visualize.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@nvhumper

Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

Comment thread src/engine/MemoryStats.cpp Outdated
#include <unordered_set>

#if DONUT_WITH_DX12
#include <d3d12.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the general rule that this should be done in NRHI.

Comment thread src/engine/MemoryStats.cpp Outdated
if (device == nullptr || buffer == nullptr)
return false;

const nvrhi::MemoryRequirements requirements = device->getBufferMemoryRequirements(buffer);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the D3D11 implementation.

    MemoryRequirements Device::getBufferMemoryRequirements(IBuffer*)
    {
        utils::NotSupported();
        return MemoryRequirements();
    }

Comment thread src/engine/MemoryStats.cpp Outdated
return stats;
}

TopLevelAccelStructPrebuildStats QueryTopLevelAccelStructPrebuildStats(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would like to see this as an NVRHI call. Ok to stub out on Vulkan for now, with verbose.

Comment thread include/donut/engine/MemoryStats.h Outdated

struct GpuMemoryUsage
{
uint64_t CapacityBytes = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code base uses camelCase.

@nvhumper

Copy link
Copy Markdown
Collaborator Author

Updated the branch to address the review. The NVRHI dependency is NVIDIA-RTX/NVRHI#145.

  • Donut no longer contains native allocation or TLAS-prebuild code; it retains scene aggregation and calls NVRHI's optional resource query.
  • D3D11 returns unavailable without calling the asserting legacy method. TLAS prebuild is an NVRHI call; Vulkan/D3D11 return unavailable with an informational diagnostic. Failed queries preserve outputs rather than reporting a valid zero.
  • New statistics fields/functions use camelCase.
  • Added headless Donut D3D11/D3D12 WARP regression tests covering all availability, capacity/allocation, shared-buffer/cross-category, empty/partial scene, replacement and removal scenarios through raw and validation devices. Both passed in native Debug. NVRHI's D3D11/D3D12/Vulkan native tests also passed, including imported/volatile D3D12 buffers. Both libraries passed no-mistakes review/test/document/lint validation.

The NVRHI fork URL/gitlink is intentional for this dependent review and was verified fetchable. Local native validation is not being presented as upstream build CI: the dependency's CLA check passes, but no upstream Build run has been observed. No merges performed.

@nvhumper

Copy link
Copy Markdown
Collaborator Author

Follow-up published at 00ee41b13d1bb6a89a852fb0a4cc799b95a9b04b, using NVRHI 37eb75a5ec42e4fb78025180b44af7471ee0969b from NVIDIA-RTX/NVRHI#145.

The existing-resource query is now optional IResource::queryMemoryRequirements, dispatched virtually by the resource. TLAS prebuild remains on IDevice. Donut retains scene aggregation and its public helper signature/null-device behavior; null-resource and unavailable queries still preserve the output. No backend-specific code was reintroduced.

Both library follow-ups passed no-mistakes review/test/document/lint. Native Debug NVRHI D3D11/D3D12/Vulkan and Donut D3D11/D3D12 WARP regressions passed through raw and validation paths. Additional dependency checks covered actual enhanced-barrier off/on behavior, externally managed BLAS queries after compaction, and Vulkan TLAS/micromaps. D3D12 OMM query coverage remains unavailable in the library test configuration.

The final dependency chain also passed the full consuming RTXPT Debug build, packaged memory regression, and 46 packaged shader checks. Both packaged Windows samples independently loaded/rendered their default scene with zero arguments and exited normally after a bounded normal window-close request; no desktop input automation was used.

These are native validation results, not a claim of upstream build CI: the NVRHI Build workflow still requires maintainer approval. Both branches were updated with ordinary non-force pushes, NVRHI first, after verifying the dependency was fetchable. Neither review was merged.

@nvhumper
nvhumper merged commit bd498ea into NVIDIA-RTX:main Sep 23, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants