bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.05k stars 1.94k forks source link

Dynamic vertex buffer getting overwritten by update after being submitted #3316

Closed adaxiik closed 4 months ago

adaxiik commented 4 months ago

Describe the bug Dynamic vertex buffer is getting overwritten by update after being submitted and I'm not sure if its expected/wanted behavior.

To Reproduce Steps to reproduce the behavior:

  1. Create DynamicVertexBuffer and fill it with data
  2. Submit it for render
  3. Update vertices with other data
  4. Submit it again
  5. First vertices are overwritten by second submit

Expected behavior I expected to see both of the submitted meshes at different positions

Repro I modified example 01 to demonstrate the bug

Additional context

bkaradzic commented 4 months ago

This is expected behavior. You can't modify data until it's consumed (by bgfx::frame call).

You should not open issues like this, rather ask question in Discord and Discussions.

adaxiik commented 4 months ago

thanks for the clarification! I will definitely join the discord community :100:

bkaradzic commented 4 months ago

Also check TransientVertex/IndexBuffers, it's better match for code in repro.

Transient buffers are when buffer life time is 1 frame. Dynamic buffers are more for things that last more than 1 frame but it's not completely static.