Skip to content
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

Win32+Angle: reuse the first created D3D11 display #12574

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Aug 17, 2023

What does the pull request do?

On Windows, when Angle + DirectX 11 are used (these are the defaults), a call to D3D11CreateDevice is made to ensure that D3D11 works correctly. However, this call is very slow: on my system, it's ≈65ms spent in native code (DirectX lib + Nvidia drivers).

When the renderer starts, it makes the same call again. It's a bit faster, but not by much (≈50ms).
This PR reuses the first created display if possible, improving startup time in all scenarios, NativeAOT included.

Remarks

AngleWin32PlatformGraphics has been split into two classes: D3D9 (shared) and D3D11 (non shared) since they use two distinct paths, making clearer which members are used.

IPlatformGraphicsOpenGlContextFactory isn't implemented anymore for D3D9: its CreateContext implementation was always throwing anyways. The only usage is in OpenGlControlBase, which will fail a line earlier in this case:

var contextFactory = AvaloniaLocator.Current.GetRequiredService<IPlatformGraphicsOpenGlContextFactory>();
ctx = contextFactory.CreateContext(null);

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0038512-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul force-pushed the perf/win32-angle-creation branch from 6cae8c5 to aee4078 Compare September 2, 2023 13:08
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0039133-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Sep 3, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 3, 2023
@MrJul MrJul added this pull request to the merge queue Sep 3, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 3, 2023
@kekekeks kekekeks added this pull request to the merge queue Sep 3, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 3, 2023
@maxkatz6 maxkatz6 added this pull request to the merge queue Sep 4, 2023
Merged via the queue into AvaloniaUI:master with commit 52a3bee Sep 4, 2023
@MrJul MrJul deleted the perf/win32-angle-creation branch September 4, 2023 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants