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 upFix eglGetProcAddress for core OpenGL entrypoints #94
Conversation
| @@ -38,5 +40,8 @@ gdi32-sys = "0.2" | |||
| user32-sys = "0.2" | |||
| kernel32-sys = "0.2" | |||
|
|
|||
| [target.'cfg(any(target_os="macos", target_os="windows"))'.dependencies] | |||
| [target.'cfg(any(target_os="macos", target_os="windows", target_os="android"))'.dependencies] | |||
| lazy_static = "0.2" | |||
This comment has been minimized.
This comment has been minimized.
| lazy_static! { | ||
| static ref GL_LIB: Option<lib::Library> = { | ||
| if cfg!(target_os = "android") { | ||
| lib::Library::new("libGLESv2.so").ok() |
This comment has been minimized.
This comment has been minimized.
kvark
Mar 30, 2017
Member
This doesn't support run-time selection of the GL backend. E.g. one may want to run with GLES on Linux desktop.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Mar 30, 2017
Author
Collaborator
That would require a change in the API because get_proc_address trait is static and we can't know the user preference. We could work on that on a separate issue/PR, it's less critical in this moment.
This comment has been minimized.
This comment has been minimized.
emilio
Mar 31, 2017
Member
Perhaps we should be using or_else and not platform-cfgs?
Library::new("libGLESv2.so").or_else(|| lib::Library::new("libGL.so"))?
| let addr = CString::new(addr.as_bytes()).unwrap().as_ptr(); | ||
| egl::GetProcAddress(addr as *const _) as *const () | ||
| if let Some(ref lib) = *GL_LIB { | ||
| let symbol: lib::Symbol<unsafe extern fn()> = lib.get(addr.as_bytes()).unwrap(); |
This comment has been minimized.
This comment has been minimized.
| egl::GetProcAddress(addr as *const _) as *const () | ||
| if let Some(ref lib) = *GL_LIB { | ||
| let symbol: lib::Symbol<unsafe extern fn()> = lib.get(addr.as_bytes()).unwrap(); | ||
| return *symbol.deref() as *const(); |
This comment has been minimized.
This comment has been minimized.
| lazy_static! { | ||
| static ref GL_LIB: Option<lib::Library> = { | ||
| if cfg!(target_os = "android") { | ||
| lib::Library::new("libGLESv2.so").ok() |
This comment has been minimized.
This comment has been minimized.
emilio
Mar 31, 2017
Member
Perhaps we should be using or_else and not platform-cfgs?
Library::new("libGLESv2.so").or_else(|| lib::Library::new("libGL.so"))?
eb403c5
to
06e074e
|
Curiosity: using or_else or other closuse patterns within the lazy_static macro causes some obscure errors: possibly related issue here rust-lang/rust#24680 |
| } else { | ||
| lib::Library::new("libGL.so").ok() | ||
| } | ||
| let names = ["libGLESv2.so", "libGLES.so", "libGLESv3.so"]; |
This comment has been minimized.
This comment has been minimized.
| let names = ["libGLESv2.so", "libGLES.so", "libGLESv3.so"]; | ||
| for name in &names { | ||
| let lib = lib::Library::new(name); | ||
| if lib.is_ok() { |
This comment has been minimized.
This comment has been minimized.
emilio
Mar 31, 2017
Member
if let Ok(lib) = lib::Library::new(name) {
return Some(lib);
}
May be slightly clearer, your call.
|
@emilio I added libGL.so for desktop GL on linux. Ideally we should have a way to choose the desired library version instead of the predefined order. |
|
LGTM, thanks :) |
Fix Android issues: update servo-glutin & offscreen_gl_context <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/16237) <!-- Reviewable:end -->
Fix Android issues: update servo-glutin & offscreen_gl_context <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/16237) <!-- Reviewable:end -->
Fix Android issues: update servo-glutin & offscreen_gl_context <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/16237) <!-- Reviewable:end -->
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 76e38ca77cc9227bfaa6f30cc6445cdfcbacf29c
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6 UltraBlame original commit: 7f9f301f0bb21e330116c34f393514bcf20bc451
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6 UltraBlame original commit: 7f9f301f0bb21e330116c34f393514bcf20bc451
…reen_gl_context (from MortimerGoro:update_glutin_offscreen); r=jdm <!-- Please describe your changes on the following line: --> See servo/surfman#94 and servo/glutin#121 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: f659d43bd403e4ac1305990ba704f23b4a6cd5e6 UltraBlame original commit: 7f9f301f0bb21e330116c34f393514bcf20bc451
MortimerGoro commentedMar 30, 2017
•
edited
Hi,
The upgrade to the new gleam has broken offscreen EGL based contexts & Android WebGL on Servo. This is because eglProcAddress can't be used to resolve core OpenGL function entry points on many implementations. Loading core functions with eglProcAddress is only possible in EGL 1.5.