title: Making GL textures uploading async and figuring out when it's done uploading
body: <p>I have run into an issue where my application requires loading images dynamically at runtime. This ends up being a problem because it's not possible to load them all up front since I can't know which ones will be used... otherwise I have to upload everything. The problem is that some people do not have good PCs and have been complaining that loading all the images to the GPU takes a long time for them due to bad hardware.</p>
  
  <p>My work around for the latter group was to upload textures just as is needed, and this worked for the most part. The problem is that during the application, there are times where delays occur when a series of images need to be uploaded and there's a delay due to the uploading. </p>
  
  <p>I was researching how to get around this, and I have an idea: Users want a smooth experience and are okay if the textures are not immediately loaded but instead are absent. This makes it easy, as I can upload in the background and then just draw nothing for where the object should be, and then bring it into existence after it is done. This is acceptable because the uploads are usually pretty fast anyways, but they're slow enough that it causes it to dip under 60 fps for some people which causes some stutter. On average it causes anywhere from 1-3 frames of stutter so the uploads do resolve fast and on average less than 50ms.</p>
  
  <p>My solution was to attempt something using a PBO to get some async-like uploading. Problem is I cannot find online how I can tell when the uploading is done. Is there a way to do this?</p>
  
  <p>I figure there are four options:</p>
  
  <ol>
  <li>There's a way to do what I want with OpenGL 3.1 onwards and that will be that</li>
  <li>It is not possible to do (1), but I could place a fence in and then check if the fence is done, however I've never had to do this before so I'm not sure if it would work in this case</li>
  <li>It's not possible, but I could make the assumption that everything would be uploaded in &lt; 50ms and use some kind of timestamp to tell if it's drawable or not and just hope that it is the case (and if the time is &lt; 50ms since issuing an upload, then draw nothing)</li>
  <li>It's not possible do to this for texture uploading and I'm stuck</li>
  </ol>
  
  <p><strong>This leads me to my question:</strong> Can I tell when an asynchronous upload of pixels to a texture is done?</p>