Skip to content
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

egl/display: Pass *pointer to* output variable when querying DEVICE_EXT #1696

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Sep 5, 2024

Supersedes #1695

By casting a null_mut() ptr and passing it directly by value to QueryDisplayAttribEXT(), the function ignores writing the output as it didn't receive an address (it received NULL) to write the device to. Instead we should take the pointer address of this null_mut() pointer and provide that to the function instead so that it can overwrite it with a pointer to the requested eglDevice.

  • Tested on all platforms changed
    • Tested by adding dbg!(display.device()) to examples/egl_device.rs. This returns BadParameter before this patch, and the device afterwards.
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • (N/A) Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • (N/A) Created or updated an example program if it would help users understand this functionality

@MarijnS95 MarijnS95 mentioned this pull request Sep 5, 2024
@MarijnS95
Copy link
Member Author

All other calls to QueryDisplayAttribEXT() (despite not for ptrs) use MaybeUninit which is an even cleaner way :)

@MarijnS95 MarijnS95 force-pushed the egl-display-ptr branch 3 times, most recently from 83618d7 to 96fc48d Compare September 5, 2024 09:36
@MarijnS95
Copy link
Member Author

@kchibisov I also noticed that DisplayInner::uses_display_reference() doesn't check the returned value of the MaybeUninit query for TRACK_REFERENCES, but only whether eglQueryDisplayAttrib{KHR,EXT} did not error out (and returned TRUE).

I think we need something like https://github.com/MarijnS95/glutin/compare/egl-display-attrib-value but I don't have any driver to test it on.

…EXT`

By casting a `null_mut()` ptr and passing it directly _by value_ to
`QueryDisplayAttribEXT()`, the function ignores writing the output as
it didn't receive an address (it received `NULL`) to write the device
to.  Instead we should take the _pointer address of this `null_mut()`
pointer_ and provide that to the function instead so that it can
_overwrite_ it with a pointer to the requested `eglDevice`.

This is even more clear when allocating a `MaybeUninit` in which the
pointer will be returned, which has a convenient `.as_mut_ptr()` member
to pass its pointer value directly into `QueryDisplayAttribEXT()`.
@kchibisov kchibisov merged commit 8ee2600 into master Sep 5, 2024
43 checks passed
@MarijnS95 MarijnS95 deleted the egl-display-ptr branch September 5, 2024 11:45
@chrisduerr
Copy link
Contributor

Would you mind cutting a new release? Would make my life a little easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants