-
Notifications
You must be signed in to change notification settings - Fork 171
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
gles: Sync texture uploads for shared contexts #1616
base: master
Are you sure you want to change the base?
Conversation
4bec64a
to
c79e229
Compare
Hm, a Might be best just to disable shared contexts on GL ES 2.0 then, though that would be handled by the compositor and not Smithay (should it be documented somewhere?). |
Yeah, that is what I was thinking for cosmic-comp. Disable sharing, if only 2.0 is available. I struggled with finding a place to document this. It really belongs to the |
Sounds good.
Actually there are; if you add a doc comment to the Though it's not emphasized much in the generated documentation, so it's rather easy to miss any information there. |
c79e229
to
834888a
Compare
@ids1024 Should both be addressed. |
This generally looks right. When a surface rendered on multiple outputs, do multiple threads end up calling |
Only if they race the import. The last imported commit is only updated after the import has taken place. I guess we could change that now that we are synchronizing, but I am not sure this is correct for other renderers, which might then access the old or partially updated texture during the second import. If we wanted to address that, we probably need to document the expected synchronization/multi-threading properties and then carefully check every renderer.
Yes, to fix that we would need to pass in some serial of the import, so we would know, if the
Rendering the texture also briefly locks the upload sync-point, so as long as an import is still in progress we will block there. The only issue here is, when we are already drawing, thus the sync-lock is released and then the |
I guess this shouldn't race at the moment (at least as this is usually used), since Though |
True.
No, since the texture storage is specific to the renderer. |
Oh right, So yeah, as far as I can tell this should synchronize things correctly with the way compositors normally use these APIs, though a compositor doing something more unusual may still be able to do something that doesn't synchronize properly. So this seems like a good improvement, though it could be worth thinking about how to better design some of these APIs in the future. |
834888a
to
7862bd6
Compare
Attempt to solve #1615.
This solution isn't perfect, most notably it doesn't synchronize across the access of
Bind<GlesTexture>
. To do that we would need to be able to store the lock, which means moving theGlesTarget
into theGlesFrame
and makingBind
return aFrame
. I think we talked about this, so we should fix this at some point, but I didn't want to do that refactor now.Fixing
Bind
would automatically solve this for exporting and other things as well, as all of these rely to binding a framebuffer container object to our texture.(Also binding a texture to write to it and sampling from it in a separate thread is probably a operation not as common.)
Additionally we keep a lock to the surface-data, so threads should not be able to race imports to the same texture any more.
In an attempt to not punish GL ES 2.0 contexts too much (which don't support fencing at all), we do try to track whether a context is shared or not in the first place, before we fall back to
glFinish
. This means writes to a texture while a shared context is constructed could potentially be still racy, but I doubt this is a real problem.