-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Improved: D3D11 Adapter Creation Speed by Manually Selecting Hardware Type #16035
Conversation
You can test this PR using the following package version. |
I suspect that it will break virtual machines with Microsoft Basic Render Device |
src/Windows/Avalonia.Win32/OpenGl/Angle/AngleWin32EglDisplay.cs
Outdated
Show resolved
Hide resolved
You can test this PR using the following package version. |
It was my first time trying QEMU+KVM for Windows, but I've tried both the RedHat driver and the Basic Microsoft Driver with no issues. |
You can test this PR using the following package version. |
@Sewer56 looks like this PR break Angle/DX on my machine:
There are couple of problems:
|
I think the core issue lies here. Technically speaking, you're supposed to check the The existing Avalonia code before this PR however did not do this. It checked the In order to keep the amount of changes from I did actually originally change the signature to fix this up (you can see it in earlier commits), but cleaned up to reduce the diff size from main. Edit: I didn't know @maxkatz6 Should I throw a patch for this? With regards of what needs to be done, I think you're right on the money. Remove The patch for this should be trivial, but you're the one who will have to test either way since the hardware's on your end. I wouldn't mind throwing the PR in for this though. |
Ah, I was about to throw a PR against main to fix either way. In any case, what would be the preferred course of action here? Should I re-submit? |
Yes, a new PR with updated version of the change. |
What does the pull request do?
This pull request speeds up the creation of the D3D11 device during startup by manually selecting the hardware type.
This results in a significant improvement in startup time when using Win D3D11 on NAOT.
What is the current behavior?
Currently, the
CreateD3D11Display
method inAngleWin32EglDisplay.cs
usesD3D_DRIVER_TYPE_UNKNOWN
when creating the D3D11 device.This can lead to slower startup times as the runtime needs to determine the appropriate driver type based on the available adapters.
What is the updated/expected behavior with this PR?
With this PR, the startup time of Avalonia applications using Direct3D 11 is improved by approximately 40-50ms on most machines. On my desktop this results in a reduction of 75ms -> 25ms to initialize Avalonia under AOT.
(Measured from
AppBuilder.Configure
to runningInitialize
inApp.axaml.cs
)The
CreateD3D11Display
method now explicitly selects the appropriate driver type (D3D_DRIVER_TYPE_HARDWARE
orD3D_DRIVER_TYPE_WARP
) based on the characteristics of the chosen adapter. (With a fallback to legacyD3D_DRIVER_TYPE_SOFTWARE
)This eliminates the overhead of the runtime determining the driver type and makes the creation of the D3D11 device essentially free. Since we're already querying the available display adapters, it would be a waste to not use that information.
How was the solution implemented?
And also
ThrowFormattedException
helper methods to allow callers to be inlined.