-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Legendary 4638 shared texture perf improvement
This fixes remaining performance and frame pacing issues when using CEF 95 with texture sharing on Windows. I hacked Chromium internally to treat shared textures similarly to how the 3770 method worked. Let me document my little adventure. First, we were getting system freezes, and from analysis of the bluescreen dumps, they were always during synchronization, so I had a hunch: "are keyed mutexes doing this?" The system freeze issue left me hopeless. I already had a disdain for the stupid keyed mutexes, and due to my immense hatred of them, I was angry and I just wanted to try removing them, because 1.) What if they were the cause? (They were), and 2.) I hated them anyway. It was an irrational vendetta, and I was on a war path to remove them just in the *slightest* chance that those god forsaken keyed mutexes were the cause. So I got angry and decided to remove them from almost everything in Chromium just to see if it would fix the system freeze issue. I removed their usage from almost everything in Chromium related to GLImageDXGI. Let me go on a rant about keyed mutexes. I hate keyed mutexes. I *want* synchronization between devices, but what I *don't* want is to be forced to swap stupid "keys" between the two devices; especially if you're in a situation where you cannot pass the next key value to the next device so the next device knows what key to use, because then, the original device can no longer lock the object anymore, and the object is completely forfeit. Then you get suck in a situation where you're forced to wait infinitely if you have no way of telling the other device to use the correct key. I wish I could suggest a better design, but all I know is that I hate it, it's an insufferable design as it is right now, and I don't think there's a single human being on the planet who will ever convince me otherwise. Absolutely insufferable design. I've always hated them and always will. Anyway, sorry about that. Like I was saying, I removed keyed mutex usage from texture sharing inside chromium. But the problem is that with the 4638 version of shared textures, it was about 5 textures which were used round-robin. Because we were forced to remove keyed mutexes (which were crashing the entire system), we could no longer synchronize between client and Chromium, thus frame pacing issues were introduced. Even flushing wasn't helping. They weren't noticeable, and we were *almost* just going to use it as it, but I decided I wasn't finished with my war path. I had fixed the system freeze issue by removing keyed mutexes, but now there was this frame pacing issue. So, I was upset, and I tried many different techniques to try to synchronize. Flushing, more textures, less textures, trying to adjust timing; I thought it was hopeless, until I started looking at the 3770 version and started looking around 4638 code for ways I could do the same thing. I had already removed keyed mutex objects from GLImageDXGI objects, but then I realized: what if I just add the same staging/CopyResource method 3770 did, and then just use one shared texture? 3770 worked amazingly well, so why not try it? Through much toil and experimentation, I got it working. However, there was still one annoying caveat. Because of the fact that Chromium now only deals with NT-style HANDLE objects for shared textures, it would duplicate handles every time it was passed. There was no way of detecting whether we were already using the same shared texture (and CompareObjectHandles in KernelBase didn't work), so we had to recreate the stupid texture object every time. So I introduced a new OnAcceleratedPaint2 function specifically to specify whether the texture has been changed -- that way we don't need to have to continually keep recreating the god-forsaken texture object. All these things combined has won us a huge victory, not only did we solve the system freeze issue, but we also reduced the amount of resources being used from the original version by removing the round robin, eliminated frame pacing issues, and improved the perf back to 3770 levels. In fact, I'm pretty sure that perf levels are even better than they were even with the keyed mutex version (if they weren't causing stupid system freezes), because the keyed mutex version forced INFINITE lock durations due to the inability to relay keys. After 27.2 had this issue, I had to delay the release, and I spent a week toiling over this. To get the system freeze issue fixed, and then to get perf levels back to 3770 levels. And I did it by sifting through millions of lines of Chromium code. Needless to say I feel really damn good right now. This was a legendary fix. I'm sorry, I need a little bit of ego just for once. I feel like I've earned it.
- Loading branch information
Showing
13 changed files
with
203 additions
and
53 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
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
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
Oops, something went wrong.
36fdac1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! I'm not really sure what you did here, but your commit message deserves respect already ;-)
It would be nice if github allowed to star commits. Yes. you should feel really damn good!
(found it through good-github)
36fdac1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maaan, you are a legend!
Having spent some time myself on Chromium, and countless hours building and rebuilding different branches, what you've done is AMAZING!
Congrats!