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

Move dynamic allocations to device context #420

Open
TheMostDiligent opened this issue Jul 25, 2023 · 0 comments
Open

Move dynamic allocations to device context #420

TheMostDiligent opened this issue Jul 25, 2023 · 0 comments

Comments

@TheMostDiligent
Copy link
Contributor

At the moment, each USAGE_DYNAMIC buffer internally keeps dynamic allocations for each device context. This is inefficient from multiple points of view:

  • Allocations may never be needed if the buffer is not mapped
  • Allocations are only temporary and only needed for the time while buffer is mapped, yet they are allocated permanently
  • Allocations are aligned up to the cache line size, which further increases memory consumption

The last point also creates UB sanitizer errors such as this one:

git/DiligentEngine/DiligentCore/Common/interface/STDAllocator.hpp:148:19: runtime error: constructor call on misaligned address 0x000173672da0 for type 'Diligent::BufferVkImpl::CtxDynamicData', which requires 64 byte alignment
0x000173672da0: note: pointer points here
 00 00 00 00  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be

The solution is to keep dynamic allocations in the context directly.
This requires using fast hash map as with std::unordered_map, the performance is unacceptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant