objc2-metal-performance-shaders 0.3.2

Bindings to the MetalPerformanceShaders 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayquantizationscheme?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MPSNDArrayQuantizationScheme(pub NSUInteger);
bitflags::bitflags! {
    impl MPSNDArrayQuantizationScheme: NSUInteger {
        #[doc(alias = "MPSNDArrayQuantizationTypeNone")]
        const TypeNone = 0;
        #[doc(alias = "MPSNDArrayQuantizationTypeAffine")]
        const TypeAffine = 1;
        #[doc(alias = "MPSNDArrayQuantizationTypeLUT")]
        const TypeLUT = 2;
    }
}

unsafe impl Encode for MPSNDArrayQuantizationScheme {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MPSNDArrayQuantizationScheme {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Dependencies: This depends on Metal.framework.
    ///
    /// Common methods for quantization descriptors
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayquantizationdescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPSNDArrayQuantizationDescriptor;
);

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

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

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

impl MPSNDArrayQuantizationDescriptor {
    extern_methods!(
        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
        /// The datatype to use with quantization - the default is MPSDataTypeUint8
        #[unsafe(method(quantizationDataType))]
        #[unsafe(method_family = none)]
        pub unsafe fn quantizationDataType(&self) -> MPSDataType;

        /// The quantization scheme for this descriptor. The default is MPSNDArrayQuantizationTypeNone.
        #[unsafe(method(quantizationScheme))]
        #[unsafe(method_family = none)]
        pub unsafe fn quantizationScheme(&self) -> MPSNDArrayQuantizationScheme;
    );
}

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

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

extern_class!(
    /// Dependencies: This depends on Metal.framework.
    ///
    /// Describes an affine quantization scheme
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayaffinequantizationdescriptor?language=objc)
    #[unsafe(super(MPSNDArrayQuantizationDescriptor, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPSNDArrayAffineQuantizationDescriptor;
);

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

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

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

impl MPSNDArrayAffineQuantizationDescriptor {
    extern_methods!(
        /// If yes then asymmetric quantization is used. See MPSNDArrayQuantizationScheme.
        #[unsafe(method(hasZeroPoint))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasZeroPoint(&self) -> bool;

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

        /// If yes then offset is used. See MPSNDArrayQuantizationScheme.
        #[unsafe(method(hasMinValue))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasMinValue(&self) -> bool;

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

        /// If true and quantized values are signed, these are assumed to be stored with an
        /// implicit offset or zero-point of 2^(quantizationBitWidth-1) added to bring signed values into unsigned range.
        /// e.g. Int4 values are in range [-8,7]. If we add 8 to it values are in range
        /// [0,15] and can be encoded/stored as UInt4.
        /// Default is false. Its only currently applicable to Int4.
        /// Implementation will generate error for any other data type;
        #[unsafe(method(implicitZeroPoint))]
        #[unsafe(method_family = none)]
        pub unsafe fn implicitZeroPoint(&self) -> bool;

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

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
        /// Initializes an affine quantization descriptor.
        ///
        /// Parameter `quantizationDataType`: Which quantized datatype is used.
        ///
        /// Parameter `hasZeroPoint`: A flag indicating that a zero-point input is expected.
        ///
        /// Parameter `hasMinValue`: A flag indicating that a minimum value input is expected.
        ///
        /// Returns: A new quantization descriptor.
        #[unsafe(method(initWithDataType:hasZeroPoint:hasMinValue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDataType_hasZeroPoint_hasMinValue(
            this: Allocated<Self>,
            quantization_data_type: MPSDataType,
            has_zero_point: bool,
            has_min_value: bool,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl MPSNDArrayAffineQuantizationDescriptor {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Dependencies: This depends on Metal.framework.
    ///
    /// Describes a lookup-table based quantization scheme
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraylutquantizationdescriptor?language=objc)
    #[unsafe(super(MPSNDArrayQuantizationDescriptor, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MPSNDArrayLUTQuantizationDescriptor;
);

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

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

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

impl MPSNDArrayLUTQuantizationDescriptor {
    extern_methods!(
        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
        /// Initializes a scalar lookup-table quantization descriptor.
        ///
        /// Parameter `quantizationDataType`: Which quantized datatype is used.
        ///
        /// Returns: A new quantization descriptor.
        #[unsafe(method(initWithDataType:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDataType(
            this: Allocated<Self>,
            quantization_data_type: MPSDataType,
        ) -> Retained<Self>;

        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
        /// Initializes a vector lookup-table quantization descriptor.
        ///
        /// Parameter `quantizationDataType`: Which quantized datatype is used.
        ///
        /// Parameter `vectorAxis`: The quantization vector axis - this axis will receive the vector component in the destination.
        ///
        /// Returns: A new quantization descriptor.
        #[unsafe(method(initWithDataType:vectorAxis:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDataType_vectorAxis(
            this: Allocated<Self>,
            quantization_data_type: MPSDataType,
            vector_axis: NSUInteger,
        ) -> Retained<Self>;
    );
}

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

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