Sign in to follow this  

DirectX12 Minumum Allocation size.

This topic is 823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It looks like even for a buffer with a width 1 ID3D12Device::GetResourseAllocationInfo always returns the size/aligment as 64K. That is not a problem. The issue i am having is that any resource created on that heap needs to respect the aligment. So if put a resource at Offset 0 and try to put another resource at 32k for example. The resource at 0 will work but when i try to put something at 32k, it generates an error that say all resource needs to respect the boundary. So if i have two distinct buffers of let's say 32k each, there is no way i can create two distinct resources with the exact amout of memory i want to use because of that issue. One buffer would need to be at HeapOffset 0 and the other at HeapOffset 64k. Also now i would need to create a Heap with a size of 64k*2 in order to put two 32k buffers in there. Now i just waste 32k on each side. I know i can overcome this by creating one Huge buffer and and just point to the buffer location that i want to draw. But i kind of find it very annoying that the API does not let you insert the data into any location in a Heap.

 

All in all i know you can write a system that managed the heaps similar to how you would do it in the CPU side if you were to write your own memory management system. That

way that limitation does not seem like it exist.

Edited by BornToCode

Share this post


Link to post
Share on other sites

for a buffer with a width 1 ID3D12Device::GetResourseAllocationInfo always returns the size/aligment as 64K. That is not a problem. The issue i am having is that any resource created on that heap needs to respect the aligment. So if put a resource at Offset 0 and try to put another resource at 32k for example. The resource at 0 will work but when i try to put something at 32k, it generates an error that say all resource needs to respect the boundary.

I don't understand... You say that it's not a problem that the API tells you that you need use 64k alignment, but then you try and use 32k alignment instead anyway, which fails, as expected?

But i kind of find it very annoying that the API does not let you insert the data into any location in a Heap.

It's because GPUs have alignment requirements, and will crash if given misaligned pointers.

Share this post


Link to post
Share on other sites
My beef was that I cannot insert object anywhere I want on that heap of 64k. For example on the cpu side when you write your own memory manager you can put things anywhere you want. So I was not expecting the gpu to have that kind of limitation. But just like I said it is no biggie because you can create a memory management system that works around that.

Share this post


Link to post
Share on other sites

The CPU side has alignment limitations as well, they're just usually smaller. When trying to allocate an object of type T in C++, you should make sure that the memory address that you give it is a multiple of alignof(T).

It's just that GPU's tend to have (much) larger alignment requirements than CPU's. e.g. The biggest CPU-side alignment requirement that's commonly seen is 16-bytes, whereas GPU requirements are often measured in kilobytes smile.png

 

DX11 code (and earlier) didn't have to deal with this as the driver hid all the memory allocations from you. This is good as before, you were completely unaware that you might have been wasting loads of VRAM by making small buffers, but now, it's extremely obvious that 32KB buffers are wasteful!

 

In theory, these requirements would change from GPU to GPU, so the point of GetResourseAllocationInfo is that you can ask the API for information on the alignment requirements at runtime.

Edited by Hodgman

Share this post


Link to post
Share on other sites

I have gotten around it by creating a single buffer of 64k then just pass back a pointer that points to the current location in that buffer that i want to put the info. So the first object uses the first 32k and the second object uses the starting address+offset. Whenever i Map my resource i automaticaly add the offset to the starting address depending on the object i want to change. That way the resource is bound once and i can draw the two objects without any issues. That is what i meant when i say that you can write a system that can work around the limitation, you just have to managed it which is not a problem for me. I have written a ton of memory management system. smile.png. To be honest i really like

the way they have it, because now you can tell exactly how much memory you are using.

Edited by BornToCode

Share this post


Link to post
Share on other sites

This topic is 823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this