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 IOSurface for texture sharing on macOS #23509
Conversation
highfive
commented
Jun 4, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 4, 2019
|
cc @jdm |
|
Yay! It would be very very nice to have this. I'm happily surprised we can do this without any changes to webrender! My main question is about whether we can do this but keep the existing sync'ing mechanism, so we don't end up with very different stories of how to avoid race conditions on different architectures. |
| WebGLSender<(u32, Size2D<i32>, usize)>, | ||
| WebGLReceiver<(u32, Size2D<i32>, usize)>, | ||
| WebGLSender<(u32, Size2D<i32>, Option<u32>, usize)>, | ||
| WebGLReceiver<(u32, Size2D<i32>, Option<u32>, usize)>, |
This comment has been minimized.
This comment has been minimized.
| @@ -70,18 +72,29 @@ impl WebGLThreads { | |||
| struct WebGLExternalImages { | |||
| webrender_gl: Rc<dyn gl::Gl>, | |||
| webgl_channel: WebGLSender<WebGLMsg>, | |||
| // Mapping between an IOSurface and the texture it is bound on the WR thread | |||
| textures: FnvHashMap<u32, gl::GLuint>, | |||
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jun 4, 2019
Member
Nit: any chance we can name these types? I'm getting lost in all the u32s :)
| let texture_id = match io_surface_id { | ||
| Some(io_surface_id) => { | ||
| let texture_id = match self.textures.entry(io_surface_id) { | ||
| Entry::Occupied(o) => *o.get(), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
zakorgy
Jun 10, 2019
Author
Contributor
As I remember we can't because of the borrow of self here, but I will check it again.
| *v.insert(texture_id) | ||
| }, | ||
| }; | ||
| texture_id |
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jun 4, 2019
Member
There's no locking or sync'ing needed here? How does this avoid race conditions between the WebGL thread and the WebRender thread?
This comment has been minimized.
This comment has been minimized.
zakorgy
Jun 10, 2019
Author
Contributor
So far the triple buffering result worked for me, because the time interval between Lock and Unlock messages was lesser than switching texture targets on the WebGL thread two times. But I can agree adding it would be make the code more safer, I will look into that.
| @@ -277,18 +312,33 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> { | |||
| .gl_factory | |||
| .new_shared_context(version, size, attributes) | |||
| .map(|r| (r, WebGLContextShareMode::SharedTexture)) | |||
| .or_else(|err| { | |||
| #[cfg(target_os = "macos")] | |||
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jun 4, 2019
Member
Should we introduce a new abstraction so we're not special-casing macos? Something where the GL context isn't sharing, but the texture is? Alternatively, should we move this logic into GLFactory?
|
@asajeffrey sorry for the late answer and thank you for the review. For answering your main question, I tried to use the current syncing mechanism, but unfortunately this was the only satisfying solution I could come up, because we can't use OpenGL sync objects between non shared contexts. |
|
Oh that's annoying. We should be using some sync mechanism rather than relying on timing. Perhaps we can use a variant on triple buffering, where we keep 3 buffers: the one that webrender is reading from, the one the webgl is currently writing to, and the one that webgl has finished writing to? Lock would swap 1 and 3, and at the end of an rAF we'd flush and swap 2 and 3? |
|
@asajeffrey your idea works well, I will address the review changes and update the PR. After that I will check if we could abstract away the cfg-s in |
|
Oh, good find on using the correct clear color! |
| @@ -28,3 +28,4 @@ opt-level = 3 | |||
| # Those are here to dedupe winapi since mio is still using winapi 0.2. | |||
| mio = { git = "https://github.com/servo/mio.git", branch = "servo" } | |||
| iovec = { git = "https://github.com/servo/iovec.git", branch = "servo" } | |||
| offscreen_gl_context = { git = "https://github.com/zakorgy/rust-offscreen-rendering-context", branch = "io-surface" } | |||
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jun 11, 2019
Member
We should land this patch to offscreen_gl_context before landing this PR.
|
@bors-servo try=wpt-mac |
Use IOSurface for texture sharing on macOS <!-- Please describe your changes on the following line: --> Use a non-shared GL context for the WebGL threads, with triple buffered IOSurfaces bound to the Framebuffer. Using a simple IOSurface resulted in flickering since both the WR and the WebGL thread uses it, using three gave me the proper result. When we receive a `Lock` message, we send the id of a finished IOSurface to the WR thread where we bind it to a texture, which WR can use. The synchronization of the IOSurfaces is a little hacky, since there are no clue in GL that we started rendering a new frame and we can swap the surfaces: if the document process a `FrameRequestCallback` callback (which comes from `requestAnimationFrame`), we send a message to the WebGL thread to notify about the start of the new frame. This is where we swap the underlying IOsurfaces of the WebGL contexts. I have checked the performance on several WebGL samples and the FPS numbers where promising. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11138 (GitHub issue number if applicable) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23509) <!-- Reviewable:end -->
|
Also the linux and windows builds are failing:
|
|
Lots of test failures - here are the unique ones:
|
|
One difference that occurs when running tests is that we run them under OSMesa. |
|
|
|
|
5a75217
to
dfc18a6
dfc18a6
to
b92d407
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Use surfman for managing GL surfaces <!-- Please describe your changes on the following line: --> Replaces texture sharing with surfman surface sharing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23509 and #24256 - [x] These changes do not require tests because this is backend gfx <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
zakorgy commentedJun 4, 2019
•
edited by SimonSapin
Use a non-shared GL context for the WebGL threads, with triple buffered IOSurfaces bound to the Framebuffer. Using a simple IOSurface resulted in flickering since both the WR and the WebGL thread uses it, using three gave me the proper result.
When we receive a
Lockmessage, we send the id of a finished IOSurface to the WR thread where we bind it to a texture, which WR can use.The synchronization of the IOSurfaces is a little hacky, since there are no clue in GL that we started rendering a new frame and we can swap the surfaces: if the document process a
FrameRequestCallbackcallback (which comes fromrequestAnimationFrame), we send a message to the WebGL thread to notify about the start of the new frame. This is where we swap the underlying IOsurfaces of the WebGL contexts.I have checked the performance on several WebGL samples and the FPS numbers where promising.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is