Implement support for allocating resources within memory budget.#186
Merged
Implement support for allocating resources within memory budget.#186
Conversation
Owner
Author
|
Run: checks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
This PR implements support for memory budgets using the new
AllocationBehaviorflags, that can be passed to theIGraphicsFactorymethods that allocate resources. The first of those flags,StayWithinBudgetforces 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,DontExpandCacheis 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