[Impeller] Support managed static branches for ImpellerC shaders. #116103
Labels
c: proposal
A detailed proposal for a change to Flutter
e: impeller
Impeller rendering backend issues and features requests
engine
flutter/engine repository. See also e: labels.
P2
Important issues not at the top of the work list
team-engine
Owned by Engine team
triaged-engine
Triaged by Engine team
When authoring shaders which perform a given rendering task, it's often convenient to customize the task at runtime by dynamically branching on a discrete uniform input (constant with respect to the pipeline invocation). Shaders which are extended this way are both easy to author and maintain.
For example, a uniform could be used to turn on/off an optional rendering feature, or to enumerate different UV mapping behaviors when sampling from bound textures.
This technique can work great for simple branches that contribute minimal constant time overhead to the computation, but can quickly pose a performance problem if the branch is nontrivial and/or needs to be used in a superconstant code path.
The fast alternative to uniform dynamic branching is to produce individual specialized shaders for each branch case. Then, the correct shader can be chosen at render time on the CPU.
However, converting uniform branches to static branches is currently an incredibly cumbersome process that outputs maintainability nightmares.
These are the problems that managed static branches can solve. Static branching should be no more difficult (and perhaps even easier) than dynamic branching on discrete uniforms. For shader authors, defining and using static branches can be made trivial.
The text was updated successfully, but these errors were encountered: