Skip to content

Implement support for allocating resources within memory budget.#186

Merged
crud89 merged 11 commits intomainfrom
dev/memory-budget
Oct 13, 2025
Merged

Implement support for allocating resources within memory budget.#186
crud89 merged 11 commits intomainfrom
dev/memory-budget

Conversation

@crud89
Copy link
Copy Markdown
Owner

@crud89 crud89 commented Oct 13, 2025

Describe the pull request

This PR implements support for memory budgets using the new AllocationBehavior flags, that can be passed to the IGraphicsFactory methods that allocate resources. The first of those flags, StayWithinBudget forces allocations to fail, if no more memory is available in a given resource heap and it is not possible to allocate more. Drivers may fall back to allocating memory from a different (less efficient) heap instead, but with this new flag, clients have control over this behavior. The second flag, DontExpandCache is even more strict, as it prevents the underlying allocators from allocating additional heap space altogether. This can be useful in performance critical code, where allocations can be postponed to a later (less critical) time.

By default, the factory methods previously raised an exception, if allocations failed. Especially to be used in combination with the new budgeting flags, resource factory methods now provide a version prefixed with try (e.g., IGraphicsFactory::tryCreateBuffer), that does not fail, but returns a boolean instead. Note that those methods may still raise exceptions, if input argument validation fails, however, they do no longer throw if the allocation itself fails.

Related issues

@crud89 crud89 added this to the Alpha #05 milestone Oct 13, 2025
@crud89 crud89 self-assigned this Oct 13, 2025
@crud89 crud89 added the Vulkan πŸŒ‹ The issue involves the Vulkan backend. label Oct 13, 2025
@crud89 crud89 added this to LiteFX Oct 13, 2025
@crud89 crud89 added the DX12 ❎ The issue involves the DX12 backend. label Oct 13, 2025
@crud89 crud89 linked an issue Oct 13, 2025 that may be closed by this pull request
@crud89 crud89 moved this to In Progress in LiteFX Oct 13, 2025
@crud89
Copy link
Copy Markdown
Owner Author

crud89 commented Oct 13, 2025

Run: checks

@crud89 crud89 merged commit dec7763 into main Oct 13, 2025
9 checks passed
@crud89 crud89 deleted the dev/memory-budget branch October 13, 2025 18:43
@crud89 crud89 moved this from In Progress to v0.5.1 in LiteFX Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX12 ❎ The issue involves the DX12 backend. Vulkan πŸŒ‹ The issue involves the Vulkan backend.

Projects

Status: v0.5.1

Development

Successfully merging this pull request may close these issues.

Implement memory budgets.

1 participant