2
\$\begingroup\$

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)

\$\endgroup\$
3
  • \$\begingroup\$ What do you mean allocating but not using? You mean like allocating vertices but then not indexing all of them? \$\endgroup\$
    – kaoD
    Commented Mar 25, 2012 at 20:12
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DMan
    Commented Mar 25, 2012 at 20:17
  • \$\begingroup\$ @kaoD yes exactly, updated the question. \$\endgroup\$
    – Ali1S232
    Commented Mar 25, 2012 at 20:38

2 Answers 2

6
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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).

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .