-
Notifications
You must be signed in to change notification settings - Fork 83
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
Fix 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, so we can have a dependency mentioned twice?
lazy_static! { | ||
static ref GL_LIB: Option<lib::Library> = { | ||
if cfg!(target_os = "android") { | ||
lib::Library::new("libGLESv2.so").ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't support run-time selection of the GL backend. E.g. one may want to run with GLES on Linux desktop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps returning ptr::null
instead of unwrapping?
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after const
lazy_static! { | ||
static ref GL_LIB: Option<lib::Library> = { | ||
if cfg!(target_os = "android") { | ||
lib::Library::new("libGLESv2.so").ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Compare
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"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need libGL
?
let names = ["libGLESv2.so", "libGLES.so", "libGLESv3.so"]; | ||
for name in &names { | ||
let lib = lib::Library::new(name); | ||
if lib.is_ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.