Skip to content

Text2d optimization (culling/batching) #11081

@jfaz1

Description

@jfaz1

What problem does this solve or what need does it fill?

Unlike 2d sprites, it seems that Text2d is neither batched nor culled. A simple benchmark spawning 5000 off-camera Text2dBundle instances yields the following FPS for me:

  • No characters (empty string): 2400 FPS
  • 1 character: 1200 FPS
  • 3 characters: 750 FPS
  • 50 characters: 45 FPS

Batching may be a little tougher due to varying size glyphs, but from what I understand culling should be fairly straightforward.

What alternative(s) have you considered?

In my case, almost all Text2d is parented to a border sprite, so I just manually set its visibility to match its parent sprite so when it gets automatically culled the text also becomes hidden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-TextRendering and layout for charactersC-PerformanceA change motivated by improving speed, memory usage or compile times

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions