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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Groups parameters for the creation of a Metal argument table.
    ///
    /// Argument tables provide resource bindings to your Metal pipeline states.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4argumenttabledescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTL4ArgumentTableDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTL4ArgumentTableDescriptor {}
);

unsafe impl CopyingHelper for MTL4ArgumentTableDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTL4ArgumentTableDescriptor {}
);

impl MTL4ArgumentTableDescriptor {
    extern_methods!(
        /// Determines the number of buffer-binding slots for the argument table.
        ///
        /// The maximum value of this parameter is 31.
        #[unsafe(method(maxBufferBindCount))]
        #[unsafe(method_family = none)]
        pub fn maxBufferBindCount(&self) -> NSUInteger;

        /// Setter for [`maxBufferBindCount`][Self::maxBufferBindCount].
        #[unsafe(method(setMaxBufferBindCount:))]
        #[unsafe(method_family = none)]
        pub fn setMaxBufferBindCount(&self, max_buffer_bind_count: NSUInteger);

        /// Determines the number of texture-binding slots for the argument table.
        ///
        /// The maximum value of this parameter is 128.
        #[unsafe(method(maxTextureBindCount))]
        #[unsafe(method_family = none)]
        pub fn maxTextureBindCount(&self) -> NSUInteger;

        /// Setter for [`maxTextureBindCount`][Self::maxTextureBindCount].
        #[unsafe(method(setMaxTextureBindCount:))]
        #[unsafe(method_family = none)]
        pub fn setMaxTextureBindCount(&self, max_texture_bind_count: NSUInteger);

        /// Determines the number of sampler state-binding slots for the argument table.
        ///
        /// The maximum value of this parameter is 16.
        #[unsafe(method(maxSamplerStateBindCount))]
        #[unsafe(method_family = none)]
        pub fn maxSamplerStateBindCount(&self) -> NSUInteger;

        /// Setter for [`maxSamplerStateBindCount`][Self::maxSamplerStateBindCount].
        #[unsafe(method(setMaxSamplerStateBindCount:))]
        #[unsafe(method_family = none)]
        pub fn setMaxSamplerStateBindCount(&self, max_sampler_state_bind_count: NSUInteger);

        /// Configures whether Metal initializes the bindings to nil values upon creation of argument table.
        ///
        /// The default value of this property is
        /// <doc
        /// ://com.apple.documentation/documentation/swift/false>.
        #[unsafe(method(initializeBindings))]
        #[unsafe(method_family = none)]
        pub fn initializeBindings(&self) -> bool;

        /// Setter for [`initializeBindings`][Self::initializeBindings].
        #[unsafe(method(setInitializeBindings:))]
        #[unsafe(method_family = none)]
        pub fn setInitializeBindings(&self, initialize_bindings: bool);

        /// Controls whether Metal should reserve memory for attribute strides in the argument table.
        ///
        /// Set this value to true if you intend to provide dynamic attribute strides when binding vertex
        /// array buffers to the argument table by calling ``MTL4ArgumentTable/setAddress:attributeStride:atIndex:``
        ///
        /// The default value of this property is
        /// <doc
        /// ://com.apple.documentation/documentation/swift/false>.
        #[unsafe(method(supportAttributeStrides))]
        #[unsafe(method_family = none)]
        pub fn supportAttributeStrides(&self) -> bool;

        /// Setter for [`supportAttributeStrides`][Self::supportAttributeStrides].
        #[unsafe(method(setSupportAttributeStrides:))]
        #[unsafe(method_family = none)]
        pub fn setSupportAttributeStrides(&self, support_attribute_strides: bool);

        /// Assigns an optional label with the argument table for debug purposes.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        pub fn label(&self) -> Option<Retained<NSString>>;

        /// Setter for [`label`][Self::label].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLabel:))]
        #[unsafe(method_family = none)]
        pub fn setLabel(&self, label: Option<&NSString>);
    );
}

