Restore differential drawing to DirectWrite renderer #1069

Closed
opened 2026-01-30 22:15:42 +00:00 by claunia · 10 comments
Owner

Originally created by @miniksa on GitHub (May 14, 2019).

Originally assigned to: @miniksa on GitHub.

For some reason, I turned this off in the haste to get things "working" well enough.

But it's definitely a performance hog. We should get differential drawing back inside the DirectWrite renderer.

Most of the provisions are already there with the invalid rectangle, we're just not using them.

I'm not sure if I'll be able to do cell-by-cell differential drawing like the GDI renderer because the more advanced glyphs/runs we support now (like ligatures) might necessitate that we instead just mark "invalid lines" and redraw the whole line. That would be mildly better than the whole screen.

This also would re-enable the use of the Present1 call to the DX infrastructure which is more efficient at scrolling and dirty regions.

Originally created by @miniksa on GitHub (May 14, 2019). Originally assigned to: @miniksa on GitHub. For some reason, I turned this off in the haste to get things "working" well enough. But it's definitely a performance hog. We should get differential drawing back inside the DirectWrite renderer. Most of the provisions are already there with the invalid rectangle, we're just not using them. I'm not sure if I'll be able to do cell-by-cell differential drawing like the GDI renderer because the more advanced glyphs/runs we support now (like ligatures) might necessitate that we instead just mark "invalid lines" and redraw the whole line. That would be mildly better than the whole screen. This also would re-enable the use of the `Present1` call to the DX infrastructure which is more efficient at scrolling and dirty regions.
Author
Owner

@oising commented on GitHub (May 14, 2019):

I think line invalidation is an honorable first pass and would be welcome.

@oising commented on GitHub (May 14, 2019): I think line invalidation is an honorable first pass and would be welcome.
Author
Owner

@skyline75489 commented on GitHub (Nov 11, 2019):

I've tried enable differential drawing on db79758092 . To my surprise, it does not help much of the performance as I originally anticipated.

First with #2959 and co the raw rendering performance is faster than before. In a way it is "fast enough" to deliquate the effect of differential drawing. Second, AFAIK most terminal operations requires entire screen redrawing, at which differential drawing makes little difference.

Update: I'm blinded by the PC I've be using myself. People with 4K display or higher would still need this.

@skyline75489 commented on GitHub (Nov 11, 2019): I've tried enable differential drawing on https://github.com/microsoft/terminal/commit/db797580923472c08613f054364097be06d73229 . To my surprise, it does not help much of the performance as I originally anticipated. First with #2959 and co the raw rendering performance is faster than before. In a way it is "fast enough" to deliquate the effect of differential drawing. Second, AFAIK most terminal operations requires entire screen redrawing, at which differential drawing makes little difference. **Update**: I'm blinded by the PC I've be using myself. People with 4K display or higher would still need this.
Author
Owner

@miniksa commented on GitHub (Mar 30, 2020):

A comparison:

Running each of these commands for ~15 seconds under WPR on the same dev box.
Cleaned up as many bg processes as possible, graphs scoped to just the WindowsTerminalDev package.

Master

  • PTY - individual cells
  • Term - full screen blit

DX cells

  • PTY - individual cells
  • Term - individual cells

note: Ligatures and multi-cell glyphs don't work well with this.

DX lines

  • PTY - individual cells
  • Term - individual complete rows

DX lines fixed

  • PTY - individual cells
  • Term - individual complete rows with patched til::bitmap algorithm to used optimized set method on dynamic_bitset<>

cmatrix

master

image

dx cells

image

dx lines

image

dx lines fixed

image

cmatrix -u0

master

image

dx cells

image

dx lines

image

dx lines fixed

image

cacafire

master

image

dx cells

image

dx lines

image

dx lines fixed

image


And for flavor, this is what cacafire graphs look like. It's kinda fun. You can see it ramping up in the amount of work required to draw the growing fire.
image

@miniksa commented on GitHub (Mar 30, 2020): A comparison: Running each of these commands for ~15 seconds under WPR on the same dev box. Cleaned up as many bg processes as possible, graphs scoped to just the `WindowsTerminalDev` package. **Master** - PTY - individual cells - Term - full screen blit **DX cells** - PTY - individual cells - Term - individual cells *note:* Ligatures and multi-cell glyphs don't work well with this. **DX lines** - PTY - individual cells - Term - individual complete rows **DX lines fixed** - PTY - individual cells - Term - individual complete rows with patched `til::bitmap` algorithm to used optimized set method on `dynamic_bitset<>` ## cmatrix ### master ![image](https://user-images.githubusercontent.com/18221333/77964754-790f6600-7294-11ea-9c1d-2e6969179c3c.png) ### dx cells ![image](https://user-images.githubusercontent.com/18221333/77964629-3a79ab80-7294-11ea-8639-4ced716157a7.png) ### dx lines ![image](https://user-images.githubusercontent.com/18221333/77964984-f509ae00-7294-11ea-87c5-0a456e575453.png) ### dx lines fixed ![image](https://user-images.githubusercontent.com/18221333/77967139-5a5f9e00-7299-11ea-9483-b0a46a1e9211.png) ## cmatrix -u0 ### master ![image](https://user-images.githubusercontent.com/18221333/77964838-a65c1400-7294-11ea-80fd-407cc24e9add.png) ### dx cells ![image](https://user-images.githubusercontent.com/18221333/77964723-64cb6900-7294-11ea-8273-c6dcd83711b6.png) ### dx lines ![image](https://user-images.githubusercontent.com/18221333/77964962-ec18dc80-7294-11ea-9c1a-d25aae94ccd5.png) ### dx lines fixed ![image](https://user-images.githubusercontent.com/18221333/77967424-ed003d00-7299-11ea-8b1f-35b31356ab49.png) ## cacafire ### master ![image](https://user-images.githubusercontent.com/18221333/77964858-b247d600-7294-11ea-9968-06fd5bd96e21.png) ### dx cells ![image](https://user-images.githubusercontent.com/18221333/77964710-5d0bc480-7294-11ea-8eb7-ed7c188915ef.png) ### dx lines ![image](https://user-images.githubusercontent.com/18221333/77964938-de635700-7294-11ea-8b1c-6cd792e6c0c2.png) ### dx lines fixed ![image](https://user-images.githubusercontent.com/18221333/77966723-6d25a300-7298-11ea-955a-71a19d1a9389.png) --------------- And for flavor, this is what `cacafire` graphs look like. It's kinda fun. You can see it ramping up in the amount of work required to draw the growing fire. ![image](https://user-images.githubusercontent.com/18221333/77965052-166a9a00-7295-11ea-8dcf-f83af8c13e24.png)
Author
Owner

@miniksa commented on GitHub (Mar 30, 2020):

Figuring out why dx lines cacafire is so much slower than the others
image
The act of setting all the bits in the rows appears to be taking a long time.

Updated trace changing void til::bitmap::set(const til::rectangle) to use dynamic_bitset<>::set(pos, len) to set the whole row at once:
image

Back to almost normal.

@miniksa commented on GitHub (Mar 30, 2020): Figuring out why `dx lines` `cacafire` is so much slower than the others ![image](https://user-images.githubusercontent.com/18221333/77965806-ab21c780-7296-11ea-9a69-76d659640845.png) The act of setting all the bits in the rows appears to be taking a long time. Updated trace changing `void til::bitmap::set(const til::rectangle)` to use `dynamic_bitset<>::set(pos, len)` to set the whole row at once: ![image](https://user-images.githubusercontent.com/18221333/77966723-6d25a300-7298-11ea-955a-71a19d1a9389.png) Back to almost normal.
Author
Owner

@miniksa commented on GitHub (Mar 30, 2020):

dxlines cmatrix: (with fix to setting rectangles)
image

@miniksa commented on GitHub (Mar 30, 2020): `dxlines` `cmatrix`: (with fix to setting rectangles) ![image](https://user-images.githubusercontent.com/18221333/77967139-5a5f9e00-7299-11ea-9483-b0a46a1e9211.png)
Author
Owner

@miniksa commented on GitHub (Mar 30, 2020):

dxlines cmatrix -u0: (with fix to setting rectangles)
image

I think that's justification for using the row/line invalidator for DX. It's better than painting the whole screen and works for ligatures. Not as fast as individual cells, but scoping it down further can be a later problem.

@miniksa commented on GitHub (Mar 30, 2020): `dxlines` `cmatrix -u0`: (with fix to setting rectangles) ![image](https://user-images.githubusercontent.com/18221333/77967424-ed003d00-7299-11ea-8b1f-35b31356ab49.png) I think that's justification for using the row/line invalidator for DX. It's better than painting the whole screen and works for ligatures. Not as fast as individual cells, but scoping it down further can be a later problem.
Author
Owner

@miniksa commented on GitHub (Apr 15, 2020):

I have to back this out for 1.0. I can't land #5345. There are too many loose ends.

@miniksa commented on GitHub (Apr 15, 2020): I have to back this out for 1.0. I can't land #5345. There are too many loose ends.
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 16, 2020):

Closing this one out again pending our decision on differential drawing. We think we can stick the landing for v1.

@DHowett-MSFT commented on GitHub (Apr 16, 2020): Closing this one out again pending our decision on differential drawing. We think we can stick the landing for v1.
Author
Owner

@ghost commented on GitHub (May 5, 2020):

:tada:This issue was addressed in #5185, which has now been successfully released as Windows Terminal Release Candidate v0.11.1251.0 (1.0rc1).🎉

Handy links:

@ghost commented on GitHub (May 5, 2020): :tada:This issue was addressed in #5185, which has now been successfully released as `Windows Terminal Release Candidate v0.11.1251.0 (1.0rc1)`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.11.1251.0 (1.0rc1)) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@BarrettStephen commented on GitHub (May 6, 2020):

using the terminal is so much faster now. its just crazy fast. a git pull used to scroll so slowly and now its just boom done

@BarrettStephen commented on GitHub (May 6, 2020): using the terminal is *so much faster* now. its just crazy fast. a git pull used to scroll so slowly and now its just boom done
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1069