Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

For my game I need to generate a mesh dynamically. Now I'm wondering does it have a noticeable affect in FPS if I allocate more vertices than what I'm actually using or not? and does it matter if I'm using DirectX or OpenGL?

Edit

Final output will be a w*h cell grid, but for technical issues it's much easier for me to allocate (w+1)*(h+1) vertices. Sure I'll only use w*h vertices in indexing, and I know there is some memory wasting there, but I want to know if it also affect FPS or not? (Note that mesh is only generated once in each time you play the game)

share|improve this question
    
What do you mean allocating but not using? You mean like allocating vertices but then not indexing all of them? –  kaoD Mar 25 '12 at 20:12
1  
Well you'll use more memory, and, depending on whether or not those vertices are visible, will have an effect on your FPS in both OpenGL and DirectX. –  DMan Mar 25 '12 at 20:17
    
@kaoD yes exactly, updated the question. –  Ali.S Mar 25 '12 at 20:38

2 Answers 2

up vote 5 down vote accepted

You'll obviously be wasting memory resources, but the question about FPS is a good one actually.

Your framerate might drop not because you need more processing power or for cache-swapping reasons but for wasted memory accesses.

This is all about where are those extra vertices located. If the vertices are interleaved in the array you'll need more memory accesses since you'll waste a lot of bandwith fetching irrelevant data. If your extra vertices are contiguous then you'll get no FPS drop at all, since they're probably not going to be fetched (or will be fetched few times while fetching your last vertices.)

The more relevant data you can bring from memory at the same time, the better. Of course cache is also relevant, but for the same reasons stated in the last paragraph. Data doesn't matter for cache if you're not fetching it!

The actual FPS drop might not be noticeable. Unfortunately like almost anything GPU-related, you'll have to try it.

share|improve this answer

It could, in theory. More vertices means more memory used on the GPU. If your game uses enough GPU memory to trigger swapping, then you could lose a bit of time to memory transfer. However, if w and h are low, then the buffer will use a negligible amount of memory, and if w and h are high then the wasted memory is fairly small. (As an example, the overhead on a 64x64 grid is about 3%.) The chance that a useful buffer could fit in that additional space is pretty small. The chance that you'd notice the FPS difference there is pretty tiny.

It could also somewhat penalize a smarter GPU. Although a vertex that is never listed in the index buffer should never get transformed by your vertex shader, it still might be fetched and take up cache space, depending on how the GPU works. This assumes your wasted vertices are littered all over your vertex buffer, not concentrated at the end (where they'd presumably be easy to get rid of).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.