I am currently working on an application that does some expensive data updates in an update thread and renders in a second thread. The updates typically consist of uploading several hundred MB to an SSBO, followed by a compute shader dispatch to process the uploaded data and write the result into another SSBO that is used for rendering. For the sake of argument, let’s say the updates are performed in alphabetic order of the data’s file names. However, rendering of the results should be performed starting with the smallest data first. I.e.:
Update: updateSmallData(); updateHugeData(); updateGiganticData(); updateTinyData(); Rendering: renderTinyData(); renderSmallData(); renderHugeData(); renderGiganticData();
How can I implement this such that renderTinyData() only requires updateTinyData() to be finished, while all larger updates continue during rendering? If I use a memory barrier before renderTinyData(), it will stall until all results of updateGiganticData() have been written. Likewise, if I insert fences before and after updateTinyData(), I cannot just wait for the completion of all commands between these two fences. Does OpenGL (any version, any extension) provide a mechanism to explicitly state which (range of) commands to sync?
I hope you get the idea. I have both large and small data updates that are completely independent from each other and that are completely unsorted with respect to their update cost. All data will always change at the same time. Rendering, however, should start with the smallest data and should only stall if the update (buffer upload + compute shader + SSBO write) for these data is not yet finished, while the updates of larger data are permitted to continue. I know this is possible by reordering the updates, but I am explicitly asking for a mechanism that avoids this, because I simply don’t reliably know the cost of an update beforehand. Is this possible?