/// Methods declared on superclass `NSObject`.
impl MTL4ArgumentTableDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTL4ArgumentTableDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// Provides a mechanism to manage and provide resource bindings for buffers, textures, sampler states and other Metal resources.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4argumenttable?language=objc)
    pub unsafe trait MTL4ArgumentTable: NSObjectProtocol {
        #[cfg(feature = "MTLGPUAddress")]
        /// Binds a GPU address to a buffer binding slot.
        ///
        /// - Parameters:
        /// - gpuAddress: The GPU address of a ``MTLBuffer`` to set.
        /// - bindingIndex: a valid binding index in the buffer binding range.
        /// It is an error for this value to match or exceed the value of property
        /// ``MTL4ArgumentTableDescriptor/maxBufferBindCount`` on the descriptor
        /// from which you created this argument table.
        ///
        /// # Safety
        ///
        /// `bindingIndex` might not be bounds-checked.
        #[unsafe(method(setAddress:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setAddress_atIndex(&self, gpu_address: MTLGPUAddress, binding_index: NSUInteger);

        #[cfg(feature = "MTLGPUAddress")]
        /// Binds a GPU address to a buffer binding slot, providing a dynamic vertex stride.
        ///
        /// This method requires that the value of property ``MTL4ArgumentTableDescriptor/supportAttributeStrides`` on the
        /// descriptor from which you created this argument table is true.
        ///
        /// - Parameters:
        /// - gpuAddress: The GPU address of a ``MTLBuffer`` to set.
        /// - stride: The stride between attributes in the buffer.
        /// - bindingIndex: a valid binding index in the buffer binding range.
        /// It is an error for this value to match or exceed the value of property
        /// ``MTL4ArgumentTableDescriptor/maxBufferBindCount`` on the descriptor
        /// from which you created this argument table.
        ///
        /// # Safety
        ///
        /// - `stride` might not be bounds-checked.
        /// - `bindingIndex` might not be bounds-checked.
        #[unsafe(method(setAddress:attributeStride:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setAddress_attributeStride_atIndex(
            &self,
            gpu_address: MTLGPUAddress,
            stride: NSUInteger,
            binding_index: NSUInteger,
        );

        #[cfg(feature = "MTLTypes")]
        /// Binds a resource to a buffer binding slot.
        ///
        /// - Parameters:
        /// - resourceID: The ``MTLResourceID`` of the Metal resource to bind.
        /// - bindingIndex: a valid binding index in the buffer binding range.
        /// It is an error for this value to match or exceed the value of property
        /// ``MTL4ArgumentTableDescriptor/maxBufferBindCount`` on the descriptor
        /// from which you created this argument table.
        ///
        /// # Safety
        ///
        /// `bindingIndex` might not be bounds-checked.
        #[unsafe(method(setResource:atBufferIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setResource_atBufferIndex(
            &self,
            resource_id: MTLResourceID,
            binding_index: NSUInteger,
        );

        #[cfg(feature = "MTLTypes")]
        /// Binds a texture to a texture binding slot.
        ///
        /// - Parameters:
        /// - resourceID: The ``MTLResourceID`` of the ``MTLTexture`` instance to bind.
        /// - bindingIndex: a valid binding index in the texture binding range.
        /// It is an error for this value to match or exceed the value of property
        /// ``MTL4ArgumentTableDescriptor/maxTextureBindCount`` on the descriptor
        /// from which you created this argument table.
        ///
        /// # Safety
        ///
        /// `bindingIndex` might not be bounds-checked.
        #[unsafe(method(setTexture:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setTexture_atIndex(&self, resource_id: MTLResourceID, binding_index: NSUInteger);

        #[cfg(feature = "MTLTypes")]
        /// Binds a sampler state to a sampler state binding slot.
        ///
        /// - Parameters:
        /// - resourceID: The ``MTLResourceID`` of the ``MTLSamplerState`` instance to bind.
        /// - bindingIndex: a valid binding index in the sampler binding range.
        /// It is an error for this value to match or exceed the value of property
        /// ``MTL4ArgumentTableDescriptor/maxSamplerStateBindCount`` on the descriptor
        /// from which you created this argument table.
        ///
        /// # Safety
        ///
        /// `bindingIndex` might not be bounds-checked.
        #[unsafe(method(setSamplerState:atIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn setSamplerState_atIndex(
            &self,
            resource_id: MTLResourceID,
            binding_index: NSUInteger,
        );

        #[cfg(feature = "MTLDevice")]
        /// The device from which you created this argument table.
        #[unsafe(method(device))]
        #[unsafe(method_family = none)]
        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;

        /// Assigns an optional label with this argument table for debugging purposes.
        ///
        /// You set this label by setting property ``MTL4ArgumentTableDescriptor/label`` on the descriptor object, prior to
        /// creating this table instance.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        fn label(&self) -> Option<Retained<NSString>>;
    }
);