Skip to content

Implement memory budgets. #177

@crud89

Description

@crud89

Describe your problem

Both memory allocator libraries support flags that control allocation behavior if memory budget is low. We should add support for those allocation strategies as well.

Describe your proposed solution

  • Add tryAllocate versions to IGraphicsFactory and resource interfaces, that does not throw if an allocation fails.
  • Add withinBudget switch to respect memory budget of the requested heap.
  • Add noCacheResize switch to prevent new memory blocks from being allocated (helpful for streaming in resources, in situations where frame times have priority).

For the tests, we can test failure with WITHIN_BUDGET and NEVER_ALLOCATE by allocating buffers that are too large for the default heaps. VMA allocates 1Gb blocks for "small" (VMA_SMALL_HEAP_MAX_SIZE) and 256Mb blocks for "large" resources (VMA_LARGE_HEAP_MAX_SIZE), while D3D12MA allocates 64Mb blocks by default (D3D12MA_DEFAULT_BLOCK_SIZE). Allocating a 1.5Gb buffer should fail with NEVER_ALLOCATE, but succeed with WITHIN_BUDGET (as well as no flags). We should add tests for all supported resource types (buffers, vertex buffers, index buffers and images) and both backends. Also we should test both, the throwing- and non-throwing versions in a test.

Metadata

Metadata

Assignees

Labels

DX12 ❎The issue involves the DX12 backend.FeatureNew feature or request.Vulkan 🌋The issue involves the Vulkan backend.

Projects

Status

v0.5.1

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions