On Wed, Jul 31, 2013 at 10:09 AM, Antony Riakiotakis <[email protected]> wrote: > I think a good example of that is GPU_free_images that takes care of > centrally deallocating all resources and zeroing their identifiers. The > design here is that the data structure (image) is the owner (holds the ID > resource) of the GPU data so it is easy to invalidate the GPU data for all > owners. For shared resources this would not work if the identifier was > shared, we need to share an owner that will hold the ID and that owner can > be centrally notified for deallocation/zeroing. That means keeping a list > of owners of course. > I think GPU buffers also have an encapsulating inteface though, possibly > shaders too?
There are GPUTexture, GPUShader, GPUDrawObject, .. wrappers. There's a few places that hold OpenGL ids directly but these could be changed. I guess in general the issue is more having a way to clear all of them which the current wrappers don't help with. You could have these wrappers store a pointer to a pointer so that they can be automatically set to NULL in the owner (like a weak reference). And then put them in some global array so that you can loop over all of them. I'm not sure if that makes the code more clear, I don't really have a strong opinion here, having a function that loops over all of them isn't so terrible either. > Note, GPU_free_images also deletes the resources besides zeroing the IDs, > I'm not sure if on context loss this is already done, so possibly a version > that only zeroes the IDs may need to be written. I imagine this might give an OpenGL error but not actually cause any problems, not sure. But might as well check for it and only delete when needed. Brecht. _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
