-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling Hardware Acceleration on RDP #7684
Conversation
I don't think using the registry and requiring the full exe path is a good solution. |
@batzen - Yes, you're correct. While the registry solution may not be suitable for all users, we have discovered that several switches in the unmanaged code rely on this approach. Link
Although using AppContextSwitch might have been a better option, we need to investigate its viability in the unmanaged part of WPF. |
509c977
to
7d5766f
Compare
Hello, JLuc |
@JLucGarnier - We are targeting this for .NET 8. We're only left with the last steps here - To integrate an opt-in switch mechanism. |
92bfe6c
to
d251a99
Compare
c68c959
to
5a9517a
Compare
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
058d38a
to
75d8c7c
Compare
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.
Clearly this needs to go through DRT in RDP.
I guess the biggest question is why is this opt-in rather than opt-out?
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WpfGfx/core/common/renderoptions.cpp
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WpfGfx/core/common/renderoptions.h
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WpfGfx/core/hw/hwbitmapcolorsource.cpp
Outdated
Show resolved
Hide resolved
The idea that no display = no hw acceleration is also questionable to me. |
The other flag that triggers A relevant documentation (reason for |
@miloush - Our rationale for making this change opt-in vs opt-out is the lack of appropriate test coverage in this area. There could be use-cases where such feature may start breaking applications post upgrade. Hence we are inclined to keep this opt-in for now and work on improving the tests around this area first. Once we have that we can decide to turn it on by default for all users (in future .NET releases). |
src/Microsoft.DotNet.Wpf/src/WpfGfx/core/common/renderoptions.cpp
Outdated
Show resolved
Hide resolved
@pchaurasia14 While I understand the concern, I do not find an opt-in justified or beneficial enough in this case. You also cannot be adding compatibility flags for every change, it adds maintainability costs to the future. The DirectX documentation states that creating the surface under RDP is now always supported. You have as much testing as you have for any other feature by running the DTS in a remote desktop session. There already exist several opt out of hardware acceleration options for users:
Hardware acceleration should be the normal state of things, and what we hope to have going forward. You are looking for more testing, but I am worried you will not get enough coverage by real-world applications if this is an opt in. As indicated in the original issue, this change has been analysed several times in the past by @vatsan-madhavan and you are not going to get anything better than that. He also suggested running regression tests in RDP for verification and no reason for a flag in .NET (though he supported one for .NET Framework). If you are not comfortable making this change without a flag, it sounds to me like an opt out rather than opt in would be a good compromise and with alignment of the other options to opt out of hw rendering. In general, how do you decide whether to go for opt in or opt out, are there any criteria? |
@miloush - Fair points. Currently, our criteria is the higher number of unknowns in the code paths and the approaching timeline for .NET8 release. The change in the current PR is at a fairly low level which creates higher risk of applications failing to start if we have missed something. All the changes in the current PR were made on the issues we encountered in sample application (that uses multiple animations). With the limited coverage, we don't know if the code paths in question are being executed for any other use cases. Also, as we have more (and better) tests around this, we will revisit this and turn on the flag for next releases (.NET9). We'll create a tracker issue for this. Having an opt-in gives us the room for experiment without causing disruption to people who would be migrating to newer .NET version. |
Given that .NET is a side by side update (and not in-place) it makes sense that quirks like these, if they must exist, are either opt-outs or have a well understood compat-breaking scenario that's being guarded against. Opt-ins are more naturally suited for .NET Framework, where fixes are in-place updates. That said, if .NET 8 must get this change with an opt-in, I'd recommend making it the default in .NET 9 code base immediately (with optionally leaving the quirk in as an opt-out). Improvements like these should become default for wider adoption, and the earlier they're made default in .NET 9 the better it is for gaining confidence through community feedback etc. |
On the topic of opt-in vs. opt-out, in WinForms we lean towards opt-out much as described by @vatsan-madhavan .NET Framework deals with this by typically flipping |
Please take a look at this to see how AppContext flags are plumbed down into WpfGfx. You'll have to further search the codebase for where wpf/src/Microsoft.DotNet.Wpf/src/WpfGfx/include/exports.cs Lines 2536 to 2553 in f1987cd
Given that This information should be plumbed down at the very start of WpfGfx thread, and known early. I don't understand whether you evaluated this existing mechanism and decided to do something else out of (unspecified) necessity, or whether you were unaware of this mechanism existing in WpfGfx. If the latter, please rework the changes (and if former, it would help reviewers to understand rationale). |
See my previous comment about how AppContext switch plumbing works all the way into WpfGfx. |
In this context,
In either case, the idea is that the quirks should be structured like this:
|
Certainly! To provide more detail, I noticed that the flag I am sending is similar in nature to the flag used for forced software rendering in wpfgfx. Therefore, I decided to replicate the mechanism already in place for passing down that flag to wpfgfx, and use it for my new flag as well, just like the existing flag. |
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaSystem.cs
Outdated
Show resolved
Hide resolved
@vatsan-madhavan I tested the codepath you recommended to determine if it is appropriate for my use case. I discovered that the flag you suggested as a reference is being set every time a Hwnd is created, but my flag should only be set once throughout the entire lifecycle of the application. I looked into various code paths to find a suitable location to introduce the logic for passing down the flag to wpfgfx, but I couldn't find a better place than the current code changes where the flag is being communicated to wpfgfx. According to our requirements, we need to pass down the flag to wpfgfx early on and only once. After my investigation, I believe that the current code changes are the most resilient to any potential regression that may occur if I were to modify the existing code flow. However, I was unable to find any code flow that meets our requirements. |
Fixes #3215
Description
Enabling Hardware Acceleration on RDP for exes which can opt-in.
Customer Impact
Without this fix, customers won't be able to get the benefits of Hardware Acceleration on RDP.
Regression
No
Testing
In progress
Risk
Risk is Low as the applications which want to have hardware acceleration on RDP need to Opt-in by setting AppContext Switch (
Switch.System.Windows.Media.EnableHardwareAccelerationForRdp
) to true.Microsoft Reviewers: Open in CodeFlow