Skip to content

Store the ImageInfo for font textures in the font#1030

Merged
robertosfield merged 1 commit intovsg-dev:masterfrom
timoore:font-image-info
Nov 17, 2023
Merged

Store the ImageInfo for font textures in the font#1030
robertosfield merged 1 commit intovsg-dev:masterfrom
timoore:font-image-info

Conversation

@timoore
Copy link
Copy Markdown
Contributor

@timoore timoore commented Nov 17, 2023

This is in place of only storing the Data for the font texture and relying on SharedObjects to find an already created font texture. The font glyph metrics weren't stored as data at all, but were recreated on every creation of a GpuLayoutTechnique.

At the moment this change results in a massive memory savings in complex scenes. There seems to be a bug in SharedObjects in that it can't pick up the images in a font if they are recreated on each use, resulting in gigabytes of extra texture use. Even if SharedObjects is fixed, it is cleaner to store the images in the font.

The glyph metrics texture should probably be a storage buffer instead.

If this is accepted, then the code in vsgXchange that creates a font using freetype should probably change to call createFontImages().

This is in place of only storing the Data for the font texture and
relying on SharedObjects to find an already created font texture. The
font glyph metrics weren't stored as data at all, but were recreated
on every creation of a GpuLayoutTechnique.

At the moment this change results in a massive memory savings in
complex scenes. There seems to be a bug in SharedObjects in that it
can't pick up the images in a font if they are recreated on each use,
resulting in gigabytes of extra texture use. Even if SharedObjects is
fixed, it is cleaner to store the images in the font.

The glyph metrics texture should probably be a storage buffer
instead.
@robertosfield
Copy link
Copy Markdown
Collaborator

Changes look good. It looks like createFontImages() is already created when needed, so what would the benefit of vsgXchange::freetype calling it explicitly?

@robertosfield robertosfield merged commit ebfab60 into vsg-dev:master Nov 17, 2023
@timoore
Copy link
Copy Markdown
Contributor Author

timoore commented Nov 17, 2023

I was worried about multithreading issues and didn't want to add a mutex to the font or something, and so thought it best if the font-building code completely constructed the images.

@robertosfield
Copy link
Copy Markdown
Collaborator

It is indeed safer to create as much up front before objects are shared to prevent possible race conditions.

There remains an open ended question of how much of the compile and record traversals need objects protected to prevent race conditions, so far I have left it high level coordinates of threads to prevent them stepping on each others toes with shared data, but it's fragile peace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants