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

Support protocol.MTLDevice.methods."newTextureWithDescriptor:iosurface:plane:" #643

Open
sotaroikeda opened this issue Aug 1, 2024 · 1 comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request

Comments

@sotaroikeda
Copy link

The newTextureWithDescriptor:iosurface:plane: is not supported. It is necessary for
gfx-rs/wgpu#5641 to be used by gecko see Bug 1910043.

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Aug 11, 2024
@madsmtm
Copy link
Owner

madsmtm commented Aug 11, 2024

Indeed, it is intentionally skipped because we don't expose IOSurfaceRef in any shape or form.

The proper solution needs support for CoreFoundation, for now you can do something like:

#[repr(transparent)]
struct IOSurfaceRefWrapper(io_surface::IOSurfaceRef);

// SAFETY: `IOSurfaceRefWrapper` is `#[repr(transparent)]` over
// `IOSurfaceRef`, which is a typedef to `struct __IOSurface *`.
unsafe impl Encode for IOSurfaceRefWrapper {
    const ENCODING: Encoding = Encoding::Pointer(&Encoding::Struct("__IOSurface", &[]));
}

pub fn new_with_descriptor_surface_plane(
    device: &ProtocolObject<dyn MTLDevice>,
    descriptor: &MTLTextureDescriptor,
    surface: io_surface::IOSurfaceRef,
    plane: NSUInteger,
) -> Retained<ProtocolObject<dyn MTLTexture>> {
    let surface = IOSurfaceRefWrapper(surface);
    msg_send_id![device, newTextureWithDescriptor: descriptor, iosurface: surface, plane: plane]
}

This approach is somewhat documented in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants