Original Post
Hi everybody. --- --- The application consists of two threads, "Renderer" and "Loader". "Renderer" draws objects with VBO and "Loader" update VBO's contents. If "Renderer" is calling some gl commands (drawing or state updating), can "Loader" modify VBO content without blocking "Renderer" ? --- --- Consider this situation: 1) there are a fixed number of VBO; 2) thread "Renderer" is the main, rendering thread: 2-a) in a first visit, selects the objects to draw and ask thread "Loader" to load their associate data from disk; 2-b) for each of the previously selected objects, asks the "Loader" to get a the vbo ID in which object's data has been loaded and if so draws it, otherwise proceeds to the next object (well, in effect some vbo ID is always returned, even if it is associated to a lower resolution of the requested data); 3) thread "Loader" is the loader: reads requests from thread "Renderer" and, accordingly to some kind of priority, selects an unlocked victim from cache, lock it, loads in it new data from disk, put it in cache and unlock it. 4) I omitted all other shared data exclusive access (queues, cache etc.) for simplicity. Typical situation: -- "Renderer" can be calling state commands like glClear(...), glEnable(...), etc. or vbo-binding/drawing commands like glBindBuffer(...) and GLDrawArrays(...); --- "Loader" can be calling vbo-binding/updating commands like glBindBuffer(...) and glBufferSubData(...); If I can guarantee (in effect it is done) that the vbo currently used by "Renderer" is different from the one used by "Loader", can these commands be executed without the two threads blocking each other? If not, is a solution If I can guarantee that every group of call to vbo stuff is done in mutual exclusion even if not referring the same vbo? And more in general (even if my question regards only vbo management), can non-interfering gl commands be called on the same gl-context without the need for synchronization? In effect, a solution for this problem is that the "Loader" can put the data loaded in a temporary buffer associated with every vbo and the vbo marked as "dirty". Then when the "Renderer" wants to use it, if it is dirty then upload the data from the vbo's temporary buffer, and finally renders it. However, I don't want to keep a temporary buffer for each vbo thus duplicating the total system + video memory. In addition, It is preferable even not to using a single temporary buffer in the "Loader", but instead specifying the memory mapped pointer returned by glMapBuffer(...) as the destination address of a fread(...) or memcpy(...) (if the file is memory mapped). I am very sorry for the very long post, but the situation required it to eliminate possible doubts about problem and solution. Thanks in advance!!! :) Marco