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

WIP: macos: Copy to IOSurface on present #96

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Apr 11, 2023

Alternative to #95, that avoids API changes.

In a release build on an M1 mac, fullscreened at 1440p, this brings the animation examples redraw time from about 10ms to 900μs. But the winit example ends up increasing to 20ms from around 18ms. This does include resizing time, but seems to still take at least a ms more even excluding that?

#95 does improve the winit example here to 12ms, but gets 1.25ms for animation (that's probably since it currently allocates an IOBuffer every single present, so it could be fixed by doing that correctly).

Interesting how this version compares. There is also likely some overhead to the previous version this test isn't catching (When does it actually copy from the CGDataProvider to GPU? Is that later in our main loop, or does the display server handle that?).

It looks like `BytesPerRow` (the stride) has some kind of alignment requirement (testing on M1), that doesn't let us just use the width. So for this to work, softbuffer needs to expose the stride, and the user needs to deal with that...

This doesn't seem to be showing the right thing even when width matches stride. Not sure why.
Division is more expensive than multiplication, and this doesn't seem to
be optimize away, so iterating over `(0..height)` and `(0..width)`
provides better performance.

It's good to have the example show the best way to write code using
softbuffer, and this helps when using examples as a benchmark. This will
also be needed if Softbuffer supports formats where `stride` isn't just
`width * pixel_size`, and needs alignment.
@ids1024
Copy link
Member Author

ids1024 commented Apr 11, 2023

Interesting, the main time overhead on the animation example with master that is fixed is in transaction::commit. Not sure what that is doing. It's not taking any significant amount of time with the winit example, so it presumably has something to do with drawing unthrottled when a redraw wasn't requested by the display server...

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

Successfully merging this pull request may close these issues.

None yet

1 participant