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

Optimize Rendering Push Performance Using MIT-SHM #17118

Open
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

lindexi
Copy link
Contributor

@lindexi lindexi commented Sep 25, 2024

What does the pull request do?

This pull request implements the use of MIT-SHM for pushing rendered images. It replaces the XPutImage method with XShmPutImage. This change significantly reduces Bitmap copying at the X11 layer, enhancing rendering push performance.

What is the current behavior?

Currently, only XPutImage is used for pushing rendered images in soft rendering mode.

What is the updated/expected behavior with this PR?

This pull request provides additional options, allowing developers to configure the use of MIT-SHM shared memory for pushing rendered images. This can effectively improve rendering performance and reduce rendering latency on low-performance devices.

How was the solution implemented (if it's not obvious)?

The solution involves using MIT-SHM to push rendered images, following the method outlined by @kekekeks in #16690 (reply in thread) .

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

src/Avalonia.X11/X11Structs.cs Outdated Show resolved Hide resolved
return;
}

// The reason for using `_x11.Display` instead of `_x11.DeferredDisplay` is that XSHM requires pushing to a Display that can receive Events, in order to obtain the XShmCompletionEvent when rendering is complete.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeferredDisplay should be used for rendering since compositor runs on a separate thread. You can get events from that connection too as previously discussed in #16690 (reply in thread) (see DeferredDisplayEvents class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kekekeks The DeferredDisplay do not call the XSelectInput, and I do not know how to recevice the XShmCompletionEvent from DeferredDisplay. Thank you.


namespace Avalonia.X11.XShmExtensions;

internal static class X11ShmDebugLogger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger.TryGet(LogEventLevel.Information, "X11")?.Log(...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kekekeks Thank you. I intend for the X11ShmDebugLogger to be used by Avalonia framework developers when investigating the XShm module, rather than by application developers using the Avalonia framework. Application developers should not be misled by the debug output from XShm. I'm not sure if this expectation is reasonable.

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@lindexi lindexi marked this pull request as ready for review September 29, 2024 12:08
@avaloniaui-bot
Copy link

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

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