Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse EGL Sync Objects to ensure that shared WebGL textures are ready to be used #1407
Conversation
| if self.dirty_webgl_contexts.contains(&id) { | ||
| webgl_context.make_current(); | ||
| // Call FenceSync and ClientWaitSync to ensure that textures are ready. | ||
| let sync = webgl_context.gl().fence_sync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Jun 20, 2017
Author
Contributor
Do you mean that they should be called using WebGLCommand enum? (as it was done with the existing glFlush call)
This comment has been minimized.
This comment has been minimized.
| // Sync objects are the recommended way to ensure that textures are ready in OpenGL 3.0+. | ||
| // They are more performant than glFinish and guarantee the completion of the GL commands. | ||
| for (id, webgl_context) in &self.webgl_contexts { | ||
| if self.dirty_webgl_contexts.contains(&id) { |
This comment has been minimized.
This comment has been minimized.
|
glClientWaitSync is only available on desktop GL 3.2+, I believe. Although we currently do require 3.2, we're meant to be dropping required desktop GL to 3.1... |
Yes, glClientWaitSync is available in GL 3.2+ and GL ES 3.0+. We could check if GL_ARB_sync extension is available in GL 3.1 and fallback to glFlush/glFinish if not. Do you want to do that in this PR or create an issue or handle this in the future WebGL separate crate? |
|
That's fine to do it as a follow up, so long as we have a valid fallback plan (which it sounds like we do). Thanks! |
|
|
|
@MortimerGoro This needs a rebase. |
|
Done! |
|
One question, otherwise looks good. |
| // Call FenceSync and ClientWaitSync to ensure that textures are ready. | ||
| let sync = gl.fence_sync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0); | ||
| // SYNC_FLUSH_COMMANDS_BIT is used to automatically generate a glFlush before blocking on the sync object. | ||
| gl.client_wait_sync(sync, gl::SYNC_FLUSH_COMMANDS_BIT, gl::TIMEOUT_IGNORED); |
This comment has been minimized.
This comment has been minimized.
glennw
Jul 5, 2017
Member
Why does this need to be a glClientWaitSync ? Wouldn't a glWaitSync be more appropriate in this case, so that the CPU isn't blocked? I would have though a glWaitSync would be enough to sync between the two command streams?
This comment has been minimized.
This comment has been minimized.
…o be used
|
Looks good, thanks! @bors-servo r+ |
|
|
Use EGL Sync Objects to ensure that shared WebGL textures are ready to be used Currently a glFlush call is issued at the start of the frame to guarantee that shared WebGL texture data is valid. But glFlush is not enough in some GPUs because it doesn't guarantee the completion of the GL commands when the shared texture is sampled. This leads to some graphic glitches on some demos or even nothing being rendered at all (GPU Mali-T880). glFinish guarantees the completion of the commands but it may hurt performance a lot. Sync objects are the recommended way to ensure that textures are ready in OpenGL 3.0+. They are more performant than glFinish and guarantee the completion of the GL commands. I added dirty checking so the sync is only performed when WebGL contexts are being used. This PR might be improved if we move the glClientWaitSync to the WR render thread (before the shared texture is used). The parallelism should be better that way. I don know where is the best place to add the sync wait in WR. If you can guide me on that I'll update the PR. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1407) <!-- Reviewable:end -->
|
|
This change caused many WebGL tests to fail in Servo, which is blocking the WebRender update. Partially revert the change in order to reland it later with the issue properly fixed.
|
This change is causing many Servo WebGL tests to fail, so I posted a PR to partially revert this (temporarily) in order to move the WebRender update forward. Sorry! |
|
Ok, no problem. I'm working on #1353 so the WebGL code will be refactored to a new component. I'll check all the WebGL tests after the refactor. |
Partially revert #1407 This change caused many WebGL tests to fail in Servo, which is blocking the WebRender update. Partially revert the change in order to reland it later with the issue properly fixed. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1471) <!-- Reviewable:end -->
MortimerGoro commentedJun 20, 2017
•
edited
Currently a glFlush call is issued at the start of the frame to guarantee that shared WebGL texture data is valid. But glFlush is not enough in some GPUs because it doesn't guarantee the completion of the GL commands when the shared texture is sampled. This leads to some graphic glitches on some demos or even nothing being rendered at all (GPU Mali-T880). glFinish guarantees the completion of the commands but it may hurt performance a lot.
Sync objects are the recommended way to ensure that textures are ready in OpenGL 3.0+. They are more performant than glFinish and guarantee the completion of the GL commands.
I added dirty checking so the sync is only performed when WebGL contexts are being used. This PR might be improved if we move the glClientWaitSync to the WR render thread (before the shared texture is used). The parallelism should be better that way. I don know where is the best place to add the sync wait in WR. If you can guide me on that I'll update the PR.
This change is