Cinder-SdfText icon indicating copy to clipboard operation
Cinder-SdfText copied to clipboard

Efficiency

Open paulhoux opened this issue 8 years ago • 1 comments

This is not an issue, but a list of ways to improve efficiency:

  • Using a texture size of 512 or smaller may require more than one texture for all glyphs. If more than one texture is used, the number of draw calls to render the text increases. This leads to a lower frame rate. Instead of creating one draw call per texture, consider using an actual texture atlas, so that we can still render all text with single draw call.
  • Bin-packing will increase the number of glyphs that fit on a single texture. I have made good progress with it. One step of the algorithm does a brute force intersection test that could be improved. It helps to reduce the texture size to 512, because this will lower the number of intersection tests considerably.
  • The MSDFGEN algrotihm could potentially run on a separate thread, as long as access to FreeType is made thread-safe. I've tried this and it drastically improves performance. I used one thread per full texture, which rendered all glyphs assigned to that texture. The texture was also uploaded using a Pbo on a shared context.

Feel free to add more bullet points.

paulhoux avatar Sep 11 '16 21:09 paulhoux

Efficiency should be a high priority in my opinion, as loading just one font in Debug mode takes a really long time.

Edit: Never mind, I just discovered the save feature. It's as easy as:

	addAssetDirectory(getAppPath());

	//Load the Verdana 16 font.
	//verdana16Font = gl::SdfText::Font(loadAsset("verdana.ttf"), 16.0f);
	//verdana16Text = gl::SdfText::create(verdana16Font);
	//gl::SdfText::save(getAssetPath("") / "verdana.sdft", verdana16Text);
	verdana16Text = gl::SdfText::load(getAssetPath("") / "verdana.sdft");

And then the font loads much faster.

AndrewDavis avatar Apr 13 '17 01:04 AndrewDavis