Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to query if an allocation is dedicated? #383

Closed
debaetsd opened this issue Nov 6, 2023 · 7 comments
Closed

How to query if an allocation is dedicated? #383

debaetsd opened this issue Nov 6, 2023 · 7 comments
Labels
feature Adding new feature next release To be done as soon as possible

Comments

@debaetsd
Copy link

debaetsd commented Nov 6, 2023

Is there a way to know if an allocation is flagged as dedicated?
I need to know this in order to properly setup interop flags (GL_DEDICATED_MEMORY_OBJECT_EXT for example).
Currently vma can decide to make an allocation dedicated (for valid reasons) but as far as I can tell there is no way to know that?

I modified our local fork (with changes discussed in #340 ) to return this knowledge inside VmaAllocationInfo.
Is this the only way (and our our fork is diverging even more) or was there already a way to know this?

@adam-sawicki-a
Copy link
Contributor

I am sorry, but this information is not available and I don't want to add it to VmaAllocationInfo. The whole point of using VMA is to hide such things from the user and handle them automatically, which simplifies the memory allocation aspect of Vulkan usage.

If you need explicit control over when VkMemoryDedicatedAllocateInfoKHR is used, you can do so in VMA by:

  • Passing VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT to make sure it is used.
  • Create a custom pool with VmaPoolCreateInfo::blockSize > 0, to make sure allocations are placed in larger heaps and never dedicated.

Or you can allocate these special resources that need OpenGL interop directly in Vulkan, without VMA.

@adam-sawicki-a adam-sawicki-a added question Further information is requested wontfix This will not be worked on labels Nov 6, 2023
@debaetsd
Copy link
Author

debaetsd commented Nov 7, 2023

The thing is, I do not want control about dedicated allocations, block sizes or pools.
I am perfectly fine with the decisions VMA is making, I just want to know about it (so I can pass the correct flags/properties to OpenGL).

I understand your point wrt simplicity but as it stands, it does not really apply to interop right?
Doing proper interop is just not possible with the current version so the bit of support of interop currently inside VMA could probably be even removed as it is not working anyway (unless you are willing to back yourself into a very narrow corner)

@adam-sawicki-a
Copy link
Contributor

adam-sawicki-a commented Nov 7, 2023

How about we add a separate function vmaGetAllocationInfo2 and structure VmaAllocationInfo2 that would carry VmaAllocationInfo + additional members: blockSize, hasDecicatedMemory? Would that help in your case? What else should we add to make VMA working with the interop?

@debaetsd
Copy link
Author

debaetsd commented Nov 7, 2023

Yes that would work perfectly!

For interop, we need the following information (some of it is obviously already provided):

ideally also as part of the various vmaAllocateMemory functions as optional argument (though that is just a bit of syntax sugar and we could make that additional GetAlloctionInfo2 call ourselves.

adam-sawicki-a added a commit that referenced this issue Nov 8, 2023
@adam-sawicki-a
Copy link
Contributor

I've added the function and structure as proposed above. Please let me know if it works for you.

@adam-sawicki-a adam-sawicki-a added feature Adding new feature next release To be done as soon as possible and removed question Further information is requested wontfix This will not be worked on labels Nov 8, 2023
@debaetsd
Copy link
Author

debaetsd commented Nov 9, 2023

I tested this inside our codebase and it works flawless!
This will make our own fork redundant, thank you for doing this!

@adam-sawicki-a
Copy link
Contributor

Thank you for the confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new feature next release To be done as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants