5
\$\begingroup\$

Maybe it's a stupid question but I actually don't know - is it possible to change vertex buffer's size after it's been already created (with CreateBuffer())? If so, how do I update its data (with both Map() and UpdateSubresource()) when the new data contains more/less vertices?

I'm interested in vertex buffers and dx11 but the question probably applies also to index buffers and opengl.

\$\endgroup\$

1 Answer 1

9
\$\begingroup\$

No, at least in D3D11 it is not possible to change the size of a buffer or texture after it's been allocated. You would have to release the old buffer and create a new one (which is inadvisable to do often, as it can hurt performance).

It's okay to only use part of a vertex buffer, so if you know the maximum size your data will be, I'd allocate the buffer to that size; then you can just write to and draw from as much of it as you need in a given frame.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.