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

X11 can use XShm for faster rendering #4

Closed
lunixbochs opened this issue Apr 24, 2022 · 4 comments
Closed

X11 can use XShm for faster rendering #4

lunixbochs opened this issue Apr 24, 2022 · 4 comments

Comments

@lunixbochs
Copy link
Contributor

Here's an example usage of XShm (originally from Fabrice Bellard's TinyGL): https://github.com/lunixbochs/tinygles/blob/unstable/src/gles/glx.c#L107

Basically, this allows you to blit pixels directly into X11's memory, saving both a memory copy and the general overhead of passing your image through an X11 socket.

In the non-shm case, you also shouldn't need to create a new XImage every frame as you're doing now. You only really need to do it on startup and when the window is resized. You can just call XPutImage on an existing XImage repeatedly, as done here: https://github.com/lunixbochs/tinygles/blob/unstable/src/gles/glx.c#L368

@john01dav
Copy link
Collaborator

Is this motivated by any particular performance or issue in practice? The current code is quite simple and it works very well on the computers that I tested on. As such, I'm hesitant for any change such as this to be introduced if it does not somehow make the library materially better, as complexity trade-offs (and just development time) are here.

@lunixbochs
Copy link
Contributor Author

This isn't urgent, mostly informational based on past experience. If someone tries software rendering with this on a weaker system, the memory bandwidth requirements for framebuffer copies can end up being the largest overhead.

(I may end up using this crate for my app as part of a software rendering fallback for users without working GPU drivers, and in which case I may offer to implement + support this feature myself)

@john01dav
Copy link
Collaborator

FWIW I tried it on a weak, although not embedded weak, laptop (2010 Intel Thinkpad) and it was totally fine. Do you have weaker systems in mind? I'm not really sure how popular X is in the embedded world. If you submit a PR that makes it usefully faster in any specific use case, though, I'll merge it (assuming good code quality, etc.).

john01dav pushed a commit that referenced this issue Dec 22, 2022
@john01dav
Copy link
Collaborator

Closing as duplicate of #38 in relation to the merge of swbuf and softbuffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants