Skip to content

[Impeller] Use the IO context for OpenGL program setup#31

Draft
xiaowei-guan wants to merge 7 commits intoflutter-tizen:flutter-3.41.4from
xiaowei-guan:flutter-3.41.4
Draft

[Impeller] Use the IO context for OpenGL program setup#31
xiaowei-guan wants to merge 7 commits intoflutter-tizen:flutter-3.41.4from
xiaowei-guan:flutter-3.41.4

Conversation

@xiaowei-guan
Copy link
Copy Markdown

No description provided.

chinmaygarde and others added 7 commits March 23, 2026 22:25
…of waiting. (flutter#180022)

Also, removes "lazy shader mode" and re-enables eager PSO pre-flight.

Impeller eagerly sets up the entire set of pipeline state objects (PSOs)
it may need during renderer setup. This works fine on mid to high-end
devices as the setup completes well before the first frame is rendered.

However on low-end devices, not all PSOs may be ready before the first
frame is rendered. Low-end device usually don't have as much available
concurrency and are slower to boot. On these devices, the rendering
thread had to wait for the background compile job to be completed. It
was also observed that the relatively higher priority render thread was
waiting on a background thread to finish a PSO compile job. The PSO
compile job could also be stuck behind another job that was not
immediately needed. This made the situation on low end devices less than
ideal.

To ameliorate this situation, a stop-gap was introduced called "lazy
shader mode". This disabled PSO pre-flight entirely and only dispatched
jobs when they were needed. This ameliorated somewhat the issue of
unneeded jobs blocking the eagerly needed job but the other issues
remained. It also meant that one could expect jank the first time a new
PSO was needed. This mode was not widely used or advertised.

In this patch, the lazy shader mode has been entirely removed and eager
PSO pre-flight is the default in all configurations. Pipeline compile
jobs are now handled by a separate compile queue. This queue operates
like a transparent concurrent worker pool job dispatcher in the usual
case. However, when the pipeline for a specific descriptor is needed,
instead of waiting for the job to complete, the queue allows the job for
that descriptor to skip to the head of the queue and be performed on the
calling thread. This effectively make the calling thread do the job
instead of waiting. Another nice side effect of this behavior is that
the higher priority thread is now doing the job it was previously
waiting on.

This fixes all issues on lower end devices except one. During eager
pre-flight, it would still be better if PSO compile jobs for that were
somehow divined to be needed first were towards the front of the
pre-flight queue. After all, only a handful of rendering features
account for the majority of rendering operations. A future augmentation
to the compile queue would be to allow higher prioritization of more
widely used pipeline compile jobs as instrumented in
flutter#176660. This task is tracked
in flutter#176665.

This patch only wires up the compile queue for Vulkan.
flutter#176657 tracks doing the same
for OpenGL.

The efficacy of the re-prioritizations can be traced using the
PrioritiesElevated trace counter. On higher end devices, there should
be zero of these.

Fixes flutter#176656
Fixes flutter#176663
Fixes flutter#176658
Because IO thread is the owner of resource context, pipeline library
gles can load resource by IO thread.
@xiaowei-guan xiaowei-guan marked this pull request as draft April 16, 2026 08:49
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