Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

Dynamic Vertex Buffer?

This topic is 2520 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

is it possible to do the following...

Instantiate a Dynamic Vertex buffer like so in my class constructor


// Create Our Dynamic Vertex Buffer
D3D11_BUFFER_DESC bufferDesc;
bufferDesc.ByteWidth = 0; // ?
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // Might need D3D11_CPU_ACCESS_READ
bufferDesc.MiscFlags = 0; // ?

pGameDevice->CreateBuffer(&bufferDesc, NULL, &m_pVertexBuffer);


The descriptor asks for ByteWidth of the buffer and [color=#000000][font=Consolas, Courier, monospace]

StructureByteStride but i don't know these since i have no vertex to place in the buffer yet..im just wanting to have it ready for when i am going to use it for multiple function in my class.[/font]

Share this post


Link to post
Share on other sites
Advertisement

is it possible to do the following...

Instantiate a Dynamic Vertex buffer like so in my class constructor


// Create Our Dynamic Vertex Buffer
D3D11_BUFFER_DESC bufferDesc;
bufferDesc.ByteWidth = 0; // ?
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // Might need D3D11_CPU_ACCESS_READ
bufferDesc.MiscFlags = 0; // ?

pGameDevice->CreateBuffer(&bufferDesc, NULL, &m_pVertexBuffer);


The descriptor asks for ByteWidth of the buffer and [color=#000000][font=Consolas, Courier, monospace]

StructureByteStride but i don't know these since i have no vertex to place in the buffer yet..im just wanting to have it ready for when i am going to use it for multiple function in my class.[/font]



ByteWidth, make it equal to the total size of your vertex buffer (in bytes).

I could be wrong, and please, someone correct me if I am, but I think StructureByteStride is used to determine offsets of data elements in a structured buffer?

Share this post


Link to post
Share on other sites
AFAIK it's not possible to change a buffer's size after creation. You should know the number of vertices you want to put into the buffer before you create it. If you don't know, you could just make the buffer really big, and if it happens to get full, just make another buffer. but usually you should know how many vertices you will be putting into the buffer before it's created

ByteWidth = (sizeof(vertexStructure)) * numberOfVertices

Share this post


Link to post
Share on other sites
Hi,

you should reconsider your needs. Normally you shouldn't read back (have CPU read access) from vertex buffers (and mostly from any other direct3d resource).

StructureByteStride is only used for structured buffer. Set it to zero.




You don't have to know the size of the vertex/vertices that you will use with the dynamic vertex buffer. It is just a buffer and you may fill it with any sized verteces ie. you may also have different vertex sizes inside the buffer. There used to be some recommendations for the size of a dynamic vertex buffer, but I don't know if they still apply. You may try different sizes. There is some overhead with the MAP_DISCARD map flag so it shouldn't be used too often, which of course means that while drawing a frame the buffer should be big enough to hold a certain portion of the total dynamic data.

Can you describe the future use of the dynamic vertex buffer a little bit?

Best regards!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!