Advanced API Performance: Memory and Resources

This post covers best practices for memory and resources on NVIDIA GPUs.

Andrew Allan
5 min readbeginner
--
View Original

Overview

This article discusses best practices for memory and resource management on NVIDIA GPUs, particularly in the context of DirectX 12. It provides detailed recommendations for optimal memory management to ensure high and consistent frame rates in applications.

What You'll Learn

1

How to manage video memory effectively in DirectX 12 applications

2

Why resource creation should be done off the critical path

3

When to use MakeResident and Evict calls to manage memory budgets

Prerequisites & Requirements

  • Understanding of DirectX 12 and GPU memory management concepts

Key Questions Answered

What are the best practices for managing video memory in DirectX 12?
Best practices include using IDXGIAdapter3::QueryVideoMemoryInfo to check available video memory, responding to budget changes with IDXGIAdapter3::RegisterVideoMemoryBudgetChangeNotificationEvent, and prioritizing GPU-written resources with ID3D12Device1::SetResidencyPriority. Additionally, batching MakeResident calls can reduce overhead.
What should be avoided when managing resources in DirectX 12?
Avoid relying on the availability of tiled resources, expecting to allocate all GPU memory at once, and using a pattern of resource creation and destruction. Instead, utilize MakeUnresident and MakeResident to manage resources efficiently.
How should resource formats be selected for optimal performance?
Selecting resource formats should depend on application requirements. For instance, using 32-bit color formats like DXGI_FORMAT_R11G11B10_FLOAT is recommended over 64-bit formats to reduce bandwidth. D24 or D16 depth formats are preferred for performance.

Technologies & Tools

API
Directx 12
Used for developing high-performance graphics applications on NVIDIA GPUs.

Key Actionable Insights

1
Batching MakeResident calls can significantly lower overhead and improve performance.
This is particularly useful when managing large amounts of video memory, as it reduces the CPU and GPU costs associated with page table updates.
2
Align updates to placed or tiled resources at a 2-MB granularity for best performance.
This alignment helps optimize memory access patterns and can lead to improved rendering performance in applications.
3
Use 32-bit color formats over 64-bit formats to minimize bandwidth usage.
This practice is crucial in applications where performance is critical, especially when rendering large textures or complex scenes.

Common Pitfalls

1
Relying on the availability of tiled resources can lead to performance issues.
Different hardware classes may not support tiled resources, so it's essential to check capability bits before depending on them.
2
Expecting immediate costs for Evict calls can result in unexpected performance degradation.
The cost of an Evict call may be deferred, leading to memory management issues if not handled properly.

Related Concepts

GPU Memory Management
Directx 12 Performance Optimization
Resource Allocation Strategies