1
0
Fork 0
Commit graph

55 commits

Author SHA1 Message Date
Neil Roberts
9139f21e09 cogl-atlas-texture: Remove textures from the atlas when mipmapping is required
Mipmaps don't work very well in the current atlas because there is not
enough padding between the textures. If ensure_mipmaps is called it
will now create a new texture and migrate the atlased texture to
it. It will use the same blit mechanism as when migrating so it will
try to use an FBO for a fast blit. However if this is not possible it
will end up downloading the data for the entire atlas which is not
ideal.
2009-12-05 14:11:57 +00:00
Neil Roberts
3ebe48105d cogl-atlas-texture: Try to do texture blits using an FBO
When reorganizing the textures, we can avoid downloading the entire
texture data if we bind the source texture in a framebuffer object and
copy the destination using glCopyTexSubImage2D. This is also
implemented using a much faster path in Mesa.

Currently it is calling the GL framebuffer API directly but ideally it
would use the Cogl offscreen API. However there is no way to tell Cogl
not to create a stencil renderbuffer which seems like a waste in this
situation.

If FBOs are not available it will fallback to reading back the entire
texture data as before.
2009-12-05 14:11:31 +00:00
Neil Roberts
f5d43d9b02 cogl-texture-atlas: Add some debugging notes
This adds an 'atlas' category to the COGL_DEBUG environment
variable. When enabled Cogl will display messages when textures are
added to the atlas and when the atlas is reorganized.
2009-12-04 20:29:12 +00:00
Neil Roberts
ec547b7ce0 cogl-atlas-texture: Support reorganizing the atlas when it is full
When space can't be found in the atlas for a new texture it will now
try to reorganize the atlas to make space. A new CoglAtlas is created
and all of the textures are readded in decreasing size order. If the
textures still don't fit then the size of the atlas is doubled until
either we find a space or we reach the texture size limits. If we
successfully find an organization that fits then all of the textures
will be migrated to a new texture. This involves copying the texture
data into CPU memory and then uploading it again. Potentially it could
eventually use a PBO or an FBO to transfer the image without going
through the CPU.

The algorithm for laying out the textures works a lot better if the
rectangles are added in order so we might eventually want some API for
creating multiple textures in one go to avoid reorganizing the atlas
as far as possible.
2009-12-04 20:27:02 +00:00
Neil Roberts
bec2600087 cogl: Add an atlased texture backend
This adds a CoglAtlas type which is a data structure that keeps track
of unused sub rectangles of a larger rectangle. There is a new atlased
texture backend which uses this to put multiple textures into a single
larger texture.

Currently the atlas is always sized 256x256 and the textures are never
moved once they are put in. Eventually it needs to be able to
reorganise the atlas and grow it if necessary. It also needs to
migrate the textures out of the atlas if mipmaps are required.
2009-12-04 20:26:39 +00:00