Maximum number of index buffers allowed?

Started by
5 comments, last by Evil Steve 14 years, 11 months ago
Here's a bit of an odd DX9 issue. In a class, I have 2 index buffers (each created as dynamic in the default pool). The first one has a size of 12,288 bytes and the second a size of 96 bytes. There are 16,384 of these instantiated classes, so memory-wise, that's about ~202 MB in index buffers in total. This is not how things will be done eventually, creating this many classes/index buffers isn't necessary for my design, it was just a consequence of some tinkering I've been doing with my terrain engine. Creating 16,384 instances of this class and using the index buffers works fine, everything renders perfectly, but then things start getting strange when I add another index buffer to the class. If I add another index buffer to the class (of size 36 bytes), I get an out of memory exception mid-way through creating the 16,384 objects. That's understandable, I hear you say, and it is - if that 3rd index buffer uses up more memory than I have left in the GPU, I'd expect that error. BUT.. If I change the 1st index buffer to use only 96 bytes instead of 12,288 bytes, I still get the error - that's a memory footprint of only ~3 MB for all 16,384 of the instances. I'm pretty certain the code is correct and there are no strange copy/paste issues and everything is locked/unlocked correctly. I'm using a dual GPU card with 896 MB of VRAM and other than these index buffers, I'm probably using up ~120 MB of VRAM. So is there either a card or DirectX9-based limit to the number of index buffers you can create on the GPU? Perhaps the limit is 32768? I've done some research and everything seems to be related to the maximum size of the content of index buffers, rather than how many actual index buffers you are allowed to create. Thanks
Advertisement
There shouldn't be any officially-imposed limit to the number of index buffers you can have. There's nothing to that effect in the caps at least. Realistically, it's probably limited by what the driver is able to do due to memory or abitrarily imposed limits.

And although your card has 896MB total VRAM, there's currently no dual-GPU card that has a shared framebuffer. So in effect you only have 448MB VRAM, duplicated across both GPUs.

But really, 16,000 index buffers is a heck of a lot. Why do you need so many separate buffers? DrawIndexedPrimitive allows you to specify the starting index to use - you could theoretically even merge all your index buffers into a single massive buffer and use the StartIndex parameter to index different parts.
NextWar: The Quest for Earth available now for Windows Phone 7.
Quote:This is not how things will be done eventually, creating this many classes/index buffers isn't necessary for my design, it was just a consequence of some tinkering I've been doing with my terrain engine.


I don't need them all and if I choose this method, I will be using some form of compression, which is, as you mentioned, likely to be indexing into a larger buffer. I was just experimenting with ideas without being too fussed about memory at this stage and was just curious as to whether it was a limitation or not. I think it must be some kind of limitation - especially as I get the memory exception even when the index buffers amount to ~3 MB.

Thanks for your response though.
Memory on cards is typically allocated in pages. My guess would be that this applies to index buffers like any other card memory (texture, etc.). Suppose a page size is 4K, then even a 36 byte buffer will take 4K. I did a (not very short) web search for this info, but couldn't find it for your card (presumably a modern GeForce). It's not out of the question that page size is higher than 4K. 8K will mean 3 * 16,384 small buffers take 384MB. 16K will mean 768MB, and so on.

In short, it's certainly possible that you're running out of memory.
I'll do some checks tonight, but I'm fairly convinced you're on the money there. Thanks for checking.
ET3D : Would you mind posting some official info / link from card manufacturers that states those numbers ?

Thanks
Quote:Original post by joe1024
ET3D : Would you mind posting some official info / link from card manufacturers that states those numbers ?
The way most memory managers work is they allocate in pages - a graphics card is no exception. ET3D already said that he couldn't find any information about the page size, but it's likely to be at least 4KB (Which is what Windows uses), and likely larger since typically VRAM is required in large chunks, not lots of small amounts.

This topic is closed to new replies.

Advertisement