objc2-metal 0.3.2

Bindings to the Metal framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_protocol!(
    /// A pool of lightweight texture views.
    ///
    /// Use texture view pools to create lightweight texture view objects of ``MTLTexture``
    /// and ``MTLBuffer`` instances.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtltextureviewpool?language=objc)
    #[cfg(feature = "MTLResourceViewPool")]
    pub unsafe trait MTLTextureViewPool: MTLResourceViewPool {
        #[cfg(all(
            feature = "MTLAllocation",
            feature = "MTLResource",
            feature = "MTLTexture",
            feature = "MTLTypes"
        ))]
        /// Copies a default texture view to a slot in this texture view pool at an index provided.
        ///
        /// - Parameters:
        /// - texture: An ``MTLTexture`` instance for which to copy its texture view.
        /// - index: An index of a slot in this texture pool into which this method copies the texture view.
        /// - Returns: The ``MTLResourceID`` of a newly created texture view in this pool.
        ///
        /// # Safety
        ///
        /// - `texture` may need to be synchronized.
        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
        /// - `index` might not be bounds-checked.
        #[unsafe(method(setTextureView:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setTextureView_atIndex(
            &self,
            texture: &ProtocolObject<dyn MTLTexture>,
            index: NSUInteger,
        ) -> MTLResourceID;

        #[cfg(all(
            feature = "MTLAllocation",
            feature = "MTLResource",
            feature = "MTLTexture",
            feature = "MTLTypes"
        ))]
        /// Creates a new lightweight texture view.
        ///
        /// This method creates a lightweight texture view over a texture according to
        /// a descriptor you provide. It then associates the texture view with a slot
        /// in this texture view pool at the index you specify.
        ///
        /// - Parameters:
        /// - texture: An ``MTLTexture`` instance for which to create a new lightweight texture view.
        /// - descriptor: A descriptor specifying properties of the texture view to create.
        /// - index: An index of a slot in the texture pool into which this method writes the new texture view.
        /// - Returns: The ``MTLResourceID`` of a newly created texture view in this pool.
        ///
        /// # Safety
        ///
        /// - `texture` may need to be synchronized.
        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
        /// - `index` might not be bounds-checked.
        #[unsafe(method(setTextureView:descriptor:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setTextureView_descriptor_atIndex(
            &self,
            texture: &ProtocolObject<dyn MTLTexture>,
            descriptor: &MTLTextureViewDescriptor,
            index: NSUInteger,
        ) -> MTLResourceID;

        #[cfg(all(
            feature = "MTLAllocation",
            feature = "MTLBuffer",
            feature = "MTLResource",
            feature = "MTLTexture",
            feature = "MTLTypes"
        ))]
        /// Creates a new lightweight texture view of a buffer.
        ///
        /// This method creates a lightweight texture view over a buffer, according to
        /// a descriptor you provide. It then associates the texture view with a slot
        /// in this texture view pool at the index you specify.
        ///
        /// - Parameters:
        /// - buffer: An ``MTLBuffer`` instance for which to create a new texture view.
        /// - descriptor: A descriptor specifying properties of the texture view to create.
        /// - offset: A byte offset, within the `buffer` parameter, at which the data for the texture view starts.
        /// - bytesPerRow: The number of bytes between adjacent rows of pixels in the source buffer’s memory.
        /// - index: An index of a slot in the table into which this method writes the new texture view.
        /// - Returns: The ``MTLResourceID`` of a new buffer view in this pool.
        ///
        /// # Safety
        ///
        /// - `buffer` may need to be synchronized.
        /// - `buffer` may be unretained, you must ensure it is kept alive while in use.
        /// - `buffer` contents should be of the correct type.
        /// - `offset` might not be bounds-checked.
        /// - `index` might not be bounds-checked.
        #[unsafe(method(setTextureViewFromBuffer:descriptor:offset:bytesPerRow:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setTextureViewFromBuffer_descriptor_offset_bytesPerRow_atIndex(
            &self,
            buffer: &ProtocolObject<dyn MTLBuffer>,
            descriptor: &MTLTextureDescriptor,
            offset: NSUInteger,
            bytes_per_row: NSUInteger,
            index: NSUInteger,
        ) -> MTLResourceID;
    }
);