-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AtlasEngine: Reduce shader power draw with explicit branching (#12552)
Many articles I read while writing this engine claimed that GPUs can't do branches like CPUs can. One common approach to branching in GPUs is apparently to "mask" out results, a technique called branch predication. The GPU will simply execute all instructions in your shader linearly, but if a branch isn't taken, it'll ignore the computation results. This is unfortunate for our shader, since most branches we have are only very seldomly taken. The cursor for instance is only drawn on a single cell and underlines are seldomly used. But apparently modern GPUs (2010s and later?) are actually entirely capable of branching, _if_ all lanes ("pixels") processed by a wave (""GPU core"") take the same branch. On both my Nvidia GPU (RTX 3080) and Intel iGPU (Intel HD Graphics 530) this change has a positive impact on power draw. Most noticeably on the latter this reduces power draw from 900mW down to 600mW at 60 FPS. ## PR Checklist * [x] I work here * [x] Tests added/passed ## Validation Steps Performed It seems to work fine on Intel and Nvidia GPUs. Unfortunately I don't have a AMD GPU to test this on, but I suspect it can't be worse.
- Loading branch information
Showing
4 changed files
with
49 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters