Hi,
Let's imagine this scenario:
The database pager loads the file "x.osgb".
This file contains 3 geometries (A, B, C). A has a texture that uses
A.jpg, B uses B.jpg and C uses C.jpg. These textures are not used by
the already rendered geometry (i.e. not compiled)
The FindCompileableGLObjectsVisitor is configured to set a pixel
buffer object on the texture's image. An unique buffer object
(shared by the 3 images) is created.
The buffer object is configured to release it's GL buffer once the
texture is applied (setCopyDataAndReleaseGLBufferObject(true)).
After the draw dispatch, the IncrementalCompileOperation compiles
the new geometries and textures:
for each textures
texture->apply(. . .) =
bind the buffer object
copy A.jpg, b.jpg and C.jpg in the buffer (the 3 images
are copied because the buffer object is shared)
glTex[Sub]Image(. . ., offset of the current image in
the buffer)
if (getCopyDataAndReleaseGLBufferObject())
release GL buffer
So, for each texture, a GL buffer is created, the 3 images are
copied, the data is copied in the texture using the current image
offset in the buffer and the buffer is deleted.
The GL buffer should not be released before all the images are copied
into their textures(i.e. glTex[Sub]Image for all the textures).
There are few usages cases of a pixel buffer object:
* texture paging (IncrementalCompileOperation): the GL buffer release
can be done after the compilation loop
* rendering (a noncompiled texture is used to render geometry): the GL
buffer release can be done once all the textures using the buffer
are compiled
* texture streaming (movie): the GL buffer should not be released
The first 2 cases can be handledusing some king of reference counter
(the buffer contains X segments, each glTex[Sub]Image decrements this
counter, when it reaches 0the buffer can be released).
In the third case, the buffer should never be released. The counter
should not be decremented.
What do you think about this? I'm not sure all the usage cases are
covered, especially if the buffer is a vertex buffer or an indices buffer.
Lionel Lagarde
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org