title: Best way to sync VBOs between threads
body: <p>So I have a minecraft-like chunk system, meaning it's one block of render data. When the player moves around and enters another chunk, out-of-range chunks are being unloaded while new ones are being loaded, which makes it quite demanding since render data has to be calculated in another thread first before it can be shown.</p>
  
  <p>Assuming the data is already loaded from the disk it looks like this</p>
  
  <p>Main/Render Thread           Render Data Generation Thread</p>
  
  <pre><code>   |         Request Chunk            |
     | -------------------------------&gt; |
     |                                  |
     |                                  | Generating render data (FloatBuffer)
     |                                  |
     |                                  .
     |                                  .
     |                                  .
     |        Get Ready Chunks          |
     | &lt;------------------------------- |
     |                                  |
     | Upload Data                      |
     |                                  |
     | Render                           |
     |                                  |
  </code></pre>
  
  <p>"Request Chunk" and "Get Ready Chunks" are not synchronized so the render thread really works independently.</p>
  
  <p>The problem with this is that uploading a lot of chunks at once causes framedrops, but calculating how much time I have left to upload can't be done reliably. If I only uploade one per frame I would miss out on alot of speed, although it works fine (That's how it's implemented at the moment).</p>
  
  <p>Since I'm using only one GL context I can only create VBOs in the main thread at the moment.</p>
  
  <p>Is there any way to solve this to be more efficently, like creating VBOs in the other thread and just passing them over to the main thread?</p>