Results 1 to 5 of 5

Thread: Does Vulkan prevent the local device memory fragmentation?

  1. #1

    Does Vulkan prevent the local device memory fragmentation?

    I hope it is not already asked, but as the question says, after a series of allocations and releases, the device memory may become fragmented and, despite having enough memory for a request, the runtime won't provide a valid pointer because that memory isn't contiguous. Does Vulkan prevent this in any form? or should we write our own managers to address such issue?

    Thanks

  2. #2
    Quote Originally Posted by SantiagoAlberto View Post
    I hope it is not already asked, but as the question says, after a series of allocations and releases, the device memory may become fragmented and, despite having enough memory for a request, the runtime won't provide a valid pointer because that memory isn't contiguous. Does Vulkan prevent this in any form? or should we write our own managers to address such issue?

    Thanks
    You should not be allocating and releasing memory in Vulkan sufficiently frequently for that to matter. Most applications that need to use Vulkan should make a fixed number of allocations.

  3. #3
    Junior Member MaryCamp's Avatar
    Join Date
    Sep 2017
    Posts
    5
    Hi all,
    If I understand it correctly you should allocate one big buffer and then use that buffer for multiple smaller buffers.
    Let's say we want to load a bunch of modeldata onto the gpu.
    CarModel = 5.7mb,
    StoneModel = 2.5mb,
    HumanModel = 6.2mb,
    Now those models should probably reside in device local memory as it is immutable.
    ModelBuffer = [CarModel, StoneModel, HumanModel, ... junk data]
    I haven't actually tried it yet but you then should be able to access them with the offset parameter.
    At one point you also need to delete some models as that are no longer needed. For example we might want to "unload" the CarModel.

  4. #4
    Senior Member
    Join Date
    Dec 2013
    Location
    Germany
    Posts
    140
    Yes, that's the correct way. You should keep API allocations down to a minimum and allocate in big chunks per memory type instead (e.g. 256 MB) and do sub-allocations yourself and then just offset for rendering.

    If you need a basic example (without manual sub allocations) of how to do this, there is an https://github.com/SaschaWillems/Vulkan/blob/master/scenerendering/scenerendering.cpp]example of this in my repository.

  5. #5
    I will take a look at that example. Thanks for your answers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean