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

Frame synchronization in Metal #2143

Closed
kvark opened this issue Jun 12, 2018 · 3 comments
Closed

Frame synchronization in Metal #2143

kvark opened this issue Jun 12, 2018 · 3 comments

Comments

@kvark
Copy link
Member

kvark commented Jun 12, 2018

After #2138 got in, we got a problem with exclusive full-screen mode of Dota, where a semaphore is provided for the frame, and there is nothing instantly available. So nextDrawable == nil, and we don't get a CADrawable, and we don't get the associated MTLTexture... which is needed for immediate command buffer recording.

One possible solution would be to switch to deferred recording once we encounter a texture that will be available later (from an acquired frame). We'd only be able to record the rest when we get that texture.

@kvark
Copy link
Member Author

kvark commented Jun 13, 2018

This is a real blocker/PITA. MoltenVK isn't affected that much because they defer the actual command recording to the submission time, where they are safe to wait for semaphores first, and thus they have all the required textures to work with.

As for my proposed workaround, we don't know out of hand where exactly such a texture would be needed. Say, we are in the middle of a render pass, and receive a bind_graphics_descriptor_sets call that has a reference to a frame. If we switch to deferred recording, we'd have to keep a hold on that WIP render pass in the mean time. So it still seems possible, but not super convenient or easy.

@msiglreith
Copy link
Contributor

For clarification:
acquire_image -> record commands -> record command with image with current acquired image -> submit cmd buffer (including wait on acquire)
The issue here is that the image is not ready but it's needs to be for recording already?

@kvark
Copy link
Member Author

kvark commented Jun 13, 2018

@msiglreith correct, yes. When recording a command buffer immediately (i.e. one-time submit ones), we need MTLTexture, but we can only get it from CADrawable, which we can only get after the frame-sync wait.

bors bot added a commit that referenced this issue Jun 23, 2018
2169: Persistent Metal swapchain r=grovesNL a=kvark

Includes #2164
Fixes #2168
Fixes #2143
Removes deferred image resolution (yay!), and also renames some of the outdated concepts.
We have no flickering, and proper frame sync now.

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends:


Co-authored-by: Dzmitry Malyshau <[email protected]>
@bors bors bot closed this as completed in #2169 Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants