Skip to content

Efficient usage of multiple TextBrush instances #22

@eseaflower

Description

@eseaflower

Hi and thanks for your work with wgpu-text.
I want to use wgpu-text to draw text into several different views within a render pass (using RenderPass::set_viewport). The options I have considered so far are:

  1. For each viewport within the render pass, queue the text for the viewport and then render it immediately. Repeat this for each call to set_viewport. This seems innefficient since the cache in glyph_brush is flushed on each draw call, retaining only the data in the most recent render.
  2. Use separate TextBrush instances for each viewport. This enables queueing of the text before rendering and each viewport will have its own cache. The downside of this approach is that we also end up with a separate wgpu::RenderPipeline for each instance and multiple invocations of shader compilation each time the number of viewports change.

One way to overcome this limitation is to allow the creation of a TextBrush with a 'shared' wgpu::RenderPipeline. The idea would be that multiple instances of TextBrush could share a RenderPipeline while still maintaining seprarate vertext buffers and caches. I'm thinking this could be exposed via something like BrushBuilder::with_shared_pipeline().

What do you think, is this something you would like me to implement?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions