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

Improve external texture image API #8395

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Conversation

pixelflinger
Copy link
Collaborator

The current API used a void* in Texture::setExternalImage to pass the platform specific image. This was a problem because on some platform like Android, there could be several types (EGLImageKHR and AHardwareBuffer), and with the void* there was no way to distinguish them on the backend / platform side.

We now have a new Texture API which takes a
Platform::ExternalImageHandle, which is a reference-counted handle to a Platform::ExternalImage. Platform::ExternalImage is an opaque type only known by the platform.

This type must be created using a concrete Platform specific API, such as:

PlatformEGL::createExternalImage
PlatformEGLAndroid::createExternalImage
PlatformCocoaGL::createExternalImage
PlatformCocoaTouchGL::createExternalImage

New types can easily be added in the future.

There is no "destroy" call because the Platform::ExternalImageHandle is reference-counted and the client can let go of it as soon as it doesn't need it any longer (typically after calling Texture::setExternalImage). Platform::ExternalImage is a small structure that just anonymously wraps the concrete types.

New internal driver APIs have been added to handle this functionality.

@pixelflinger pixelflinger requested a review from bejado January 28, 2025 08:43
@pixelflinger pixelflinger force-pushed the ma/platform-external-image branch from 4759d8c to 87c0f52 Compare January 31, 2025 17:53
@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label Jan 31, 2025
* @see PlatformCocoaGL::createExternalImage
* @see PlatformCocoaTouchGL::createExternalImage
*/
void setExternalImage(Engine& engine, ExternalImageHandleRef image) noexcept;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea that clients call the platform-specific createExternalImage and then pass that ref here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@pixelflinger pixelflinger force-pushed the ma/platform-external-image branch from 87c0f52 to 5be382a Compare February 2, 2025 06:34
The current API used a void* in Texture::setExternalImage to pass
the platform specific image. This was a problem because on some
platform like Android, there could be several types (EGLImageKHR and
AHardwareBuffer), and with the void* there was no way to distinguish
them on the backend / platform side.

We now have a new Texture API which takes a
Platform::ExternalImageHandle, which is a reference-counted handle
to a Platform::ExternalImage. Platform::ExternalImage is an opaque
type only known by the platform.

This type must be created using a concrete Platform specific API, such
as:

PlatformEGL::createExternalImage
PlatformEGLAndroid::createExternalImage
PlatformCocoaGL::createExternalImage
PlatformCocoaTouchGL::createExternalImage

New types can easily be added in the future.

There is no "destroy" call because the Platform::ExternalImageHandle is
reference-counted and the client can let go of it as soon as it
doesn't need it any longer (typically after calling
Texture::setExternalImage). Platform::ExternalImage is a small
structure that just anonymously wraps the concrete types.

New internal driver APIs have been added to handle this functionality.
@pixelflinger pixelflinger force-pushed the ma/platform-external-image branch from efa48b4 to d2d2ab3 Compare February 3, 2025 22:43
@pixelflinger pixelflinger merged commit ad4f349 into main Feb 4, 2025
13 checks passed
@pixelflinger pixelflinger deleted the ma/platform-external-image branch February 4, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants