LeshaInc
LeshaInc

Reputation: 111

Why Vulkan has a limit of memory allocations?

Is there any technical reasons to limit the maximum number of memory allocations?

Check out vkAllocateMemory manual page. It says:

The maximum number of valid memory allocations that can exist simultaneously within a VkDevice may be restricted by implementation- or platform-dependent limits. If a call to vkAllocateMemory would cause the total number of allocations to exceed these limits, such a call will fail and must return VK_ERROR_TOO_MANY_OBJECTS.

OpenGL doesn't limit allocations, DirectX 11/12 neither. So why should Vulkan do so?

Upvotes: 6

Views: 3270

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473302

As explained here, this is primarily an OS limitation.

OpenGL doesn't limit allocations, DirectX 11/12 neither

Oh, they do. They just don't tell you about it.

OpenGL and DX11 drivers tend to internally do large GPU (virtual) allocations and perform sub-allocations from those when you allocate memory. Thus, they can create the illusion that you can perform more hardware allocations. But the limitation is still there.

As for DX12, I'm fairly sure that if you try to allocate more than 4096 heaps, you will find CreateHeap returning errors.

Vulkan is simply the API that's up-front about the existence of the limitation.

With Vulkan, this is simply a problem that should never arise. If you're performing over a thousand individual memory allocations, your memory allocation scheme is wrong. You're supposed to allocate a few large slabs of memory, then use sub-sections of them for your textures and buffers.

Upvotes: 13

Related Questions