From 91615bced1f63a6dcfdec861140c7a97637978cb Mon Sep 17 00:00:00 2001 From: David Koski Date: Fri, 24 Oct 2025 14:06:44 -0700 Subject: [PATCH 1/3] build MLX, Cmlx via xcodeproj as a framework tests passing with https://github.com/ml-explore/mlx/pull/2702 locally applied expose C++ API --- .gitignore | 1 - README.xcodeproj.md | 18 + Source/Cmlx/include-framework/Cmlx.h | 36 + Source/Cmlx/include-framework/mlx-allocator.h | 54 + Source/Cmlx/include-framework/mlx-array.h | 624 +++++ .../include-framework/mlx-backend-cuda-cuda.h | 12 + .../mlx-backend-gpu-available.h | 11 + .../mlx-backend-metal-metal.h | 24 + Source/Cmlx/include-framework/mlx-c-array.h | 379 +++ Source/Cmlx/include-framework/mlx-c-closure.h | 193 ++ Source/Cmlx/include-framework/mlx-c-compile.h | 55 + Source/Cmlx/include-framework/mlx-c-device.h | 80 + .../include-framework/mlx-c-distributed.h | 76 + .../mlx-c-distributed_group.h | 58 + Source/Cmlx/include-framework/mlx-c-error.h | 41 + Source/Cmlx/include-framework/mlx-c-export.h | 75 + Source/Cmlx/include-framework/mlx-c-fast.h | 195 ++ Source/Cmlx/include-framework/mlx-c-fft.h | 136 ++ Source/Cmlx/include-framework/mlx-c-half.h | 26 + Source/Cmlx/include-framework/mlx-c-io.h | 61 + .../Cmlx/include-framework/mlx-c-io_types.h | 104 + Source/Cmlx/include-framework/mlx-c-linalg.h | 126 + Source/Cmlx/include-framework/mlx-c-map.h | 149 ++ Source/Cmlx/include-framework/mlx-c-memory.h | 45 + Source/Cmlx/include-framework/mlx-c-metal.h | 48 + Source/Cmlx/include-framework/mlx-c-mlx.h | 33 + Source/Cmlx/include-framework/mlx-c-ops.h | 1155 ++++++++++ .../Cmlx/include-framework/mlx-c-optional.h | 43 + Source/Cmlx/include-framework/mlx-c-random.h | 164 ++ Source/Cmlx/include-framework/mlx-c-stream.h | 88 + Source/Cmlx/include-framework/mlx-c-string.h | 55 + .../Cmlx/include-framework/mlx-c-transforms.h | 66 + .../include-framework/mlx-c-transforms_impl.h | 52 + Source/Cmlx/include-framework/mlx-c-vector.h | 133 ++ Source/Cmlx/include-framework/mlx-c-version.h | 18 + Source/Cmlx/include-framework/mlx-compile.h | 46 + Source/Cmlx/include-framework/mlx-device.h | 33 + .../mlx-distributed-distributed.h | 61 + .../include-framework/mlx-distributed-ops.h | 53 + Source/Cmlx/include-framework/mlx-dtype.h | 117 + Source/Cmlx/include-framework/mlx-einsum.h | 24 + Source/Cmlx/include-framework/mlx-event.h | 59 + Source/Cmlx/include-framework/mlx-export.h | 68 + .../Cmlx/include-framework/mlx-export_impl.h | 73 + Source/Cmlx/include-framework/mlx-fast.h | 104 + Source/Cmlx/include-framework/mlx-fft.h | 169 ++ Source/Cmlx/include-framework/mlx-io-load.h | 176 ++ Source/Cmlx/include-framework/mlx-io.h | 63 + Source/Cmlx/include-framework/mlx-linalg.h | 113 + Source/Cmlx/include-framework/mlx-memory.h | 80 + Source/Cmlx/include-framework/mlx-ops.h | 1540 +++++++++++++ Source/Cmlx/include-framework/mlx-random.h | 284 +++ .../Cmlx/include-framework/mlx-small_vector.h | 542 +++++ Source/Cmlx/include-framework/mlx-stream.h | 43 + .../Cmlx/include-framework/mlx-threadpool.h | 135 ++ .../Cmlx/include-framework/mlx-transforms.h | 231 ++ .../Cmlx/include-framework/mlx-types-bf16.h | 189 ++ .../include-framework/mlx-types-complex.h | 115 + .../include-framework/mlx-types-half_types.h | 60 + Source/Cmlx/include-framework/mlx-utils.h | 172 ++ Source/Cmlx/include-framework/mlx-version.h | 22 + Source/Cmlx/metal-cpp/Foundation/NSBundle.hpp | 6 +- Source/MLX/MLXArray.swift | 2 +- tools/update-mlx.sh | 69 + xcode/MLX.xcodeproj/project.pbxproj | 2038 +++++++++++++++++ .../contents.xcworkspacedata | 7 + xcode/xcconfig/Cmlx.xcconfig | 99 + xcode/xcconfig/MLX.xcconfig | 88 + xcode/xcconfig/MLXNN.xcconfig | 88 + xcode/xcconfig/MLXOptimizers.xcconfig | 88 + xcode/xcconfig/MLXTests.xcconfig | 16 + xcode/xcconfig/project.xcconfig | 60 + 72 files changed, 11562 insertions(+), 5 deletions(-) create mode 100644 README.xcodeproj.md create mode 100644 Source/Cmlx/include-framework/Cmlx.h create mode 100644 Source/Cmlx/include-framework/mlx-allocator.h create mode 100644 Source/Cmlx/include-framework/mlx-array.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-cuda-cuda.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-gpu-available.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-metal-metal.h create mode 100644 Source/Cmlx/include-framework/mlx-c-array.h create mode 100644 Source/Cmlx/include-framework/mlx-c-closure.h create mode 100644 Source/Cmlx/include-framework/mlx-c-compile.h create mode 100644 Source/Cmlx/include-framework/mlx-c-device.h create mode 100644 Source/Cmlx/include-framework/mlx-c-distributed.h create mode 100644 Source/Cmlx/include-framework/mlx-c-distributed_group.h create mode 100644 Source/Cmlx/include-framework/mlx-c-error.h create mode 100644 Source/Cmlx/include-framework/mlx-c-export.h create mode 100644 Source/Cmlx/include-framework/mlx-c-fast.h create mode 100644 Source/Cmlx/include-framework/mlx-c-fft.h create mode 100644 Source/Cmlx/include-framework/mlx-c-half.h create mode 100644 Source/Cmlx/include-framework/mlx-c-io.h create mode 100644 Source/Cmlx/include-framework/mlx-c-io_types.h create mode 100644 Source/Cmlx/include-framework/mlx-c-linalg.h create mode 100644 Source/Cmlx/include-framework/mlx-c-map.h create mode 100644 Source/Cmlx/include-framework/mlx-c-memory.h create mode 100644 Source/Cmlx/include-framework/mlx-c-metal.h create mode 100644 Source/Cmlx/include-framework/mlx-c-mlx.h create mode 100644 Source/Cmlx/include-framework/mlx-c-ops.h create mode 100644 Source/Cmlx/include-framework/mlx-c-optional.h create mode 100644 Source/Cmlx/include-framework/mlx-c-random.h create mode 100644 Source/Cmlx/include-framework/mlx-c-stream.h create mode 100644 Source/Cmlx/include-framework/mlx-c-string.h create mode 100644 Source/Cmlx/include-framework/mlx-c-transforms.h create mode 100644 Source/Cmlx/include-framework/mlx-c-transforms_impl.h create mode 100644 Source/Cmlx/include-framework/mlx-c-vector.h create mode 100644 Source/Cmlx/include-framework/mlx-c-version.h create mode 100644 Source/Cmlx/include-framework/mlx-compile.h create mode 100644 Source/Cmlx/include-framework/mlx-device.h create mode 100644 Source/Cmlx/include-framework/mlx-distributed-distributed.h create mode 100644 Source/Cmlx/include-framework/mlx-distributed-ops.h create mode 100644 Source/Cmlx/include-framework/mlx-dtype.h create mode 100644 Source/Cmlx/include-framework/mlx-einsum.h create mode 100644 Source/Cmlx/include-framework/mlx-event.h create mode 100644 Source/Cmlx/include-framework/mlx-export.h create mode 100644 Source/Cmlx/include-framework/mlx-export_impl.h create mode 100644 Source/Cmlx/include-framework/mlx-fast.h create mode 100644 Source/Cmlx/include-framework/mlx-fft.h create mode 100644 Source/Cmlx/include-framework/mlx-io-load.h create mode 100644 Source/Cmlx/include-framework/mlx-io.h create mode 100644 Source/Cmlx/include-framework/mlx-linalg.h create mode 100644 Source/Cmlx/include-framework/mlx-memory.h create mode 100644 Source/Cmlx/include-framework/mlx-ops.h create mode 100644 Source/Cmlx/include-framework/mlx-random.h create mode 100644 Source/Cmlx/include-framework/mlx-small_vector.h create mode 100644 Source/Cmlx/include-framework/mlx-stream.h create mode 100644 Source/Cmlx/include-framework/mlx-threadpool.h create mode 100644 Source/Cmlx/include-framework/mlx-transforms.h create mode 100644 Source/Cmlx/include-framework/mlx-types-bf16.h create mode 100644 Source/Cmlx/include-framework/mlx-types-complex.h create mode 100644 Source/Cmlx/include-framework/mlx-types-half_types.h create mode 100644 Source/Cmlx/include-framework/mlx-utils.h create mode 100644 Source/Cmlx/include-framework/mlx-version.h create mode 100644 xcode/MLX.xcodeproj/project.pbxproj create mode 100644 xcode/MLX.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 xcode/xcconfig/Cmlx.xcconfig create mode 100644 xcode/xcconfig/MLX.xcconfig create mode 100644 xcode/xcconfig/MLXNN.xcconfig create mode 100644 xcode/xcconfig/MLXOptimizers.xcconfig create mode 100644 xcode/xcconfig/MLXTests.xcconfig create mode 100644 xcode/xcconfig/project.xcconfig diff --git a/.gitignore b/.gitignore index 20b47c63..7e7669c5 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ playground.xcworkspace Packages/ Package.pins Package.resolved -*.xcodeproj # # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata # hence it is not needed unless you have added a package configuration file to your project diff --git a/README.xcodeproj.md b/README.xcodeproj.md new file mode 100644 index 00000000..af647c37 --- /dev/null +++ b/README.xcodeproj.md @@ -0,0 +1,18 @@ +See `xcode/MLX.xcodeproj`. + +# Cmlx + +This is set up to build roughly how Package.swift builds. + +- Look at Project -> Cmlx -> Build Phases +- remove all Project headers +- remove all Copy Bundle Resources +- remove any files that should not be built from the Target membership, e.g the items in `exclude` + +Public headers are in `include-framework` and this is managed by tools/update-mlx + +Settings, including header search paths are in xcode/xcconfig. + +# MLX, etc. + +These are just normal frameworks that link to Cmlx and others as needed. The source files are all swift and there are no special settings needed. diff --git a/Source/Cmlx/include-framework/Cmlx.h b/Source/Cmlx/include-framework/Cmlx.h new file mode 100644 index 00000000..0bea1aae --- /dev/null +++ b/Source/Cmlx/include-framework/Cmlx.h @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Source/Cmlx/include-framework/mlx-allocator.h b/Source/Cmlx/include-framework/mlx-allocator.h new file mode 100644 index 00000000..853c9e90 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-allocator.h @@ -0,0 +1,54 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include + +namespace mlx::core::allocator { + +// Simple wrapper around buffer pointers +// WARNING: Only Buffer objects constructed from and those that wrap +// raw pointers from mlx::allocator are supported. +class Buffer { + private: + void* ptr_; + + public: + Buffer(void* ptr) : ptr_(ptr) {}; + + // Get the raw data pointer from the buffer + void* raw_ptr(); + + // Get the buffer pointer from the buffer + const void* ptr() const { + return ptr_; + }; + void* ptr() { + return ptr_; + }; +}; + +Buffer malloc(size_t size); + +void free(Buffer buffer); + +class Allocator { + /** Abstract base class for a memory allocator. */ + public: + virtual Buffer malloc(size_t size) = 0; + virtual void free(Buffer buffer) = 0; + virtual size_t size(Buffer buffer) const = 0; + + Allocator() = default; + Allocator(const Allocator& other) = delete; + Allocator(Allocator&& other) = delete; + Allocator& operator=(const Allocator& other) = delete; + Allocator& operator=(Allocator&& other) = delete; + virtual ~Allocator() = default; +}; + +Allocator& allocator(); + +} // namespace mlx::core::allocator +#endif diff --git a/Source/Cmlx/include-framework/mlx-array.h b/Source/Cmlx/include-framework/mlx-array.h new file mode 100644 index 00000000..8cc39b1e --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-array.h @@ -0,0 +1,624 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace mlx::core { + +// Forward declaration +class Primitive; + +using Deleter = std::function; +using ShapeElem = int32_t; +using Shape = SmallVector; +using Strides = SmallVector; + +class array { + /* An array is really a node in a graph. It contains a shared ArrayDesc + * object */ + + public: + /** Construct a scalar array with zero dimensions. */ + template + explicit array(T val, Dtype dtype = TypeToDtype()); + + /* Special case since std::complex can't be implicitly converted to other + * types. */ + explicit array(const std::complex& val, Dtype dtype = complex64); + + template + explicit array( + It data, + Shape shape, + Dtype dtype = + TypeToDtype::value_type>()); + + template + explicit array(std::initializer_list data, Dtype dtype = TypeToDtype()); + + /* Special case so empty lists default to float32. */ + explicit array(std::initializer_list data); + + /* Special case so array({}, type) is an empty array. */ + explicit array(std::initializer_list data, Dtype dtype); + + template + explicit array( + std::initializer_list data, + Shape shape, + Dtype dtype = TypeToDtype()); + + /* Build an array from a buffer */ + explicit array( + allocator::Buffer data, + Shape shape, + Dtype dtype, + Deleter deleter = allocator::free); + + /** Assignment to rvalue does not compile. */ + array& operator=(const array& other) && = delete; + array& operator=(array&& other) && = delete; + + /** Default copy and move constructors otherwise. */ + array& operator=(array&& other) & = default; + array(const array& other) = default; + array(array&& other) = default; + + array& operator=(const array& other) & { + if (this->id() != other.id()) { + this->array_desc_ = other.array_desc_; + } + return *this; + } + + /** The size of the array's datatype in bytes. */ + size_t itemsize() const { + return size_of(dtype()); + } + + /** The number of elements in the array. */ + size_t size() const { + return array_desc_->size; + } + + /** The number of bytes in the array. */ + size_t nbytes() const { + return size() * itemsize(); + } + + /** The number of dimensions of the array. */ + size_t ndim() const { + return array_desc_->shape.size(); + } + + /** The shape of the array as a vector of integers. */ + const Shape& shape() const { + return array_desc_->shape; + } + + /** + * Get the size of the corresponding dimension. + * + * This function supports negative indexing and provides + * bounds checking. */ + auto shape(int dim) const { + return shape().at(dim < 0 ? dim + ndim() : dim); + } + + /** The strides of the array. */ + const Strides& strides() const { + return array_desc_->strides; + } + + /** + * Get the stride of the corresponding dimension. + * + * This function supports negative indexing and provides + * bounds checking. */ + auto strides(int dim) const { + return strides().at(dim < 0 ? dim + ndim() : dim); + } + + /** Get the arrays data type. */ + Dtype dtype() const { + return array_desc_->dtype; + } + + /** Evaluate the array. */ + void eval(); + + /** Get the value from a scalar array. */ + template + T item(); + + template + T item() const; + + struct ArrayIterator { + using iterator_category = std::random_access_iterator_tag; + using difference_type = size_t; + using value_type = const array; + using reference = value_type; + + explicit ArrayIterator(const array& arr, int idx = 0); + + reference operator*() const; + + ArrayIterator& operator+(difference_type diff) { + idx += diff; + return *this; + } + + ArrayIterator& operator++() { + idx++; + return *this; + } + + friend bool operator==(const ArrayIterator& a, const ArrayIterator& b) { + return a.arr.id() == b.arr.id() && a.idx == b.idx; + } + friend bool operator!=(const ArrayIterator& a, const ArrayIterator& b) { + return !(a == b); + } + + private: + const array& arr; + int idx; + }; + + ArrayIterator begin() const { + return ArrayIterator(*this); + } + ArrayIterator end() const { + return ArrayIterator(*this, shape(0)); + } + + /** + * The following methods should be used with caution. + * They are intended for use by the backend implementation and the + * API may change. + */ + + array( + Shape shape, + Dtype dtype, + std::shared_ptr primitive, + std::vector inputs); + + static std::vector make_arrays( + std::vector shapes, + const std::vector& dtypes, + const std::shared_ptr& primitive, + const std::vector& inputs); + + /** + * Get a new array that refers to the same data as the input but with a + * non-owning pointer to it. Note the array is detached from the graph and has + * no inputs, siblings or primitive. + */ + static array unsafe_weak_copy(const array& other); + + /** A unique identifier for an array. */ + std::uintptr_t id() const { + return reinterpret_cast(array_desc_.get()); + } + + /** A unique identifier for an arrays primitive. */ + std::uintptr_t primitive_id() const { + return reinterpret_cast(array_desc_->primitive.get()); + } + + struct Data { + allocator::Buffer buffer; + Deleter d; + Data(allocator::Buffer buffer, Deleter d = allocator::free) + : buffer(buffer), d(d) {} + // Not copyable + Data(const Data& d) = delete; + Data& operator=(const Data& d) = delete; + Data(Data&& o) : buffer(o.buffer), d(o.d) { + o.buffer = allocator::Buffer(nullptr); + o.d = [](allocator::Buffer) {}; + } + ~Data() { + d(buffer); + } + }; + + struct Flags { + // True iff there are no gaps in the underlying data. Each item + // in the underlying data buffer belongs to at least one index. + // + // True iff: + // prod(shape[i] for i in range(ndim) if strides[i] > 0) == data_size() + bool contiguous : 1; + + // True iff: + // strides[-1] == 1 and + // all(strides[i] == (shape[i+1]*strides[i+1]) or shape[i] == 1 for i in + // range(ndim - 1)) + bool row_contiguous : 1; + + // True iff: + // strides[0] == 1 and + // all(strides[i] == (shape[i-1]*strides[i-1]) or shape[i] == 1 for i in + // range(1, ndim)) + bool col_contiguous : 1; + }; + + /** The array's primitive. */ + Primitive& primitive() const { + return *(array_desc_->primitive); + } + + /** A shared pointer to the array's primitive. */ + std::shared_ptr& primitive_ptr() const { + return array_desc_->primitive; + } + + /** Check if the array has an attached primitive or is a leaf node. */ + bool has_primitive() const { + return array_desc_->primitive != nullptr; + } + + /** The array's inputs. */ + const std::vector& inputs() const { + return array_desc_->inputs; + } + + std::vector& inputs() { + return array_desc_->inputs; + } + + /** True indicates the arrays buffer is safe to reuse */ + bool is_donatable() const { + return array_desc_.use_count() == 1 && (array_desc_->data.use_count() == 1); + } + + /** The array's siblings. */ + const std::vector& siblings() const { + return array_desc_->siblings; + } + + /** The array's siblings. */ + std::vector& siblings() { + return array_desc_->siblings; + } + + void set_siblings(std::vector siblings, uint16_t position) { + array_desc_->siblings = std::move(siblings); + array_desc_->position = position; + } + + /** The outputs of the array's primitive (i.e. this array and + * its siblings) in the order the primitive expects. */ + std::vector outputs() const { + auto idx = array_desc_->position; + std::vector outputs; + outputs.reserve(siblings().size() + 1); + outputs.insert(outputs.end(), siblings().begin(), siblings().begin() + idx); + outputs.push_back(*this); + outputs.insert(outputs.end(), siblings().begin() + idx, siblings().end()); + return outputs; + } + + /** Detach the array from the graph. */ + void detach(); + + /** Get the Flags bit-field. */ + const Flags& flags() const { + return array_desc_->flags; + } + + /** The size (in elements) of the underlying buffer the array points to. + * + * This can be different than the actual size of the array if the array has + * been broadcast or irregularly strided. If ``first`` is the offset into + * the data buffer of the first element of the array (i.e. the offset + * corresponding to ``arr[0, 0, ...]``) and last is the offset into the + * data buffer of the last element of the array (i.e. the offset + * corresponding to ``arr[-1, -1, ...]``) then ``data_size = last - first``. + * Note, ``data_size`` is in units of ``item_size`` (not bytes). + **/ + size_t data_size() const { + return array_desc_->data_size; + } + + allocator::Buffer& buffer() { + return array_desc_->data->buffer; + } + const allocator::Buffer& buffer() const { + return array_desc_->data->buffer; + } + + size_t buffer_size() const { + return allocator::allocator().size(buffer()); + } + + // Return the shared pointer to the array::Data struct + const std::shared_ptr& data_shared_ptr() const { + return array_desc_->data; + } + + // Return a raw pointer to the arrays data + template + T* data() { + return static_cast(array_desc_->data_ptr); + } + + template + const T* data() const { + return static_cast(array_desc_->data_ptr); + } + + enum Status { + // The output of a computation which has not been scheduled. + // For example, the status of `x` in `auto x = a + b`. + unscheduled, + + // The array's `eval_*` function has been run, but the computation is not + // necessarily complete. The array will have memory allocated and if it is + // not a tracer then it will be detached from the graph. + evaluated, + + // If the array is the output of a computation then the computation + // is complete. Constant arrays are always available (e.g. `array({1, 2, + // 3})`) + available + }; + + // Check if the array is safe to read. + bool is_available() const; + + // Wait on the array to be available. After this `is_available` returns + // `true`. + void wait(); + + Status status() const { + return array_desc_->status; + } + + void set_status(Status s) const { + array_desc_->status = s; + } + + // Get the array's shared event + Event& event() const { + return array_desc_->event; + } + + // Attach an event to a not yet evaluated array + void attach_event(Event e) const { + array_desc_->event = std::move(e); + } + + void detach_event() const { + array_desc_->event = Event{}; + } + + // Mark the array as a tracer array (true) or not. + void set_tracer(bool is_tracer) { + array_desc_->is_tracer = is_tracer; + } + // Check if the array is a tracer array + bool is_tracer() const; + + void set_data(allocator::Buffer buffer, Deleter d = allocator::free); + + void set_data( + allocator::Buffer buffer, + size_t data_size, + Strides strides, + Flags flags, + Deleter d = allocator::free); + + void copy_shared_buffer( + const array& other, + const Strides& strides, + Flags flags, + size_t data_size, + size_t offset = 0); + + void copy_shared_buffer(const array& other); + + void overwrite_descriptor(const array& other) { + array_desc_ = other.array_desc_; + } + + ~array(); + + private: + // Initialize the arrays data + template + void init(const It src); + + struct ArrayDesc { + Shape shape; + Strides strides; + size_t size; + Dtype dtype; + std::shared_ptr primitive; + + Status status; + + // An event on the array used for synchronization + Event event; + + // Indicates an array is being used in a graph transform + // and should not be detached from the graph + bool is_tracer{false}; + + // This is a shared pointer so that *different* arrays + // can share the underlying data buffer. + std::shared_ptr data; + + // Properly offset data pointer + void* data_ptr{nullptr}; + + // The size in elements of the data buffer the array accesses + size_t data_size; + + // Contains useful meta data about the array + Flags flags; + + std::vector inputs; + // An array to keep track of the siblings from a multi-output + // primitive. + std::vector siblings; + // The arrays position in the output list + uint32_t position{0}; + + explicit ArrayDesc(Shape shape, Dtype dtype); + + explicit ArrayDesc( + Shape shape, + Dtype dtype, + std::shared_ptr primitive, + std::vector inputs); + + ~ArrayDesc(); + + private: + // Initialize size, strides, and other metadata + void init(); + }; + + // The ArrayDesc contains the details of the materialized array including the + // shape, strides, the data type. It also includes + // the primitive which knows how to compute the array's data from its inputs + // and the list of array's inputs for the primitive. + std::shared_ptr array_desc_; +}; + +template +array::array(T val, Dtype dtype /* = TypeToDtype() */) + : array_desc_(std::make_shared(Shape{}, dtype)) { + init(&val); +} + +template +array::array( + It data, + Shape shape, + Dtype dtype /* = TypeToDtype::value_type>() */) : + array_desc_(std::make_shared(std::move(shape), dtype)) { + init(data); +} + +template +array::array( + std::initializer_list data, + Dtype dtype /* = TypeToDtype() */) + : array_desc_(std::make_shared( + Shape{static_cast(data.size())}, + dtype)) { + init(data.begin()); +} + +template +array::array( + std::initializer_list data, + Shape shape, + Dtype dtype /* = TypeToDtype() */) + : array_desc_(std::make_shared(std::move(shape), dtype)) { + if (data.size() != size()) { + throw std::invalid_argument( + "Data size and provided shape mismatch in array construction."); + } + init(data.begin()); +} + +template +T array::item() { + if (size() != 1) { + throw std::invalid_argument("item can only be called on arrays of size 1."); + } + eval(); + return *data(); +} + +template +T array::item() const { + if (size() != 1) { + throw std::invalid_argument("item can only be called on arrays of size 1."); + } + if (status() == Status::unscheduled) { + throw std::invalid_argument( + "item() const can only be called on evaled arrays"); + } + const_cast(this)->eval(); + return *data(); +} + +template +void array::init(It src) { + set_data(allocator::malloc(size() * size_of(dtype()))); + switch (dtype()) { + case bool_: + std::copy(src, src + size(), data()); + break; + case uint8: + std::copy(src, src + size(), data()); + break; + case uint16: + std::copy(src, src + size(), data()); + break; + case uint32: + std::copy(src, src + size(), data()); + break; + case uint64: + std::copy(src, src + size(), data()); + break; + case int8: + std::copy(src, src + size(), data()); + break; + case int16: + std::copy(src, src + size(), data()); + break; + case int32: + std::copy(src, src + size(), data()); + break; + case int64: + std::copy(src, src + size(), data()); + break; + case float16: + std::copy(src, src + size(), data()); + break; + case float32: + std::copy(src, src + size(), data()); + break; + case float64: + std::copy(src, src + size(), data()); + break; + case bfloat16: + std::copy(src, src + size(), data()); + break; + case complex64: + std::copy(src, src + size(), data()); + break; + } +} + +/* Utilities for determining whether a template parameter is array. */ +template +inline constexpr bool is_array_v = + std::is_same_v>, array>; + +template +inline constexpr bool is_arrays_v = (is_array_v && ...); + +template +using enable_for_arrays_t = typename std::enable_if_t>; + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-cuda-cuda.h b/Source/Cmlx/include-framework/mlx-backend-cuda-cuda.h new file mode 100644 index 00000000..4eb779a4 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-cuda-cuda.h @@ -0,0 +1,12 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. + +#pragma once + +namespace mlx::core::cu { + +/* Check if the CUDA backend is available. */ +bool is_available(); + +} // namespace mlx::core::cu +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-gpu-available.h b/Source/Cmlx/include-framework/mlx-backend-gpu-available.h new file mode 100644 index 00000000..16189d50 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-gpu-available.h @@ -0,0 +1,11 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. + +#pragma once + +namespace mlx::core::gpu { + +bool is_available(); + +} // namespace mlx::core::gpu +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-metal-metal.h b/Source/Cmlx/include-framework/mlx-backend-metal-metal.h new file mode 100644 index 00000000..8b9e5f78 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-metal-metal.h @@ -0,0 +1,24 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include +#include + +namespace mlx::core::metal { + +/* Check if the Metal backend is available. */ +bool is_available(); + +/** Capture a GPU trace, saving it to an absolute file `path` */ +void start_capture(std::string path = ""); +void stop_capture(); + +/** Get information about the GPU and system settings. */ +const std::unordered_map>& +device_info(); + +} // namespace mlx::core::metal +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-array.h b/Source/Cmlx/include-framework/mlx-c-array.h new file mode 100644 index 00000000..46fcdbdc --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-array.h @@ -0,0 +1,379 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_ARRAY_H +#define MLX_ARRAY_H + +#include + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_array Array + * MLX N-dimensional array object. + */ +/**@{*/ + +/** + * A N-dimensional array object. + */ +typedef struct mlx_array_ { + void* ctx; +} mlx_array; + +static mlx_array mlx_array_empty; + +/** + * Array element type. + */ +typedef enum mlx_dtype_ { + MLX_BOOL, + MLX_UINT8, + MLX_UINT16, + MLX_UINT32, + MLX_UINT64, + MLX_INT8, + MLX_INT16, + MLX_INT32, + MLX_INT64, + MLX_FLOAT16, + MLX_FLOAT32, + MLX_FLOAT64, + MLX_BFLOAT16, + MLX_COMPLEX64, +} mlx_dtype; + +/** + * Size of given mlx_dtype datatype in bytes. + */ +size_t mlx_dtype_size(mlx_dtype dtype); + +/** + * Get array description. + */ +int mlx_array_tostring(mlx_string* str, const mlx_array arr); + +/** + * New empty array. + */ +mlx_array mlx_array_new(void); + +/** + * Free an array. + */ +int mlx_array_free(mlx_array arr); + +/** + * New array from a bool scalar. + */ +mlx_array mlx_array_new_bool(bool val); +/** + * New array from a int scalar. + */ +mlx_array mlx_array_new_int(int val); +/** + * New array from a float32 scalar. + */ +mlx_array mlx_array_new_float32(float val); +/** + * New array from a float scalar. + * Same as float32. + */ +mlx_array mlx_array_new_float(float val); +/** + * New array from a float64 scalar. + */ +mlx_array mlx_array_new_float64(double val); +/** + * New array from a double scalar. + * Same as float64. + */ +mlx_array mlx_array_new_double(double val); +/** + * New array from a complex scalar. + */ +mlx_array mlx_array_new_complex(float real_val, float imag_val); +/** + * New array from existing buffer. + * @param data A buffer which will be copied. + * @param shape Shape of the array. + * @param dim Number of dimensions (size of `shape`). + * @param dtype Type of array elements. + */ +mlx_array mlx_array_new_data( + const void* data, + const int* shape, + int dim, + mlx_dtype dtype); +/** + * Set array to provided src array. + */ +int mlx_array_set(mlx_array* arr, const mlx_array src); +/** + * Set array to a bool scalar. + */ +int mlx_array_set_bool(mlx_array* arr, bool val); +/** + * Set array to a int scalar. + */ +int mlx_array_set_int(mlx_array* arr, int val); +/** + * Set array to a float32 scalar. + */ +int mlx_array_set_float32(mlx_array* arr, float val); +/** + * Set array to a float scalar. + */ +int mlx_array_set_float(mlx_array* arr, float val); +/** + * Set array to a float64 scalar. + */ +int mlx_array_set_float64(mlx_array* arr, double val); +/** + * Set array to a double scalar. + */ +int mlx_array_set_double(mlx_array* arr, double val); +/** + * Set array to a complex scalar. + */ +int mlx_array_set_complex(mlx_array* arr, float real_val, float imag_val); +/** + * Set array to specified data and shape. + * @param arr Destination array. + * @param data A buffer which will be copied. + * @param shape Shape of the array. + * @param dim Number of dimensions (size of `shape`). + * @param dtype Type of array elements. + */ +int mlx_array_set_data( + mlx_array* arr, + const void* data, + const int* shape, + int dim, + mlx_dtype dtype); + +/** + * The size of the array's datatype in bytes. + */ +size_t mlx_array_itemsize(const mlx_array arr); +/** + * Number of elements in the array. + */ +size_t mlx_array_size(const mlx_array arr); +/** + * The number of bytes in the array. + */ +size_t mlx_array_nbytes(const mlx_array arr); +/** + * The array's dimension. + */ +size_t mlx_array_ndim(const mlx_array arr); +/** + * The shape of the array. + * Returns: a pointer to the sizes of each dimension. + */ +const int* mlx_array_shape(const mlx_array arr); +/** + * The strides of the array. + * Returns: a pointer to the sizes of each dimension. + */ +const size_t* mlx_array_strides(const mlx_array arr); +/** + * The shape of the array in a particular dimension. + */ +int mlx_array_dim(const mlx_array arr, int dim); +/** + * The array element type. + */ +mlx_dtype mlx_array_dtype(const mlx_array arr); + +/** + * Evaluate the array. + */ +int mlx_array_eval(mlx_array arr); + +/** + * Access the value of a scalar array. + */ +int mlx_array_item_bool(bool* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_uint8(uint8_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_uint16(uint16_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_uint32(uint32_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_uint64(uint64_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_int8(int8_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_int16(int16_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_int32(int32_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_int64(int64_t* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_float32(float* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_float64(double* res, const mlx_array arr); +/** + * Access the value of a scalar array. + */ +int mlx_array_item_complex64(float _Complex* res, const mlx_array arr); + +#ifdef HAS_FLOAT16 +/** + * Access the value of a scalar array. + */ +int mlx_array_item_float16(float16_t* res, const mlx_array arr); +#endif + +#ifdef HAS_BFLOAT16 +/** + * Access the value of a scalar array. + */ +int mlx_array_item_bfloat16(bfloat16_t* res, const mlx_array arr); +#endif + +/** + * Returns a pointer to the array data, cast to `bool*`. + * Array must be evaluated, otherwise returns NULL. + */ +const bool* mlx_array_data_bool(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `uint8_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const uint8_t* mlx_array_data_uint8(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `uint16_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const uint16_t* mlx_array_data_uint16(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `uint32_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const uint32_t* mlx_array_data_uint32(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `uint64_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const uint64_t* mlx_array_data_uint64(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `int8_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const int8_t* mlx_array_data_int8(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `int16_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const int16_t* mlx_array_data_int16(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `int32_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const int32_t* mlx_array_data_int32(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `int64_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const int64_t* mlx_array_data_int64(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `float32*`. + * Array must be evaluated, otherwise returns NULL. + */ +const float* mlx_array_data_float32(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `float64*`. + * Array must be evaluated, otherwise returns NULL. + */ +const double* mlx_array_data_float64(const mlx_array arr); +/** + * Returns a pointer to the array data, cast to `_Complex*`. + * Array must be evaluated, otherwise returns NULL. + */ +const float _Complex* mlx_array_data_complex64(const mlx_array arr); + +#ifdef HAS_FLOAT16 +/** + * Returns a pointer to the array data, cast to `float16_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const float16_t* mlx_array_data_float16(const mlx_array arr); +#endif + +#ifdef HAS_BFLOAT16 +/** + * Returns a pointer to the array data, cast to `bfloat16_t*`. + * Array must be evaluated, otherwise returns NULL. + */ +const bfloat16_t* mlx_array_data_bfloat16(const mlx_array arr); +#endif + +/** + * Check if the array is available. + * Internal function: use at your own risk. + */ +int _mlx_array_is_available(bool* res, const mlx_array arr); + +/** + * Wait on the array to be available. After this `_mlx_array_is_available` + * returns `true`. Internal function: use at your own risk. + */ +int _mlx_array_wait(const mlx_array arr); + +/** + * Whether the array is contiguous in memory. + * Internal function: use at your own risk. + */ +int _mlx_array_is_contiguous(bool* res, const mlx_array arr); + +/** + * Whether the array's rows are contiguous in memory. + * Internal function: use at your own risk. + */ +int _mlx_array_is_row_contiguous(bool* res, const mlx_array arr); + +/** + * Whether the array's columns are contiguous in memory. + * Internal function: use at your own risk. + */ +int _mlx_array_is_col_contiguous(bool* res, const mlx_array arr); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-closure.h b/Source/Cmlx/include-framework/mlx-c-closure.h new file mode 100644 index 00000000..b6f903f5 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-closure.h @@ -0,0 +1,193 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_CLOSURE_H +#define MLX_CLOSURE_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_closure Closures + * MLX closure objects. + */ +/**@{*/ + +typedef struct mlx_closure_ { + void* ctx; +} mlx_closure; +mlx_closure mlx_closure_new(void); +int mlx_closure_free(mlx_closure cls); +mlx_closure mlx_closure_new_func( + int (*fun)(mlx_vector_array*, const mlx_vector_array)); +mlx_closure mlx_closure_new_func_payload( + int (*fun)(mlx_vector_array*, const mlx_vector_array, void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_set(mlx_closure* cls, const mlx_closure src); +int mlx_closure_apply( + mlx_vector_array* res, + mlx_closure cls, + const mlx_vector_array input); + +mlx_closure mlx_closure_new_unary(int (*fun)(mlx_array*, const mlx_array)); + +typedef struct mlx_closure_kwargs_ { + void* ctx; +} mlx_closure_kwargs; +mlx_closure_kwargs mlx_closure_kwargs_new(void); +int mlx_closure_kwargs_free(mlx_closure_kwargs cls); +mlx_closure_kwargs mlx_closure_kwargs_new_func(int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_map_string_to_array)); +mlx_closure_kwargs mlx_closure_kwargs_new_func_payload( + int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_map_string_to_array, + void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_kwargs_set( + mlx_closure_kwargs* cls, + const mlx_closure_kwargs src); +int mlx_closure_kwargs_apply( + mlx_vector_array* res, + mlx_closure_kwargs cls, + const mlx_vector_array input_0, + const mlx_map_string_to_array input_1); + +typedef struct mlx_closure_value_and_grad_ { + void* ctx; +} mlx_closure_value_and_grad; +mlx_closure_value_and_grad mlx_closure_value_and_grad_new(void); +int mlx_closure_value_and_grad_free(mlx_closure_value_and_grad cls); +mlx_closure_value_and_grad mlx_closure_value_and_grad_new_func( + int (*fun)(mlx_vector_array*, mlx_vector_array*, const mlx_vector_array)); +mlx_closure_value_and_grad mlx_closure_value_and_grad_new_func_payload( + int (*fun)( + mlx_vector_array*, + mlx_vector_array*, + const mlx_vector_array, + void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_value_and_grad_set( + mlx_closure_value_and_grad* cls, + const mlx_closure_value_and_grad src); +int mlx_closure_value_and_grad_apply( + mlx_vector_array* res_0, + mlx_vector_array* res_1, + mlx_closure_value_and_grad cls, + const mlx_vector_array input); + +typedef struct mlx_closure_custom_ { + void* ctx; +} mlx_closure_custom; +mlx_closure_custom mlx_closure_custom_new(void); +int mlx_closure_custom_free(mlx_closure_custom cls); +mlx_closure_custom mlx_closure_custom_new_func(int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_vector_array, + const mlx_vector_array)); +mlx_closure_custom mlx_closure_custom_new_func_payload( + int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_vector_array, + const mlx_vector_array, + void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_custom_set( + mlx_closure_custom* cls, + const mlx_closure_custom src); +int mlx_closure_custom_apply( + mlx_vector_array* res, + mlx_closure_custom cls, + const mlx_vector_array input_0, + const mlx_vector_array input_1, + const mlx_vector_array input_2); + +typedef struct mlx_closure_custom_jvp_ { + void* ctx; +} mlx_closure_custom_jvp; +mlx_closure_custom_jvp mlx_closure_custom_jvp_new(void); +int mlx_closure_custom_jvp_free(mlx_closure_custom_jvp cls); +mlx_closure_custom_jvp mlx_closure_custom_jvp_new_func(int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_vector_array, + const int*, + size_t _num)); +mlx_closure_custom_jvp mlx_closure_custom_jvp_new_func_payload( + int (*fun)( + mlx_vector_array*, + const mlx_vector_array, + const mlx_vector_array, + const int*, + size_t _num, + void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_custom_jvp_set( + mlx_closure_custom_jvp* cls, + const mlx_closure_custom_jvp src); +int mlx_closure_custom_jvp_apply( + mlx_vector_array* res, + mlx_closure_custom_jvp cls, + const mlx_vector_array input_0, + const mlx_vector_array input_1, + const int* input_2, + size_t input_2_num); + +typedef struct mlx_closure_custom_vmap_ { + void* ctx; +} mlx_closure_custom_vmap; +mlx_closure_custom_vmap mlx_closure_custom_vmap_new(void); +int mlx_closure_custom_vmap_free(mlx_closure_custom_vmap cls); +mlx_closure_custom_vmap mlx_closure_custom_vmap_new_func(int (*fun)( + mlx_vector_array*, + mlx_vector_int*, + const mlx_vector_array, + const int*, + size_t _num)); +mlx_closure_custom_vmap mlx_closure_custom_vmap_new_func_payload( + int (*fun)( + mlx_vector_array*, + mlx_vector_int*, + const mlx_vector_array, + const int*, + size_t _num, + void*), + void* payload, + void (*dtor)(void*)); +int mlx_closure_custom_vmap_set( + mlx_closure_custom_vmap* cls, + const mlx_closure_custom_vmap src); +int mlx_closure_custom_vmap_apply( + mlx_vector_array* res_0, + mlx_vector_int* res_1, + mlx_closure_custom_vmap cls, + const mlx_vector_array input_0, + const int* input_1, + size_t input_1_num); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-compile.h b/Source/Cmlx/include-framework/mlx-c-compile.h new file mode 100644 index 00000000..c7bd9917 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-compile.h @@ -0,0 +1,55 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_COMPILE_H +#define MLX_COMPILE_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup compile Compilation operations + */ +/**@{*/ +typedef enum mlx_compile_mode_ { + MLX_COMPILE_MODE_DISABLED, + MLX_COMPILE_MODE_NO_SIMPLIFY, + MLX_COMPILE_MODE_NO_FUSE, + MLX_COMPILE_MODE_ENABLED +} mlx_compile_mode; +int mlx_compile(mlx_closure* res, const mlx_closure fun, bool shapeless); +int mlx_detail_compile( + mlx_closure* res, + const mlx_closure fun, + uintptr_t fun_id, + bool shapeless, + const uint64_t* constants, + size_t constants_num); +int mlx_detail_compile_clear_cache(void); +int mlx_detail_compile_erase(uintptr_t fun_id); +int mlx_disable_compile(void); +int mlx_enable_compile(void); +int mlx_set_compile_mode(mlx_compile_mode mode); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-device.h b/Source/Cmlx/include-framework/mlx-c-device.h new file mode 100644 index 00000000..5cc00e2c --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-device.h @@ -0,0 +1,80 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_DEVICE_H +#define MLX_DEVICE_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_device Device + * MLX device object. + */ +/**@{*/ + +/** + * A MLX device object. + */ +typedef struct mlx_device_ { + void* ctx; +} mlx_device; + +/** + * Device type. + */ +typedef enum mlx_device_type_ { MLX_CPU, MLX_GPU } mlx_device_type; + +/** + * Returns a new empty device. + */ +mlx_device mlx_device_new(void); + +/** + * Returns a new device of specified `type`, with specified `index`. + */ +mlx_device mlx_device_new_type(mlx_device_type type, int index); +/** + * Free a device. + */ +int mlx_device_free(mlx_device dev); +/** + * Set device to provided src device. + */ +int mlx_device_set(mlx_device* dev, const mlx_device src); +/** + * Get device description. + */ +int mlx_device_tostring(mlx_string* str, mlx_device dev); +/** + * Check if devices are the same. + */ +bool mlx_device_equal(mlx_device lhs, mlx_device rhs); +/** + * Returns the index of the device. + */ +int mlx_device_get_index(int* index, mlx_device dev); +/** + * Returns the type of the device. + */ +int mlx_device_get_type(mlx_device_type* type, mlx_device dev); +/** + * Returns the default MLX device. + */ +int mlx_get_default_device(mlx_device* dev); +/** + * Set the default MLX device. + */ +int mlx_set_default_device(mlx_device dev); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-distributed.h b/Source/Cmlx/include-framework/mlx-c-distributed.h new file mode 100644 index 00000000..b049677b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-distributed.h @@ -0,0 +1,76 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_DISTRIBUTED_H +#define MLX_DISTRIBUTED_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup distributed Distributed collectives + */ +/**@{*/ +int mlx_distributed_all_gather( + mlx_array* res, + const mlx_array x, + const mlx_distributed_group group /* may be null */, + const mlx_stream S); +int mlx_distributed_all_max( + mlx_array* res, + const mlx_array x, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +int mlx_distributed_all_min( + mlx_array* res, + const mlx_array x, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +int mlx_distributed_all_sum( + mlx_array* res, + const mlx_array x, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +int mlx_distributed_recv( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + int src, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +int mlx_distributed_recv_like( + mlx_array* res, + const mlx_array x, + int src, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +int mlx_distributed_send( + mlx_array* res, + const mlx_array x, + int dst, + const mlx_distributed_group group /* may be null */, + const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-distributed_group.h b/Source/Cmlx/include-framework/mlx-c-distributed_group.h new file mode 100644 index 00000000..b57c54f6 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-distributed_group.h @@ -0,0 +1,58 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_DISTRIBUTED_GROUP_H +#define MLX_DISTRIBUTED_GROUP_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_distributed_group MLX distributed + */ +/**@{*/ + +/** + * A MLX distributed group object. + */ +typedef struct mlx_distributed_group_ { + void* ctx; +} mlx_distributed_group; + +/** + * Get the rank. + */ +int mlx_distributed_group_rank(mlx_distributed_group group); + +/** + * Get the group size. + */ +int mlx_distributed_group_size(mlx_distributed_group group); + +/** + * Split the group. + */ +mlx_distributed_group +mlx_distributed_group_split(mlx_distributed_group group, int color, int key); + +/** + * Check if distributed is available. + */ +bool mlx_distributed_is_available(void); + +/** + * Initialize distributed. + */ +mlx_distributed_group mlx_distributed_init(bool strict); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-error.h b/Source/Cmlx/include-framework/mlx-c-error.h new file mode 100644 index 00000000..8c063a40 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-error.h @@ -0,0 +1,41 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_ERROR_H +#define MLX_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_error Error management + */ +/**@{*/ + +typedef void (*mlx_error_handler_func)(const char* msg, void* data); + +/** + * Set the error handler. + */ +void mlx_set_error_handler( + mlx_error_handler_func handler, + void* data, + void (*dtor)(void*)); + +/** + * Throw an error. + */ +void _mlx_error(const char* file, const int line, const char* fmt, ...); + +/** + * Throw an error. Macro which passes file name and line number to _mlx_error(). + */ +#define mlx_error(...) _mlx_error(__FILE__, __LINE__, __VA_ARGS__) + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-export.h b/Source/Cmlx/include-framework/mlx-c-export.h new file mode 100644 index 00000000..96ab788a --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-export.h @@ -0,0 +1,75 @@ +/* Copyright © 2023-2025 Apple Inc. */ + +#ifndef MLX_EXPORT_H +#define MLX_EXPORT_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup export Function serialization + */ +/**@{*/ +int mlx_export_function( + const char* file, + const mlx_closure fun, + const mlx_vector_array args, + bool shapeless); +int mlx_export_function_kwargs( + const char* file, + const mlx_closure_kwargs fun, + const mlx_vector_array args, + const mlx_map_string_to_array kwargs, + bool shapeless); + +typedef struct mlx_function_exporter_ { + void* ctx; +} mlx_function_exporter; +mlx_function_exporter mlx_function_exporter_new( + const char* file, + const mlx_closure fun, + bool shapeless); +int mlx_function_exporter_free(mlx_function_exporter xfunc); +int mlx_function_exporter_apply( + const mlx_function_exporter xfunc, + const mlx_vector_array args); +int mlx_function_exporter_apply_kwargs( + const mlx_function_exporter xfunc, + const mlx_vector_array args, + const mlx_map_string_to_array kwargs); + +typedef struct mlx_imported_function_ { + void* ctx; +} mlx_imported_function; +mlx_imported_function mlx_imported_function_new(const char* file); +int mlx_imported_function_free(mlx_imported_function xfunc); +int mlx_imported_function_apply( + mlx_vector_array* res, + const mlx_imported_function xfunc, + const mlx_vector_array args); +int mlx_imported_function_apply_kwargs( + mlx_vector_array* res, + const mlx_imported_function xfunc, + const mlx_vector_array args, + const mlx_map_string_to_array kwargs); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-fast.h b/Source/Cmlx/include-framework/mlx-c-fast.h new file mode 100644 index 00000000..dca069d0 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-fast.h @@ -0,0 +1,195 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_FAST_H +#define MLX_FAST_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup fast Fast custom operations + */ +/**@{*/ + +typedef struct mlx_fast_cuda_kernel_config_ { + void* ctx; +} mlx_fast_cuda_kernel_config; +mlx_fast_cuda_kernel_config mlx_fast_cuda_kernel_config_new(void); +void mlx_fast_cuda_kernel_config_free(mlx_fast_cuda_kernel_config cls); + +int mlx_fast_cuda_kernel_config_add_output_arg( + mlx_fast_cuda_kernel_config cls, + const int* shape, + size_t size, + mlx_dtype dtype); +int mlx_fast_cuda_kernel_config_set_grid( + mlx_fast_cuda_kernel_config cls, + int grid1, + int grid2, + int grid3); +int mlx_fast_cuda_kernel_config_set_thread_group( + mlx_fast_cuda_kernel_config cls, + int thread1, + int thread2, + int thread3); +int mlx_fast_cuda_kernel_config_set_init_value( + mlx_fast_cuda_kernel_config cls, + float value); +int mlx_fast_cuda_kernel_config_set_verbose( + mlx_fast_cuda_kernel_config cls, + bool verbose); +int mlx_fast_cuda_kernel_config_add_template_arg_dtype( + mlx_fast_cuda_kernel_config cls, + const char* name, + mlx_dtype dtype); +int mlx_fast_cuda_kernel_config_add_template_arg_int( + mlx_fast_cuda_kernel_config cls, + const char* name, + int value); +int mlx_fast_cuda_kernel_config_add_template_arg_bool( + mlx_fast_cuda_kernel_config cls, + const char* name, + bool value); + +typedef struct mlx_fast_cuda_kernel_ { + void* ctx; +} mlx_fast_cuda_kernel; + +mlx_fast_cuda_kernel mlx_fast_cuda_kernel_new( + const char* name, + const mlx_vector_string input_names, + const mlx_vector_string output_names, + const char* source, + const char* header, + bool ensure_row_contiguous, + int shared_memory); + +void mlx_fast_cuda_kernel_free(mlx_fast_cuda_kernel cls); + +int mlx_fast_cuda_kernel_apply( + mlx_vector_array* outputs, + mlx_fast_cuda_kernel cls, + const mlx_vector_array inputs, + const mlx_fast_cuda_kernel_config config, + const mlx_stream stream); + +int mlx_fast_layer_norm( + mlx_array* res, + const mlx_array x, + const mlx_array weight /* may be null */, + const mlx_array bias /* may be null */, + float eps, + const mlx_stream s); + +typedef struct mlx_fast_metal_kernel_config_ { + void* ctx; +} mlx_fast_metal_kernel_config; +mlx_fast_metal_kernel_config mlx_fast_metal_kernel_config_new(void); +void mlx_fast_metal_kernel_config_free(mlx_fast_metal_kernel_config cls); + +int mlx_fast_metal_kernel_config_add_output_arg( + mlx_fast_metal_kernel_config cls, + const int* shape, + size_t size, + mlx_dtype dtype); +int mlx_fast_metal_kernel_config_set_grid( + mlx_fast_metal_kernel_config cls, + int grid1, + int grid2, + int grid3); +int mlx_fast_metal_kernel_config_set_thread_group( + mlx_fast_metal_kernel_config cls, + int thread1, + int thread2, + int thread3); +int mlx_fast_metal_kernel_config_set_init_value( + mlx_fast_metal_kernel_config cls, + float value); +int mlx_fast_metal_kernel_config_set_verbose( + mlx_fast_metal_kernel_config cls, + bool verbose); +int mlx_fast_metal_kernel_config_add_template_arg_dtype( + mlx_fast_metal_kernel_config cls, + const char* name, + mlx_dtype dtype); +int mlx_fast_metal_kernel_config_add_template_arg_int( + mlx_fast_metal_kernel_config cls, + const char* name, + int value); +int mlx_fast_metal_kernel_config_add_template_arg_bool( + mlx_fast_metal_kernel_config cls, + const char* name, + bool value); + +typedef struct mlx_fast_metal_kernel_ { + void* ctx; +} mlx_fast_metal_kernel; + +mlx_fast_metal_kernel mlx_fast_metal_kernel_new( + const char* name, + const mlx_vector_string input_names, + const mlx_vector_string output_names, + const char* source, + const char* header, + bool ensure_row_contiguous, + bool atomic_outputs); + +void mlx_fast_metal_kernel_free(mlx_fast_metal_kernel cls); + +int mlx_fast_metal_kernel_apply( + mlx_vector_array* outputs, + mlx_fast_metal_kernel cls, + const mlx_vector_array inputs, + const mlx_fast_metal_kernel_config config, + const mlx_stream stream); + +int mlx_fast_rms_norm( + mlx_array* res, + const mlx_array x, + const mlx_array weight /* may be null */, + float eps, + const mlx_stream s); +int mlx_fast_rope( + mlx_array* res, + const mlx_array x, + int dims, + bool traditional, + mlx_optional_float base, + float scale, + int offset, + const mlx_array freqs /* may be null */, + const mlx_stream s); +int mlx_fast_scaled_dot_product_attention( + mlx_array* res, + const mlx_array queries, + const mlx_array keys, + const mlx_array values, + float scale, + const char* mask_mode, + const mlx_vector_array mask_arrs, + const mlx_array sinks /* may be null */, + const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-fft.h b/Source/Cmlx/include-framework/mlx-c-fft.h new file mode 100644 index 00000000..6726de1b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-fft.h @@ -0,0 +1,136 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_FFT_H +#define MLX_FFT_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup fft FFT operations + */ +/**@{*/ +int mlx_fft_fft( + mlx_array* res, + const mlx_array a, + int n, + int axis, + const mlx_stream s); +int mlx_fft_fft2( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_fftn( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_fftshift( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_ifft( + mlx_array* res, + const mlx_array a, + int n, + int axis, + const mlx_stream s); +int mlx_fft_ifft2( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_ifftn( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_ifftshift( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_irfft( + mlx_array* res, + const mlx_array a, + int n, + int axis, + const mlx_stream s); +int mlx_fft_irfft2( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_irfftn( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_rfft( + mlx_array* res, + const mlx_array a, + int n, + int axis, + const mlx_stream s); +int mlx_fft_rfft2( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_fft_rfftn( + mlx_array* res, + const mlx_array a, + const int* n, + size_t n_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-half.h b/Source/Cmlx/include-framework/mlx-c-half.h new file mode 100644 index 00000000..958d555f --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-half.h @@ -0,0 +1,26 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_HALF_H +#define MLX_HALF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) || defined(__aarch64__) +#define HAS_FLOAT16 +#include +typedef __fp16 float16_t; +#endif + +#if defined(__ARM_FEATURE_BF16) || defined(__aarch64__) +#define HAS_BFLOAT16 +#include +typedef __bf16 bfloat16_t; +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-io.h b/Source/Cmlx/include-framework/mlx-c-io.h new file mode 100644 index 00000000..f54da8e2 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-io.h @@ -0,0 +1,61 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_IO_H +#define MLX_IO_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup io IO operations + */ +/**@{*/ +int mlx_load_reader( + mlx_array* res, + mlx_io_reader in_stream, + const mlx_stream s); +int mlx_load(mlx_array* res, const char* file, const mlx_stream s); +int mlx_load_safetensors_reader( + mlx_map_string_to_array* res_0, + mlx_map_string_to_string* res_1, + mlx_io_reader in_stream, + const mlx_stream s); +int mlx_load_safetensors( + mlx_map_string_to_array* res_0, + mlx_map_string_to_string* res_1, + const char* file, + const mlx_stream s); +int mlx_save_writer(mlx_io_writer out_stream, const mlx_array a); +int mlx_save(const char* file, const mlx_array a); +int mlx_save_safetensors_writer( + mlx_io_writer in_stream, + const mlx_map_string_to_array param, + const mlx_map_string_to_string metadata); +int mlx_save_safetensors( + const char* file, + const mlx_map_string_to_array param, + const mlx_map_string_to_string metadata); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-io_types.h b/Source/Cmlx/include-framework/mlx-c-io_types.h new file mode 100644 index 00000000..52fc7fbc --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-io_types.h @@ -0,0 +1,104 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_IO_TYPES_H +#define MLX_IO_TYPES_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_io_types IO Types + * MLX IO type objects. + */ +/**@{*/ + +/** + * A MLX IO reader object. + */ +typedef struct mlx_io_reader_ { + void* ctx; +} mlx_io_reader; +/** + * A MLX IO writer object. + */ +typedef struct mlx_io_writer_ { + void* ctx; +} mlx_io_writer; + +/** + * Virtual table for custom IO reader and writer objects. + */ +typedef struct mlx_io_vtable_ { + bool (*is_open)(void*); + bool (*good)(void*); + size_t (*tell)(void*); + void (*seek)(void*, int64_t off, int whence); + void (*read)(void*, char* data, size_t n); + void (*read_at_offset)(void*, char* data, size_t n, size_t off); + void (*write)(void*, const char* data, size_t n); + const char* (*label)(void*); + void (*free)(void*); +} mlx_io_vtable; + +/** + * Returns a new custom IO reader. + * `vtable` operates on user descriptor `desc`. + */ +mlx_io_reader mlx_io_reader_new(void* desc, mlx_io_vtable vtable); + +/** + * Get IO reader user descriptor. + */ +int mlx_io_reader_descriptor(void** desc_, mlx_io_reader io); + +/** + * Get IO reader description. + */ +int mlx_io_reader_tostring(mlx_string* str_, mlx_io_reader io); + +/** + * Free IO reader. + * + * Note that MLX arrays are lazily evaluated, so the underlying object may + * be not freed right away. The ``free()`` callback from ``mlx_io_vtable`` + * will be called when the underlying object is actually freed. + */ +int mlx_io_reader_free(mlx_io_reader io); + +/** + * Returns a new custom IO writer. + * `vtable` operates on user descriptor `desc`. + */ +mlx_io_writer mlx_io_writer_new(void* desc, mlx_io_vtable vtable); + +/** + * Get IO writer user descriptor. + */ +int mlx_io_writer_descriptor(void** desc_, mlx_io_writer io); + +/** + * Get IO writer description. + */ +int mlx_io_writer_tostring(mlx_string* str_, mlx_io_writer io); + +/** + * Free IO writer. + * + * Note that MLX arrays are lazily evaluated, so the underlying object may + * be not freed right away. The ``free()`` callback from ``mlx_io_vtable`` + * will be called when the underlying object is actually freed. + */ +int mlx_io_writer_free(mlx_io_writer io); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-linalg.h b/Source/Cmlx/include-framework/mlx-c-linalg.h new file mode 100644 index 00000000..50ea7170 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-linalg.h @@ -0,0 +1,126 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_LINALG_H +#define MLX_LINALG_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup linalg Linear algebra operations + */ +/**@{*/ +int mlx_linalg_cholesky( + mlx_array* res, + const mlx_array a, + bool upper, + const mlx_stream s); +int mlx_linalg_cholesky_inv( + mlx_array* res, + const mlx_array a, + bool upper, + const mlx_stream s); +int mlx_linalg_cross( + mlx_array* res, + const mlx_array a, + const mlx_array b, + int axis, + const mlx_stream s); +int mlx_linalg_eig( + mlx_array* res_0, + mlx_array* res_1, + const mlx_array a, + const mlx_stream s); +int mlx_linalg_eigh( + mlx_array* res_0, + mlx_array* res_1, + const mlx_array a, + const char* UPLO, + const mlx_stream s); +int mlx_linalg_eigvals(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_linalg_eigvalsh( + mlx_array* res, + const mlx_array a, + const char* UPLO, + const mlx_stream s); +int mlx_linalg_inv(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_linalg_lu(mlx_vector_array* res, const mlx_array a, const mlx_stream s); +int mlx_linalg_lu_factor( + mlx_array* res_0, + mlx_array* res_1, + const mlx_array a, + const mlx_stream s); +int mlx_linalg_norm( + mlx_array* res, + const mlx_array a, + double ord, + const int* axis /* may be null */, + size_t axis_num, + bool keepdims, + const mlx_stream s); +int mlx_linalg_norm_matrix( + mlx_array* res, + const mlx_array a, + const char* ord, + const int* axis /* may be null */, + size_t axis_num, + bool keepdims, + const mlx_stream s); +int mlx_linalg_norm_l2( + mlx_array* res, + const mlx_array a, + const int* axis /* may be null */, + size_t axis_num, + bool keepdims, + const mlx_stream s); +int mlx_linalg_pinv(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_linalg_qr( + mlx_array* res_0, + mlx_array* res_1, + const mlx_array a, + const mlx_stream s); +int mlx_linalg_solve( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_linalg_solve_triangular( + mlx_array* res, + const mlx_array a, + const mlx_array b, + bool upper, + const mlx_stream s); +int mlx_linalg_svd( + mlx_vector_array* res, + const mlx_array a, + bool compute_uv, + const mlx_stream s); +int mlx_linalg_tri_inv( + mlx_array* res, + const mlx_array a, + bool upper, + const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-map.h b/Source/Cmlx/include-framework/mlx-c-map.h new file mode 100644 index 00000000..b921133d --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-map.h @@ -0,0 +1,149 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_MAP_H +#define MLX_MAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_map Maps + * MLX map objects. + */ +/**@{*/ + +/** + * A string-to-array map + */ +typedef struct mlx_map_string_to_array_ { + void* ctx; +} mlx_map_string_to_array; + +/** + * Returns a new empty string-to-array map. + */ +mlx_map_string_to_array mlx_map_string_to_array_new(void); +/** + * Set map to provided src map. + */ +int mlx_map_string_to_array_set( + mlx_map_string_to_array* map, + const mlx_map_string_to_array src); +/** + * Free a string-to-array map. + */ +int mlx_map_string_to_array_free(mlx_map_string_to_array map); +/** + * Insert a new `value` at the specified `key` in the map. + */ +int mlx_map_string_to_array_insert( + mlx_map_string_to_array map, + const char* key, + const mlx_array value); +/** + * Returns the value indexed at the specified `key` in the map. + */ +int mlx_map_string_to_array_get( + mlx_array* value, + const mlx_map_string_to_array map, + const char* key); + +/** + * An iterator over a string-to-array map. + */ +typedef struct mlx_map_string_to_array_iterator_ { + void* ctx; + void* map_ctx; +} mlx_map_string_to_array_iterator; +/** + * Returns a new iterator over the given map. + */ +mlx_map_string_to_array_iterator mlx_map_string_to_array_iterator_new( + mlx_map_string_to_array map); +/** + * Free iterator. + */ +int mlx_map_string_to_array_iterator_free(mlx_map_string_to_array_iterator it); +/** + * Increment iterator. + */ +int mlx_map_string_to_array_iterator_next( + const char** key, + mlx_array* value, + mlx_map_string_to_array_iterator it); + +/** + * A string-to-string map + */ +typedef struct mlx_map_string_to_string_ { + void* ctx; +} mlx_map_string_to_string; + +/** + * Returns a new empty string-to-string map. + */ +mlx_map_string_to_string mlx_map_string_to_string_new(void); +/** + * Set map to provided src map. + */ +int mlx_map_string_to_string_set( + mlx_map_string_to_string* map, + const mlx_map_string_to_string src); +/** + * Free a string-to-string map. + */ +int mlx_map_string_to_string_free(mlx_map_string_to_string map); +/** + * Insert a new `value` at the specified `key` in the map. + */ +int mlx_map_string_to_string_insert( + mlx_map_string_to_string map, + const char* key, + const char* value); +/** + * Returns the value indexed at the specified `key` in the map. + */ +int mlx_map_string_to_string_get( + const char** value, + const mlx_map_string_to_string map, + const char* key); + +/** + * An iterator over a string-to-string map. + */ +typedef struct mlx_map_string_to_string_iterator_ { + void* ctx; + void* map_ctx; +} mlx_map_string_to_string_iterator; +/** + * Returns a new iterator over the given map. + */ +mlx_map_string_to_string_iterator mlx_map_string_to_string_iterator_new( + mlx_map_string_to_string map); +/** + * Free iterator. + */ +int mlx_map_string_to_string_iterator_free( + mlx_map_string_to_string_iterator it); +/** + * Increment iterator. + */ +int mlx_map_string_to_string_iterator_next( + const char** key, + const char** value, + mlx_map_string_to_string_iterator it); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-memory.h b/Source/Cmlx/include-framework/mlx-c-memory.h new file mode 100644 index 00000000..5f59c0d1 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-memory.h @@ -0,0 +1,45 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_MEMORY_H +#define MLX_MEMORY_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup memory Memory operations + */ +/**@{*/ +int mlx_clear_cache(void); +int mlx_get_active_memory(size_t* res); +int mlx_get_cache_memory(size_t* res); +int mlx_get_memory_limit(size_t* res); +int mlx_get_peak_memory(size_t* res); +int mlx_reset_peak_memory(void); +int mlx_set_cache_limit(size_t* res, size_t limit); +int mlx_set_memory_limit(size_t* res, size_t limit); +int mlx_set_wired_limit(size_t* res, size_t limit); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-metal.h b/Source/Cmlx/include-framework/mlx-c-metal.h new file mode 100644 index 00000000..ad61eacd --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-metal.h @@ -0,0 +1,48 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_METAL_H +#define MLX_METAL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup metal Metal specific operations + */ +/**@{*/ + +typedef struct mlx_metal_device_info_t_ { + char architecture[256]; + size_t max_buffer_length; + size_t max_recommended_working_set_size; + size_t memory_size; +} mlx_metal_device_info_t; +mlx_metal_device_info_t mlx_metal_device_info(void); + +int mlx_metal_is_available(bool* res); +int mlx_metal_start_capture(const char* path); +int mlx_metal_stop_capture(void); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-mlx.h b/Source/Cmlx/include-framework/mlx-c-mlx.h new file mode 100644 index 00000000..82b025fb --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-mlx.h @@ -0,0 +1,33 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_ALL_H +#define MLX_ALL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-ops.h b/Source/Cmlx/include-framework/mlx-c-ops.h new file mode 100644 index 00000000..79e68f2b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-ops.h @@ -0,0 +1,1155 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_OPS_H +#define MLX_OPS_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup ops Core array operations + */ +/**@{*/ +int mlx_abs(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_add( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_addmm( + mlx_array* res, + const mlx_array c, + const mlx_array a, + const mlx_array b, + float alpha, + float beta, + const mlx_stream s); +int mlx_all_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_all_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_all( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_allclose( + mlx_array* res, + const mlx_array a, + const mlx_array b, + double rtol, + double atol, + bool equal_nan, + const mlx_stream s); +int mlx_any_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_any_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_any( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_arange( + mlx_array* res, + double start, + double stop, + double step, + mlx_dtype dtype, + const mlx_stream s); +int mlx_arccos(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_arccosh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_arcsin(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_arcsinh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_arctan(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_arctan2( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_arctanh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_argmax_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_argmax( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_argmin_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_argmin( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_argpartition_axis( + mlx_array* res, + const mlx_array a, + int kth, + int axis, + const mlx_stream s); +int mlx_argpartition( + mlx_array* res, + const mlx_array a, + int kth, + const mlx_stream s); +int mlx_argsort_axis( + mlx_array* res, + const mlx_array a, + int axis, + const mlx_stream s); +int mlx_argsort(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_array_equal( + mlx_array* res, + const mlx_array a, + const mlx_array b, + bool equal_nan, + const mlx_stream s); +int mlx_as_strided( + mlx_array* res, + const mlx_array a, + const int* shape, + size_t shape_num, + const int64_t* strides, + size_t strides_num, + size_t offset, + const mlx_stream s); +int mlx_astype( + mlx_array* res, + const mlx_array a, + mlx_dtype dtype, + const mlx_stream s); +int mlx_atleast_1d(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_atleast_2d(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_atleast_3d(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_bitwise_and( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_bitwise_invert(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_bitwise_or( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_bitwise_xor( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_block_masked_mm( + mlx_array* res, + const mlx_array a, + const mlx_array b, + int block_size, + const mlx_array mask_out /* may be null */, + const mlx_array mask_lhs /* may be null */, + const mlx_array mask_rhs /* may be null */, + const mlx_stream s); +int mlx_broadcast_arrays( + mlx_vector_array* res, + const mlx_vector_array inputs, + const mlx_stream s); +int mlx_broadcast_to( + mlx_array* res, + const mlx_array a, + const int* shape, + size_t shape_num, + const mlx_stream s); +int mlx_ceil(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_clip( + mlx_array* res, + const mlx_array a, + const mlx_array a_min /* may be null */, + const mlx_array a_max /* may be null */, + const mlx_stream s); +int mlx_concatenate_axis( + mlx_array* res, + const mlx_vector_array arrays, + int axis, + const mlx_stream s); +int mlx_concatenate( + mlx_array* res, + const mlx_vector_array arrays, + const mlx_stream s); +int mlx_conjugate(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_contiguous( + mlx_array* res, + const mlx_array a, + bool allow_col_major, + const mlx_stream s); +int mlx_conv1d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride, + int padding, + int dilation, + int groups, + const mlx_stream s); +int mlx_conv2d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride_0, + int stride_1, + int padding_0, + int padding_1, + int dilation_0, + int dilation_1, + int groups, + const mlx_stream s); +int mlx_conv3d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride_0, + int stride_1, + int stride_2, + int padding_0, + int padding_1, + int padding_2, + int dilation_0, + int dilation_1, + int dilation_2, + int groups, + const mlx_stream s); +int mlx_conv_general( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + const int* stride, + size_t stride_num, + const int* padding_lo, + size_t padding_lo_num, + const int* padding_hi, + size_t padding_hi_num, + const int* kernel_dilation, + size_t kernel_dilation_num, + const int* input_dilation, + size_t input_dilation_num, + int groups, + bool flip, + const mlx_stream s); +int mlx_conv_transpose1d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride, + int padding, + int dilation, + int output_padding, + int groups, + const mlx_stream s); +int mlx_conv_transpose2d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride_0, + int stride_1, + int padding_0, + int padding_1, + int dilation_0, + int dilation_1, + int output_padding_0, + int output_padding_1, + int groups, + const mlx_stream s); +int mlx_conv_transpose3d( + mlx_array* res, + const mlx_array input, + const mlx_array weight, + int stride_0, + int stride_1, + int stride_2, + int padding_0, + int padding_1, + int padding_2, + int dilation_0, + int dilation_1, + int dilation_2, + int output_padding_0, + int output_padding_1, + int output_padding_2, + int groups, + const mlx_stream s); +int mlx_copy(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_cos(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_cosh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_cummax( + mlx_array* res, + const mlx_array a, + int axis, + bool reverse, + bool inclusive, + const mlx_stream s); +int mlx_cummin( + mlx_array* res, + const mlx_array a, + int axis, + bool reverse, + bool inclusive, + const mlx_stream s); +int mlx_cumprod( + mlx_array* res, + const mlx_array a, + int axis, + bool reverse, + bool inclusive, + const mlx_stream s); +int mlx_cumsum( + mlx_array* res, + const mlx_array a, + int axis, + bool reverse, + bool inclusive, + const mlx_stream s); +int mlx_degrees(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_depends( + mlx_vector_array* res, + const mlx_vector_array inputs, + const mlx_vector_array dependencies); +int mlx_dequantize( + mlx_array* res, + const mlx_array w, + const mlx_array scales, + const mlx_array biases /* may be null */, + int group_size, + int bits, + const char* mode, + const mlx_stream s); +int mlx_diag(mlx_array* res, const mlx_array a, int k, const mlx_stream s); +int mlx_diagonal( + mlx_array* res, + const mlx_array a, + int offset, + int axis1, + int axis2, + const mlx_stream s); +int mlx_divide( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_divmod( + mlx_vector_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_einsum( + mlx_array* res, + const char* subscripts, + const mlx_vector_array operands, + const mlx_stream s); +int mlx_equal( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_erf(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_erfinv(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_exp(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_expand_dims_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_expand_dims( + mlx_array* res, + const mlx_array a, + int axis, + const mlx_stream s); +int mlx_expm1(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_eye( + mlx_array* res, + int n, + int m, + int k, + mlx_dtype dtype, + const mlx_stream s); +int mlx_flatten( + mlx_array* res, + const mlx_array a, + int start_axis, + int end_axis, + const mlx_stream s); +int mlx_floor(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_floor_divide( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_full( + mlx_array* res, + const int* shape, + size_t shape_num, + const mlx_array vals, + mlx_dtype dtype, + const mlx_stream s); +int mlx_gather( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const int* axes, + size_t axes_num, + const int* slice_sizes, + size_t slice_sizes_num, + const mlx_stream s); +int mlx_gather_mm( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_array lhs_indices /* may be null */, + const mlx_array rhs_indices /* may be null */, + bool sorted_indices, + const mlx_stream s); +int mlx_gather_qmm( + mlx_array* res, + const mlx_array x, + const mlx_array w, + const mlx_array scales, + const mlx_array biases /* may be null */, + const mlx_array lhs_indices /* may be null */, + const mlx_array rhs_indices /* may be null */, + bool transpose, + int group_size, + int bits, + const char* mode, + bool sorted_indices, + const mlx_stream s); +int mlx_greater( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_greater_equal( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_hadamard_transform( + mlx_array* res, + const mlx_array a, + mlx_optional_float scale, + const mlx_stream s); +int mlx_identity(mlx_array* res, int n, mlx_dtype dtype, const mlx_stream s); +int mlx_imag(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_inner( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_isclose( + mlx_array* res, + const mlx_array a, + const mlx_array b, + double rtol, + double atol, + bool equal_nan, + const mlx_stream s); +int mlx_isfinite(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_isinf(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_isnan(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_isneginf(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_isposinf(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_kron( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_left_shift( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_less( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_less_equal( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_linspace( + mlx_array* res, + double start, + double stop, + int num, + mlx_dtype dtype, + const mlx_stream s); +int mlx_log(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_log10(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_log1p(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_log2(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_logaddexp( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_logcumsumexp( + mlx_array* res, + const mlx_array a, + int axis, + bool reverse, + bool inclusive, + const mlx_stream s); +int mlx_logical_and( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_logical_not(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_logical_or( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_logsumexp_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_logsumexp_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_logsumexp( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_matmul( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_max_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_max_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_max( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_maximum( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_mean_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_mean_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_mean( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_meshgrid( + mlx_vector_array* res, + const mlx_vector_array arrays, + bool sparse, + const char* indexing, + const mlx_stream s); +int mlx_min_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_min_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_min( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_minimum( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_moveaxis( + mlx_array* res, + const mlx_array a, + int source, + int destination, + const mlx_stream s); +int mlx_multiply( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_nan_to_num( + mlx_array* res, + const mlx_array a, + float nan, + mlx_optional_float posinf, + mlx_optional_float neginf, + const mlx_stream s); +int mlx_negative(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_not_equal( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_number_of_elements( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool inverted, + mlx_dtype dtype, + const mlx_stream s); +int mlx_ones( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_stream s); +int mlx_ones_like(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_outer( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_pad( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const int* low_pad_size, + size_t low_pad_size_num, + const int* high_pad_size, + size_t high_pad_size_num, + const mlx_array pad_value, + const char* mode, + const mlx_stream s); +int mlx_pad_symmetric( + mlx_array* res, + const mlx_array a, + int pad_width, + const mlx_array pad_value, + const char* mode, + const mlx_stream s); +int mlx_partition_axis( + mlx_array* res, + const mlx_array a, + int kth, + int axis, + const mlx_stream s); +int mlx_partition( + mlx_array* res, + const mlx_array a, + int kth, + const mlx_stream s); +int mlx_power( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_prod_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_prod_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_prod( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_put_along_axis( + mlx_array* res, + const mlx_array a, + const mlx_array indices, + const mlx_array values, + int axis, + const mlx_stream s); +int mlx_quantize( + mlx_vector_array* res, + const mlx_array w, + int group_size, + int bits, + const char* mode, + const mlx_stream s); +int mlx_quantized_matmul( + mlx_array* res, + const mlx_array x, + const mlx_array w, + const mlx_array scales, + const mlx_array biases /* may be null */, + bool transpose, + int group_size, + int bits, + const char* mode, + const mlx_stream s); +int mlx_radians(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_real(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_reciprocal(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_remainder( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_repeat_axis( + mlx_array* res, + const mlx_array arr, + int repeats, + int axis, + const mlx_stream s); +int mlx_repeat( + mlx_array* res, + const mlx_array arr, + int repeats, + const mlx_stream s); +int mlx_reshape( + mlx_array* res, + const mlx_array a, + const int* shape, + size_t shape_num, + const mlx_stream s); +int mlx_right_shift( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_roll_axis( + mlx_array* res, + const mlx_array a, + const int* shift, + size_t shift_num, + int axis, + const mlx_stream s); +int mlx_roll_axes( + mlx_array* res, + const mlx_array a, + const int* shift, + size_t shift_num, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_roll( + mlx_array* res, + const mlx_array a, + const int* shift, + size_t shift_num, + const mlx_stream s); +int mlx_round( + mlx_array* res, + const mlx_array a, + int decimals, + const mlx_stream s); +int mlx_rsqrt(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_scatter( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const mlx_array updates, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_scatter_add( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const mlx_array updates, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_scatter_add_axis( + mlx_array* res, + const mlx_array a, + const mlx_array indices, + const mlx_array values, + int axis, + const mlx_stream s); +int mlx_scatter_max( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const mlx_array updates, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_scatter_min( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const mlx_array updates, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_scatter_prod( + mlx_array* res, + const mlx_array a, + const mlx_vector_array indices, + const mlx_array updates, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_segmented_mm( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_array segments, + const mlx_stream s); +int mlx_sigmoid(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_sign(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_sin(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_sinh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_slice( + mlx_array* res, + const mlx_array a, + const int* start, + size_t start_num, + const int* stop, + size_t stop_num, + const int* strides, + size_t strides_num, + const mlx_stream s); +int mlx_slice_dynamic( + mlx_array* res, + const mlx_array a, + const mlx_array start, + const int* axes, + size_t axes_num, + const int* slice_size, + size_t slice_size_num, + const mlx_stream s); +int mlx_slice_update( + mlx_array* res, + const mlx_array src, + const mlx_array update, + const int* start, + size_t start_num, + const int* stop, + size_t stop_num, + const int* strides, + size_t strides_num, + const mlx_stream s); +int mlx_slice_update_dynamic( + mlx_array* res, + const mlx_array src, + const mlx_array update, + const mlx_array start, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_softmax_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool precise, + const mlx_stream s); +int mlx_softmax_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool precise, + const mlx_stream s); +int mlx_softmax( + mlx_array* res, + const mlx_array a, + bool precise, + const mlx_stream s); +int mlx_sort_axis( + mlx_array* res, + const mlx_array a, + int axis, + const mlx_stream s); +int mlx_sort(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_split( + mlx_vector_array* res, + const mlx_array a, + int num_splits, + int axis, + const mlx_stream s); +int mlx_split_sections( + mlx_vector_array* res, + const mlx_array a, + const int* indices, + size_t indices_num, + int axis, + const mlx_stream s); +int mlx_sqrt(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_square(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_squeeze_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_squeeze_axis( + mlx_array* res, + const mlx_array a, + int axis, + const mlx_stream s); +int mlx_squeeze(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_stack_axis( + mlx_array* res, + const mlx_vector_array arrays, + int axis, + const mlx_stream s); +int mlx_stack( + mlx_array* res, + const mlx_vector_array arrays, + const mlx_stream s); +int mlx_std_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_std_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_std( + mlx_array* res, + const mlx_array a, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_stop_gradient(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_subtract( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const mlx_stream s); +int mlx_sum_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + const mlx_stream s); +int mlx_sum_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + const mlx_stream s); +int mlx_sum( + mlx_array* res, + const mlx_array a, + bool keepdims, + const mlx_stream s); +int mlx_swapaxes( + mlx_array* res, + const mlx_array a, + int axis1, + int axis2, + const mlx_stream s); +int mlx_take_axis( + mlx_array* res, + const mlx_array a, + const mlx_array indices, + int axis, + const mlx_stream s); +int mlx_take( + mlx_array* res, + const mlx_array a, + const mlx_array indices, + const mlx_stream s); +int mlx_take_along_axis( + mlx_array* res, + const mlx_array a, + const mlx_array indices, + int axis, + const mlx_stream s); +int mlx_tan(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_tanh(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_tensordot( + mlx_array* res, + const mlx_array a, + const mlx_array b, + const int* axes_a, + size_t axes_a_num, + const int* axes_b, + size_t axes_b_num, + const mlx_stream s); +int mlx_tensordot_axis( + mlx_array* res, + const mlx_array a, + const mlx_array b, + int axis, + const mlx_stream s); +int mlx_tile( + mlx_array* res, + const mlx_array arr, + const int* reps, + size_t reps_num, + const mlx_stream s); +int mlx_topk_axis( + mlx_array* res, + const mlx_array a, + int k, + int axis, + const mlx_stream s); +int mlx_topk(mlx_array* res, const mlx_array a, int k, const mlx_stream s); +int mlx_trace( + mlx_array* res, + const mlx_array a, + int offset, + int axis1, + int axis2, + mlx_dtype dtype, + const mlx_stream s); +int mlx_transpose_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + const mlx_stream s); +int mlx_transpose(mlx_array* res, const mlx_array a, const mlx_stream s); +int mlx_tri( + mlx_array* res, + int n, + int m, + int k, + mlx_dtype type, + const mlx_stream s); +int mlx_tril(mlx_array* res, const mlx_array x, int k, const mlx_stream s); +int mlx_triu(mlx_array* res, const mlx_array x, int k, const mlx_stream s); +int mlx_unflatten( + mlx_array* res, + const mlx_array a, + int axis, + const int* shape, + size_t shape_num, + const mlx_stream s); +int mlx_var_axes( + mlx_array* res, + const mlx_array a, + const int* axes, + size_t axes_num, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_var_axis( + mlx_array* res, + const mlx_array a, + int axis, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_var( + mlx_array* res, + const mlx_array a, + bool keepdims, + int ddof, + const mlx_stream s); +int mlx_view( + mlx_array* res, + const mlx_array a, + mlx_dtype dtype, + const mlx_stream s); +int mlx_where( + mlx_array* res, + const mlx_array condition, + const mlx_array x, + const mlx_array y, + const mlx_stream s); +int mlx_zeros( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_stream s); +int mlx_zeros_like(mlx_array* res, const mlx_array a, const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-optional.h b/Source/Cmlx/include-framework/mlx-c-optional.h new file mode 100644 index 00000000..1bef7403 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-optional.h @@ -0,0 +1,43 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_OPTIONAL_H +#define MLX_OPTIONAL_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_optional Optionals + * MLX optional scalars. + */ +/**@{*/ + +/** + * A int optional. + */ +typedef struct mlx_optional_int_ { + int value; + bool has_value; +} mlx_optional_int; + +/** + * A float optional. + */ +typedef struct mlx_optional_float_ { + float value; + bool has_value; +} mlx_optional_float; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-random.h b/Source/Cmlx/include-framework/mlx-c-random.h new file mode 100644 index 00000000..34625bbf --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-random.h @@ -0,0 +1,164 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_RANDOM_H +#define MLX_RANDOM_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup random Random number operations + */ +/**@{*/ +int mlx_random_bernoulli( + mlx_array* res, + const mlx_array p, + const int* shape, + size_t shape_num, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_bits( + mlx_array* res, + const int* shape, + size_t shape_num, + int width, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_categorical_shape( + mlx_array* res, + const mlx_array logits, + int axis, + const int* shape, + size_t shape_num, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_categorical_num_samples( + mlx_array* res, + const mlx_array logits_, + int axis, + int num_samples, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_categorical( + mlx_array* res, + const mlx_array logits, + int axis, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_gumbel( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_key(mlx_array* res, uint64_t seed); +int mlx_random_laplace( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + float loc, + float scale, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_multivariate_normal( + mlx_array* res, + const mlx_array mean, + const mlx_array cov, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_normal_broadcast( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array loc /* may be null */, + const mlx_array scale /* may be null */, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_normal( + mlx_array* res, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + float loc, + float scale, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_permutation( + mlx_array* res, + const mlx_array x, + int axis, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_permutation_arange( + mlx_array* res, + int x, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_randint( + mlx_array* res, + const mlx_array low, + const mlx_array high, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_seed(uint64_t seed); +int mlx_random_split_num( + mlx_array* res, + const mlx_array key, + int num, + const mlx_stream s); +int mlx_random_split( + mlx_array* res_0, + mlx_array* res_1, + const mlx_array key, + const mlx_stream s); +int mlx_random_truncated_normal( + mlx_array* res, + const mlx_array lower, + const mlx_array upper, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array key /* may be null */, + const mlx_stream s); +int mlx_random_uniform( + mlx_array* res, + const mlx_array low, + const mlx_array high, + const int* shape, + size_t shape_num, + mlx_dtype dtype, + const mlx_array key /* may be null */, + const mlx_stream s); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-stream.h b/Source/Cmlx/include-framework/mlx-c-stream.h new file mode 100644 index 00000000..a4aa39ab --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-stream.h @@ -0,0 +1,88 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_STREAM_H +#define MLX_STREAM_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_stream Stream + * MLX stream object. + */ +/**@{*/ + +/** + * A MLX stream object. + */ +typedef struct mlx_stream_ { + void* ctx; +} mlx_stream; + +/** + * Returns a new empty stream. + */ +mlx_stream mlx_stream_new(void); + +/** + * Returns a new stream on a device. + */ +mlx_stream mlx_stream_new_device(mlx_device dev); +/** + * Set stream to provided src stream. + */ +int mlx_stream_set(mlx_stream* stream, const mlx_stream src); +/** + * Free a stream. + */ +int mlx_stream_free(mlx_stream stream); +/** + * Get stream description. + */ +int mlx_stream_tostring(mlx_string* str, mlx_stream stream); +/** + * Check if streams are the same. + */ +bool mlx_stream_equal(mlx_stream lhs, mlx_stream rhs); +/** + * Return the device of the stream. + */ +int mlx_stream_get_device(mlx_device* dev, mlx_stream stream); +/** + * Return the index of the stream. + */ +int mlx_stream_get_index(int* index, mlx_stream stream); +/** + * Synchronize with the provided stream. + */ +int mlx_synchronize(mlx_stream stream); +/** + * Returns the default stream on the given device. + */ +int mlx_get_default_stream(mlx_stream* stream, mlx_device dev); +/** + * Set default stream. + */ +int mlx_set_default_stream(mlx_stream stream); +/** + * Returns the current default CPU stream. + */ +mlx_stream mlx_default_cpu_stream_new(void); + +/** + * Returns the current default GPU stream. + */ +mlx_stream mlx_default_gpu_stream_new(void); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-string.h b/Source/Cmlx/include-framework/mlx-c-string.h new file mode 100644 index 00000000..0d2a356b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-string.h @@ -0,0 +1,55 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_STRING_H +#define MLX_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_string String + * MLX string object. + */ +/**@{*/ + +/** + * A MLX string object. + */ +typedef struct mlx_string_ { + void* ctx; +} mlx_string; + +/** + * Returns a new empty string. + */ +mlx_string mlx_string_new(void); + +/** + * Returns a new string, copying contents from `str`, which must end with `\0`. + */ +mlx_string mlx_string_new_data(const char* str); + +/** + * Set string to src string. + */ +int mlx_string_set(mlx_string* str, const mlx_string src); + +/** + * Returns a pointer to the string contents. + * The pointer is valid for the life duration of the string. + */ +const char* mlx_string_data(mlx_string str); + +/** + * Free string. + */ +int mlx_string_free(mlx_string str); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-transforms.h b/Source/Cmlx/include-framework/mlx-c-transforms.h new file mode 100644 index 00000000..30ceac5c --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-transforms.h @@ -0,0 +1,66 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_TRANSFORMS_H +#define MLX_TRANSFORMS_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup transforms Transform operations + */ +/**@{*/ +int mlx_async_eval(const mlx_vector_array outputs); +int mlx_checkpoint(mlx_closure* res, const mlx_closure fun); +int mlx_custom_function( + mlx_closure* res, + const mlx_closure fun, + const mlx_closure_custom fun_vjp /* may be null */, + const mlx_closure_custom_jvp fun_jvp /* may be null */, + const mlx_closure_custom_vmap fun_vmap /* may be null */); +int mlx_custom_vjp( + mlx_closure* res, + const mlx_closure fun, + const mlx_closure_custom fun_vjp); +int mlx_eval(const mlx_vector_array outputs); +int mlx_jvp( + mlx_vector_array* res_0, + mlx_vector_array* res_1, + const mlx_closure fun, + const mlx_vector_array primals, + const mlx_vector_array tangents); +int mlx_value_and_grad( + mlx_closure_value_and_grad* res, + const mlx_closure fun, + const int* argnums, + size_t argnums_num); +int mlx_vjp( + mlx_vector_array* res_0, + mlx_vector_array* res_1, + const mlx_closure fun, + const mlx_vector_array primals, + const mlx_vector_array cotangents); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-transforms_impl.h b/Source/Cmlx/include-framework/mlx-c-transforms_impl.h new file mode 100644 index 00000000..fdd0ab8f --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-transforms_impl.h @@ -0,0 +1,52 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_TRANSFORMS_IMPL_H +#define MLX_TRANSFORMS_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup transforms_impl Implementation detail operations + */ +/**@{*/ +int mlx_detail_vmap_replace( + mlx_vector_array* res, + const mlx_vector_array inputs, + const mlx_vector_array s_inputs, + const mlx_vector_array s_outputs, + const int* in_axes, + size_t in_axes_num, + const int* out_axes, + size_t out_axes_num); +int mlx_detail_vmap_trace( + mlx_vector_array* res_0, + mlx_vector_array* res_1, + const mlx_closure fun, + const mlx_vector_array inputs, + const int* in_axes, + size_t in_axes_num); +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-vector.h b/Source/Cmlx/include-framework/mlx-c-vector.h new file mode 100644 index 00000000..1954c6d0 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-vector.h @@ -0,0 +1,133 @@ +/* Copyright © 2023-2024 Apple Inc. */ +/* */ +/* This file is auto-generated. Do not edit manually. */ +/* */ + +#ifndef MLX_VECTOR_H +#define MLX_VECTOR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup mlx_vector Vectors + * MLX vector objects. + */ +/**@{*/ + +/** + * A vector of array. + */ +typedef struct mlx_vector_array_ { + void* ctx; +} mlx_vector_array; +mlx_vector_array mlx_vector_array_new(void); +int mlx_vector_array_set(mlx_vector_array* vec, const mlx_vector_array src); +int mlx_vector_array_free(mlx_vector_array vec); +mlx_vector_array mlx_vector_array_new_data(const mlx_array* data, size_t size); +mlx_vector_array mlx_vector_array_new_value(const mlx_array val); +int mlx_vector_array_set_data( + mlx_vector_array* vec, + const mlx_array* data, + size_t size); +int mlx_vector_array_set_value(mlx_vector_array* vec, const mlx_array val); +int mlx_vector_array_append_data( + mlx_vector_array vec, + const mlx_array* data, + size_t size); +int mlx_vector_array_append_value(mlx_vector_array vec, const mlx_array val); +size_t mlx_vector_array_size(mlx_vector_array vec); +int mlx_vector_array_get( + mlx_array* res, + const mlx_vector_array vec, + size_t idx); + +/** + * A vector of vector_array. + */ +typedef struct mlx_vector_vector_array_ { + void* ctx; +} mlx_vector_vector_array; +mlx_vector_vector_array mlx_vector_vector_array_new(void); +int mlx_vector_vector_array_set( + mlx_vector_vector_array* vec, + const mlx_vector_vector_array src); +int mlx_vector_vector_array_free(mlx_vector_vector_array vec); +mlx_vector_vector_array mlx_vector_vector_array_new_data( + const mlx_vector_array* data, + size_t size); +mlx_vector_vector_array mlx_vector_vector_array_new_value( + const mlx_vector_array val); +int mlx_vector_vector_array_set_data( + mlx_vector_vector_array* vec, + const mlx_vector_array* data, + size_t size); +int mlx_vector_vector_array_set_value( + mlx_vector_vector_array* vec, + const mlx_vector_array val); +int mlx_vector_vector_array_append_data( + mlx_vector_vector_array vec, + const mlx_vector_array* data, + size_t size); +int mlx_vector_vector_array_append_value( + mlx_vector_vector_array vec, + const mlx_vector_array val); +size_t mlx_vector_vector_array_size(mlx_vector_vector_array vec); +int mlx_vector_vector_array_get( + mlx_vector_array* res, + const mlx_vector_vector_array vec, + size_t idx); + +/** + * A vector of int. + */ +typedef struct mlx_vector_int_ { + void* ctx; +} mlx_vector_int; +mlx_vector_int mlx_vector_int_new(void); +int mlx_vector_int_set(mlx_vector_int* vec, const mlx_vector_int src); +int mlx_vector_int_free(mlx_vector_int vec); +mlx_vector_int mlx_vector_int_new_data(int* data, size_t size); +mlx_vector_int mlx_vector_int_new_value(int val); +int mlx_vector_int_set_data(mlx_vector_int* vec, int* data, size_t size); +int mlx_vector_int_set_value(mlx_vector_int* vec, int val); +int mlx_vector_int_append_data(mlx_vector_int vec, int* data, size_t size); +int mlx_vector_int_append_value(mlx_vector_int vec, int val); +size_t mlx_vector_int_size(mlx_vector_int vec); +int mlx_vector_int_get(int* res, const mlx_vector_int vec, size_t idx); + +/** + * A vector of string. + */ +typedef struct mlx_vector_string_ { + void* ctx; +} mlx_vector_string; +mlx_vector_string mlx_vector_string_new(void); +int mlx_vector_string_set(mlx_vector_string* vec, const mlx_vector_string src); +int mlx_vector_string_free(mlx_vector_string vec); +mlx_vector_string mlx_vector_string_new_data(const char** data, size_t size); +mlx_vector_string mlx_vector_string_new_value(const char* val); +int mlx_vector_string_set_data( + mlx_vector_string* vec, + const char** data, + size_t size); +int mlx_vector_string_set_value(mlx_vector_string* vec, const char* val); +int mlx_vector_string_append_data( + mlx_vector_string vec, + const char** data, + size_t size); +int mlx_vector_string_append_value(mlx_vector_string vec, const char* val); +size_t mlx_vector_string_size(mlx_vector_string vec); +int mlx_vector_string_get(char** res, const mlx_vector_string vec, size_t idx); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-c-version.h b/Source/Cmlx/include-framework/mlx-c-version.h new file mode 100644 index 00000000..5c259b6f --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-c-version.h @@ -0,0 +1,18 @@ +/* Copyright © 2023-2024 Apple Inc. */ + +#ifndef MLX_VERSION_H +#define MLX_VERSION_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int mlx_version(mlx_string* str_); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Source/Cmlx/include-framework/mlx-compile.h b/Source/Cmlx/include-framework/mlx-compile.h new file mode 100644 index 00000000..2ea7a446 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-compile.h @@ -0,0 +1,46 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include + +namespace mlx::core { + +enum class CompileMode { disabled, no_simplify, no_fuse, enabled }; + +/** Compile takes a function and returns a compiled function. */ +std::function(const std::vector&)> compile( + std::function(const std::vector&)> fun, + bool shapeless = false); + +std::function(const std::vector&)> compile( + std::vector (*fun)(const std::vector&), + bool shapeless = false); + +// Convert capture-less lambdas to function pointers. +template < + typename F, + typename = std::enable_if_t< + std::is_convertible_v())>>> +std::function(const std::vector&)> compile( + F&& f, + bool shapeless = false) { + return compile(+f, shapeless); +} + +/** Globally disable compilation. + * Setting the environment variable ``MLX_DISABLE_COMPILE`` can also + * be used to disable compilation. + */ +void disable_compile(); + +/** Globally enable compilation. + * This will override the environment variable ``MLX_DISABLE_COMPILE``. + */ +void enable_compile(); + +/** Set the compiler mode to the given value. */ +void set_compile_mode(CompileMode mode); +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-device.h b/Source/Cmlx/include-framework/mlx-device.h new file mode 100644 index 00000000..1144d705 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-device.h @@ -0,0 +1,33 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +namespace mlx::core { + +struct Device { + enum class DeviceType { + cpu, + gpu, + }; + + static constexpr DeviceType cpu = DeviceType::cpu; + static constexpr DeviceType gpu = DeviceType::gpu; + + Device(DeviceType type, int index = 0) : type(type), index(index) {} + + DeviceType type; + int index; +}; + +const Device& default_device(); + +void set_default_device(const Device& d); + +bool operator==(const Device& lhs, const Device& rhs); +bool operator!=(const Device& lhs, const Device& rhs); + +bool is_available(const Device& d); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-distributed-distributed.h b/Source/Cmlx/include-framework/mlx-distributed-distributed.h new file mode 100644 index 00000000..2a5c307f --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-distributed-distributed.h @@ -0,0 +1,61 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. + +#pragma once + +#include + +#include +#include + +namespace mlx::core::distributed { + +// Forward declaration of the base group implementation. +namespace detail { +class GroupImpl; +}; + +/* Check if a communication backend is available */ +bool is_available(); + +/** + * A distributed::Group represents a group of independent mlx processes that + * can communicate. We must also be able to create sub-groups from a group in + * order to define more granular communication. + */ +struct Group { + Group(std::shared_ptr group) : group_(std::move(group)) {} + + int rank() const; + int size() const; + + /** + * Split the group according to the provided color. Namely processes that use + * the same color will go to the same group. + * + * The key defines the rank of the processes in the new group. The smaller + * the key the smaller the rank. If the provided key is negative, then the + * rank in the current group is used. + */ + Group split(int color, int key = -1) const; + + const std::shared_ptr& raw_group() const { + return group_; + } + + private: + std::shared_ptr group_{nullptr}; +}; + +/** + * Initialize the distributed backend and return the group containing all + * discoverable processes. + * + * If strict is true then throw an error if we couldn't initialize the + * distributed subsystem. Otherwise simply return a singleton group which will + * render communication operations as no-op. + */ +Group init(bool strict = false, const std::string& bk = "any"); + +} // namespace mlx::core::distributed +#endif diff --git a/Source/Cmlx/include-framework/mlx-distributed-ops.h b/Source/Cmlx/include-framework/mlx-distributed-ops.h new file mode 100644 index 00000000..6057a051 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-distributed-ops.h @@ -0,0 +1,53 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. + +#pragma once + +#include + +#include +#include + +namespace mlx::core::distributed { + +array all_sum( + const array& x, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +array all_gather( + const array& x, + std::optional group = std::nullopt, + StreamOrDevice S = {}); + +array send( + const array& x, + int dst, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +array recv( + Shape shape, + Dtype dtype, + int src, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +array recv_like( + const array& x, + int src, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +array all_max( + const array& x, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +array all_min( + const array& x, + std::optional group = std::nullopt, + StreamOrDevice s = {}); + +} // namespace mlx::core::distributed +#endif diff --git a/Source/Cmlx/include-framework/mlx-dtype.h b/Source/Cmlx/include-framework/mlx-dtype.h new file mode 100644 index 00000000..55f0d4b5 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-dtype.h @@ -0,0 +1,117 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include + +#include +#include + +namespace mlx::core { + +struct Dtype { + enum class Val { + bool_, + uint8, + uint16, + uint32, + uint64, + int8, + int16, + int32, + int64, + float16, + float32, + float64, + bfloat16, + complex64, + }; + + enum class Kind { + b, /* bool */ + u, /* unsigned int */ + i, /* signed int */ + f, /* float */ + c, /* complex */ + V, /* void - used for brain float */ + }; + + enum class Category { + complexfloating, + floating, + inexact, + signedinteger, + unsignedinteger, + integer, + number, + generic + }; + + constexpr explicit Dtype(Val val, uint8_t size) : val_(val), size_(size) {} + + constexpr operator Val() const { + return val_; + } + constexpr Val val() const { + return val_; + } + constexpr uint8_t size() const { + return size_; + } + + private: + Val val_; + uint8_t size_; +}; + +inline constexpr Dtype bool_{Dtype::Val::bool_, sizeof(bool)}; + +inline constexpr Dtype uint8{Dtype::Val::uint8, sizeof(uint8_t)}; +inline constexpr Dtype uint16{Dtype::Val::uint16, sizeof(uint16_t)}; +inline constexpr Dtype uint32{Dtype::Val::uint32, sizeof(uint32_t)}; +inline constexpr Dtype uint64{Dtype::Val::uint64, sizeof(uint64_t)}; + +inline constexpr Dtype int8{Dtype::Val::int8, sizeof(int8_t)}; +inline constexpr Dtype int16{Dtype::Val::int16, sizeof(int16_t)}; +inline constexpr Dtype int32{Dtype::Val::int32, sizeof(int32_t)}; +inline constexpr Dtype int64{Dtype::Val::int64, sizeof(int64_t)}; + +inline constexpr Dtype float16{Dtype::Val::float16, sizeof(uint16_t)}; +inline constexpr Dtype float32{Dtype::Val::float32, sizeof(float)}; +inline constexpr Dtype float64{Dtype::Val::float64, sizeof(double)}; +inline constexpr Dtype bfloat16{Dtype::Val::bfloat16, sizeof(uint16_t)}; +inline constexpr Dtype complex64{Dtype::Val::complex64, sizeof(complex64_t)}; + +inline constexpr Dtype::Category complexfloating = + Dtype::Category::complexfloating; +inline constexpr Dtype::Category floating = Dtype::Category::floating; +inline constexpr Dtype::Category inexact = Dtype::Category::inexact; +inline constexpr Dtype::Category signedinteger = Dtype::Category::signedinteger; +inline constexpr Dtype::Category unsignedinteger = + Dtype::Category::unsignedinteger; +inline constexpr Dtype::Category integer = Dtype::Category::integer; +inline constexpr Dtype::Category number = Dtype::Category::number; +inline constexpr Dtype::Category generic = Dtype::Category::generic; + +bool issubdtype(const Dtype& a, const Dtype& b); +bool issubdtype(const Dtype::Category& a, const Dtype& b); +bool issubdtype(const Dtype& a, const Dtype::Category& b); +bool issubdtype(const Dtype::Category& a, const Dtype::Category& b); + +Dtype promote_types(const Dtype& t1, const Dtype& t2); + +inline uint8_t size_of(const Dtype& t) { + return t.size(); +} + +Dtype::Kind kindof(const Dtype& t); + +template +struct TypeToDtype { + operator Dtype(); +}; + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-einsum.h b/Source/Cmlx/include-framework/mlx-einsum.h new file mode 100644 index 00000000..44454d07 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-einsum.h @@ -0,0 +1,24 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. +#pragma once + +#include +#include +#include + +#include +#include + +namespace mlx::core { + +std::pair>, std::string> einsum_path( + const std::string& subscripts, + const std::vector& operands); + +array einsum( + const std::string& subscripts, + const std::vector& operands, + StreamOrDevice s = {}); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-event.h b/Source/Cmlx/include-framework/mlx-event.h new file mode 100644 index 00000000..e31ad92f --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-event.h @@ -0,0 +1,59 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. +#pragma once + +#include +#include + +#include + +namespace mlx::core { + +class Event { + public: + Event() {}; + explicit Event(Stream stream); + + // Wait for the event to be signaled at its current value + void wait(); + + // Wait in the given stream for the event to be signaled at its current value + void wait(Stream stream); + + // Signal the event at its current value in the given stream + void signal(Stream stream); + + // Check if the event has been signaled at its current value + bool is_signaled() const; + + // Check if the event is valid + bool valid() const { + return event_ != nullptr; + } + + uint64_t value() const { + return value_; + } + + void set_value(uint64_t v) { + value_ = v; + } + + const Stream& stream() const { + if (!valid()) { + throw std::runtime_error( + "[Event::stream] Cannot access stream on invalid event."); + } + return stream_; + } + + private: + // Default constructed stream should never be used + // since the event is not yet valid + Stream stream_{0, Device::cpu}; + std::shared_ptr event_{nullptr}; + uint64_t value_{0}; +}; + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-export.h b/Source/Cmlx/include-framework/mlx-export.h new file mode 100644 index 00000000..4c86a080 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-export.h @@ -0,0 +1,68 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. + +#pragma once + +#include +#include +#include + +namespace mlx::core { + +using Args = std::vector; +using Kwargs = std::unordered_map; + +struct FunctionExporter; + +/** + * Make an exporter to save multiple traces of a given function to + * the same file. + */ +FunctionExporter exporter( + const std::string& file, + const std::function(const Args&)>& fun, + bool shapeless = false); + +FunctionExporter exporter( + const std::string& file, + const std::function(const Kwargs&)>& fun, + bool shapeless = false); + +FunctionExporter exporter( + const std::string& path, + const std::function(const Args&, const Kwargs&)>& fun, + bool shapeless = false); + +/** + * Export a function to a file. + */ +void export_function( + const std::string& file, + const std::function(const Args&)>& fun, + const Args& args, + bool shapeless = false); + +void export_function( + const std::string& file, + const std::function(const Kwargs&)>& fun, + const Kwargs& kwargs, + bool shapeless = false); + +void export_function( + const std::string& file, + const std::function(const Args&, const Kwargs&)>& fun, + const Args& args, + const Kwargs& kwargs, + bool shapeless = false); + +struct ImportedFunction; + +/** + * Import a function from a file. + */ +ImportedFunction import_function(const std::string& file); + +} // namespace mlx::core + +#include +#endif diff --git a/Source/Cmlx/include-framework/mlx-export_impl.h b/Source/Cmlx/include-framework/mlx-export_impl.h new file mode 100644 index 00000000..aa1d23f2 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-export_impl.h @@ -0,0 +1,73 @@ +#ifdef __cplusplus +// Copyright © 2024 Apple Inc. + +#include + +#pragma once + +namespace mlx::core { + +struct FunctionTable; + +struct FunctionExporter { + void operator()(const std::initializer_list& args) { + this->operator()(Args(args)); + } + void operator()(const Args& args); + void operator()(const Kwargs& kwargs); + void operator()(const Args& args, const Kwargs& kwargs); + + void close(); + + FunctionExporter(const FunctionExporter&) = delete; + FunctionExporter& operator=(const FunctionExporter&) = delete; + FunctionExporter(FunctionExporter&& other) = default; + + private: + friend FunctionExporter exporter( + const std::string&, + const std::function(const Args&)>&, + bool shapeless); + + friend FunctionExporter exporter( + const std::string&, + const std::function(const Kwargs&)>&, + bool shapeless); + + friend FunctionExporter exporter( + const std::string&, + const std::function(const Args&, const Kwargs&)>&, + bool shapeless); + + FunctionExporter( + const std::string& file, + std::function(const Args&, const Kwargs&)> fun, + bool shapeless); + io::FileWriter os; + std::function(const Args&, const Kwargs& kwargs)> fun; + void export_function(const Args& args, const Kwargs& kwargs); + std::set constants; + int count{0}; + bool closed{false}; + std::shared_ptr ftable; +}; + +struct ImportedFunction { + std::vector operator()( + const std::initializer_list& args) const { + return this->operator()(Args(args)); + } + std::vector operator()(const Args& args) const; + std::vector operator()(const Kwargs& kwargs) const; + std::vector operator()(const Args& args, const Kwargs& kwargs) const; + + private: + ImportedFunction(const std::string& file); + friend ImportedFunction import_function(const std::string&); + ImportedFunction(); + + std::shared_ptr ftable; +}; + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-fast.h b/Source/Cmlx/include-framework/mlx-fast.h new file mode 100644 index 00000000..01e00d07 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-fast.h @@ -0,0 +1,104 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include + +#include + +namespace mlx::core::fast { + +array rms_norm( + const array& x, + const std::optional& weight, + float eps, + StreamOrDevice s = {}); + +array layer_norm( + const array& x, + const std::optional& weight, + const std::optional& bias, + float eps, + StreamOrDevice s = {}); + +array rope( + const array& x, + int dims, + bool traditional, + std::optional base, + float scale, + int offset, + const std::optional& freqs = std::nullopt, + StreamOrDevice s = {}); + +array rope( + const array& x, + int dims, + bool traditional, + std::optional base, + float scale, + const array& offset, + const std::optional& freqs = std::nullopt, + StreamOrDevice s = {}); + +/** Computes: O = softmax(Q @ K.T) @ V **/ +array scaled_dot_product_attention( + const array& queries, + const array& keys, + const array& values, + const float scale, + const std::string& mask_mode = "", + const std::vector& mask_arrs = {}, + const std::optional& sinks = {}, + StreamOrDevice s = {}); + +using TemplateArg = std::variant; +using ScalarArg = std::variant; + +using CustomKernelFunction = std::function( + const std::vector&, + const std::vector&, + const std::vector&, + std::tuple, + std::tuple, + std::vector>, + std::optional, + bool, + StreamOrDevice)>; + +CustomKernelFunction metal_kernel( + const std::string& name, + const std::vector& input_names, + const std::vector& output_names, + const std::string& source, + const std::string& header = "", + bool ensure_row_contiguous = true, + bool atomic_outputs = false); + +CustomKernelFunction cuda_kernel( + const std::string& name, + const std::vector& input_names, + const std::vector& output_names, + const std::string& source, + const std::string& header = "", + bool ensure_row_contiguous = true, + int shared_memory = 0); + +std::vector precompiled_cuda_kernel( + const std::string& name, + const std::string& compiled_source, + const std::vector& inputs, + const std::vector& output_shapes, + const std::vector& output_dtypes, + const std::vector& scalars, + std::tuple grid, + std::tuple threadgroup, + int shared_memory = 0, + std::optional init_value = std::nullopt, + bool ensure_row_contiguous = false, + StreamOrDevice s = {}); + +} // namespace mlx::core::fast +#endif diff --git a/Source/Cmlx/include-framework/mlx-fft.h b/Source/Cmlx/include-framework/mlx-fft.h new file mode 100644 index 00000000..e427e94c --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-fft.h @@ -0,0 +1,169 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include + +#include +#include +#include + +namespace mlx::core::fft { + +/** Compute the n-dimensional Fourier Transform. */ +array fftn( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}); +array fftn(const array& a, const std::vector& axes, StreamOrDevice s = {}); +array fftn(const array& a, StreamOrDevice s = {}); + +/** Compute the n-dimensional inverse Fourier Transform. */ +array ifftn( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}); +array ifftn( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); +array ifftn(const array& a, StreamOrDevice s = {}); + +/** Compute the one-dimensional Fourier Transform. */ +inline array fft(const array& a, int n, int axis, StreamOrDevice s = {}) { + return fftn(a, {n}, {axis}, s); +} +inline array fft(const array& a, int axis = -1, StreamOrDevice s = {}) { + return fftn(a, {axis}, s); +} + +/** Compute the one-dimensional inverse Fourier Transform. */ +inline array ifft(const array& a, int n, int axis, StreamOrDevice s = {}) { + return ifftn(a, {n}, {axis}, s); +} +inline array ifft(const array& a, int axis = -1, StreamOrDevice s = {}) { + return ifftn(a, {axis}, s); +} + +/** Compute the two-dimensional Fourier Transform. */ +inline array fft2( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}) { + return fftn(a, n, axes, s); +} +inline array fft2( + const array& a, + const std::vector& axes = {-2, -1}, + StreamOrDevice s = {}) { + return fftn(a, axes, s); +} + +/** Compute the two-dimensional inverse Fourier Transform. */ +inline array ifft2( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}) { + return ifftn(a, n, axes, s); +} +inline array ifft2( + const array& a, + const std::vector& axes = {-2, -1}, + StreamOrDevice s = {}) { + return ifftn(a, axes, s); +} + +/** Compute the n-dimensional Fourier Transform on a real input. */ +array rfftn( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}); +array rfftn( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); +array rfftn(const array& a, StreamOrDevice s = {}); + +/** Compute the n-dimensional inverse of `rfftn`. */ +array irfftn( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}); +array irfftn( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); +array irfftn(const array& a, StreamOrDevice s = {}); + +/** Compute the one-dimensional Fourier Transform on a real input. */ +inline array rfft(const array& a, int n, int axis, StreamOrDevice s = {}) { + return rfftn(a, {n}, {axis}, s); +} +inline array rfft(const array& a, int axis = -1, StreamOrDevice s = {}) { + return rfftn(a, {axis}, s); +} +/** Compute the one-dimensional inverse of `rfft`. */ +inline array irfft(const array& a, int n, int axis, StreamOrDevice s = {}) { + return irfftn(a, {n}, {axis}, s); +} +inline array irfft(const array& a, int axis = -1, StreamOrDevice s = {}) { + return irfftn(a, {axis}, s); +} + +/** Compute the two-dimensional Fourier Transform on a real input. */ +inline array rfft2( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}) { + return rfftn(a, n, axes, s); +} +inline array rfft2( + const array& a, + const std::vector& axes = {-2, -1}, + StreamOrDevice s = {}) { + return rfftn(a, axes, s); +} + +/** Compute the two-dimensional inverse of `rfft2`. */ +inline array irfft2( + const array& a, + const Shape& n, + const std::vector& axes, + StreamOrDevice s = {}) { + return irfftn(a, n, axes, s); +} +inline array irfft2( + const array& a, + const std::vector& axes = {-2, -1}, + StreamOrDevice s = {}) { + return irfftn(a, axes, s); +} +/** Shift the zero-frequency component to the center of the spectrum. */ +array fftshift(const array& a, StreamOrDevice s = {}); + +/** Shift the zero-frequency component to the center of the spectrum along + * specified axes. */ +array fftshift( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); + +/** The inverse of fftshift. */ +array ifftshift(const array& a, StreamOrDevice s = {}); + +/** The inverse of fftshift along specified axes. */ +array ifftshift( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); + +} // namespace mlx::core::fft +#endif diff --git a/Source/Cmlx/include-framework/mlx-io-load.h b/Source/Cmlx/include-framework/mlx-io-load.h new file mode 100644 index 00000000..f402929b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-io-load.h @@ -0,0 +1,176 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include +#include + +#include +#ifdef _MSC_VER +#include +#else +#include +#include +#endif + +#include + +// Strictly we need to operate on files in binary mode (to avoid \r getting +// automatically inserted), but every modern system except for Windows no +// longer differentiates between binary and text files and for them define +// the flag as no-op. +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +namespace mlx::core { + +namespace io { + +ThreadPool& thread_pool(); + +class Reader { + public: + virtual bool is_open() const = 0; + virtual bool good() const = 0; + virtual size_t tell() = 0; // tellp is non-const in iostream + virtual void seek( + int64_t off, + std::ios_base::seekdir way = std::ios_base::beg) = 0; + virtual void read(char* data, size_t n) = 0; + virtual void read(char* data, size_t n, size_t offset) = 0; + virtual std::string label() const = 0; + virtual ~Reader() = default; +}; + +class Writer { + public: + virtual bool is_open() const = 0; + virtual bool good() const = 0; + virtual size_t tell() = 0; + virtual void seek( + int64_t off, + std::ios_base::seekdir way = std::ios_base::beg) = 0; + virtual void write(const char* data, size_t n) = 0; + virtual std::string label() const = 0; + virtual ~Writer() = default; +}; + +class ParallelFileReader : public Reader { + public: + explicit ParallelFileReader(std::string file_path) + : fd_(open(file_path.c_str(), O_RDONLY | O_BINARY)), + label_(std::move(file_path)) {} + + ~ParallelFileReader() override { + close(fd_); + } + + bool is_open() const override { + return fd_ > 0; + } + + bool good() const override { + return is_open(); + } + + size_t tell() override { + return lseek(fd_, 0, SEEK_CUR); + } + + // Warning: do not use this function from multiple threads as + // it advances the file descriptor + void seek(int64_t off, std::ios_base::seekdir way = std::ios_base::beg) + override { + if (way == std::ios_base::beg) { + lseek(fd_, off, 0); + } else { + lseek(fd_, off, SEEK_CUR); + } + } + + // Warning: do not use this function from multiple threads as + // it advances the file descriptor + void read(char* data, size_t n) override; + + void read(char* data, size_t n, size_t offset) override; + + std::string label() const override { + return "file " + label_; + } + + private: + static constexpr size_t batch_size_ = 1 << 25; + static ThreadPool& thread_pool(); + int fd_; + std::string label_; +}; + +class FileWriter : public Writer { + public: + explicit FileWriter(std::string file_path) + : fd_(open( + file_path.c_str(), + O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, + 0644)), + label_(std::move(file_path)) {} + + FileWriter(const FileWriter&) = delete; + FileWriter& operator=(const FileWriter&) = delete; + FileWriter(FileWriter&& other) { + std::swap(fd_, other.fd_); + } + + ~FileWriter() override { + if (fd_ != 0) { + close(fd_); + } + } + + bool is_open() const override { + return fd_ >= 0; + } + + bool good() const override { + return is_open(); + } + + size_t tell() override { + return lseek(fd_, 0, SEEK_CUR); + } + + void seek(int64_t off, std::ios_base::seekdir way = std::ios_base::beg) + override { + if (way == std::ios_base::beg) { + lseek(fd_, off, 0); + } else { + lseek(fd_, off, SEEK_CUR); + } + } + + void write(const char* data, size_t n) override { + while (n != 0) { + auto m = ::write(fd_, data, std::min(n, static_cast(INT32_MAX))); + if (m <= 0) { + std::ostringstream msg; + msg << "[write] Unable to write " << n << " bytes to file."; + throw std::runtime_error(msg.str()); + } + data += m; + n -= m; + } + } + + std::string label() const override { + return "file " + label_; + } + + private: + int fd_{0}; + std::string label_; +}; + +} // namespace io +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-io.h b/Source/Cmlx/include-framework/mlx-io.h new file mode 100644 index 00000000..184fe361 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-io.h @@ -0,0 +1,63 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include + +#include +#include +#include +#include + +namespace mlx::core { +using GGUFMetaData = + std::variant>; +using GGUFLoad = std::pair< + std::unordered_map, + std::unordered_map>; +using SafetensorsLoad = std::pair< + std::unordered_map, + std::unordered_map>; + +/** Save array to out stream in .npy format */ +void save(std::shared_ptr out_stream, array a); + +/** Save array to file in .npy format */ +void save(std::string file, array a); + +/** Load array from reader in .npy format */ +array load(std::shared_ptr in_stream, StreamOrDevice s = {}); + +/** Load array from file in .npy format */ +array load(std::string file, StreamOrDevice s = {}); + +/** Load array map from .safetensors file format */ +SafetensorsLoad load_safetensors( + std::shared_ptr in_stream, + StreamOrDevice s = {}); +SafetensorsLoad load_safetensors( + const std::string& file, + StreamOrDevice s = {}); + +void save_safetensors( + std::shared_ptr in_stream, + std::unordered_map, + std::unordered_map metadata = {}); +void save_safetensors( + std::string file, + std::unordered_map, + std::unordered_map metadata = {}); + +/** Load array map and metadata from .gguf file format */ + +GGUFLoad load_gguf(const std::string& file, StreamOrDevice s = {}); + +void save_gguf( + std::string file, + std::unordered_map array_map, + std::unordered_map meta_data = {}); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-linalg.h b/Source/Cmlx/include-framework/mlx-linalg.h new file mode 100644 index 00000000..c0c2f470 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-linalg.h @@ -0,0 +1,113 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include + +#include +#include +#include +#include + +namespace mlx::core::linalg { + +/** + * Compute vector or matrix norms. + * + * - If axis and ord are both unspecified, computes the 2-norm of flatten(x). + * - If axis is not provided but ord is, then x must be either 1D or 2D. + * - If axis is provided, but ord is not, then the 2-norm (or Frobenius norm + * for matrices) is computed along the given axes. At most 2 axes can be + * specified. + * - If both axis and ord are provided, then the corresponding matrix or vector + * norm is computed. At most 2 axes can be specified. + */ +array norm( + const array& a, + const double ord, + const std::optional>& axis = std::nullopt, + bool keepdims = false, + StreamOrDevice s = {}); +inline array norm( + const array& a, + const double ord, + int axis, + bool keepdims = false, + StreamOrDevice s = {}) { + return norm(a, ord, std::vector{axis}, keepdims, s); +} +array norm( + const array& a, + const std::string& ord, + const std::optional>& axis = std::nullopt, + bool keepdims = false, + StreamOrDevice s = {}); +inline array norm( + const array& a, + const std::string& ord, + int axis, + bool keepdims = false, + StreamOrDevice s = {}) { + return norm(a, ord, std::vector{axis}, keepdims, s); +} +array norm( + const array& a, + const std::optional>& axis = std::nullopt, + bool keepdims = false, + StreamOrDevice s = {}); +inline array +norm(const array& a, int axis, bool keepdims = false, StreamOrDevice s = {}) { + return norm(a, std::vector{axis}, keepdims, s); +} + +std::pair qr(const array& a, StreamOrDevice s = {}); + +std::vector +svd(const array& a, bool compute_uv, StreamOrDevice s /* = {} */); +inline std::vector svd(const array& a, StreamOrDevice s = {}) { + return svd(a, true, s); +} + +array inv(const array& a, StreamOrDevice s = {}); + +array tri_inv(const array& a, bool upper = false, StreamOrDevice s = {}); + +array cholesky(const array& a, bool upper = false, StreamOrDevice s = {}); + +array pinv(const array& a, StreamOrDevice s = {}); + +array cholesky_inv(const array& a, bool upper = false, StreamOrDevice s = {}); + +std::vector lu(const array& a, StreamOrDevice s = {}); + +std::pair lu_factor(const array& a, StreamOrDevice s = {}); + +array solve(const array& a, const array& b, StreamOrDevice s = {}); + +array solve_triangular( + const array& a, + const array& b, + bool upper = false, + StreamOrDevice s = {}); + +/** + * Compute the cross product of two arrays along the given axis. + */ +array cross( + const array& a, + const array& b, + int axis = -1, + StreamOrDevice s = {}); + +std::pair eig(const array& a, StreamOrDevice s = {}); + +array eigvals(const array& a, StreamOrDevice s = {}); + +array eigvalsh(const array& a, std::string UPLO = "L", StreamOrDevice s = {}); + +std::pair +eigh(const array& a, std::string UPLO = "L", StreamOrDevice s = {}); + +} // namespace mlx::core::linalg +#endif diff --git a/Source/Cmlx/include-framework/mlx-memory.h b/Source/Cmlx/include-framework/mlx-memory.h new file mode 100644 index 00000000..9d6d8924 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-memory.h @@ -0,0 +1,80 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. + +#pragma once + +#include + +namespace mlx::core { + +/* Get the actively used memory in bytes. + * + * Note, this will not always match memory use reported by the system because + * it does not include cached memory buffers. + * */ +size_t get_active_memory(); + +/* Get the peak amount of used memory in bytes. + * + * The maximum memory used recorded from the beginning of the program + * execution or since the last call to reset_peak_memory. + * */ +size_t get_peak_memory(); + +/* Reset the peak memory to zero. + * */ +void reset_peak_memory(); + +/* Get the cache size in bytes. + * + * The cache includes memory not currently used that has not been returned + * to the system allocator. + * */ +size_t get_cache_memory(); + +/* Set the memory limit. + * The memory limit is a guideline for the maximum amount of memory to use + * during graph evaluation. If the memory limit is exceeded and there is no + * more RAM (including swap when available) allocations will result in an + * exception. + * + * When Metal is available the memory limit defaults to 1.5 times the maximum + * recommended working set size reported by the device. + * + * Returns the previous memory limit. + * */ +size_t set_memory_limit(size_t limit); + +/* Get the current memory limit. */ +size_t get_memory_limit(); + +/* Set the cache limit. + * If using more than the given limit, free memory will be reclaimed + * from the cache on the next allocation. To disable the cache, + * set the limit to 0. + * + * The cache limit defaults to the memory limit. + * + * Returns the previous cache limit. + * */ +size_t set_cache_limit(size_t limit); + +/* Clear the memory cache. */ +void clear_cache(); + +/* Set the wired size limit. + * + * Note, this function is only useful when using the Metal backend with + * macOS 15.0 or higher. + * + * The wired limit is the total size in bytes of memory that will be kept + * resident. The default value is ``0``. + * + * Setting a wired limit larger than system wired limit is an error. + * + * Returns the previous wired limit. + * */ +size_t set_wired_limit(size_t limit); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-ops.h b/Source/Cmlx/include-framework/mlx-ops.h new file mode 100644 index 00000000..b0e26dfb --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-ops.h @@ -0,0 +1,1540 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include + +#include +#include +#include +#include + +namespace mlx::core { + +/** + * \defgroup ops Core array operations + * @{ + */ + +/** + * A 1D array of numbers starting at `start` (optional), + * stopping at stop, stepping by `step` (optional). */ +array arange( + double start, + double stop, + double step, + Dtype dtype, + StreamOrDevice s = {}); +array arange(double start, double stop, double step, StreamOrDevice s = {}); +array arange(double start, double stop, Dtype dtype, StreamOrDevice s = {}); +array arange(double start, double stop, StreamOrDevice s = {}); +array arange(double stop, Dtype dtype, StreamOrDevice s = {}); +array arange(double stop, StreamOrDevice s = {}); + +array arange(int start, int stop, int step, StreamOrDevice s = {}); +array arange(int start, int stop, StreamOrDevice s = {}); +array arange(int stop, StreamOrDevice s = {}); + +/** A 1D array of `num` evenly spaced numbers in the range `[start, stop]` */ +array linspace( + double start, + double stop, + int num = 50, + Dtype dtype = float32, + StreamOrDevice s = {}); + +/** Convert an array to the given data type. */ +array astype(array a, Dtype dtype, StreamOrDevice s = {}); + +/** Create a view of an array with the given shape and strides. */ +array as_strided( + array a, + Shape shape, + Strides strides, + size_t offset, + StreamOrDevice s = {}); + +/** Copy another array. */ +array copy(array a, StreamOrDevice s = {}); + +/** Fill an array of the given shape with the given value(s). */ +array full(Shape shape, array vals, Dtype dtype, StreamOrDevice s = {}); +array full(Shape shape, array vals, StreamOrDevice s = {}); +template +array full(Shape shape, T val, Dtype dtype, StreamOrDevice s = {}) { + return full(std::move(shape), array(val, dtype), to_stream(s)); +} +template +array full(Shape shape, T val, StreamOrDevice s = {}) { + return full(std::move(shape), array(val), to_stream(s)); +} + +/** Fill an array of the given shape with zeros. */ +array zeros(const Shape& shape, Dtype dtype, StreamOrDevice s = {}); +inline array zeros(const Shape& shape, StreamOrDevice s = {}) { + return zeros(shape, float32, s); +} +array zeros_like(const array& a, StreamOrDevice s = {}); + +/** Fill an array of the given shape with ones. */ +array ones(const Shape& shape, Dtype dtype, StreamOrDevice s = {}); +inline array ones(const Shape& shape, StreamOrDevice s = {}) { + return ones(shape, float32, s); +} +array ones_like(const array& a, StreamOrDevice s = {}); + +/** Fill an array of the given shape (n,m) with ones in the specified diagonal + * k, and zeros everywhere else. */ +array eye(int n, int m, int k, Dtype dtype, StreamOrDevice s = {}); +inline array eye(int n, Dtype dtype, StreamOrDevice s = {}) { + return eye(n, n, 0, dtype, s); +} +inline array eye(int n, int m, StreamOrDevice s = {}) { + return eye(n, m, 0, float32, s); +} +inline array eye(int n, int m, int k, StreamOrDevice s = {}) { + return eye(n, m, k, float32, s); +} +inline array eye(int n, StreamOrDevice s = {}) { + return eye(n, n, 0, float32, s); +} + +/** Create a square matrix of shape (n,n) of zeros, and ones in the major + * diagonal. */ +array identity(int n, Dtype dtype, StreamOrDevice s = {}); +inline array identity(int n, StreamOrDevice s = {}) { + return identity(n, float32, s); +} + +array tri(int n, int m, int k, Dtype type, StreamOrDevice s = {}); +inline array tri(int n, Dtype type, StreamOrDevice s = {}) { + return tri(n, n, 0, type, s); +} + +array tril(array x, int k = 0, StreamOrDevice s = {}); +array triu(array x, int k = 0, StreamOrDevice s = {}); + +/** Reshape an array to the given shape. */ +array reshape(const array& a, Shape shape, StreamOrDevice s = {}); + +/** Unflatten the axis to the given shape. */ +array unflatten(const array& a, int axis, Shape shape, StreamOrDevice s = {}); + +/** Flatten the dimensions in the range `[start_axis, end_axis]` . */ +array flatten( + const array& a, + int start_axis, + int end_axis = -1, + StreamOrDevice s = {}); + +/** Flatten the array to 1D. */ +array flatten(const array& a, StreamOrDevice s = {}); + +/** Multiply the array by the Hadamard matrix of corresponding size. */ +array hadamard_transform( + const array& a, + std::optional scale = std::nullopt, + StreamOrDevice s = {}); + +/** Remove singleton dimensions at the given axes. */ +array squeeze( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); + +/** Remove singleton dimensions at the given axis. */ +array squeeze(const array& a, int axis, StreamOrDevice s = {}); + +/** Remove all singleton dimensions. */ +array squeeze(const array& a, StreamOrDevice s = {}); + +/** Add a singleton dimension at the given axes. */ +array expand_dims( + const array& a, + const std::vector& axes, + StreamOrDevice s = {}); + +/** Add a singleton dimension at the given axis. */ +array expand_dims(const array& a, int axis, StreamOrDevice s = {}); + +/** Slice an array. */ +array slice( + const array& a, + Shape start, + Shape stop, + Shape strides, + StreamOrDevice s = {}); +inline array slice( + const array& a, + std::initializer_list start, + Shape stop, + Shape strides, + StreamOrDevice s = {}) { + return slice(a, Shape(start), std::move(stop), std::move(strides), s); +} + +/** Slice an array with a stride of 1 in each dimension. */ +array slice(const array& a, Shape start, Shape stop, StreamOrDevice s = {}); + +/** Slice an array with dynamic starting indices. */ +array slice( + const array& a, + const array& start, + std::vector axes, + Shape slice_size, + StreamOrDevice s = {}); + +/** Update a slice from the source array. */ +array slice_update( + const array& src, + const array& update, + Shape start, + Shape stop, + Shape strides, + StreamOrDevice s = {}); + +/** Update a slice from the source array with stride 1 in each dimension. */ +array slice_update( + const array& src, + const array& update, + Shape start, + Shape stop, + StreamOrDevice s = {}); + +/** Update a slice from the source array with dynamic starting indices. */ +array slice_update( + const array& src, + const array& update, + const array& start, + std::vector axes, + StreamOrDevice s = {}); + +/** Split an array into sub-arrays along a given axis. */ +std::vector +split(const array& a, int num_splits, int axis, StreamOrDevice s = {}); +std::vector split(const array& a, int num_splits, StreamOrDevice s = {}); +std::vector +split(const array& a, const Shape& indices, int axis, StreamOrDevice s = {}); +std::vector +split(const array& a, const Shape& indices, StreamOrDevice s = {}); + +/** A vector of coordinate arrays from coordinate vectors. */ +std::vector meshgrid( + const std::vector& arrays, + bool sparse = false, + const std::string& indexing = "xy", + StreamOrDevice s = {}); + +/** + * Clip (limit) the values in an array. + */ +array clip( + const array& a, + const std::optional& a_min = std::nullopt, + const std::optional& a_max = std::nullopt, + StreamOrDevice s = {}); + +/** Concatenate arrays along a given axis. */ +array concatenate(std::vector arrays, int axis, StreamOrDevice s = {}); +array concatenate(std::vector arrays, StreamOrDevice s = {}); + +/** Stack arrays along a new axis. */ +array stack(const std::vector& arrays, int axis, StreamOrDevice s = {}); +array stack(const std::vector& arrays, StreamOrDevice s = {}); + +/** Repeat an array along an axis. */ +array repeat(const array& arr, int repeats, int axis, StreamOrDevice s = {}); +array repeat(const array& arr, int repeats, StreamOrDevice s = {}); + +array tile(const array& arr, std::vector reps, StreamOrDevice s = {}); + +/** Permutes the dimensions according to the given axes. */ +array transpose(const array& a, std::vector axes, StreamOrDevice s = {}); +inline array transpose( + const array& a, + std::initializer_list axes, + StreamOrDevice s = {}) { + return transpose(a, std::vector(axes), s); +} + +/** Swap two axes of an array. */ +array swapaxes(const array& a, int axis1, int axis2, StreamOrDevice s = {}); + +/** Move an axis of an array. */ +array moveaxis( + const array& a, + int source, + int destination, + StreamOrDevice s = {}); + +/** Pad an array with a constant value */ +array pad( + const array& a, + const std::vector& axes, + const Shape& low_pad_size, + const Shape& high_pad_size, + const array& pad_value = array(0), + const std::string& mode = "constant", + StreamOrDevice s = {}); + +/** Pad an array with a constant value along all axes */ +array pad( + const array& a, + const std::vector>& pad_width, + const array& pad_value = array(0), + const std::string& mode = "constant", + StreamOrDevice s = {}); +array pad( + const array& a, + const std::pair& pad_width, + const array& pad_value = array(0), + const std::string& mode = "constant", + StreamOrDevice s = {}); +array pad( + const array& a, + int pad_width, + const array& pad_value = array(0), + const std::string& mode = "constant", + StreamOrDevice s = {}); + +/** Permutes the dimensions in reverse order. */ +array transpose(const array& a, StreamOrDevice s = {}); + +/** Broadcast an array to a given shape. */ +array broadcast_to(const array& a, const Shape& shape, StreamOrDevice s = {}); + +/** Broadcast a vector of arrays against one another. */ +std::vector broadcast_arrays( + const std::vector& inputs, + StreamOrDevice s = {}); + +/** Returns the bool array with (a == b) element-wise. */ +array equal(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator==(const array& a, const array& b) { + return equal(a, b); +} +template +array operator==(T a, const array& b) { + return equal(array(a), b); +} +template +array operator==(const array& a, T b) { + return equal(a, array(b)); +} + +/** Returns the bool array with (a != b) element-wise. */ +array not_equal(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator!=(const array& a, const array& b) { + return not_equal(a, b); +} +template +array operator!=(T a, const array& b) { + return not_equal(array(a), b); +} +template +array operator!=(const array& a, T b) { + return not_equal(a, array(b)); +} + +/** Returns bool array with (a > b) element-wise. */ +array greater(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator>(const array& a, const array& b) { + return greater(a, b); +} +template +array operator>(T a, const array& b) { + return greater(array(a), b); +} +template +array operator>(const array& a, T b) { + return greater(a, array(b)); +} + +/** Returns bool array with (a >= b) element-wise. */ +array greater_equal(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator>=(const array& a, const array& b) { + return greater_equal(a, b); +} +template +array operator>=(T a, const array& b) { + return greater_equal(array(a), b); +} +template +array operator>=(const array& a, T b) { + return greater_equal(a, array(b)); +} + +/** Returns bool array with (a < b) element-wise. */ +array less(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator<(const array& a, const array& b) { + return less(a, b); +} +template +array operator<(T a, const array& b) { + return less(array(a), b); +} +template +array operator<(const array& a, T b) { + return less(a, array(b)); +} + +/** Returns bool array with (a <= b) element-wise. */ +array less_equal(const array& a, const array& b, StreamOrDevice s = {}); +inline array operator<=(const array& a, const array& b) { + return less_equal(a, b); +} +template +array operator<=(T a, const array& b) { + return less_equal(array(a), b); +} +template +array operator<=(const array& a, T b) { + return less_equal(a, array(b)); +} + +/** True if two arrays have the same shape and elements. */ +array array_equal( + const array& a, + const array& b, + bool equal_nan, + StreamOrDevice s = {}); +inline array +array_equal(const array& a, const array& b, StreamOrDevice s = {}) { + return array_equal(a, b, false, s); +} + +array isnan(const array& a, StreamOrDevice s = {}); + +array isinf(const array& a, StreamOrDevice s = {}); + +array isfinite(const array& a, StreamOrDevice s = {}); + +array isposinf(const array& a, StreamOrDevice s = {}); + +array isneginf(const array& a, StreamOrDevice s = {}); + +/** Select from x or y depending on condition. */ +array where( + const array& condition, + const array& x, + const array& y, + StreamOrDevice s = {}); + +/** Replace NaN and infinities with finite numbers. */ +array nan_to_num( + const array& a, + float nan = 0.0f, + const std::optional posinf = std::nullopt, + const std::optional neginf = std::nullopt, + StreamOrDevice s = {}); + +/** True if all elements in the array are true (or non-zero). **/ +array all(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array all(const array& a, StreamOrDevice s = {}) { + return all(a, false, to_stream(s)); +} + +/** True if the two arrays are equal within the specified tolerance. */ +array allclose( + const array& a, + const array& b, + double rtol = 1e-5, + double atol = 1e-8, + bool equal_nan = false, + StreamOrDevice s = {}); + +/** Returns a boolean array where two arrays are element-wise equal within the + * specified tolerance. */ +array isclose( + const array& a, + const array& b, + double rtol = 1e-5, + double atol = 1e-8, + bool equal_nan = false, + StreamOrDevice s = {}); + +/** + * Reduces the input along the given axes. An output value is true + * if all the corresponding inputs are true. + **/ +array all( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** + * Reduces the input along the given axis. An output value is true + * if all the corresponding inputs are true. + **/ +array all( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** True if any elements in the array are true (or non-zero). **/ +array any(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array any(const array& a, StreamOrDevice s = {}) { + return any(a, false, to_stream(s)); +} + +/** + * Reduces the input along the given axes. An output value is true + * if any of the corresponding inputs are true. + **/ +array any( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** + * Reduces the input along the given axis. An output value is true + * if any of the corresponding inputs are true. + **/ +array any( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Sums the elements of an array. */ +array sum(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array sum(const array& a, StreamOrDevice s = {}) { + return sum(a, false, to_stream(s)); +} + +/** Sums the elements of an array along the given axes. */ +array sum( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Sums the elements of an array along the given axis. */ +array sum( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Computes the mean of the elements of an array. */ +array mean(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array mean(const array& a, StreamOrDevice s = {}) { + return mean(a, false, to_stream(s)); +} + +/** Computes the mean of the elements of an array along the given axes */ +array mean( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Computes the mean of the elements of an array along the given axis */ +array mean( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Computes the variance of the elements of an array. */ +array var(const array& a, bool keepdims, int ddof = 0, StreamOrDevice s = {}); +inline array var(const array& a, StreamOrDevice s = {}) { + return var(a, false, 0, to_stream(s)); +} + +/** Computes the variance of the elements of an array along the given + * axes */ +array var( + const array& a, + const std::vector& axes, + bool keepdims = false, + int ddof = 0, + StreamOrDevice s = {}); + +/** Computes the variance of the elements of an array along the given + * axis */ +array var( + const array& a, + int axis, + bool keepdims = false, + int ddof = 0, + StreamOrDevice s = {}); + +/** Computes the standard deviation of the elements of an array. */ +array std(const array& a, bool keepdims, int ddof = 0, StreamOrDevice s = {}); +inline array std(const array& a, StreamOrDevice s = {}) { + return std(a, false, 0, to_stream(s)); +} + +/** Computes the standard deviation of the elements of an array along the given + * axes */ +array std( + const array& a, + const std::vector& axes, + bool keepdims = false, + int ddof = 0, + StreamOrDevice s = {}); + +/** Computes the standard deviation of the elements of an array along the given + * axis */ +array std( + const array& a, + int axis, + bool keepdims = false, + int ddof = 0, + StreamOrDevice s = {}); + +/** The product of all elements of the array. */ +array prod(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array prod(const array& a, StreamOrDevice s = {}) { + return prod(a, false, to_stream(s)); +} + +/** The product of the elements of an array along the given axes. */ +array prod( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The product of the elements of an array along the given axis. */ +array prod( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The maximum of all elements of the array. */ +array max(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array max(const array& a, StreamOrDevice s = {}) { + return max(a, false, to_stream(s)); +} + +/** The maximum of the elements of an array along the given axes. */ +array max( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The maximum of the elements of an array along the given axis. */ +array max( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The minimum of all elements of the array. */ +array min(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array min(const array& a, StreamOrDevice s = {}) { + return min(a, false, to_stream(s)); +} + +/** The minimum of the elements of an array along the given axes. */ +array min( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The minimum of the elements of an array along the given axis. */ +array min( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Returns the index of the minimum value in the array. */ +array argmin(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array argmin(const array& a, StreamOrDevice s = {}) { + return argmin(a, false, s); +} + +/** Returns the indices of the minimum values along a given axis. */ +array argmin( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Returns the index of the maximum value in the array. */ +array argmax(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array argmax(const array& a, StreamOrDevice s = {}) { + return argmax(a, false, s); +} + +/** Returns the indices of the maximum values along a given axis. */ +array argmax( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Returns a sorted copy of the flattened array. */ +array sort(const array& a, StreamOrDevice s = {}); + +/** Returns a sorted copy of the array along a given axis. */ +array sort(const array& a, int axis, StreamOrDevice s = {}); + +/** Returns indices that sort the flattened array. */ +array argsort(const array& a, StreamOrDevice s = {}); + +/** Returns indices that sort the array along a given axis. */ +array argsort(const array& a, int axis, StreamOrDevice s = {}); + +/** + * Returns a partitioned copy of the flattened array + * such that the smaller kth elements are first. + **/ +array partition(const array& a, int kth, StreamOrDevice s = {}); + +/** + * Returns a partitioned copy of the array along a given axis + * such that the smaller kth elements are first. + **/ +array partition(const array& a, int kth, int axis, StreamOrDevice s = {}); + +/** + * Returns indices that partition the flattened array + * such that the smaller kth elements are first. + **/ +array argpartition(const array& a, int kth, StreamOrDevice s = {}); + +/** + * Returns indices that partition the array along a given axis + * such that the smaller kth elements are first. + **/ +array argpartition(const array& a, int kth, int axis, StreamOrDevice s = {}); + +/** Returns topk elements of the flattened array. */ +array topk(const array& a, int k, StreamOrDevice s = {}); + +/** Returns topk elements of the array along a given axis. */ +array topk(const array& a, int k, int axis, StreamOrDevice s = {}); + +/** Cumulative logsumexp of an array. */ +array logcumsumexp( + const array& a, + int axis, + bool reverse = false, + bool inclusive = true, + StreamOrDevice s = {}); + +/** The logsumexp of all elements of the array. */ +array logsumexp(const array& a, bool keepdims, StreamOrDevice s = {}); +inline array logsumexp(const array& a, StreamOrDevice s = {}) { + return logsumexp(a, false, to_stream(s)); +} + +/** The logsumexp of the elements of an array along the given axes. */ +array logsumexp( + const array& a, + const std::vector& axes, + bool keepdims = false, + StreamOrDevice s = {}); + +/** The logsumexp of the elements of an array along the given axis. */ +array logsumexp( + const array& a, + int axis, + bool keepdims = false, + StreamOrDevice s = {}); + +/** Absolute value of elements in an array. */ +array abs(const array& a, StreamOrDevice s = {}); + +/** Negate an array. */ +array negative(const array& a, StreamOrDevice s = {}); +array operator-(const array& a); + +/** The sign of the elements in an array. */ +array sign(const array& a, StreamOrDevice s = {}); + +/** Logical not of an array */ +array logical_not(const array& a, StreamOrDevice s = {}); + +/** Logical and of two arrays */ +array logical_and(const array& a, const array& b, StreamOrDevice s = {}); +array operator&&(const array& a, const array& b); + +/** Logical or of two arrays */ +array logical_or(const array& a, const array& b, StreamOrDevice s = {}); +array operator||(const array& a, const array& b); + +/** The reciprocal (1/x) of the elements in an array. */ +array reciprocal(const array& a, StreamOrDevice s = {}); + +/** Add two arrays. */ +array add(const array& a, const array& b, StreamOrDevice s = {}); +array operator+(const array& a, const array& b); +template +array operator+(T a, const array& b) { + return add(array(a), b); +} +template +array operator+(const array& a, T b) { + return add(a, array(b)); +} + +/** Subtract two arrays. */ +array subtract(const array& a, const array& b, StreamOrDevice s = {}); +array operator-(const array& a, const array& b); +template +array operator-(T a, const array& b) { + return subtract(array(a), b); +} +template +array operator-(const array& a, T b) { + return subtract(a, array(b)); +} + +/** Multiply two arrays. */ +array multiply(const array& a, const array& b, StreamOrDevice s = {}); +array operator*(const array& a, const array& b); +template +array operator*(T a, const array& b) { + return multiply(array(a), b); +} +template +array operator*(const array& a, T b) { + return multiply(a, array(b)); +} + +/** Divide two arrays. */ +array divide(const array& a, const array& b, StreamOrDevice s = {}); +array operator/(const array& a, const array& b); +array operator/(double a, const array& b); +array operator/(const array& a, double b); + +/** Compute the element-wise quotient and remainder. */ +std::vector +divmod(const array& a, const array& b, StreamOrDevice s = {}); + +/** Compute integer division. Equivalent to doing floor(a / x). */ +array floor_divide(const array& a, const array& b, StreamOrDevice s = {}); + +/** Compute the element-wise remainder of division */ +array remainder(const array& a, const array& b, StreamOrDevice s = {}); +array operator%(const array& a, const array& b); +template +array operator%(T a, const array& b) { + return remainder(array(a), b); +} +template +array operator%(const array& a, T b) { + return remainder(a, array(b)); +} + +/** Element-wise maximum between two arrays. */ +array maximum(const array& a, const array& b, StreamOrDevice s = {}); + +/** Element-wise minimum between two arrays. */ +array minimum(const array& a, const array& b, StreamOrDevice s = {}); + +/** Floor the element of an array. **/ +array floor(const array& a, StreamOrDevice s = {}); + +/** Ceil the element of an array. **/ +array ceil(const array& a, StreamOrDevice s = {}); + +/** Square the elements of an array. */ +array square(const array& a, StreamOrDevice s = {}); + +/** Exponential of the elements of an array. */ +array exp(const array& a, StreamOrDevice s = {}); + +/** Sine of the elements of an array */ +array sin(const array& a, StreamOrDevice s = {}); + +/** Cosine of the elements of an array */ +array cos(const array& a, StreamOrDevice s = {}); + +/** Tangent of the elements of an array */ +array tan(const array& a, StreamOrDevice s = {}); + +/** Arc Sine of the elements of an array */ +array arcsin(const array& a, StreamOrDevice s = {}); + +/** Arc Cosine of the elements of an array */ +array arccos(const array& a, StreamOrDevice s = {}); + +/** Arc Tangent of the elements of an array */ +array arctan(const array& a, StreamOrDevice s = {}); + +/** Inverse tangent of the ratio of two arrays */ +array arctan2(const array& a, const array& b, StreamOrDevice s = {}); + +/** Hyperbolic Sine of the elements of an array */ +array sinh(const array& a, StreamOrDevice s = {}); + +/** Hyperbolic Cosine of the elements of an array */ +array cosh(const array& a, StreamOrDevice s = {}); + +/** Hyperbolic Tangent of the elements of an array */ +array tanh(const array& a, StreamOrDevice s = {}); + +/** Inverse Hyperbolic Sine of the elements of an array */ +array arcsinh(const array& a, StreamOrDevice s = {}); + +/** Inverse Hyperbolic Cosine of the elements of an array */ +array arccosh(const array& a, StreamOrDevice s = {}); + +/** Inverse Hyperbolic Tangent of the elements of an array */ +array arctanh(const array& a, StreamOrDevice s = {}); + +/** Convert the elements of an array from Radians to Degrees **/ +array degrees(const array& a, StreamOrDevice s = {}); + +/** Convert the elements of an array from Degrees to Radians **/ +array radians(const array& a, StreamOrDevice s = {}); + +/** Natural logarithm of the elements of an array. */ +array log(const array& a, StreamOrDevice s = {}); + +/** Log base 2 of the elements of an array. */ +array log2(const array& a, StreamOrDevice s = {}); + +/** Log base 10 of the elements of an array. */ +array log10(const array& a, StreamOrDevice s = {}); + +/** Natural logarithm of one plus elements in the array: `log(1 + a)`. */ +array log1p(const array& a, StreamOrDevice s = {}); + +/** Log-add-exp of one elements in the array: `log(exp(a) + exp(b))`. */ +array logaddexp(const array& a, const array& b, StreamOrDevice s = {}); + +/** Element-wise logistic sigmoid of the array: `1 / (1 + exp(-x)`. */ +array sigmoid(const array& a, StreamOrDevice s = {}); + +/** Computes the error function of the elements of an array. */ +array erf(const array& a, StreamOrDevice s = {}); + +/** Computes the inverse error function of the elements of an array. */ +array erfinv(const array& a, StreamOrDevice s = {}); + +/** Computes the expm1 function of the elements of an array. */ +array expm1(const array& a, StreamOrDevice s = {}); + +/** Stop the flow of gradients. */ +array stop_gradient(const array& a, StreamOrDevice s = {}); + +/** Round a floating point number */ +array round(const array& a, int decimals, StreamOrDevice s = {}); +inline array round(const array& a, StreamOrDevice s = {}) { + return round(a, 0, s); +} + +/** Matrix-matrix multiplication. */ +array matmul(const array& a, const array& b, StreamOrDevice s = {}); + +/** Gather array entries given indices and slices */ +array gather( + const array& a, + const std::vector& indices, + const std::vector& axes, + const Shape& slice_sizes, + StreamOrDevice s = {}); +inline array gather( + const array& a, + const array& indices, + int axis, + const Shape& slice_sizes, + StreamOrDevice s = {}) { + return gather(a, {indices}, std::vector{axis}, slice_sizes, s); +} + +/** Compute the Kronecker product of two arrays. */ +array kron(const array& a, const array& b, StreamOrDevice s = {}); + +/** Take array slices at the given indices of the specified axis. */ +array take( + const array& a, + const array& indices, + int axis, + StreamOrDevice s = {}); +array take(const array& a, int index, int axis, StreamOrDevice s = {}); + +/** Take array entries at the given indices treating the array as flattened. */ +array take(const array& a, const array& indices, StreamOrDevice s = {}); +array take(const array& a, int index, StreamOrDevice s = {}); + +/** Take array entries given indices along the axis */ +array take_along_axis( + const array& a, + const array& indices, + int axis, + StreamOrDevice s = {}); + +/** Put the values into the array at the given indices along the axis */ +array put_along_axis( + const array& a, + const array& indices, + const array& values, + int axis, + StreamOrDevice s = {}); + +/** Add the values into the array at the given indices along the axis */ +array scatter_add_axis( + const array& a, + const array& indices, + const array& values, + int axis, + StreamOrDevice s = {}); + +/** Scatter updates to the given indices. + * + * The parameters ``indices`` and ``axes`` determine the locations of ``a`` + * that are updated with the values in ``updates``. Assuming 1-d ``indices`` + * for simplicity, ``indices[i]`` are the indices on axis ``axes[i]`` to which + * the values in ``updates`` will be applied. Note each array in + * ``indices`` is assigned to a corresponding axis and hence ``indices.size() == + * axes.size()``. If an index/axis pair is not provided then indices along that + * axis are assumed to be zero. + * + * Note the rank of ``updates`` must be equal to the sum of the rank of the + * broadcasted ``indices`` and the rank of ``a``. In other words, assuming the + * arrays in ``indices`` have the same shape, ``updates.ndim() == + * indices[0].ndim() + a.ndim()``. The leading dimensions of ``updates`` + * correspond to the indices, and the remaining ``a.ndim()`` dimensions are the + * values that will be applied to the given location in ``a``. + * + * For example: + * + * @code + * auto in = zeros({4, 4}, float32); + * auto indices = array({2}); + * auto updates = reshape(arange(1, 3, float32), {1, 1, 2}); + * std::vector axes{0}; + * + * auto out = scatter(in, {indices}, updates, axes); + * @endcode + * + * will produce: + * + * @code + * array([[0, 0, 0, 0], + * [0, 0, 0, 0], + * [1, 2, 0, 0], + * [0, 0, 0, 0]], dtype=float32) + * @endcode + * + * This scatters the two-element row vector ``[1, 2]`` starting at the ``(2, + * 0)`` position of ``a``. + * + * Adding another element to ``indices`` will scatter into another location of + * ``a``. We also have to add an another update for the new index: + * + * @code + * auto in = zeros({4, 4}, float32); + * auto indices = array({2, 0}); + * auto updates = reshape(arange(1, 5, float32), {2, 1, 2}); + * std::vector axes{0}; + * + * auto out = scatter(in, {indices}, updates, axes): + * @endcode + * + * will produce: + * + * @code + * array([[3, 4, 0, 0], + * [0, 0, 0, 0], + * [1, 2, 0, 0], + * [0, 0, 0, 0]], dtype=float32) + * @endcode + * + * To control the scatter location on an additional axis, add another index + * array to ``indices`` and another axis to ``axes``: + * + * @code + * auto in = zeros({4, 4}, float32); + * auto indices = std::vector{array({2, 0}), array({1, 2})}; + * auto updates = reshape(arange(1, 5, float32), {2, 1, 2}); + * std::vector axes{0, 1}; + * + * auto out = scatter(in, indices, updates, axes); + * @endcode + * + * will produce: + * + * @code + * array([[0, 0, 3, 4], + * [0, 0, 0, 0], + * [0, 1, 2, 0], + * [0, 0, 0, 0]], dtype=float32) + * @endcode + * + * Items in indices are broadcasted together. This means: + * + * @code + * auto indices = std::vector{array({2, 0}), array({1})}; + * @endcode + * + * is equivalent to: + * + * @code + * auto indices = std::vector{array({2, 0}), array({1, 1})}; + * @endcode + * + * Note, ``scatter`` does not perform bounds checking on the indices and + * updates. Out-of-bounds accesses on ``a`` are undefined and typically result + * in unintended or invalid memory writes. + */ +array scatter( + const array& a, + const std::vector& indices, + const array& updates, + const std::vector& axes, + StreamOrDevice s = {}); +inline array scatter( + const array& a, + const array& indices, + const array& updates, + int axis, + StreamOrDevice s = {}) { + return scatter(a, {indices}, updates, std::vector{axis}, s); +} + +/** Scatter and add updates to given indices */ +array scatter_add( + const array& a, + const std::vector& indices, + const array& updates, + const std::vector& axes, + StreamOrDevice s = {}); +inline array scatter_add( + const array& a, + const array& indices, + const array& updates, + int axis, + StreamOrDevice s = {}) { + return scatter_add(a, {indices}, updates, std::vector{axis}, s); +} + +/** Scatter and prod updates to given indices */ +array scatter_prod( + const array& a, + const std::vector& indices, + const array& updates, + const std::vector& axes, + StreamOrDevice s = {}); +inline array scatter_prod( + const array& a, + const array& indices, + const array& updates, + int axis, + StreamOrDevice s = {}) { + return scatter_prod(a, {indices}, updates, std::vector{axis}, s); +} + +/** Scatter and max updates to given linear indices */ +array scatter_max( + const array& a, + const std::vector& indices, + const array& updates, + const std::vector& axes, + StreamOrDevice s = {}); +inline array scatter_max( + const array& a, + const array& indices, + const array& updates, + int axis, + StreamOrDevice s = {}) { + return scatter_max(a, {indices}, updates, std::vector{axis}, s); +} +/** Scatter and min updates to given linear indices */ +array scatter_min( + const array& a, + const std::vector& indices, + const array& updates, + const std::vector& axes, + StreamOrDevice s = {}); +inline array scatter_min( + const array& a, + const array& indices, + const array& updates, + int axis, + StreamOrDevice s = {}) { + return scatter_min(a, {indices}, updates, std::vector{axis}, s); +} + +/** Square root the elements of an array. */ +array sqrt(const array& a, StreamOrDevice s = {}); + +/** Square root and reciprocal the elements of an array. */ +array rsqrt(const array& a, StreamOrDevice s = {}); + +/** Softmax of an array. */ +array softmax( + const array& a, + const std::vector& axes, + bool precise = false, + StreamOrDevice s = {}); + +/** Softmax of an array. */ +array softmax(const array& a, bool precise = false, StreamOrDevice s = {}); + +/** Softmax of an array. */ +inline array +softmax(const array& a, int axis, bool precise = false, StreamOrDevice s = {}) { + return softmax(a, std::vector{axis}, precise, s); +} + +/** Raise elements of a to the power of b element-wise */ +array power(const array& a, const array& b, StreamOrDevice s = {}); + +/** Cumulative sum of an array. */ +array cumsum( + const array& a, + int axis, + bool reverse = false, + bool inclusive = true, + StreamOrDevice s = {}); + +/** Cumulative product of an array. */ +array cumprod( + const array& a, + int axis, + bool reverse = false, + bool inclusive = true, + StreamOrDevice s = {}); + +/** Cumulative max of an array. */ +array cummax( + const array& a, + int axis, + bool reverse = false, + bool inclusive = true, + StreamOrDevice s = {}); + +/** Cumulative min of an array. */ +array cummin( + const array& a, + int axis, + bool reverse = false, + bool inclusive = true, + StreamOrDevice s = {}); + +/** General convolution with a filter */ +array conv_general( + array input, + array weight, + std::vector stride = {}, + std::vector padding_lo = {}, + std::vector padding_hi = {}, + std::vector kernel_dilation = {}, + std::vector input_dilation = {}, + int groups = 1, + bool flip = false, + StreamOrDevice s = {}); + +/** General convolution with a filter */ +inline array conv_general( + const array& input, + const array& weight, + std::vector stride = {}, + std::vector padding = {}, + std::vector kernel_dilation = {}, + std::vector input_dilation = {}, + int groups = 1, + bool flip = false, + StreamOrDevice s = {}) { + return conv_general( + /* const array& input = */ input, + /* const array& weight = */ weight, + /* std::vector stride = */ stride, + /* std::vector padding_lo = */ padding, + /* std::vector padding_hi = */ padding, + /* std::vector kernel_dilation = */ kernel_dilation, + /* std::vector input_dilation = */ input_dilation, + /* int groups = */ groups, + /* bool flip = */ flip, + /* StreamOrDevice s = */ s); +} + +/** 1D convolution with a filter */ +array conv1d( + const array& input, + const array& weight, + int stride = 1, + int padding = 0, + int dilation = 1, + int groups = 1, + StreamOrDevice s = {}); + +/** 2D convolution with a filter */ +array conv2d( + const array& input, + const array& weight, + const std::pair& stride = {1, 1}, + const std::pair& padding = {0, 0}, + const std::pair& dilation = {1, 1}, + int groups = 1, + StreamOrDevice s = {}); + +/** 3D convolution with a filter */ +array conv3d( + const array& input, + const array& weight, + const std::tuple& stride = {1, 1, 1}, + const std::tuple& padding = {0, 0, 0}, + const std::tuple& dilation = {1, 1, 1}, + int groups = 1, + StreamOrDevice s = {}); + +/** 1D transposed convolution with a filter */ +array conv_transpose1d( + const array& input, + const array& weight, + int stride = 1, + int padding = 0, + int dilation = 1, + int output_padding = 0, + int groups = 1, + StreamOrDevice s = {}); + +/** 2D transposed convolution with a filter */ +array conv_transpose2d( + const array& input, + const array& weight, + const std::pair& stride = {1, 1}, + const std::pair& padding = {0, 0}, + const std::pair& dilation = {1, 1}, + const std::pair& output_padding = {0, 0}, + int groups = 1, + StreamOrDevice s = {}); + +/** 3D transposed convolution with a filter */ +array conv_transpose3d( + const array& input, + const array& weight, + const std::tuple& stride = {1, 1, 1}, + const std::tuple& padding = {0, 0, 0}, + const std::tuple& dilation = {1, 1, 1}, + const std::tuple& output_padding = {0, 0, 0}, + int groups = 1, + StreamOrDevice s = {}); + +/** Quantized matmul multiplies x with a quantized matrix w*/ +array quantized_matmul( + array x, + array w, + array scales, + std::optional biases = std::nullopt, + bool transpose = true, + int group_size = 64, + int bits = 4, + const std::string& mode = "affine", + StreamOrDevice s = {}); + +/** Quantize a matrix along its last axis */ +std::vector quantize( + const array& w, + int group_size = 64, + int bits = 4, + const std::string& mode = "affine", + StreamOrDevice s = {}); + +/** Dequantize a matrix produced by quantize() */ +array dequantize( + const array& w, + const array& scales, + const std::optional& biases = std::nullopt, + int group_size = 64, + int bits = 4, + const std::string& mode = "affine", + StreamOrDevice s = {}); + +/** Compute matrix products with matrix-level gather. */ +array gather_qmm( + const array& x, + const array& w, + const array& scales, + const std::optional& biases = std::nullopt, + std::optional lhs_indices = std::nullopt, + std::optional rhs_indices = std::nullopt, + bool transpose = true, + int group_size = 64, + int bits = 4, + const std::string& mode = "affine", + bool sorted_indices = false, + StreamOrDevice s = {}); + +/** Returns a contraction of a and b over multiple dimensions. */ +array tensordot( + const array& a, + const array& b, + const int axis = 2, + StreamOrDevice s = {}); + +array tensordot( + const array& a, + const array& b, + const std::vector& axes_a, + const std::vector& axes_b, + StreamOrDevice s = {}); + +/** Compute the outer product of two vectors. */ +array outer(const array& a, const array& b, StreamOrDevice s = {}); + +/** Compute the inner product of two vectors. */ +array inner(const array& a, const array& b, StreamOrDevice s = {}); + +/** Compute D = beta * C + alpha * (A @ B) */ +array addmm( + array c, + array a, + array b, + const float& alpha = 1.f, + const float& beta = 1.f, + StreamOrDevice s = {}); + +/** Compute matrix product with block masking */ +array block_masked_mm( + array a, + array b, + int block_size, + std::optional mask_out = std::nullopt, + std::optional mask_lhs = std::nullopt, + std::optional mask_rhs = std::nullopt, + StreamOrDevice s = {}); + +/** Compute matrix product with matrix-level gather */ +array gather_mm( + array a, + array b, + std::optional lhs_indices = std::nullopt, + std::optional rhs_indices = std::nullopt, + bool sorted_indices = false, + StreamOrDevice s = {}); + +/** + * Compute a matrix product but segment the inner dimension and write the + * result separately for each segment. + */ +array segmented_mm(array a, array b, array segments, StreamOrDevice s = {}); + +/** Extract a diagonal or construct a diagonal array */ +array diagonal( + const array& a, + int offset = 0, + int axis1 = 0, + int axis2 = 1, + StreamOrDevice s = {}); + +/** Extract diagonal from a 2d array or create a diagonal matrix. */ +array diag(const array& a, int k = 0, StreamOrDevice s = {}); + +/** Return the sum along a specified diagonal in the given array. */ +array trace( + const array& a, + int offset, + int axis1, + int axis2, + Dtype dtype, + StreamOrDevice s = {}); +array trace( + const array& a, + int offset, + int axis1, + int axis2, + StreamOrDevice s = {}); +array trace(const array& a, StreamOrDevice s = {}); + +/** + * Implements the identity function but allows injecting dependencies to other + * arrays. This ensures that these other arrays will have been computed + * when the outputs of this function are computed. + */ +std::vector depends( + const std::vector& inputs, + const std::vector& dependencies); + +/** convert an array to an atleast ndim array */ +array atleast_1d(const array& a, StreamOrDevice s = {}); +std::vector atleast_1d( + const std::vector& a, + StreamOrDevice s = {}); +array atleast_2d(const array& a, StreamOrDevice s = {}); +std::vector atleast_2d( + const std::vector& a, + StreamOrDevice s = {}); +array atleast_3d(const array& a, StreamOrDevice s = {}); +std::vector atleast_3d( + const std::vector& a, + StreamOrDevice s = {}); + +/** + * Extract the number of elements along some axes as a scalar array. Used to + * allow shape dependent shapeless compilation (pun intended). + */ +array number_of_elements( + const array& a, + std::vector axes, + bool inverted, + Dtype dtype = int32, + StreamOrDevice s = {}); + +array conjugate(const array& a, StreamOrDevice s = {}); + +/** Bitwise and. */ +array bitwise_and(const array& a, const array& b, StreamOrDevice s = {}); +array operator&(const array& a, const array& b); + +/** Bitwise inclusive or. */ +array bitwise_or(const array& a, const array& b, StreamOrDevice s = {}); +array operator|(const array& a, const array& b); + +/** Bitwise exclusive or. */ +array bitwise_xor(const array& a, const array& b, StreamOrDevice s = {}); +array operator^(const array& a, const array& b); + +/** Shift bits to the left. */ +array left_shift(const array& a, const array& b, StreamOrDevice s = {}); +array operator<<(const array& a, const array& b); + +/** Shift bits to the right. */ +array right_shift(const array& a, const array& b, StreamOrDevice s = {}); +array operator>>(const array& a, const array& b); + +/** Invert the bits. */ +array bitwise_invert(const array& a, StreamOrDevice s = {}); +array operator~(const array& a); + +array view(const array& a, const Dtype& dtype, StreamOrDevice s = {}); + +/** Roll elements along an axis and introduce them on the other side */ +array roll(const array& a, int shift, StreamOrDevice s = {}); +array roll(const array& a, const Shape& shift, StreamOrDevice s = {}); +array roll(const array& a, int shift, int axis, StreamOrDevice s = {}); +array roll( + const array& a, + int shift, + const std::vector& axes, + StreamOrDevice s = {}); +array roll(const array& a, const Shape& shift, int axis, StreamOrDevice s = {}); +array roll( + const array& a, + const Shape& shift, + const std::vector& axes, + StreamOrDevice s = {}); + +/* The real part of a complex array. */ +array real(const array& a, StreamOrDevice s = {}); + +/* The imaginary part of a complex array. */ +array imag(const array& a, StreamOrDevice s = {}); + +/* Ensure the array's underlying memory is contiguous. */ +array contiguous( + const array& a, + bool allow_col_major = false, + StreamOrDevice s = {}); + +/** @} */ + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-random.h b/Source/Cmlx/include-framework/mlx-random.h new file mode 100644 index 00000000..09beebce --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-random.h @@ -0,0 +1,284 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include +#include + +#include +#include +#include + +namespace mlx::core::random { + +class KeySequence { + public: + explicit KeySequence(uint64_t seed); + + void seed(uint64_t seed); + array next(); + + // static default + static KeySequence& default_() { + static KeySequence ks(get_current_time_seed()); + return ks; + } + + private: + array key_; + static uint64_t get_current_time_seed() { + auto now = std::chrono::system_clock::now(); + return std::chrono::duration_cast( + now.time_since_epoch()) + .count(); + } +}; + +/** Get a PRNG key from a seed. */ +array key(uint64_t seed); + +/** Seed the default PRNG key. */ +void seed(uint64_t seed); + +/** Generate an array with type uint32 filled with random bits. */ +array bits( + const Shape& shape, + int width, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); +inline array bits( + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return bits(shape, 4, key, s); +} + +/** Split the rng key into a pair of keys. */ +std::pair split(const array& key, StreamOrDevice s = {}); + +/** Split the rng key into `num` keys. */ +array split(const array& key, int num, StreamOrDevice s = {}); + +/** Generate uniform random numbers between low and high. */ +array uniform( + const array& low, + const array& high, + const Shape& shape, + Dtype dtype = float32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +template +array uniform( + T low, + U high, + const Shape& shape, + Dtype dtype = float32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return uniform(array(low), array(high), shape, dtype, key, to_stream(s)); +} + +/** Generate uniform random numbers between 0 and 1. */ +array uniform( + const Shape& shape, + Dtype dtype, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); +inline array uniform( + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return uniform(shape, float32, key); +} + +/** Generate samples from the standard normal distribution. */ +array normal( + const Shape& shape, + Dtype dtype, + const std::optional& loc, + const std::optional& scale, + const std::optional& key, + StreamOrDevice s = {}); +inline array normal( + const Shape& shape, + Dtype dtype, + const float loc, + const float scale, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + auto loc_ = loc == 0 ? std::nullopt : std::make_optional(array(loc, dtype)); + auto scale_ = + scale == 1 ? std::nullopt : std::make_optional(array(scale, dtype)); + return normal(shape, dtype, loc_, scale_, key, s); +} +inline array normal( + const Shape& shape, + const float loc, + const float scale, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return normal(shape, float32, loc, scale, key, s); +} +inline array normal( + const Shape& shape, + const Dtype dtype, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return normal(shape, dtype, std::nullopt, std::nullopt, key, s); +} +inline array normal( + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return normal(shape, float32, std::nullopt, std::nullopt, key, s); +} + +/** Generate samples from a multivariate normal distribution. **/ +array multivariate_normal( + const array& mean, + const array& cov, + const Shape& shape, + Dtype dtype, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +/** Generate integer samples uniformly at random */ +array randint( + const array& low, + const array& high, + const Shape& shape, + Dtype dtype = int32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +template +array randint( + T low, + U high, + const Shape& shape, + Dtype dtype = int32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return randint(array(low), array(high), shape, dtype, key, to_stream(s)); +} + +/** Generate binary variables with probability to be true equal to p */ +array bernoulli( + const array& p, + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); +array bernoulli( + const array& p, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +template +array bernoulli( + T p, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return bernoulli(array(p), key, s); +} + +template +array bernoulli( + T p, + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return bernoulli(array(p), shape, key, s); +} + +array bernoulli( + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array truncated_normal( + const array& lower, + const array& upper, + const Shape& shape, + Dtype dtype = float32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array truncated_normal( + const array& lower, + const array& upper, + Dtype dtype = float32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array gumbel( + const Shape& shape, + Dtype dtype = float32, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array categorical( + const array& logits, + int axis, + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array categorical( + const array& logits_, + int axis, + int num_samples, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +array categorical( + const array& logits, + int axis = -1, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +/** Generate samples from the laplace distribution. */ +array laplace( + const Shape& shape, + Dtype dtype, + const float loc, + const float scale, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); +inline array laplace( + const Shape& shape, + const float loc, + const float scale, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return laplace(shape, float32, loc, scale, key, s); +} +inline array laplace( + const Shape& shape, + const Dtype dtype, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return laplace(shape, dtype, 0.0, 1.0, key, s); +} +inline array laplace( + const Shape& shape, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}) { + return laplace(shape, float32, 0.0, 1.0, key, s); +} + +/* Randomly permute the elements of x along the given axis. */ +array permutation( + const array& x, + int axis = 0, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +/* A random permutation of `arange(x)` */ +array permutation( + int x, + const std::optional& key = std::nullopt, + StreamOrDevice s = {}); + +} // namespace mlx::core::random +#endif diff --git a/Source/Cmlx/include-framework/mlx-small_vector.h b/Source/Cmlx/include-framework/mlx-small_vector.h new file mode 100644 index 00000000..073c7d8e --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-small_vector.h @@ -0,0 +1,542 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. +// Copyright © 2018 the V8 project authors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#pragma once + +#include +#include +#include +#include + +namespace mlx::core { + +#if defined(__has_builtin) +#define MLX_HAS_BUILTIN(x) __has_builtin(x) +#else +#define MLX_HAS_BUILTIN(x) 0 +#endif + +#if defined(__has_attribute) +#define MLX_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +#define MLX_HAS_ATTRIBUTE(x) 0 +#endif + +#if MLX_HAS_BUILTIN(__builtin_expect) +#define MLX_LIKELY(condition) (__builtin_expect(!!(condition), 1)) +#define MLX_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) +#else +#define MLX_LIKELY(condition) (condition) +#define MLX_UNLIKELY(condition) (condition) +#endif + +#if MLX_HAS_ATTRIBUTE(noinline) +#define MLX_NOINLINE __attribute__((noinline)) +#else +#define MLX_NOINLINE +#endif + +template +struct is_iterator : std::false_type {}; + +template +struct is_iterator< + T, + std::void_t< + typename std::iterator_traits::difference_type, + typename std::iterator_traits::iterator_category, + typename std::iterator_traits::pointer, + typename std::iterator_traits::reference, + typename std::iterator_traits::value_type>> : std::true_type {}; + +template +constexpr bool is_iterator_v = is_iterator::value; + +// Minimal SmallVector implementation. Uses inline storage first, switches to +// dynamic storage when it overflows. +// +// Notes: +// * The default inline storage size is MAX_NDIM, as it is mainly used for +// shapes and strides, users should choose a better size for other cases. +// * The data() returns real address even for empty vector. +// * The pointer returned by data() will change after moving the vector as it +// points to the inline storage. +// * For trivial elements the storage will not be default constructed, +// i.e. SmallVector(10) will not be filled with 0 by default. +template > +class SmallVector { + public: + using value_type = T; + using reference = T&; + using const_reference = const T&; + using iterator = T*; + using const_iterator = const T*; + using difference_type = std::ptrdiff_t; + using size_type = std::size_t; + + SmallVector() = default; + + explicit SmallVector(const Allocator& allocator) : allocator_(allocator) {} + + explicit SmallVector(size_t size, const Allocator& allocator = Allocator()) + : allocator_(allocator) { + resize(size); + } + + SmallVector( + size_t size, + const T& initial_value, + const Allocator& allocator = Allocator()) + : allocator_(allocator) { + resize(size, initial_value); + } + + SmallVector( + std::initializer_list init, + const Allocator& allocator = Allocator()) + : allocator_(allocator) { + if (init.size() > capacity()) { + grow(init.size()); + } + assert(capacity() >= init.size()); // sanity check + std::uninitialized_move(init.begin(), init.end(), begin_); + end_ = begin_ + init.size(); + } + + template >> + SmallVector(Iter begin, Iter end, const Allocator& allocator = Allocator()) + : allocator_(allocator) { + size_t size = std::distance(begin, end); + if (size > capacity()) { + grow(size); + } + assert(capacity() >= size); // sanity check + std::uninitialized_copy(begin, end, begin_); + end_ = begin_ + size; + } + + SmallVector(const SmallVector& other) : allocator_(other.allocator_) { + *this = other; + } + SmallVector(const SmallVector& other, const Allocator& allocator) + : allocator_(allocator) { + *this = other; + } + SmallVector(SmallVector&& other) : allocator_(std::move(other.allocator_)) { + *this = std::move(other); + } + SmallVector(SmallVector&& other, const Allocator& allocator) + : allocator_(allocator) { + *this = std::move(other); + } + + ~SmallVector() { + free_storage(); + } + + SmallVector& operator=(const SmallVector& other) { + if (this == &other) { + return *this; + } + size_t other_size = other.size(); + if (capacity() < other_size) { + // Create large-enough heap-allocated storage. + free_storage(); + begin_ = allocator_.allocate(other_size); + end_of_storage_ = begin_ + other_size; + std::uninitialized_copy(other.begin_, other.end_, begin_); + } else if constexpr (kHasTrivialElement) { + std::copy(other.begin_, other.end_, begin_); + } else { + ptrdiff_t to_copy = + std::min(static_cast(other_size), end_ - begin_); + std::copy(other.begin_, other.begin_ + to_copy, begin_); + if (other.begin_ + to_copy < other.end_) { + std::uninitialized_copy( + other.begin_ + to_copy, other.end_, begin_ + to_copy); + } else { + std::destroy_n(begin_ + to_copy, size() - to_copy); + } + } + end_ = begin_ + other_size; + return *this; + } + + SmallVector& operator=(SmallVector&& other) { + if (this == &other) { + return *this; + } + if (other.is_big()) { + free_storage(); + begin_ = other.begin_; + end_ = other.end_; + end_of_storage_ = other.end_of_storage_; + } else { + assert(capacity() >= other.size()); // sanity check + size_t other_size = other.size(); + if constexpr (kHasTrivialElement) { + std::move(other.begin_, other.end_, begin_); + } else { + ptrdiff_t to_move = + std::min(static_cast(other_size), end_ - begin_); + std::move(other.begin_, other.begin_ + to_move, begin_); + if (other.begin_ + to_move < other.end_) { + std::uninitialized_move( + other.begin_ + to_move, other.end_, begin_ + to_move); + } else { + std::destroy_n(begin_ + to_move, size() - to_move); + } + } + end_ = begin_ + other_size; + } + other.reset_to_inline_storage(); + return *this; + } + + bool operator==(const SmallVector& other) const { + if (size() != other.size()) { + return false; + } + return std::equal(begin_, end_, other.begin_); + } + + bool operator!=(const SmallVector& other) const { + return !(*this == other); + } + + T* data() { + return begin_; + } + const T* data() const { + return begin_; + } + + iterator begin() { + return begin_; + } + const_iterator begin() const { + return begin_; + } + + iterator end() { + return end_; + } + const_iterator end() const { + return end_; + } + + const_iterator cbegin() const { + return begin_; + } + + const_iterator cend() const { + return end_; + } + + auto rbegin() { + return std::make_reverse_iterator(end_); + } + auto rbegin() const { + return std::make_reverse_iterator(end_); + } + + auto rend() { + return std::make_reverse_iterator(begin_); + } + auto rend() const { + return std::make_reverse_iterator(begin_); + } + + size_t size() const { + return end_ - begin_; + } + bool empty() const { + return end_ == begin_; + } + size_t capacity() const { + return end_of_storage_ - begin_; + } + + T& front() { + assert(size() != 0); + return begin_[0]; + } + const T& front() const { + assert(size() != 0); + return begin_[0]; + } + + T& back() { + assert(size() != 0); + return end_[-1]; + } + const T& back() const { + assert(size() != 0); + return end_[-1]; + } + + T& at(size_t index) { + if (index >= size()) { + throw std::out_of_range("SmallVector out of range."); + } + return begin_[index]; + } + const T& at(size_t index) const { + return const_cast(this)->at(index); + } + + T& operator[](size_t index) { + assert(size() > index); + return begin_[index]; + } + const T& operator[](size_t index) const { + return const_cast(this)->operator[](index); + } + + template + void emplace_back(Args&&... args) { + if (MLX_UNLIKELY(end_ == end_of_storage_)) { + grow(); + } + void* storage = end_; + end_ += 1; + new (storage) T(std::forward(args)...); + } + + void push_back(T x) { + emplace_back(std::move(x)); + } + + void pop_back(size_t count = 1) { + assert(size() >= count); + end_ -= count; + std::destroy_n(end_, count); + } + + iterator insert(iterator pos, T value) { + return insert(pos, static_cast(1), std::move(value)); + } + + iterator insert(iterator pos, size_t count, T value) { + assert(pos <= end_); + size_t offset = pos - begin_; + size_t old_size = size(); + resize(old_size + count); + pos = begin_ + offset; + iterator old_end = begin_ + old_size; + assert(old_end <= end_); + std::move_backward(pos, old_end, end_); + if constexpr (kHasTrivialElement) { + std::fill_n(pos, count, value); + } else { + std::fill_n(pos + 1, count - 1, value); + *pos = std::move(value); + } + return pos; + } + + template >> + iterator insert(iterator pos, Iter begin, Iter end) { + if constexpr (std::is_same_v, iterator>) { + // The implementation can not take overlapping range. + assert(!(begin >= pos && begin < pos + std::distance(begin, end))); + assert(!(end > pos && end <= pos + std::distance(begin, end))); + } + + assert(pos <= end_); + size_t offset = pos - begin_; + size_t count = std::distance(begin, end); + size_t old_size = size(); + resize(old_size + count); + pos = begin_ + offset; + iterator old_end = begin_ + old_size; + assert(old_end <= end_); + std::move_backward(pos, old_end, end_); + std::copy(begin, end, pos); + return pos; + } + + iterator insert(iterator pos, std::initializer_list values) { + return insert(pos, values.begin(), values.end()); + } + + iterator erase(iterator erase_start, iterator erase_end) { + assert(erase_start >= begin_); + assert(erase_start <= erase_end); + assert(erase_end <= end_); + iterator new_end = std::move(erase_end, end_, erase_start); + std::destroy_n(new_end, std::distance(new_end, end_)); + end_ = new_end; + return erase_start; + } + + iterator erase(iterator pos) { + return erase(pos, pos + 1); + } + + void resize(size_t new_size) { + if (new_size > capacity()) { + grow(new_size); + } + T* new_end = begin_ + new_size; + if constexpr (!kHasTrivialElement) { + if (new_end > end_) { + std::uninitialized_default_construct(end_, new_end); + } else { + std::destroy_n(new_end, end_ - new_end); + } + } + end_ = new_end; + } + + void resize(size_t new_size, const T& initial_value) { + if (new_size > capacity()) { + grow(new_size); + } + T* new_end = begin_ + new_size; + if (new_end > end_) { + std::uninitialized_fill(end_, new_end, initial_value); + } else { + std::destroy_n(new_end, end_ - new_end); + } + end_ = new_end; + } + + void reserve(size_t new_capacity) { + if (new_capacity > capacity()) { + grow(new_capacity); + } + } + + // Clear without reverting back to inline storage. + void clear() { + std::destroy_n(begin_, end_ - begin_); + end_ = begin_; + } + + private: + // Grows the backing store by a factor of two, and at least to {min_capacity}. + // TODO: Move to private after removing external code using this method. + MLX_NOINLINE void grow(size_t min_capacity = 0) { + size_t new_capacity = std::max(min_capacity, 2 * capacity()); + // Round up to power of 2. + new_capacity--; + new_capacity |= new_capacity >> 1; + new_capacity |= new_capacity >> 2; + new_capacity |= new_capacity >> 4; + new_capacity |= new_capacity >> 8; + new_capacity |= new_capacity >> 16; + if constexpr (sizeof(size_t) == sizeof(uint64_t)) { + new_capacity |= new_capacity >> 32; + } + new_capacity++; + + T* new_storage = allocator_.allocate(new_capacity); + if (new_storage == nullptr) { + throw std::bad_alloc(); + } + + size_t in_use = end_ - begin_; + std::uninitialized_move(begin_, end_, new_storage); + free_storage(); + begin_ = new_storage; + end_ = new_storage + in_use; + end_of_storage_ = new_storage + new_capacity; + } + + MLX_NOINLINE void free_storage() { + std::destroy_n(begin_, end_ - begin_); + if (is_big()) { + allocator_.deallocate(begin_, end_of_storage_ - begin_); + } + } + + // Clear and go back to inline storage. Dynamic storage is *not* freed. For + // internal use only. + void reset_to_inline_storage() { + if constexpr (!kHasTrivialElement) { + if (!is_big()) + std::destroy_n(begin_, end_ - begin_); + } + begin_ = inline_storage_begin(); + end_ = begin_; + end_of_storage_ = begin_ + kSize; + } + + bool is_big() const { + return begin_ != inline_storage_begin(); + } + + T* inline_storage_begin() { + return reinterpret_cast(inline_storage_); + } + const T* inline_storage_begin() const { + return reinterpret_cast(inline_storage_); + } + + Allocator allocator_; + + // Invariants: + // 1. The elements in the range between `begin_` (included) and `end_` (not + // included) will be initialized at all times. + // 2. All other elements outside the range, both in the inline storage and in + // the dynamic storage (if it exists), will be uninitialized at all times. + + T* begin_ = inline_storage_begin(); + T* end_ = begin_; + T* end_of_storage_ = begin_ + kSize; + + alignas(T) char inline_storage_[sizeof(T) * kSize]; + + static constexpr bool kHasTrivialElement = + std::is_trivially_copyable::value && + std::is_trivially_destructible::value; +}; + +template +struct is_vector : std::false_type {}; + +template +struct is_vector> : std::true_type {}; + +template +struct is_vector> : std::true_type {}; + +template +inline constexpr bool is_vector_v = is_vector::value; + +#undef MLX_HAS_BUILTIN +#undef MLX_HAS_ATTRIBUTE +#undef MLX_LIKELY +#undef MLX_UNLIKELY +#undef MLX_NOINLINE + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-stream.h b/Source/Cmlx/include-framework/mlx-stream.h new file mode 100644 index 00000000..b8da0ea2 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-stream.h @@ -0,0 +1,43 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include + +namespace mlx::core { + +struct Stream { + int index; + Device device; + explicit Stream(int index, Device device) : index(index), device(device) {} +}; + +/** Get the default stream for the given device. */ +Stream default_stream(Device d); + +/** Make the stream the default for its device. */ +void set_default_stream(Stream s); + +/** Make a new stream on the given device. */ +Stream new_stream(Device d); + +/** Get the stream with the given index. */ +Stream get_stream(int index); + +inline bool operator==(const Stream& lhs, const Stream& rhs) { + return lhs.index == rhs.index; +} + +inline bool operator!=(const Stream& lhs, const Stream& rhs) { + return !(lhs == rhs); +} + +/* Synchronize with the default stream. */ +void synchronize(); + +/* Synchronize with the provided stream. */ +void synchronize(Stream); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-threadpool.h b/Source/Cmlx/include-framework/mlx-threadpool.h new file mode 100644 index 00000000..473a9c1e --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-threadpool.h @@ -0,0 +1,135 @@ +#ifdef __cplusplus +// This code was modified from https://github.com/progschj/ThreadPool +// The original License is copied below: +// +// Copyright (c) 2012 Jakob Progsch, Václav Zeman +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ThreadPool { + public: + ThreadPool(size_t); + template + auto enqueue(F&& f, Args&&... args) + -> std::future>; + void resize(size_t); + ~ThreadPool(); + + private: + void stop_and_wait(); + void start_threads(size_t); + + std::vector workers; + std::queue> tasks; + std::mutex queue_mutex; + std::condition_variable condition; + bool stop; +}; + +inline ThreadPool::ThreadPool(size_t threads) : stop(false) { + start_threads(threads); +} + +template +auto ThreadPool::enqueue(F&& f, Args&&... args) + -> std::future> { + using return_type = typename std::invoke_result_t; + + auto task = std::make_shared>( + std::bind(std::forward(f), std::forward(args)...)); + + std::future res = task->get_future(); + { + std::unique_lock lock(queue_mutex); + + if (stop) { + throw std::runtime_error( + "[ThreadPool::enqueue] Not allowed on stopped ThreadPool"); + } + + tasks.emplace([task]() { (*task)(); }); + } + condition.notify_one(); + return res; +} + +inline void ThreadPool::resize(size_t threads) { + if (workers.size() == threads) { + return; + } + + if (workers.size() > threads) { + stop_and_wait(); + } + start_threads(threads - workers.size()); +} + +inline ThreadPool::~ThreadPool() { + stop_and_wait(); +} + +inline void ThreadPool::stop_and_wait() { + // Stop the current threads and wait until they finish + { + std::unique_lock lock(queue_mutex); + stop = true; + } + condition.notify_all(); + for (std::thread& worker : workers) { + worker.join(); + } + + // Reset the member variables so that the threadpool is reusable + stop = false; + workers.clear(); +} + +inline void ThreadPool::start_threads(size_t threads) { + for (size_t i = 0; i < threads; ++i) { + workers.emplace_back([this] { + for (;;) { + std::function task; + + { + std::unique_lock lock(this->queue_mutex); + this->condition.wait( + lock, [this] { return this->stop || !this->tasks.empty(); }); + if (this->stop && this->tasks.empty()) + return; + task = std::move(this->tasks.front()); + this->tasks.pop(); + } + + task(); + } + }); + } +} +#endif diff --git a/Source/Cmlx/include-framework/mlx-transforms.h b/Source/Cmlx/include-framework/mlx-transforms.h new file mode 100644 index 00000000..f6e99fc3 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-transforms.h @@ -0,0 +1,231 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include + +#include + +namespace mlx::core { + +void async_eval(std::vector outputs); + +template > +void async_eval(Arrays&&... outputs) { + async_eval(std::vector{std::forward(outputs)...}); +} + +void eval(std::vector outputs); + +template > +void eval(Arrays&&... outputs) { + eval(std::vector{std::forward(outputs)...}); +} + +/** + * Computes the output and vector-Jacobian product (VJP) of a function. + * + * Computes the vector-Jacobian product of the vector of cotangents with the + * Jacobian of the function evaluated at the primals. Returns a pair of + * vectors of output arrays and VJP arrays. + **/ +std::pair, std::vector> vjp( + const std::function(const std::vector&)>& fun, + const std::vector& primals, + const std::vector& cotangents); + +/** + * Computes the output and vector-Jacobian product (VJP) of a unary function. + */ +std::pair vjp( + const std::function& fun, + const array& primal, + const array& cotangent); + +/** + * Computes the output and Jacobian-vector product (JVP) of a function. + * + * Computes the Jacobian-vector product of the Jacobian of the function + * evaluated at the primals with the vector of tangents. Returns a pair of + * vectors of output arrays and JVP arrays. + **/ +std::pair, std::vector> jvp( + const std::function(const std::vector&)>& fun, + const std::vector& primals, + const std::vector& tangents); + +/** + * Computes the output and Jacobian-vector product (JVP) of a unary function. + */ +std::pair jvp( + const std::function& fun, + const array& primal, + const array& tangent); + +// Return type of general value_and_grad: a function which takes an input +// vector of arrays and returns a pair of vectors of arrays one for the +// values and one for the gradients wrt the first value. +using ValueAndGradFn = + std::function, std::vector>( + const std::vector&)>; +using SimpleValueAndGradFn = std::function>( + const std::vector&)>; + +/** + * Returns a function which computes the value and gradient of the input + * function with respect to a vector of input arrays. + **/ +ValueAndGradFn value_and_grad( + const std::function(const std::vector&)>& fun, + const std::vector& argnums); + +/** + * Returns a function which computes the value and gradient of the input + * function with respect to a single input array. + **/ +ValueAndGradFn inline value_and_grad( + const std::function(const std::vector&)>& fun, + int argnum = 0) { + return value_and_grad(fun, std::vector{argnum}); +} + +/** + * Returns a function which computes the value and gradient of the unary + * input function. + **/ +std::function(const array&)> inline value_and_grad( + const std::function& fun) { + return [fun](auto inputs) { return vjp(fun, inputs, array(1.0f)); }; +} + +SimpleValueAndGradFn inline value_and_grad( + const std::function&)>& fun, + const std::vector& argnums) { + return [fun, argnums](auto inputs) { + auto result = value_and_grad( + [fun](auto inputs) { return std::vector{fun(inputs)}; }, + argnums)(inputs); + + return std::make_pair(result.first[0], result.second); + }; +} + +SimpleValueAndGradFn inline value_and_grad( + const std::function&)>& fun, + int argnum = 0) { + return value_and_grad(fun, std::vector{argnum}); +} + +/** + * Returns a function which computes the gradient of the input function with + * respect to a vector of input arrays. + * + * The function being differentiated takes a vector of arrays and returns an + * array. The vector of `argnums` specifies which the arguments to compute + * the gradient with respect to. At least one argument must be specified. + **/ +std::function(const std::vector&)> inline grad( + const std::function&)>& fun, + const std::vector& argnums) { + auto fn = value_and_grad(fun, argnums); + return [fn](const std::vector& inputs) { return fn(inputs).second; }; +} + +/** + * Returns a function which computes the gradient of the input function with + * respect to a single input array. + * + * The function being differentiated takes a vector of arrays and returns an + * array. The optional `argnum` index specifies which the argument to compute + * the gradient with respect to and defaults to 0. + **/ +std::function(const std::vector&)> inline grad( + const std::function&)>& fun, + int argnum = 0) { + return grad(fun, std::vector{argnum}); +} + +/** + * Returns a function which computes the gradient of the unary input function. + **/ +std::function inline grad( + const std::function& fun) { + auto fn = value_and_grad(fun); + return [fn](const array& input) { return fn(input).second; }; +} + +/** + * Automatically vectorize a unary function over the requested axes. + */ +std::function vmap( + const std::function& fun, + int in_axis = 0, + int out_axis = 0); + +/** + * Automatically vectorize a binary function over the requested axes. + */ +std::function vmap( + const std::function& fun, + int in_axis_a = 0, + int in_axis_b = 0, + int out_axis = 0); + +/** + * Automatically vectorize a function over the requested axes. + * + * The input function to `vmap` takes as an argument a vector of arrays and + * returns a vector of arrays. Optionally specify the axes to vectorize over + * with `in_axes` and `out_axes`, otherwise a default of 0 is used. + * Returns a vectorized function with the same signature as the input + * function. + */ +std::function(const std::vector&)> vmap( + const std::function(const std::vector&)>& fun, + const std::vector& in_axes = {}, + const std::vector& out_axes = {}); + +/** + * Redefine the transformations of `fun` according to the provided functions. + * + * Namely when calling the vjp of `fun` then `fun_vjp` will be called, + * `fun_jvp` for the jvp and `fun_vmap` for vmap. + * + * If any transformation is not provided, then a default one is created by + * calling `vjp`, `jvp` and `vmap` on the function directly. + */ +std::function(const std::vector&)> custom_function( + std::function(const std::vector&)> fun, + std::optional( + const std::vector&, + const std::vector&, + const std::vector&)>> fun_vjp = std::nullopt, + std::optional( + const std::vector&, + const std::vector&, + const std::vector&)>> fun_jvp = std::nullopt, + std::optional, std::vector>( + const std::vector&, + const std::vector&)>> fun_vmap = std::nullopt); + +/** + * Return a function that behaves exactly like `fun` but if the vjp of the + * results is computed `fun_vjp` will be used instead of `vjp(fun, ...)` . + */ +std::function(const std::vector&)> custom_vjp( + std::function(const std::vector&)> fun, + std::function( + const std::vector&, + const std::vector&, + const std::vector&)> fun_vjp); + +/** + * Checkpoint the gradient of a function. Namely, discard all intermediate + * state and recalculate it when we need to compute the gradient. + */ +std::function(const std::vector&)> checkpoint( + std::function(const std::vector&)> fun); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-types-bf16.h b/Source/Cmlx/include-framework/mlx-types-bf16.h new file mode 100644 index 00000000..ff670737 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-types-bf16.h @@ -0,0 +1,189 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include +#include +#include +#include + +#define __MLX_BFLOAT_NAN__ 0x7FC0 + +namespace mlx::core { + +namespace { +union float_bits_bf16 { + float f; + uint32_t u; +}; +} // namespace + +struct _MLX_BFloat16 { + uint16_t bits_; + + // Default constructor + _MLX_BFloat16() = default; + + // Default copy constructor + _MLX_BFloat16(_MLX_BFloat16 const&) = default; + + // Appease std::vector for being special + _MLX_BFloat16& operator=(std::vector::reference x) { + bits_ = x; + return *this; + } + + _MLX_BFloat16& operator=(const float& x) { + return (*this = _MLX_BFloat16(x)); + } + + // From float32 + _MLX_BFloat16(const float& x) { + if (std::isnan(x)) { + bits_ = __MLX_BFLOAT_NAN__; + } else { + // Union + float_bits_bf16 in; + + // Take bits + in.f = x; + + // Round to nearest even + in.u += (in.u >> 16 & 1) + uint32_t(0x7FFF); + + // Take upper 16 bits + bits_ = in.u >> 16; + } + } + + // To float32 + operator float() const { + // Union + float_bits_bf16 out; + + // Upper 16 bits are the data and lower 16 bits are 0s + out.u = ((uint32_t)bits_) << 16; + + return out.f; + } +}; + +#define bfloat_binop_base(__op__, __operator__, otype, atype, btype, ctype) \ + inline otype __operator__(atype lhs, btype rhs) { \ + return static_cast(lhs) __op__ static_cast(rhs); \ + } + +#define bfloat_binop_helper(__op__, __operator__, otype, itype, ctype) \ + inline otype __operator__(_MLX_BFloat16 lhs, itype rhs) { \ + return static_cast(lhs) __op__ static_cast(rhs); \ + } \ + inline otype __operator__(itype lhs, _MLX_BFloat16 rhs) { \ + return static_cast(lhs) __op__ static_cast(rhs); \ + } + +// Operators +#define bfloat_binop(_op_, _operator_) \ + bfloat_binop_base( \ + _op_, _operator_, _MLX_BFloat16, _MLX_BFloat16, _MLX_BFloat16, float); \ + bfloat_binop_helper(_op_, _operator_, float, float, float); \ + bfloat_binop_helper(_op_, _operator_, double, double, double); \ + bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, bool, float); \ + bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, int32_t, float); \ + bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, uint32_t, float); \ + bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, int64_t, float); \ + bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, uint64_t, float); + +bfloat_binop(+, operator+); +bfloat_binop(-, operator-); +bfloat_binop(*, operator*); +bfloat_binop(/, operator/); + +#undef bfloat_binop + +// Comparison ops +#define bfloat_compop(__op__, __operator__) \ + bfloat_binop_base( \ + __op__, __operator__, bool, _MLX_BFloat16, _MLX_BFloat16, float); \ + bfloat_binop_helper(__op__, __operator__, bool, float, float); \ + bfloat_binop_helper(__op__, __operator__, bool, double, double); \ + bfloat_binop_helper(__op__, __operator__, bool, int32_t, float); \ + bfloat_binop_helper(__op__, __operator__, bool, uint32_t, float); \ + bfloat_binop_helper(__op__, __operator__, bool, int64_t, float); \ + bfloat_binop_helper(__op__, __operator__, bool, uint64_t, float); + +bfloat_compop(>, operator>); +bfloat_compop(<, operator<); +bfloat_compop(>=, operator>=); +bfloat_compop(<=, operator<=); +bfloat_compop(==, operator==); +bfloat_compop(!=, operator!=); + +#undef bfloat_compop + +// Negative +inline _MLX_BFloat16 operator-(_MLX_BFloat16 lhs) { + return -static_cast(lhs); +} + +// Inplace ops +#define bfloat_inplace_op(__op__, __operator__) \ + inline _MLX_BFloat16& __operator__(_MLX_BFloat16& lhs, const float& rhs) { \ + lhs = lhs __op__ rhs; \ + return lhs; \ + } \ + inline float& __operator__(float& lhs, _MLX_BFloat16 rhs) { \ + lhs = lhs __op__ rhs; \ + return lhs; \ + } + +bfloat_inplace_op(+, operator+=); +bfloat_inplace_op(-, operator-=); +bfloat_inplace_op(*, operator*=); +bfloat_inplace_op(/, operator/=); + +#undef bfloat_inplace_op + +// Bitwise ops + +#define bfloat_bitop(__op__, __operator__) \ + inline _MLX_BFloat16 __operator__(_MLX_BFloat16 lhs, _MLX_BFloat16 rhs) { \ + _MLX_BFloat16 out; \ + out.bits_ = lhs.bits_ __op__ rhs.bits_; \ + return out; \ + } \ + inline _MLX_BFloat16 __operator__(_MLX_BFloat16 lhs, uint16_t rhs) { \ + _MLX_BFloat16 out; \ + out.bits_ = lhs.bits_ __op__ rhs; \ + return out; \ + } \ + inline _MLX_BFloat16 __operator__(uint16_t lhs, _MLX_BFloat16 rhs) { \ + _MLX_BFloat16 out; \ + out.bits_ = lhs __op__ rhs.bits_; \ + return out; \ + } + +bfloat_bitop(|, operator|); +bfloat_bitop(&, operator&); +bfloat_bitop(^, operator^); + +#undef bfloat_bitop + +#define bfloat_inplace_bitop(__op__, __operator__) \ + inline _MLX_BFloat16& __operator__(_MLX_BFloat16& lhs, _MLX_BFloat16 rhs) { \ + lhs.bits_ = lhs.bits_ __op__ rhs.bits_; \ + return lhs; \ + } \ + inline _MLX_BFloat16& __operator__(_MLX_BFloat16& lhs, uint16_t rhs) { \ + lhs.bits_ = lhs.bits_ __op__ rhs; \ + return lhs; \ + } + +bfloat_inplace_bitop(|, operator|=); +bfloat_inplace_bitop(&, operator&=); +bfloat_inplace_bitop(^, operator^=); + +#undef bfloat_inplace_bitop + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-types-complex.h b/Source/Cmlx/include-framework/mlx-types-complex.h new file mode 100644 index 00000000..c5c1f284 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-types-complex.h @@ -0,0 +1,115 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once +#include +#include + +namespace mlx::core { + +struct complex64_t; +struct complex128_t; + +template +inline constexpr bool can_convert_to_complex128 = + !std::is_same_v && std::is_convertible_v; + +struct complex128_t : public std::complex { + complex128_t() : std::complex() {}; + complex128_t(double v, double u) : std::complex(v, u) {}; + complex128_t(std::complex v) : std::complex(v) {}; + + template < + typename T, + typename = typename std::enable_if>::type> + complex128_t(T x) : std::complex(x){}; + + operator float() const { + return real(); + }; +}; + +template +inline constexpr bool can_convert_to_complex64 = + !std::is_same_v && std::is_convertible_v; + +struct complex64_t : public std::complex { + complex64_t() : std::complex() {}; + complex64_t(float v, float u) : std::complex(v, u) {}; + complex64_t(std::complex v) : std::complex(v) {}; + + template < + typename T, + typename = typename std::enable_if>::type> + complex64_t(T x) : std::complex(x){}; + + operator float() const { + return real(); + }; +}; + +inline bool operator>=(const complex64_t& a, const complex64_t& b) { + return (a.real() > b.real()) || + (a.real() == b.real() && a.imag() >= b.imag()); +} + +inline bool operator>(const complex64_t& a, const complex64_t& b) { + return (a.real() > b.real()) || (a.real() == b.real() && a.imag() > b.imag()); +} + +inline complex64_t operator%(complex64_t a, complex64_t b) { + auto real = a.real() - (b.real() * static_cast(a.real() / b.real())); + auto imag = a.imag() - (b.imag() * static_cast(a.imag() / b.imag())); + if (real != 0 && ((real < 0) != (b.real() < 0))) + real += b.real(); + if (imag != 0 && ((imag < 0) != (b.imag() < 0))) + imag += b.imag(); + return {real, imag}; +} + +inline bool operator<=(const complex64_t& a, const complex64_t& b) { + return operator>=(b, a); +} + +inline bool operator<(const complex64_t& a, const complex64_t& b) { + return operator>(b, a); +} + +inline complex64_t operator-(const complex64_t& v) { + return -static_cast>(v); +} + +// clang-format off +#define complex_binop_helper(_op_, _operator_, itype) \ + inline complex64_t _operator_(itype x, const complex64_t& y) { \ + return static_cast(x) _op_ y; \ + } \ + inline complex64_t _operator_(const complex64_t& x, itype y) { \ + return x _op_ static_cast(y); \ + } + +#define complex_binop(_op_, _operator_) \ + inline complex64_t _operator_(const std::complex& x, const complex64_t& y) { \ + return x _op_ static_cast>(y); \ + } \ + inline complex64_t _operator_(const complex64_t& x, const std::complex& y) { \ + return static_cast>(x) _op_ y; \ + } \ + inline complex64_t _operator_(const complex64_t& x, const complex64_t& y) { \ + return static_cast>(x) \ + _op_ static_cast>(y); \ + } \ + complex_binop_helper(_op_, _operator_, bool) \ + complex_binop_helper(_op_, _operator_, uint32_t) \ + complex_binop_helper(_op_, _operator_, uint64_t) \ + complex_binop_helper(_op_, _operator_, int32_t) \ + complex_binop_helper(_op_, _operator_, int64_t) \ + complex_binop_helper(_op_, _operator_, float16_t) \ + complex_binop_helper(_op_, _operator_, bfloat16_t) \ + complex_binop_helper(_op_, _operator_, float) +// clang-format on + +complex_binop(+, operator+) + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-types-half_types.h b/Source/Cmlx/include-framework/mlx-types-half_types.h new file mode 100644 index 00000000..f9a8622c --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-types-half_types.h @@ -0,0 +1,60 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#ifdef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC + +#include +namespace mlx::core { +using ::float16_t; +} // namespace mlx::core + +#else + +#define ADD_HALF_BINOPS +#include +namespace mlx::core { +typedef struct _MLX_Float16 float16_t; +} // namespace mlx::core + +#endif // __ARM_FEATURE_FP16_SCALAR_ARITHMETIC + +#ifdef __ARM_FEATURE_BF16 + +#include +namespace mlx::core { +using ::bfloat16_t; +} // namespace mlx::core + +#else + +#define ADD_HALF_BINOPS +#include +namespace mlx::core { +typedef struct _MLX_BFloat16 bfloat16_t; +} // namespace mlx::core + +#endif // __ARM_FEATURE_BF16 + +#ifdef ADD_HALF_BINOPS +namespace mlx::core { + +// clang-format off +#define fp16_bf16_binop_helper(__op__, __operator__) \ + inline float __operator__(float16_t lhs, bfloat16_t rhs) { \ + return static_cast(lhs) __op__ static_cast(rhs); \ + } \ + inline float __operator__(bfloat16_t lhs, float16_t rhs) { \ + return static_cast(lhs) __op__ static_cast(rhs); \ + } + +fp16_bf16_binop_helper(+, operator+) +fp16_bf16_binop_helper(-, operator-) +fp16_bf16_binop_helper(*, operator*) +fp16_bf16_binop_helper(/, operator/) +// clang-format on + +} // namespace mlx::core +#endif +#endif diff --git a/Source/Cmlx/include-framework/mlx-utils.h b/Source/Cmlx/include-framework/mlx-utils.h new file mode 100644 index 00000000..3d852228 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-utils.h @@ -0,0 +1,172 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include + +#include +#include +#include +#include + +namespace mlx::core { + +using StreamOrDevice = std::variant; +Stream to_stream(StreamOrDevice s); +Stream to_stream(StreamOrDevice s, Device default_); + +struct StreamContext { + public: + StreamContext(StreamOrDevice s) : _stream(default_stream(default_device())) { + if (std::holds_alternative(s)) { + throw std::runtime_error( + "[StreamContext] Invalid argument, please specify a stream or device."); + } + auto _s = to_stream(s); + set_default_device(_s.device); + set_default_stream(_s); + } + + ~StreamContext() { + set_default_device(_stream.device); + set_default_stream(_stream); + } + + private: + Stream _stream; +}; + +struct PrintFormatter { + inline void print(std::ostream& os, bool val); + inline void print(std::ostream& os, int16_t val); + inline void print(std::ostream& os, uint16_t val); + inline void print(std::ostream& os, int32_t val); + inline void print(std::ostream& os, uint32_t val); + inline void print(std::ostream& os, int64_t val); + inline void print(std::ostream& os, uint64_t val); + inline void print(std::ostream& os, float16_t val); + inline void print(std::ostream& os, bfloat16_t val); + inline void print(std::ostream& os, float val); + inline void print(std::ostream& os, double val); + inline void print(std::ostream& os, complex64_t val); + + bool capitalize_bool{false}; +}; + +PrintFormatter& get_global_formatter(); + +/** Print the exception and then abort. */ +void abort_with_exception(const std::exception& error); + +/** Holds information about floating-point types. */ +struct finfo { + explicit finfo(Dtype dtype); + Dtype dtype; + double min; + double max; + double eps; +}; + +/** Holds information about integral types. */ +struct iinfo { + explicit iinfo(Dtype dtype); + Dtype dtype; + int64_t min; + uint64_t max; +}; + +/** The type from promoting the arrays' types with one another. */ +inline Dtype result_type(const array& a, const array& b) { + return promote_types(a.dtype(), b.dtype()); +} +inline Dtype result_type(const array& a, const array& b, const array& c) { + return promote_types(result_type(a, b), c.dtype()); +} +Dtype result_type(const std::vector& arrays); + +Shape broadcast_shapes(const Shape& s1, const Shape& s2); + +/** + * Returns the axis normalized to be in the range [0, ndim). + */ +int normalize_axis_index( + int axis, + int ndim, + const std::string& msg_prefix = ""); + +std::ostream& operator<<(std::ostream& os, const Device& d); +std::ostream& operator<<(std::ostream& os, const Stream& s); +std::ostream& operator<<(std::ostream& os, const Dtype& d); +std::ostream& operator<<(std::ostream& os, const Dtype::Kind& k); +std::ostream& operator<<(std::ostream& os, array a); +inline std::ostream& operator<<(std::ostream& os, const complex64_t& v) { + return os << v.real() << (v.imag() >= 0 ? "+" : "") << v.imag() << "j"; +} +inline std::ostream& operator<<(std::ostream& os, const float16_t& v) { + return os << static_cast(v); +} +inline std::ostream& operator<<(std::ostream& os, const bfloat16_t& v) { + return os << static_cast(v); +} + +template >> +inline std::ostream& operator<<(std::ostream& os, const Vec& v) { + os << "("; + for (auto it = v.begin(); it != v.end(); ++it) { + os << *it; + if (it != std::prev(v.end())) { + os << ","; + } + } + os << ")"; + return os; +} + +inline bool is_power_of_2(int n) { + return ((n & (n - 1)) == 0) && n != 0; +} + +inline int next_power_of_2(int n) { + if (is_power_of_2(n)) { + return n; + } + return pow(2, std::ceil(std::log2(n))); +} + +namespace env { + +int get_var(const char* name, int default_value); + +inline int bfs_max_width() { + static int bfs_max_width_ = get_var("MLX_BFS_MAX_WIDTH", 20); + return bfs_max_width_; +} + +inline int max_ops_per_buffer(int default_value) { + static int max_ops_per_buffer_ = + get_var("MLX_MAX_OPS_PER_BUFFER", default_value); + return max_ops_per_buffer_; +} + +inline int max_mb_per_buffer(int default_value) { + static int max_mb_per_buffer_ = + get_var("MLX_MAX_MB_PER_BUFFER", default_value); + return max_mb_per_buffer_; +} + +inline bool metal_fast_synch() { + static bool metal_fast_synch = get_var("MLX_METAL_FAST_SYNCH", 0); + return metal_fast_synch; +} + +inline bool enable_tf32() { + static bool enable_tf32_ = get_var("MLX_ENABLE_TF32", 1); + return enable_tf32_; +} + +} // namespace env + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-version.h b/Source/Cmlx/include-framework/mlx-version.h new file mode 100644 index 00000000..80e1fc48 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-version.h @@ -0,0 +1,22 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. + +#pragma once + +#define MLX_VERSION_MAJOR 0 +#define MLX_VERSION_MINOR 29 +#define MLX_VERSION_PATCH 1 +#define MLX_VERSION_NUMERIC \ + (100000 * MLX_VERSION_MAJOR + 1000 * MLX_VERSION_MINOR + MLX_VERSION_PATCH) + +namespace mlx::core { + +/* A string representation of the MLX version in the format + * "major.minor.pat.h>. + * + * For dev builds, the version will include the suffix ".devYYYYMMDD+ha.h> + */ +const char* version(); + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/metal-cpp/Foundation/NSBundle.hpp b/Source/Cmlx/metal-cpp/Foundation/NSBundle.hpp index bc2de8bc..2f6e888c 100644 --- a/Source/Cmlx/metal-cpp/Foundation/NSBundle.hpp +++ b/Source/Cmlx/metal-cpp/Foundation/NSBundle.hpp @@ -53,7 +53,7 @@ class Bundle : public Referencing Bundle* init(const class URL* pURL); static Array* allBundles(); - class Array* allFrameworks() const; + static Array* allFrameworks(); bool load(); bool unload(); @@ -177,9 +177,9 @@ _NS_INLINE NS::Array* NS::Bundle::allBundles() //------------------------------------------------------------------------------------------------------------------------------------------------------------- -_NS_INLINE NS::Array* NS::Bundle::allFrameworks() const +_NS_INLINE NS::Array* NS::Bundle::allFrameworks() { - return Object::sendMessage(this, _NS_PRIVATE_SEL(allFrameworks)); + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(allFrameworks)); } //------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Source/MLX/MLXArray.swift b/Source/MLX/MLXArray.swift index 2fefccca..31bcbd75 100644 --- a/Source/MLX/MLXArray.swift +++ b/Source/MLX/MLXArray.swift @@ -8,7 +8,7 @@ import Numerics public final class MLXArray { /// Internal pointer to the mlx-c wrapper on `mlx::core::array`, used with `Cmlx` interop. - public package(set) var ctx: mlx_array + public internal(set) var ctx: mlx_array /// Initialize with the given +1 context (transfer ownership). /// diff --git a/tools/update-mlx.sh b/tools/update-mlx.sh index a52a191b..54fd3546 100755 --- a/tools/update-mlx.sh +++ b/tools/update-mlx.sh @@ -14,6 +14,75 @@ fi rm -f Source/Cmlx/include/mlx/c/* cp Source/Cmlx/mlx-c/mlx/c/*.h Source/Cmlx/include/mlx/c +# same for xcodeproj +rm -f Source/Cmlx/include-framework/*.h +cp Source/Cmlx/mlx-c/mlx/c/*.h Source/Cmlx/include-framework + +for x in Source/Cmlx/include-framework/*.h ; do \ + sed -i .tmp -e 's:"mlx/c/::g' $x +done; +rm Source/Cmlx/include-framework/*.tmp + +for x in Source/Cmlx/include-framework/*.h ; do \ + mv $x `echo $x | sed -e 's:/include-framework/:/include-framework/mlx-c-:g'` +done; + +cat > Source/Cmlx/include-framework/Cmlx.h < +#include +#include +#include + +EOF + +# c++ headers for xcodeproj -- these are transitively reachable +# from mlx/mlx/mlx.h + +for x in \ + array.h \ + backend/cuda/cuda.h \ + backend/gpu/available.h \ + backend/metal/metal.h \ + compile.h \ + device.h \ + distributed/distributed.h \ + distributed/ops.h \ + einsum.h \ + export.h \ + fast.h \ + fft.h \ + io.h \ + linalg.h \ + memory.h \ + ops.h \ + random.h \ + stream.h \ + transforms.h \ + utils.h \ + version.h \ + allocator.h \ + dtype.h \ + event.h \ + small_vector.h \ + types/complex.h \ + types/half_types.h \ + types/bf16.h \ + io/load.h \ + export_impl.h \ + threadpool.h +do + # guard the contents for non c++ callers + h=mlx-`echo $x | tr / -` + d=Source/Cmlx/include-framework/$h + echo "#ifdef __cplusplus" > $d + cat Source/Cmlx/mlx/mlx/$x | sed -e 's:backend/:backend-:g' -e 's:cuda/:cuda-:g' -e 's:gpu/:gpu-:g' -e 's:metal/:metal-:g' -e 's:distributed/:distributed-:g' -e 's:types/:types-:' -e 's:io/:io-:' -e 's:#include "mlx/:#include :g' >> $d + echo "#endif" >> $d + + # add to Cmlx + echo "#include " >> Source/Cmlx/include-framework/Cmlx.h +done + + # run the command to do the build-time code generation mkdir build diff --git a/xcode/MLX.xcodeproj/project.pbxproj b/xcode/MLX.xcodeproj/project.pbxproj new file mode 100644 index 00000000..a6d7fb72 --- /dev/null +++ b/xcode/MLX.xcodeproj/project.pbxproj @@ -0,0 +1,2038 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + C3434FA12EABEF350010D6B8 /* Cmlx.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AE8EE62EAAA3C5000BD280 /* Cmlx.framework */; }; + C3AE8ECE2EAAA15F000BD280 /* MLX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AE8EC42EAAA15F000BD280 /* MLX.framework */; }; + C3AEA0322EAAE79A000BD280 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AEA0312EAAE79A000BD280 /* Accelerate.framework */; }; + C3AEA0342EAAE7A0000BD280 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AEA0332EAAE7A0000BD280 /* Metal.framework */; }; + C3AEA0362EAAE7A9000BD280 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AEA0352EAAE7A9000BD280 /* Foundation.framework */; }; + C3CBE67C2EABFBA60029A645 /* Numerics in Frameworks */ = {isa = PBXBuildFile; productRef = C3CBE67B2EABFBA60029A645 /* Numerics */; }; + C3CBE7022EAC15780029A645 /* MLXNN.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3CBE6B52EAC14DE0029A645 /* MLXNN.framework */; }; + C3CBE7062EAC15780029A645 /* MLXOptimizers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3CBE6CF2EAC15310029A645 /* MLXOptimizers.framework */; }; + C3CBE70B2EAC15850029A645 /* MLX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AE8EC42EAAA15F000BD280 /* MLX.framework */; }; + C3CBE7102EAC15960029A645 /* MLX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3AE8EC42EAAA15F000BD280 /* MLX.framework */; }; + C3CBE7142EAC15960029A645 /* MLXNN.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3CBE6B52EAC14DE0029A645 /* MLXNN.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + C3AE8ECF2EAAA15F000BD280 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3AE8EC32EAAA15F000BD280; + remoteInfo = MLX; + }; + C3CBE7042EAC15780029A645 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3CBE6B42EAC14DE0029A645; + remoteInfo = MLXNN; + }; + C3CBE7082EAC15780029A645 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3CBE6CE2EAC15310029A645; + remoteInfo = MLXOptimizers; + }; + C3CBE70D2EAC15850029A645 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3AE8EC32EAAA15F000BD280; + remoteInfo = MLX; + }; + C3CBE7122EAC15960029A645 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3AE8EC32EAAA15F000BD280; + remoteInfo = MLX; + }; + C3CBE7162EAC15960029A645 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C3AE8EBB2EAAA15F000BD280 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C3CBE6B42EAC14DE0029A645; + remoteInfo = MLXNN; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + C3AE8EC42EAAA15F000BD280 /* MLX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MLX.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C3AE8ECD2EAAA15F000BD280 /* MLXTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MLXTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C3AE8EE62EAAA3C5000BD280 /* Cmlx.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cmlx.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C3AEA0312EAAE79A000BD280 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk/System/Library/Frameworks/Accelerate.framework; sourceTree = DEVELOPER_DIR; }; + C3AEA0332EAAE7A0000BD280 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; + C3AEA0352EAAE7A9000BD280 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + C3CBE6B52EAC14DE0029A645 /* MLXNN.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MLXNN.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C3CBE6CF2EAC15310029A645 /* MLXOptimizers.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MLXOptimizers.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C3CBF17F2EAC22110029A645 /* ACKNOWLEDGMENTS.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = ACKNOWLEDGMENTS.md; path = ../ACKNOWLEDGMENTS.md; sourceTree = SOURCE_ROOT; }; + C3CBF1802EAC22110029A645 /* CODE_OF_CONDUCT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CODE_OF_CONDUCT.md; path = ../CODE_OF_CONDUCT.md; sourceTree = SOURCE_ROOT; }; + C3CBF1812EAC22110029A645 /* CONTRIBUTING.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CONTRIBUTING.md; path = ../CONTRIBUTING.md; sourceTree = SOURCE_ROOT; }; + C3CBF1822EAC22110029A645 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = SOURCE_ROOT; }; + C3CBF1832EAC22110029A645 /* MAINTENANCE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = MAINTENANCE.md; path = ../MAINTENANCE.md; sourceTree = SOURCE_ROOT; }; + C3CBF1842EAC22110029A645 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = SOURCE_ROOT; }; + C3CBF1852EAC22110029A645 /* README.xcodeproj.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.xcodeproj.md; path = ../README.xcodeproj.md; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + C3AE939F2EAAAA5A000BD280 /* Exceptions for "metal-cpp" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Foundation/Foundation.hpp, + Foundation/NSArray.hpp, + Foundation/NSAutoreleasePool.hpp, + Foundation/NSBundle.hpp, + Foundation/NSData.hpp, + Foundation/NSDate.hpp, + Foundation/NSDefines.hpp, + Foundation/NSDictionary.hpp, + Foundation/NSEnumerator.hpp, + Foundation/NSError.hpp, + Foundation/NSLock.hpp, + Foundation/NSNotification.hpp, + Foundation/NSNumber.hpp, + Foundation/NSObjCRuntime.hpp, + Foundation/NSObject.hpp, + Foundation/NSPrivate.hpp, + Foundation/NSProcessInfo.hpp, + Foundation/NSRange.hpp, + Foundation/NSSet.hpp, + Foundation/NSSharedPtr.hpp, + Foundation/NSString.hpp, + Foundation/NSTypes.hpp, + Foundation/NSURL.hpp, + LICENSE.txt, + Metal/Metal.hpp, + Metal/MTLAccelerationStructure.hpp, + Metal/MTLAccelerationStructureCommandEncoder.hpp, + Metal/MTLAccelerationStructureTypes.hpp, + Metal/MTLAllocation.hpp, + Metal/MTLArgument.hpp, + Metal/MTLArgumentEncoder.hpp, + Metal/MTLBinaryArchive.hpp, + Metal/MTLBlitCommandEncoder.hpp, + Metal/MTLBlitPass.hpp, + Metal/MTLBuffer.hpp, + Metal/MTLCaptureManager.hpp, + Metal/MTLCaptureScope.hpp, + Metal/MTLCommandBuffer.hpp, + Metal/MTLCommandEncoder.hpp, + Metal/MTLCommandQueue.hpp, + Metal/MTLComputeCommandEncoder.hpp, + Metal/MTLComputePass.hpp, + Metal/MTLComputePipeline.hpp, + Metal/MTLCounters.hpp, + Metal/MTLDefines.hpp, + Metal/MTLDepthStencil.hpp, + Metal/MTLDevice.hpp, + Metal/MTLDrawable.hpp, + Metal/MTLDynamicLibrary.hpp, + Metal/MTLEvent.hpp, + Metal/MTLFence.hpp, + Metal/MTLFunctionConstantValues.hpp, + Metal/MTLFunctionDescriptor.hpp, + Metal/MTLFunctionHandle.hpp, + Metal/MTLFunctionLog.hpp, + Metal/MTLFunctionStitching.hpp, + Metal/MTLHeaderBridge.hpp, + Metal/MTLHeap.hpp, + Metal/MTLIndirectCommandBuffer.hpp, + Metal/MTLIndirectCommandEncoder.hpp, + Metal/MTLIntersectionFunctionTable.hpp, + Metal/MTLIOCommandBuffer.hpp, + Metal/MTLIOCommandQueue.hpp, + Metal/MTLIOCompressor.hpp, + Metal/MTLLibrary.hpp, + Metal/MTLLinkedFunctions.hpp, + Metal/MTLLogState.hpp, + Metal/MTLParallelRenderCommandEncoder.hpp, + Metal/MTLPipeline.hpp, + Metal/MTLPixelFormat.hpp, + Metal/MTLPrivate.hpp, + Metal/MTLRasterizationRate.hpp, + Metal/MTLRenderCommandEncoder.hpp, + Metal/MTLRenderPass.hpp, + Metal/MTLRenderPipeline.hpp, + Metal/MTLResidencySet.hpp, + Metal/MTLResource.hpp, + Metal/MTLResourceStateCommandEncoder.hpp, + Metal/MTLResourceStatePass.hpp, + Metal/MTLSampler.hpp, + Metal/MTLStageInputOutputDescriptor.hpp, + Metal/MTLTexture.hpp, + Metal/MTLTypes.hpp, + Metal/MTLVersion.hpp, + Metal/MTLVertexDescriptor.hpp, + Metal/MTLVisibleFunctionTable.hpp, + MetalFX/MetalFX.hpp, + MetalFX/MTLFXDefines.hpp, + MetalFX/MTLFXPrivate.hpp, + MetalFX/MTLFXSpatialScaler.hpp, + MetalFX/MTLFXTemporalScaler.hpp, + QuartzCore/CADefines.hpp, + QuartzCore/CAMetalDrawable.hpp, + QuartzCore/CAMetalLayer.hpp, + QuartzCore/CAPrivate.hpp, + QuartzCore/QuartzCore.hpp, + README.md, + SingleHeader/MakeSingleHeader.py, + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; + C3AE9E162EAAAB37000BD280 /* Exceptions for "mlx-c" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + ".clang-format", + .gitignore, + ACKNOWLEDGMENTS.md, + CMakeLists.txt, + CODE_OF_CONDUCT.md, + CONTRIBUTING.md, + docs/.gitignore, + docs/.nojekyll, + docs/Doxyfile, + docs/index.html, + docs/Makefile, + docs/README.md, + docs/requirements.txt, + docs/src/_static/mlx_logo_dark.png, + docs/src/_static/mlx_logo.png, + docs/src/array.rst, + docs/src/closure.rst, + docs/src/compile.rst, + docs/src/conf.py, + docs/src/device.rst, + docs/src/distributed_group.rst, + docs/src/distributed_ops.rst, + docs/src/error.rst, + docs/src/export.rst, + docs/src/fast.rst, + docs/src/fft.rst, + docs/src/index.rst, + docs/src/install.rst, + docs/src/io.rst, + docs/src/linalg.rst, + docs/src/map.rst, + docs/src/metal.rst, + docs/src/ops.rst, + docs/src/optional.rst, + docs/src/overview.rst, + docs/src/random.rst, + docs/src/stream.rst, + docs/src/string.rst, + docs/src/transforms.rst, + docs/src/vector.rst, + examples/arrays.safetensors, + examples/CMakeLists.txt, + "examples/example-closure.c", + "examples/example-export.c", + "examples/example-float64.c", + "examples/example-grad.c", + "examples/example-metal-kernel.c", + "examples/example-safe-tensors.c", + examples/example.c, + LICENSE, + "mlx-c.pc.in", + mlx/c/array.h, + mlx/c/closure.h, + mlx/c/compile.h, + mlx/c/device.h, + mlx/c/distributed_group.h, + mlx/c/distributed.h, + mlx/c/error.h, + mlx/c/export.h, + mlx/c/fast.h, + mlx/c/fft.h, + mlx/c/half.h, + mlx/c/io_types.h, + mlx/c/io.h, + mlx/c/linalg.h, + mlx/c/map.h, + mlx/c/memory.h, + mlx/c/metal.h, + mlx/c/mlx.h, + mlx/c/ops.h, + mlx/c/optional.h, + mlx/c/private/array.h, + mlx/c/private/closure.h, + mlx/c/private/device.h, + mlx/c/private/distributed_group.h, + mlx/c/private/enums.h, + mlx/c/private/export.h, + mlx/c/private/io.h, + mlx/c/private/map.h, + mlx/c/private/mlx.h, + mlx/c/private/stream.h, + mlx/c/private/string.h, + mlx/c/private/vector.h, + mlx/c/random.h, + mlx/c/stream.h, + mlx/c/string.h, + mlx/c/transforms_impl.h, + mlx/c/transforms.h, + mlx/c/vector.h, + mlx/c/version.h, + python/c.py, + python/closure_generator.py, + python/generator.py, + python/map_generator.py, + python/mlxhooks.py, + python/mlxtypes.py, + python/mlxvariants.py, + python/type_private_generator.py, + python/vector_generator.py, + README.md, + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; + C3AE9EA62EAAABFC000BD280 /* Exceptions for "mlx" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + .circleci/config.yml, + ".clang-format", + .github/ISSUE_TEMPLATE/bug_report.md, + .github/pull_request_template.md, + .github/workflows/pull_request.yml, + .gitignore, + ".pre-commit-config.yaml", + ACKNOWLEDGMENTS.md, + benchmarks/cpp/autograd.cpp, + benchmarks/cpp/CMakeLists.txt, + benchmarks/cpp/compare_devices.cpp, + benchmarks/cpp/irregular_strides.cpp, + benchmarks/cpp/single_ops.cpp, + benchmarks/cpp/time_utils.h, + benchmarks/numpy/single_ops.py, + benchmarks/numpy/time_utils.py, + benchmarks/python/batch_matmul_bench.py, + benchmarks/python/blas/bench_gemm.py, + benchmarks/python/blas/bench_gemv.py, + benchmarks/python/comparative/bench_mlx.py, + benchmarks/python/comparative/bench_torch.py, + benchmarks/python/comparative/compare.py, + benchmarks/python/comparative/README.md, + benchmarks/python/compile_bench.py, + benchmarks/python/conv_bench.py, + benchmarks/python/conv_transpose_bench.py, + benchmarks/python/conv_unaligned_bench.py, + benchmarks/python/conv1d_bench.py, + benchmarks/python/conv2d_bench_cpu.py, + benchmarks/python/conv2d_train_bench_cpu.py, + benchmarks/python/conv2d_transpose_bench_cpu.py, + benchmarks/python/conv3d_bench_cpu.py, + benchmarks/python/conv3d_train_bench_cpu.py, + benchmarks/python/conv3d_transpose_bench_cpu.py, + benchmarks/python/distributed_bench.py, + benchmarks/python/einsum_bench.py, + benchmarks/python/fft_bench.py, + benchmarks/python/gather_bench.py, + benchmarks/python/gather_mm_bench.py, + benchmarks/python/gather_qmm_bench.py, + benchmarks/python/hadamard_bench.py, + benchmarks/python/layer_norm_bench.py, + benchmarks/python/rms_norm_bench.py, + benchmarks/python/rope_bench.py, + benchmarks/python/scatter_bench.py, + benchmarks/python/sdpa_bench.py, + benchmarks/python/sdpa_vector_bench.py, + benchmarks/python/single_ops.py, + benchmarks/python/synchronize_bench.py, + benchmarks/python/time_utils.py, + CITATION.cff, + cmake/extension.cmake, + cmake/FindNCCL.cmake, + CMakeLists.txt, + CODE_OF_CONDUCT.md, + CONTRIBUTING.md, + "docs/.clang-format", + docs/.gitignore, + docs/.nojekyll, + docs/Doxyfile, + docs/index.html, + docs/Makefile, + docs/README.md, + docs/requirements.txt, + docs/src/_static/metal_debugger/capture.png, + docs/src/_static/metal_debugger/schema.png, + docs/src/_static/mlx_logo_dark.png, + docs/src/_static/mlx_logo.png, + "docs/src/_templates/module-base-class.rst", + "docs/src/_templates/nn-module-template.rst", + "docs/src/_templates/optimizers-template.rst", + docs/src/conf.py, + docs/src/cpp/ops.rst, + docs/src/dev/custom_metal_kernels.rst, + docs/src/dev/extensions.rst, + docs/src/dev/metal_debugger.rst, + docs/src/dev/mlx_in_cpp.rst, + docs/src/examples/linear_regression.rst, + "docs/src/examples/llama-inference.rst", + docs/src/examples/mlp.rst, + docs/src/index.rst, + docs/src/install.rst, + docs/src/python/array.rst, + docs/src/python/cuda.rst, + docs/src/python/data_types.rst, + docs/src/python/devices_and_streams.rst, + docs/src/python/distributed.rst, + docs/src/python/export.rst, + docs/src/python/fast.rst, + docs/src/python/fft.rst, + docs/src/python/linalg.rst, + docs/src/python/memory_management.rst, + docs/src/python/metal.rst, + docs/src/python/nn.rst, + docs/src/python/nn/functions.rst, + docs/src/python/nn/init.rst, + docs/src/python/nn/layers.rst, + docs/src/python/nn/losses.rst, + docs/src/python/nn/module.rst, + docs/src/python/ops.rst, + docs/src/python/optimizers.rst, + docs/src/python/optimizers/common_optimizers.rst, + docs/src/python/optimizers/optimizer.rst, + docs/src/python/optimizers/schedulers.rst, + docs/src/python/random.rst, + docs/src/python/transforms.rst, + docs/src/python/tree_utils.rst, + docs/src/usage/compile.rst, + docs/src/usage/distributed.rst, + docs/src/usage/export.rst, + docs/src/usage/function_transforms.rst, + docs/src/usage/indexing.rst, + docs/src/usage/launching_distributed.rst, + docs/src/usage/lazy_evaluation.rst, + docs/src/usage/numpy.rst, + docs/src/usage/quick_start.rst, + docs/src/usage/saving_and_loading.rst, + docs/src/usage/unified_memory.rst, + docs/src/usage/using_streams.rst, + examples/cmake_project/CMakeLists.txt, + examples/cmake_project/example.cpp, + examples/cmake_project/README.md, + examples/cpp/CMakeLists.txt, + examples/cpp/distributed.cpp, + examples/cpp/linear_regression.cpp, + examples/cpp/logistic_regression.cpp, + examples/cpp/metal_capture.cpp, + examples/cpp/timer.h, + examples/cpp/tutorial.cpp, + examples/export/CMakeLists.txt, + examples/export/eval_mlp.cpp, + examples/export/eval_mlp.py, + examples/export/README.md, + examples/export/train_mlp.cpp, + examples/export/train_mlp.py, + examples/extensions/axpby/axpby.cpp, + examples/extensions/axpby/axpby.h, + examples/extensions/axpby/axpby.metal, + examples/extensions/bindings.cpp, + examples/extensions/CMakeLists.txt, + examples/extensions/mlx_sample_extensions/__init__.py, + examples/extensions/pyproject.toml, + examples/extensions/README.md, + examples/extensions/requirements.txt, + examples/extensions/setup.py, + examples/extensions/test.py, + examples/python/linear_regression.py, + examples/python/logistic_regression.py, + LICENSE, + MANIFEST.in, + mlx.pc.in, + "mlx/3rdparty/.clang-format", + mlx/3rdparty/pocketfft.h, + mlx/allocator.h, + mlx/array.h, + mlx/backend/common/binary.h, + mlx/backend/common/broadcasting.h, + mlx/backend/common/buffer_cache.h, + mlx/backend/common/CMakeLists.txt, + mlx/backend/common/compiled.h, + mlx/backend/common/copy.h, + mlx/backend/common/hadamard.h, + mlx/backend/common/matmul.h, + mlx/backend/common/reduce.h, + mlx/backend/common/slicing.h, + mlx/backend/common/ternary.h, + mlx/backend/common/unary.h, + mlx/backend/common/utils.h, + mlx/backend/cpu/arange.h, + mlx/backend/cpu/available.h, + mlx/backend/cpu/binary_ops.h, + mlx/backend/cpu/binary_two.h, + mlx/backend/cpu/binary.h, + mlx/backend/cpu/CMakeLists.txt, + mlx/backend/cpu/compiled_preamble.h, + mlx/backend/cpu/compiled.cpp, + mlx/backend/cpu/copy.h, + mlx/backend/cpu/encoder.h, + mlx/backend/cpu/eval.h, + mlx/backend/cpu/gemm.h, + mlx/backend/cpu/gemms/simd_bf16.cpp, + mlx/backend/cpu/gemms/simd_fp16.cpp, + mlx/backend/cpu/gemms/simd_gemm.h, + mlx/backend/cpu/jit_compiler.h, + mlx/backend/cpu/lapack.h, + mlx/backend/cpu/make_compiled_preamble.ps1, + mlx/backend/cpu/make_compiled_preamble.sh, + mlx/backend/cpu/simd/accelerate_fp16_simd.h, + mlx/backend/cpu/simd/accelerate_simd.h, + mlx/backend/cpu/simd/base_simd.h, + mlx/backend/cpu/simd/math.h, + mlx/backend/cpu/simd/neon_fp16_simd.h, + mlx/backend/cpu/simd/simd.h, + mlx/backend/cpu/simd/type.h, + mlx/backend/cpu/slicing.h, + mlx/backend/cpu/ternary.h, + mlx/backend/cpu/threefry.h, + mlx/backend/cpu/unary_ops.h, + mlx/backend/cpu/unary.h, + mlx/backend/cuda/allocator.cpp, + mlx/backend/cuda/allocator.h, + mlx/backend/cuda/arange.cu, + mlx/backend/cuda/arg_reduce.cu, + mlx/backend/cuda/bin2h.cmake, + mlx/backend/cuda/binary_two.cu, + mlx/backend/cuda/binary/add.cu, + mlx/backend/cuda/binary/arctan2.cu, + mlx/backend/cuda/binary/binary.cuh, + mlx/backend/cuda/binary/bitwise_binary.cu, + mlx/backend/cuda/binary/CMakeLists.txt, + mlx/backend/cuda/binary/divide.cu, + mlx/backend/cuda/binary/equal.cu, + mlx/backend/cuda/binary/greater_equal.cu, + mlx/backend/cuda/binary/greater.cu, + mlx/backend/cuda/binary/less_equal.cu, + mlx/backend/cuda/binary/less.cu, + mlx/backend/cuda/binary/log_add_exp.cu, + mlx/backend/cuda/binary/logical_and.cu, + mlx/backend/cuda/binary/logical_or.cu, + mlx/backend/cuda/binary/maximum.cu, + mlx/backend/cuda/binary/minimum.cu, + mlx/backend/cuda/binary/multiply.cu, + mlx/backend/cuda/binary/not_equal.cu, + mlx/backend/cuda/binary/power.cu, + mlx/backend/cuda/binary/remainder.cu, + mlx/backend/cuda/binary/subtract.cu, + mlx/backend/cuda/CMakeLists.txt, + mlx/backend/cuda/compiled.cpp, + mlx/backend/cuda/conv.cpp, + mlx/backend/cuda/conv/conv.h, + mlx/backend/cuda/conv/gemm_conv.cu, + mlx/backend/cuda/conv/gemm_grouped_conv.cu, + mlx/backend/cuda/copy.cu, + mlx/backend/cuda/copy/copy_contiguous.cu, + mlx/backend/cuda/copy/copy_general_dynamic.cu, + mlx/backend/cuda/copy/copy_general_input.cu, + mlx/backend/cuda/copy/copy_general.cu, + mlx/backend/cuda/copy/copy.cuh, + mlx/backend/cuda/cuda.cpp, + mlx/backend/cuda/cuda.h, + mlx/backend/cuda/cudnn_utils.cpp, + mlx/backend/cuda/cudnn_utils.h, + mlx/backend/cuda/custom_kernel.cpp, + mlx/backend/cuda/device.cpp, + mlx/backend/cuda/device.h, + mlx/backend/cuda/device/atomic_ops.cuh, + mlx/backend/cuda/device/binary_ops.cuh, + mlx/backend/cuda/device/cast_op.cuh, + mlx/backend/cuda/device/complex.cuh, + mlx/backend/cuda/device/config.h, + mlx/backend/cuda/device/fp16_math.cuh, + mlx/backend/cuda/device/gather_axis.cuh, + mlx/backend/cuda/device/gather.cuh, + mlx/backend/cuda/device/indexing.cuh, + mlx/backend/cuda/device/scatter_axis.cuh, + mlx/backend/cuda/device/scatter_ops.cuh, + mlx/backend/cuda/device/scatter.cuh, + mlx/backend/cuda/device/ternary_ops.cuh, + mlx/backend/cuda/device/unary_ops.cuh, + mlx/backend/cuda/device/utils.cuh, + mlx/backend/cuda/distributed.cu, + mlx/backend/cuda/eval.cpp, + mlx/backend/cuda/event.cu, + mlx/backend/cuda/event.h, + mlx/backend/cuda/fence.cpp, + mlx/backend/cuda/gemms/cublas_gemm_batched_12_0.cpp, + mlx/backend/cuda/gemms/cublas_gemm_batched_12_9.cu, + mlx/backend/cuda/gemms/cublas_gemm.cpp, + mlx/backend/cuda/gemms/cublas_gemm.h, + mlx/backend/cuda/gemms/gemv.cu, + mlx/backend/cuda/gemms/gemv.h, + mlx/backend/cuda/indexing.cpp, + mlx/backend/cuda/jit_module.cpp, + mlx/backend/cuda/jit_module.h, + mlx/backend/cuda/kernel_utils.cu, + mlx/backend/cuda/kernel_utils.cuh, + mlx/backend/cuda/layer_norm.cu, + mlx/backend/cuda/logsumexp.cu, + mlx/backend/cuda/lru_cache.h, + mlx/backend/cuda/matmul.cpp, + mlx/backend/cuda/primitives.cpp, + mlx/backend/cuda/quantized/affine_quantize.cu, + mlx/backend/cuda/quantized/quantized_utils.cuh, + mlx/backend/cuda/quantized/quantized.cpp, + mlx/backend/cuda/quantized/quantized.h, + mlx/backend/cuda/random.cu, + mlx/backend/cuda/reduce.cu, + mlx/backend/cuda/reduce/all_reduce.cu, + mlx/backend/cuda/reduce/col_reduce.cu, + mlx/backend/cuda/reduce/init_reduce.cu, + mlx/backend/cuda/reduce/reduce_ops.cuh, + mlx/backend/cuda/reduce/reduce_utils.cuh, + mlx/backend/cuda/reduce/reduce.cuh, + mlx/backend/cuda/reduce/row_reduce.cu, + mlx/backend/cuda/rms_norm.cu, + mlx/backend/cuda/rope.cu, + mlx/backend/cuda/scaled_dot_product_attention.cu, + mlx/backend/cuda/scan.cu, + mlx/backend/cuda/slicing.cpp, + mlx/backend/cuda/softmax.cu, + mlx/backend/cuda/sort.cu, + mlx/backend/cuda/steel/defines.cuh, + mlx/backend/cuda/steel/gemm.cuh, + mlx/backend/cuda/steel/mma.cuh, + mlx/backend/cuda/steel/tiles.cuh, + mlx/backend/cuda/steel/utils.cuh, + mlx/backend/cuda/ternary.cu, + mlx/backend/cuda/unary.cu, + mlx/backend/cuda/unary/abs.cu, + mlx/backend/cuda/unary/arccos.cu, + mlx/backend/cuda/unary/arccosh.cu, + mlx/backend/cuda/unary/arcsin.cu, + mlx/backend/cuda/unary/arcsinh.cu, + mlx/backend/cuda/unary/arctan.cu, + mlx/backend/cuda/unary/arctanh.cu, + mlx/backend/cuda/unary/bitwise_invert.cu, + mlx/backend/cuda/unary/ceil.cu, + mlx/backend/cuda/unary/CMakeLists.txt, + mlx/backend/cuda/unary/conjugate.cu, + mlx/backend/cuda/unary/cos.cu, + mlx/backend/cuda/unary/cosh.cu, + mlx/backend/cuda/unary/erf_inv.cu, + mlx/backend/cuda/unary/erf.cu, + mlx/backend/cuda/unary/exp.cu, + mlx/backend/cuda/unary/expm1.cu, + mlx/backend/cuda/unary/floor.cu, + mlx/backend/cuda/unary/imag.cu, + mlx/backend/cuda/unary/log.cu, + mlx/backend/cuda/unary/log1p.cu, + mlx/backend/cuda/unary/logical_not.cu, + mlx/backend/cuda/unary/negative.cu, + mlx/backend/cuda/unary/real.cu, + mlx/backend/cuda/unary/round.cu, + mlx/backend/cuda/unary/sigmoid.cu, + mlx/backend/cuda/unary/sign.cu, + mlx/backend/cuda/unary/sin.cu, + mlx/backend/cuda/unary/sinh.cu, + mlx/backend/cuda/unary/sqrt.cu, + mlx/backend/cuda/unary/square.cu, + mlx/backend/cuda/unary/tan.cu, + mlx/backend/cuda/unary/tanh.cu, + mlx/backend/cuda/unary/unary.cuh, + mlx/backend/cuda/utils.cpp, + mlx/backend/cuda/utils.h, + mlx/backend/cuda/worker.cpp, + mlx/backend/cuda/worker.h, + mlx/backend/gpu/available.h, + mlx/backend/gpu/CMakeLists.txt, + mlx/backend/gpu/copy.h, + mlx/backend/gpu/eval.h, + mlx/backend/gpu/slicing.h, + mlx/backend/metal/allocator.h, + mlx/backend/metal/binary.h, + mlx/backend/metal/CMakeLists.txt, + mlx/backend/metal/device.h, + mlx/backend/metal/jit/includes.h, + mlx/backend/metal/jit/indexing.h, + mlx/backend/metal/kernels.h, + mlx/backend/metal/kernels/arange.h, + mlx/backend/metal/kernels/arange.metal, + mlx/backend/metal/kernels/arg_reduce.metal, + mlx/backend/metal/kernels/atomic.h, + mlx/backend/metal/kernels/bf16_math.h, + mlx/backend/metal/kernels/binary_ops.h, + mlx/backend/metal/kernels/binary_two.h, + mlx/backend/metal/kernels/binary_two.metal, + mlx/backend/metal/kernels/binary.h, + mlx/backend/metal/kernels/binary.metal, + mlx/backend/metal/kernels/cexpf.h, + mlx/backend/metal/kernels/CMakeLists.txt, + mlx/backend/metal/kernels/complex.h, + mlx/backend/metal/kernels/conv.metal, + mlx/backend/metal/kernels/copy.h, + mlx/backend/metal/kernels/copy.metal, + mlx/backend/metal/kernels/defines.h, + mlx/backend/metal/kernels/erf.h, + mlx/backend/metal/kernels/expm1f.h, + mlx/backend/metal/kernels/fence.metal, + mlx/backend/metal/kernels/fft.h, + mlx/backend/metal/kernels/fft.metal, + mlx/backend/metal/kernels/fft/radix.h, + mlx/backend/metal/kernels/fft/readwrite.h, + mlx/backend/metal/kernels/fp4_quantized.h, + mlx/backend/metal/kernels/fp4_quantized.metal, + mlx/backend/metal/kernels/gemv_masked.h, + mlx/backend/metal/kernels/gemv_masked.metal, + mlx/backend/metal/kernels/gemv.metal, + mlx/backend/metal/kernels/hadamard.h, + mlx/backend/metal/kernels/indexing/gather_axis.h, + mlx/backend/metal/kernels/indexing/gather_front.h, + mlx/backend/metal/kernels/indexing/gather.h, + mlx/backend/metal/kernels/indexing/indexing.h, + mlx/backend/metal/kernels/indexing/scatter_axis.h, + mlx/backend/metal/kernels/indexing/scatter.h, + mlx/backend/metal/kernels/jit/bf16.h, + mlx/backend/metal/kernels/layer_norm.metal, + mlx/backend/metal/kernels/logsumexp.h, + mlx/backend/metal/kernels/logsumexp.metal, + mlx/backend/metal/kernels/metal_3_0/bf16.h, + mlx/backend/metal/kernels/metal_3_1/bf16.h, + mlx/backend/metal/kernels/quantized_utils.h, + mlx/backend/metal/kernels/quantized.h, + mlx/backend/metal/kernels/quantized.metal, + mlx/backend/metal/kernels/random.metal, + mlx/backend/metal/kernels/reduce_utils.h, + mlx/backend/metal/kernels/reduce.h, + mlx/backend/metal/kernels/reduce.metal, + mlx/backend/metal/kernels/reduction/ops.h, + mlx/backend/metal/kernels/reduction/reduce_all.h, + mlx/backend/metal/kernels/reduction/reduce_col.h, + mlx/backend/metal/kernels/reduction/reduce_init.h, + mlx/backend/metal/kernels/reduction/reduce_row.h, + mlx/backend/metal/kernels/rms_norm.metal, + mlx/backend/metal/kernels/rope.metal, + mlx/backend/metal/kernels/scaled_dot_product_attention.metal, + mlx/backend/metal/kernels/scan.h, + mlx/backend/metal/kernels/scan.metal, + mlx/backend/metal/kernels/sdpa_vector.h, + mlx/backend/metal/kernels/softmax.h, + mlx/backend/metal/kernels/softmax.metal, + mlx/backend/metal/kernels/sort.h, + mlx/backend/metal/kernels/sort.metal, + mlx/backend/metal/kernels/steel/attn/attn.h, + mlx/backend/metal/kernels/steel/attn/kernels/steel_attention.h, + mlx/backend/metal/kernels/steel/attn/kernels/steel_attention.metal, + mlx/backend/metal/kernels/steel/attn/loader.h, + mlx/backend/metal/kernels/steel/attn/mma.h, + mlx/backend/metal/kernels/steel/attn/params.h, + mlx/backend/metal/kernels/steel/attn/transforms.h, + mlx/backend/metal/kernels/steel/conv/conv.h, + mlx/backend/metal/kernels/steel/conv/kernels/steel_conv_general.h, + mlx/backend/metal/kernels/steel/conv/kernels/steel_conv_general.metal, + mlx/backend/metal/kernels/steel/conv/kernels/steel_conv.h, + mlx/backend/metal/kernels/steel/conv/kernels/steel_conv.metal, + mlx/backend/metal/kernels/steel/conv/loader.h, + mlx/backend/metal/kernels/steel/conv/loaders/loader_channel_l.h, + mlx/backend/metal/kernels/steel/conv/loaders/loader_channel_n.h, + mlx/backend/metal/kernels/steel/conv/loaders/loader_general.h, + mlx/backend/metal/kernels/steel/conv/params.h, + mlx/backend/metal/kernels/steel/defines.h, + mlx/backend/metal/kernels/steel/gemm/gemm.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_fused.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_fused.metal, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_gather.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_gather.metal, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_masked.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_masked.metal, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_segmented.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_segmented.metal, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_splitk.h, + mlx/backend/metal/kernels/steel/gemm/kernels/steel_gemm_splitk.metal, + mlx/backend/metal/kernels/steel/gemm/loader.h, + mlx/backend/metal/kernels/steel/gemm/mma.h, + mlx/backend/metal/kernels/steel/gemm/params.h, + mlx/backend/metal/kernels/steel/gemm/transforms.h, + mlx/backend/metal/kernels/steel/utils.h, + mlx/backend/metal/kernels/steel/utils/integral_constant.h, + mlx/backend/metal/kernels/steel/utils/type_traits.h, + mlx/backend/metal/kernels/ternary_ops.h, + mlx/backend/metal/kernels/ternary.h, + mlx/backend/metal/kernels/ternary.metal, + mlx/backend/metal/kernels/unary_ops.h, + mlx/backend/metal/kernels/unary.h, + mlx/backend/metal/kernels/unary.metal, + mlx/backend/metal/kernels/utils.h, + mlx/backend/metal/make_compiled_preamble.sh, + mlx/backend/metal/matmul.h, + mlx/backend/metal/metal.h, + mlx/backend/metal/no_metal.cpp, + mlx/backend/metal/nojit_kernels.cpp, + mlx/backend/metal/reduce.h, + mlx/backend/metal/resident.h, + mlx/backend/metal/ternary.h, + mlx/backend/metal/unary.h, + mlx/backend/metal/utils.h, + mlx/backend/no_cpu/available.cpp, + mlx/backend/no_cpu/CMakeLists.txt, + mlx/backend/no_cpu/compiled.cpp, + mlx/backend/no_cpu/primitives.cpp, + mlx/backend/no_gpu/allocator.cpp, + mlx/backend/no_gpu/apple_memory.h, + mlx/backend/no_gpu/CMakeLists.txt, + mlx/backend/no_gpu/eval.cpp, + mlx/backend/no_gpu/event.cpp, + mlx/backend/no_gpu/fence.cpp, + mlx/backend/no_gpu/linux_memory.h, + mlx/backend/no_gpu/primitives.cpp, + mlx/CMakeLists.txt, + mlx/compile_impl.h, + mlx/compile.h, + mlx/device.h, + mlx/distributed/CMakeLists.txt, + mlx/distributed/distributed_impl.h, + mlx/distributed/distributed.h, + mlx/distributed/mpi/CMakeLists.txt, + mlx/distributed/mpi/mpi_declarations.h, + mlx/distributed/mpi/mpi.cpp, + mlx/distributed/mpi/mpi.h, + mlx/distributed/nccl/CMakeLists.txt, + mlx/distributed/nccl/nccl_stub/CMakeLists.txt, + mlx/distributed/nccl/nccl_stub/nccl_stubs.cpp, + mlx/distributed/nccl/nccl.cpp, + mlx/distributed/nccl/nccl.h, + mlx/distributed/ops.h, + mlx/distributed/primitives.h, + mlx/distributed/ring/CMakeLists.txt, + mlx/distributed/ring/ring.cpp, + mlx/distributed/ring/ring.h, + mlx/dtype_utils.h, + mlx/dtype.h, + mlx/einsum.h, + mlx/event.h, + mlx/export_impl.h, + mlx/export.h, + mlx/fast_primitives.h, + mlx/fast.h, + mlx/fence.h, + mlx/fft.h, + mlx/graph_utils.h, + mlx/io.h, + mlx/io/CMakeLists.txt, + mlx/io/gguf_quants.cpp, + mlx/io/gguf.cpp, + mlx/io/gguf.h, + mlx/io/load.h, + mlx/io/no_safetensors.cpp, + mlx/linalg.h, + mlx/memory.h, + mlx/mlx.h, + mlx/ops.h, + mlx/primitives.h, + mlx/random.h, + mlx/scheduler.h, + mlx/small_vector.h, + mlx/stream.h, + mlx/threadpool.h, + mlx/transforms_impl.h, + mlx/transforms.h, + mlx/types/bf16.h, + mlx/types/complex.h, + mlx/types/fp16.h, + mlx/types/half_types.h, + mlx/types/limits.h, + mlx/utils.h, + mlx/version.h, + pyproject.toml, + python/mlx/__main__.py, + python/mlx/_os_warning.py, + python/mlx/_reprlib_fix.py, + python/mlx/_stub_patterns.txt, + python/mlx/distributed_run.py, + python/mlx/extension.py, + python/mlx/nn/__init__.py, + python/mlx/nn/init.py, + python/mlx/nn/layers/__init__.py, + python/mlx/nn/layers/activations.py, + python/mlx/nn/layers/base.py, + python/mlx/nn/layers/containers.py, + python/mlx/nn/layers/convolution_transpose.py, + python/mlx/nn/layers/convolution.py, + python/mlx/nn/layers/distributed.py, + python/mlx/nn/layers/dropout.py, + python/mlx/nn/layers/embedding.py, + python/mlx/nn/layers/linear.py, + python/mlx/nn/layers/normalization.py, + python/mlx/nn/layers/pooling.py, + python/mlx/nn/layers/positional_encoding.py, + python/mlx/nn/layers/quantized.py, + python/mlx/nn/layers/recurrent.py, + python/mlx/nn/layers/transformer.py, + python/mlx/nn/layers/upsample.py, + python/mlx/nn/losses.py, + python/mlx/nn/utils.py, + python/mlx/optimizers/__init__.py, + python/mlx/optimizers/optimizers.py, + python/mlx/optimizers/schedulers.py, + python/mlx/py.typed, + python/mlx/utils.py, + python/scripts/repair_cuda.sh, + python/scripts/repair_linux.sh, + python/scripts/repair_record.py, + python/src/array.cpp, + python/src/buffer.h, + python/src/CMakeLists.txt, + python/src/constants.cpp, + python/src/convert.cpp, + python/src/convert.h, + python/src/cuda.cpp, + python/src/device.cpp, + python/src/distributed.cpp, + python/src/export.cpp, + python/src/fast.cpp, + python/src/fft.cpp, + python/src/indexing.cpp, + python/src/indexing.h, + python/src/linalg.cpp, + python/src/load.cpp, + python/src/load.h, + python/src/memory.cpp, + python/src/metal.cpp, + python/src/mlx_func.cpp, + python/src/mlx_func.h, + python/src/mlx.cpp, + python/src/ops.cpp, + python/src/random.cpp, + python/src/small_vector.h, + python/src/stream.cpp, + python/src/transforms.cpp, + python/src/trees.cpp, + python/src/trees.h, + python/src/utils.cpp, + python/src/utils.h, + python/tests/__main__.py, + python/tests/cuda_skip.py, + python/tests/mlx_distributed_tests.py, + python/tests/mlx_tests.py, + python/tests/mpi_test_distributed.py, + python/tests/nccl_test_distributed.py, + python/tests/ring_test_distributed.py, + python/tests/test_array.py, + python/tests/test_autograd.py, + python/tests/test_bf16.py, + python/tests/test_blas.py, + python/tests/test_compile.py, + python/tests/test_constants.py, + python/tests/test_conv_transpose.py, + python/tests/test_conv.py, + python/tests/test_device.py, + python/tests/test_double.py, + python/tests/test_einsum.py, + python/tests/test_eval.py, + python/tests/test_export_import.py, + python/tests/test_fast_sdpa.py, + python/tests/test_fast.py, + python/tests/test_fft.py, + python/tests/test_graph.py, + python/tests/test_init.py, + python/tests/test_linalg.py, + python/tests/test_load.py, + python/tests/test_losses.py, + python/tests/test_memory.py, + python/tests/test_nn.py, + python/tests/test_ops.py, + python/tests/test_optimizers.py, + python/tests/test_quantized.py, + python/tests/test_random.py, + python/tests/test_reduce.py, + python/tests/test_tree.py, + python/tests/test_upsample.py, + python/tests/test_vmap.py, + README.md, + setup.py, + tests/allocator_tests.cpp, + tests/arg_reduce_tests.cpp, + tests/array_tests.cpp, + tests/autograd_tests.cpp, + tests/blas_tests.cpp, + tests/CMakeLists.txt, + tests/compile_tests.cpp, + tests/creations_tests.cpp, + tests/custom_vjp_tests.cpp, + tests/device_tests.cpp, + tests/einsum_tests.cpp, + tests/eval_tests.cpp, + tests/export_import_tests.cpp, + tests/fft_tests.cpp, + tests/gpu_tests.cpp, + tests/linalg_tests.cpp, + tests/load_tests.cpp, + tests/ops_tests.cpp, + tests/random_tests.cpp, + tests/scheduler_tests.cpp, + tests/tests.cpp, + tests/utils_tests.cpp, + tests/vmap_tests.cpp, + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; + C3CB09A12EAC2EF70029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + publicHeaders = ( + Cmlx.h, + "mlx-allocator.h", + "mlx-array.h", + "mlx-backend-cuda-cuda.h", + "mlx-backend-gpu-available.h", + "mlx-backend-metal-metal.h", + "mlx-c-array.h", + "mlx-c-closure.h", + "mlx-c-compile.h", + "mlx-c-device.h", + "mlx-c-distributed_group.h", + "mlx-c-distributed.h", + "mlx-c-error.h", + "mlx-c-export.h", + "mlx-c-fast.h", + "mlx-c-fft.h", + "mlx-c-half.h", + "mlx-c-io_types.h", + "mlx-c-io.h", + "mlx-c-linalg.h", + "mlx-c-map.h", + "mlx-c-memory.h", + "mlx-c-metal.h", + "mlx-c-mlx.h", + "mlx-c-ops.h", + "mlx-c-optional.h", + "mlx-c-random.h", + "mlx-c-stream.h", + "mlx-c-string.h", + "mlx-c-transforms_impl.h", + "mlx-c-transforms.h", + "mlx-c-vector.h", + "mlx-c-version.h", + "mlx-compile.h", + "mlx-device.h", + "mlx-distributed-distributed.h", + "mlx-distributed-ops.h", + "mlx-dtype.h", + "mlx-einsum.h", + "mlx-event.h", + "mlx-export_impl.h", + "mlx-export.h", + "mlx-fast.h", + "mlx-fft.h", + "mlx-io-load.h", + "mlx-io.h", + "mlx-linalg.h", + "mlx-memory.h", + "mlx-ops.h", + "mlx-random.h", + "mlx-small_vector.h", + "mlx-stream.h", + "mlx-threadpool.h", + "mlx-transforms.h", + "mlx-types-bf16.h", + "mlx-types-complex.h", + "mlx-types-half_types.h", + "mlx-utils.h", + "mlx-version.h", + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; + C3CB0BCF2EAC301E0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + metal/arange.h, + metal/atomic.h, + metal/bf16_math.h, + metal/bf16.h, + metal/binary_ops.h, + metal/binary_two.h, + metal/binary.h, + metal/cexpf.h, + metal/complex.h, + metal/copy.h, + metal/defines.h, + metal/erf.h, + metal/expm1f.h, + metal/fft.h, + metal/fft/radix.h, + metal/fft/readwrite.h, + metal/fp4_quantized.h, + metal/gemv_masked.h, + metal/hadamard.h, + metal/indexing/gather_axis.h, + metal/indexing/gather_front.h, + metal/indexing/gather.h, + metal/indexing/indexing.h, + metal/indexing/scatter_axis.h, + metal/indexing/scatter.h, + metal/jit/bf16.h, + metal/logsumexp.h, + metal/metal_3_0/bf16.h, + metal/metal_3_1/bf16.h, + metal/quantized_utils.h, + metal/quantized.h, + metal/reduce_utils.h, + metal/reduce.h, + metal/reduction/ops.h, + metal/reduction/reduce_all.h, + metal/reduction/reduce_col.h, + metal/reduction/reduce_init.h, + metal/reduction/reduce_row.h, + metal/scan.h, + metal/sdpa_vector.h, + metal/softmax.h, + metal/sort.h, + metal/steel/attn/attn.h, + metal/steel/attn/kernels/steel_attention.h, + metal/steel/attn/loader.h, + metal/steel/attn/mma.h, + metal/steel/attn/params.h, + metal/steel/attn/transforms.h, + metal/steel/conv/conv.h, + metal/steel/conv/kernels/steel_conv_general.h, + metal/steel/conv/kernels/steel_conv.h, + metal/steel/conv/loader.h, + metal/steel/conv/loaders/loader_channel_l.h, + metal/steel/conv/loaders/loader_channel_n.h, + metal/steel/conv/loaders/loader_general.h, + metal/steel/conv/params.h, + metal/steel/defines.h, + metal/steel/gemm/gemm.h, + metal/steel/gemm/kernels/steel_gemm_fused.h, + metal/steel/gemm/kernels/steel_gemm_gather.h, + metal/steel/gemm/kernels/steel_gemm_masked.h, + metal/steel/gemm/kernels/steel_gemm_segmented.h, + metal/steel/gemm/kernels/steel_gemm_splitk.h, + metal/steel/gemm/loader.h, + metal/steel/gemm/mma.h, + metal/steel/gemm/params.h, + metal/steel/gemm/transforms.h, + metal/steel/utils.h, + metal/steel/utils/integral_constant.h, + metal/steel/utils/type_traits.h, + metal/ternary_ops.h, + metal/ternary.h, + metal/unary_ops.h, + metal/unary.h, + metal/utils.h, + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; + C3CBF3322EAC23D80029A645 /* Exceptions for "fmt" folder in "Cmlx" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + ".clang-format", + .gitignore, + ChangeLog.md, + CMakeLists.txt, + CONTRIBUTING.md, + doc/_static/bootstrap.min.js, + doc/_static/breathe.css, + "doc/_static/fonts/glyphicons-halflings-regular.eot", + "doc/_static/fonts/glyphicons-halflings-regular.svg", + "doc/_static/fonts/glyphicons-halflings-regular.ttf", + "doc/_static/fonts/glyphicons-halflings-regular.woff", + doc/_templates/layout.html, + doc/_templates/search.html, + doc/api.rst, + "doc/basic-bootstrap/layout.html", + "doc/basic-bootstrap/README", + "doc/basic-bootstrap/theme.conf", + doc/bootstrap/alerts.less, + doc/bootstrap/badges.less, + doc/bootstrap/bootstrap.less, + doc/bootstrap/breadcrumbs.less, + "doc/bootstrap/button-groups.less", + doc/bootstrap/buttons.less, + doc/bootstrap/carousel.less, + doc/bootstrap/close.less, + doc/bootstrap/code.less, + "doc/bootstrap/component-animations.less", + doc/bootstrap/dropdowns.less, + doc/bootstrap/forms.less, + doc/bootstrap/glyphicons.less, + doc/bootstrap/grid.less, + "doc/bootstrap/input-groups.less", + doc/bootstrap/jumbotron.less, + doc/bootstrap/labels.less, + "doc/bootstrap/list-group.less", + doc/bootstrap/media.less, + doc/bootstrap/mixins.less, + doc/bootstrap/mixins/alerts.less, + "doc/bootstrap/mixins/background-variant.less", + "doc/bootstrap/mixins/border-radius.less", + doc/bootstrap/mixins/buttons.less, + "doc/bootstrap/mixins/center-block.less", + doc/bootstrap/mixins/clearfix.less, + doc/bootstrap/mixins/forms.less, + doc/bootstrap/mixins/gradients.less, + "doc/bootstrap/mixins/grid-framework.less", + doc/bootstrap/mixins/grid.less, + "doc/bootstrap/mixins/hide-text.less", + doc/bootstrap/mixins/image.less, + doc/bootstrap/mixins/labels.less, + "doc/bootstrap/mixins/list-group.less", + "doc/bootstrap/mixins/nav-divider.less", + "doc/bootstrap/mixins/nav-vertical-align.less", + doc/bootstrap/mixins/opacity.less, + doc/bootstrap/mixins/pagination.less, + doc/bootstrap/mixins/panels.less, + "doc/bootstrap/mixins/progress-bar.less", + "doc/bootstrap/mixins/reset-filter.less", + doc/bootstrap/mixins/resize.less, + "doc/bootstrap/mixins/responsive-visibility.less", + doc/bootstrap/mixins/size.less, + "doc/bootstrap/mixins/tab-focus.less", + "doc/bootstrap/mixins/table-row.less", + "doc/bootstrap/mixins/text-emphasis.less", + "doc/bootstrap/mixins/text-overflow.less", + "doc/bootstrap/mixins/vendor-prefixes.less", + doc/bootstrap/modals.less, + doc/bootstrap/navbar.less, + doc/bootstrap/navs.less, + doc/bootstrap/normalize.less, + doc/bootstrap/pager.less, + doc/bootstrap/pagination.less, + doc/bootstrap/panels.less, + doc/bootstrap/popovers.less, + doc/bootstrap/print.less, + "doc/bootstrap/progress-bars.less", + "doc/bootstrap/responsive-embed.less", + "doc/bootstrap/responsive-utilities.less", + doc/bootstrap/scaffolding.less, + doc/bootstrap/tables.less, + doc/bootstrap/theme.less, + doc/bootstrap/thumbnails.less, + doc/bootstrap/tooltip.less, + doc/bootstrap/type.less, + doc/bootstrap/utilities.less, + doc/bootstrap/variables.less, + doc/bootstrap/wells.less, + doc/build.py, + doc/CMakeLists.txt, + doc/conf.py, + doc/contents.rst, + doc/fmt.less, + doc/index.rst, + "doc/python-license.txt", + doc/syntax.rst, + doc/usage.rst, + include/fmt/args.h, + include/fmt/chrono.h, + include/fmt/color.h, + include/fmt/compile.h, + include/fmt/core.h, + "include/fmt/format-inl.h", + include/fmt/format.h, + include/fmt/os.h, + include/fmt/ostream.h, + include/fmt/printf.h, + include/fmt/ranges.h, + include/fmt/std.h, + include/fmt/xchar.h, + LICENSE, + README.md, + src/fmt.cc, + src/os.cc, + support/Android.mk, + support/AndroidManifest.xml, + support/bazel/.bazelversion, + support/bazel/BUILD.bazel, + support/bazel/README.md, + support/bazel/WORKSPACE.bazel, + "support/build-docs.py", + support/build.gradle, + "support/C++.sublime-syntax", + support/cmake/FindSetEnv.cmake, + "support/cmake/fmt-config.cmake.in", + support/cmake/fmt.pc.in, + support/cmake/JoinPaths.cmake, + "support/compute-powers.py", + support/docopt.py, + support/manage.py, + support/printable.py, + support/README, + support/rtd/conf.py, + support/rtd/index.rst, + support/rtd/theme/layout.html, + support/rtd/theme/theme.conf, + support/Vagrantfile, + "test/add-subdirectory-test/CMakeLists.txt", + "test/add-subdirectory-test/main.cc", + "test/args-test.cc", + "test/assert-test.cc", + "test/chrono-test.cc", + test/CMakeLists.txt, + "test/color-test.cc", + "test/compile-error-test/CMakeLists.txt", + "test/compile-fp-test.cc", + "test/compile-test.cc", + "test/core-test.cc", + "test/cuda-test/CMakeLists.txt", + "test/cuda-test/cpp14.cc", + "test/cuda-test/cuda-cpp14.cu", + "test/detect-stdfs.cc", + "test/enforce-checks-test.cc", + "test/find-package-test/CMakeLists.txt", + "test/find-package-test/main.cc", + "test/format-impl-test.cc", + "test/format-test.cc", + test/fuzzing/.gitignore, + test/fuzzing/build.sh, + "test/fuzzing/chrono-duration.cc", + "test/fuzzing/chrono-timepoint.cc", + test/fuzzing/CMakeLists.txt, + test/fuzzing/float.cc, + "test/fuzzing/fuzzer-common.h", + test/fuzzing/main.cc, + "test/fuzzing/named-arg.cc", + "test/fuzzing/one-arg.cc", + test/fuzzing/README.md, + "test/fuzzing/two-args.cc", + "test/gtest-extra-test.cc", + "test/gtest-extra.cc", + "test/gtest-extra.h", + "test/gtest/.clang-format", + test/gtest/CMakeLists.txt, + "test/gtest/gmock-gtest-all.cc", + test/gtest/gmock/gmock.h, + "test/gtest/gtest/gtest-spi.h", + test/gtest/gtest/gtest.h, + "test/header-only-test.cc", + "test/mock-allocator.h", + "test/module-test.cc", + "test/noexception-test.cc", + "test/os-test.cc", + "test/ostream-test.cc", + "test/posix-mock-test.cc", + "test/posix-mock.h", + "test/printf-test.cc", + "test/ranges-odr-test.cc", + "test/ranges-test.cc", + "test/scan-test.cc", + test/scan.h, + "test/static-export-test/CMakeLists.txt", + "test/static-export-test/library.cc", + "test/static-export-test/main.cc", + "test/std-test.cc", + "test/test-assert.h", + "test/test-main.cc", + "test/unicode-test.cc", + test/util.cc, + test/util.h, + "test/xchar-test.cc", + ); + target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + C3434F7C2EABEF1E0010D6B8 /* MLX */ = { + isa = PBXFileSystemSynchronizedRootGroup; + name = MLX; + path = ../Source/MLX; + sourceTree = SOURCE_ROOT; + }; + C3AE8EDE2EAAA21C000BD280 /* xcconfig */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = xcconfig; + sourceTree = ""; + }; + C3AE90232EAAA47E000BD280 /* json */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = json; + sourceTree = ""; + }; + C3AE908B2EAAA47E000BD280 /* metal-cpp */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3AE939F2EAAAA5A000BD280 /* Exceptions for "metal-cpp" folder in "Cmlx" target */, + ); + path = "metal-cpp"; + sourceTree = ""; + }; + C3AE97002EAAAAAD000BD280 /* mlx */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3AE9EA62EAAABFC000BD280 /* Exceptions for "mlx" folder in "Cmlx" target */, + ); + path = mlx; + sourceTree = ""; + }; + C3AE97872EAAAAAD000BD280 /* mlx-conditional */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = "mlx-conditional"; + sourceTree = ""; + }; + C3AE98112EAAAAAD000BD280 /* mlx-generated */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3CB0BCF2EAC301E0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */, + ); + path = "mlx-generated"; + sourceTree = ""; + }; + C3AE9D992EAAAB29000BD280 /* mlx-c */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3AE9E162EAAAB37000BD280 /* Exceptions for "mlx-c" folder in "Cmlx" target */, + ); + path = "mlx-c"; + sourceTree = ""; + }; + C3CBE24A2EABF7870029A645 /* include-framework */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3CB09A12EAC2EF70029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */, + ); + path = "include-framework"; + sourceTree = ""; + }; + C3CBE6962EAC14BC0029A645 /* MLXTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + name = MLXTests; + path = ../Tests/MLXTests; + sourceTree = SOURCE_ROOT; + }; + C3CBE6E92EAC15530029A645 /* MLXNN */ = { + isa = PBXFileSystemSynchronizedRootGroup; + name = MLXNN; + path = ../Source/MLXNN; + sourceTree = SOURCE_ROOT; + }; + C3CBE6FF2EAC15650029A645 /* MLXOptimizers */ = { + isa = PBXFileSystemSynchronizedRootGroup; + name = MLXOptimizers; + path = ../Source/MLXOptimizers; + sourceTree = SOURCE_ROOT; + }; + C3CBF2682EAC23BA0029A645 /* fmt */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + C3CBF3322EAC23D80029A645 /* Exceptions for "fmt" folder in "Cmlx" target */, + ); + path = fmt; + sourceTree = ""; + }; + C3CBF3382EAC243B0029A645 /* tools */ = { + isa = PBXFileSystemSynchronizedRootGroup; + name = tools; + path = ../tools; + sourceTree = SOURCE_ROOT; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + C3AE8EC12EAAA15F000BD280 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3CBE67C2EABFBA60029A645 /* Numerics in Frameworks */, + C3434FA12EABEF350010D6B8 /* Cmlx.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8ECA2EAAA15F000BD280 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3CBE7022EAC15780029A645 /* MLXNN.framework in Frameworks */, + C3AE8ECE2EAAA15F000BD280 /* MLX.framework in Frameworks */, + C3CBE7062EAC15780029A645 /* MLXOptimizers.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8EE32EAAA3C5000BD280 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3AEA0342EAAE7A0000BD280 /* Metal.framework in Frameworks */, + C3AEA0362EAAE7A9000BD280 /* Foundation.framework in Frameworks */, + C3AEA0322EAAE79A000BD280 /* Accelerate.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6B22EAC14DE0029A645 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3CBE70B2EAC15850029A645 /* MLX.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6CC2EAC15310029A645 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3CBE7142EAC15960029A645 /* MLXNN.framework in Frameworks */, + C3CBE7102EAC15960029A645 /* MLX.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C3AE8EBA2EAAA15F000BD280 = { + isa = PBXGroup; + children = ( + C3CBF17F2EAC22110029A645 /* ACKNOWLEDGMENTS.md */, + C3AE8EFC2EAAA40E000BD280 /* Cmlx */, + C3CBF1802EAC22110029A645 /* CODE_OF_CONDUCT.md */, + C3CBF1812EAC22110029A645 /* CONTRIBUTING.md */, + C3AEA0302EAAE79A000BD280 /* Frameworks */, + C3CBF1822EAC22110029A645 /* LICENSE */, + C3CBF1832EAC22110029A645 /* MAINTENANCE.md */, + C3434F7C2EABEF1E0010D6B8 /* MLX */, + C3CBE6E92EAC15530029A645 /* MLXNN */, + C3CBE6FF2EAC15650029A645 /* MLXOptimizers */, + C3CBE6962EAC14BC0029A645 /* MLXTests */, + C3AE8EC52EAAA15F000BD280 /* Products */, + C3CBF1842EAC22110029A645 /* README.md */, + C3CBF1852EAC22110029A645 /* README.xcodeproj.md */, + C3CBF3382EAC243B0029A645 /* tools */, + C3AE8EDE2EAAA21C000BD280 /* xcconfig */, + ); + sourceTree = ""; + }; + C3AE8EC52EAAA15F000BD280 /* Products */ = { + isa = PBXGroup; + children = ( + C3AE8EC42EAAA15F000BD280 /* MLX.framework */, + C3AE8ECD2EAAA15F000BD280 /* MLXTests.xctest */, + C3AE8EE62EAAA3C5000BD280 /* Cmlx.framework */, + C3CBE6B52EAC14DE0029A645 /* MLXNN.framework */, + C3CBE6CF2EAC15310029A645 /* MLXOptimizers.framework */, + ); + name = Products; + sourceTree = ""; + }; + C3AE8EFC2EAAA40E000BD280 /* Cmlx */ = { + isa = PBXGroup; + children = ( + C3CBF2682EAC23BA0029A645 /* fmt */, + C3CBE24A2EABF7870029A645 /* include-framework */, + C3AE90232EAAA47E000BD280 /* json */, + C3AE908B2EAAA47E000BD280 /* metal-cpp */, + C3AE97002EAAAAAD000BD280 /* mlx */, + C3AE9D992EAAAB29000BD280 /* mlx-c */, + C3AE97872EAAAAAD000BD280 /* mlx-conditional */, + C3AE98112EAAAAAD000BD280 /* mlx-generated */, + ); + name = Cmlx; + path = ../Source/Cmlx; + sourceTree = ""; + }; + C3AEA0302EAAE79A000BD280 /* Frameworks */ = { + isa = PBXGroup; + children = ( + C3AEA0352EAAE7A9000BD280 /* Foundation.framework */, + C3AEA0332EAAE7A0000BD280 /* Metal.framework */, + C3AEA0312EAAE79A000BD280 /* Accelerate.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + C3AE8EBF2EAAA15F000BD280 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8EE12EAAA3C5000BD280 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6B02EAC14DE0029A645 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6CA2EAC15310029A645 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + C3AE8EC32EAAA15F000BD280 /* MLX */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3AE8ED62EAAA15F000BD280 /* Build configuration list for PBXNativeTarget "MLX" */; + buildPhases = ( + C3AE8EBF2EAAA15F000BD280 /* Headers */, + C3AE8EC02EAAA15F000BD280 /* Sources */, + C3AE8EC12EAAA15F000BD280 /* Frameworks */, + C3AE8EC22EAAA15F000BD280 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + C3434F7C2EABEF1E0010D6B8 /* MLX */, + ); + name = MLX; + packageProductDependencies = ( + C3CBE67B2EABFBA60029A645 /* Numerics */, + ); + productName = MLX; + productReference = C3AE8EC42EAAA15F000BD280 /* MLX.framework */; + productType = "com.apple.product-type.framework"; + }; + C3AE8ECC2EAAA15F000BD280 /* MLXTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3AE8ED92EAAA15F000BD280 /* Build configuration list for PBXNativeTarget "MLXTests" */; + buildPhases = ( + C3AE8EC92EAAA15F000BD280 /* Sources */, + C3AE8ECA2EAAA15F000BD280 /* Frameworks */, + C3AE8ECB2EAAA15F000BD280 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C3AE8ED02EAAA15F000BD280 /* PBXTargetDependency */, + C3CBE7052EAC15780029A645 /* PBXTargetDependency */, + C3CBE7092EAC15780029A645 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + C3CBE6962EAC14BC0029A645 /* MLXTests */, + ); + name = MLXTests; + packageProductDependencies = ( + ); + productName = MLXTests; + productReference = C3AE8ECD2EAAA15F000BD280 /* MLXTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + C3AE8EE52EAAA3C5000BD280 /* Cmlx */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3AE8EF52EAAA3C5000BD280 /* Build configuration list for PBXNativeTarget "Cmlx" */; + buildPhases = ( + C3AE8EE12EAAA3C5000BD280 /* Headers */, + C3AE8EE22EAAA3C5000BD280 /* Sources */, + C3AE8EE32EAAA3C5000BD280 /* Frameworks */, + C3AE8EE42EAAA3C5000BD280 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + C3AE908B2EAAA47E000BD280 /* metal-cpp */, + C3AE97002EAAAAAD000BD280 /* mlx */, + C3AE97872EAAAAAD000BD280 /* mlx-conditional */, + C3AE98112EAAAAAD000BD280 /* mlx-generated */, + C3AE9D992EAAAB29000BD280 /* mlx-c */, + C3CBE24A2EABF7870029A645 /* include-framework */, + C3CBF2682EAC23BA0029A645 /* fmt */, + ); + name = Cmlx; + packageProductDependencies = ( + ); + productName = Cmlx; + productReference = C3AE8EE62EAAA3C5000BD280 /* Cmlx.framework */; + productType = "com.apple.product-type.framework"; + }; + C3CBE6B42EAC14DE0029A645 /* MLXNN */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3CBE6C42EAC14DE0029A645 /* Build configuration list for PBXNativeTarget "MLXNN" */; + buildPhases = ( + C3CBE6B02EAC14DE0029A645 /* Headers */, + C3CBE6B12EAC14DE0029A645 /* Sources */, + C3CBE6B22EAC14DE0029A645 /* Frameworks */, + C3CBE6B32EAC14DE0029A645 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C3CBE70E2EAC15850029A645 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + C3CBE6E92EAC15530029A645 /* MLXNN */, + ); + name = MLXNN; + packageProductDependencies = ( + ); + productName = MLXNN; + productReference = C3CBE6B52EAC14DE0029A645 /* MLXNN.framework */; + productType = "com.apple.product-type.framework"; + }; + C3CBE6CE2EAC15310029A645 /* MLXOptimizers */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3CBE6D32EAC15320029A645 /* Build configuration list for PBXNativeTarget "MLXOptimizers" */; + buildPhases = ( + C3CBE6CA2EAC15310029A645 /* Headers */, + C3CBE6CB2EAC15310029A645 /* Sources */, + C3CBE6CC2EAC15310029A645 /* Frameworks */, + C3CBE6CD2EAC15310029A645 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C3CBE7132EAC15960029A645 /* PBXTargetDependency */, + C3CBE7172EAC15960029A645 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + C3CBE6FF2EAC15650029A645 /* MLXOptimizers */, + ); + name = MLXOptimizers; + packageProductDependencies = ( + ); + productName = MLXOptimizers; + productReference = C3CBE6CF2EAC15310029A645 /* MLXOptimizers.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C3AE8EBB2EAAA15F000BD280 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1640; + LastUpgradeCheck = 1640; + ORGANIZATIONNAME = "Apple Inc."; + TargetAttributes = { + C3AE8EC32EAAA15F000BD280 = { + CreatedOnToolsVersion = 16.4; + }; + C3AE8ECC2EAAA15F000BD280 = { + CreatedOnToolsVersion = 16.4; + }; + C3AE8EE52EAAA3C5000BD280 = { + CreatedOnToolsVersion = 16.4; + }; + C3CBE6B42EAC14DE0029A645 = { + CreatedOnToolsVersion = 16.4; + }; + C3CBE6CE2EAC15310029A645 = { + CreatedOnToolsVersion = 16.4; + }; + }; + }; + buildConfigurationList = C3AE8EBE2EAAA15F000BD280 /* Build configuration list for PBXProject "MLX" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C3AE8EBA2EAAA15F000BD280; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + C3CBE67A2EABFBA60029A645 /* XCRemoteSwiftPackageReference "swift-numerics" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = C3AE8EC52EAAA15F000BD280 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C3AE8EC32EAAA15F000BD280 /* MLX */, + C3AE8ECC2EAAA15F000BD280 /* MLXTests */, + C3AE8EE52EAAA3C5000BD280 /* Cmlx */, + C3CBE6B42EAC14DE0029A645 /* MLXNN */, + C3CBE6CE2EAC15310029A645 /* MLXOptimizers */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C3AE8EC22EAAA15F000BD280 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8ECB2EAAA15F000BD280 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8EE42EAAA3C5000BD280 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6B32EAC14DE0029A645 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6CD2EAC15310029A645 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C3AE8EC02EAAA15F000BD280 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8EC92EAAA15F000BD280 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3AE8EE22EAAA3C5000BD280 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6B12EAC14DE0029A645 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C3CBE6CB2EAC15310029A645 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + C3AE8ED02EAAA15F000BD280 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3AE8EC32EAAA15F000BD280 /* MLX */; + targetProxy = C3AE8ECF2EAAA15F000BD280 /* PBXContainerItemProxy */; + }; + C3CBE7052EAC15780029A645 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3CBE6B42EAC14DE0029A645 /* MLXNN */; + targetProxy = C3CBE7042EAC15780029A645 /* PBXContainerItemProxy */; + }; + C3CBE7092EAC15780029A645 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3CBE6CE2EAC15310029A645 /* MLXOptimizers */; + targetProxy = C3CBE7082EAC15780029A645 /* PBXContainerItemProxy */; + }; + C3CBE70E2EAC15850029A645 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3AE8EC32EAAA15F000BD280 /* MLX */; + targetProxy = C3CBE70D2EAC15850029A645 /* PBXContainerItemProxy */; + }; + C3CBE7132EAC15960029A645 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3AE8EC32EAAA15F000BD280 /* MLX */; + targetProxy = C3CBE7122EAC15960029A645 /* PBXContainerItemProxy */; + }; + C3CBE7172EAC15960029A645 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C3CBE6B42EAC14DE0029A645 /* MLXNN */; + targetProxy = C3CBE7162EAC15960029A645 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + C3AE8ED42EAAA15F000BD280 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = project.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3AE8ED52EAAA15F000BD280 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = project.xcconfig; + buildSettings = { + }; + name = Release; + }; + C3AE8ED72EAAA15F000BD280 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLX.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3AE8ED82EAAA15F000BD280 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLX.xcconfig; + buildSettings = { + }; + name = Release; + }; + C3AE8EDA2EAAA15F000BD280 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXTests.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3AE8EDB2EAAA15F000BD280 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXTests.xcconfig; + buildSettings = { + }; + name = Release; + }; + C3AE8EF62EAAA3C5000BD280 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = Cmlx.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3AE8EF72EAAA3C5000BD280 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = Cmlx.xcconfig; + buildSettings = { + }; + name = Release; + }; + C3CBE6C52EAC14DE0029A645 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXNN.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3CBE6C62EAC14DE0029A645 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXNN.xcconfig; + buildSettings = { + }; + name = Release; + }; + C3CBE6D42EAC15320029A645 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXOptimizers.xcconfig; + buildSettings = { + }; + name = Debug; + }; + C3CBE6D52EAC15320029A645 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = C3AE8EDE2EAAA21C000BD280 /* xcconfig */; + baseConfigurationReferenceRelativePath = MLXOptimizers.xcconfig; + buildSettings = { + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C3AE8EBE2EAAA15F000BD280 /* Build configuration list for PBXProject "MLX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3AE8ED42EAAA15F000BD280 /* Debug */, + C3AE8ED52EAAA15F000BD280 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3AE8ED62EAAA15F000BD280 /* Build configuration list for PBXNativeTarget "MLX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3AE8ED72EAAA15F000BD280 /* Debug */, + C3AE8ED82EAAA15F000BD280 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3AE8ED92EAAA15F000BD280 /* Build configuration list for PBXNativeTarget "MLXTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3AE8EDA2EAAA15F000BD280 /* Debug */, + C3AE8EDB2EAAA15F000BD280 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3AE8EF52EAAA3C5000BD280 /* Build configuration list for PBXNativeTarget "Cmlx" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3AE8EF62EAAA3C5000BD280 /* Debug */, + C3AE8EF72EAAA3C5000BD280 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3CBE6C42EAC14DE0029A645 /* Build configuration list for PBXNativeTarget "MLXNN" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3CBE6C52EAC14DE0029A645 /* Debug */, + C3CBE6C62EAC14DE0029A645 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3CBE6D32EAC15320029A645 /* Build configuration list for PBXNativeTarget "MLXOptimizers" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3CBE6D42EAC15320029A645 /* Debug */, + C3CBE6D52EAC15320029A645 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + C3CBE67A2EABFBA60029A645 /* XCRemoteSwiftPackageReference "swift-numerics" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-numerics.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.1.1; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + C3CBE67B2EABFBA60029A645 /* Numerics */ = { + isa = XCSwiftPackageProductDependency; + package = C3CBE67A2EABFBA60029A645 /* XCRemoteSwiftPackageReference "swift-numerics" */; + productName = Numerics; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C3AE8EBB2EAAA15F000BD280 /* Project object */; +} diff --git a/xcode/MLX.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/xcode/MLX.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/xcode/MLX.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/xcode/xcconfig/Cmlx.xcconfig b/xcode/xcconfig/Cmlx.xcconfig new file mode 100644 index 00000000..7ab66d21 --- /dev/null +++ b/xcode/xcconfig/Cmlx.xcconfig @@ -0,0 +1,99 @@ +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +ALWAYS_SEARCH_USER_PATHS = NO +ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES +BUILD_LIBRARY_FOR_DISTRIBUTION = YES +CLANG_ANALYZER_NONNULL = YES +CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE +CLANG_CXX_LANGUAGE_STANDARD = gnu++17 +CLANG_ENABLE_MODULES = YES +CLANG_ENABLE_OBJC_ARC = YES +CLANG_ENABLE_OBJC_WEAK = YES +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES +CLANG_WARN_BOOL_CONVERSION = YES +CLANG_WARN_COMMA = YES +CLANG_WARN_CONSTANT_CONVERSION = YES +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +CLANG_WARN_DOCUMENTATION_COMMENTS = YES +CLANG_WARN_EMPTY_BODY = YES +CLANG_WARN_ENUM_CONVERSION = YES +CLANG_WARN_INFINITE_RECURSION = YES +CLANG_WARN_INT_CONVERSION = YES +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_SUSPICIOUS_MOVE = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN_UNREACHABLE_CODE = YES +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CODE_SIGN_STYLE = Automatic +COPY_PHASE_STRIP = NO +CURRENT_PROJECT_VERSION = 1 +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym +DYLIB_COMPATIBILITY_VERSION = 1 +DYLIB_CURRENT_VERSION = 1 +DYLIB_INSTALL_NAME_BASE = @rpath +ENABLE_MODULE_VERIFIER = YES +ENABLE_NS_ASSERTIONS[config=Release] = NO +ENABLE_STRICT_OBJC_MSGSEND = YES +ENABLE_TESTABILITY[config=Debug] = YES +ENABLE_USER_SCRIPT_SANDBOXING = YES +GCC_C_LANGUAGE_STANDARD = c17 +GCC_DYNAMIC_NO_PIC[config=Debug] = NO +GCC_NO_COMMON_BLOCKS = YES +GCC_OPTIMIZATION_LEVEL[config=Debug] = 0 +GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 $(inherited) +GCC_WARN_64_TO_32_BIT_CONVERSION = YES +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +GCC_WARN_UNDECLARED_SELECTOR = YES +GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +GCC_WARN_UNUSED_FUNCTION = YES +GCC_WARN_UNUSED_VARIABLE = YES +GENERATE_INFOPLIST_FILE = YES +INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2025 Apple Inc. All rights reserved. +INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks +IPHONEOS_DEPLOYMENT_TARGET = 18.5 +LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks @loader_path/Frameworks +LOCALIZATION_PREFERS_STRING_CATALOGS = YES +MACOSX_DEPLOYMENT_TARGET = 15.5 +MARKETING_VERSION = 1.0 +MODULE_VERIFIER_SUPPORTED_LANGUAGES = objective-c objective-c++ +MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = gnu17 gnu++20 +MTL_ENABLE_DEBUG_INFO[config=Debug] = INCLUDE_SOURCE +MTL_ENABLE_DEBUG_INFO[config=Release] = NO +MTL_FAST_MATH = YES +ONLY_ACTIVE_ARCH[config=Debug] = YES +PRODUCT_BUNDLE_IDENTIFIER = com.apple.mlx.Cmlx +PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) +SDKROOT = auto +SKIP_INSTALL = YES +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG $(inherited) +SWIFT_COMPILATION_MODE[config=Release] = wholemodule +SWIFT_EMIT_LOC_STRINGS = YES +SWIFT_INSTALL_MODULE = YES +SWIFT_INSTALL_OBJC_HEADER = NO +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +SWIFT_VERSION = 5.0 +TARGETED_DEVICE_FAMILY = 1,2,7 +VERSIONING_SYSTEM = apple-generic +VERSION_INFO_PREFIX = +XROS_DEPLOYMENT_TARGET = 2.5 + +DEFINES_MODULE = YES + +HEADER_SEARCH_PATHS = $(SDKROOT)/usr/include/c++/v1 $(SDKROOT)/usr/include $(inherited) $(SRCROOT)/../Source/Cmlx/metal-cpp $(SRCROOT)/../Source/Cmlx/fmt/include $(SRCROOT)/../Source/Cmlx/json/single_include/nlohmann + +OTHER_CFLAGS = -isysroot $(SDKROOT) + +USER_HEADER_SEARCH_PATHS = $(SRCROOT)/../Source/Cmlx/mlx-c $(SRCROOT)/../Source/Cmlx/mlx + + +GCC_PREPROCESSOR_DEFINITIONS = _METAL_=1 SWIFTPM_BUNDLE=\"com.apple.mlx.Cmlx\" MLX_VERSION=\"0.29.1\" MLX_USE_ACCELERATE=1 METAL_PATH=\"default.metallib\" ACCELERATE_NEW_LAPACK=1 + diff --git a/xcode/xcconfig/MLX.xcconfig b/xcode/xcconfig/MLX.xcconfig new file mode 100644 index 00000000..b4991f0e --- /dev/null +++ b/xcode/xcconfig/MLX.xcconfig @@ -0,0 +1,88 @@ +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +ALWAYS_SEARCH_USER_PATHS = NO +ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES +CLANG_ANALYZER_NONNULL = YES +CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE +CLANG_CXX_LANGUAGE_STANDARD = gnu++20 +CLANG_ENABLE_MODULES = YES +CLANG_ENABLE_OBJC_ARC = YES +CLANG_ENABLE_OBJC_WEAK = YES +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES +CLANG_WARN_BOOL_CONVERSION = YES +CLANG_WARN_COMMA = YES +CLANG_WARN_CONSTANT_CONVERSION = YES +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +CLANG_WARN_DOCUMENTATION_COMMENTS = YES +CLANG_WARN_EMPTY_BODY = YES +CLANG_WARN_ENUM_CONVERSION = YES +CLANG_WARN_INFINITE_RECURSION = YES +CLANG_WARN_INT_CONVERSION = YES +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_SUSPICIOUS_MOVE = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN_UNREACHABLE_CODE = YES +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CODE_SIGN_STYLE = Automatic +COPY_PHASE_STRIP = NO +CURRENT_PROJECT_VERSION = 1 +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym +DYLIB_COMPATIBILITY_VERSION = 1 +DYLIB_CURRENT_VERSION = 1 +DYLIB_INSTALL_NAME_BASE = @rpath +ENABLE_MODULE_VERIFIER = YES +ENABLE_NS_ASSERTIONS[config=Release] = NO +ENABLE_STRICT_OBJC_MSGSEND = YES +ENABLE_TESTABILITY[config=Debug] = YES +ENABLE_USER_SCRIPT_SANDBOXING = YES +GCC_C_LANGUAGE_STANDARD = gnu17 +GCC_DYNAMIC_NO_PIC[config=Debug] = NO +GCC_NO_COMMON_BLOCKS = YES +GCC_OPTIMIZATION_LEVEL[config=Debug] = 0 +GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 $(inherited) +GCC_WARN_64_TO_32_BIT_CONVERSION = YES +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +GCC_WARN_UNDECLARED_SELECTOR = YES +GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +GCC_WARN_UNUSED_FUNCTION = YES +GCC_WARN_UNUSED_VARIABLE = YES +GENERATE_INFOPLIST_FILE = YES +INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2025 Apple Inc. All rights reserved. +INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks +IPHONEOS_DEPLOYMENT_TARGET = 18.5 +LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks @loader_path/Frameworks +LOCALIZATION_PREFERS_STRING_CATALOGS = YES +MACOSX_DEPLOYMENT_TARGET = 15.5 +MARKETING_VERSION = 1.0 +MODULE_VERIFIER_SUPPORTED_LANGUAGES = objective-c objective-c++ +MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = gnu17 gnu++20 +MTL_ENABLE_DEBUG_INFO[config=Debug] = INCLUDE_SOURCE +MTL_ENABLE_DEBUG_INFO[config=Release] = NO +MTL_FAST_MATH = YES +ONLY_ACTIVE_ARCH[config=Debug] = YES +PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) +SDKROOT = auto +SKIP_INSTALL = YES +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG $(inherited) +SWIFT_COMPILATION_MODE[config=Release] = wholemodule +SWIFT_EMIT_LOC_STRINGS = YES +SWIFT_INSTALL_MODULE = YES +SWIFT_INSTALL_OBJC_HEADER = NO +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +SWIFT_VERSION = 5.0 +TARGETED_DEVICE_FAMILY = 1,2,7 +VERSIONING_SYSTEM = apple-generic +VERSION_INFO_PREFIX = +XROS_DEPLOYMENT_TARGET = 2.5 + + +PRODUCT_BUNDLE_IDENTIFIER = com.apple.mlx.MLX diff --git a/xcode/xcconfig/MLXNN.xcconfig b/xcode/xcconfig/MLXNN.xcconfig new file mode 100644 index 00000000..d77ea5cc --- /dev/null +++ b/xcode/xcconfig/MLXNN.xcconfig @@ -0,0 +1,88 @@ +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +ALWAYS_SEARCH_USER_PATHS = NO +ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES +CLANG_ANALYZER_NONNULL = YES +CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE +CLANG_CXX_LANGUAGE_STANDARD = gnu++20 +CLANG_ENABLE_MODULES = YES +CLANG_ENABLE_OBJC_ARC = YES +CLANG_ENABLE_OBJC_WEAK = YES +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES +CLANG_WARN_BOOL_CONVERSION = YES +CLANG_WARN_COMMA = YES +CLANG_WARN_CONSTANT_CONVERSION = YES +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +CLANG_WARN_DOCUMENTATION_COMMENTS = YES +CLANG_WARN_EMPTY_BODY = YES +CLANG_WARN_ENUM_CONVERSION = YES +CLANG_WARN_INFINITE_RECURSION = YES +CLANG_WARN_INT_CONVERSION = YES +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_SUSPICIOUS_MOVE = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN_UNREACHABLE_CODE = YES +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CODE_SIGN_STYLE = Automatic +COPY_PHASE_STRIP = NO +CURRENT_PROJECT_VERSION = 1 +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym +DYLIB_COMPATIBILITY_VERSION = 1 +DYLIB_CURRENT_VERSION = 1 +DYLIB_INSTALL_NAME_BASE = @rpath +ENABLE_MODULE_VERIFIER = YES +ENABLE_NS_ASSERTIONS[config=Release] = NO +ENABLE_STRICT_OBJC_MSGSEND = YES +ENABLE_TESTABILITY[config=Debug] = YES +ENABLE_USER_SCRIPT_SANDBOXING = YES +GCC_C_LANGUAGE_STANDARD = gnu17 +GCC_DYNAMIC_NO_PIC[config=Debug] = NO +GCC_NO_COMMON_BLOCKS = YES +GCC_OPTIMIZATION_LEVEL[config=Debug] = 0 +GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 $(inherited) +GCC_WARN_64_TO_32_BIT_CONVERSION = YES +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +GCC_WARN_UNDECLARED_SELECTOR = YES +GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +GCC_WARN_UNUSED_FUNCTION = YES +GCC_WARN_UNUSED_VARIABLE = YES +GENERATE_INFOPLIST_FILE = YES +INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2025 Apple Inc. All rights reserved. +INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks +IPHONEOS_DEPLOYMENT_TARGET = 18.5 +LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks @loader_path/Frameworks +LOCALIZATION_PREFERS_STRING_CATALOGS = YES +MACOSX_DEPLOYMENT_TARGET = 15.5 +MARKETING_VERSION = 1.0 +MODULE_VERIFIER_SUPPORTED_LANGUAGES = objective-c objective-c++ +MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = gnu17 gnu++20 +MTL_ENABLE_DEBUG_INFO[config=Debug] = INCLUDE_SOURCE +MTL_ENABLE_DEBUG_INFO[config=Release] = NO +MTL_FAST_MATH = YES +ONLY_ACTIVE_ARCH[config=Debug] = YES +PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) +SDKROOT = auto +SKIP_INSTALL = YES +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG $(inherited) +SWIFT_COMPILATION_MODE[config=Release] = wholemodule +SWIFT_EMIT_LOC_STRINGS = YES +SWIFT_INSTALL_MODULE = YES +SWIFT_INSTALL_OBJC_HEADER = NO +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +SWIFT_VERSION = 5.0 +TARGETED_DEVICE_FAMILY = 1,2,7 +VERSIONING_SYSTEM = apple-generic +VERSION_INFO_PREFIX = +XROS_DEPLOYMENT_TARGET = 2.5 + + +PRODUCT_BUNDLE_IDENTIFIER = com.apple.mlx.MLXNN diff --git a/xcode/xcconfig/MLXOptimizers.xcconfig b/xcode/xcconfig/MLXOptimizers.xcconfig new file mode 100644 index 00000000..eabdfe80 --- /dev/null +++ b/xcode/xcconfig/MLXOptimizers.xcconfig @@ -0,0 +1,88 @@ +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +ALWAYS_SEARCH_USER_PATHS = NO +ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES +CLANG_ANALYZER_NONNULL = YES +CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE +CLANG_CXX_LANGUAGE_STANDARD = gnu++20 +CLANG_ENABLE_MODULES = YES +CLANG_ENABLE_OBJC_ARC = YES +CLANG_ENABLE_OBJC_WEAK = YES +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES +CLANG_WARN_BOOL_CONVERSION = YES +CLANG_WARN_COMMA = YES +CLANG_WARN_CONSTANT_CONVERSION = YES +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +CLANG_WARN_DOCUMENTATION_COMMENTS = YES +CLANG_WARN_EMPTY_BODY = YES +CLANG_WARN_ENUM_CONVERSION = YES +CLANG_WARN_INFINITE_RECURSION = YES +CLANG_WARN_INT_CONVERSION = YES +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_SUSPICIOUS_MOVE = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN_UNREACHABLE_CODE = YES +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CODE_SIGN_STYLE = Automatic +COPY_PHASE_STRIP = NO +CURRENT_PROJECT_VERSION = 1 +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym +DYLIB_COMPATIBILITY_VERSION = 1 +DYLIB_CURRENT_VERSION = 1 +DYLIB_INSTALL_NAME_BASE = @rpath +ENABLE_MODULE_VERIFIER = YES +ENABLE_NS_ASSERTIONS[config=Release] = NO +ENABLE_STRICT_OBJC_MSGSEND = YES +ENABLE_TESTABILITY[config=Debug] = YES +ENABLE_USER_SCRIPT_SANDBOXING = YES +GCC_C_LANGUAGE_STANDARD = gnu17 +GCC_DYNAMIC_NO_PIC[config=Debug] = NO +GCC_NO_COMMON_BLOCKS = YES +GCC_OPTIMIZATION_LEVEL[config=Debug] = 0 +GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 $(inherited) +GCC_WARN_64_TO_32_BIT_CONVERSION = YES +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +GCC_WARN_UNDECLARED_SELECTOR = YES +GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +GCC_WARN_UNUSED_FUNCTION = YES +GCC_WARN_UNUSED_VARIABLE = YES +GENERATE_INFOPLIST_FILE = YES +INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2025 Apple Inc. All rights reserved. +INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks +IPHONEOS_DEPLOYMENT_TARGET = 18.5 +LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks @loader_path/Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks @loader_path/Frameworks +LOCALIZATION_PREFERS_STRING_CATALOGS = YES +MACOSX_DEPLOYMENT_TARGET = 15.5 +MARKETING_VERSION = 1.0 +MODULE_VERIFIER_SUPPORTED_LANGUAGES = objective-c objective-c++ +MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = gnu17 gnu++20 +MTL_ENABLE_DEBUG_INFO[config=Debug] = INCLUDE_SOURCE +MTL_ENABLE_DEBUG_INFO[config=Release] = NO +MTL_FAST_MATH = YES +ONLY_ACTIVE_ARCH[config=Debug] = YES +PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) +SDKROOT = auto +SKIP_INSTALL = YES +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG $(inherited) +SWIFT_COMPILATION_MODE[config=Release] = wholemodule +SWIFT_EMIT_LOC_STRINGS = YES +SWIFT_INSTALL_MODULE = YES +SWIFT_INSTALL_OBJC_HEADER = NO +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +SWIFT_VERSION = 5.0 +TARGETED_DEVICE_FAMILY = 1,2,7 +VERSIONING_SYSTEM = apple-generic +VERSION_INFO_PREFIX = +XROS_DEPLOYMENT_TARGET = 2.5 + + +PRODUCT_BUNDLE_IDENTIFIER = com.apple.mlx.MLXOptimizers diff --git a/xcode/xcconfig/MLXTests.xcconfig b/xcode/xcconfig/MLXTests.xcconfig new file mode 100644 index 00000000..c9861c56 --- /dev/null +++ b/xcode/xcconfig/MLXTests.xcconfig @@ -0,0 +1,16 @@ +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +CODE_SIGN_STYLE = Automatic +CURRENT_PROJECT_VERSION = 1 +GENERATE_INFOPLIST_FILE = YES +IPHONEOS_DEPLOYMENT_TARGET = 18.5 +MACOSX_DEPLOYMENT_TARGET = 15.5 +MARKETING_VERSION = 1.0 +PRODUCT_BUNDLE_IDENTIFIER = com.apple.mlx.MLXTests +PRODUCT_NAME = $(TARGET_NAME) +SDKROOT = auto +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator +SWIFT_EMIT_LOC_STRINGS = NO +SWIFT_VERSION = 5.0 +TARGETED_DEVICE_FAMILY = 1,2,7 +XROS_DEPLOYMENT_TARGET = 2.5 + diff --git a/xcode/xcconfig/project.xcconfig b/xcode/xcconfig/project.xcconfig new file mode 100644 index 00000000..812b2a54 --- /dev/null +++ b/xcode/xcconfig/project.xcconfig @@ -0,0 +1,60 @@ +ALWAYS_SEARCH_USER_PATHS = NO +ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES +CLANG_ANALYZER_NONNULL = YES +CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE +CLANG_CXX_LANGUAGE_STANDARD = c++17 +CLANG_ENABLE_MODULES = YES +CLANG_ENABLE_OBJC_ARC = YES +CLANG_ENABLE_OBJC_WEAK = YES +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES +CLANG_WARN_BOOL_CONVERSION = YES +CLANG_WARN_COMMA = YES +CLANG_WARN_CONSTANT_CONVERSION = YES +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +CLANG_WARN_DOCUMENTATION_COMMENTS = YES +CLANG_WARN_EMPTY_BODY = YES +CLANG_WARN_ENUM_CONVERSION = YES +CLANG_WARN_INFINITE_RECURSION = YES +CLANG_WARN_INT_CONVERSION = YES +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_SUSPICIOUS_MOVE = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN_UNREACHABLE_CODE = YES +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +COPY_PHASE_STRIP = NO +CURRENT_PROJECT_VERSION = 1 +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym +ENABLE_NS_ASSERTIONS[config=Release] = NO +ENABLE_STRICT_OBJC_MSGSEND = YES +ENABLE_TESTABILITY[config=Debug] = YES +ENABLE_USER_SCRIPT_SANDBOXING = YES +GCC_C_LANGUAGE_STANDARD = c17 +GCC_DYNAMIC_NO_PIC[config=Debug] = NO +GCC_NO_COMMON_BLOCKS = YES +GCC_OPTIMIZATION_LEVEL[config=Debug] = 0 +GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 $(inherited) +GCC_WARN_64_TO_32_BIT_CONVERSION = YES +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +GCC_WARN_UNDECLARED_SELECTOR = YES +GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +GCC_WARN_UNUSED_FUNCTION = YES +GCC_WARN_UNUSED_VARIABLE = YES +LOCALIZATION_PREFERS_STRING_CATALOGS = YES +MTL_ENABLE_DEBUG_INFO[config=Debug] = INCLUDE_SOURCE +MTL_ENABLE_DEBUG_INFO[config=Release] = NO +MTL_FAST_MATH = YES +ONLY_ACTIVE_ARCH[config=Debug] = YES +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG $(inherited) +SWIFT_COMPILATION_MODE[config=Release] = wholemodule +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +VERSIONING_SYSTEM = apple-generic +VERSION_INFO_PREFIX = + From f61870c9761883ae8760301b4149b285c5708afc Mon Sep 17 00:00:00 2001 From: David Koski Date: Tue, 28 Oct 2025 09:04:13 -0700 Subject: [PATCH 2/3] ObjC class triggers load in framework --- Package.swift | 4 ++++ Source/Cmlx/framework/Cmlx.m | 12 ++++++++++++ xcode/MLX.xcodeproj/project.pbxproj | 7 +++++++ 3 files changed, 23 insertions(+) create mode 100644 Source/Cmlx/framework/Cmlx.m diff --git a/Package.swift b/Package.swift index 49c39b2b..551d9982 100644 --- a/Package.swift +++ b/Package.swift @@ -32,6 +32,10 @@ let package = Package( .target( name: "Cmlx", exclude: [ + // xcodeproj pieces + "framework", + "include-framework", + // vendor docs "metal-cpp.patch", "vendor-README.md", diff --git a/Source/Cmlx/framework/Cmlx.m b/Source/Cmlx/framework/Cmlx.m new file mode 100644 index 00000000..aa68ed20 --- /dev/null +++ b/Source/Cmlx/framework/Cmlx.m @@ -0,0 +1,12 @@ +// +// Copyright © 2025 Apple Inc. All rights reserved. +// + +#import + +// ObjC class to trigger loading as a NSBundle.allFrameworks +@interface Cmlx: NSObject +@end + +@implementation Cmlx +@end diff --git a/xcode/MLX.xcodeproj/project.pbxproj b/xcode/MLX.xcodeproj/project.pbxproj index a6d7fb72..76ed91b0 100644 --- a/xcode/MLX.xcodeproj/project.pbxproj +++ b/xcode/MLX.xcodeproj/project.pbxproj @@ -1383,6 +1383,11 @@ path = "mlx-c"; sourceTree = ""; }; + C3CB25472EB11EFE0029A645 /* framework */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = framework; + sourceTree = ""; + }; C3CBE24A2EABF7870029A645 /* include-framework */ = { isa = PBXFileSystemSynchronizedRootGroup; exceptions = ( @@ -1512,6 +1517,7 @@ C3AE8EFC2EAAA40E000BD280 /* Cmlx */ = { isa = PBXGroup; children = ( + C3CB25472EB11EFE0029A645 /* framework */, C3CBF2682EAC23BA0029A645 /* fmt */, C3CBE24A2EABF7870029A645 /* include-framework */, C3AE90232EAAA47E000BD280 /* json */, @@ -1637,6 +1643,7 @@ C3AE97872EAAAAAD000BD280 /* mlx-conditional */, C3AE98112EAAAAAD000BD280 /* mlx-generated */, C3AE9D992EAAAB29000BD280 /* mlx-c */, + C3CB25472EB11EFE0029A645 /* framework */, C3CBE24A2EABF7870029A645 /* include-framework */, C3CBF2682EAC23BA0029A645 /* fmt */, ); From e4b31a7f14fa1a68bf6d5847ec1b86df89aa4671 Mon Sep 17 00:00:00 2001 From: David Koski Date: Tue, 28 Oct 2025 15:19:21 -0700 Subject: [PATCH 3/3] expose more of the C++ API to implement extensions --- Source/Cmlx/include-framework/Cmlx.h | 8 + Source/Cmlx/include-framework/Metal.hpp | 22818 ++++++++++++++++ .../mlx-backend-common-utils.h | 207 + .../mlx-backend-cpu-encoder.h | 69 + .../include-framework/mlx-backend-gpu-eval.h | 20 + .../mlx-backend-metal-device.h | 270 + .../mlx-backend-metal-utils.h | 86 + .../Cmlx/include-framework/mlx-primitives.h | 2474 ++ Source/Cmlx/include-framework/mlx-scheduler.h | 186 + tools/update-mlx.sh | 20 +- xcode/MLX.xcodeproj/project.pbxproj | 16 +- 11 files changed, 26168 insertions(+), 6 deletions(-) create mode 100644 Source/Cmlx/include-framework/Metal.hpp create mode 100644 Source/Cmlx/include-framework/mlx-backend-common-utils.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-cpu-encoder.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-gpu-eval.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-metal-device.h create mode 100644 Source/Cmlx/include-framework/mlx-backend-metal-utils.h create mode 100644 Source/Cmlx/include-framework/mlx-primitives.h create mode 100644 Source/Cmlx/include-framework/mlx-scheduler.h diff --git a/Source/Cmlx/include-framework/Cmlx.h b/Source/Cmlx/include-framework/Cmlx.h index 0bea1aae..76e44a32 100644 --- a/Source/Cmlx/include-framework/Cmlx.h +++ b/Source/Cmlx/include-framework/Cmlx.h @@ -34,3 +34,11 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Source/Cmlx/include-framework/Metal.hpp b/Source/Cmlx/include-framework/Metal.hpp new file mode 100644 index 00000000..80036358 --- /dev/null +++ b/Source/Cmlx/include-framework/Metal.hpp @@ -0,0 +1,22818 @@ +#ifdef __cplusplus +// +// Metal.hpp.in +// +// Autogenerated from commit f61870c9761883ae8760301b4149b285c5708afc. +// +// Copyright 2020-2024 Apple Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#pragma once + +#define _NS_WEAK_IMPORT __attribute__((weak_import)) +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_EXPORT __attribute__((visibility("hidden"))) +#else +#define _NS_EXPORT __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_EXTERN extern "C" _NS_EXPORT +#define _NS_INLINE inline __attribute__((always_inline)) +#define _NS_PACKED __attribute__((packed)) + +#define _NS_CONST(type, name) _NS_EXTERN type const name +#define _NS_ENUM(type, name) enum name : type +#define _NS_OPTIONS(type, name) \ + using name = type; \ + enum : name + +#define _NS_CAST_TO_UINT(value) static_cast(value) +#define _NS_VALIDATE_SIZE(ns, name) static_assert(sizeof(ns::name) == sizeof(ns##name), "size mismatch " #ns "::" #name) +#define _NS_VALIDATE_ENUM(ns, name) static_assert(_NS_CAST_TO_UINT(ns::name) == _NS_CAST_TO_UINT(ns##name), "value mismatch " #ns "::" #name) + +#include + +#define _NS_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _NS_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +#if defined(NS_PRIVATE_IMPLEMENTATION) + +#include + +namespace NS::Private +{ + template + inline _Type const LoadSymbol(const char* pSymbol) + { + const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); + + return pAddress ? *pAddress : _Type(); + } +} // NS::Private + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _NS_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _NS_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _NS_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _NS_PRIVATE_VISIBILITY = _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _NS_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _NS_PRIVATE_VISIBILITY = _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _NS_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _NS_PRIVATE_VISIBILITY = sel_registerName(symbol) + +#if defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) +#define _NS_PRIVATE_DEF_CONST(type, symbol) \ + _NS_EXTERN type const NS##symbol _NS_PRIVATE_IMPORT; \ + type const NS::symbol = (nullptr != &NS##symbol) ? NS##symbol : type() +#else +#define _NS_PRIVATE_DEF_CONST(type, symbol) \ + _NS_EXTERN type const MTL##symbol _NS_PRIVATE_IMPORT; \ + type const NS::symbol = Private::LoadSymbol("NS" #symbol) +#endif + +#else + +#define _NS_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _NS_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _NS_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _NS_PRIVATE_DEF_CONST(type, symbol) extern type const NS::symbol + +#endif // NS_PRIVATE_IMPLEMENTATION + +namespace NS +{ +namespace Private +{ + namespace Class + { + + _NS_PRIVATE_DEF_CLS(NSArray); + _NS_PRIVATE_DEF_CLS(NSAutoreleasePool); + _NS_PRIVATE_DEF_CLS(NSBundle); + _NS_PRIVATE_DEF_CLS(NSCondition); + _NS_PRIVATE_DEF_CLS(NSDate); + _NS_PRIVATE_DEF_CLS(NSDictionary); + _NS_PRIVATE_DEF_CLS(NSError); + _NS_PRIVATE_DEF_CLS(NSNotificationCenter); + _NS_PRIVATE_DEF_CLS(NSNumber); + _NS_PRIVATE_DEF_CLS(NSObject); + _NS_PRIVATE_DEF_CLS(NSProcessInfo); + _NS_PRIVATE_DEF_CLS(NSSet); + _NS_PRIVATE_DEF_CLS(NSString); + _NS_PRIVATE_DEF_CLS(NSURL); + _NS_PRIVATE_DEF_CLS(NSValue); + + } // Class +} // Private +} // MTL + +namespace NS +{ +namespace Private +{ + namespace Protocol + { + + } // Protocol +} // Private +} // NS + +namespace NS +{ +namespace Private +{ + namespace Selector + { + + _NS_PRIVATE_DEF_SEL(addObject_, + "addObject:"); + _NS_PRIVATE_DEF_SEL(addObserverName_object_queue_block_, + "addObserverForName:object:queue:usingBlock:"); + _NS_PRIVATE_DEF_SEL(activeProcessorCount, + "activeProcessorCount"); + _NS_PRIVATE_DEF_SEL(allBundles, + "allBundles"); + _NS_PRIVATE_DEF_SEL(allFrameworks, + "allFrameworks"); + _NS_PRIVATE_DEF_SEL(allObjects, + "allObjects"); + _NS_PRIVATE_DEF_SEL(alloc, + "alloc"); + _NS_PRIVATE_DEF_SEL(appStoreReceiptURL, + "appStoreReceiptURL"); + _NS_PRIVATE_DEF_SEL(arguments, + "arguments"); + _NS_PRIVATE_DEF_SEL(array, + "array"); + _NS_PRIVATE_DEF_SEL(arrayWithObject_, + "arrayWithObject:"); + _NS_PRIVATE_DEF_SEL(arrayWithObjects_count_, + "arrayWithObjects:count:"); + _NS_PRIVATE_DEF_SEL(automaticTerminationSupportEnabled, + "automaticTerminationSupportEnabled"); + _NS_PRIVATE_DEF_SEL(autorelease, + "autorelease"); + _NS_PRIVATE_DEF_SEL(beginActivityWithOptions_reason_, + "beginActivityWithOptions:reason:"); + _NS_PRIVATE_DEF_SEL(boolValue, + "boolValue"); + _NS_PRIVATE_DEF_SEL(broadcast, + "broadcast"); + _NS_PRIVATE_DEF_SEL(builtInPlugInsPath, + "builtInPlugInsPath"); + _NS_PRIVATE_DEF_SEL(builtInPlugInsURL, + "builtInPlugInsURL"); + _NS_PRIVATE_DEF_SEL(bundleIdentifier, + "bundleIdentifier"); + _NS_PRIVATE_DEF_SEL(bundlePath, + "bundlePath"); + _NS_PRIVATE_DEF_SEL(bundleURL, + "bundleURL"); + _NS_PRIVATE_DEF_SEL(bundleWithPath_, + "bundleWithPath:"); + _NS_PRIVATE_DEF_SEL(bundleWithURL_, + "bundleWithURL:"); + _NS_PRIVATE_DEF_SEL(caseInsensitiveCompare_, + "caseInsensitiveCompare:"); + _NS_PRIVATE_DEF_SEL(characterAtIndex_, + "characterAtIndex:"); + _NS_PRIVATE_DEF_SEL(charValue, + "charValue"); + _NS_PRIVATE_DEF_SEL(countByEnumeratingWithState_objects_count_, + "countByEnumeratingWithState:objects:count:"); + _NS_PRIVATE_DEF_SEL(cStringUsingEncoding_, + "cStringUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(code, + "code"); + _NS_PRIVATE_DEF_SEL(compare_, + "compare:"); + _NS_PRIVATE_DEF_SEL(copy, + "copy"); + _NS_PRIVATE_DEF_SEL(count, + "count"); + _NS_PRIVATE_DEF_SEL(dateWithTimeIntervalSinceNow_, + "dateWithTimeIntervalSinceNow:"); + _NS_PRIVATE_DEF_SEL(defaultCenter, + "defaultCenter"); + _NS_PRIVATE_DEF_SEL(descriptionWithLocale_, + "descriptionWithLocale:"); + _NS_PRIVATE_DEF_SEL(disableAutomaticTermination_, + "disableAutomaticTermination:"); + _NS_PRIVATE_DEF_SEL(disableSuddenTermination, + "disableSuddenTermination"); + _NS_PRIVATE_DEF_SEL(debugDescription, + "debugDescription"); + _NS_PRIVATE_DEF_SEL(description, + "description"); + _NS_PRIVATE_DEF_SEL(dictionary, + "dictionary"); + _NS_PRIVATE_DEF_SEL(dictionaryWithObject_forKey_, + "dictionaryWithObject:forKey:"); + _NS_PRIVATE_DEF_SEL(dictionaryWithObjects_forKeys_count_, + "dictionaryWithObjects:forKeys:count:"); + _NS_PRIVATE_DEF_SEL(domain, + "domain"); + _NS_PRIVATE_DEF_SEL(doubleValue, + "doubleValue"); + _NS_PRIVATE_DEF_SEL(drain, + "drain"); + _NS_PRIVATE_DEF_SEL(enableAutomaticTermination_, + "enableAutomaticTermination:"); + _NS_PRIVATE_DEF_SEL(enableSuddenTermination, + "enableSuddenTermination"); + _NS_PRIVATE_DEF_SEL(endActivity_, + "endActivity:"); + _NS_PRIVATE_DEF_SEL(environment, + "environment"); + _NS_PRIVATE_DEF_SEL(errorWithDomain_code_userInfo_, + "errorWithDomain:code:userInfo:"); + _NS_PRIVATE_DEF_SEL(executablePath, + "executablePath"); + _NS_PRIVATE_DEF_SEL(executableURL, + "executableURL"); + _NS_PRIVATE_DEF_SEL(fileSystemRepresentation, + "fileSystemRepresentation"); + _NS_PRIVATE_DEF_SEL(fileURLWithPath_, + "fileURLWithPath:"); + _NS_PRIVATE_DEF_SEL(floatValue, + "floatValue"); + _NS_PRIVATE_DEF_SEL(fullUserName, + "fullUserName"); + _NS_PRIVATE_DEF_SEL(getValue_size_, + "getValue:size:"); + _NS_PRIVATE_DEF_SEL(globallyUniqueString, + "globallyUniqueString"); + _NS_PRIVATE_DEF_SEL(hash, + "hash"); + _NS_PRIVATE_DEF_SEL(hasPerformanceProfile_, + "hasPerformanceProfile:"); + _NS_PRIVATE_DEF_SEL(hostName, + "hostName"); + _NS_PRIVATE_DEF_SEL(infoDictionary, + "infoDictionary"); + _NS_PRIVATE_DEF_SEL(init, + "init"); + _NS_PRIVATE_DEF_SEL(initFileURLWithPath_, + "initFileURLWithPath:"); + _NS_PRIVATE_DEF_SEL(initWithBool_, + "initWithBool:"); + _NS_PRIVATE_DEF_SEL(initWithBytes_objCType_, + "initWithBytes:objCType:"); + _NS_PRIVATE_DEF_SEL(initWithBytesNoCopy_length_encoding_freeWhenDone_, + "initWithBytesNoCopy:length:encoding:freeWhenDone:"); + _NS_PRIVATE_DEF_SEL(initWithChar_, + "initWithChar:"); + _NS_PRIVATE_DEF_SEL(initWithCoder_, + "initWithCoder:"); + _NS_PRIVATE_DEF_SEL(initWithCString_encoding_, + "initWithCString:encoding:"); + _NS_PRIVATE_DEF_SEL(initWithDomain_code_userInfo_, + "initWithDomain:code:userInfo:"); + _NS_PRIVATE_DEF_SEL(initWithDouble_, + "initWithDouble:"); + _NS_PRIVATE_DEF_SEL(initWithFloat_, + "initWithFloat:"); + _NS_PRIVATE_DEF_SEL(initWithInt_, + "initWithInt:"); + _NS_PRIVATE_DEF_SEL(initWithLong_, + "initWithLong:"); + _NS_PRIVATE_DEF_SEL(initWithLongLong_, + "initWithLongLong:"); + _NS_PRIVATE_DEF_SEL(initWithObjects_count_, + "initWithObjects:count:"); + _NS_PRIVATE_DEF_SEL(initWithObjects_forKeys_count_, + "initWithObjects:forKeys:count:"); + _NS_PRIVATE_DEF_SEL(initWithPath_, + "initWithPath:"); + _NS_PRIVATE_DEF_SEL(initWithShort_, + "initWithShort:"); + _NS_PRIVATE_DEF_SEL(initWithString_, + "initWithString:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedChar_, + "initWithUnsignedChar:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedInt_, + "initWithUnsignedInt:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedLong_, + "initWithUnsignedLong:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedLongLong_, + "initWithUnsignedLongLong:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedShort_, + "initWithUnsignedShort:"); + _NS_PRIVATE_DEF_SEL(initWithURL_, + "initWithURL:"); + _NS_PRIVATE_DEF_SEL(integerValue, + "integerValue"); + _NS_PRIVATE_DEF_SEL(intValue, + "intValue"); + _NS_PRIVATE_DEF_SEL(isDeviceCertified_, + "isDeviceCertifiedFor:"); + _NS_PRIVATE_DEF_SEL(isEqual_, + "isEqual:"); + _NS_PRIVATE_DEF_SEL(isEqualToNumber_, + "isEqualToNumber:"); + _NS_PRIVATE_DEF_SEL(isEqualToString_, + "isEqualToString:"); + _NS_PRIVATE_DEF_SEL(isEqualToValue_, + "isEqualToValue:"); + _NS_PRIVATE_DEF_SEL(isiOSAppOnMac, + "isiOSAppOnMac"); + _NS_PRIVATE_DEF_SEL(isLoaded, + "isLoaded"); + _NS_PRIVATE_DEF_SEL(isLowPowerModeEnabled, + "isLowPowerModeEnabled"); + _NS_PRIVATE_DEF_SEL(isMacCatalystApp, + "isMacCatalystApp"); + _NS_PRIVATE_DEF_SEL(isOperatingSystemAtLeastVersion_, + "isOperatingSystemAtLeastVersion:"); + _NS_PRIVATE_DEF_SEL(keyEnumerator, + "keyEnumerator"); + _NS_PRIVATE_DEF_SEL(length, + "length"); + _NS_PRIVATE_DEF_SEL(lengthOfBytesUsingEncoding_, + "lengthOfBytesUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(load, + "load"); + _NS_PRIVATE_DEF_SEL(loadAndReturnError_, + "loadAndReturnError:"); + _NS_PRIVATE_DEF_SEL(localizedDescription, + "localizedDescription"); + _NS_PRIVATE_DEF_SEL(localizedFailureReason, + "localizedFailureReason"); + _NS_PRIVATE_DEF_SEL(localizedInfoDictionary, + "localizedInfoDictionary"); + _NS_PRIVATE_DEF_SEL(localizedRecoveryOptions, + "localizedRecoveryOptions"); + _NS_PRIVATE_DEF_SEL(localizedRecoverySuggestion, + "localizedRecoverySuggestion"); + _NS_PRIVATE_DEF_SEL(localizedStringForKey_value_table_, + "localizedStringForKey:value:table:"); + _NS_PRIVATE_DEF_SEL(lock, + "lock"); + _NS_PRIVATE_DEF_SEL(longValue, + "longValue"); + _NS_PRIVATE_DEF_SEL(longLongValue, + "longLongValue"); + _NS_PRIVATE_DEF_SEL(mainBundle, + "mainBundle"); + _NS_PRIVATE_DEF_SEL(maximumLengthOfBytesUsingEncoding_, + "maximumLengthOfBytesUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(methodSignatureForSelector_, + "methodSignatureForSelector:"); + _NS_PRIVATE_DEF_SEL(mutableBytes, + "mutableBytes"); + _NS_PRIVATE_DEF_SEL(name, + "name"); + _NS_PRIVATE_DEF_SEL(nextObject, + "nextObject"); + _NS_PRIVATE_DEF_SEL(numberWithBool_, + "numberWithBool:"); + _NS_PRIVATE_DEF_SEL(numberWithChar_, + "numberWithChar:"); + _NS_PRIVATE_DEF_SEL(numberWithDouble_, + "numberWithDouble:"); + _NS_PRIVATE_DEF_SEL(numberWithFloat_, + "numberWithFloat:"); + _NS_PRIVATE_DEF_SEL(numberWithInt_, + "numberWithInt:"); + _NS_PRIVATE_DEF_SEL(numberWithLong_, + "numberWithLong:"); + _NS_PRIVATE_DEF_SEL(numberWithLongLong_, + "numberWithLongLong:"); + _NS_PRIVATE_DEF_SEL(numberWithShort_, + "numberWithShort:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedChar_, + "numberWithUnsignedChar:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedInt_, + "numberWithUnsignedInt:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedLong_, + "numberWithUnsignedLong:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedLongLong_, + "numberWithUnsignedLongLong:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedShort_, + "numberWithUnsignedShort:"); + _NS_PRIVATE_DEF_SEL(objCType, + "objCType"); + _NS_PRIVATE_DEF_SEL(object, + "object"); + _NS_PRIVATE_DEF_SEL(objectAtIndex_, + "objectAtIndex:"); + _NS_PRIVATE_DEF_SEL(objectEnumerator, + "objectEnumerator"); + _NS_PRIVATE_DEF_SEL(objectForInfoDictionaryKey_, + "objectForInfoDictionaryKey:"); + _NS_PRIVATE_DEF_SEL(objectForKey_, + "objectForKey:"); + _NS_PRIVATE_DEF_SEL(operatingSystem, + "operatingSystem"); + _NS_PRIVATE_DEF_SEL(operatingSystemVersion, + "operatingSystemVersion"); + _NS_PRIVATE_DEF_SEL(operatingSystemVersionString, + "operatingSystemVersionString"); + _NS_PRIVATE_DEF_SEL(pathForAuxiliaryExecutable_, + "pathForAuxiliaryExecutable:"); + _NS_PRIVATE_DEF_SEL(performActivityWithOptions_reason_usingBlock_, + "performActivityWithOptions:reason:usingBlock:"); + _NS_PRIVATE_DEF_SEL(performExpiringActivityWithReason_usingBlock_, + "performExpiringActivityWithReason:usingBlock:"); + _NS_PRIVATE_DEF_SEL(physicalMemory, + "physicalMemory"); + _NS_PRIVATE_DEF_SEL(pointerValue, + "pointerValue"); + _NS_PRIVATE_DEF_SEL(preflightAndReturnError_, + "preflightAndReturnError:"); + _NS_PRIVATE_DEF_SEL(privateFrameworksPath, + "privateFrameworksPath"); + _NS_PRIVATE_DEF_SEL(privateFrameworksURL, + "privateFrameworksURL"); + _NS_PRIVATE_DEF_SEL(processIdentifier, + "processIdentifier"); + _NS_PRIVATE_DEF_SEL(processInfo, + "processInfo"); + _NS_PRIVATE_DEF_SEL(processName, + "processName"); + _NS_PRIVATE_DEF_SEL(processorCount, + "processorCount"); + _NS_PRIVATE_DEF_SEL(rangeOfString_options_, + "rangeOfString:options:"); + _NS_PRIVATE_DEF_SEL(release, + "release"); + _NS_PRIVATE_DEF_SEL(removeObserver_, + "removeObserver:"); + _NS_PRIVATE_DEF_SEL(resourcePath, + "resourcePath"); + _NS_PRIVATE_DEF_SEL(resourceURL, + "resourceURL"); + _NS_PRIVATE_DEF_SEL(respondsToSelector_, + "respondsToSelector:"); + _NS_PRIVATE_DEF_SEL(retain, + "retain"); + _NS_PRIVATE_DEF_SEL(retainCount, + "retainCount"); + _NS_PRIVATE_DEF_SEL(setAutomaticTerminationSupportEnabled_, + "setAutomaticTerminationSupportEnabled:"); + _NS_PRIVATE_DEF_SEL(setProcessName_, + "setProcessName:"); + _NS_PRIVATE_DEF_SEL(sharedFrameworksPath, + "sharedFrameworksPath"); + _NS_PRIVATE_DEF_SEL(sharedFrameworksURL, + "sharedFrameworksURL"); + _NS_PRIVATE_DEF_SEL(sharedSupportPath, + "sharedSupportPath"); + _NS_PRIVATE_DEF_SEL(sharedSupportURL, + "sharedSupportURL"); + _NS_PRIVATE_DEF_SEL(shortValue, + "shortValue"); + _NS_PRIVATE_DEF_SEL(showPools, + "showPools"); + _NS_PRIVATE_DEF_SEL(signal, + "signal"); + _NS_PRIVATE_DEF_SEL(string, + "string"); + _NS_PRIVATE_DEF_SEL(stringValue, + "stringValue"); + _NS_PRIVATE_DEF_SEL(stringWithString_, + "stringWithString:"); + _NS_PRIVATE_DEF_SEL(stringWithCString_encoding_, + "stringWithCString:encoding:"); + _NS_PRIVATE_DEF_SEL(stringByAppendingString_, + "stringByAppendingString:"); + _NS_PRIVATE_DEF_SEL(systemUptime, + "systemUptime"); + _NS_PRIVATE_DEF_SEL(thermalState, + "thermalState"); + _NS_PRIVATE_DEF_SEL(unload, + "unload"); + _NS_PRIVATE_DEF_SEL(unlock, + "unlock"); + _NS_PRIVATE_DEF_SEL(unsignedCharValue, + "unsignedCharValue"); + _NS_PRIVATE_DEF_SEL(unsignedIntegerValue, + "unsignedIntegerValue"); + _NS_PRIVATE_DEF_SEL(unsignedIntValue, + "unsignedIntValue"); + _NS_PRIVATE_DEF_SEL(unsignedLongValue, + "unsignedLongValue"); + _NS_PRIVATE_DEF_SEL(unsignedLongLongValue, + "unsignedLongLongValue"); + _NS_PRIVATE_DEF_SEL(unsignedShortValue, + "unsignedShortValue"); + _NS_PRIVATE_DEF_SEL(URLForAuxiliaryExecutable_, + "URLForAuxiliaryExecutable:"); + _NS_PRIVATE_DEF_SEL(userInfo, + "userInfo"); + _NS_PRIVATE_DEF_SEL(userName, + "userName"); + _NS_PRIVATE_DEF_SEL(UTF8String, + "UTF8String"); + _NS_PRIVATE_DEF_SEL(valueWithBytes_objCType_, + "valueWithBytes:objCType:"); + _NS_PRIVATE_DEF_SEL(valueWithPointer_, + "valueWithPointer:"); + _NS_PRIVATE_DEF_SEL(wait, + "wait"); + _NS_PRIVATE_DEF_SEL(waitUntilDate_, + "waitUntilDate:"); + } // Class +} // Private +} // MTL + +#include +#include + +namespace NS +{ +using TimeInterval = double; + +using Integer = std::intptr_t; +using UInteger = std::uintptr_t; + +const Integer IntegerMax = INTPTR_MAX; +const Integer IntegerMin = INTPTR_MIN; +const UInteger UIntegerMax = UINTPTR_MAX; + +struct OperatingSystemVersion +{ + Integer majorVersion; + Integer minorVersion; + Integer patchVersion; +} _NS_PACKED; +} + +#include +#include + +#include + +namespace NS +{ +template +class _NS_EXPORT Referencing : public _Base +{ +public: + _Class* retain(); + void release(); + + _Class* autorelease(); + + UInteger retainCount() const; +}; + +template +class Copying : public Referencing<_Class, _Base> +{ +public: + _Class* copy() const; +}; + +template +class SecureCoding : public Referencing<_Class, _Base> +{ +}; + +class Object : public Referencing +{ +public: + UInteger hash() const; + bool isEqual(const Object* pObject) const; + + class String* description() const; + class String* debugDescription() const; + +protected: + friend class Referencing; + + template + static _Class* alloc(const char* pClassName); + template + static _Class* alloc(const void* pClass); + template + _Class* init(); + + template + static _Dst bridgingCast(const void* pObj); + static class MethodSignature* methodSignatureForSelector(const void* pObj, SEL selector); + static bool respondsToSelector(const void* pObj, SEL selector); + template + static constexpr bool doesRequireMsgSendStret(); + template + static _Ret sendMessage(const void* pObj, SEL selector, _Args... args); + template + static _Ret sendMessageSafe(const void* pObj, SEL selector, _Args... args); + +private: + Object() = delete; + Object(const Object&) = delete; + ~Object() = delete; + + Object& operator=(const Object&) = delete; +}; +} + +template +_NS_INLINE _Class* NS::Referencing<_Class, _Base>::retain() +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(retain)); +} + +template +_NS_INLINE void NS::Referencing<_Class, _Base>::release() +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(release)); +} + +template +_NS_INLINE _Class* NS::Referencing<_Class, _Base>::autorelease() +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(autorelease)); +} + +template +_NS_INLINE NS::UInteger NS::Referencing<_Class, _Base>::retainCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(retainCount)); +} + +template +_NS_INLINE _Class* NS::Copying<_Class, _Base>::copy() const +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(copy)); +} + +template +_NS_INLINE _Dst NS::Object::bridgingCast(const void* pObj) +{ +#ifdef __OBJC__ + return (__bridge _Dst)pObj; +#else + return (_Dst)pObj; +#endif // __OBJC__ +} + +template +_NS_INLINE constexpr bool NS::Object::doesRequireMsgSendStret() +{ +#if (defined(__i386__) || defined(__x86_64__)) + constexpr size_t kStructLimit = (sizeof(std::uintptr_t) << 1); + + return sizeof(_Type) > kStructLimit; +#elif defined(__arm64__) + return false; +#elif defined(__arm__) + constexpr size_t kStructLimit = sizeof(std::uintptr_t); + + return std::is_class(_Type) && (sizeof(_Type) > kStructLimit); +#else +#error "Unsupported architecture!" +#endif +} + +template <> +_NS_INLINE constexpr bool NS::Object::doesRequireMsgSendStret() +{ + return false; +} + +template +_NS_INLINE _Ret NS::Object::sendMessage(const void* pObj, SEL selector, _Args... args) +{ +#if (defined(__i386__) || defined(__x86_64__)) + if constexpr (std::is_floating_point<_Ret>()) + { + using SendMessageProcFpret = _Ret (*)(const void*, SEL, _Args...); + + const SendMessageProcFpret pProc = reinterpret_cast(&objc_msgSend_fpret); + + return (*pProc)(pObj, selector, args...); + } + else +#endif // ( defined( __i386__ ) || defined( __x86_64__ ) ) +#if !defined(__arm64__) + if constexpr (doesRequireMsgSendStret<_Ret>()) + { + using SendMessageProcStret = void (*)(_Ret*, const void*, SEL, _Args...); + + const SendMessageProcStret pProc = reinterpret_cast(&objc_msgSend_stret); + _Ret ret; + + (*pProc)(&ret, pObj, selector, args...); + + return ret; + } + else +#endif // !defined( __arm64__ ) + { + using SendMessageProc = _Ret (*)(const void*, SEL, _Args...); + + const SendMessageProc pProc = reinterpret_cast(&objc_msgSend); + + return (*pProc)(pObj, selector, args...); + } +} + +_NS_INLINE NS::MethodSignature* NS::Object::methodSignatureForSelector(const void* pObj, SEL selector) +{ + return sendMessage(pObj, _NS_PRIVATE_SEL(methodSignatureForSelector_), selector); +} + +_NS_INLINE bool NS::Object::respondsToSelector(const void* pObj, SEL selector) +{ + return sendMessage(pObj, _NS_PRIVATE_SEL(respondsToSelector_), selector); +} + +template +_NS_INLINE _Ret NS::Object::sendMessageSafe(const void* pObj, SEL selector, _Args... args) +{ + if ((respondsToSelector(pObj, selector)) || (nullptr != methodSignatureForSelector(pObj, selector))) + { + return sendMessage<_Ret>(pObj, selector, args...); + } + + if constexpr (!std::is_void<_Ret>::value) + { + return _Ret(0); + } +} + +template +_NS_INLINE _Class* NS::Object::alloc(const char* pClassName) +{ + return sendMessage<_Class*>(objc_lookUpClass(pClassName), _NS_PRIVATE_SEL(alloc)); +} + +template +_NS_INLINE _Class* NS::Object::alloc(const void* pClass) +{ + return sendMessage<_Class*>(pClass, _NS_PRIVATE_SEL(alloc)); +} + +template +_NS_INLINE _Class* NS::Object::init() +{ + return sendMessage<_Class*>(this, _NS_PRIVATE_SEL(init)); +} + +_NS_INLINE NS::UInteger NS::Object::hash() const +{ + return sendMessage(this, _NS_PRIVATE_SEL(hash)); +} + +_NS_INLINE bool NS::Object::isEqual(const Object* pObject) const +{ + return sendMessage(this, _NS_PRIVATE_SEL(isEqual_), pObject); +} + +_NS_INLINE NS::String* NS::Object::description() const +{ + return sendMessage(this, _NS_PRIVATE_SEL(description)); +} + +_NS_INLINE NS::String* NS::Object::debugDescription() const +{ + return sendMessageSafe(this, _NS_PRIVATE_SEL(debugDescription)); +} + +namespace NS +{ +class Array : public Copying +{ +public: + static Array* array(); + static Array* array(const Object* pObject); + static Array* array(const Object* const* pObjects, UInteger count); + + static Array* alloc(); + + Array* init(); + Array* init(const Object* const* pObjects, UInteger count); + Array* init(const class Coder* pCoder); + + template + _Object* object(UInteger index) const; + UInteger count() const; +}; +} + +_NS_INLINE NS::Array* NS::Array::array() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(array)); +} + +_NS_INLINE NS::Array* NS::Array::array(const Object* pObject) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObject_), pObject); +} + +_NS_INLINE NS::Array* NS::Array::array(const Object* const* pObjects, UInteger count) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObjects_count_), pObjects, count); +} + +_NS_INLINE NS::Array* NS::Array::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSArray)); +} + +_NS_INLINE NS::Array* NS::Array::init() +{ + return NS::Object::init(); +} + +_NS_INLINE NS::Array* NS::Array::init(const Object* const* pObjects, UInteger count) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_count_), pObjects, count); +} + +_NS_INLINE NS::Array* NS::Array::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +_NS_INLINE NS::UInteger NS::Array::count() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +template +_NS_INLINE _Object* NS::Array::object(UInteger index) const +{ + return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectAtIndex_), index); +} + +namespace NS +{ +class AutoreleasePool : public Object +{ +public: + static AutoreleasePool* alloc(); + AutoreleasePool* init(); + + void drain(); + + void addObject(Object* pObject); + + static void showPools(); +}; +} + +_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSAutoreleasePool)); +} + +_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::init() +{ + return NS::Object::init(); +} + +_NS_INLINE void NS::AutoreleasePool::drain() +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(drain)); +} + +_NS_INLINE void NS::AutoreleasePool::addObject(Object* pObject) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(addObject_), pObject); +} + +_NS_INLINE void NS::AutoreleasePool::showPools() +{ + Object::sendMessage(_NS_PRIVATE_CLS(NSAutoreleasePool), _NS_PRIVATE_SEL(showPools)); +} + +namespace NS +{ +struct FastEnumerationState +{ + unsigned long state; + Object** itemsPtr; + unsigned long* mutationsPtr; + unsigned long extra[5]; +} _NS_PACKED; + +class FastEnumeration : public Referencing +{ +public: + NS::UInteger countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len); +}; + +template +class Enumerator : public Referencing, FastEnumeration> +{ +public: + _ObjectType* nextObject(); + class Array* allObjects(); +}; +} + +_NS_INLINE NS::UInteger NS::FastEnumeration::countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(countByEnumeratingWithState_objects_count_), pState, pBuffer, len); +} + +template +_NS_INLINE _ObjectType* NS::Enumerator<_ObjectType>::nextObject() +{ + return Object::sendMessage<_ObjectType*>(this, _NS_PRIVATE_SEL(nextObject)); +} + +template +_NS_INLINE NS::Array* NS::Enumerator<_ObjectType>::allObjects() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(allObjects)); +} + +namespace NS +{ +class Dictionary : public NS::Copying +{ +public: + static Dictionary* dictionary(); + static Dictionary* dictionary(const Object* pObject, const Object* pKey); + static Dictionary* dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count); + + static Dictionary* alloc(); + + Dictionary* init(); + Dictionary* init(const Object* const* pObjects, const Object* const* pKeys, UInteger count); + Dictionary* init(const class Coder* pCoder); + + template + Enumerator<_KeyType>* keyEnumerator() const; + + template + _Object* object(const Object* pKey) const; + UInteger count() const; +}; +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionary)); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* pObject, const Object* pKey) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObject_forKey_), pObject, pKey); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObjects_forKeys_count_), + pObjects, pKeys, count); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSDictionary)); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::init() +{ + return NS::Object::init(); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::init(const Object* const* pObjects, const Object* const* pKeys, UInteger count) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_forKeys_count_), pObjects, pKeys, count); +} + +_NS_INLINE NS::Dictionary* NS::Dictionary::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +template +_NS_INLINE NS::Enumerator<_KeyType>* NS::Dictionary::keyEnumerator() const +{ + return Object::sendMessage*>(this, _NS_PRIVATE_SEL(keyEnumerator)); +} + +template +_NS_INLINE _Object* NS::Dictionary::object(const Object* pKey) const +{ + return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectForKey_), pKey); +} + +_NS_INLINE NS::UInteger NS::Dictionary::count() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +namespace NS +{ + +_NS_ENUM(Integer, ComparisonResult) { + OrderedAscending = -1L, + OrderedSame, + OrderedDescending +}; + +const Integer NotFound = IntegerMax; + +} + +namespace NS +{ +struct Range +{ + static Range Make(UInteger loc, UInteger len); + + Range(UInteger loc, UInteger len); + + bool Equal(const Range& range) const; + bool LocationInRange(UInteger loc) const; + UInteger Max() const; + + UInteger location; + UInteger length; +} _NS_PACKED; +} + +_NS_INLINE NS::Range::Range(UInteger loc, UInteger len) + : location(loc) + , length(len) +{ +} + +_NS_INLINE NS::Range NS::Range::Make(UInteger loc, UInteger len) +{ + return Range(loc, len); +} + +_NS_INLINE bool NS::Range::Equal(const Range& range) const +{ + return (location == range.location) && (length == range.length); +} + +_NS_INLINE bool NS::Range::LocationInRange(UInteger loc) const +{ + return (!(loc < location)) && ((loc - location) < length); +} + +_NS_INLINE NS::UInteger NS::Range::Max() const +{ + return location + length; +} + +namespace NS +{ +_NS_ENUM(NS::UInteger, StringEncoding) { + ASCIIStringEncoding = 1, + NEXTSTEPStringEncoding = 2, + JapaneseEUCStringEncoding = 3, + UTF8StringEncoding = 4, + ISOLatin1StringEncoding = 5, + SymbolStringEncoding = 6, + NonLossyASCIIStringEncoding = 7, + ShiftJISStringEncoding = 8, + ISOLatin2StringEncoding = 9, + UnicodeStringEncoding = 10, + WindowsCP1251StringEncoding = 11, + WindowsCP1252StringEncoding = 12, + WindowsCP1253StringEncoding = 13, + WindowsCP1254StringEncoding = 14, + WindowsCP1250StringEncoding = 15, + ISO2022JPStringEncoding = 21, + MacOSRomanStringEncoding = 30, + + UTF16StringEncoding = UnicodeStringEncoding, + + UTF16BigEndianStringEncoding = 0x90000100, + UTF16LittleEndianStringEncoding = 0x94000100, + + UTF32StringEncoding = 0x8c000100, + UTF32BigEndianStringEncoding = 0x98000100, + UTF32LittleEndianStringEncoding = 0x9c000100 +}; + +_NS_OPTIONS(NS::UInteger, StringCompareOptions) { + CaseInsensitiveSearch = 1, + LiteralSearch = 2, + BackwardsSearch = 4, + AnchoredSearch = 8, + NumericSearch = 64, + DiacriticInsensitiveSearch = 128, + WidthInsensitiveSearch = 256, + ForcedOrderingSearch = 512, + RegularExpressionSearch = 1024 +}; + +using unichar = unsigned short; + +class String : public Copying +{ +public: + static String* string(); + static String* string(const String* pString); + static String* string(const char* pString, StringEncoding encoding); + + static String* alloc(); + String* init(); + String* init(const String* pString); + String* init(const char* pString, StringEncoding encoding); + String* init(void* pBytes, UInteger len, StringEncoding encoding, bool freeBuffer); + + unichar character(UInteger index) const; + UInteger length() const; + + const char* cString(StringEncoding encoding) const; + const char* utf8String() const; + UInteger maximumLengthOfBytes(StringEncoding encoding) const; + UInteger lengthOfBytes(StringEncoding encoding) const; + + bool isEqualToString(const String* pString) const; + Range rangeOfString(const String* pString, StringCompareOptions options) const; + + const char* fileSystemRepresentation() const; + + String* stringByAppendingString(const String* pString) const; + ComparisonResult caseInsensitiveCompare(const String* pString) const; +}; + +#define MTLSTR(literal) (NS::String*)__builtin___CFStringMakeConstantString("" literal "") + +template +[[deprecated("please use MTLSTR(str)")]] constexpr const String* MakeConstantString(const char (&str)[_StringLen]) +{ + return reinterpret_cast(__CFStringMakeConstantString(str)); +} + +} + +_NS_INLINE NS::String* NS::String::string() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(string)); +} + +_NS_INLINE NS::String* NS::String::string(const String* pString) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(stringWithString_), pString); +} + +_NS_INLINE NS::String* NS::String::string(const char* pString, StringEncoding encoding) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(stringWithCString_encoding_), pString, encoding); +} + +_NS_INLINE NS::String* NS::String::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSString)); +} + +_NS_INLINE NS::String* NS::String::init() +{ + return Object::init(); +} + +_NS_INLINE NS::String* NS::String::init(const String* pString) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithString_), pString); +} + +_NS_INLINE NS::String* NS::String::init(const char* pString, StringEncoding encoding) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCString_encoding_), pString, encoding); +} + +_NS_INLINE NS::String* NS::String::init(void* pBytes, UInteger len, StringEncoding encoding, bool freeBuffer) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBytesNoCopy_length_encoding_freeWhenDone_), pBytes, len, encoding, freeBuffer); +} + +_NS_INLINE NS::unichar NS::String::character(UInteger index) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(characterAtIndex_), index); +} + +_NS_INLINE NS::UInteger NS::String::length() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(length)); +} + +_NS_INLINE const char* NS::String::cString(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(cStringUsingEncoding_), encoding); +} + +_NS_INLINE const char* NS::String::utf8String() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(UTF8String)); +} + +_NS_INLINE NS::UInteger NS::String::maximumLengthOfBytes(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(maximumLengthOfBytesUsingEncoding_), encoding); +} + +_NS_INLINE NS::UInteger NS::String::lengthOfBytes(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(lengthOfBytesUsingEncoding_), encoding); +} + +_NS_INLINE bool NS::String::isEqualToString(const NS::String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToString_), pString); +} + +_NS_INLINE NS::Range NS::String::rangeOfString(const NS::String* pString, NS::StringCompareOptions options) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(rangeOfString_options_), pString, options); +} + +_NS_INLINE const char* NS::String::fileSystemRepresentation() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(fileSystemRepresentation)); +} + +_NS_INLINE NS::String* NS::String::stringByAppendingString(const String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(stringByAppendingString_), pString); +} + +_NS_INLINE NS::ComparisonResult NS::String::caseInsensitiveCompare(const String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(caseInsensitiveCompare_), pString); +} + +#include + +namespace NS +{ +using NotificationName = class String*; + +class Notification : public NS::Referencing +{ +public: + NS::String* name() const; + NS::Object* object() const; + NS::Dictionary* userInfo() const; +}; + +using ObserverBlock = void(^)(Notification*); +using ObserverFunction = std::function; + +class NotificationCenter : public NS::Referencing +{ + public: + static class NotificationCenter* defaultCenter(); + Object* addObserver(NotificationName name, Object* pObj, void* pQueue, ObserverBlock block); + Object* addObserver(NotificationName name, Object* pObj, void* pQueue, ObserverFunction &handler); + void removeObserver(Object* pObserver); + +}; +} + +_NS_INLINE NS::String* NS::Notification::name() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(name)); +} + +_NS_INLINE NS::Object* NS::Notification::object() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(object)); +} + +_NS_INLINE NS::Dictionary* NS::Notification::userInfo() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(userInfo)); +} + +_NS_INLINE NS::NotificationCenter* NS::NotificationCenter::defaultCenter() +{ + return NS::Object::sendMessage(_NS_PRIVATE_CLS(NSNotificationCenter), _NS_PRIVATE_SEL(defaultCenter)); +} + +_NS_INLINE NS::Object* NS::NotificationCenter::addObserver(NS::NotificationName name, Object* pObj, void* pQueue, NS::ObserverBlock block) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(addObserverName_object_queue_block_), name, pObj, pQueue, block); +} + +_NS_INLINE NS::Object* NS::NotificationCenter::addObserver(NS::NotificationName name, Object* pObj, void* pQueue, NS::ObserverFunction &handler) +{ + __block ObserverFunction blockFunction = handler; + + return addObserver(name, pObj, pQueue, ^(NS::Notification* pNotif) {blockFunction(pNotif);}); +} + +_NS_INLINE void NS::NotificationCenter::removeObserver(Object* pObserver) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(removeObserver_), pObserver); +} + +namespace NS +{ +_NS_CONST(NotificationName, BundleDidLoadNotification); +_NS_CONST(NotificationName, BundleResourceRequestLowDiskSpaceNotification); + +class String* LocalizedString(const String* pKey, const String*); +class String* LocalizedStringFromTable(const String* pKey, const String* pTbl, const String*); +class String* LocalizedStringFromTableInBundle(const String* pKey, const String* pTbl, const class Bundle* pBdle, const String*); +class String* LocalizedStringWithDefaultValue(const String* pKey, const String* pTbl, const class Bundle* pBdle, const String* pVal, const String*); + +class Bundle : public Referencing +{ +public: + static Bundle* mainBundle(); + + static Bundle* bundle(const class String* pPath); + static Bundle* bundle(const class URL* pURL); + + static Bundle* alloc(); + + Bundle* init(const class String* pPath); + Bundle* init(const class URL* pURL); + + static Array* allBundles(); + static Array* allFrameworks(); + + bool load(); + bool unload(); + + bool isLoaded() const; + + bool preflightAndReturnError(class Error** pError) const; + bool loadAndReturnError(class Error** pError); + + class URL* bundleURL() const; + class URL* resourceURL() const; + class URL* executableURL() const; + class URL* URLForAuxiliaryExecutable(const class String* pExecutableName) const; + + class URL* privateFrameworksURL() const; + class URL* sharedFrameworksURL() const; + class URL* sharedSupportURL() const; + class URL* builtInPlugInsURL() const; + class URL* appStoreReceiptURL() const; + + class String* bundlePath() const; + class String* resourcePath() const; + class String* executablePath() const; + class String* pathForAuxiliaryExecutable(const class String* pExecutableName) const; + + class String* privateFrameworksPath() const; + class String* sharedFrameworksPath() const; + class String* sharedSupportPath() const; + class String* builtInPlugInsPath() const; + + class String* bundleIdentifier() const; + class Dictionary* infoDictionary() const; + class Dictionary* localizedInfoDictionary() const; + class Object* objectForInfoDictionaryKey(const class String* pKey); + + class String* localizedString(const class String* pKey, const class String* pValue = nullptr, const class String* pTableName = nullptr) const; +}; +} + +_NS_PRIVATE_DEF_CONST(NS::NotificationName, BundleDidLoadNotification); +_NS_PRIVATE_DEF_CONST(NS::NotificationName, BundleResourceRequestLowDiskSpaceNotification); + +_NS_INLINE NS::String* NS::LocalizedString(const String* pKey, const String*) +{ + return Bundle::mainBundle()->localizedString(pKey, nullptr, nullptr); +} + +_NS_INLINE NS::String* NS::LocalizedStringFromTable(const String* pKey, const String* pTbl, const String*) +{ + return Bundle::mainBundle()->localizedString(pKey, nullptr, pTbl); +} + +_NS_INLINE NS::String* NS::LocalizedStringFromTableInBundle(const String* pKey, const String* pTbl, const Bundle* pBdl, const String*) +{ + return pBdl->localizedString(pKey, nullptr, pTbl); +} + +_NS_INLINE NS::String* NS::LocalizedStringWithDefaultValue(const String* pKey, const String* pTbl, const Bundle* pBdl, const String* pVal, const String*) +{ + return pBdl->localizedString(pKey, pVal, pTbl); +} + +_NS_INLINE NS::Bundle* NS::Bundle::mainBundle() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(mainBundle)); +} + +_NS_INLINE NS::Bundle* NS::Bundle::bundle(const class String* pPath) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(bundleWithPath_), pPath); +} + +_NS_INLINE NS::Bundle* NS::Bundle::bundle(const class URL* pURL) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(bundleWithURL_), pURL); +} + +_NS_INLINE NS::Bundle* NS::Bundle::alloc() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(alloc)); +} + +_NS_INLINE NS::Bundle* NS::Bundle::init(const String* pPath) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithPath_), pPath); +} + +_NS_INLINE NS::Bundle* NS::Bundle::init(const URL* pURL) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithURL_), pURL); +} + +_NS_INLINE NS::Array* NS::Bundle::allBundles() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(allBundles)); +} + +_NS_INLINE NS::Array* NS::Bundle::allFrameworks() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(allFrameworks)); +} + +_NS_INLINE bool NS::Bundle::load() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(load)); +} + +_NS_INLINE bool NS::Bundle::unload() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unload)); +} + +_NS_INLINE bool NS::Bundle::isLoaded() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isLoaded)); +} + +_NS_INLINE bool NS::Bundle::preflightAndReturnError(Error** pError) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(preflightAndReturnError_), pError); +} + +_NS_INLINE bool NS::Bundle::loadAndReturnError(Error** pError) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(loadAndReturnError_), pError); +} + +_NS_INLINE NS::URL* NS::Bundle::bundleURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundleURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::resourceURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(resourceURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::executableURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(executableURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::URLForAuxiliaryExecutable(const String* pExecutableName) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(URLForAuxiliaryExecutable_), pExecutableName); +} + +_NS_INLINE NS::URL* NS::Bundle::privateFrameworksURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(privateFrameworksURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::sharedFrameworksURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedFrameworksURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::sharedSupportURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedSupportURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::builtInPlugInsURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(builtInPlugInsURL)); +} + +_NS_INLINE NS::URL* NS::Bundle::appStoreReceiptURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(appStoreReceiptURL)); +} + +_NS_INLINE NS::String* NS::Bundle::bundlePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundlePath)); +} + +_NS_INLINE NS::String* NS::Bundle::resourcePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(resourcePath)); +} + +_NS_INLINE NS::String* NS::Bundle::executablePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(executablePath)); +} + +_NS_INLINE NS::String* NS::Bundle::pathForAuxiliaryExecutable(const String* pExecutableName) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(pathForAuxiliaryExecutable_), pExecutableName); +} + +_NS_INLINE NS::String* NS::Bundle::privateFrameworksPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(privateFrameworksPath)); +} + +_NS_INLINE NS::String* NS::Bundle::sharedFrameworksPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedFrameworksPath)); +} + +_NS_INLINE NS::String* NS::Bundle::sharedSupportPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedSupportPath)); +} + +_NS_INLINE NS::String* NS::Bundle::builtInPlugInsPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(builtInPlugInsPath)); +} + +_NS_INLINE NS::String* NS::Bundle::bundleIdentifier() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundleIdentifier)); +} + +_NS_INLINE NS::Dictionary* NS::Bundle::infoDictionary() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(infoDictionary)); +} + +_NS_INLINE NS::Dictionary* NS::Bundle::localizedInfoDictionary() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedInfoDictionary)); +} + +_NS_INLINE NS::Object* NS::Bundle::objectForInfoDictionaryKey(const String* pKey) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(objectForInfoDictionaryKey_), pKey); +} + +_NS_INLINE NS::String* NS::Bundle::localizedString(const String* pKey, const String* pValue /* = nullptr */, const String* pTableName /* = nullptr */) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedStringForKey_value_table_), pKey, pValue, pTableName); +} + +namespace NS +{ +class Data : public Copying +{ +public: + void* mutableBytes() const; + UInteger length() const; +}; +} + +_NS_INLINE void* NS::Data::mutableBytes() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(mutableBytes)); +} + +_NS_INLINE NS::UInteger NS::Data::length() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(length)); +} + +namespace NS +{ + +using TimeInterval = double; + +class Date : public Copying +{ +public: + static Date* dateWithTimeIntervalSinceNow(TimeInterval secs); +}; + +} // NS + +_NS_INLINE NS::Date* NS::Date::dateWithTimeIntervalSinceNow(NS::TimeInterval secs) +{ + return NS::Object::sendMessage(_NS_PRIVATE_CLS(NSDate), _NS_PRIVATE_SEL(dateWithTimeIntervalSinceNow_), secs); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +using ErrorDomain = class String*; + +_NS_CONST(ErrorDomain, CocoaErrorDomain); +_NS_CONST(ErrorDomain, POSIXErrorDomain); +_NS_CONST(ErrorDomain, OSStatusErrorDomain); +_NS_CONST(ErrorDomain, MachErrorDomain); + +using ErrorUserInfoKey = class String*; + +_NS_CONST(ErrorUserInfoKey, UnderlyingErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedDescriptionKey); +_NS_CONST(ErrorUserInfoKey, LocalizedFailureReasonErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedRecoverySuggestionErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedRecoveryOptionsErrorKey); +_NS_CONST(ErrorUserInfoKey, RecoveryAttempterErrorKey); +_NS_CONST(ErrorUserInfoKey, HelpAnchorErrorKey); +_NS_CONST(ErrorUserInfoKey, DebugDescriptionErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedFailureErrorKey); +_NS_CONST(ErrorUserInfoKey, StringEncodingErrorKey); +_NS_CONST(ErrorUserInfoKey, URLErrorKey); +_NS_CONST(ErrorUserInfoKey, FilePathErrorKey); + +class Error : public Copying +{ +public: + static Error* error(ErrorDomain domain, Integer code, class Dictionary* pDictionary); + + static Error* alloc(); + Error* init(); + Error* init(ErrorDomain domain, Integer code, class Dictionary* pDictionary); + + Integer code() const; + ErrorDomain domain() const; + class Dictionary* userInfo() const; + + class String* localizedDescription() const; + class Array* localizedRecoveryOptions() const; + class String* localizedRecoverySuggestion() const; + class String* localizedFailureReason() const; +}; +} + +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, CocoaErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, POSIXErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, OSStatusErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, MachErrorDomain); + +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, UnderlyingErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedDescriptionKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedFailureReasonErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedRecoverySuggestionErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedRecoveryOptionsErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, RecoveryAttempterErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, HelpAnchorErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, DebugDescriptionErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedFailureErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, StringEncodingErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, URLErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, FilePathErrorKey); + +_NS_INLINE NS::Error* NS::Error::error(ErrorDomain domain, Integer code, class Dictionary* pDictionary) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSError), _NS_PRIVATE_SEL(errorWithDomain_code_userInfo_), domain, code, pDictionary); +} + +_NS_INLINE NS::Error* NS::Error::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSError)); +} + +_NS_INLINE NS::Error* NS::Error::init() +{ + return Object::init(); +} + +_NS_INLINE NS::Error* NS::Error::init(ErrorDomain domain, Integer code, class Dictionary* pDictionary) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithDomain_code_userInfo_), domain, code, pDictionary); +} + +_NS_INLINE NS::Integer NS::Error::code() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(code)); +} + +_NS_INLINE NS::ErrorDomain NS::Error::domain() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(domain)); +} + +_NS_INLINE NS::Dictionary* NS::Error::userInfo() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(userInfo)); +} + +_NS_INLINE NS::String* NS::Error::localizedDescription() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedDescription)); +} + +_NS_INLINE NS::Array* NS::Error::localizedRecoveryOptions() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedRecoveryOptions)); +} + +_NS_INLINE NS::String* NS::Error::localizedRecoverySuggestion() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedRecoverySuggestion)); +} + +_NS_INLINE NS::String* NS::Error::localizedFailureReason() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedFailureReason)); +} + +namespace NS +{ + +template +class Locking : public _Base +{ +public: + void lock(); + void unlock(); +}; + +class Condition : public Locking +{ +public: + static Condition* alloc(); + + Condition* init(); + + void wait(); + bool waitUntilDate(Date* pLimit); + void signal(); + void broadcast(); +}; + +} // NS + +template +_NS_INLINE void NS::Locking<_Class, _Base>::lock() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(lock)); +} + +template +_NS_INLINE void NS::Locking<_Class, _Base>::unlock() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(unlock)); +} + +_NS_INLINE NS::Condition* NS::Condition::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSCondition)); +} + +_NS_INLINE NS::Condition* NS::Condition::init() +{ + return NS::Object::init(); +} + +_NS_INLINE void NS::Condition::wait() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(wait)); +} + +_NS_INLINE bool NS::Condition::waitUntilDate(NS::Date* pLimit) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(waitUntilDate_), pLimit); +} + +_NS_INLINE void NS::Condition::signal() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(signal)); +} + +_NS_INLINE void NS::Condition::broadcast() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(broadcast)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class Value : public Copying +{ +public: + static Value* value(const void* pValue, const char* pType); + static Value* value(const void* pPointer); + + static Value* alloc(); + + Value* init(const void* pValue, const char* pType); + Value* init(const class Coder* pCoder); + + void getValue(void* pValue, UInteger size) const; + const char* objCType() const; + + bool isEqualToValue(Value* pValue) const; + void* pointerValue() const; +}; + +class Number : public Copying +{ +public: + static Number* number(char value); + static Number* number(unsigned char value); + static Number* number(short value); + static Number* number(unsigned short value); + static Number* number(int value); + static Number* number(unsigned int value); + static Number* number(long value); + static Number* number(unsigned long value); + static Number* number(long long value); + static Number* number(unsigned long long value); + static Number* number(float value); + static Number* number(double value); + static Number* number(bool value); + + static Number* alloc(); + + Number* init(const class Coder* pCoder); + Number* init(char value); + Number* init(unsigned char value); + Number* init(short value); + Number* init(unsigned short value); + Number* init(int value); + Number* init(unsigned int value); + Number* init(long value); + Number* init(unsigned long value); + Number* init(long long value); + Number* init(unsigned long long value); + Number* init(float value); + Number* init(double value); + Number* init(bool value); + + char charValue() const; + unsigned char unsignedCharValue() const; + short shortValue() const; + unsigned short unsignedShortValue() const; + int intValue() const; + unsigned int unsignedIntValue() const; + long longValue() const; + unsigned long unsignedLongValue() const; + long long longLongValue() const; + unsigned long long unsignedLongLongValue() const; + float floatValue() const; + double doubleValue() const; + bool boolValue() const; + Integer integerValue() const; + UInteger unsignedIntegerValue() const; + class String* stringValue() const; + + ComparisonResult compare(const Number* pOtherNumber) const; + bool isEqualToNumber(const Number* pNumber) const; + + class String* descriptionWithLocale(const Object* pLocale) const; +}; +} + +_NS_INLINE NS::Value* NS::Value::value(const void* pValue, const char* pType) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSValue), _NS_PRIVATE_SEL(valueWithBytes_objCType_), pValue, pType); +} + +_NS_INLINE NS::Value* NS::Value::value(const void* pPointer) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSValue), _NS_PRIVATE_SEL(valueWithPointer_), pPointer); +} + +_NS_INLINE NS::Value* NS::Value::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSValue)); +} + +_NS_INLINE NS::Value* NS::Value::init(const void* pValue, const char* pType) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBytes_objCType_), pValue, pType); +} + +_NS_INLINE NS::Value* NS::Value::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +_NS_INLINE void NS::Value::getValue(void* pValue, UInteger size) const +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(getValue_size_), pValue, size); +} + +_NS_INLINE const char* NS::Value::objCType() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(objCType)); +} + +_NS_INLINE bool NS::Value::isEqualToValue(Value* pValue) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToValue_), pValue); +} + +_NS_INLINE void* NS::Value::pointerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(pointerValue)); +} + +_NS_INLINE NS::Number* NS::Number::number(char value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithChar_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(unsigned char value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedChar_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(short value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithShort_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(unsigned short value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedShort_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(int value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithInt_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(unsigned int value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedInt_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(unsigned long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(long long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithLongLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(unsigned long long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedLongLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(float value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithFloat_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(double value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithDouble_), value); +} + +_NS_INLINE NS::Number* NS::Number::number(bool value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithBool_), value); +} + +_NS_INLINE NS::Number* NS::Number::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSNumber)); +} + +_NS_INLINE NS::Number* NS::Number::init(const Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +_NS_INLINE NS::Number* NS::Number::init(char value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithChar_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(unsigned char value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedChar_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(short value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithShort_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(unsigned short value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedShort_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(int value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithInt_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(unsigned int value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedInt_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(unsigned long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(long long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithLongLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(unsigned long long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedLongLong_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(float value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithFloat_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(double value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithDouble_), value); +} + +_NS_INLINE NS::Number* NS::Number::init(bool value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBool_), value); +} + +_NS_INLINE char NS::Number::charValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(charValue)); +} + +_NS_INLINE unsigned char NS::Number::unsignedCharValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedCharValue)); +} + +_NS_INLINE short NS::Number::shortValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(shortValue)); +} + +_NS_INLINE unsigned short NS::Number::unsignedShortValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedShortValue)); +} + +_NS_INLINE int NS::Number::intValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(intValue)); +} + +_NS_INLINE unsigned int NS::Number::unsignedIntValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedIntValue)); +} + +_NS_INLINE long NS::Number::longValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(longValue)); +} + +_NS_INLINE unsigned long NS::Number::unsignedLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedLongValue)); +} + +_NS_INLINE long long NS::Number::longLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(longLongValue)); +} + +_NS_INLINE unsigned long long NS::Number::unsignedLongLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedLongLongValue)); +} + +_NS_INLINE float NS::Number::floatValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(floatValue)); +} + +_NS_INLINE double NS::Number::doubleValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(doubleValue)); +} + +_NS_INLINE bool NS::Number::boolValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(boolValue)); +} + +_NS_INLINE NS::Integer NS::Number::integerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(integerValue)); +} + +_NS_INLINE NS::UInteger NS::Number::unsignedIntegerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedIntegerValue)); +} + +_NS_INLINE NS::String* NS::Number::stringValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(stringValue)); +} + +_NS_INLINE NS::ComparisonResult NS::Number::compare(const Number* pOtherNumber) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(compare_), pOtherNumber); +} + +_NS_INLINE bool NS::Number::isEqualToNumber(const Number* pNumber) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToNumber_), pNumber); +} + +_NS_INLINE NS::String* NS::Number::descriptionWithLocale(const Object* pLocale) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(descriptionWithLocale_), pLocale); +} + +#include + +namespace NS +{ +_NS_CONST(NotificationName, ProcessInfoThermalStateDidChangeNotification); +_NS_CONST(NotificationName, ProcessInfoPowerStateDidChangeNotification); +_NS_CONST(NotificationName, ProcessInfoPerformanceProfileDidChangeNotification); + +_NS_ENUM(NS::Integer, ProcessInfoThermalState) { + ProcessInfoThermalStateNominal = 0, + ProcessInfoThermalStateFair = 1, + ProcessInfoThermalStateSerious = 2, + ProcessInfoThermalStateCritical = 3 +}; + +_NS_OPTIONS(std::uint64_t, ActivityOptions) { + ActivityIdleDisplaySleepDisabled = (1ULL << 40), + ActivityIdleSystemSleepDisabled = (1ULL << 20), + ActivitySuddenTerminationDisabled = (1ULL << 14), + ActivityAutomaticTerminationDisabled = (1ULL << 15), + ActivityUserInitiated = (0x00FFFFFFULL | ActivityIdleSystemSleepDisabled), + ActivityUserInitiatedAllowingIdleSystemSleep = (ActivityUserInitiated & ~ActivityIdleSystemSleepDisabled), + ActivityBackground = 0x000000FFULL, + ActivityLatencyCritical = 0xFF00000000ULL, +}; + +typedef NS::Integer DeviceCertification; +_NS_CONST(DeviceCertification, DeviceCertificationiPhonePerformanceGaming); + +typedef NS::Integer ProcessPerformanceProfile; +_NS_CONST(ProcessPerformanceProfile, ProcessPerformanceProfileDefault); +_NS_CONST(ProcessPerformanceProfile, ProcessPerformanceProfileSustained); + +class ProcessInfo : public Referencing +{ +public: + static ProcessInfo* processInfo(); + + class Array* arguments() const; + class Dictionary* environment() const; + class String* hostName() const; + class String* processName() const; + void setProcessName(const String* pString); + int processIdentifier() const; + class String* globallyUniqueString() const; + + class String* userName() const; + class String* fullUserName() const; + + UInteger operatingSystem() const; + OperatingSystemVersion operatingSystemVersion() const; + class String* operatingSystemVersionString() const; + bool isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const; + + UInteger processorCount() const; + UInteger activeProcessorCount() const; + unsigned long long physicalMemory() const; + TimeInterval systemUptime() const; + + void disableSuddenTermination(); + void enableSuddenTermination(); + + void disableAutomaticTermination(const class String* pReason); + void enableAutomaticTermination(const class String* pReason); + bool automaticTerminationSupportEnabled() const; + void setAutomaticTerminationSupportEnabled(bool enabled); + + class Object* beginActivity(ActivityOptions options, const class String* pReason); + void endActivity(class Object* pActivity); + void performActivity(ActivityOptions options, const class String* pReason, void (^block)(void)); + void performActivity(ActivityOptions options, const class String* pReason, const std::function& func); + void performExpiringActivity(const class String* pReason, void (^block)(bool expired)); + void performExpiringActivity(const class String* pReason, const std::function& func); + + ProcessInfoThermalState thermalState() const; + bool isLowPowerModeEnabled() const; + + bool isiOSAppOnMac() const; + bool isMacCatalystApp() const; + + bool isDeviceCertified(DeviceCertification performanceTier) const; + bool hasPerformanceProfile(ProcessPerformanceProfile performanceProfile) const; + +}; +} + +_NS_PRIVATE_DEF_CONST(NS::NotificationName, ProcessInfoThermalStateDidChangeNotification); +_NS_PRIVATE_DEF_CONST(NS::NotificationName, ProcessInfoPowerStateDidChangeNotification); + +_NS_PRIVATE_DEF_CONST(NS::NotificationName, ProcessInfoPerformanceProfileDidChangeNotification); +_NS_PRIVATE_DEF_CONST(NS::DeviceCertification, DeviceCertificationiPhonePerformanceGaming); +_NS_PRIVATE_DEF_CONST(NS::ProcessPerformanceProfile, ProcessPerformanceProfileDefault); +_NS_PRIVATE_DEF_CONST(NS::ProcessPerformanceProfile, ProcessPerformanceProfileSustained); + +_NS_INLINE NS::ProcessInfo* NS::ProcessInfo::processInfo() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSProcessInfo), _NS_PRIVATE_SEL(processInfo)); +} + +_NS_INLINE NS::Array* NS::ProcessInfo::arguments() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(arguments)); +} + +_NS_INLINE NS::Dictionary* NS::ProcessInfo::environment() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(environment)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::hostName() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(hostName)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::processName() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processName)); +} + +_NS_INLINE void NS::ProcessInfo::setProcessName(const String* pString) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(setProcessName_), pString); +} + +_NS_INLINE int NS::ProcessInfo::processIdentifier() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processIdentifier)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::globallyUniqueString() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(globallyUniqueString)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::userName() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(userName)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::fullUserName() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(fullUserName)); +} + +_NS_INLINE NS::UInteger NS::ProcessInfo::operatingSystem() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystem)); +} + +_NS_INLINE NS::OperatingSystemVersion NS::ProcessInfo::operatingSystemVersion() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystemVersion)); +} + +_NS_INLINE NS::String* NS::ProcessInfo::operatingSystemVersionString() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystemVersionString)); +} + +_NS_INLINE bool NS::ProcessInfo::isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isOperatingSystemAtLeastVersion_), version); +} + +_NS_INLINE NS::UInteger NS::ProcessInfo::processorCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processorCount)); +} + +_NS_INLINE NS::UInteger NS::ProcessInfo::activeProcessorCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(activeProcessorCount)); +} + +_NS_INLINE unsigned long long NS::ProcessInfo::physicalMemory() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(physicalMemory)); +} + +_NS_INLINE NS::TimeInterval NS::ProcessInfo::systemUptime() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(systemUptime)); +} + +_NS_INLINE void NS::ProcessInfo::disableSuddenTermination() +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(disableSuddenTermination)); +} + +_NS_INLINE void NS::ProcessInfo::enableSuddenTermination() +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(enableSuddenTermination)); +} + +_NS_INLINE void NS::ProcessInfo::disableAutomaticTermination(const String* pReason) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(disableAutomaticTermination_), pReason); +} + +_NS_INLINE void NS::ProcessInfo::enableAutomaticTermination(const String* pReason) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(enableAutomaticTermination_), pReason); +} + +_NS_INLINE bool NS::ProcessInfo::automaticTerminationSupportEnabled() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(automaticTerminationSupportEnabled)); +} + +_NS_INLINE void NS::ProcessInfo::setAutomaticTerminationSupportEnabled(bool enabled) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(setAutomaticTerminationSupportEnabled_), enabled); +} + +_NS_INLINE NS::Object* NS::ProcessInfo::beginActivity(ActivityOptions options, const String* pReason) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(beginActivityWithOptions_reason_), options, pReason); +} + +_NS_INLINE void NS::ProcessInfo::endActivity(Object* pActivity) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(endActivity_), pActivity); +} + +_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, void (^block)(void)) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(performActivityWithOptions_reason_usingBlock_), options, pReason, block); +} + +_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, const std::function& function) +{ + __block std::function blockFunction = function; + + performActivity(options, pReason, ^() { blockFunction(); }); +} + +_NS_INLINE void NS::ProcessInfo::performExpiringActivity(const String* pReason, void (^block)(bool expired)) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(performExpiringActivityWithReason_usingBlock_), pReason, block); +} + +_NS_INLINE void NS::ProcessInfo::performExpiringActivity(const String* pReason, const std::function& function) +{ + __block std::function blockFunction = function; + + performExpiringActivity(pReason, ^(bool expired) { blockFunction(expired); }); +} + +_NS_INLINE NS::ProcessInfoThermalState NS::ProcessInfo::thermalState() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(thermalState)); +} + +_NS_INLINE bool NS::ProcessInfo::isLowPowerModeEnabled() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isLowPowerModeEnabled)); +} + +_NS_INLINE bool NS::ProcessInfo::isiOSAppOnMac() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isiOSAppOnMac)); +} + +_NS_INLINE bool NS::ProcessInfo::isMacCatalystApp() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isMacCatalystApp)); +} + +_NS_INLINE bool NS::ProcessInfo::isDeviceCertified(DeviceCertification performanceTier) const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isDeviceCertified_), performanceTier); +} + +_NS_INLINE bool NS::ProcessInfo::hasPerformanceProfile(ProcessPerformanceProfile performanceProfile) const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(hasPerformanceProfile_), performanceProfile); +} + +/*****Immutable Set*******/ + +namespace NS +{ + class Set : public NS::Copying + { + public: + UInteger count() const; + Enumerator* objectEnumerator() const; + + static Set* alloc(); + + Set* init(); + Set* init(const Object* const* pObjects, UInteger count); + Set* init(const class Coder* pCoder); + + }; +} + +_NS_INLINE NS::UInteger NS::Set::count() const +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +_NS_INLINE NS::Enumerator* NS::Set::objectEnumerator() const +{ + return NS::Object::sendMessage*>(this, _NS_PRIVATE_SEL(objectEnumerator)); +} + +_NS_INLINE NS::Set* NS::Set::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSSet)); +} + +_NS_INLINE NS::Set* NS::Set::init() +{ + return NS::Object::init(); +} + +_NS_INLINE NS::Set* NS::Set::init(const Object* const* pObjects, NS::UInteger count) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_count_), pObjects, count); +} + +_NS_INLINE NS::Set* NS::Set::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +#pragma once + +namespace NS +{ +template +class SharedPtr +{ +public: + /** + * Create a new null pointer. + */ + SharedPtr(); + + /** + * Destroy this SharedPtr, decreasing the reference count. + */ + ~SharedPtr(); + + /** + * SharedPtr copy constructor. + */ + SharedPtr(const SharedPtr<_Class>& other) noexcept; + + /** + * Construction from another pointee type. + */ + template + SharedPtr(const SharedPtr<_OtherClass>& other, typename std::enable_if_t> * = nullptr) noexcept; + + /** + * SharedPtr move constructor. + */ + SharedPtr(SharedPtr<_Class>&& other) noexcept; + + /** + * Move from another pointee type. + */ + template + SharedPtr(SharedPtr<_OtherClass>&& other, typename std::enable_if_t> * = nullptr) noexcept; + + /** + * Copy assignment operator. + * Copying increases reference count. Only releases previous pointee if objects are different. + */ + SharedPtr& operator=(const SharedPtr<_Class>& other); + + /** + * Copy-assignment from different pointee. + * Copying increases reference count. Only releases previous pointee if objects are different. + */ + template + typename std::enable_if_t, SharedPtr &> + operator=(const SharedPtr<_OtherClass>& other); + + /** + * Move assignment operator. + * Move without affecting reference counts, unless pointees are equal. Moved-from object is reset to nullptr. + */ + SharedPtr& operator=(SharedPtr<_Class>&& other); + + /** + * Move-asignment from different pointee. + * Move without affecting reference counts, unless pointees are equal. Moved-from object is reset to nullptr. + */ + template + typename std::enable_if_t, SharedPtr &> + operator=(SharedPtr<_OtherClass>&& other); + + /** + * Access raw pointee. + * @warning Avoid wrapping the returned value again, as it may lead double frees unless this object becomes detached. + */ + _Class* get() const; + + /** + * Call operations directly on the pointee. + */ + _Class* operator->() const; + + /** + * Implicit cast to bool. + */ + explicit operator bool() const; + + /** + * Reset this SharedPtr to null, decreasing the reference count. + */ + void reset(); + + /** + * Detach the SharedPtr from the pointee, without decreasing the reference count. + */ + void detach(); + + template + friend SharedPtr<_OtherClass> RetainPtr(_OtherClass* ptr); + + template + friend SharedPtr<_OtherClass> TransferPtr(_OtherClass* ptr); + +private: + _Class* m_pObject; +}; + +/** + * Create a SharedPtr by retaining an existing raw pointer. + * Increases the reference count of the passed-in object. + * If the passed-in object was in an AutoreleasePool, it will be removed from it. + */ +template +_NS_INLINE NS::SharedPtr<_Class> RetainPtr(_Class* pObject) +{ + NS::SharedPtr<_Class> ret; + ret.m_pObject = pObject->retain(); + return ret; +} + +/* + * Create a SharedPtr by transfering the ownership of an existing raw pointer to SharedPtr. + * Does not increase the reference count of the passed-in pointer, it is assumed to be >= 1. + * This method does not remove objects from an AutoreleasePool. +*/ +template +_NS_INLINE NS::SharedPtr<_Class> TransferPtr(_Class* pObject) +{ + NS::SharedPtr<_Class> ret; + ret.m_pObject = pObject; + return ret; +} + +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr() + : m_pObject(nullptr) +{ +} + +template +_NS_INLINE NS::SharedPtr<_Class>::~SharedPtr<_Class>() +{ + if (m_pObject) + { + m_pObject->release(); + } +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(const NS::SharedPtr<_Class>& other) noexcept + : m_pObject(other.m_pObject->retain()) +{ +} + +template +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(const NS::SharedPtr<_OtherClass>& other, typename std::enable_if_t> *) noexcept + : m_pObject(reinterpret_cast<_Class*>(other.get()->retain())) +{ +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(NS::SharedPtr<_Class>&& other) noexcept + : m_pObject(other.m_pObject) +{ + other.m_pObject = nullptr; +} + +template +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(NS::SharedPtr<_OtherClass>&& other, typename std::enable_if_t> *) noexcept + : m_pObject(reinterpret_cast<_Class*>(other.get())) +{ + other.detach(); +} + +template +_NS_INLINE _Class* NS::SharedPtr<_Class>::get() const +{ + return m_pObject; +} + +template +_NS_INLINE _Class* NS::SharedPtr<_Class>::operator->() const +{ + return m_pObject; +} + +template +_NS_INLINE NS::SharedPtr<_Class>::operator bool() const +{ + return nullptr != m_pObject; +} + +template +_NS_INLINE void NS::SharedPtr<_Class>::reset() +{ + m_pObject->release(); + m_pObject = nullptr; +} + +template +_NS_INLINE void NS::SharedPtr<_Class>::detach() +{ + m_pObject = nullptr; +} + +template +_NS_INLINE NS::SharedPtr<_Class>& NS::SharedPtr<_Class>::operator=(const SharedPtr<_Class>& other) +{ + if (m_pObject != other.m_pObject) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = other.m_pObject->retain(); + } + return *this; +} + +template +template +typename std::enable_if_t, NS::SharedPtr<_Class> &> +_NS_INLINE NS::SharedPtr<_Class>::operator=(const SharedPtr<_OtherClass>& other) +{ + if (m_pObject != other.get()) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = reinterpret_cast<_Class*>(other.get()->retain()); + } + return *this; +} + +template +_NS_INLINE NS::SharedPtr<_Class>& NS::SharedPtr<_Class>::operator=(SharedPtr<_Class>&& other) +{ + if (m_pObject != other.m_pObject) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = other.m_pObject; + } + else + { + m_pObject = other.m_pObject; + other.m_pObject->release(); + } + other.m_pObject = nullptr; + return *this; +} + +template +template +typename std::enable_if_t, NS::SharedPtr<_Class> &> +_NS_INLINE NS::SharedPtr<_Class>::operator=(SharedPtr<_OtherClass>&& other) +{ + if (m_pObject != other.get()) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = reinterpret_cast<_Class*>(other.get()); + other.detach(); + } + else + { + m_pObject = other.get(); + other.reset(); + } + return *this; +} + +template +_NS_INLINE bool operator==(const NS::SharedPtr<_ClassLhs>& lhs, const NS::SharedPtr<_ClassRhs>& rhs) +{ + return lhs.get() == rhs.get(); +} + +template +_NS_INLINE bool operator!=(const NS::SharedPtr<_ClassLhs>& lhs, const NS::SharedPtr<_ClassRhs>& rhs) +{ + return lhs.get() != rhs.get(); +} + +namespace NS +{ +class URL : public Copying +{ +public: + static URL* fileURLWithPath(const class String* pPath); + + static URL* alloc(); + URL* init(); + URL* init(const class String* pString); + URL* initFileURLWithPath(const class String* pPath); + + const char* fileSystemRepresentation() const; +}; +} + +_NS_INLINE NS::URL* NS::URL::fileURLWithPath(const String* pPath) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSURL), _NS_PRIVATE_SEL(fileURLWithPath_), pPath); +} + +_NS_INLINE NS::URL* NS::URL::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSURL)); +} + +_NS_INLINE NS::URL* NS::URL::init() +{ + return Object::init(); +} + +_NS_INLINE NS::URL* NS::URL::init(const String* pString) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithString_), pString); +} + +_NS_INLINE NS::URL* NS::URL::initFileURLWithPath(const String* pPath) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initFileURLWithPath_), pPath); +} + +_NS_INLINE const char* NS::URL::fileSystemRepresentation() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(fileSystemRepresentation)); +} + +#pragma once + +#define _MTL_EXPORT _NS_EXPORT +#define _MTL_EXTERN _NS_EXTERN +#define _MTL_INLINE _NS_INLINE +#define _MTL_PACKED _NS_PACKED + +#define _MTL_CONST(type, name) _NS_CONST(type, name) +#define _MTL_ENUM(type, name) _NS_ENUM(type, name) +#define _MTL_OPTIONS(type, name) _NS_OPTIONS(type, name) + +#define _MTL_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) +#define _MTL_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) + +#pragma once + +#include + +#define _MTL_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _MTL_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _MTL_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _MTL_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _MTL_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _MTL_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _MTL_PRIVATE_VISIBILITY = sel_registerName(symbol) + +#include +#define MTL_DEF_FUNC( name, signature ) \ + using Fn##name = signature; \ + Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) ) + +namespace MTL::Private +{ + template + inline _Type const LoadSymbol(const char* pSymbol) + { + const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); + + return pAddress ? *pAddress : nullptr; + } +} // MTL::Private + +#if defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) + +#define _MTL_PRIVATE_DEF_STR(type, symbol) \ + _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \ + type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr + +#define _MTL_PRIVATE_DEF_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \ + type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr + +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#else + +#define _MTL_PRIVATE_DEF_STR(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#define _MTL_PRIVATE_DEF_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) _MTL_PRIVATE_DEF_CONST(type, symbol) + +#endif // defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) + +#else + +#define _MTL_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _MTL_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _MTL_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _MTL_PRIVATE_DEF_STR(type, symbol) extern type const MTL::symbol +#define _MTL_PRIVATE_DEF_CONST(type, symbol) extern type const MTL::symbol +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) extern type const MTL::symbol + +#endif // MTL_PRIVATE_IMPLEMENTATION + +namespace MTL +{ +namespace Private +{ + namespace Class + { + + } // Class +} // Private +} // MTL + +namespace MTL +{ +namespace Private +{ + namespace Protocol + { + + } // Protocol +} // Private +} // MTL + +namespace MTL +{ +namespace Private +{ + namespace Selector + { + + _MTL_PRIVATE_DEF_SEL(beginScope, + "beginScope"); + _MTL_PRIVATE_DEF_SEL(endScope, + "endScope"); + } // Class +} // Private +} // MTL + +namespace MTL::Private::Class +{ + +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureCurveGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureTriangleGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLArchitecture); +_MTL_PRIVATE_DEF_CLS(MTLArgument); +_MTL_PRIVATE_DEF_CLS(MTLArgumentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLArrayType); +_MTL_PRIVATE_DEF_CLS(MTLAttribute); +_MTL_PRIVATE_DEF_CLS(MTLAttributeDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAttributeDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLBinaryArchiveDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLBufferLayoutDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBufferLayoutDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLCaptureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLCaptureManager); +_MTL_PRIVATE_DEF_CLS(MTLCommandBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLCommandQueueDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLCompileOptions); +_MTL_PRIVATE_DEF_CLS(MTLComputePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLComputePipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePipelineReflection); +_MTL_PRIVATE_DEF_CLS(MTLCounterSampleBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLDepthStencilDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLFunctionConstant); +_MTL_PRIVATE_DEF_CLS(MTLFunctionConstantValues); +_MTL_PRIVATE_DEF_CLS(MTLFunctionDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingAttributeAlwaysInline); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingFunctionNode); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingGraph); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingInputNode); +_MTL_PRIVATE_DEF_CLS(MTLHeapDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIOCommandQueueDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIndirectCommandBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIndirectInstanceAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLInstanceAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIntersectionFunctionDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIntersectionFunctionTableDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLLinkedFunctions); +_MTL_PRIVATE_DEF_CLS(MTLLogStateDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLMeshRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLMotionKeyframeData); +_MTL_PRIVATE_DEF_CLS(MTLPipelineBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLPipelineBufferDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLPointerType); +_MTL_PRIVATE_DEF_CLS(MTLPrimitiveAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateLayerArray); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateLayerDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateMapDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateSampleArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassDepthAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassStencilAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineFunctionsDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineReflection); +_MTL_PRIVATE_DEF_CLS(MTLResidencySetDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLSamplerDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLSharedEventHandle); +_MTL_PRIVATE_DEF_CLS(MTLSharedEventListener); +_MTL_PRIVATE_DEF_CLS(MTLSharedTextureHandle); +_MTL_PRIVATE_DEF_CLS(MTLStageInputOutputDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStencilDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStitchedLibraryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStructMember); +_MTL_PRIVATE_DEF_CLS(MTLStructType); +_MTL_PRIVATE_DEF_CLS(MTLTextureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLTextureReferenceType); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLType); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttribute); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttributeDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttributeDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLVertexBufferLayoutDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVertexBufferLayoutDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLVertexDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVisibleFunctionTableDescriptor); + +} + +namespace MTL::Private::Protocol +{ + +_MTL_PRIVATE_DEF_PRO(MTLAccelerationStructure); +_MTL_PRIVATE_DEF_PRO(MTLAccelerationStructureCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLAllocation); +_MTL_PRIVATE_DEF_PRO(MTLArgumentEncoder); +_MTL_PRIVATE_DEF_PRO(MTLBinaryArchive); +_MTL_PRIVATE_DEF_PRO(MTLBinding); +_MTL_PRIVATE_DEF_PRO(MTLBlitCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLBuffer); +_MTL_PRIVATE_DEF_PRO(MTLBufferBinding); +_MTL_PRIVATE_DEF_PRO(MTLCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLCommandBufferEncoderInfo); +_MTL_PRIVATE_DEF_PRO(MTLCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLCommandQueue); +_MTL_PRIVATE_DEF_PRO(MTLComputeCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLComputePipelineState); +_MTL_PRIVATE_DEF_PRO(MTLCounter); +_MTL_PRIVATE_DEF_PRO(MTLCounterSampleBuffer); +_MTL_PRIVATE_DEF_PRO(MTLCounterSet); +_MTL_PRIVATE_DEF_PRO(MTLDepthStencilState); +_MTL_PRIVATE_DEF_PRO(MTLDevice); +_MTL_PRIVATE_DEF_PRO(MTLDrawable); +_MTL_PRIVATE_DEF_PRO(MTLDynamicLibrary); +_MTL_PRIVATE_DEF_PRO(MTLEvent); +_MTL_PRIVATE_DEF_PRO(MTLFence); +_MTL_PRIVATE_DEF_PRO(MTLFunction); +_MTL_PRIVATE_DEF_PRO(MTLFunctionHandle); +_MTL_PRIVATE_DEF_PRO(MTLFunctionLog); +_MTL_PRIVATE_DEF_PRO(MTLFunctionLogDebugLocation); +_MTL_PRIVATE_DEF_PRO(MTLFunctionStitchingAttribute); +_MTL_PRIVATE_DEF_PRO(MTLFunctionStitchingNode); +_MTL_PRIVATE_DEF_PRO(MTLHeap); +_MTL_PRIVATE_DEF_PRO(MTLIOCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIOCommandQueue); +_MTL_PRIVATE_DEF_PRO(MTLIOFileHandle); +_MTL_PRIVATE_DEF_PRO(MTLIOScratchBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIOScratchBufferAllocator); +_MTL_PRIVATE_DEF_PRO(MTLIndirectCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIndirectComputeCommand); +_MTL_PRIVATE_DEF_PRO(MTLIndirectRenderCommand); +_MTL_PRIVATE_DEF_PRO(MTLIntersectionFunctionTable); +_MTL_PRIVATE_DEF_PRO(MTLLibrary); +_MTL_PRIVATE_DEF_PRO(MTLLogContainer); +_MTL_PRIVATE_DEF_PRO(MTLLogState); +_MTL_PRIVATE_DEF_PRO(MTLObjectPayloadBinding); +_MTL_PRIVATE_DEF_PRO(MTLParallelRenderCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLRasterizationRateMap); +_MTL_PRIVATE_DEF_PRO(MTLRenderCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLRenderPipelineState); +_MTL_PRIVATE_DEF_PRO(MTLResidencySet); +_MTL_PRIVATE_DEF_PRO(MTLResource); +_MTL_PRIVATE_DEF_PRO(MTLResourceStateCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLSamplerState); +_MTL_PRIVATE_DEF_PRO(MTLSharedEvent); +_MTL_PRIVATE_DEF_PRO(MTLTexture); +_MTL_PRIVATE_DEF_PRO(MTLTextureBinding); +_MTL_PRIVATE_DEF_PRO(MTLThreadgroupBinding); +_MTL_PRIVATE_DEF_PRO(MTLVisibleFunctionTable); + +} + +namespace MTL::Private::Selector +{ + +_MTL_PRIVATE_DEF_SEL(GPUEndTime, + "GPUEndTime"); +_MTL_PRIVATE_DEF_SEL(GPUStartTime, + "GPUStartTime"); +_MTL_PRIVATE_DEF_SEL(URL, + "URL"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureCommandEncoder, + "accelerationStructureCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureCommandEncoderWithDescriptor_, + "accelerationStructureCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(accelerationStructurePassDescriptor, + "accelerationStructurePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureSizesWithDescriptor_, + "accelerationStructureSizesWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(access, + "access"); +_MTL_PRIVATE_DEF_SEL(addAllocation_, + "addAllocation:"); +_MTL_PRIVATE_DEF_SEL(addAllocations_count_, + "addAllocations:count:"); +_MTL_PRIVATE_DEF_SEL(addBarrier, + "addBarrier"); +_MTL_PRIVATE_DEF_SEL(addCompletedHandler_, + "addCompletedHandler:"); +_MTL_PRIVATE_DEF_SEL(addComputePipelineFunctionsWithDescriptor_error_, + "addComputePipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addDebugMarker_range_, + "addDebugMarker:range:"); +_MTL_PRIVATE_DEF_SEL(addFunctionWithDescriptor_library_error_, + "addFunctionWithDescriptor:library:error:"); +_MTL_PRIVATE_DEF_SEL(addLibraryWithDescriptor_error_, + "addLibraryWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addLogHandler_, + "addLogHandler:"); +_MTL_PRIVATE_DEF_SEL(addMeshRenderPipelineFunctionsWithDescriptor_error_, + "addMeshRenderPipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addPresentedHandler_, + "addPresentedHandler:"); +_MTL_PRIVATE_DEF_SEL(addRenderPipelineFunctionsWithDescriptor_error_, + "addRenderPipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addResidencySet_, + "addResidencySet:"); +_MTL_PRIVATE_DEF_SEL(addResidencySets_count_, + "addResidencySets:count:"); +_MTL_PRIVATE_DEF_SEL(addScheduledHandler_, + "addScheduledHandler:"); +_MTL_PRIVATE_DEF_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_, + "addTileRenderPipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(alignment, + "alignment"); +_MTL_PRIVATE_DEF_SEL(allAllocations, + "allAllocations"); +_MTL_PRIVATE_DEF_SEL(allocatedSize, + "allocatedSize"); +_MTL_PRIVATE_DEF_SEL(allocationCount, + "allocationCount"); +_MTL_PRIVATE_DEF_SEL(allowDuplicateIntersectionFunctionInvocation, + "allowDuplicateIntersectionFunctionInvocation"); +_MTL_PRIVATE_DEF_SEL(allowGPUOptimizedContents, + "allowGPUOptimizedContents"); +_MTL_PRIVATE_DEF_SEL(allowReferencingUndefinedSymbols, + "allowReferencingUndefinedSymbols"); +_MTL_PRIVATE_DEF_SEL(alphaBlendOperation, + "alphaBlendOperation"); +_MTL_PRIVATE_DEF_SEL(architecture, + "architecture"); +_MTL_PRIVATE_DEF_SEL(areBarycentricCoordsSupported, + "areBarycentricCoordsSupported"); +_MTL_PRIVATE_DEF_SEL(areProgrammableSamplePositionsSupported, + "areProgrammableSamplePositionsSupported"); +_MTL_PRIVATE_DEF_SEL(areRasterOrderGroupsSupported, + "areRasterOrderGroupsSupported"); +_MTL_PRIVATE_DEF_SEL(argumentBuffersSupport, + "argumentBuffersSupport"); +_MTL_PRIVATE_DEF_SEL(argumentDescriptor, + "argumentDescriptor"); +_MTL_PRIVATE_DEF_SEL(argumentIndex, + "argumentIndex"); +_MTL_PRIVATE_DEF_SEL(argumentIndexStride, + "argumentIndexStride"); +_MTL_PRIVATE_DEF_SEL(arguments, + "arguments"); +_MTL_PRIVATE_DEF_SEL(arrayLength, + "arrayLength"); +_MTL_PRIVATE_DEF_SEL(arrayType, + "arrayType"); +_MTL_PRIVATE_DEF_SEL(attributeIndex, + "attributeIndex"); +_MTL_PRIVATE_DEF_SEL(attributeType, + "attributeType"); +_MTL_PRIVATE_DEF_SEL(attributes, + "attributes"); +_MTL_PRIVATE_DEF_SEL(backFaceStencil, + "backFaceStencil"); +_MTL_PRIVATE_DEF_SEL(binaryArchives, + "binaryArchives"); +_MTL_PRIVATE_DEF_SEL(binaryFunctions, + "binaryFunctions"); +_MTL_PRIVATE_DEF_SEL(bindings, + "bindings"); +_MTL_PRIVATE_DEF_SEL(blitCommandEncoder, + "blitCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(blitCommandEncoderWithDescriptor_, + "blitCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(blitPassDescriptor, + "blitPassDescriptor"); +_MTL_PRIVATE_DEF_SEL(borderColor, + "borderColor"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBuffer, + "boundingBoxBuffer"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBufferOffset, + "boundingBoxBufferOffset"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBuffers, + "boundingBoxBuffers"); +_MTL_PRIVATE_DEF_SEL(boundingBoxCount, + "boundingBoxCount"); +_MTL_PRIVATE_DEF_SEL(boundingBoxStride, + "boundingBoxStride"); +_MTL_PRIVATE_DEF_SEL(buffer, + "buffer"); +_MTL_PRIVATE_DEF_SEL(bufferAlignment, + "bufferAlignment"); +_MTL_PRIVATE_DEF_SEL(bufferBytesPerRow, + "bufferBytesPerRow"); +_MTL_PRIVATE_DEF_SEL(bufferDataSize, + "bufferDataSize"); +_MTL_PRIVATE_DEF_SEL(bufferDataType, + "bufferDataType"); +_MTL_PRIVATE_DEF_SEL(bufferIndex, + "bufferIndex"); +_MTL_PRIVATE_DEF_SEL(bufferOffset, + "bufferOffset"); +_MTL_PRIVATE_DEF_SEL(bufferPointerType, + "bufferPointerType"); +_MTL_PRIVATE_DEF_SEL(bufferSize, + "bufferSize"); +_MTL_PRIVATE_DEF_SEL(bufferStructType, + "bufferStructType"); +_MTL_PRIVATE_DEF_SEL(buffers, + "buffers"); +_MTL_PRIVATE_DEF_SEL(buildAccelerationStructure_descriptor_scratchBuffer_scratchBufferOffset_, + "buildAccelerationStructure:descriptor:scratchBuffer:scratchBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(captureObject, + "captureObject"); +_MTL_PRIVATE_DEF_SEL(clearBarrier, + "clearBarrier"); +_MTL_PRIVATE_DEF_SEL(clearColor, + "clearColor"); +_MTL_PRIVATE_DEF_SEL(clearDepth, + "clearDepth"); +_MTL_PRIVATE_DEF_SEL(clearStencil, + "clearStencil"); +_MTL_PRIVATE_DEF_SEL(colorAttachments, + "colorAttachments"); +_MTL_PRIVATE_DEF_SEL(column, + "column"); +_MTL_PRIVATE_DEF_SEL(commandBuffer, + "commandBuffer"); +_MTL_PRIVATE_DEF_SEL(commandBufferWithDescriptor_, + "commandBufferWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(commandBufferWithUnretainedReferences, + "commandBufferWithUnretainedReferences"); +_MTL_PRIVATE_DEF_SEL(commandQueue, + "commandQueue"); +_MTL_PRIVATE_DEF_SEL(commandTypes, + "commandTypes"); +_MTL_PRIVATE_DEF_SEL(commit, + "commit"); +_MTL_PRIVATE_DEF_SEL(compareFunction, + "compareFunction"); +_MTL_PRIVATE_DEF_SEL(compileSymbolVisibility, + "compileSymbolVisibility"); +_MTL_PRIVATE_DEF_SEL(compressionType, + "compressionType"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoder, + "computeCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoderWithDescriptor_, + "computeCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoderWithDispatchType_, + "computeCommandEncoderWithDispatchType:"); +_MTL_PRIVATE_DEF_SEL(computeFunction, + "computeFunction"); +_MTL_PRIVATE_DEF_SEL(computePassDescriptor, + "computePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(concurrentDispatchThreadgroups_threadsPerThreadgroup_, + "concurrentDispatchThreadgroups:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(concurrentDispatchThreads_threadsPerThreadgroup_, + "concurrentDispatchThreads:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(constantBlockAlignment, + "constantBlockAlignment"); +_MTL_PRIVATE_DEF_SEL(constantDataAtIndex_, + "constantDataAtIndex:"); +_MTL_PRIVATE_DEF_SEL(constantValues, + "constantValues"); +_MTL_PRIVATE_DEF_SEL(containsAllocation_, + "containsAllocation:"); +_MTL_PRIVATE_DEF_SEL(contents, + "contents"); +_MTL_PRIVATE_DEF_SEL(controlDependencies, + "controlDependencies"); +_MTL_PRIVATE_DEF_SEL(controlPointBuffer, + "controlPointBuffer"); +_MTL_PRIVATE_DEF_SEL(controlPointBufferOffset, + "controlPointBufferOffset"); +_MTL_PRIVATE_DEF_SEL(controlPointBuffers, + "controlPointBuffers"); +_MTL_PRIVATE_DEF_SEL(controlPointCount, + "controlPointCount"); +_MTL_PRIVATE_DEF_SEL(controlPointFormat, + "controlPointFormat"); +_MTL_PRIVATE_DEF_SEL(controlPointStride, + "controlPointStride"); +_MTL_PRIVATE_DEF_SEL(convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions_, + "convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions:"); +_MTL_PRIVATE_DEF_SEL(convertSparseTileRegions_toPixelRegions_withTileSize_numRegions_, + "convertSparseTileRegions:toPixelRegions:withTileSize:numRegions:"); +_MTL_PRIVATE_DEF_SEL(copyAccelerationStructure_toAccelerationStructure_, + "copyAccelerationStructure:toAccelerationStructure:"); +_MTL_PRIVATE_DEF_SEL(copyAndCompactAccelerationStructure_toAccelerationStructure_, + "copyAndCompactAccelerationStructure:toAccelerationStructure:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options_, + "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size_, + "copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount_, + "copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_toTexture_, + "copyFromTexture:toTexture:"); +_MTL_PRIVATE_DEF_SEL(copyIndirectCommandBuffer_sourceRange_destination_destinationIndex_, + "copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:"); +_MTL_PRIVATE_DEF_SEL(copyParameterDataToBuffer_offset_, + "copyParameterDataToBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(copyStatusToBuffer_offset_, + "copyStatusToBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(counterSet, + "counterSet"); +_MTL_PRIVATE_DEF_SEL(counterSets, + "counterSets"); +_MTL_PRIVATE_DEF_SEL(counters, + "counters"); +_MTL_PRIVATE_DEF_SEL(cpuCacheMode, + "cpuCacheMode"); +_MTL_PRIVATE_DEF_SEL(currentAllocatedSize, + "currentAllocatedSize"); +_MTL_PRIVATE_DEF_SEL(curveBasis, + "curveBasis"); +_MTL_PRIVATE_DEF_SEL(curveEndCaps, + "curveEndCaps"); +_MTL_PRIVATE_DEF_SEL(curveType, + "curveType"); +_MTL_PRIVATE_DEF_SEL(data, + "data"); +_MTL_PRIVATE_DEF_SEL(dataSize, + "dataSize"); +_MTL_PRIVATE_DEF_SEL(dataType, + "dataType"); +_MTL_PRIVATE_DEF_SEL(dealloc, + "dealloc"); +_MTL_PRIVATE_DEF_SEL(debugLocation, + "debugLocation"); +_MTL_PRIVATE_DEF_SEL(debugSignposts, + "debugSignposts"); +_MTL_PRIVATE_DEF_SEL(defaultCaptureScope, + "defaultCaptureScope"); +_MTL_PRIVATE_DEF_SEL(defaultRasterSampleCount, + "defaultRasterSampleCount"); +_MTL_PRIVATE_DEF_SEL(depth, + "depth"); +_MTL_PRIVATE_DEF_SEL(depthAttachment, + "depthAttachment"); +_MTL_PRIVATE_DEF_SEL(depthAttachmentPixelFormat, + "depthAttachmentPixelFormat"); +_MTL_PRIVATE_DEF_SEL(depthCompareFunction, + "depthCompareFunction"); +_MTL_PRIVATE_DEF_SEL(depthFailureOperation, + "depthFailureOperation"); +_MTL_PRIVATE_DEF_SEL(depthPlane, + "depthPlane"); +_MTL_PRIVATE_DEF_SEL(depthResolveFilter, + "depthResolveFilter"); +_MTL_PRIVATE_DEF_SEL(depthStencilPassOperation, + "depthStencilPassOperation"); +_MTL_PRIVATE_DEF_SEL(descriptor, + "descriptor"); +_MTL_PRIVATE_DEF_SEL(destination, + "destination"); +_MTL_PRIVATE_DEF_SEL(destinationAlphaBlendFactor, + "destinationAlphaBlendFactor"); +_MTL_PRIVATE_DEF_SEL(destinationRGBBlendFactor, + "destinationRGBBlendFactor"); +_MTL_PRIVATE_DEF_SEL(device, + "device"); +_MTL_PRIVATE_DEF_SEL(didModifyRange_, + "didModifyRange:"); +_MTL_PRIVATE_DEF_SEL(dispatchQueue, + "dispatchQueue"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadgroups_threadsPerThreadgroup_, + "dispatchThreadgroups:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup_, + "dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreads_threadsPerThreadgroup_, + "dispatchThreads:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadsPerTile_, + "dispatchThreadsPerTile:"); +_MTL_PRIVATE_DEF_SEL(dispatchType, + "dispatchType"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_, + "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_, + "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchIndexBuffer_patchIndexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawPatches:patchIndexBuffer:patchIndexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_, + "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_, + "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_indirectBuffer_indirectBufferOffset_, + "drawPrimitives:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_, + "drawPrimitives:vertexStart:vertexCount:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_, + "drawPrimitives:vertexStart:vertexCount:instanceCount:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_, + "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawableID, + "drawableID"); +_MTL_PRIVATE_DEF_SEL(elementArrayType, + "elementArrayType"); +_MTL_PRIVATE_DEF_SEL(elementIsArgumentBuffer, + "elementIsArgumentBuffer"); +_MTL_PRIVATE_DEF_SEL(elementPointerType, + "elementPointerType"); +_MTL_PRIVATE_DEF_SEL(elementStructType, + "elementStructType"); +_MTL_PRIVATE_DEF_SEL(elementTextureReferenceType, + "elementTextureReferenceType"); +_MTL_PRIVATE_DEF_SEL(elementType, + "elementType"); +_MTL_PRIVATE_DEF_SEL(enableLogging, + "enableLogging"); +_MTL_PRIVATE_DEF_SEL(encodeSignalEvent_value_, + "encodeSignalEvent:value:"); +_MTL_PRIVATE_DEF_SEL(encodeWaitForEvent_value_, + "encodeWaitForEvent:value:"); +_MTL_PRIVATE_DEF_SEL(encodedLength, + "encodedLength"); +_MTL_PRIVATE_DEF_SEL(encoderLabel, + "encoderLabel"); +_MTL_PRIVATE_DEF_SEL(endEncoding, + "endEncoding"); +_MTL_PRIVATE_DEF_SEL(endOfEncoderSampleIndex, + "endOfEncoderSampleIndex"); +_MTL_PRIVATE_DEF_SEL(endOfFragmentSampleIndex, + "endOfFragmentSampleIndex"); +_MTL_PRIVATE_DEF_SEL(endOfVertexSampleIndex, + "endOfVertexSampleIndex"); +_MTL_PRIVATE_DEF_SEL(endResidency, + "endResidency"); +_MTL_PRIVATE_DEF_SEL(enqueue, + "enqueue"); +_MTL_PRIVATE_DEF_SEL(enqueueBarrier, + "enqueueBarrier"); +_MTL_PRIVATE_DEF_SEL(error, + "error"); +_MTL_PRIVATE_DEF_SEL(errorOptions, + "errorOptions"); +_MTL_PRIVATE_DEF_SEL(errorState, + "errorState"); +_MTL_PRIVATE_DEF_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_, + "executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(executeCommandsInBuffer_withRange_, + "executeCommandsInBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(fastMathEnabled, + "fastMathEnabled"); +_MTL_PRIVATE_DEF_SEL(fillBuffer_range_value_, + "fillBuffer:range:value:"); +_MTL_PRIVATE_DEF_SEL(firstMipmapInTail, + "firstMipmapInTail"); +_MTL_PRIVATE_DEF_SEL(format, + "format"); +_MTL_PRIVATE_DEF_SEL(fragmentAdditionalBinaryFunctions, + "fragmentAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(fragmentArguments, + "fragmentArguments"); +_MTL_PRIVATE_DEF_SEL(fragmentBindings, + "fragmentBindings"); +_MTL_PRIVATE_DEF_SEL(fragmentBuffers, + "fragmentBuffers"); +_MTL_PRIVATE_DEF_SEL(fragmentFunction, + "fragmentFunction"); +_MTL_PRIVATE_DEF_SEL(fragmentLinkedFunctions, + "fragmentLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(fragmentPreloadedLibraries, + "fragmentPreloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(frontFaceStencil, + "frontFaceStencil"); +_MTL_PRIVATE_DEF_SEL(function, + "function"); +_MTL_PRIVATE_DEF_SEL(functionConstantsDictionary, + "functionConstantsDictionary"); +_MTL_PRIVATE_DEF_SEL(functionCount, + "functionCount"); +_MTL_PRIVATE_DEF_SEL(functionDescriptor, + "functionDescriptor"); +_MTL_PRIVATE_DEF_SEL(functionGraphs, + "functionGraphs"); +_MTL_PRIVATE_DEF_SEL(functionHandleWithFunction_, + "functionHandleWithFunction:"); +_MTL_PRIVATE_DEF_SEL(functionHandleWithFunction_stage_, + "functionHandleWithFunction:stage:"); +_MTL_PRIVATE_DEF_SEL(functionName, + "functionName"); +_MTL_PRIVATE_DEF_SEL(functionNames, + "functionNames"); +_MTL_PRIVATE_DEF_SEL(functionType, + "functionType"); +_MTL_PRIVATE_DEF_SEL(functions, + "functions"); +_MTL_PRIVATE_DEF_SEL(generateMipmapsForTexture_, + "generateMipmapsForTexture:"); +_MTL_PRIVATE_DEF_SEL(geometryDescriptors, + "geometryDescriptors"); +_MTL_PRIVATE_DEF_SEL(getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice_, + "getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(getBytes_bytesPerRow_fromRegion_mipmapLevel_, + "getBytes:bytesPerRow:fromRegion:mipmapLevel:"); +_MTL_PRIVATE_DEF_SEL(getDefaultSamplePositions_count_, + "getDefaultSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(getSamplePositions_count_, + "getSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(getTextureAccessCounters_region_mipLevel_slice_resetCounters_countersBuffer_countersBufferOffset_, + "getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(gpuAddress, + "gpuAddress"); +_MTL_PRIVATE_DEF_SEL(gpuResourceID, + "gpuResourceID"); +_MTL_PRIVATE_DEF_SEL(groups, + "groups"); +_MTL_PRIVATE_DEF_SEL(hasUnifiedMemory, + "hasUnifiedMemory"); +_MTL_PRIVATE_DEF_SEL(hazardTrackingMode, + "hazardTrackingMode"); +_MTL_PRIVATE_DEF_SEL(heap, + "heap"); +_MTL_PRIVATE_DEF_SEL(heapAccelerationStructureSizeAndAlignWithDescriptor_, + "heapAccelerationStructureSizeAndAlignWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(heapAccelerationStructureSizeAndAlignWithSize_, + "heapAccelerationStructureSizeAndAlignWithSize:"); +_MTL_PRIVATE_DEF_SEL(heapBufferSizeAndAlignWithLength_options_, + "heapBufferSizeAndAlignWithLength:options:"); +_MTL_PRIVATE_DEF_SEL(heapOffset, + "heapOffset"); +_MTL_PRIVATE_DEF_SEL(heapTextureSizeAndAlignWithDescriptor_, + "heapTextureSizeAndAlignWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(height, + "height"); +_MTL_PRIVATE_DEF_SEL(horizontal, + "horizontal"); +_MTL_PRIVATE_DEF_SEL(horizontalSampleStorage, + "horizontalSampleStorage"); +_MTL_PRIVATE_DEF_SEL(imageblockMemoryLengthForDimensions_, + "imageblockMemoryLengthForDimensions:"); +_MTL_PRIVATE_DEF_SEL(imageblockSampleLength, + "imageblockSampleLength"); +_MTL_PRIVATE_DEF_SEL(index, + "index"); +_MTL_PRIVATE_DEF_SEL(indexBuffer, + "indexBuffer"); +_MTL_PRIVATE_DEF_SEL(indexBufferIndex, + "indexBufferIndex"); +_MTL_PRIVATE_DEF_SEL(indexBufferOffset, + "indexBufferOffset"); +_MTL_PRIVATE_DEF_SEL(indexType, + "indexType"); +_MTL_PRIVATE_DEF_SEL(indirectComputeCommandAtIndex_, + "indirectComputeCommandAtIndex:"); +_MTL_PRIVATE_DEF_SEL(indirectRenderCommandAtIndex_, + "indirectRenderCommandAtIndex:"); +_MTL_PRIVATE_DEF_SEL(inheritBuffers, + "inheritBuffers"); +_MTL_PRIVATE_DEF_SEL(inheritPipelineState, + "inheritPipelineState"); +_MTL_PRIVATE_DEF_SEL(init, + "init"); +_MTL_PRIVATE_DEF_SEL(initWithArgumentIndex_, + "initWithArgumentIndex:"); +_MTL_PRIVATE_DEF_SEL(initWithDispatchQueue_, + "initWithDispatchQueue:"); +_MTL_PRIVATE_DEF_SEL(initWithFunctionName_nodes_outputNode_attributes_, + "initWithFunctionName:nodes:outputNode:attributes:"); +_MTL_PRIVATE_DEF_SEL(initWithName_arguments_controlDependencies_, + "initWithName:arguments:controlDependencies:"); +_MTL_PRIVATE_DEF_SEL(initWithSampleCount_, + "initWithSampleCount:"); +_MTL_PRIVATE_DEF_SEL(initWithSampleCount_horizontal_vertical_, + "initWithSampleCount:horizontal:vertical:"); +_MTL_PRIVATE_DEF_SEL(initialCapacity, + "initialCapacity"); +_MTL_PRIVATE_DEF_SEL(inputPrimitiveTopology, + "inputPrimitiveTopology"); +_MTL_PRIVATE_DEF_SEL(insertDebugCaptureBoundary, + "insertDebugCaptureBoundary"); +_MTL_PRIVATE_DEF_SEL(insertDebugSignpost_, + "insertDebugSignpost:"); +_MTL_PRIVATE_DEF_SEL(insertLibraries, + "insertLibraries"); +_MTL_PRIVATE_DEF_SEL(installName, + "installName"); +_MTL_PRIVATE_DEF_SEL(instanceCount, + "instanceCount"); +_MTL_PRIVATE_DEF_SEL(instanceCountBuffer, + "instanceCountBuffer"); +_MTL_PRIVATE_DEF_SEL(instanceCountBufferOffset, + "instanceCountBufferOffset"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorBuffer, + "instanceDescriptorBuffer"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorBufferOffset, + "instanceDescriptorBufferOffset"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorStride, + "instanceDescriptorStride"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorType, + "instanceDescriptorType"); +_MTL_PRIVATE_DEF_SEL(instanceTransformationMatrixLayout, + "instanceTransformationMatrixLayout"); +_MTL_PRIVATE_DEF_SEL(instancedAccelerationStructures, + "instancedAccelerationStructures"); +_MTL_PRIVATE_DEF_SEL(intersectionFunctionTableDescriptor, + "intersectionFunctionTableDescriptor"); +_MTL_PRIVATE_DEF_SEL(intersectionFunctionTableOffset, + "intersectionFunctionTableOffset"); +_MTL_PRIVATE_DEF_SEL(iosurface, + "iosurface"); +_MTL_PRIVATE_DEF_SEL(iosurfacePlane, + "iosurfacePlane"); +_MTL_PRIVATE_DEF_SEL(isActive, + "isActive"); +_MTL_PRIVATE_DEF_SEL(isAliasable, + "isAliasable"); +_MTL_PRIVATE_DEF_SEL(isAlphaToCoverageEnabled, + "isAlphaToCoverageEnabled"); +_MTL_PRIVATE_DEF_SEL(isAlphaToOneEnabled, + "isAlphaToOneEnabled"); +_MTL_PRIVATE_DEF_SEL(isArgument, + "isArgument"); +_MTL_PRIVATE_DEF_SEL(isBlendingEnabled, + "isBlendingEnabled"); +_MTL_PRIVATE_DEF_SEL(isCapturing, + "isCapturing"); +_MTL_PRIVATE_DEF_SEL(isDepth24Stencil8PixelFormatSupported, + "isDepth24Stencil8PixelFormatSupported"); +_MTL_PRIVATE_DEF_SEL(isDepthTexture, + "isDepthTexture"); +_MTL_PRIVATE_DEF_SEL(isDepthWriteEnabled, + "isDepthWriteEnabled"); +_MTL_PRIVATE_DEF_SEL(isFramebufferOnly, + "isFramebufferOnly"); +_MTL_PRIVATE_DEF_SEL(isHeadless, + "isHeadless"); +_MTL_PRIVATE_DEF_SEL(isLowPower, + "isLowPower"); +_MTL_PRIVATE_DEF_SEL(isPatchControlPointData, + "isPatchControlPointData"); +_MTL_PRIVATE_DEF_SEL(isPatchData, + "isPatchData"); +_MTL_PRIVATE_DEF_SEL(isRasterizationEnabled, + "isRasterizationEnabled"); +_MTL_PRIVATE_DEF_SEL(isRemovable, + "isRemovable"); +_MTL_PRIVATE_DEF_SEL(isShareable, + "isShareable"); +_MTL_PRIVATE_DEF_SEL(isSparse, + "isSparse"); +_MTL_PRIVATE_DEF_SEL(isTessellationFactorScaleEnabled, + "isTessellationFactorScaleEnabled"); +_MTL_PRIVATE_DEF_SEL(isUsed, + "isUsed"); +_MTL_PRIVATE_DEF_SEL(kernelEndTime, + "kernelEndTime"); +_MTL_PRIVATE_DEF_SEL(kernelStartTime, + "kernelStartTime"); +_MTL_PRIVATE_DEF_SEL(label, + "label"); +_MTL_PRIVATE_DEF_SEL(languageVersion, + "languageVersion"); +_MTL_PRIVATE_DEF_SEL(layerAtIndex_, + "layerAtIndex:"); +_MTL_PRIVATE_DEF_SEL(layerCount, + "layerCount"); +_MTL_PRIVATE_DEF_SEL(layers, + "layers"); +_MTL_PRIVATE_DEF_SEL(layouts, + "layouts"); +_MTL_PRIVATE_DEF_SEL(length, + "length"); +_MTL_PRIVATE_DEF_SEL(level, + "level"); +_MTL_PRIVATE_DEF_SEL(libraries, + "libraries"); +_MTL_PRIVATE_DEF_SEL(libraryType, + "libraryType"); +_MTL_PRIVATE_DEF_SEL(line, + "line"); +_MTL_PRIVATE_DEF_SEL(linkedFunctions, + "linkedFunctions"); +_MTL_PRIVATE_DEF_SEL(loadAction, + "loadAction"); +_MTL_PRIVATE_DEF_SEL(loadBuffer_offset_size_sourceHandle_sourceHandleOffset_, + "loadBuffer:offset:size:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(loadBytes_size_sourceHandle_sourceHandleOffset_, + "loadBytes:size:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(loadTexture_slice_level_size_sourceBytesPerRow_sourceBytesPerImage_destinationOrigin_sourceHandle_sourceHandleOffset_, + "loadTexture:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(location, + "location"); +_MTL_PRIVATE_DEF_SEL(locationNumber, + "locationNumber"); +_MTL_PRIVATE_DEF_SEL(lodAverage, + "lodAverage"); +_MTL_PRIVATE_DEF_SEL(lodMaxClamp, + "lodMaxClamp"); +_MTL_PRIVATE_DEF_SEL(lodMinClamp, + "lodMinClamp"); +_MTL_PRIVATE_DEF_SEL(logState, + "logState"); +_MTL_PRIVATE_DEF_SEL(logs, + "logs"); +_MTL_PRIVATE_DEF_SEL(magFilter, + "magFilter"); +_MTL_PRIVATE_DEF_SEL(makeAliasable, + "makeAliasable"); +_MTL_PRIVATE_DEF_SEL(mapPhysicalToScreenCoordinates_forLayer_, + "mapPhysicalToScreenCoordinates:forLayer:"); +_MTL_PRIVATE_DEF_SEL(mapScreenToPhysicalCoordinates_forLayer_, + "mapScreenToPhysicalCoordinates:forLayer:"); +_MTL_PRIVATE_DEF_SEL(mathFloatingPointFunctions, + "mathFloatingPointFunctions"); +_MTL_PRIVATE_DEF_SEL(mathMode, + "mathMode"); +_MTL_PRIVATE_DEF_SEL(maxAnisotropy, + "maxAnisotropy"); +_MTL_PRIVATE_DEF_SEL(maxArgumentBufferSamplerCount, + "maxArgumentBufferSamplerCount"); +_MTL_PRIVATE_DEF_SEL(maxAvailableSizeWithAlignment_, + "maxAvailableSizeWithAlignment:"); +_MTL_PRIVATE_DEF_SEL(maxBufferLength, + "maxBufferLength"); +_MTL_PRIVATE_DEF_SEL(maxCallStackDepth, + "maxCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maxCommandBufferCount, + "maxCommandBufferCount"); +_MTL_PRIVATE_DEF_SEL(maxCommandsInFlight, + "maxCommandsInFlight"); +_MTL_PRIVATE_DEF_SEL(maxFragmentBufferBindCount, + "maxFragmentBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxFragmentCallStackDepth, + "maxFragmentCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maxInstanceCount, + "maxInstanceCount"); +_MTL_PRIVATE_DEF_SEL(maxKernelBufferBindCount, + "maxKernelBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxKernelThreadgroupMemoryBindCount, + "maxKernelThreadgroupMemoryBindCount"); +_MTL_PRIVATE_DEF_SEL(maxMeshBufferBindCount, + "maxMeshBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxMotionTransformCount, + "maxMotionTransformCount"); +_MTL_PRIVATE_DEF_SEL(maxObjectBufferBindCount, + "maxObjectBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxObjectThreadgroupMemoryBindCount, + "maxObjectThreadgroupMemoryBindCount"); +_MTL_PRIVATE_DEF_SEL(maxSampleCount, + "maxSampleCount"); +_MTL_PRIVATE_DEF_SEL(maxTessellationFactor, + "maxTessellationFactor"); +_MTL_PRIVATE_DEF_SEL(maxThreadgroupMemoryLength, + "maxThreadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(maxThreadsPerThreadgroup, + "maxThreadsPerThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadgroupsPerMeshGrid, + "maxTotalThreadgroupsPerMeshGrid"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerMeshThreadgroup, + "maxTotalThreadsPerMeshThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerObjectThreadgroup, + "maxTotalThreadsPerObjectThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerThreadgroup, + "maxTotalThreadsPerThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTransferRate, + "maxTransferRate"); +_MTL_PRIVATE_DEF_SEL(maxVertexAmplificationCount, + "maxVertexAmplificationCount"); +_MTL_PRIVATE_DEF_SEL(maxVertexBufferBindCount, + "maxVertexBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxVertexCallStackDepth, + "maxVertexCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maximumConcurrentCompilationTaskCount, + "maximumConcurrentCompilationTaskCount"); +_MTL_PRIVATE_DEF_SEL(memberByName_, + "memberByName:"); +_MTL_PRIVATE_DEF_SEL(members, + "members"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithResources_count_, + "memoryBarrierWithResources:count:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithResources_count_afterStages_beforeStages_, + "memoryBarrierWithResources:count:afterStages:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithScope_, + "memoryBarrierWithScope:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithScope_afterStages_beforeStages_, + "memoryBarrierWithScope:afterStages:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(meshBindings, + "meshBindings"); +_MTL_PRIVATE_DEF_SEL(meshBuffers, + "meshBuffers"); +_MTL_PRIVATE_DEF_SEL(meshFunction, + "meshFunction"); +_MTL_PRIVATE_DEF_SEL(meshLinkedFunctions, + "meshLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(meshThreadExecutionWidth, + "meshThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(meshThreadgroupSizeIsMultipleOfThreadExecutionWidth, + "meshThreadgroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(minFilter, + "minFilter"); +_MTL_PRIVATE_DEF_SEL(minimumLinearTextureAlignmentForPixelFormat_, + "minimumLinearTextureAlignmentForPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(minimumTextureBufferAlignmentForPixelFormat_, + "minimumTextureBufferAlignmentForPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(mipFilter, + "mipFilter"); +_MTL_PRIVATE_DEF_SEL(mipmapLevelCount, + "mipmapLevelCount"); +_MTL_PRIVATE_DEF_SEL(motionEndBorderMode, + "motionEndBorderMode"); +_MTL_PRIVATE_DEF_SEL(motionEndTime, + "motionEndTime"); +_MTL_PRIVATE_DEF_SEL(motionKeyframeCount, + "motionKeyframeCount"); +_MTL_PRIVATE_DEF_SEL(motionStartBorderMode, + "motionStartBorderMode"); +_MTL_PRIVATE_DEF_SEL(motionStartTime, + "motionStartTime"); +_MTL_PRIVATE_DEF_SEL(motionTransformBuffer, + "motionTransformBuffer"); +_MTL_PRIVATE_DEF_SEL(motionTransformBufferOffset, + "motionTransformBufferOffset"); +_MTL_PRIVATE_DEF_SEL(motionTransformCount, + "motionTransformCount"); +_MTL_PRIVATE_DEF_SEL(motionTransformCountBuffer, + "motionTransformCountBuffer"); +_MTL_PRIVATE_DEF_SEL(motionTransformCountBufferOffset, + "motionTransformCountBufferOffset"); +_MTL_PRIVATE_DEF_SEL(motionTransformStride, + "motionTransformStride"); +_MTL_PRIVATE_DEF_SEL(motionTransformType, + "motionTransformType"); +_MTL_PRIVATE_DEF_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(mutability, + "mutability"); +_MTL_PRIVATE_DEF_SEL(name, + "name"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithDescriptor_, + "newAccelerationStructureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithDescriptor_offset_, + "newAccelerationStructureWithDescriptor:offset:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithSize_, + "newAccelerationStructureWithSize:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithSize_offset_, + "newAccelerationStructureWithSize:offset:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderForBufferAtIndex_, + "newArgumentEncoderForBufferAtIndex:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithArguments_, + "newArgumentEncoderWithArguments:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferBinding_, + "newArgumentEncoderWithBufferBinding:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferIndex_, + "newArgumentEncoderWithBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferIndex_reflection_, + "newArgumentEncoderWithBufferIndex:reflection:"); +_MTL_PRIVATE_DEF_SEL(newBinaryArchiveWithDescriptor_error_, + "newBinaryArchiveWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithBytes_length_options_, + "newBufferWithBytes:length:options:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithBytesNoCopy_length_options_deallocator_, + "newBufferWithBytesNoCopy:length:options:deallocator:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithLength_options_, + "newBufferWithLength:options:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithLength_options_offset_, + "newBufferWithLength:options:offset:"); +_MTL_PRIVATE_DEF_SEL(newCaptureScopeWithCommandQueue_, + "newCaptureScopeWithCommandQueue:"); +_MTL_PRIVATE_DEF_SEL(newCaptureScopeWithDevice_, + "newCaptureScopeWithDevice:"); +_MTL_PRIVATE_DEF_SEL(newCommandQueue, + "newCommandQueue"); +_MTL_PRIVATE_DEF_SEL(newCommandQueueWithDescriptor_, + "newCommandQueueWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newCommandQueueWithMaxCommandBufferCount_, + "newCommandQueueWithMaxCommandBufferCount:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithAdditionalBinaryFunctions_error_, + "newComputePipelineStateWithAdditionalBinaryFunctions:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithDescriptor_options_completionHandler_, + "newComputePipelineStateWithDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithDescriptor_options_reflection_error_, + "newComputePipelineStateWithDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_completionHandler_, + "newComputePipelineStateWithFunction:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_error_, + "newComputePipelineStateWithFunction:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_options_completionHandler_, + "newComputePipelineStateWithFunction:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_options_reflection_error_, + "newComputePipelineStateWithFunction:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newCounterSampleBufferWithDescriptor_error_, + "newCounterSampleBufferWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newDefaultLibrary, + "newDefaultLibrary"); +_MTL_PRIVATE_DEF_SEL(newDefaultLibraryWithBundle_error_, + "newDefaultLibraryWithBundle:error:"); +_MTL_PRIVATE_DEF_SEL(newDepthStencilStateWithDescriptor_, + "newDepthStencilStateWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newDynamicLibrary_error_, + "newDynamicLibrary:error:"); +_MTL_PRIVATE_DEF_SEL(newDynamicLibraryWithURL_error_, + "newDynamicLibraryWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newEvent, + "newEvent"); +_MTL_PRIVATE_DEF_SEL(newFence, + "newFence"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithDescriptor_completionHandler_, + "newFunctionWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithDescriptor_error_, + "newFunctionWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_, + "newFunctionWithName:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_constantValues_completionHandler_, + "newFunctionWithName:constantValues:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_constantValues_error_, + "newFunctionWithName:constantValues:error:"); +_MTL_PRIVATE_DEF_SEL(newHeapWithDescriptor_, + "newHeapWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newIOCommandQueueWithDescriptor_error_, + "newIOCommandQueueWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newIOFileHandleWithURL_compressionMethod_error_, + "newIOFileHandleWithURL:compressionMethod:error:"); +_MTL_PRIVATE_DEF_SEL(newIOFileHandleWithURL_error_, + "newIOFileHandleWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newIOHandleWithURL_compressionMethod_error_, + "newIOHandleWithURL:compressionMethod:error:"); +_MTL_PRIVATE_DEF_SEL(newIOHandleWithURL_error_, + "newIOHandleWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newIndirectCommandBufferWithDescriptor_maxCommandCount_options_, + "newIndirectCommandBufferWithDescriptor:maxCommandCount:options:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionTableWithDescriptor_, + "newIntersectionFunctionTableWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionTableWithDescriptor_stage_, + "newIntersectionFunctionTableWithDescriptor:stage:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionWithDescriptor_completionHandler_, + "newIntersectionFunctionWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionWithDescriptor_error_, + "newIntersectionFunctionWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithData_error_, + "newLibraryWithData:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithFile_error_, + "newLibraryWithFile:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithSource_options_completionHandler_, + "newLibraryWithSource:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithSource_options_error_, + "newLibraryWithSource:options:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithStitchedDescriptor_completionHandler_, + "newLibraryWithStitchedDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithStitchedDescriptor_error_, + "newLibraryWithStitchedDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithURL_error_, + "newLibraryWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newLogStateWithDescriptor_error_, + "newLogStateWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newRasterizationRateMapWithDescriptor_, + "newRasterizationRateMapWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newRemoteBufferViewForDevice_, + "newRemoteBufferViewForDevice:"); +_MTL_PRIVATE_DEF_SEL(newRemoteTextureViewForDevice_, + "newRemoteTextureViewForDevice:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithAdditionalBinaryFunctions_error_, + "newRenderPipelineStateWithAdditionalBinaryFunctions:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_completionHandler_, + "newRenderPipelineStateWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_error_, + "newRenderPipelineStateWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_options_completionHandler_, + "newRenderPipelineStateWithDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_options_reflection_error_, + "newRenderPipelineStateWithDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithMeshDescriptor_options_completionHandler_, + "newRenderPipelineStateWithMeshDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithMeshDescriptor_options_reflection_error_, + "newRenderPipelineStateWithMeshDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithTileDescriptor_options_completionHandler_, + "newRenderPipelineStateWithTileDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithTileDescriptor_options_reflection_error_, + "newRenderPipelineStateWithTileDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newResidencySetWithDescriptor_error_, + "newResidencySetWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newSamplerStateWithDescriptor_, + "newSamplerStateWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newScratchBufferWithMinimumSize_, + "newScratchBufferWithMinimumSize:"); +_MTL_PRIVATE_DEF_SEL(newSharedEvent, + "newSharedEvent"); +_MTL_PRIVATE_DEF_SEL(newSharedEventHandle, + "newSharedEventHandle"); +_MTL_PRIVATE_DEF_SEL(newSharedEventWithHandle_, + "newSharedEventWithHandle:"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureHandle, + "newSharedTextureHandle"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureWithDescriptor_, + "newSharedTextureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureWithHandle_, + "newSharedTextureWithHandle:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_, + "newTextureViewWithPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_, + "newTextureViewWithPixelFormat:textureType:levels:slices:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_swizzle_, + "newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_, + "newTextureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_iosurface_plane_, + "newTextureWithDescriptor:iosurface:plane:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_offset_, + "newTextureWithDescriptor:offset:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_offset_bytesPerRow_, + "newTextureWithDescriptor:offset:bytesPerRow:"); +_MTL_PRIVATE_DEF_SEL(newVisibleFunctionTableWithDescriptor_, + "newVisibleFunctionTableWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newVisibleFunctionTableWithDescriptor_stage_, + "newVisibleFunctionTableWithDescriptor:stage:"); +_MTL_PRIVATE_DEF_SEL(nodes, + "nodes"); +_MTL_PRIVATE_DEF_SEL(normalizedCoordinates, + "normalizedCoordinates"); +_MTL_PRIVATE_DEF_SEL(notifyListener_atValue_block_, + "notifyListener:atValue:block:"); +_MTL_PRIVATE_DEF_SEL(objectAtIndexedSubscript_, + "objectAtIndexedSubscript:"); +_MTL_PRIVATE_DEF_SEL(objectBindings, + "objectBindings"); +_MTL_PRIVATE_DEF_SEL(objectBuffers, + "objectBuffers"); +_MTL_PRIVATE_DEF_SEL(objectFunction, + "objectFunction"); +_MTL_PRIVATE_DEF_SEL(objectLinkedFunctions, + "objectLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(objectPayloadAlignment, + "objectPayloadAlignment"); +_MTL_PRIVATE_DEF_SEL(objectPayloadDataSize, + "objectPayloadDataSize"); +_MTL_PRIVATE_DEF_SEL(objectThreadExecutionWidth, + "objectThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(objectThreadgroupSizeIsMultipleOfThreadExecutionWidth, + "objectThreadgroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(offset, + "offset"); +_MTL_PRIVATE_DEF_SEL(opaque, + "opaque"); +_MTL_PRIVATE_DEF_SEL(optimizationLevel, + "optimizationLevel"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForCPUAccess_, + "optimizeContentsForCPUAccess:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForCPUAccess_slice_level_, + "optimizeContentsForCPUAccess:slice:level:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForGPUAccess_, + "optimizeContentsForGPUAccess:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForGPUAccess_slice_level_, + "optimizeContentsForGPUAccess:slice:level:"); +_MTL_PRIVATE_DEF_SEL(optimizeIndirectCommandBuffer_withRange_, + "optimizeIndirectCommandBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(options, + "options"); +_MTL_PRIVATE_DEF_SEL(outputNode, + "outputNode"); +_MTL_PRIVATE_DEF_SEL(outputURL, + "outputURL"); +_MTL_PRIVATE_DEF_SEL(parallelRenderCommandEncoderWithDescriptor_, + "parallelRenderCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(parameterBufferSizeAndAlign, + "parameterBufferSizeAndAlign"); +_MTL_PRIVATE_DEF_SEL(parentRelativeLevel, + "parentRelativeLevel"); +_MTL_PRIVATE_DEF_SEL(parentRelativeSlice, + "parentRelativeSlice"); +_MTL_PRIVATE_DEF_SEL(parentTexture, + "parentTexture"); +_MTL_PRIVATE_DEF_SEL(patchControlPointCount, + "patchControlPointCount"); +_MTL_PRIVATE_DEF_SEL(patchType, + "patchType"); +_MTL_PRIVATE_DEF_SEL(payloadMemoryLength, + "payloadMemoryLength"); +_MTL_PRIVATE_DEF_SEL(peerCount, + "peerCount"); +_MTL_PRIVATE_DEF_SEL(peerGroupID, + "peerGroupID"); +_MTL_PRIVATE_DEF_SEL(peerIndex, + "peerIndex"); +_MTL_PRIVATE_DEF_SEL(physicalGranularity, + "physicalGranularity"); +_MTL_PRIVATE_DEF_SEL(physicalSizeForLayer_, + "physicalSizeForLayer:"); +_MTL_PRIVATE_DEF_SEL(pixelFormat, + "pixelFormat"); +_MTL_PRIVATE_DEF_SEL(pointerType, + "pointerType"); +_MTL_PRIVATE_DEF_SEL(popDebugGroup, + "popDebugGroup"); +_MTL_PRIVATE_DEF_SEL(preloadedLibraries, + "preloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(preprocessorMacros, + "preprocessorMacros"); +_MTL_PRIVATE_DEF_SEL(present, + "present"); +_MTL_PRIVATE_DEF_SEL(presentAfterMinimumDuration_, + "presentAfterMinimumDuration:"); +_MTL_PRIVATE_DEF_SEL(presentAtTime_, + "presentAtTime:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_, + "presentDrawable:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_afterMinimumDuration_, + "presentDrawable:afterMinimumDuration:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_atTime_, + "presentDrawable:atTime:"); +_MTL_PRIVATE_DEF_SEL(presentedTime, + "presentedTime"); +_MTL_PRIVATE_DEF_SEL(preserveInvariance, + "preserveInvariance"); +_MTL_PRIVATE_DEF_SEL(primitiveDataBuffer, + "primitiveDataBuffer"); +_MTL_PRIVATE_DEF_SEL(primitiveDataBufferOffset, + "primitiveDataBufferOffset"); +_MTL_PRIVATE_DEF_SEL(primitiveDataElementSize, + "primitiveDataElementSize"); +_MTL_PRIVATE_DEF_SEL(primitiveDataStride, + "primitiveDataStride"); +_MTL_PRIVATE_DEF_SEL(priority, + "priority"); +_MTL_PRIVATE_DEF_SEL(privateFunctions, + "privateFunctions"); +_MTL_PRIVATE_DEF_SEL(pushDebugGroup_, + "pushDebugGroup:"); +_MTL_PRIVATE_DEF_SEL(rAddressMode, + "rAddressMode"); +_MTL_PRIVATE_DEF_SEL(radiusBuffer, + "radiusBuffer"); +_MTL_PRIVATE_DEF_SEL(radiusBufferOffset, + "radiusBufferOffset"); +_MTL_PRIVATE_DEF_SEL(radiusBuffers, + "radiusBuffers"); +_MTL_PRIVATE_DEF_SEL(radiusFormat, + "radiusFormat"); +_MTL_PRIVATE_DEF_SEL(radiusStride, + "radiusStride"); +_MTL_PRIVATE_DEF_SEL(rasterSampleCount, + "rasterSampleCount"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMap, + "rasterizationRateMap"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_, + "rasterizationRateMapDescriptorWithScreenSize:"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_layer_, + "rasterizationRateMapDescriptorWithScreenSize:layer:"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_layerCount_layers_, + "rasterizationRateMapDescriptorWithScreenSize:layerCount:layers:"); +_MTL_PRIVATE_DEF_SEL(readMask, + "readMask"); +_MTL_PRIVATE_DEF_SEL(readWriteTextureSupport, + "readWriteTextureSupport"); +_MTL_PRIVATE_DEF_SEL(recommendedMaxWorkingSetSize, + "recommendedMaxWorkingSetSize"); +_MTL_PRIVATE_DEF_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_, + "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_options_, + "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:options:"); +_MTL_PRIVATE_DEF_SEL(registryID, + "registryID"); +_MTL_PRIVATE_DEF_SEL(remoteStorageBuffer, + "remoteStorageBuffer"); +_MTL_PRIVATE_DEF_SEL(remoteStorageTexture, + "remoteStorageTexture"); +_MTL_PRIVATE_DEF_SEL(removeAllAllocations, + "removeAllAllocations"); +_MTL_PRIVATE_DEF_SEL(removeAllDebugMarkers, + "removeAllDebugMarkers"); +_MTL_PRIVATE_DEF_SEL(removeAllocation_, + "removeAllocation:"); +_MTL_PRIVATE_DEF_SEL(removeAllocations_count_, + "removeAllocations:count:"); +_MTL_PRIVATE_DEF_SEL(removeResidencySet_, + "removeResidencySet:"); +_MTL_PRIVATE_DEF_SEL(removeResidencySets_count_, + "removeResidencySets:count:"); +_MTL_PRIVATE_DEF_SEL(renderCommandEncoder, + "renderCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(renderCommandEncoderWithDescriptor_, + "renderCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(renderPassDescriptor, + "renderPassDescriptor"); +_MTL_PRIVATE_DEF_SEL(renderTargetArrayLength, + "renderTargetArrayLength"); +_MTL_PRIVATE_DEF_SEL(renderTargetHeight, + "renderTargetHeight"); +_MTL_PRIVATE_DEF_SEL(renderTargetWidth, + "renderTargetWidth"); +_MTL_PRIVATE_DEF_SEL(replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage_, + "replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:"); +_MTL_PRIVATE_DEF_SEL(replaceRegion_mipmapLevel_withBytes_bytesPerRow_, + "replaceRegion:mipmapLevel:withBytes:bytesPerRow:"); +_MTL_PRIVATE_DEF_SEL(requestResidency, + "requestResidency"); +_MTL_PRIVATE_DEF_SEL(required, + "required"); +_MTL_PRIVATE_DEF_SEL(reset, + "reset"); +_MTL_PRIVATE_DEF_SEL(resetCommandsInBuffer_withRange_, + "resetCommandsInBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(resetTextureAccessCounters_region_mipLevel_slice_, + "resetTextureAccessCounters:region:mipLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(resetWithRange_, + "resetWithRange:"); +_MTL_PRIVATE_DEF_SEL(resolveCounterRange_, + "resolveCounterRange:"); +_MTL_PRIVATE_DEF_SEL(resolveCounters_inRange_destinationBuffer_destinationOffset_, + "resolveCounters:inRange:destinationBuffer:destinationOffset:"); +_MTL_PRIVATE_DEF_SEL(resolveDepthPlane, + "resolveDepthPlane"); +_MTL_PRIVATE_DEF_SEL(resolveLevel, + "resolveLevel"); +_MTL_PRIVATE_DEF_SEL(resolveSlice, + "resolveSlice"); +_MTL_PRIVATE_DEF_SEL(resolveTexture, + "resolveTexture"); +_MTL_PRIVATE_DEF_SEL(resourceOptions, + "resourceOptions"); +_MTL_PRIVATE_DEF_SEL(resourceStateCommandEncoder, + "resourceStateCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(resourceStateCommandEncoderWithDescriptor_, + "resourceStateCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(resourceStatePassDescriptor, + "resourceStatePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(retainedReferences, + "retainedReferences"); +_MTL_PRIVATE_DEF_SEL(rgbBlendOperation, + "rgbBlendOperation"); +_MTL_PRIVATE_DEF_SEL(rootResource, + "rootResource"); +_MTL_PRIVATE_DEF_SEL(sAddressMode, + "sAddressMode"); +_MTL_PRIVATE_DEF_SEL(sampleBuffer, + "sampleBuffer"); +_MTL_PRIVATE_DEF_SEL(sampleBufferAttachments, + "sampleBufferAttachments"); +_MTL_PRIVATE_DEF_SEL(sampleCount, + "sampleCount"); +_MTL_PRIVATE_DEF_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_, + "sampleCountersInBuffer:atSampleIndex:withBarrier:"); +_MTL_PRIVATE_DEF_SEL(sampleTimestamps_gpuTimestamp_, + "sampleTimestamps:gpuTimestamp:"); +_MTL_PRIVATE_DEF_SEL(scratchBufferAllocator, + "scratchBufferAllocator"); +_MTL_PRIVATE_DEF_SEL(screenSize, + "screenSize"); +_MTL_PRIVATE_DEF_SEL(segmentControlPointCount, + "segmentControlPointCount"); +_MTL_PRIVATE_DEF_SEL(segmentCount, + "segmentCount"); +_MTL_PRIVATE_DEF_SEL(serializeToURL_error_, + "serializeToURL:error:"); +_MTL_PRIVATE_DEF_SEL(setAccelerationStructure_atBufferIndex_, + "setAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setAccelerationStructure_atIndex_, + "setAccelerationStructure:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setAccess_, + "setAccess:"); +_MTL_PRIVATE_DEF_SEL(setAllowDuplicateIntersectionFunctionInvocation_, + "setAllowDuplicateIntersectionFunctionInvocation:"); +_MTL_PRIVATE_DEF_SEL(setAllowGPUOptimizedContents_, + "setAllowGPUOptimizedContents:"); +_MTL_PRIVATE_DEF_SEL(setAllowReferencingUndefinedSymbols_, + "setAllowReferencingUndefinedSymbols:"); +_MTL_PRIVATE_DEF_SEL(setAlphaBlendOperation_, + "setAlphaBlendOperation:"); +_MTL_PRIVATE_DEF_SEL(setAlphaToCoverageEnabled_, + "setAlphaToCoverageEnabled:"); +_MTL_PRIVATE_DEF_SEL(setAlphaToOneEnabled_, + "setAlphaToOneEnabled:"); +_MTL_PRIVATE_DEF_SEL(setArgumentBuffer_offset_, + "setArgumentBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(setArgumentBuffer_startOffset_arrayElement_, + "setArgumentBuffer:startOffset:arrayElement:"); +_MTL_PRIVATE_DEF_SEL(setArgumentIndex_, + "setArgumentIndex:"); +_MTL_PRIVATE_DEF_SEL(setArguments_, + "setArguments:"); +_MTL_PRIVATE_DEF_SEL(setArrayLength_, + "setArrayLength:"); +_MTL_PRIVATE_DEF_SEL(setAttributes_, + "setAttributes:"); +_MTL_PRIVATE_DEF_SEL(setBackFaceStencil_, + "setBackFaceStencil:"); +_MTL_PRIVATE_DEF_SEL(setBarrier, + "setBarrier"); +_MTL_PRIVATE_DEF_SEL(setBinaryArchives_, + "setBinaryArchives:"); +_MTL_PRIVATE_DEF_SEL(setBinaryFunctions_, + "setBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setBlendColorRed_green_blue_alpha_, + "setBlendColorRed:green:blue:alpha:"); +_MTL_PRIVATE_DEF_SEL(setBlendingEnabled_, + "setBlendingEnabled:"); +_MTL_PRIVATE_DEF_SEL(setBorderColor_, + "setBorderColor:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBuffer_, + "setBoundingBoxBuffer:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBufferOffset_, + "setBoundingBoxBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBuffers_, + "setBoundingBoxBuffers:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxCount_, + "setBoundingBoxCount:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxStride_, + "setBoundingBoxStride:"); +_MTL_PRIVATE_DEF_SEL(setBuffer_, + "setBuffer:"); +_MTL_PRIVATE_DEF_SEL(setBuffer_offset_atIndex_, + "setBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBuffer_offset_attributeStride_atIndex_, + "setBuffer:offset:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferIndex_, + "setBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferOffset_atIndex_, + "setBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferOffset_attributeStride_atIndex_, + "setBufferOffset:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferSize_, + "setBufferSize:"); +_MTL_PRIVATE_DEF_SEL(setBuffers_offsets_attributeStrides_withRange_, + "setBuffers:offsets:attributeStrides:withRange:"); +_MTL_PRIVATE_DEF_SEL(setBuffers_offsets_withRange_, + "setBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setBytes_length_atIndex_, + "setBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBytes_length_attributeStride_atIndex_, + "setBytes:length:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setCaptureObject_, + "setCaptureObject:"); +_MTL_PRIVATE_DEF_SEL(setClearColor_, + "setClearColor:"); +_MTL_PRIVATE_DEF_SEL(setClearDepth_, + "setClearDepth:"); +_MTL_PRIVATE_DEF_SEL(setClearStencil_, + "setClearStencil:"); +_MTL_PRIVATE_DEF_SEL(setColorStoreAction_atIndex_, + "setColorStoreAction:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setColorStoreActionOptions_atIndex_, + "setColorStoreActionOptions:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setCommandTypes_, + "setCommandTypes:"); +_MTL_PRIVATE_DEF_SEL(setCompareFunction_, + "setCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setCompileSymbolVisibility_, + "setCompileSymbolVisibility:"); +_MTL_PRIVATE_DEF_SEL(setCompressionType_, + "setCompressionType:"); +_MTL_PRIVATE_DEF_SEL(setComputeFunction_, + "setComputeFunction:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineState_, + "setComputePipelineState:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineState_atIndex_, + "setComputePipelineState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineStates_withRange_, + "setComputePipelineStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setConstantBlockAlignment_, + "setConstantBlockAlignment:"); +_MTL_PRIVATE_DEF_SEL(setConstantValue_type_atIndex_, + "setConstantValue:type:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setConstantValue_type_withName_, + "setConstantValue:type:withName:"); +_MTL_PRIVATE_DEF_SEL(setConstantValues_, + "setConstantValues:"); +_MTL_PRIVATE_DEF_SEL(setConstantValues_type_withRange_, + "setConstantValues:type:withRange:"); +_MTL_PRIVATE_DEF_SEL(setControlDependencies_, + "setControlDependencies:"); +_MTL_PRIVATE_DEF_SEL(setControlPointBuffer_, + "setControlPointBuffer:"); +_MTL_PRIVATE_DEF_SEL(setControlPointBufferOffset_, + "setControlPointBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setControlPointBuffers_, + "setControlPointBuffers:"); +_MTL_PRIVATE_DEF_SEL(setControlPointCount_, + "setControlPointCount:"); +_MTL_PRIVATE_DEF_SEL(setControlPointFormat_, + "setControlPointFormat:"); +_MTL_PRIVATE_DEF_SEL(setControlPointStride_, + "setControlPointStride:"); +_MTL_PRIVATE_DEF_SEL(setCounterSet_, + "setCounterSet:"); +_MTL_PRIVATE_DEF_SEL(setCpuCacheMode_, + "setCpuCacheMode:"); +_MTL_PRIVATE_DEF_SEL(setCullMode_, + "setCullMode:"); +_MTL_PRIVATE_DEF_SEL(setCurveBasis_, + "setCurveBasis:"); +_MTL_PRIVATE_DEF_SEL(setCurveEndCaps_, + "setCurveEndCaps:"); +_MTL_PRIVATE_DEF_SEL(setCurveType_, + "setCurveType:"); +_MTL_PRIVATE_DEF_SEL(setDataType_, + "setDataType:"); +_MTL_PRIVATE_DEF_SEL(setDefaultCaptureScope_, + "setDefaultCaptureScope:"); +_MTL_PRIVATE_DEF_SEL(setDefaultRasterSampleCount_, + "setDefaultRasterSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setDepth_, + "setDepth:"); +_MTL_PRIVATE_DEF_SEL(setDepthAttachment_, + "setDepthAttachment:"); +_MTL_PRIVATE_DEF_SEL(setDepthAttachmentPixelFormat_, + "setDepthAttachmentPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setDepthBias_slopeScale_clamp_, + "setDepthBias:slopeScale:clamp:"); +_MTL_PRIVATE_DEF_SEL(setDepthClipMode_, + "setDepthClipMode:"); +_MTL_PRIVATE_DEF_SEL(setDepthCompareFunction_, + "setDepthCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setDepthFailureOperation_, + "setDepthFailureOperation:"); +_MTL_PRIVATE_DEF_SEL(setDepthPlane_, + "setDepthPlane:"); +_MTL_PRIVATE_DEF_SEL(setDepthResolveFilter_, + "setDepthResolveFilter:"); +_MTL_PRIVATE_DEF_SEL(setDepthStencilPassOperation_, + "setDepthStencilPassOperation:"); +_MTL_PRIVATE_DEF_SEL(setDepthStencilState_, + "setDepthStencilState:"); +_MTL_PRIVATE_DEF_SEL(setDepthStoreAction_, + "setDepthStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setDepthStoreActionOptions_, + "setDepthStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setDepthWriteEnabled_, + "setDepthWriteEnabled:"); +_MTL_PRIVATE_DEF_SEL(setDestination_, + "setDestination:"); +_MTL_PRIVATE_DEF_SEL(setDestinationAlphaBlendFactor_, + "setDestinationAlphaBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setDestinationRGBBlendFactor_, + "setDestinationRGBBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setDispatchType_, + "setDispatchType:"); +_MTL_PRIVATE_DEF_SEL(setEnableLogging_, + "setEnableLogging:"); +_MTL_PRIVATE_DEF_SEL(setEndOfEncoderSampleIndex_, + "setEndOfEncoderSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setEndOfFragmentSampleIndex_, + "setEndOfFragmentSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setEndOfVertexSampleIndex_, + "setEndOfVertexSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setErrorOptions_, + "setErrorOptions:"); +_MTL_PRIVATE_DEF_SEL(setFastMathEnabled_, + "setFastMathEnabled:"); +_MTL_PRIVATE_DEF_SEL(setFormat_, + "setFormat:"); +_MTL_PRIVATE_DEF_SEL(setFragmentAccelerationStructure_atBufferIndex_, + "setFragmentAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentAdditionalBinaryFunctions_, + "setFragmentAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBuffer_offset_atIndex_, + "setFragmentBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBufferOffset_atIndex_, + "setFragmentBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBuffers_offsets_withRange_, + "setFragmentBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBytes_length_atIndex_, + "setFragmentBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentFunction_, + "setFragmentFunction:"); +_MTL_PRIVATE_DEF_SEL(setFragmentIntersectionFunctionTable_atBufferIndex_, + "setFragmentIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentIntersectionFunctionTables_withBufferRange_, + "setFragmentIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentLinkedFunctions_, + "setFragmentLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFragmentPreloadedLibraries_, + "setFragmentPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerState_atIndex_, + "setFragmentSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerStates_withRange_, + "setFragmentSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentTexture_atIndex_, + "setFragmentTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentTextures_withRange_, + "setFragmentTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentVisibleFunctionTable_atBufferIndex_, + "setFragmentVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentVisibleFunctionTables_withBufferRange_, + "setFragmentVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setFrontFaceStencil_, + "setFrontFaceStencil:"); +_MTL_PRIVATE_DEF_SEL(setFrontFacingWinding_, + "setFrontFacingWinding:"); +_MTL_PRIVATE_DEF_SEL(setFunction_atIndex_, + "setFunction:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFunctionCount_, + "setFunctionCount:"); +_MTL_PRIVATE_DEF_SEL(setFunctionGraphs_, + "setFunctionGraphs:"); +_MTL_PRIVATE_DEF_SEL(setFunctionName_, + "setFunctionName:"); +_MTL_PRIVATE_DEF_SEL(setFunctions_, + "setFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFunctions_withRange_, + "setFunctions:withRange:"); +_MTL_PRIVATE_DEF_SEL(setGeometryDescriptors_, + "setGeometryDescriptors:"); +_MTL_PRIVATE_DEF_SEL(setGroups_, + "setGroups:"); +_MTL_PRIVATE_DEF_SEL(setHazardTrackingMode_, + "setHazardTrackingMode:"); +_MTL_PRIVATE_DEF_SEL(setHeight_, + "setHeight:"); +_MTL_PRIVATE_DEF_SEL(setImageblockSampleLength_, + "setImageblockSampleLength:"); +_MTL_PRIVATE_DEF_SEL(setImageblockWidth_height_, + "setImageblockWidth:height:"); +_MTL_PRIVATE_DEF_SEL(setIndex_, + "setIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndexBuffer_, + "setIndexBuffer:"); +_MTL_PRIVATE_DEF_SEL(setIndexBufferIndex_, + "setIndexBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndexBufferOffset_, + "setIndexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setIndexType_, + "setIndexType:"); +_MTL_PRIVATE_DEF_SEL(setIndirectCommandBuffer_atIndex_, + "setIndirectCommandBuffer:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndirectCommandBuffers_withRange_, + "setIndirectCommandBuffers:withRange:"); +_MTL_PRIVATE_DEF_SEL(setInheritBuffers_, + "setInheritBuffers:"); +_MTL_PRIVATE_DEF_SEL(setInheritPipelineState_, + "setInheritPipelineState:"); +_MTL_PRIVATE_DEF_SEL(setInitialCapacity_, + "setInitialCapacity:"); +_MTL_PRIVATE_DEF_SEL(setInputPrimitiveTopology_, + "setInputPrimitiveTopology:"); +_MTL_PRIVATE_DEF_SEL(setInsertLibraries_, + "setInsertLibraries:"); +_MTL_PRIVATE_DEF_SEL(setInstallName_, + "setInstallName:"); +_MTL_PRIVATE_DEF_SEL(setInstanceCount_, + "setInstanceCount:"); +_MTL_PRIVATE_DEF_SEL(setInstanceCountBuffer_, + "setInstanceCountBuffer:"); +_MTL_PRIVATE_DEF_SEL(setInstanceCountBufferOffset_, + "setInstanceCountBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorBuffer_, + "setInstanceDescriptorBuffer:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorBufferOffset_, + "setInstanceDescriptorBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorStride_, + "setInstanceDescriptorStride:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorType_, + "setInstanceDescriptorType:"); +_MTL_PRIVATE_DEF_SEL(setInstanceTransformationMatrixLayout_, + "setInstanceTransformationMatrixLayout:"); +_MTL_PRIVATE_DEF_SEL(setInstancedAccelerationStructures_, + "setInstancedAccelerationStructures:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTable_atBufferIndex_, + "setIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTable_atIndex_, + "setIntersectionFunctionTable:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTableOffset_, + "setIntersectionFunctionTableOffset:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTables_withBufferRange_, + "setIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTables_withRange_, + "setIntersectionFunctionTables:withRange:"); +_MTL_PRIVATE_DEF_SEL(setKernelBuffer_offset_atIndex_, + "setKernelBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setKernelBuffer_offset_attributeStride_atIndex_, + "setKernelBuffer:offset:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setLabel_, + "setLabel:"); +_MTL_PRIVATE_DEF_SEL(setLanguageVersion_, + "setLanguageVersion:"); +_MTL_PRIVATE_DEF_SEL(setLayer_atIndex_, + "setLayer:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setLevel_, + "setLevel:"); +_MTL_PRIVATE_DEF_SEL(setLibraries_, + "setLibraries:"); +_MTL_PRIVATE_DEF_SEL(setLibraryType_, + "setLibraryType:"); +_MTL_PRIVATE_DEF_SEL(setLinkedFunctions_, + "setLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setLoadAction_, + "setLoadAction:"); +_MTL_PRIVATE_DEF_SEL(setLodAverage_, + "setLodAverage:"); +_MTL_PRIVATE_DEF_SEL(setLodMaxClamp_, + "setLodMaxClamp:"); +_MTL_PRIVATE_DEF_SEL(setLodMinClamp_, + "setLodMinClamp:"); +_MTL_PRIVATE_DEF_SEL(setLogState_, + "setLogState:"); +_MTL_PRIVATE_DEF_SEL(setMagFilter_, + "setMagFilter:"); +_MTL_PRIVATE_DEF_SEL(setMathFloatingPointFunctions_, + "setMathFloatingPointFunctions:"); +_MTL_PRIVATE_DEF_SEL(setMathMode_, + "setMathMode:"); +_MTL_PRIVATE_DEF_SEL(setMaxAnisotropy_, + "setMaxAnisotropy:"); +_MTL_PRIVATE_DEF_SEL(setMaxCallStackDepth_, + "setMaxCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMaxCommandBufferCount_, + "setMaxCommandBufferCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxCommandsInFlight_, + "setMaxCommandsInFlight:"); +_MTL_PRIVATE_DEF_SEL(setMaxFragmentBufferBindCount_, + "setMaxFragmentBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxFragmentCallStackDepth_, + "setMaxFragmentCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMaxInstanceCount_, + "setMaxInstanceCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxKernelBufferBindCount_, + "setMaxKernelBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxKernelThreadgroupMemoryBindCount_, + "setMaxKernelThreadgroupMemoryBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxMeshBufferBindCount_, + "setMaxMeshBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxMotionTransformCount_, + "setMaxMotionTransformCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxObjectBufferBindCount_, + "setMaxObjectBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxObjectThreadgroupMemoryBindCount_, + "setMaxObjectThreadgroupMemoryBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxTessellationFactor_, + "setMaxTessellationFactor:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadgroupsPerMeshGrid_, + "setMaxTotalThreadgroupsPerMeshGrid:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerMeshThreadgroup_, + "setMaxTotalThreadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerObjectThreadgroup_, + "setMaxTotalThreadsPerObjectThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerThreadgroup_, + "setMaxTotalThreadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexAmplificationCount_, + "setMaxVertexAmplificationCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexBufferBindCount_, + "setMaxVertexBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexCallStackDepth_, + "setMaxVertexCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMeshBuffer_offset_atIndex_, + "setMeshBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshBufferOffset_atIndex_, + "setMeshBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshBuffers_offsets_withRange_, + "setMeshBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshBytes_length_atIndex_, + "setMeshBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshFunction_, + "setMeshFunction:"); +_MTL_PRIVATE_DEF_SEL(setMeshLinkedFunctions_, + "setMeshLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerState_atIndex_, + "setMeshSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerStates_withRange_, + "setMeshSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshTexture_atIndex_, + "setMeshTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshTextures_withRange_, + "setMeshTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth_, + "setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setMinFilter_, + "setMinFilter:"); +_MTL_PRIVATE_DEF_SEL(setMipFilter_, + "setMipFilter:"); +_MTL_PRIVATE_DEF_SEL(setMipmapLevelCount_, + "setMipmapLevelCount:"); +_MTL_PRIVATE_DEF_SEL(setMotionEndBorderMode_, + "setMotionEndBorderMode:"); +_MTL_PRIVATE_DEF_SEL(setMotionEndTime_, + "setMotionEndTime:"); +_MTL_PRIVATE_DEF_SEL(setMotionKeyframeCount_, + "setMotionKeyframeCount:"); +_MTL_PRIVATE_DEF_SEL(setMotionStartBorderMode_, + "setMotionStartBorderMode:"); +_MTL_PRIVATE_DEF_SEL(setMotionStartTime_, + "setMotionStartTime:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformBuffer_, + "setMotionTransformBuffer:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformBufferOffset_, + "setMotionTransformBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformCount_, + "setMotionTransformCount:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformCountBuffer_, + "setMotionTransformCountBuffer:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformCountBufferOffset_, + "setMotionTransformCountBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformStride_, + "setMotionTransformStride:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformType_, + "setMotionTransformType:"); +_MTL_PRIVATE_DEF_SEL(setMutability_, + "setMutability:"); +_MTL_PRIVATE_DEF_SEL(setName_, + "setName:"); +_MTL_PRIVATE_DEF_SEL(setNodes_, + "setNodes:"); +_MTL_PRIVATE_DEF_SEL(setNormalizedCoordinates_, + "setNormalizedCoordinates:"); +_MTL_PRIVATE_DEF_SEL(setObject_atIndexedSubscript_, + "setObject:atIndexedSubscript:"); +_MTL_PRIVATE_DEF_SEL(setObjectBuffer_offset_atIndex_, + "setObjectBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectBufferOffset_atIndex_, + "setObjectBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectBuffers_offsets_withRange_, + "setObjectBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectBytes_length_atIndex_, + "setObjectBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectFunction_, + "setObjectFunction:"); +_MTL_PRIVATE_DEF_SEL(setObjectLinkedFunctions_, + "setObjectLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerState_atIndex_, + "setObjectSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerStates_withRange_, + "setObjectSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectTexture_atIndex_, + "setObjectTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectTextures_withRange_, + "setObjectTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectThreadgroupMemoryLength_atIndex_, + "setObjectThreadgroupMemoryLength:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth_, + "setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setOffset_, + "setOffset:"); +_MTL_PRIVATE_DEF_SEL(setOpaque_, + "setOpaque:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueCurveIntersectionFunctionWithSignature_atIndex_, + "setOpaqueCurveIntersectionFunctionWithSignature:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueCurveIntersectionFunctionWithSignature_withRange_, + "setOpaqueCurveIntersectionFunctionWithSignature:withRange:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_atIndex_, + "setOpaqueTriangleIntersectionFunctionWithSignature:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_withRange_, + "setOpaqueTriangleIntersectionFunctionWithSignature:withRange:"); +_MTL_PRIVATE_DEF_SEL(setOptimizationLevel_, + "setOptimizationLevel:"); +_MTL_PRIVATE_DEF_SEL(setOptions_, + "setOptions:"); +_MTL_PRIVATE_DEF_SEL(setOutputNode_, + "setOutputNode:"); +_MTL_PRIVATE_DEF_SEL(setOutputURL_, + "setOutputURL:"); +_MTL_PRIVATE_DEF_SEL(setOwnerWithIdentity_, + "setOwnerWithIdentity:"); +_MTL_PRIVATE_DEF_SEL(setPayloadMemoryLength_, + "setPayloadMemoryLength:"); +_MTL_PRIVATE_DEF_SEL(setPixelFormat_, + "setPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setPreloadedLibraries_, + "setPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setPreprocessorMacros_, + "setPreprocessorMacros:"); +_MTL_PRIVATE_DEF_SEL(setPreserveInvariance_, + "setPreserveInvariance:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataBuffer_, + "setPrimitiveDataBuffer:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataBufferOffset_, + "setPrimitiveDataBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataElementSize_, + "setPrimitiveDataElementSize:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataStride_, + "setPrimitiveDataStride:"); +_MTL_PRIVATE_DEF_SEL(setPriority_, + "setPriority:"); +_MTL_PRIVATE_DEF_SEL(setPrivateFunctions_, + "setPrivateFunctions:"); +_MTL_PRIVATE_DEF_SEL(setPurgeableState_, + "setPurgeableState:"); +_MTL_PRIVATE_DEF_SEL(setRAddressMode_, + "setRAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setRadiusBuffer_, + "setRadiusBuffer:"); +_MTL_PRIVATE_DEF_SEL(setRadiusBufferOffset_, + "setRadiusBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setRadiusBuffers_, + "setRadiusBuffers:"); +_MTL_PRIVATE_DEF_SEL(setRadiusFormat_, + "setRadiusFormat:"); +_MTL_PRIVATE_DEF_SEL(setRadiusStride_, + "setRadiusStride:"); +_MTL_PRIVATE_DEF_SEL(setRasterSampleCount_, + "setRasterSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setRasterizationEnabled_, + "setRasterizationEnabled:"); +_MTL_PRIVATE_DEF_SEL(setRasterizationRateMap_, + "setRasterizationRateMap:"); +_MTL_PRIVATE_DEF_SEL(setReadMask_, + "setReadMask:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineState_, + "setRenderPipelineState:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineState_atIndex_, + "setRenderPipelineState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineStates_withRange_, + "setRenderPipelineStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetArrayLength_, + "setRenderTargetArrayLength:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetHeight_, + "setRenderTargetHeight:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetWidth_, + "setRenderTargetWidth:"); +_MTL_PRIVATE_DEF_SEL(setResolveDepthPlane_, + "setResolveDepthPlane:"); +_MTL_PRIVATE_DEF_SEL(setResolveLevel_, + "setResolveLevel:"); +_MTL_PRIVATE_DEF_SEL(setResolveSlice_, + "setResolveSlice:"); +_MTL_PRIVATE_DEF_SEL(setResolveTexture_, + "setResolveTexture:"); +_MTL_PRIVATE_DEF_SEL(setResourceOptions_, + "setResourceOptions:"); +_MTL_PRIVATE_DEF_SEL(setRetainedReferences_, + "setRetainedReferences:"); +_MTL_PRIVATE_DEF_SEL(setRgbBlendOperation_, + "setRgbBlendOperation:"); +_MTL_PRIVATE_DEF_SEL(setSAddressMode_, + "setSAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setSampleBuffer_, + "setSampleBuffer:"); +_MTL_PRIVATE_DEF_SEL(setSampleCount_, + "setSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setSamplePositions_count_, + "setSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(setSamplerState_atIndex_, + "setSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setSamplerStates_withRange_, + "setSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setScissorRect_, + "setScissorRect:"); +_MTL_PRIVATE_DEF_SEL(setScissorRects_count_, + "setScissorRects:count:"); +_MTL_PRIVATE_DEF_SEL(setScratchBufferAllocator_, + "setScratchBufferAllocator:"); +_MTL_PRIVATE_DEF_SEL(setScreenSize_, + "setScreenSize:"); +_MTL_PRIVATE_DEF_SEL(setSegmentControlPointCount_, + "setSegmentControlPointCount:"); +_MTL_PRIVATE_DEF_SEL(setSegmentCount_, + "setSegmentCount:"); +_MTL_PRIVATE_DEF_SEL(setShaderValidation_, + "setShaderValidation:"); +_MTL_PRIVATE_DEF_SEL(setShouldMaximizeConcurrentCompilation_, + "setShouldMaximizeConcurrentCompilation:"); +_MTL_PRIVATE_DEF_SEL(setSignaledValue_, + "setSignaledValue:"); +_MTL_PRIVATE_DEF_SEL(setSize_, + "setSize:"); +_MTL_PRIVATE_DEF_SEL(setSlice_, + "setSlice:"); +_MTL_PRIVATE_DEF_SEL(setSourceAlphaBlendFactor_, + "setSourceAlphaBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setSourceRGBBlendFactor_, + "setSourceRGBBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setSparsePageSize_, + "setSparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(setSpecializedName_, + "setSpecializedName:"); +_MTL_PRIVATE_DEF_SEL(setStageInRegion_, + "setStageInRegion:"); +_MTL_PRIVATE_DEF_SEL(setStageInRegionWithIndirectBuffer_indirectBufferOffset_, + "setStageInRegionWithIndirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setStageInputDescriptor_, + "setStageInputDescriptor:"); +_MTL_PRIVATE_DEF_SEL(setStartOfEncoderSampleIndex_, + "setStartOfEncoderSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStartOfFragmentSampleIndex_, + "setStartOfFragmentSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStartOfVertexSampleIndex_, + "setStartOfVertexSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStencilAttachment_, + "setStencilAttachment:"); +_MTL_PRIVATE_DEF_SEL(setStencilAttachmentPixelFormat_, + "setStencilAttachmentPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setStencilCompareFunction_, + "setStencilCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setStencilFailureOperation_, + "setStencilFailureOperation:"); +_MTL_PRIVATE_DEF_SEL(setStencilFrontReferenceValue_backReferenceValue_, + "setStencilFrontReferenceValue:backReferenceValue:"); +_MTL_PRIVATE_DEF_SEL(setStencilReferenceValue_, + "setStencilReferenceValue:"); +_MTL_PRIVATE_DEF_SEL(setStencilResolveFilter_, + "setStencilResolveFilter:"); +_MTL_PRIVATE_DEF_SEL(setStencilStoreAction_, + "setStencilStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setStencilStoreActionOptions_, + "setStencilStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setStepFunction_, + "setStepFunction:"); +_MTL_PRIVATE_DEF_SEL(setStepRate_, + "setStepRate:"); +_MTL_PRIVATE_DEF_SEL(setStorageMode_, + "setStorageMode:"); +_MTL_PRIVATE_DEF_SEL(setStoreAction_, + "setStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setStoreActionOptions_, + "setStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setStride_, + "setStride:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingBinaryFunctions_, + "setSupportAddingBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingFragmentBinaryFunctions_, + "setSupportAddingFragmentBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingVertexBinaryFunctions_, + "setSupportAddingVertexBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportArgumentBuffers_, + "setSupportArgumentBuffers:"); +_MTL_PRIVATE_DEF_SEL(setSupportDynamicAttributeStride_, + "setSupportDynamicAttributeStride:"); +_MTL_PRIVATE_DEF_SEL(setSupportIndirectCommandBuffers_, + "setSupportIndirectCommandBuffers:"); +_MTL_PRIVATE_DEF_SEL(setSupportRayTracing_, + "setSupportRayTracing:"); +_MTL_PRIVATE_DEF_SEL(setSwizzle_, + "setSwizzle:"); +_MTL_PRIVATE_DEF_SEL(setTAddressMode_, + "setTAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setTessellationControlPointIndexType_, + "setTessellationControlPointIndexType:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorBuffer_offset_instanceStride_, + "setTessellationFactorBuffer:offset:instanceStride:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorFormat_, + "setTessellationFactorFormat:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorScale_, + "setTessellationFactorScale:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorScaleEnabled_, + "setTessellationFactorScaleEnabled:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorStepFunction_, + "setTessellationFactorStepFunction:"); +_MTL_PRIVATE_DEF_SEL(setTessellationOutputWindingOrder_, + "setTessellationOutputWindingOrder:"); +_MTL_PRIVATE_DEF_SEL(setTessellationPartitionMode_, + "setTessellationPartitionMode:"); +_MTL_PRIVATE_DEF_SEL(setTexture_, + "setTexture:"); +_MTL_PRIVATE_DEF_SEL(setTexture_atIndex_, + "setTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTextureType_, + "setTextureType:"); +_MTL_PRIVATE_DEF_SEL(setTextures_withRange_, + "setTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setThreadGroupSizeIsMultipleOfThreadExecutionWidth_, + "setThreadGroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_, + "setThreadgroupMemoryLength:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_atIndex_, + "setThreadgroupMemoryLength:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_offset_atIndex_, + "setThreadgroupMemoryLength:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupSizeMatchesTileSize_, + "setThreadgroupSizeMatchesTileSize:"); +_MTL_PRIVATE_DEF_SEL(setTileAccelerationStructure_atBufferIndex_, + "setTileAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileAdditionalBinaryFunctions_, + "setTileAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setTileBuffer_offset_atIndex_, + "setTileBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileBufferOffset_atIndex_, + "setTileBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileBuffers_offsets_withRange_, + "setTileBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileBytes_length_atIndex_, + "setTileBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileFunction_, + "setTileFunction:"); +_MTL_PRIVATE_DEF_SEL(setTileHeight_, + "setTileHeight:"); +_MTL_PRIVATE_DEF_SEL(setTileIntersectionFunctionTable_atBufferIndex_, + "setTileIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileIntersectionFunctionTables_withBufferRange_, + "setTileIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerState_atIndex_, + "setTileSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerStates_withRange_, + "setTileSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileTexture_atIndex_, + "setTileTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileTextures_withRange_, + "setTileTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileVisibleFunctionTable_atBufferIndex_, + "setTileVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileVisibleFunctionTables_withBufferRange_, + "setTileVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setTileWidth_, + "setTileWidth:"); +_MTL_PRIVATE_DEF_SEL(setTransformationMatrixBuffer_, + "setTransformationMatrixBuffer:"); +_MTL_PRIVATE_DEF_SEL(setTransformationMatrixBufferOffset_, + "setTransformationMatrixBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setTransformationMatrixLayout_, + "setTransformationMatrixLayout:"); +_MTL_PRIVATE_DEF_SEL(setTriangleCount_, + "setTriangleCount:"); +_MTL_PRIVATE_DEF_SEL(setTriangleFillMode_, + "setTriangleFillMode:"); +_MTL_PRIVATE_DEF_SEL(setType_, + "setType:"); +_MTL_PRIVATE_DEF_SEL(setUrl_, + "setUrl:"); +_MTL_PRIVATE_DEF_SEL(setUsage_, + "setUsage:"); +_MTL_PRIVATE_DEF_SEL(setVertexAccelerationStructure_atBufferIndex_, + "setVertexAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexAdditionalBinaryFunctions_, + "setVertexAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setVertexAmplificationCount_viewMappings_, + "setVertexAmplificationCount:viewMappings:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffer_, + "setVertexBuffer:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffer_offset_atIndex_, + "setVertexBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffer_offset_attributeStride_atIndex_, + "setVertexBuffer:offset:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_, + "setVertexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_atIndex_, + "setVertexBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_attributeStride_atIndex_, + "setVertexBufferOffset:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffers_, + "setVertexBuffers:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffers_offsets_attributeStrides_withRange_, + "setVertexBuffers:offsets:attributeStrides:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffers_offsets_withRange_, + "setVertexBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexBytes_length_atIndex_, + "setVertexBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBytes_length_attributeStride_atIndex_, + "setVertexBytes:length:attributeStride:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexDescriptor_, + "setVertexDescriptor:"); +_MTL_PRIVATE_DEF_SEL(setVertexFormat_, + "setVertexFormat:"); +_MTL_PRIVATE_DEF_SEL(setVertexFunction_, + "setVertexFunction:"); +_MTL_PRIVATE_DEF_SEL(setVertexIntersectionFunctionTable_atBufferIndex_, + "setVertexIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexIntersectionFunctionTables_withBufferRange_, + "setVertexIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexLinkedFunctions_, + "setVertexLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setVertexPreloadedLibraries_, + "setVertexPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerState_atIndex_, + "setVertexSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerStates_withRange_, + "setVertexSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexStride_, + "setVertexStride:"); +_MTL_PRIVATE_DEF_SEL(setVertexTexture_atIndex_, + "setVertexTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexTextures_withRange_, + "setVertexTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexVisibleFunctionTable_atBufferIndex_, + "setVertexVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexVisibleFunctionTables_withBufferRange_, + "setVertexVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setViewport_, + "setViewport:"); +_MTL_PRIVATE_DEF_SEL(setViewports_count_, + "setViewports:count:"); +_MTL_PRIVATE_DEF_SEL(setVisibilityResultBuffer_, + "setVisibilityResultBuffer:"); +_MTL_PRIVATE_DEF_SEL(setVisibilityResultMode_offset_, + "setVisibilityResultMode:offset:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTable_atBufferIndex_, + "setVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTable_atIndex_, + "setVisibleFunctionTable:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTables_withBufferRange_, + "setVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTables_withRange_, + "setVisibleFunctionTables:withRange:"); +_MTL_PRIVATE_DEF_SEL(setWidth_, + "setWidth:"); +_MTL_PRIVATE_DEF_SEL(setWriteMask_, + "setWriteMask:"); +_MTL_PRIVATE_DEF_SEL(shaderValidation, + "shaderValidation"); +_MTL_PRIVATE_DEF_SEL(sharedCaptureManager, + "sharedCaptureManager"); +_MTL_PRIVATE_DEF_SEL(shouldMaximizeConcurrentCompilation, + "shouldMaximizeConcurrentCompilation"); +_MTL_PRIVATE_DEF_SEL(signalEvent_value_, + "signalEvent:value:"); +_MTL_PRIVATE_DEF_SEL(signaledValue, + "signaledValue"); +_MTL_PRIVATE_DEF_SEL(size, + "size"); +_MTL_PRIVATE_DEF_SEL(slice, + "slice"); +_MTL_PRIVATE_DEF_SEL(sourceAlphaBlendFactor, + "sourceAlphaBlendFactor"); +_MTL_PRIVATE_DEF_SEL(sourceRGBBlendFactor, + "sourceRGBBlendFactor"); +_MTL_PRIVATE_DEF_SEL(sparsePageSize, + "sparsePageSize"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeInBytes, + "sparseTileSizeInBytes"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeInBytesForSparsePageSize_, + "sparseTileSizeInBytesForSparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_, + "sparseTileSizeWithTextureType:pixelFormat:sampleCount:"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize_, + "sparseTileSizeWithTextureType:pixelFormat:sampleCount:sparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(specializedName, + "specializedName"); +_MTL_PRIVATE_DEF_SEL(stageInputAttributes, + "stageInputAttributes"); +_MTL_PRIVATE_DEF_SEL(stageInputDescriptor, + "stageInputDescriptor"); +_MTL_PRIVATE_DEF_SEL(stageInputOutputDescriptor, + "stageInputOutputDescriptor"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithCommandQueue_, + "startCaptureWithCommandQueue:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithDescriptor_error_, + "startCaptureWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithDevice_, + "startCaptureWithDevice:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithScope_, + "startCaptureWithScope:"); +_MTL_PRIVATE_DEF_SEL(startOfEncoderSampleIndex, + "startOfEncoderSampleIndex"); +_MTL_PRIVATE_DEF_SEL(startOfFragmentSampleIndex, + "startOfFragmentSampleIndex"); +_MTL_PRIVATE_DEF_SEL(startOfVertexSampleIndex, + "startOfVertexSampleIndex"); +_MTL_PRIVATE_DEF_SEL(staticThreadgroupMemoryLength, + "staticThreadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(status, + "status"); +_MTL_PRIVATE_DEF_SEL(stencilAttachment, + "stencilAttachment"); +_MTL_PRIVATE_DEF_SEL(stencilAttachmentPixelFormat, + "stencilAttachmentPixelFormat"); +_MTL_PRIVATE_DEF_SEL(stencilCompareFunction, + "stencilCompareFunction"); +_MTL_PRIVATE_DEF_SEL(stencilFailureOperation, + "stencilFailureOperation"); +_MTL_PRIVATE_DEF_SEL(stencilResolveFilter, + "stencilResolveFilter"); +_MTL_PRIVATE_DEF_SEL(stepFunction, + "stepFunction"); +_MTL_PRIVATE_DEF_SEL(stepRate, + "stepRate"); +_MTL_PRIVATE_DEF_SEL(stopCapture, + "stopCapture"); +_MTL_PRIVATE_DEF_SEL(storageMode, + "storageMode"); +_MTL_PRIVATE_DEF_SEL(storeAction, + "storeAction"); +_MTL_PRIVATE_DEF_SEL(storeActionOptions, + "storeActionOptions"); +_MTL_PRIVATE_DEF_SEL(stride, + "stride"); +_MTL_PRIVATE_DEF_SEL(structType, + "structType"); +_MTL_PRIVATE_DEF_SEL(supportAddingBinaryFunctions, + "supportAddingBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportAddingFragmentBinaryFunctions, + "supportAddingFragmentBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportAddingVertexBinaryFunctions, + "supportAddingVertexBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportArgumentBuffers, + "supportArgumentBuffers"); +_MTL_PRIVATE_DEF_SEL(supportDynamicAttributeStride, + "supportDynamicAttributeStride"); +_MTL_PRIVATE_DEF_SEL(supportIndirectCommandBuffers, + "supportIndirectCommandBuffers"); +_MTL_PRIVATE_DEF_SEL(supportRayTracing, + "supportRayTracing"); +_MTL_PRIVATE_DEF_SEL(supports32BitFloatFiltering, + "supports32BitFloatFiltering"); +_MTL_PRIVATE_DEF_SEL(supports32BitMSAA, + "supports32BitMSAA"); +_MTL_PRIVATE_DEF_SEL(supportsBCTextureCompression, + "supportsBCTextureCompression"); +_MTL_PRIVATE_DEF_SEL(supportsCounterSampling_, + "supportsCounterSampling:"); +_MTL_PRIVATE_DEF_SEL(supportsDestination_, + "supportsDestination:"); +_MTL_PRIVATE_DEF_SEL(supportsDynamicLibraries, + "supportsDynamicLibraries"); +_MTL_PRIVATE_DEF_SEL(supportsFamily_, + "supportsFamily:"); +_MTL_PRIVATE_DEF_SEL(supportsFeatureSet_, + "supportsFeatureSet:"); +_MTL_PRIVATE_DEF_SEL(supportsFunctionPointers, + "supportsFunctionPointers"); +_MTL_PRIVATE_DEF_SEL(supportsFunctionPointersFromRender, + "supportsFunctionPointersFromRender"); +_MTL_PRIVATE_DEF_SEL(supportsPrimitiveMotionBlur, + "supportsPrimitiveMotionBlur"); +_MTL_PRIVATE_DEF_SEL(supportsPullModelInterpolation, + "supportsPullModelInterpolation"); +_MTL_PRIVATE_DEF_SEL(supportsQueryTextureLOD, + "supportsQueryTextureLOD"); +_MTL_PRIVATE_DEF_SEL(supportsRasterizationRateMapWithLayerCount_, + "supportsRasterizationRateMapWithLayerCount:"); +_MTL_PRIVATE_DEF_SEL(supportsRaytracing, + "supportsRaytracing"); +_MTL_PRIVATE_DEF_SEL(supportsRaytracingFromRender, + "supportsRaytracingFromRender"); +_MTL_PRIVATE_DEF_SEL(supportsRenderDynamicLibraries, + "supportsRenderDynamicLibraries"); +_MTL_PRIVATE_DEF_SEL(supportsShaderBarycentricCoordinates, + "supportsShaderBarycentricCoordinates"); +_MTL_PRIVATE_DEF_SEL(supportsTextureSampleCount_, + "supportsTextureSampleCount:"); +_MTL_PRIVATE_DEF_SEL(supportsVertexAmplificationCount_, + "supportsVertexAmplificationCount:"); +_MTL_PRIVATE_DEF_SEL(swizzle, + "swizzle"); +_MTL_PRIVATE_DEF_SEL(synchronizeResource_, + "synchronizeResource:"); +_MTL_PRIVATE_DEF_SEL(synchronizeTexture_slice_level_, + "synchronizeTexture:slice:level:"); +_MTL_PRIVATE_DEF_SEL(tAddressMode, + "tAddressMode"); +_MTL_PRIVATE_DEF_SEL(tailSizeInBytes, + "tailSizeInBytes"); +_MTL_PRIVATE_DEF_SEL(tessellationControlPointIndexType, + "tessellationControlPointIndexType"); +_MTL_PRIVATE_DEF_SEL(tessellationFactorFormat, + "tessellationFactorFormat"); +_MTL_PRIVATE_DEF_SEL(tessellationFactorStepFunction, + "tessellationFactorStepFunction"); +_MTL_PRIVATE_DEF_SEL(tessellationOutputWindingOrder, + "tessellationOutputWindingOrder"); +_MTL_PRIVATE_DEF_SEL(tessellationPartitionMode, + "tessellationPartitionMode"); +_MTL_PRIVATE_DEF_SEL(texture, + "texture"); +_MTL_PRIVATE_DEF_SEL(texture2DDescriptorWithPixelFormat_width_height_mipmapped_, + "texture2DDescriptorWithPixelFormat:width:height:mipmapped:"); +_MTL_PRIVATE_DEF_SEL(textureBarrier, + "textureBarrier"); +_MTL_PRIVATE_DEF_SEL(textureBufferDescriptorWithPixelFormat_width_resourceOptions_usage_, + "textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:"); +_MTL_PRIVATE_DEF_SEL(textureCubeDescriptorWithPixelFormat_size_mipmapped_, + "textureCubeDescriptorWithPixelFormat:size:mipmapped:"); +_MTL_PRIVATE_DEF_SEL(textureDataType, + "textureDataType"); +_MTL_PRIVATE_DEF_SEL(textureReferenceType, + "textureReferenceType"); +_MTL_PRIVATE_DEF_SEL(textureType, + "textureType"); +_MTL_PRIVATE_DEF_SEL(threadExecutionWidth, + "threadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(threadGroupSizeIsMultipleOfThreadExecutionWidth, + "threadGroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryAlignment, + "threadgroupMemoryAlignment"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryDataSize, + "threadgroupMemoryDataSize"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryLength, + "threadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(threadgroupSizeMatchesTileSize, + "threadgroupSizeMatchesTileSize"); +_MTL_PRIVATE_DEF_SEL(tileAdditionalBinaryFunctions, + "tileAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(tileArguments, + "tileArguments"); +_MTL_PRIVATE_DEF_SEL(tileBindings, + "tileBindings"); +_MTL_PRIVATE_DEF_SEL(tileBuffers, + "tileBuffers"); +_MTL_PRIVATE_DEF_SEL(tileFunction, + "tileFunction"); +_MTL_PRIVATE_DEF_SEL(tileHeight, + "tileHeight"); +_MTL_PRIVATE_DEF_SEL(tileWidth, + "tileWidth"); +_MTL_PRIVATE_DEF_SEL(transformationMatrixBuffer, + "transformationMatrixBuffer"); +_MTL_PRIVATE_DEF_SEL(transformationMatrixBufferOffset, + "transformationMatrixBufferOffset"); +_MTL_PRIVATE_DEF_SEL(transformationMatrixLayout, + "transformationMatrixLayout"); +_MTL_PRIVATE_DEF_SEL(triangleCount, + "triangleCount"); +_MTL_PRIVATE_DEF_SEL(tryCancel, + "tryCancel"); +_MTL_PRIVATE_DEF_SEL(type, + "type"); +_MTL_PRIVATE_DEF_SEL(updateFence_, + "updateFence:"); +_MTL_PRIVATE_DEF_SEL(updateFence_afterStages_, + "updateFence:afterStages:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_, + "updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMapping_mode_region_mipLevel_slice_, + "updateTextureMapping:mode:region:mipLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_, + "updateTextureMappings:mode:regions:mipLevels:slices:numRegions:"); +_MTL_PRIVATE_DEF_SEL(url, + "url"); +_MTL_PRIVATE_DEF_SEL(usage, + "usage"); +_MTL_PRIVATE_DEF_SEL(useHeap_, + "useHeap:"); +_MTL_PRIVATE_DEF_SEL(useHeap_stages_, + "useHeap:stages:"); +_MTL_PRIVATE_DEF_SEL(useHeaps_count_, + "useHeaps:count:"); +_MTL_PRIVATE_DEF_SEL(useHeaps_count_stages_, + "useHeaps:count:stages:"); +_MTL_PRIVATE_DEF_SEL(useResidencySet_, + "useResidencySet:"); +_MTL_PRIVATE_DEF_SEL(useResidencySets_count_, + "useResidencySets:count:"); +_MTL_PRIVATE_DEF_SEL(useResource_usage_, + "useResource:usage:"); +_MTL_PRIVATE_DEF_SEL(useResource_usage_stages_, + "useResource:usage:stages:"); +_MTL_PRIVATE_DEF_SEL(useResources_count_usage_, + "useResources:count:usage:"); +_MTL_PRIVATE_DEF_SEL(useResources_count_usage_stages_, + "useResources:count:usage:stages:"); +_MTL_PRIVATE_DEF_SEL(usedSize, + "usedSize"); +_MTL_PRIVATE_DEF_SEL(vertexAdditionalBinaryFunctions, + "vertexAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(vertexArguments, + "vertexArguments"); +_MTL_PRIVATE_DEF_SEL(vertexAttributes, + "vertexAttributes"); +_MTL_PRIVATE_DEF_SEL(vertexBindings, + "vertexBindings"); +_MTL_PRIVATE_DEF_SEL(vertexBuffer, + "vertexBuffer"); +_MTL_PRIVATE_DEF_SEL(vertexBufferOffset, + "vertexBufferOffset"); +_MTL_PRIVATE_DEF_SEL(vertexBuffers, + "vertexBuffers"); +_MTL_PRIVATE_DEF_SEL(vertexDescriptor, + "vertexDescriptor"); +_MTL_PRIVATE_DEF_SEL(vertexFormat, + "vertexFormat"); +_MTL_PRIVATE_DEF_SEL(vertexFunction, + "vertexFunction"); +_MTL_PRIVATE_DEF_SEL(vertexLinkedFunctions, + "vertexLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(vertexPreloadedLibraries, + "vertexPreloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(vertexStride, + "vertexStride"); +_MTL_PRIVATE_DEF_SEL(vertical, + "vertical"); +_MTL_PRIVATE_DEF_SEL(verticalSampleStorage, + "verticalSampleStorage"); +_MTL_PRIVATE_DEF_SEL(visibilityResultBuffer, + "visibilityResultBuffer"); +_MTL_PRIVATE_DEF_SEL(visibleFunctionTableDescriptor, + "visibleFunctionTableDescriptor"); +_MTL_PRIVATE_DEF_SEL(waitForEvent_value_, + "waitForEvent:value:"); +_MTL_PRIVATE_DEF_SEL(waitForFence_, + "waitForFence:"); +_MTL_PRIVATE_DEF_SEL(waitForFence_beforeStages_, + "waitForFence:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(waitUntilCompleted, + "waitUntilCompleted"); +_MTL_PRIVATE_DEF_SEL(waitUntilScheduled, + "waitUntilScheduled"); +_MTL_PRIVATE_DEF_SEL(waitUntilSignaledValue_timeoutMS_, + "waitUntilSignaledValue:timeoutMS:"); +_MTL_PRIVATE_DEF_SEL(width, + "width"); +_MTL_PRIVATE_DEF_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_, + "writeCompactedAccelerationStructureSize:toBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_sizeDataType_, + "writeCompactedAccelerationStructureSize:toBuffer:offset:sizeDataType:"); +_MTL_PRIVATE_DEF_SEL(writeMask, + "writeMask"); + +} + +#include +#include + +namespace MTL +{ +using DrawablePresentedHandler = void (^)(class Drawable*); + +using DrawablePresentedHandlerFunction = std::function; + +class Drawable : public NS::Referencing +{ +public: + void addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function); + + void present(); + + void presentAtTime(CFTimeInterval presentationTime); + + void presentAfterMinimumDuration(CFTimeInterval duration); + + void addPresentedHandler(const MTL::DrawablePresentedHandler block); + + CFTimeInterval presentedTime() const; + + NS::UInteger drawableID() const; +}; + +} + +_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function) +{ + __block DrawablePresentedHandlerFunction blockFunction = function; + + addPresentedHandler(^(Drawable* pDrawable) { blockFunction(pDrawable); }); +} + +_MTL_INLINE void MTL::Drawable::present() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(present)); +} + +_MTL_INLINE void MTL::Drawable::presentAtTime(CFTimeInterval presentationTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentAtTime_), presentationTime); +} + +_MTL_INLINE void MTL::Drawable::presentAfterMinimumDuration(CFTimeInterval duration) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentAfterMinimumDuration_), duration); +} + +_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addPresentedHandler_), block); +} + +_MTL_INLINE CFTimeInterval MTL::Drawable::presentedTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(presentedTime)); +} + +_MTL_INLINE NS::UInteger MTL::Drawable::drawableID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(drawableID)); +} + +#pragma once + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PixelFormat) { + PixelFormatInvalid = 0, + PixelFormatA8Unorm = 1, + PixelFormatR8Unorm = 10, + PixelFormatR8Unorm_sRGB = 11, + PixelFormatR8Snorm = 12, + PixelFormatR8Uint = 13, + PixelFormatR8Sint = 14, + PixelFormatR16Unorm = 20, + PixelFormatR16Snorm = 22, + PixelFormatR16Uint = 23, + PixelFormatR16Sint = 24, + PixelFormatR16Float = 25, + PixelFormatRG8Unorm = 30, + PixelFormatRG8Unorm_sRGB = 31, + PixelFormatRG8Snorm = 32, + PixelFormatRG8Uint = 33, + PixelFormatRG8Sint = 34, + PixelFormatB5G6R5Unorm = 40, + PixelFormatA1BGR5Unorm = 41, + PixelFormatABGR4Unorm = 42, + PixelFormatBGR5A1Unorm = 43, + PixelFormatR32Uint = 53, + PixelFormatR32Sint = 54, + PixelFormatR32Float = 55, + PixelFormatRG16Unorm = 60, + PixelFormatRG16Snorm = 62, + PixelFormatRG16Uint = 63, + PixelFormatRG16Sint = 64, + PixelFormatRG16Float = 65, + PixelFormatRGBA8Unorm = 70, + PixelFormatRGBA8Unorm_sRGB = 71, + PixelFormatRGBA8Snorm = 72, + PixelFormatRGBA8Uint = 73, + PixelFormatRGBA8Sint = 74, + PixelFormatBGRA8Unorm = 80, + PixelFormatBGRA8Unorm_sRGB = 81, + PixelFormatRGB10A2Unorm = 90, + PixelFormatRGB10A2Uint = 91, + PixelFormatRG11B10Float = 92, + PixelFormatRGB9E5Float = 93, + PixelFormatBGR10A2Unorm = 94, + PixelFormatBGR10_XR = 554, + PixelFormatBGR10_XR_sRGB = 555, + PixelFormatRG32Uint = 103, + PixelFormatRG32Sint = 104, + PixelFormatRG32Float = 105, + PixelFormatRGBA16Unorm = 110, + PixelFormatRGBA16Snorm = 112, + PixelFormatRGBA16Uint = 113, + PixelFormatRGBA16Sint = 114, + PixelFormatRGBA16Float = 115, + PixelFormatBGRA10_XR = 552, + PixelFormatBGRA10_XR_sRGB = 553, + PixelFormatRGBA32Uint = 123, + PixelFormatRGBA32Sint = 124, + PixelFormatRGBA32Float = 125, + PixelFormatBC1_RGBA = 130, + PixelFormatBC1_RGBA_sRGB = 131, + PixelFormatBC2_RGBA = 132, + PixelFormatBC2_RGBA_sRGB = 133, + PixelFormatBC3_RGBA = 134, + PixelFormatBC3_RGBA_sRGB = 135, + PixelFormatBC4_RUnorm = 140, + PixelFormatBC4_RSnorm = 141, + PixelFormatBC5_RGUnorm = 142, + PixelFormatBC5_RGSnorm = 143, + PixelFormatBC6H_RGBFloat = 150, + PixelFormatBC6H_RGBUfloat = 151, + PixelFormatBC7_RGBAUnorm = 152, + PixelFormatBC7_RGBAUnorm_sRGB = 153, + PixelFormatPVRTC_RGB_2BPP = 160, + PixelFormatPVRTC_RGB_2BPP_sRGB = 161, + PixelFormatPVRTC_RGB_4BPP = 162, + PixelFormatPVRTC_RGB_4BPP_sRGB = 163, + PixelFormatPVRTC_RGBA_2BPP = 164, + PixelFormatPVRTC_RGBA_2BPP_sRGB = 165, + PixelFormatPVRTC_RGBA_4BPP = 166, + PixelFormatPVRTC_RGBA_4BPP_sRGB = 167, + PixelFormatEAC_R11Unorm = 170, + PixelFormatEAC_R11Snorm = 172, + PixelFormatEAC_RG11Unorm = 174, + PixelFormatEAC_RG11Snorm = 176, + PixelFormatEAC_RGBA8 = 178, + PixelFormatEAC_RGBA8_sRGB = 179, + PixelFormatETC2_RGB8 = 180, + PixelFormatETC2_RGB8_sRGB = 181, + PixelFormatETC2_RGB8A1 = 182, + PixelFormatETC2_RGB8A1_sRGB = 183, + PixelFormatASTC_4x4_sRGB = 186, + PixelFormatASTC_5x4_sRGB = 187, + PixelFormatASTC_5x5_sRGB = 188, + PixelFormatASTC_6x5_sRGB = 189, + PixelFormatASTC_6x6_sRGB = 190, + PixelFormatASTC_8x5_sRGB = 192, + PixelFormatASTC_8x6_sRGB = 193, + PixelFormatASTC_8x8_sRGB = 194, + PixelFormatASTC_10x5_sRGB = 195, + PixelFormatASTC_10x6_sRGB = 196, + PixelFormatASTC_10x8_sRGB = 197, + PixelFormatASTC_10x10_sRGB = 198, + PixelFormatASTC_12x10_sRGB = 199, + PixelFormatASTC_12x12_sRGB = 200, + PixelFormatASTC_4x4_LDR = 204, + PixelFormatASTC_5x4_LDR = 205, + PixelFormatASTC_5x5_LDR = 206, + PixelFormatASTC_6x5_LDR = 207, + PixelFormatASTC_6x6_LDR = 208, + PixelFormatASTC_8x5_LDR = 210, + PixelFormatASTC_8x6_LDR = 211, + PixelFormatASTC_8x8_LDR = 212, + PixelFormatASTC_10x5_LDR = 213, + PixelFormatASTC_10x6_LDR = 214, + PixelFormatASTC_10x8_LDR = 215, + PixelFormatASTC_10x10_LDR = 216, + PixelFormatASTC_12x10_LDR = 217, + PixelFormatASTC_12x12_LDR = 218, + PixelFormatASTC_4x4_HDR = 222, + PixelFormatASTC_5x4_HDR = 223, + PixelFormatASTC_5x5_HDR = 224, + PixelFormatASTC_6x5_HDR = 225, + PixelFormatASTC_6x6_HDR = 226, + PixelFormatASTC_8x5_HDR = 228, + PixelFormatASTC_8x6_HDR = 229, + PixelFormatASTC_8x8_HDR = 230, + PixelFormatASTC_10x5_HDR = 231, + PixelFormatASTC_10x6_HDR = 232, + PixelFormatASTC_10x8_HDR = 233, + PixelFormatASTC_10x10_HDR = 234, + PixelFormatASTC_12x10_HDR = 235, + PixelFormatASTC_12x12_HDR = 236, + PixelFormatGBGR422 = 240, + PixelFormatBGRG422 = 241, + PixelFormatDepth16Unorm = 250, + PixelFormatDepth32Float = 252, + PixelFormatStencil8 = 253, + PixelFormatDepth24Unorm_Stencil8 = 255, + PixelFormatDepth32Float_Stencil8 = 260, + PixelFormatX32_Stencil8 = 261, + PixelFormatX24_Stencil8 = 262, +}; + +} + +#pragma once + +#include + +#pragma once + +namespace MTL +{ +class Allocation : public NS::Referencing +{ +public: + NS::UInteger allocatedSize() const; +}; + +} + +_MTL_INLINE NS::UInteger MTL::Allocation::allocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allocatedSize)); +} + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PurgeableState) { + PurgeableStateKeepCurrent = 1, + PurgeableStateNonVolatile = 2, + PurgeableStateVolatile = 3, + PurgeableStateEmpty = 4, +}; + +_MTL_ENUM(NS::UInteger, CPUCacheMode) { + CPUCacheModeDefaultCache = 0, + CPUCacheModeWriteCombined = 1, +}; + +_MTL_ENUM(NS::UInteger, StorageMode) { + StorageModeShared = 0, + StorageModeManaged = 1, + StorageModePrivate = 2, + StorageModeMemoryless = 3, +}; + +_MTL_ENUM(NS::UInteger, HazardTrackingMode) { + HazardTrackingModeDefault = 0, + HazardTrackingModeUntracked = 1, + HazardTrackingModeTracked = 2, +}; + +_MTL_OPTIONS(NS::UInteger, ResourceOptions) { + ResourceCPUCacheModeDefaultCache = 0, + ResourceCPUCacheModeWriteCombined = 1, + ResourceStorageModeShared = 0, + ResourceStorageModeManaged = 16, + ResourceStorageModePrivate = 32, + ResourceStorageModeMemoryless = 48, + ResourceHazardTrackingModeDefault = 0, + ResourceHazardTrackingModeUntracked = 256, + ResourceHazardTrackingModeTracked = 512, + ResourceOptionCPUCacheModeDefault = 0, + ResourceOptionCPUCacheModeWriteCombined = 1, +}; + +class Resource : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::CPUCacheMode cpuCacheMode() const; + + MTL::StorageMode storageMode() const; + + MTL::HazardTrackingMode hazardTrackingMode() const; + + MTL::ResourceOptions resourceOptions() const; + + MTL::PurgeableState setPurgeableState(MTL::PurgeableState state); + + class Heap* heap() const; + + NS::UInteger heapOffset() const; + + NS::UInteger allocatedSize() const; + + void makeAliasable(); + + bool isAliasable(); + + kern_return_t setOwner(task_id_token_t task_id_token); +}; + +} + +_MTL_INLINE NS::String* MTL::Resource::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Resource::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::Resource::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::CPUCacheMode MTL::Resource::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE MTL::StorageMode MTL::Resource::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE MTL::HazardTrackingMode MTL::Resource::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE MTL::ResourceOptions MTL::Resource::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE MTL::PurgeableState MTL::Resource::setPurgeableState(MTL::PurgeableState state) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(setPurgeableState_), state); +} + +_MTL_INLINE MTL::Heap* MTL::Resource::heap() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heap)); +} + +_MTL_INLINE NS::UInteger MTL::Resource::heapOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapOffset)); +} + +_MTL_INLINE NS::UInteger MTL::Resource::allocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allocatedSize)); +} + +_MTL_INLINE void MTL::Resource::makeAliasable() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(makeAliasable)); +} + +_MTL_INLINE bool MTL::Resource::isAliasable() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAliasable)); +} + +_MTL_INLINE kern_return_t MTL::Resource::setOwner(task_id_token_t task_id_token) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(setOwnerWithIdentity_), task_id_token); +} + +#pragma once + +namespace MTL +{ +struct Origin +{ + Origin() = default; + + Origin(NS::UInteger x, NS::UInteger y, NS::UInteger z); + + static Origin Make(NS::UInteger x, NS::UInteger y, NS::UInteger z); + + NS::UInteger x; + NS::UInteger y; + NS::UInteger z; +} _MTL_PACKED; + +struct Size +{ + Size() = default; + + Size(NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + static Size Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + NS::UInteger width; + NS::UInteger height; + NS::UInteger depth; +} _MTL_PACKED; + +struct Region +{ + Region() = default; + + Region(NS::UInteger x, NS::UInteger width); + + Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height); + + Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + static Region Make1D(NS::UInteger x, NS::UInteger width); + + static Region Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height); + + static Region Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + MTL::Origin origin; + MTL::Size size; +} _MTL_PACKED; + +struct SamplePosition; + +using Coordinate2D = SamplePosition; + +struct SamplePosition +{ + SamplePosition() = default; + + SamplePosition(float _x, float _y); + + static SamplePosition Make(float x, float y); + + float x; + float y; +} _MTL_PACKED; + +struct ResourceID +{ + uint64_t _impl; +} _MTL_PACKED; + +} + +_MTL_INLINE MTL::Origin::Origin(NS::UInteger _x, NS::UInteger _y, NS::UInteger _z) + : x(_x) + , y(_y) + , z(_z) +{ +} + +_MTL_INLINE MTL::Origin MTL::Origin::Make(NS::UInteger x, NS::UInteger y, NS::UInteger z) +{ + return Origin(x, y, z); +} + +_MTL_INLINE MTL::Size::Size(NS::UInteger _width, NS::UInteger _height, NS::UInteger _depth) + : width(_width) + , height(_height) + , depth(_depth) +{ +} + +_MTL_INLINE MTL::Size MTL::Size::Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth) +{ + return Size(width, height, depth); +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger width) + : origin(x, 0, 0) + , size(width, 1, 1) +{ +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height) + : origin(x, y, 0) + , size(width, height, 1) +{ +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth) + : origin(x, y, z) + , size(width, height, depth) +{ +} + +_MTL_INLINE MTL::Region MTL::Region::Make1D(NS::UInteger x, NS::UInteger width) +{ + return Region(x, width); +} + +_MTL_INLINE MTL::Region MTL::Region::Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height) +{ + return Region(x, y, width, height); +} + +_MTL_INLINE MTL::Region MTL::Region::Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth) +{ + return Region(x, y, z, width, height, depth); +} + +_MTL_INLINE MTL::SamplePosition::SamplePosition(float _x, float _y) + : x(_x) + , y(_y) +{ +} + +_MTL_INLINE MTL::SamplePosition MTL::SamplePosition::Make(float x, float y) +{ + return SamplePosition(x, y); +} + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, TextureType) { + TextureType1D = 0, + TextureType1DArray = 1, + TextureType2D = 2, + TextureType2DArray = 3, + TextureType2DMultisample = 4, + TextureTypeCube = 5, + TextureTypeCubeArray = 6, + TextureType3D = 7, + TextureType2DMultisampleArray = 8, + TextureTypeTextureBuffer = 9, +}; + +_MTL_ENUM(uint8_t, TextureSwizzle) { + TextureSwizzleZero = 0, + TextureSwizzleOne = 1, + TextureSwizzleRed = 2, + TextureSwizzleGreen = 3, + TextureSwizzleBlue = 4, + TextureSwizzleAlpha = 5, +}; + +struct TextureSwizzleChannels +{ + MTL::TextureSwizzle red; + MTL::TextureSwizzle green; + MTL::TextureSwizzle blue; + MTL::TextureSwizzle alpha; +} _MTL_PACKED; + +class SharedTextureHandle : public NS::SecureCoding +{ +public: + static class SharedTextureHandle* alloc(); + + class SharedTextureHandle* init(); + + class Device* device() const; + + NS::String* label() const; +}; + +_MTL_OPTIONS(NS::UInteger, TextureUsage) { + TextureUsageUnknown = 0, + TextureUsageShaderRead = 1, + TextureUsageShaderWrite = 2, + TextureUsageRenderTarget = 4, + TextureUsagePixelFormatView = 16, + TextureUsageShaderAtomic = 32, +}; + +_MTL_ENUM(NS::Integer, TextureCompressionType) { + TextureCompressionTypeLossless = 0, + TextureCompressionTypeLossy = 1, +}; + +class TextureDescriptor : public NS::Copying +{ +public: + static class TextureDescriptor* alloc(); + + class TextureDescriptor* init(); + + static class TextureDescriptor* texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped); + + static class TextureDescriptor* textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped); + + static class TextureDescriptor* textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage); + + MTL::TextureType textureType() const; + void setTextureType(MTL::TextureType textureType); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + NS::UInteger width() const; + void setWidth(NS::UInteger width); + + NS::UInteger height() const; + void setHeight(NS::UInteger height); + + NS::UInteger depth() const; + void setDepth(NS::UInteger depth); + + NS::UInteger mipmapLevelCount() const; + void setMipmapLevelCount(NS::UInteger mipmapLevelCount); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); + + NS::UInteger arrayLength() const; + void setArrayLength(NS::UInteger arrayLength); + + MTL::ResourceOptions resourceOptions() const; + void setResourceOptions(MTL::ResourceOptions resourceOptions); + + MTL::CPUCacheMode cpuCacheMode() const; + void setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + MTL::HazardTrackingMode hazardTrackingMode() const; + void setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode); + + MTL::TextureUsage usage() const; + void setUsage(MTL::TextureUsage usage); + + bool allowGPUOptimizedContents() const; + void setAllowGPUOptimizedContents(bool allowGPUOptimizedContents); + + MTL::TextureCompressionType compressionType() const; + void setCompressionType(MTL::TextureCompressionType compressionType); + + MTL::TextureSwizzleChannels swizzle() const; + void setSwizzle(MTL::TextureSwizzleChannels swizzle); +}; + +class Texture : public NS::Referencing +{ +public: + class Resource* rootResource() const; + + class Texture* parentTexture() const; + + NS::UInteger parentRelativeLevel() const; + + NS::UInteger parentRelativeSlice() const; + + class Buffer* buffer() const; + + NS::UInteger bufferOffset() const; + + NS::UInteger bufferBytesPerRow() const; + + IOSurfaceRef iosurface() const; + + NS::UInteger iosurfacePlane() const; + + MTL::TextureType textureType() const; + + MTL::PixelFormat pixelFormat() const; + + NS::UInteger width() const; + + NS::UInteger height() const; + + NS::UInteger depth() const; + + NS::UInteger mipmapLevelCount() const; + + NS::UInteger sampleCount() const; + + NS::UInteger arrayLength() const; + + MTL::TextureUsage usage() const; + + bool shareable() const; + + bool framebufferOnly() const; + + NS::UInteger firstMipmapInTail() const; + + NS::UInteger tailSizeInBytes() const; + + bool isSparse() const; + + bool allowGPUOptimizedContents() const; + + MTL::TextureCompressionType compressionType() const; + + MTL::ResourceID gpuResourceID() const; + + void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice); + + void replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage); + + void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level); + + void replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow); + + class Texture* newTextureView(MTL::PixelFormat pixelFormat); + + class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange); + + class SharedTextureHandle* newSharedTextureHandle(); + + class Texture* remoteStorageTexture() const; + + class Texture* newRemoteTextureViewForDevice(const class Device* device); + + MTL::TextureSwizzleChannels swizzle() const; + + class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle); +}; + +} + +_MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedTextureHandle)); +} + +_MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Device* MTL::SharedTextureHandle::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::SharedTextureHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTextureDescriptor)); +} + +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(texture2DDescriptorWithPixelFormat_width_height_mipmapped_), pixelFormat, width, height, mipmapped); +} + +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureCubeDescriptorWithPixelFormat_size_mipmapped_), pixelFormat, size, mipmapped); +} + +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureBufferDescriptorWithPixelFormat_width_resourceOptions_usage_), pixelFormat, width, resourceOptions, usage); +} + +_MTL_INLINE MTL::TextureType MTL::TextureDescriptor::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setTextureType(MTL::TextureType textureType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextureType_), textureType); +} + +_MTL_INLINE MTL::PixelFormat MTL::TextureDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::width() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(width)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setWidth(NS::UInteger width) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWidth_), width); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::height() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(height)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setHeight(NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHeight_), height); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::depth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depth)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setDepth(NS::UInteger depth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepth_), depth); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::mipmapLevelCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipmapLevelCount)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setMipmapLevelCount(NS::UInteger mipmapLevelCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMipmapLevelCount_), mipmapLevelCount); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setArrayLength(NS::UInteger arrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArrayLength_), arrayLength); +} + +_MTL_INLINE MTL::ResourceOptions MTL::TextureDescriptor::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setResourceOptions(MTL::ResourceOptions resourceOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResourceOptions_), resourceOptions); +} + +_MTL_INLINE MTL::CPUCacheMode MTL::TextureDescriptor::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCpuCacheMode_), cpuCacheMode); +} + +_MTL_INLINE MTL::StorageMode MTL::TextureDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +_MTL_INLINE MTL::HazardTrackingMode MTL::TextureDescriptor::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHazardTrackingMode_), hazardTrackingMode); +} + +_MTL_INLINE MTL::TextureUsage MTL::TextureDescriptor::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setUsage(MTL::TextureUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUsage_), usage); +} + +_MTL_INLINE bool MTL::TextureDescriptor::allowGPUOptimizedContents() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setAllowGPUOptimizedContents(bool allowGPUOptimizedContents) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowGPUOptimizedContents_), allowGPUOptimizedContents); +} + +_MTL_INLINE MTL::TextureCompressionType MTL::TextureDescriptor::compressionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compressionType)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setCompressionType(MTL::TextureCompressionType compressionType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompressionType_), compressionType); +} + +_MTL_INLINE MTL::TextureSwizzleChannels MTL::TextureDescriptor::swizzle() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(swizzle)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setSwizzle(MTL::TextureSwizzleChannels swizzle) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSwizzle_), swizzle); +} + +_MTL_INLINE MTL::Resource* MTL::Texture::rootResource() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rootResource)); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::parentTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentTexture)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::parentRelativeLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentRelativeLevel)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::parentRelativeSlice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentRelativeSlice)); +} + +_MTL_INLINE MTL::Buffer* MTL::Texture::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::bufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferOffset)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::bufferBytesPerRow() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferBytesPerRow)); +} + +_MTL_INLINE IOSurfaceRef MTL::Texture::iosurface() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(iosurface)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::iosurfacePlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(iosurfacePlane)); +} + +_MTL_INLINE MTL::TextureType MTL::Texture::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE MTL::PixelFormat MTL::Texture::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::width() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(width)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::height() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(height)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::depth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depth)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::mipmapLevelCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipmapLevelCount)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE MTL::TextureUsage MTL::Texture::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +_MTL_INLINE bool MTL::Texture::shareable() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isShareable)); +} + +_MTL_INLINE bool MTL::Texture::framebufferOnly() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isFramebufferOnly)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::firstMipmapInTail() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(firstMipmapInTail)); +} + +_MTL_INLINE NS::UInteger MTL::Texture::tailSizeInBytes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tailSizeInBytes)); +} + +_MTL_INLINE bool MTL::Texture::isSparse() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isSparse)); +} + +_MTL_INLINE bool MTL::Texture::allowGPUOptimizedContents() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents)); +} + +_MTL_INLINE MTL::TextureCompressionType MTL::Texture::compressionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compressionType)); +} + +_MTL_INLINE MTL::ResourceID MTL::Texture::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice_), pixelBytes, bytesPerRow, bytesPerImage, region, level, slice); +} + +_MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage_), region, level, slice, pixelBytes, bytesPerRow, bytesPerImage); +} + +_MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_fromRegion_mipmapLevel_), pixelBytes, bytesPerRow, region, level); +} + +_MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_withBytes_bytesPerRow_), region, level, pixelBytes, bytesPerRow); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_), pixelFormat); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_), pixelFormat, textureType, levelRange, sliceRange); +} + +_MTL_INLINE MTL::SharedTextureHandle* MTL::Texture::newSharedTextureHandle() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureHandle)); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::remoteStorageTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(remoteStorageTexture)); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::newRemoteTextureViewForDevice(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRemoteTextureViewForDevice_), device); +} + +_MTL_INLINE MTL::TextureSwizzleChannels MTL::Texture::swizzle() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(swizzle)); +} + +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_swizzle_), pixelFormat, textureType, levelRange, sliceRange, swizzle); +} + +#define _CA_EXPORT _NS_EXPORT +#define _CA_EXTERN _NS_EXTERN +#define _CA_INLINE _NS_INLINE +#define _CA_PACKED _NS_PACKED + +#define _CA_CONST(type, name) _NS_CONST(type, name) +#define _CA_ENUM(type, name) _NS_ENUM(type, name) +#define _CA_OPTIONS(type, name) _NS_OPTIONS(type, name) + +#define _CA_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) +#define _CA_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) + +#include + +#define _CA_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _CA_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +#if defined(CA_PRIVATE_IMPLEMENTATION) + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _CA_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _CA_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _CA_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _CA_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _CA_PRIVATE_VISIBILITY = sel_registerName(symbol) +#define _CA_PRIVATE_DEF_STR(type, symbol) \ + _CA_EXTERN type const CA##symbol _CA_PRIVATE_IMPORT; \ + type const CA::symbol = (nullptr != &CA##symbol) ? CA##symbol : nullptr + +#else + +#define _CA_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _CA_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _CA_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _CA_PRIVATE_DEF_STR(type, symbol) extern type const CA::symbol + +#endif // CA_PRIVATE_IMPLEMENTATION + +namespace CA +{ +namespace Private +{ + namespace Class + { + _CA_PRIVATE_DEF_CLS(CAMetalLayer); + } // Class +} // Private +} // CA + +namespace CA +{ +namespace Private +{ + namespace Protocol + { + + _CA_PRIVATE_DEF_PRO(CAMetalDrawable); + + } // Protocol +} // Private +} // CA + +namespace CA +{ +namespace Private +{ + namespace Selector + { + _CA_PRIVATE_DEF_SEL(device, + "device"); + _CA_PRIVATE_DEF_SEL(drawableSize, + "drawableSize"); + _CA_PRIVATE_DEF_SEL(framebufferOnly, + "framebufferOnly"); + _CA_PRIVATE_DEF_SEL(layer, + "layer"); + _CA_PRIVATE_DEF_SEL(nextDrawable, + "nextDrawable"); + _CA_PRIVATE_DEF_SEL(pixelFormat, + "pixelFormat"); + _CA_PRIVATE_DEF_SEL(setDevice_, + "setDevice:"); + _CA_PRIVATE_DEF_SEL(setDrawableSize_, + "setDrawableSize:"); + _CA_PRIVATE_DEF_SEL(setFramebufferOnly_, + "setFramebufferOnly:"); + _CA_PRIVATE_DEF_SEL(setPixelFormat_, + "setPixelFormat:"); + _CA_PRIVATE_DEF_SEL(texture, + "texture"); + } // Class +} // Private +} // CA + +namespace CA +{ +class MetalDrawable : public NS::Referencing +{ +public: + class MetalLayer* layer() const; + MTL::Texture* texture() const; +}; +} + +_CA_INLINE CA::MetalLayer* CA::MetalDrawable::layer() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(layer)); +} + +_CA_INLINE MTL::Texture* CA::MetalDrawable::texture() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(texture)); +} + +#include + +namespace CA +{ + +class MetalLayer : public NS::Referencing +{ +public: + static class MetalLayer* layer(); + + MTL::Device* device() const; + void setDevice(MTL::Device* device); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + bool framebufferOnly() const; + void setFramebufferOnly(bool framebufferOnly); + + CGSize drawableSize() const; + void setDrawableSize(CGSize drawableSize); + + class MetalDrawable* nextDrawable(); +}; +} // namespace CA + +_CA_INLINE CA::MetalLayer* CA::MetalLayer::layer() +{ + return Object::sendMessage(_CA_PRIVATE_CLS(CAMetalLayer), _CA_PRIVATE_SEL(layer)); +} + +_CA_INLINE MTL::Device* CA::MetalLayer::device() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(device)); +} + +_CA_INLINE void CA::MetalLayer::setDevice(MTL::Device* device) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setDevice_), device); +} + +_CA_INLINE MTL::PixelFormat CA::MetalLayer::pixelFormat() const +{ + return Object::sendMessage(this, + _CA_PRIVATE_SEL(pixelFormat)); +} + +_CA_INLINE void CA::MetalLayer::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setPixelFormat_), + pixelFormat); +} + +_CA_INLINE bool CA::MetalLayer::framebufferOnly() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(framebufferOnly)); +} + +_CA_INLINE void CA::MetalLayer::setFramebufferOnly(bool framebufferOnly) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setFramebufferOnly_), + framebufferOnly); +} + +_CA_INLINE CGSize CA::MetalLayer::drawableSize() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(drawableSize)); +} + +_CA_INLINE void CA::MetalLayer::setDrawableSize(CGSize drawableSize) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setDrawableSize_), + drawableSize); +} + +_CA_INLINE CA::MetalDrawable* CA::MetalLayer::nextDrawable() +{ + return Object::sendMessage(this, + _CA_PRIVATE_SEL(nextDrawable)); +} + +#pragma once + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, AttributeFormat) { + AttributeFormatInvalid = 0, + AttributeFormatUChar2 = 1, + AttributeFormatUChar3 = 2, + AttributeFormatUChar4 = 3, + AttributeFormatChar2 = 4, + AttributeFormatChar3 = 5, + AttributeFormatChar4 = 6, + AttributeFormatUChar2Normalized = 7, + AttributeFormatUChar3Normalized = 8, + AttributeFormatUChar4Normalized = 9, + AttributeFormatChar2Normalized = 10, + AttributeFormatChar3Normalized = 11, + AttributeFormatChar4Normalized = 12, + AttributeFormatUShort2 = 13, + AttributeFormatUShort3 = 14, + AttributeFormatUShort4 = 15, + AttributeFormatShort2 = 16, + AttributeFormatShort3 = 17, + AttributeFormatShort4 = 18, + AttributeFormatUShort2Normalized = 19, + AttributeFormatUShort3Normalized = 20, + AttributeFormatUShort4Normalized = 21, + AttributeFormatShort2Normalized = 22, + AttributeFormatShort3Normalized = 23, + AttributeFormatShort4Normalized = 24, + AttributeFormatHalf2 = 25, + AttributeFormatHalf3 = 26, + AttributeFormatHalf4 = 27, + AttributeFormatFloat = 28, + AttributeFormatFloat2 = 29, + AttributeFormatFloat3 = 30, + AttributeFormatFloat4 = 31, + AttributeFormatInt = 32, + AttributeFormatInt2 = 33, + AttributeFormatInt3 = 34, + AttributeFormatInt4 = 35, + AttributeFormatUInt = 36, + AttributeFormatUInt2 = 37, + AttributeFormatUInt3 = 38, + AttributeFormatUInt4 = 39, + AttributeFormatInt1010102Normalized = 40, + AttributeFormatUInt1010102Normalized = 41, + AttributeFormatUChar4Normalized_BGRA = 42, + AttributeFormatUChar = 45, + AttributeFormatChar = 46, + AttributeFormatUCharNormalized = 47, + AttributeFormatCharNormalized = 48, + AttributeFormatUShort = 49, + AttributeFormatShort = 50, + AttributeFormatUShortNormalized = 51, + AttributeFormatShortNormalized = 52, + AttributeFormatHalf = 53, + AttributeFormatFloatRG11B10 = 54, + AttributeFormatFloatRGB9E5 = 55, +}; + +_MTL_ENUM(NS::UInteger, IndexType) { + IndexTypeUInt16 = 0, + IndexTypeUInt32 = 1, +}; + +_MTL_ENUM(NS::UInteger, StepFunction) { + StepFunctionConstant = 0, + StepFunctionPerVertex = 1, + StepFunctionPerInstance = 2, + StepFunctionPerPatch = 3, + StepFunctionPerPatchControlPoint = 4, + StepFunctionThreadPositionInGridX = 5, + StepFunctionThreadPositionInGridY = 6, + StepFunctionThreadPositionInGridXIndexed = 7, + StepFunctionThreadPositionInGridYIndexed = 8, +}; + +class BufferLayoutDescriptor : public NS::Copying +{ +public: + static class BufferLayoutDescriptor* alloc(); + + class BufferLayoutDescriptor* init(); + + NS::UInteger stride() const; + void setStride(NS::UInteger stride); + + MTL::StepFunction stepFunction() const; + void setStepFunction(MTL::StepFunction stepFunction); + + NS::UInteger stepRate() const; + void setStepRate(NS::UInteger stepRate); +}; + +class BufferLayoutDescriptorArray : public NS::Referencing +{ +public: + static class BufferLayoutDescriptorArray* alloc(); + + class BufferLayoutDescriptorArray* init(); + + class BufferLayoutDescriptor* object(NS::UInteger index); + + void setObject(const class BufferLayoutDescriptor* bufferDesc, NS::UInteger index); +}; + +class AttributeDescriptor : public NS::Copying +{ +public: + static class AttributeDescriptor* alloc(); + + class AttributeDescriptor* init(); + + MTL::AttributeFormat format() const; + void setFormat(MTL::AttributeFormat format); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + NS::UInteger bufferIndex() const; + void setBufferIndex(NS::UInteger bufferIndex); +}; + +class AttributeDescriptorArray : public NS::Referencing +{ +public: + static class AttributeDescriptorArray* alloc(); + + class AttributeDescriptorArray* init(); + + class AttributeDescriptor* object(NS::UInteger index); + + void setObject(const class AttributeDescriptor* attributeDesc, NS::UInteger index); +}; + +class StageInputOutputDescriptor : public NS::Copying +{ +public: + static class StageInputOutputDescriptor* alloc(); + + class StageInputOutputDescriptor* init(); + + static class StageInputOutputDescriptor* stageInputOutputDescriptor(); + + class BufferLayoutDescriptorArray* layouts() const; + + class AttributeDescriptorArray* attributes() const; + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger indexBufferIndex() const; + void setIndexBufferIndex(NS::UInteger indexBufferIndex); + + void reset(); +}; + +} + +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptor)); +} + +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStride(NS::UInteger stride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStride_), stride); +} + +_MTL_INLINE MTL::StepFunction MTL::BufferLayoutDescriptor::stepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepFunction)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStepFunction(MTL::StepFunction stepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction); +} + +_MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stepRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepRate)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStepRate(NS::UInteger stepRate) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate); +} + +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptorArray)); +} + +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptorArray::setObject(const MTL::BufferLayoutDescriptor* bufferDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index); +} + +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttributeDescriptor)); +} + +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AttributeDescriptor::format() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(format)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setFormat(MTL::AttributeFormat format) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFormat_), format); +} + +_MTL_INLINE NS::UInteger MTL::AttributeDescriptor::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +_MTL_INLINE NS::UInteger MTL::AttributeDescriptor::bufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferIndex)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex); +} + +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttributeDescriptorArray)); +} + +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +_MTL_INLINE void MTL::AttributeDescriptorArray::setObject(const MTL::AttributeDescriptor* attributeDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index); +} + +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor)); +} + +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::stageInputOutputDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor), _MTL_PRIVATE_SEL(stageInputOutputDescriptor)); +} + +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::StageInputOutputDescriptor::layouts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layouts)); +} + +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::StageInputOutputDescriptor::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +_MTL_INLINE MTL::IndexType MTL::StageInputOutputDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +_MTL_INLINE NS::UInteger MTL::StageInputOutputDescriptor::indexBufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferIndex)); +} + +_MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexBufferIndex(NS::UInteger indexBufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferIndex_), indexBufferIndex); +} + +_MTL_INLINE void MTL::StageInputOutputDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +namespace MTL +{ +struct PackedFloat3 +{ + PackedFloat3(); + PackedFloat3(float x, float y, float z); + + float& operator[](int idx); + float operator[](int idx) const; + + union + { + struct + { + float x; + float y; + float z; + }; + + float elements[3]; + }; +} _MTL_PACKED; + +struct PackedFloat4x3 +{ + PackedFloat4x3(); + PackedFloat4x3(const PackedFloat3& col0, const PackedFloat3& col1, const PackedFloat3& col2, const PackedFloat3& col3); + + PackedFloat3& operator[](int idx); + const PackedFloat3& operator[](int idx) const; + + PackedFloat3 columns[4]; +} _MTL_PACKED; + +struct AxisAlignedBoundingBox +{ + AxisAlignedBoundingBox(); + AxisAlignedBoundingBox(PackedFloat3 p); + AxisAlignedBoundingBox(PackedFloat3 min, PackedFloat3 max); + + PackedFloat3 min; + PackedFloat3 max; +} _MTL_PACKED; + +struct PackedFloatQuaternion +{ + PackedFloatQuaternion(); + PackedFloatQuaternion(float x, float y, float z, float w); + + float& operator[](int idx); + const float& operator[](int idx) const; + + union + { + struct + { + float x; + float y; + float z; + float w; + }; + + float elements[4]; + }; + +} _MTL_PACKED; + +struct ComponentTransform +{ + PackedFloat3 scale; + PackedFloat3 shear; + PackedFloat3 pivot; + PackedFloatQuaternion rotation; + PackedFloat3 translation; +} _MTL_PACKED; + +} + +_MTL_INLINE MTL::PackedFloat3::PackedFloat3() + : x(0.0f) + , y(0.0f) + , z(0.0f) +{ +} + +_MTL_INLINE MTL::PackedFloat3::PackedFloat3(float _x, float _y, float _z) + : x(_x) + , y(_y) + , z(_z) +{ +} + +_MTL_INLINE float& MTL::PackedFloat3::operator[](int idx) +{ + return elements[idx]; +} + +_MTL_INLINE float MTL::PackedFloat3::operator[](int idx) const +{ + return elements[idx]; +} + +_MTL_INLINE MTL::PackedFloat4x3::PackedFloat4x3() +{ + columns[0] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[1] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[2] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[3] = PackedFloat3(0.0f, 0.0f, 0.0f); +} + +_MTL_INLINE MTL::PackedFloat4x3::PackedFloat4x3(const PackedFloat3& col0, const PackedFloat3& col1, const PackedFloat3& col2, const PackedFloat3& col3) +{ + columns[0] = col0; + columns[1] = col1; + columns[2] = col2; + columns[3] = col3; +} + +_MTL_INLINE MTL::PackedFloat3& MTL::PackedFloat4x3::operator[](int idx) +{ + return columns[idx]; +} + +_MTL_INLINE const MTL::PackedFloat3& MTL::PackedFloat4x3::operator[](int idx) const +{ + return columns[idx]; +} + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox() + : min(INFINITY, INFINITY, INFINITY) + , max(-INFINITY, -INFINITY, -INFINITY) +{ +} + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox(PackedFloat3 p) + : min(p) + , max(p) +{ +} + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox(PackedFloat3 _min, PackedFloat3 _max) + : min(_min) + , max(_max) +{ +} + +_MTL_INLINE MTL::PackedFloatQuaternion::PackedFloatQuaternion() + : x(0.0f) + , y(0.0f) + , z(0.0f) + , w(0.0f) +{ +} + +_MTL_INLINE MTL::PackedFloatQuaternion::PackedFloatQuaternion(float x, float y, float z, float w) + : x(x) + , y(y) + , z(z) + , w(w) +{ +} + +_MTL_INLINE float& MTL::PackedFloatQuaternion::operator[](int idx) +{ + return elements[idx]; +} + +_MTL_INLINE const float& MTL::PackedFloatQuaternion::operator[](int idx) const +{ + return elements[idx]; +} + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, AccelerationStructureUsage) { + AccelerationStructureUsageNone = 0, + AccelerationStructureUsageRefit = 1, + AccelerationStructureUsagePreferFastBuild = 2, + AccelerationStructureUsageExtendedLimits = 4, +}; + +_MTL_OPTIONS(uint32_t, AccelerationStructureInstanceOptions) { + AccelerationStructureInstanceOptionNone = 0, + AccelerationStructureInstanceOptionDisableTriangleCulling = 1, + AccelerationStructureInstanceOptionTriangleFrontFacingWindingCounterClockwise = 2, + AccelerationStructureInstanceOptionOpaque = 4, + AccelerationStructureInstanceOptionNonOpaque = 8, +}; + +_MTL_ENUM(NS::Integer, MatrixLayout) { + MatrixLayoutColumnMajor = 0, + MatrixLayoutRowMajor = 1, +}; + +class AccelerationStructureDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureDescriptor* alloc(); + + class AccelerationStructureDescriptor* init(); + + MTL::AccelerationStructureUsage usage() const; + void setUsage(MTL::AccelerationStructureUsage usage); +}; + +class AccelerationStructureGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureGeometryDescriptor* alloc(); + + class AccelerationStructureGeometryDescriptor* init(); + + NS::UInteger intersectionFunctionTableOffset() const; + void setIntersectionFunctionTableOffset(NS::UInteger intersectionFunctionTableOffset); + + bool opaque() const; + void setOpaque(bool opaque); + + bool allowDuplicateIntersectionFunctionInvocation() const; + void setAllowDuplicateIntersectionFunctionInvocation(bool allowDuplicateIntersectionFunctionInvocation); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Buffer* primitiveDataBuffer() const; + void setPrimitiveDataBuffer(const class Buffer* primitiveDataBuffer); + + NS::UInteger primitiveDataBufferOffset() const; + void setPrimitiveDataBufferOffset(NS::UInteger primitiveDataBufferOffset); + + NS::UInteger primitiveDataStride() const; + void setPrimitiveDataStride(NS::UInteger primitiveDataStride); + + NS::UInteger primitiveDataElementSize() const; + void setPrimitiveDataElementSize(NS::UInteger primitiveDataElementSize); +}; + +_MTL_ENUM(uint32_t, MotionBorderMode) { + MotionBorderModeClamp = 0, + MotionBorderModeVanish = 1, +}; + +class PrimitiveAccelerationStructureDescriptor : public NS::Copying +{ +public: + static class PrimitiveAccelerationStructureDescriptor* alloc(); + + class PrimitiveAccelerationStructureDescriptor* init(); + + NS::Array* geometryDescriptors() const; + void setGeometryDescriptors(const NS::Array* geometryDescriptors); + + MTL::MotionBorderMode motionStartBorderMode() const; + void setMotionStartBorderMode(MTL::MotionBorderMode motionStartBorderMode); + + MTL::MotionBorderMode motionEndBorderMode() const; + void setMotionEndBorderMode(MTL::MotionBorderMode motionEndBorderMode); + + float motionStartTime() const; + void setMotionStartTime(float motionStartTime); + + float motionEndTime() const; + void setMotionEndTime(float motionEndTime); + + NS::UInteger motionKeyframeCount() const; + void setMotionKeyframeCount(NS::UInteger motionKeyframeCount); + + static MTL::PrimitiveAccelerationStructureDescriptor* descriptor(); +}; + +class AccelerationStructureTriangleGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureTriangleGeometryDescriptor* alloc(); + + class AccelerationStructureTriangleGeometryDescriptor* init(); + + class Buffer* vertexBuffer() const; + void setVertexBuffer(const class Buffer* vertexBuffer); + + NS::UInteger vertexBufferOffset() const; + void setVertexBufferOffset(NS::UInteger vertexBufferOffset); + + MTL::AttributeFormat vertexFormat() const; + void setVertexFormat(MTL::AttributeFormat vertexFormat); + + NS::UInteger vertexStride() const; + void setVertexStride(NS::UInteger vertexStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger triangleCount() const; + void setTriangleCount(NS::UInteger triangleCount); + + class Buffer* transformationMatrixBuffer() const; + void setTransformationMatrixBuffer(const class Buffer* transformationMatrixBuffer); + + NS::UInteger transformationMatrixBufferOffset() const; + void setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset); + + MTL::MatrixLayout transformationMatrixLayout() const; + void setTransformationMatrixLayout(MTL::MatrixLayout transformationMatrixLayout); + + static MTL::AccelerationStructureTriangleGeometryDescriptor* descriptor(); +}; + +class AccelerationStructureBoundingBoxGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureBoundingBoxGeometryDescriptor* alloc(); + + class AccelerationStructureBoundingBoxGeometryDescriptor* init(); + + class Buffer* boundingBoxBuffer() const; + void setBoundingBoxBuffer(const class Buffer* boundingBoxBuffer); + + NS::UInteger boundingBoxBufferOffset() const; + void setBoundingBoxBufferOffset(NS::UInteger boundingBoxBufferOffset); + + NS::UInteger boundingBoxStride() const; + void setBoundingBoxStride(NS::UInteger boundingBoxStride); + + NS::UInteger boundingBoxCount() const; + void setBoundingBoxCount(NS::UInteger boundingBoxCount); + + static MTL::AccelerationStructureBoundingBoxGeometryDescriptor* descriptor(); +}; + +class MotionKeyframeData : public NS::Referencing +{ +public: + static class MotionKeyframeData* alloc(); + + class MotionKeyframeData* init(); + + class Buffer* buffer() const; + void setBuffer(const class Buffer* buffer); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + static MTL::MotionKeyframeData* data(); +}; + +class AccelerationStructureMotionTriangleGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureMotionTriangleGeometryDescriptor* alloc(); + + class AccelerationStructureMotionTriangleGeometryDescriptor* init(); + + NS::Array* vertexBuffers() const; + void setVertexBuffers(const NS::Array* vertexBuffers); + + MTL::AttributeFormat vertexFormat() const; + void setVertexFormat(MTL::AttributeFormat vertexFormat); + + NS::UInteger vertexStride() const; + void setVertexStride(NS::UInteger vertexStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger triangleCount() const; + void setTriangleCount(NS::UInteger triangleCount); + + class Buffer* transformationMatrixBuffer() const; + void setTransformationMatrixBuffer(const class Buffer* transformationMatrixBuffer); + + NS::UInteger transformationMatrixBufferOffset() const; + void setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset); + + MTL::MatrixLayout transformationMatrixLayout() const; + void setTransformationMatrixLayout(MTL::MatrixLayout transformationMatrixLayout); + + static MTL::AccelerationStructureMotionTriangleGeometryDescriptor* descriptor(); +}; + +class AccelerationStructureMotionBoundingBoxGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureMotionBoundingBoxGeometryDescriptor* alloc(); + + class AccelerationStructureMotionBoundingBoxGeometryDescriptor* init(); + + NS::Array* boundingBoxBuffers() const; + void setBoundingBoxBuffers(const NS::Array* boundingBoxBuffers); + + NS::UInteger boundingBoxStride() const; + void setBoundingBoxStride(NS::UInteger boundingBoxStride); + + NS::UInteger boundingBoxCount() const; + void setBoundingBoxCount(NS::UInteger boundingBoxCount); + + static MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* descriptor(); +}; + +_MTL_ENUM(NS::Integer, CurveType) { + CurveTypeRound = 0, + CurveTypeFlat = 1, +}; + +_MTL_ENUM(NS::Integer, CurveBasis) { + CurveBasisBSpline = 0, + CurveBasisCatmullRom = 1, + CurveBasisLinear = 2, + CurveBasisBezier = 3, +}; + +_MTL_ENUM(NS::Integer, CurveEndCaps) { + CurveEndCapsNone = 0, + CurveEndCapsDisk = 1, + CurveEndCapsSphere = 2, +}; + +class AccelerationStructureCurveGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureCurveGeometryDescriptor* alloc(); + + class AccelerationStructureCurveGeometryDescriptor* init(); + + class Buffer* controlPointBuffer() const; + void setControlPointBuffer(const class Buffer* controlPointBuffer); + + NS::UInteger controlPointBufferOffset() const; + void setControlPointBufferOffset(NS::UInteger controlPointBufferOffset); + + NS::UInteger controlPointCount() const; + void setControlPointCount(NS::UInteger controlPointCount); + + NS::UInteger controlPointStride() const; + void setControlPointStride(NS::UInteger controlPointStride); + + MTL::AttributeFormat controlPointFormat() const; + void setControlPointFormat(MTL::AttributeFormat controlPointFormat); + + class Buffer* radiusBuffer() const; + void setRadiusBuffer(const class Buffer* radiusBuffer); + + NS::UInteger radiusBufferOffset() const; + void setRadiusBufferOffset(NS::UInteger radiusBufferOffset); + + MTL::AttributeFormat radiusFormat() const; + void setRadiusFormat(MTL::AttributeFormat radiusFormat); + + NS::UInteger radiusStride() const; + void setRadiusStride(NS::UInteger radiusStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger segmentCount() const; + void setSegmentCount(NS::UInteger segmentCount); + + NS::UInteger segmentControlPointCount() const; + void setSegmentControlPointCount(NS::UInteger segmentControlPointCount); + + MTL::CurveType curveType() const; + void setCurveType(MTL::CurveType curveType); + + MTL::CurveBasis curveBasis() const; + void setCurveBasis(MTL::CurveBasis curveBasis); + + MTL::CurveEndCaps curveEndCaps() const; + void setCurveEndCaps(MTL::CurveEndCaps curveEndCaps); + + static MTL::AccelerationStructureCurveGeometryDescriptor* descriptor(); +}; + +class AccelerationStructureMotionCurveGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureMotionCurveGeometryDescriptor* alloc(); + + class AccelerationStructureMotionCurveGeometryDescriptor* init(); + + NS::Array* controlPointBuffers() const; + void setControlPointBuffers(const NS::Array* controlPointBuffers); + + NS::UInteger controlPointCount() const; + void setControlPointCount(NS::UInteger controlPointCount); + + NS::UInteger controlPointStride() const; + void setControlPointStride(NS::UInteger controlPointStride); + + MTL::AttributeFormat controlPointFormat() const; + void setControlPointFormat(MTL::AttributeFormat controlPointFormat); + + NS::Array* radiusBuffers() const; + void setRadiusBuffers(const NS::Array* radiusBuffers); + + MTL::AttributeFormat radiusFormat() const; + void setRadiusFormat(MTL::AttributeFormat radiusFormat); + + NS::UInteger radiusStride() const; + void setRadiusStride(NS::UInteger radiusStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger segmentCount() const; + void setSegmentCount(NS::UInteger segmentCount); + + NS::UInteger segmentControlPointCount() const; + void setSegmentControlPointCount(NS::UInteger segmentControlPointCount); + + MTL::CurveType curveType() const; + void setCurveType(MTL::CurveType curveType); + + MTL::CurveBasis curveBasis() const; + void setCurveBasis(MTL::CurveBasis curveBasis); + + MTL::CurveEndCaps curveEndCaps() const; + void setCurveEndCaps(MTL::CurveEndCaps curveEndCaps); + + static MTL::AccelerationStructureMotionCurveGeometryDescriptor* descriptor(); +}; + +struct AccelerationStructureInstanceDescriptor +{ + MTL::PackedFloat4x3 transformationMatrix; + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; +} _MTL_PACKED; + +struct AccelerationStructureUserIDInstanceDescriptor +{ + MTL::PackedFloat4x3 transformationMatrix; + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; + uint32_t userID; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, AccelerationStructureInstanceDescriptorType) { + AccelerationStructureInstanceDescriptorTypeDefault = 0, + AccelerationStructureInstanceDescriptorTypeUserID = 1, + AccelerationStructureInstanceDescriptorTypeMotion = 2, + AccelerationStructureInstanceDescriptorTypeIndirect = 3, + AccelerationStructureInstanceDescriptorTypeIndirectMotion = 4, +}; + +struct AccelerationStructureMotionInstanceDescriptor +{ + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; + uint32_t userID; + uint32_t motionTransformsStartIndex; + uint32_t motionTransformsCount; + MTL::MotionBorderMode motionStartBorderMode; + MTL::MotionBorderMode motionEndBorderMode; + float motionStartTime; + float motionEndTime; +} _MTL_PACKED; + +struct IndirectAccelerationStructureInstanceDescriptor +{ + MTL::PackedFloat4x3 transformationMatrix; + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t userID; + MTL::ResourceID accelerationStructureID; +} _MTL_PACKED; + +struct IndirectAccelerationStructureMotionInstanceDescriptor +{ + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t userID; + MTL::ResourceID accelerationStructureID; + uint32_t motionTransformsStartIndex; + uint32_t motionTransformsCount; + MTL::MotionBorderMode motionStartBorderMode; + MTL::MotionBorderMode motionEndBorderMode; + float motionStartTime; + float motionEndTime; +} _MTL_PACKED; + +_MTL_ENUM(NS::Integer, TransformType) { + TransformTypePackedFloat4x3 = 0, + TransformTypeComponent = 1, +}; + +class InstanceAccelerationStructureDescriptor : public NS::Copying +{ +public: + static class InstanceAccelerationStructureDescriptor* alloc(); + + class InstanceAccelerationStructureDescriptor* init(); + + class Buffer* instanceDescriptorBuffer() const; + void setInstanceDescriptorBuffer(const class Buffer* instanceDescriptorBuffer); + + NS::UInteger instanceDescriptorBufferOffset() const; + void setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset); + + NS::UInteger instanceDescriptorStride() const; + void setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride); + + NS::UInteger instanceCount() const; + void setInstanceCount(NS::UInteger instanceCount); + + NS::Array* instancedAccelerationStructures() const; + void setInstancedAccelerationStructures(const NS::Array* instancedAccelerationStructures); + + MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType() const; + void setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType); + + class Buffer* motionTransformBuffer() const; + void setMotionTransformBuffer(const class Buffer* motionTransformBuffer); + + NS::UInteger motionTransformBufferOffset() const; + void setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset); + + NS::UInteger motionTransformCount() const; + void setMotionTransformCount(NS::UInteger motionTransformCount); + + MTL::MatrixLayout instanceTransformationMatrixLayout() const; + void setInstanceTransformationMatrixLayout(MTL::MatrixLayout instanceTransformationMatrixLayout); + + MTL::TransformType motionTransformType() const; + void setMotionTransformType(MTL::TransformType motionTransformType); + + NS::UInteger motionTransformStride() const; + void setMotionTransformStride(NS::UInteger motionTransformStride); + + static MTL::InstanceAccelerationStructureDescriptor* descriptor(); +}; + +class IndirectInstanceAccelerationStructureDescriptor : public NS::Copying +{ +public: + static class IndirectInstanceAccelerationStructureDescriptor* alloc(); + + class IndirectInstanceAccelerationStructureDescriptor* init(); + + class Buffer* instanceDescriptorBuffer() const; + void setInstanceDescriptorBuffer(const class Buffer* instanceDescriptorBuffer); + + NS::UInteger instanceDescriptorBufferOffset() const; + void setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset); + + NS::UInteger instanceDescriptorStride() const; + void setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride); + + NS::UInteger maxInstanceCount() const; + void setMaxInstanceCount(NS::UInteger maxInstanceCount); + + class Buffer* instanceCountBuffer() const; + void setInstanceCountBuffer(const class Buffer* instanceCountBuffer); + + NS::UInteger instanceCountBufferOffset() const; + void setInstanceCountBufferOffset(NS::UInteger instanceCountBufferOffset); + + MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType() const; + void setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType); + + class Buffer* motionTransformBuffer() const; + void setMotionTransformBuffer(const class Buffer* motionTransformBuffer); + + NS::UInteger motionTransformBufferOffset() const; + void setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset); + + NS::UInteger maxMotionTransformCount() const; + void setMaxMotionTransformCount(NS::UInteger maxMotionTransformCount); + + class Buffer* motionTransformCountBuffer() const; + void setMotionTransformCountBuffer(const class Buffer* motionTransformCountBuffer); + + NS::UInteger motionTransformCountBufferOffset() const; + void setMotionTransformCountBufferOffset(NS::UInteger motionTransformCountBufferOffset); + + MTL::MatrixLayout instanceTransformationMatrixLayout() const; + void setInstanceTransformationMatrixLayout(MTL::MatrixLayout instanceTransformationMatrixLayout); + + MTL::TransformType motionTransformType() const; + void setMotionTransformType(MTL::TransformType motionTransformType); + + NS::UInteger motionTransformStride() const; + void setMotionTransformStride(NS::UInteger motionTransformStride); + + static MTL::IndirectInstanceAccelerationStructureDescriptor* descriptor(); +}; + +class AccelerationStructure : public NS::Referencing +{ +public: + NS::UInteger size() const; + + MTL::ResourceID gpuResourceID() const; +}; + +} + +_MTL_INLINE MTL::AccelerationStructureDescriptor* MTL::AccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureDescriptor* MTL::AccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::AccelerationStructureUsage MTL::AccelerationStructureDescriptor::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +_MTL_INLINE void MTL::AccelerationStructureDescriptor::setUsage(MTL::AccelerationStructureUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUsage_), usage); +} + +_MTL_INLINE MTL::AccelerationStructureGeometryDescriptor* MTL::AccelerationStructureGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureGeometryDescriptor* MTL::AccelerationStructureGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::intersectionFunctionTableOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(intersectionFunctionTableOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setIntersectionFunctionTableOffset(NS::UInteger intersectionFunctionTableOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTableOffset_), intersectionFunctionTableOffset); +} + +_MTL_INLINE bool MTL::AccelerationStructureGeometryDescriptor::opaque() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(opaque)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setOpaque(bool opaque) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaque_), opaque); +} + +_MTL_INLINE bool MTL::AccelerationStructureGeometryDescriptor::allowDuplicateIntersectionFunctionInvocation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowDuplicateIntersectionFunctionInvocation)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setAllowDuplicateIntersectionFunctionInvocation(bool allowDuplicateIntersectionFunctionInvocation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowDuplicateIntersectionFunctionInvocation_), allowDuplicateIntersectionFunctionInvocation); +} + +_MTL_INLINE NS::String* MTL::AccelerationStructureGeometryDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureGeometryDescriptor::primitiveDataBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataBuffer(const MTL::Buffer* primitiveDataBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataBuffer_), primitiveDataBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataBufferOffset(NS::UInteger primitiveDataBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataBufferOffset_), primitiveDataBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataStride(NS::UInteger primitiveDataStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataStride_), primitiveDataStride); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataElementSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataElementSize)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataElementSize(NS::UInteger primitiveDataElementSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataElementSize_), primitiveDataElementSize); +} + +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPrimitiveAccelerationStructureDescriptor)); +} + +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::PrimitiveAccelerationStructureDescriptor::geometryDescriptors() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(geometryDescriptors)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setGeometryDescriptors(const NS::Array* geometryDescriptors) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setGeometryDescriptors_), geometryDescriptors); +} + +_MTL_INLINE MTL::MotionBorderMode MTL::PrimitiveAccelerationStructureDescriptor::motionStartBorderMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionStartBorderMode)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionStartBorderMode(MTL::MotionBorderMode motionStartBorderMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionStartBorderMode_), motionStartBorderMode); +} + +_MTL_INLINE MTL::MotionBorderMode MTL::PrimitiveAccelerationStructureDescriptor::motionEndBorderMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionEndBorderMode)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionEndBorderMode(MTL::MotionBorderMode motionEndBorderMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionEndBorderMode_), motionEndBorderMode); +} + +_MTL_INLINE float MTL::PrimitiveAccelerationStructureDescriptor::motionStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionStartTime)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionStartTime(float motionStartTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionStartTime_), motionStartTime); +} + +_MTL_INLINE float MTL::PrimitiveAccelerationStructureDescriptor::motionEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionEndTime)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionEndTime(float motionEndTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionEndTime_), motionEndTime); +} + +_MTL_INLINE NS::UInteger MTL::PrimitiveAccelerationStructureDescriptor::motionKeyframeCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionKeyframeCount)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionKeyframeCount(NS::UInteger motionKeyframeCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionKeyframeCount_), motionKeyframeCount); +} + +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLPrimitiveAccelerationStructureDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureTriangleGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::vertexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexBuffer(const MTL::Buffer* vertexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_), vertexBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::vertexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexBufferOffset(NS::UInteger vertexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_), vertexBufferOffset); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureTriangleGeometryDescriptor::vertexFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexFormat(MTL::AttributeFormat vertexFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFormat_), vertexFormat); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::vertexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexStride(NS::UInteger vertexStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexStride_), vertexStride); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureTriangleGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::triangleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(triangleCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTriangleCount(NS::UInteger triangleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleCount_), triangleCount); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::transformationMatrixBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTransformationMatrixBuffer(const MTL::Buffer* transformationMatrixBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBuffer_), transformationMatrixBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::transformationMatrixBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBufferOffset_), transformationMatrixBufferOffset); +} + +_MTL_INLINE MTL::MatrixLayout MTL::AccelerationStructureTriangleGeometryDescriptor::transformationMatrixLayout() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixLayout)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTransformationMatrixLayout(MTL::MatrixLayout transformationMatrixLayout) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixLayout_), transformationMatrixLayout); +} + +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureTriangleGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxBuffer(const MTL::Buffer* boundingBoxBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBuffer_), boundingBoxBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxBufferOffset(NS::UInteger boundingBoxBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBufferOffset_), boundingBoxBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxStride(NS::UInteger boundingBoxStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxStride_), boundingBoxStride); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxCount(NS::UInteger boundingBoxCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxCount_), boundingBoxCount); +} + +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLMotionKeyframeData)); +} + +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::MotionKeyframeData::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +_MTL_INLINE void MTL::MotionKeyframeData::setBuffer(const MTL::Buffer* buffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_), buffer); +} + +_MTL_INLINE NS::UInteger MTL::MotionKeyframeData::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::MotionKeyframeData::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::data() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLMotionKeyframeData), _MTL_PRIVATE_SEL(data)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexBuffers(const NS::Array* vertexBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_), vertexBuffers); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexFormat(MTL::AttributeFormat vertexFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFormat_), vertexFormat); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexStride(NS::UInteger vertexStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexStride_), vertexStride); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::triangleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(triangleCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTriangleCount(NS::UInteger triangleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleCount_), triangleCount); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::transformationMatrixBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTransformationMatrixBuffer(const MTL::Buffer* transformationMatrixBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBuffer_), transformationMatrixBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::transformationMatrixBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBufferOffset_), transformationMatrixBufferOffset); +} + +_MTL_INLINE MTL::MatrixLayout MTL::AccelerationStructureMotionTriangleGeometryDescriptor::transformationMatrixLayout() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixLayout)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTransformationMatrixLayout(MTL::MatrixLayout transformationMatrixLayout) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixLayout_), transformationMatrixLayout); +} + +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxBuffers(const NS::Array* boundingBoxBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBuffers_), boundingBoxBuffers); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxStride(NS::UInteger boundingBoxStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxStride_), boundingBoxStride); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxCount(NS::UInteger boundingBoxCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxCount_), boundingBoxCount); +} + +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureCurveGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::controlPointBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointBuffer(const MTL::Buffer* controlPointBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBuffer_), controlPointBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointBufferOffset(NS::UInteger controlPointBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBufferOffset_), controlPointBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointCount(NS::UInteger controlPointCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointCount_), controlPointCount); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointStride(NS::UInteger controlPointStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointStride_), controlPointStride); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureCurveGeometryDescriptor::controlPointFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointFormat(MTL::AttributeFormat controlPointFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointFormat_), controlPointFormat); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::radiusBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusBuffer(const MTL::Buffer* radiusBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBuffer_), radiusBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::radiusBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusBufferOffset(NS::UInteger radiusBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBufferOffset_), radiusBufferOffset); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureCurveGeometryDescriptor::radiusFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusFormat(MTL::AttributeFormat radiusFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusFormat_), radiusFormat); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::radiusStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusStride(NS::UInteger radiusStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusStride_), radiusStride); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureCurveGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::segmentCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setSegmentCount(NS::UInteger segmentCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentCount_), segmentCount); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::segmentControlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentControlPointCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setSegmentControlPointCount(NS::UInteger segmentControlPointCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentControlPointCount_), segmentControlPointCount); +} + +_MTL_INLINE MTL::CurveType MTL::AccelerationStructureCurveGeometryDescriptor::curveType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveType)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveType(MTL::CurveType curveType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveType_), curveType); +} + +_MTL_INLINE MTL::CurveBasis MTL::AccelerationStructureCurveGeometryDescriptor::curveBasis() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveBasis)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveBasis(MTL::CurveBasis curveBasis) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveBasis_), curveBasis); +} + +_MTL_INLINE MTL::CurveEndCaps MTL::AccelerationStructureCurveGeometryDescriptor::curveEndCaps() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveEndCaps)); +} + +_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveEndCaps(MTL::CurveEndCaps curveEndCaps) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveEndCaps_), curveEndCaps); +} + +_MTL_INLINE MTL::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureCurveGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointBuffers(const NS::Array* controlPointBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBuffers_), controlPointBuffers); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointCount(NS::UInteger controlPointCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointCount_), controlPointCount); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointStride(NS::UInteger controlPointStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointStride_), controlPointStride); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointFormat(MTL::AttributeFormat controlPointFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointFormat_), controlPointFormat); +} + +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusBuffers(const NS::Array* radiusBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBuffers_), radiusBuffers); +} + +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusFormat(MTL::AttributeFormat radiusFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusFormat_), radiusFormat); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusStride(NS::UInteger radiusStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusStride_), radiusStride); +} + +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::segmentCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setSegmentCount(NS::UInteger segmentCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentCount_), segmentCount); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::segmentControlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentControlPointCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setSegmentControlPointCount(NS::UInteger segmentControlPointCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentControlPointCount_), segmentControlPointCount); +} + +_MTL_INLINE MTL::CurveType MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveType)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveType(MTL::CurveType curveType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveType_), curveType); +} + +_MTL_INLINE MTL::CurveBasis MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveBasis() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveBasis)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveBasis(MTL::CurveBasis curveBasis) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveBasis_), curveBasis); +} + +_MTL_INLINE MTL::CurveEndCaps MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveEndCaps() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveEndCaps)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveEndCaps(MTL::CurveEndCaps curveEndCaps) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveEndCaps_), curveEndCaps); +} + +_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLInstanceAccelerationStructureDescriptor)); +} + +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBuffer)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorBuffer(const MTL::Buffer* instanceDescriptorBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBuffer_), instanceDescriptorBuffer); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBufferOffset)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBufferOffset_), instanceDescriptorBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorStride)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorStride_), instanceDescriptorStride); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCount)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceCount(NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCount_), instanceCount); +} + +_MTL_INLINE NS::Array* MTL::InstanceAccelerationStructureDescriptor::instancedAccelerationStructures() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instancedAccelerationStructures)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstancedAccelerationStructures(const NS::Array* instancedAccelerationStructures) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstancedAccelerationStructures_), instancedAccelerationStructures); +} + +_MTL_INLINE MTL::AccelerationStructureInstanceDescriptorType MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorType)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorType_), instanceDescriptorType); +} + +_MTL_INLINE MTL::Buffer* MTL::InstanceAccelerationStructureDescriptor::motionTransformBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBuffer)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformBuffer(const MTL::Buffer* motionTransformBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBuffer_), motionTransformBuffer); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::motionTransformBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBufferOffset)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBufferOffset_), motionTransformBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::motionTransformCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCount)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformCount(NS::UInteger motionTransformCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCount_), motionTransformCount); +} + +_MTL_INLINE MTL::MatrixLayout MTL::InstanceAccelerationStructureDescriptor::instanceTransformationMatrixLayout() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceTransformationMatrixLayout)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceTransformationMatrixLayout(MTL::MatrixLayout instanceTransformationMatrixLayout) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceTransformationMatrixLayout_), instanceTransformationMatrixLayout); +} + +_MTL_INLINE MTL::TransformType MTL::InstanceAccelerationStructureDescriptor::motionTransformType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformType)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformType(MTL::TransformType motionTransformType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformType_), motionTransformType); +} + +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::motionTransformStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformStride)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformStride(NS::UInteger motionTransformStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformStride_), motionTransformStride); +} + +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLInstanceAccelerationStructureDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIndirectInstanceAccelerationStructureDescriptor)); +} + +_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBuffer)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorBuffer(const MTL::Buffer* instanceDescriptorBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBuffer_), instanceDescriptorBuffer); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBufferOffset)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBufferOffset_), instanceDescriptorBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorStride)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorStride_), instanceDescriptorStride); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::maxInstanceCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxInstanceCount)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMaxInstanceCount(NS::UInteger maxInstanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxInstanceCount_), maxInstanceCount); +} + +_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::instanceCountBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCountBuffer)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceCountBuffer(const MTL::Buffer* instanceCountBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCountBuffer_), instanceCountBuffer); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceCountBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCountBufferOffset)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceCountBufferOffset(NS::UInteger instanceCountBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCountBufferOffset_), instanceCountBufferOffset); +} + +_MTL_INLINE MTL::AccelerationStructureInstanceDescriptorType MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorType)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorType_), instanceDescriptorType); +} + +_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBuffer)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformBuffer(const MTL::Buffer* motionTransformBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBuffer_), motionTransformBuffer); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBufferOffset)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBufferOffset_), motionTransformBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::maxMotionTransformCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxMotionTransformCount)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMaxMotionTransformCount(NS::UInteger maxMotionTransformCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxMotionTransformCount_), maxMotionTransformCount); +} + +_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformCountBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCountBuffer)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformCountBuffer(const MTL::Buffer* motionTransformCountBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCountBuffer_), motionTransformCountBuffer); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformCountBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCountBufferOffset)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformCountBufferOffset(NS::UInteger motionTransformCountBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCountBufferOffset_), motionTransformCountBufferOffset); +} + +_MTL_INLINE MTL::MatrixLayout MTL::IndirectInstanceAccelerationStructureDescriptor::instanceTransformationMatrixLayout() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceTransformationMatrixLayout)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceTransformationMatrixLayout(MTL::MatrixLayout instanceTransformationMatrixLayout) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceTransformationMatrixLayout_), instanceTransformationMatrixLayout); +} + +_MTL_INLINE MTL::TransformType MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformType)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformType(MTL::TransformType motionTransformType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformType_), motionTransformType); +} + +_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformStride)); +} + +_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformStride(NS::UInteger motionTransformStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformStride_), motionTransformStride); +} + +_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLIndirectInstanceAccelerationStructureDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructure::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +_MTL_INLINE MTL::ResourceID MTL::AccelerationStructure::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +#pragma once + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, DataType) { + DataTypeNone = 0, + DataTypeStruct = 1, + DataTypeArray = 2, + DataTypeFloat = 3, + DataTypeFloat2 = 4, + DataTypeFloat3 = 5, + DataTypeFloat4 = 6, + DataTypeFloat2x2 = 7, + DataTypeFloat2x3 = 8, + DataTypeFloat2x4 = 9, + DataTypeFloat3x2 = 10, + DataTypeFloat3x3 = 11, + DataTypeFloat3x4 = 12, + DataTypeFloat4x2 = 13, + DataTypeFloat4x3 = 14, + DataTypeFloat4x4 = 15, + DataTypeHalf = 16, + DataTypeHalf2 = 17, + DataTypeHalf3 = 18, + DataTypeHalf4 = 19, + DataTypeHalf2x2 = 20, + DataTypeHalf2x3 = 21, + DataTypeHalf2x4 = 22, + DataTypeHalf3x2 = 23, + DataTypeHalf3x3 = 24, + DataTypeHalf3x4 = 25, + DataTypeHalf4x2 = 26, + DataTypeHalf4x3 = 27, + DataTypeHalf4x4 = 28, + DataTypeInt = 29, + DataTypeInt2 = 30, + DataTypeInt3 = 31, + DataTypeInt4 = 32, + DataTypeUInt = 33, + DataTypeUInt2 = 34, + DataTypeUInt3 = 35, + DataTypeUInt4 = 36, + DataTypeShort = 37, + DataTypeShort2 = 38, + DataTypeShort3 = 39, + DataTypeShort4 = 40, + DataTypeUShort = 41, + DataTypeUShort2 = 42, + DataTypeUShort3 = 43, + DataTypeUShort4 = 44, + DataTypeChar = 45, + DataTypeChar2 = 46, + DataTypeChar3 = 47, + DataTypeChar4 = 48, + DataTypeUChar = 49, + DataTypeUChar2 = 50, + DataTypeUChar3 = 51, + DataTypeUChar4 = 52, + DataTypeBool = 53, + DataTypeBool2 = 54, + DataTypeBool3 = 55, + DataTypeBool4 = 56, + DataTypeTexture = 58, + DataTypeSampler = 59, + DataTypePointer = 60, + DataTypeR8Unorm = 62, + DataTypeR8Snorm = 63, + DataTypeR16Unorm = 64, + DataTypeR16Snorm = 65, + DataTypeRG8Unorm = 66, + DataTypeRG8Snorm = 67, + DataTypeRG16Unorm = 68, + DataTypeRG16Snorm = 69, + DataTypeRGBA8Unorm = 70, + DataTypeRGBA8Unorm_sRGB = 71, + DataTypeRGBA8Snorm = 72, + DataTypeRGBA16Unorm = 73, + DataTypeRGBA16Snorm = 74, + DataTypeRGB10A2Unorm = 75, + DataTypeRG11B10Float = 76, + DataTypeRGB9E5Float = 77, + DataTypeRenderPipeline = 78, + DataTypeComputePipeline = 79, + DataTypeIndirectCommandBuffer = 80, + DataTypeLong = 81, + DataTypeLong2 = 82, + DataTypeLong3 = 83, + DataTypeLong4 = 84, + DataTypeULong = 85, + DataTypeULong2 = 86, + DataTypeULong3 = 87, + DataTypeULong4 = 88, + DataTypeVisibleFunctionTable = 115, + DataTypeIntersectionFunctionTable = 116, + DataTypePrimitiveAccelerationStructure = 117, + DataTypeInstanceAccelerationStructure = 118, + DataTypeBFloat = 121, + DataTypeBFloat2 = 122, + DataTypeBFloat3 = 123, + DataTypeBFloat4 = 124, +}; + +_MTL_ENUM(NS::Integer, BindingType) { + BindingTypeBuffer = 0, + BindingTypeThreadgroupMemory = 1, + BindingTypeTexture = 2, + BindingTypeSampler = 3, + BindingTypeImageblockData = 16, + BindingTypeImageblock = 17, + BindingTypeVisibleFunctionTable = 24, + BindingTypePrimitiveAccelerationStructure = 25, + BindingTypeInstanceAccelerationStructure = 26, + BindingTypeIntersectionFunctionTable = 27, + BindingTypeObjectPayload = 34, +}; + +_MTL_ENUM(NS::UInteger, ArgumentType) { + ArgumentTypeBuffer = 0, + ArgumentTypeThreadgroupMemory = 1, + ArgumentTypeTexture = 2, + ArgumentTypeSampler = 3, + ArgumentTypeImageblockData = 16, + ArgumentTypeImageblock = 17, + ArgumentTypeVisibleFunctionTable = 24, + ArgumentTypePrimitiveAccelerationStructure = 25, + ArgumentTypeInstanceAccelerationStructure = 26, + ArgumentTypeIntersectionFunctionTable = 27, +}; + +_MTL_ENUM(NS::UInteger, BindingAccess) { + BindingAccessReadOnly = 0, + BindingAccessReadWrite = 1, + BindingAccessWriteOnly = 2, + ArgumentAccessReadOnly = 0, + ArgumentAccessReadWrite = 1, + ArgumentAccessWriteOnly = 2, +}; + +class Type : public NS::Referencing +{ +public: + static class Type* alloc(); + + class Type* init(); + + MTL::DataType dataType() const; +}; + +class StructMember : public NS::Referencing +{ +public: + static class StructMember* alloc(); + + class StructMember* init(); + + NS::String* name() const; + + NS::UInteger offset() const; + + MTL::DataType dataType() const; + + class StructType* structType(); + + class ArrayType* arrayType(); + + class TextureReferenceType* textureReferenceType(); + + class PointerType* pointerType(); + + NS::UInteger argumentIndex() const; +}; + +class StructType : public NS::Referencing +{ +public: + static class StructType* alloc(); + + class StructType* init(); + + NS::Array* members() const; + + class StructMember* memberByName(const NS::String* name); +}; + +class ArrayType : public NS::Referencing +{ +public: + static class ArrayType* alloc(); + + class ArrayType* init(); + + MTL::DataType elementType() const; + + NS::UInteger arrayLength() const; + + NS::UInteger stride() const; + + NS::UInteger argumentIndexStride() const; + + class StructType* elementStructType(); + + class ArrayType* elementArrayType(); + + class TextureReferenceType* elementTextureReferenceType(); + + class PointerType* elementPointerType(); +}; + +class PointerType : public NS::Referencing +{ +public: + static class PointerType* alloc(); + + class PointerType* init(); + + MTL::DataType elementType() const; + + MTL::BindingAccess access() const; + + NS::UInteger alignment() const; + + NS::UInteger dataSize() const; + + bool elementIsArgumentBuffer() const; + + class StructType* elementStructType(); + + class ArrayType* elementArrayType(); +}; + +class TextureReferenceType : public NS::Referencing +{ +public: + static class TextureReferenceType* alloc(); + + class TextureReferenceType* init(); + + MTL::DataType textureDataType() const; + + MTL::TextureType textureType() const; + + MTL::BindingAccess access() const; + + bool isDepthTexture() const; +}; + +class Argument : public NS::Referencing +{ +public: + static class Argument* alloc(); + + class Argument* init(); + + NS::String* name() const; + + MTL::ArgumentType type() const; + + MTL::BindingAccess access() const; + + NS::UInteger index() const; + + bool active() const; + + NS::UInteger bufferAlignment() const; + + NS::UInteger bufferDataSize() const; + + MTL::DataType bufferDataType() const; + + class StructType* bufferStructType() const; + + class PointerType* bufferPointerType() const; + + NS::UInteger threadgroupMemoryAlignment() const; + + NS::UInteger threadgroupMemoryDataSize() const; + + MTL::TextureType textureType() const; + + MTL::DataType textureDataType() const; + + bool isDepthTexture() const; + + NS::UInteger arrayLength() const; +}; + +class Binding : public NS::Referencing +{ +public: + NS::String* name() const; + + MTL::BindingType type() const; + + MTL::BindingAccess access() const; + + NS::UInteger index() const; + + bool used() const; + + bool argument() const; +}; + +class BufferBinding : public NS::Referencing +{ +public: + NS::UInteger bufferAlignment() const; + + NS::UInteger bufferDataSize() const; + + MTL::DataType bufferDataType() const; + + class StructType* bufferStructType() const; + + class PointerType* bufferPointerType() const; +}; + +class ThreadgroupBinding : public NS::Referencing +{ +public: + NS::UInteger threadgroupMemoryAlignment() const; + + NS::UInteger threadgroupMemoryDataSize() const; +}; + +class TextureBinding : public NS::Referencing +{ +public: + MTL::TextureType textureType() const; + + MTL::DataType textureDataType() const; + + bool depthTexture() const; + + NS::UInteger arrayLength() const; +}; + +class ObjectPayloadBinding : public NS::Referencing +{ +public: + NS::UInteger objectPayloadAlignment() const; + + NS::UInteger objectPayloadDataSize() const; +}; + +} + +_MTL_INLINE MTL::Type* MTL::Type::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLType)); +} + +_MTL_INLINE MTL::Type* MTL::Type::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::DataType MTL::Type::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +_MTL_INLINE MTL::StructMember* MTL::StructMember::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStructMember)); +} + +_MTL_INLINE MTL::StructMember* MTL::StructMember::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::StructMember::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::UInteger MTL::StructMember::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE MTL::DataType MTL::StructMember::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +_MTL_INLINE MTL::StructType* MTL::StructMember::structType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(structType)); +} + +_MTL_INLINE MTL::ArrayType* MTL::StructMember::arrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayType)); +} + +_MTL_INLINE MTL::TextureReferenceType* MTL::StructMember::textureReferenceType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureReferenceType)); +} + +_MTL_INLINE MTL::PointerType* MTL::StructMember::pointerType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pointerType)); +} + +_MTL_INLINE NS::UInteger MTL::StructMember::argumentIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndex)); +} + +_MTL_INLINE MTL::StructType* MTL::StructType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStructType)); +} + +_MTL_INLINE MTL::StructType* MTL::StructType::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::StructType::members() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(members)); +} + +_MTL_INLINE MTL::StructMember* MTL::StructType::memberByName(const NS::String* name) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(memberByName_), name); +} + +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArrayType)); +} + +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::DataType MTL::ArrayType::elementType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementType)); +} + +_MTL_INLINE NS::UInteger MTL::ArrayType::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE NS::UInteger MTL::ArrayType::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +_MTL_INLINE NS::UInteger MTL::ArrayType::argumentIndexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndexStride)); +} + +_MTL_INLINE MTL::StructType* MTL::ArrayType::elementStructType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementStructType)); +} + +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::elementArrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementArrayType)); +} + +_MTL_INLINE MTL::TextureReferenceType* MTL::ArrayType::elementTextureReferenceType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementTextureReferenceType)); +} + +_MTL_INLINE MTL::PointerType* MTL::ArrayType::elementPointerType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementPointerType)); +} + +_MTL_INLINE MTL::PointerType* MTL::PointerType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPointerType)); +} + +_MTL_INLINE MTL::PointerType* MTL::PointerType::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::DataType MTL::PointerType::elementType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementType)); +} + +_MTL_INLINE MTL::BindingAccess MTL::PointerType::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE NS::UInteger MTL::PointerType::alignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alignment)); +} + +_MTL_INLINE NS::UInteger MTL::PointerType::dataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataSize)); +} + +_MTL_INLINE bool MTL::PointerType::elementIsArgumentBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementIsArgumentBuffer)); +} + +_MTL_INLINE MTL::StructType* MTL::PointerType::elementStructType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementStructType)); +} + +_MTL_INLINE MTL::ArrayType* MTL::PointerType::elementArrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementArrayType)); +} + +_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTextureReferenceType)); +} + +_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::DataType MTL::TextureReferenceType::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +_MTL_INLINE MTL::TextureType MTL::TextureReferenceType::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE MTL::BindingAccess MTL::TextureReferenceType::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE bool MTL::TextureReferenceType::isDepthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +_MTL_INLINE MTL::Argument* MTL::Argument::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArgument)); +} + +_MTL_INLINE MTL::Argument* MTL::Argument::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::Argument::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE MTL::ArgumentType MTL::Argument::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE MTL::BindingAccess MTL::Argument::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +_MTL_INLINE bool MTL::Argument::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::bufferAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferAlignment)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::bufferDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataSize)); +} + +_MTL_INLINE MTL::DataType MTL::Argument::bufferDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataType)); +} + +_MTL_INLINE MTL::StructType* MTL::Argument::bufferStructType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferStructType)); +} + +_MTL_INLINE MTL::PointerType* MTL::Argument::bufferPointerType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferPointerType)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryAlignment)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryDataSize)); +} + +_MTL_INLINE MTL::TextureType MTL::Argument::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE MTL::DataType MTL::Argument::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +_MTL_INLINE bool MTL::Argument::isDepthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +_MTL_INLINE NS::UInteger MTL::Argument::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE NS::String* MTL::Binding::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE MTL::BindingType MTL::Binding::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE MTL::BindingAccess MTL::Binding::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE NS::UInteger MTL::Binding::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +_MTL_INLINE bool MTL::Binding::used() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isUsed)); +} + +_MTL_INLINE bool MTL::Binding::argument() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isArgument)); +} + +_MTL_INLINE NS::UInteger MTL::BufferBinding::bufferAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferAlignment)); +} + +_MTL_INLINE NS::UInteger MTL::BufferBinding::bufferDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataSize)); +} + +_MTL_INLINE MTL::DataType MTL::BufferBinding::bufferDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataType)); +} + +_MTL_INLINE MTL::StructType* MTL::BufferBinding::bufferStructType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferStructType)); +} + +_MTL_INLINE MTL::PointerType* MTL::BufferBinding::bufferPointerType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferPointerType)); +} + +_MTL_INLINE NS::UInteger MTL::ThreadgroupBinding::threadgroupMemoryAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryAlignment)); +} + +_MTL_INLINE NS::UInteger MTL::ThreadgroupBinding::threadgroupMemoryDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryDataSize)); +} + +_MTL_INLINE MTL::TextureType MTL::TextureBinding::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE MTL::DataType MTL::TextureBinding::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +_MTL_INLINE bool MTL::TextureBinding::depthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +_MTL_INLINE NS::UInteger MTL::TextureBinding::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE NS::UInteger MTL::ObjectPayloadBinding::objectPayloadAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectPayloadAlignment)); +} + +_MTL_INLINE NS::UInteger MTL::ObjectPayloadBinding::objectPayloadDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectPayloadDataSize)); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, ResourceUsage) { + ResourceUsageRead = 1, + ResourceUsageWrite = 2, + ResourceUsageSample = 4, +}; + +_MTL_OPTIONS(NS::UInteger, BarrierScope) { + BarrierScopeBuffers = 1, + BarrierScopeTextures = 2, + BarrierScopeRenderTargets = 4, +}; + +class CommandEncoder : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + void endEncoding(); + + void insertDebugSignpost(const NS::String* string); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); +}; + +} + +_MTL_INLINE MTL::Device* MTL::CommandEncoder::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::CommandEncoder::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandEncoder::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE void MTL::CommandEncoder::endEncoding() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(endEncoding)); +} + +_MTL_INLINE void MTL::CommandEncoder::insertDebugSignpost(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(insertDebugSignpost_), string); +} + +_MTL_INLINE void MTL::CommandEncoder::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +_MTL_INLINE void MTL::CommandEncoder::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, AccelerationStructureRefitOptions) { + AccelerationStructureRefitOptionVertexData = 1, + AccelerationStructureRefitOptionPerPrimitiveData = 2, +}; + +class AccelerationStructureCommandEncoder : public NS::Referencing +{ +public: + void buildAccelerationStructure(const class AccelerationStructure* accelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset); + + void refitAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class AccelerationStructure* destinationAccelerationStructure, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset); + + void refitAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class AccelerationStructure* destinationAccelerationStructure, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset, MTL::AccelerationStructureRefitOptions options); + + void copyAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructure* destinationAccelerationStructure); + + void writeCompactedAccelerationStructureSize(const class AccelerationStructure* accelerationStructure, const class Buffer* buffer, NS::UInteger offset); + + void writeCompactedAccelerationStructureSize(const class AccelerationStructure* accelerationStructure, const class Buffer* buffer, NS::UInteger offset, MTL::DataType sizeDataType); + + void copyAndCompactAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructure* destinationAccelerationStructure); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +class AccelerationStructurePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class AccelerationStructurePassSampleBufferAttachmentDescriptor* alloc(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class AccelerationStructurePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* alloc(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* init(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class AccelerationStructurePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class AccelerationStructurePassDescriptor : public NS::Copying +{ +public: + static class AccelerationStructurePassDescriptor* alloc(); + + class AccelerationStructurePassDescriptor* init(); + + static class AccelerationStructurePassDescriptor* accelerationStructurePassDescriptor(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::buildAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(buildAccelerationStructure_descriptor_scratchBuffer_scratchBufferOffset_), accelerationStructure, descriptor, scratchBuffer, scratchBufferOffset); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::refitAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::AccelerationStructure* destinationAccelerationStructure, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_), sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::refitAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::AccelerationStructure* destinationAccelerationStructure, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset, MTL::AccelerationStructureRefitOptions options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_options_), sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset, options); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::copyAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructure* destinationAccelerationStructure) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyAccelerationStructure_toAccelerationStructure_), sourceAccelerationStructure, destinationAccelerationStructure); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::writeCompactedAccelerationStructureSize(const MTL::AccelerationStructure* accelerationStructure, const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_), accelerationStructure, buffer, offset); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::writeCompactedAccelerationStructureSize(const MTL::AccelerationStructure* accelerationStructure, const MTL::Buffer* buffer, NS::UInteger offset, MTL::DataType sizeDataType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_sizeDataType_), accelerationStructure, buffer, offset, sizeDataType); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::copyAndCompactAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructure* destinationAccelerationStructure) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyAndCompactAccelerationStructure_toAccelerationStructure_), sourceAccelerationStructure, destinationAccelerationStructure); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::accelerationStructurePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassDescriptor), _MTL_PRIVATE_SEL(accelerationStructurePassDescriptor)); +} + +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} + +#pragma once + +namespace MTL +{ + +static const NS::UInteger AttributeStrideStatic = NS::UIntegerMax; + +class ArgumentEncoder : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + NS::UInteger encodedLength() const; + + NS::UInteger alignment() const; + + void setArgumentBuffer(const class Buffer* argumentBuffer, NS::UInteger offset); + + void setArgumentBuffer(const class Buffer* argumentBuffer, NS::UInteger startOffset, NS::UInteger arrayElement); + + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setTexture(const class Texture* texture, NS::UInteger index); + + void setTextures(const class Texture* const textures[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void* constantData(NS::UInteger index); + + void setRenderPipelineState(const class RenderPipelineState* pipeline, NS::UInteger index); + + void setRenderPipelineStates(const class RenderPipelineState* const pipelines[], NS::Range range); + + void setComputePipelineState(const class ComputePipelineState* pipeline, NS::UInteger index); + + void setComputePipelineStates(const class ComputePipelineState* const pipelines[], NS::Range range); + + void setIndirectCommandBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::UInteger index); + + void setIndirectCommandBuffers(const class IndirectCommandBuffer* const buffers[], NS::Range range); + + void setAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger index); + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger index); + + void setVisibleFunctionTable(const class VisibleFunctionTable* visibleFunctionTable, NS::UInteger index); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const visibleFunctionTables[], NS::Range range); + + void setIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger index); + + void setIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); +}; + +} + +_MTL_INLINE MTL::Device* MTL::ArgumentEncoder::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::ArgumentEncoder::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE NS::UInteger MTL::ArgumentEncoder::encodedLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(encodedLength)); +} + +_MTL_INLINE NS::UInteger MTL::ArgumentEncoder::alignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alignment)); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setArgumentBuffer(const MTL::Buffer* argumentBuffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentBuffer_offset_), argumentBuffer, offset); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setArgumentBuffer(const MTL::Buffer* argumentBuffer, NS::UInteger startOffset, NS::UInteger arrayElement) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentBuffer_startOffset_arrayElement_), argumentBuffer, startOffset, arrayElement); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void* MTL::ArgumentEncoder::constantData(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantDataAtIndex_), index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setRenderPipelineState(const MTL::RenderPipelineState* pipeline, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_atIndex_), pipeline, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setRenderPipelineStates(const MTL::RenderPipelineState* const pipelines[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineStates_withRange_), pipelines, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setComputePipelineState(const MTL::ComputePipelineState* pipeline, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_atIndex_), pipeline, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setComputePipelineStates(const MTL::ComputePipelineState* const pipelines[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineStates_withRange_), pipelines, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setIndirectCommandBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndirectCommandBuffer_atIndex_), indirectCommandBuffer, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setIndirectCommandBuffers(const MTL::IndirectCommandBuffer* const buffers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndirectCommandBuffers_withRange_), buffers, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccelerationStructure_atIndex_), accelerationStructure, index); +} + +_MTL_INLINE MTL::ArgumentEncoder* MTL::ArgumentEncoder::newArgumentEncoder(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderForBufferAtIndex_), index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setVisibleFunctionTable(const MTL::VisibleFunctionTable* visibleFunctionTable, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atIndex_), visibleFunctionTable, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const visibleFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withRange_), visibleFunctionTables, range); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTable_atIndex_), intersectionFunctionTable, index); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTables_withRange_), intersectionFunctionTables, range); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, BinaryArchiveError) { + BinaryArchiveErrorNone = 0, + BinaryArchiveErrorInvalidFile = 1, + BinaryArchiveErrorUnexpectedElement = 2, + BinaryArchiveErrorCompilationFailure = 3, + BinaryArchiveErrorInternalError = 4, +}; + +class BinaryArchiveDescriptor : public NS::Copying +{ +public: + static class BinaryArchiveDescriptor* alloc(); + + class BinaryArchiveDescriptor* init(); + + NS::URL* url() const; + void setUrl(const NS::URL* url); +}; + +class BinaryArchive : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + bool addComputePipelineFunctions(const class ComputePipelineDescriptor* descriptor, NS::Error** error); + + bool addRenderPipelineFunctions(const class RenderPipelineDescriptor* descriptor, NS::Error** error); + + bool addTileRenderPipelineFunctions(const class TileRenderPipelineDescriptor* descriptor, NS::Error** error); + + bool addMeshRenderPipelineFunctions(const class MeshRenderPipelineDescriptor* descriptor, NS::Error** error); + + bool addLibrary(const class StitchedLibraryDescriptor* descriptor, NS::Error** error); + + bool serializeToURL(const NS::URL* url, NS::Error** error); + + bool addFunction(const class FunctionDescriptor* descriptor, const class Library* library, NS::Error** error); +}; + +} + +_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBinaryArchiveDescriptor)); +} + +_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::URL* MTL::BinaryArchiveDescriptor::url() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(url)); +} + +_MTL_INLINE void MTL::BinaryArchiveDescriptor::setUrl(const NS::URL* url) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUrl_), url); +} + +_MTL_INLINE NS::String* MTL::BinaryArchive::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::BinaryArchive::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::BinaryArchive::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE bool MTL::BinaryArchive::addComputePipelineFunctions(const MTL::ComputePipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addComputePipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::addRenderPipelineFunctions(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addRenderPipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::addTileRenderPipelineFunctions(const MTL::TileRenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::addMeshRenderPipelineFunctions(const MTL::MeshRenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addMeshRenderPipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::addLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addLibraryWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::serializeToURL(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error); +} + +_MTL_INLINE bool MTL::BinaryArchive::addFunction(const MTL::FunctionDescriptor* descriptor, const MTL::Library* library, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addFunctionWithDescriptor_library_error_), descriptor, library, error); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, BlitOption) { + BlitOptionNone = 0, + BlitOptionDepthFromDepthStencil = 1, + BlitOptionStencilFromDepthStencil = 2, + BlitOptionRowLinearPVRTC = 4, +}; + +class BlitCommandEncoder : public NS::Referencing +{ +public: + void synchronizeResource(const class Resource* resource); + + void synchronizeTexture(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin, MTL::BlitOption options); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage, MTL::BlitOption options); + + void generateMipmaps(const class Texture* texture); + + void fillBuffer(const class Buffer* buffer, NS::Range range, uint8_t value); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, NS::UInteger sliceCount, NS::UInteger levelCount); + + void copyFromTexture(const class Texture* sourceTexture, const class Texture* destinationTexture); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger size); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void getTextureAccessCounters(const class Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice, bool resetCounters, const class Buffer* countersBuffer, NS::UInteger countersBufferOffset); + + void resetTextureAccessCounters(const class Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice); + + void optimizeContentsForGPUAccess(const class Texture* texture); + + void optimizeContentsForGPUAccess(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void optimizeContentsForCPUAccess(const class Texture* texture); + + void optimizeContentsForCPUAccess(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void resetCommandsInBuffer(const class IndirectCommandBuffer* buffer, NS::Range range); + + void copyIndirectCommandBuffer(const class IndirectCommandBuffer* source, NS::Range sourceRange, const class IndirectCommandBuffer* destination, NS::UInteger destinationIndex); + + void optimizeIndirectCommandBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range range); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); + + void resolveCounters(const class CounterSampleBuffer* sampleBuffer, NS::Range range, const class Buffer* destinationBuffer, NS::UInteger destinationOffset); +}; + +} + +_MTL_INLINE void MTL::BlitCommandEncoder::synchronizeResource(const MTL::Resource* resource) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(synchronizeResource_), resource); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::synchronizeTexture(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(synchronizeTexture_slice_level_), texture, slice, level); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin, MTL::BlitOption options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options_), sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin, options); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage, MTL::BlitOption options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage, options); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::generateMipmaps(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(generateMipmapsForTexture_), texture); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::fillBuffer(const MTL::Buffer* buffer, NS::Range range, uint8_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(fillBuffer_range_value_), buffer, range, value); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, NS::UInteger sliceCount, NS::UInteger levelCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount_), sourceTexture, sourceSlice, sourceLevel, destinationTexture, destinationSlice, destinationLevel, sliceCount, levelCount); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, const MTL::Texture* destinationTexture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_toTexture_), sourceTexture, destinationTexture); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger size) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size_), sourceBuffer, sourceOffset, destinationBuffer, destinationOffset, size); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::getTextureAccessCounters(const MTL::Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice, bool resetCounters, const MTL::Buffer* countersBuffer, NS::UInteger countersBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getTextureAccessCounters_region_mipLevel_slice_resetCounters_countersBuffer_countersBufferOffset_), texture, region, mipLevel, slice, resetCounters, countersBuffer, countersBufferOffset); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::resetTextureAccessCounters(const MTL::Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetTextureAccessCounters_region_mipLevel_slice_), texture, region, mipLevel, slice); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForGPUAccess(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForGPUAccess_), texture); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForGPUAccess(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForGPUAccess_slice_level_), texture, slice, level); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForCPUAccess(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForCPUAccess_), texture); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForCPUAccess(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForCPUAccess_slice_level_), texture, slice, level); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::resetCommandsInBuffer(const MTL::IndirectCommandBuffer* buffer, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetCommandsInBuffer_withRange_), buffer, range); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::copyIndirectCommandBuffer(const MTL::IndirectCommandBuffer* source, NS::Range sourceRange, const MTL::IndirectCommandBuffer* destination, NS::UInteger destinationIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyIndirectCommandBuffer_sourceRange_destination_destinationIndex_), source, sourceRange, destination, destinationIndex); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeIndirectCommandBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeIndirectCommandBuffer_withRange_), indirectCommandBuffer, range); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +_MTL_INLINE void MTL::BlitCommandEncoder::resolveCounters(const MTL::CounterSampleBuffer* sampleBuffer, NS::Range range, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveCounters_inRange_destinationBuffer_destinationOffset_), sampleBuffer, range, destinationBuffer, destinationOffset); +} + +#pragma once + +namespace MTL +{ +class BlitPassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class BlitPassSampleBufferAttachmentDescriptor* alloc(); + + class BlitPassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class BlitPassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class BlitPassSampleBufferAttachmentDescriptorArray* alloc(); + + class BlitPassSampleBufferAttachmentDescriptorArray* init(); + + class BlitPassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class BlitPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class BlitPassDescriptor : public NS::Copying +{ +public: + static class BlitPassDescriptor* alloc(); + + class BlitPassDescriptor* init(); + + static class BlitPassDescriptor* blitPassDescriptor(); + + class BlitPassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassSampleBufferAttachmentDescriptor)); +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::BlitPassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +_MTL_INLINE NS::UInteger MTL::BlitPassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::BlitPassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassSampleBufferAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptorArray::setObject(const MTL::BlitPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassDescriptor)); +} + +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::blitPassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLBlitPassDescriptor), _MTL_PRIVATE_SEL(blitPassDescriptor)); +} + +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} + +#pragma once + +namespace MTL +{ +class Buffer : public NS::Referencing +{ +public: + NS::UInteger length() const; + + void* contents(); + + void didModifyRange(NS::Range range); + + class Texture* newTexture(const class TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow); + + void addDebugMarker(const NS::String* marker, NS::Range range); + + void removeAllDebugMarkers(); + + class Buffer* remoteStorageBuffer() const; + + class Buffer* newRemoteBufferViewForDevice(const class Device* device); + + uint64_t gpuAddress() const; +}; + +} + +_MTL_INLINE NS::UInteger MTL::Buffer::length() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(length)); +} + +_MTL_INLINE void* MTL::Buffer::contents() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(contents)); +} + +_MTL_INLINE void MTL::Buffer::didModifyRange(NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(didModifyRange_), range); +} + +_MTL_INLINE MTL::Texture* MTL::Buffer::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_bytesPerRow_), descriptor, offset, bytesPerRow); +} + +_MTL_INLINE void MTL::Buffer::addDebugMarker(const NS::String* marker, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addDebugMarker_range_), marker, range); +} + +_MTL_INLINE void MTL::Buffer::removeAllDebugMarkers() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeAllDebugMarkers)); +} + +_MTL_INLINE MTL::Buffer* MTL::Buffer::remoteStorageBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(remoteStorageBuffer)); +} + +_MTL_INLINE MTL::Buffer* MTL::Buffer::newRemoteBufferViewForDevice(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRemoteBufferViewForDevice_), device); +} + +_MTL_INLINE uint64_t MTL::Buffer::gpuAddress() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuAddress)); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::Integer, CaptureError) { + CaptureErrorNotSupported = 1, + CaptureErrorAlreadyCapturing = 2, + CaptureErrorInvalidDescriptor = 3, +}; + +_MTL_ENUM(NS::Integer, CaptureDestination) { + CaptureDestinationDeveloperTools = 1, + CaptureDestinationGPUTraceDocument = 2, +}; + +class CaptureDescriptor : public NS::Copying +{ +public: + static class CaptureDescriptor* alloc(); + + class CaptureDescriptor* init(); + + id captureObject() const; + void setCaptureObject(id captureObject); + + MTL::CaptureDestination destination() const; + void setDestination(MTL::CaptureDestination destination); + + NS::URL* outputURL() const; + void setOutputURL(const NS::URL* outputURL); +}; + +class CaptureManager : public NS::Referencing +{ +public: + static class CaptureManager* alloc(); + + static class CaptureManager* sharedCaptureManager(); + + MTL::CaptureManager* init(); + + class CaptureScope* newCaptureScope(const class Device* device); + + class CaptureScope* newCaptureScope(const class CommandQueue* commandQueue); + + bool supportsDestination(MTL::CaptureDestination destination); + + bool startCapture(const class CaptureDescriptor* descriptor, NS::Error** error); + + void startCapture(const class Device* device); + + void startCapture(const class CommandQueue* commandQueue); + + void startCapture(const class CaptureScope* captureScope); + + void stopCapture(); + + class CaptureScope* defaultCaptureScope() const; + void setDefaultCaptureScope(const class CaptureScope* defaultCaptureScope); + + bool isCapturing() const; +}; + +} + +_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCaptureDescriptor)); +} + +_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE id MTL::CaptureDescriptor::captureObject() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(captureObject)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setCaptureObject(id captureObject) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCaptureObject_), captureObject); +} + +_MTL_INLINE MTL::CaptureDestination MTL::CaptureDescriptor::destination() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destination)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setDestination(MTL::CaptureDestination destination) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestination_), destination); +} + +_MTL_INLINE NS::URL* MTL::CaptureDescriptor::outputURL() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(outputURL)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setOutputURL(const NS::URL* outputURL) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOutputURL_), outputURL); +} + +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCaptureManager)); +} + +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::sharedCaptureManager() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLCaptureManager), _MTL_PRIVATE_SEL(sharedCaptureManager)); +} + +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCaptureScopeWithDevice_), device); +} + +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::CommandQueue* commandQueue) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCaptureScopeWithCommandQueue_), commandQueue); +} + +_MTL_INLINE bool MTL::CaptureManager::supportsDestination(MTL::CaptureDestination destination) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsDestination_), destination); +} + +_MTL_INLINE bool MTL::CaptureManager::startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::Device* device) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithDevice_), device); +} + +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CommandQueue* commandQueue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithCommandQueue_), commandQueue); +} + +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CaptureScope* captureScope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithScope_), captureScope); +} + +_MTL_INLINE void MTL::CaptureManager::stopCapture() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(stopCapture)); +} + +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::defaultCaptureScope() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(defaultCaptureScope)); +} + +_MTL_INLINE void MTL::CaptureManager::setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDefaultCaptureScope_), defaultCaptureScope); +} + +_MTL_INLINE bool MTL::CaptureManager::isCapturing() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isCapturing)); +} + +namespace MTL +{ +class CaptureScope : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* pLabel); + + class CommandQueue* commandQueue() const; + + void beginScope(); + void endScope(); +}; +} + +_MTL_INLINE MTL::Device* MTL::CaptureScope::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::CaptureScope::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CaptureScope::setLabel(const NS::String* pLabel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), pLabel); +} + +_MTL_INLINE MTL::CommandQueue* MTL::CaptureScope::commandQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandQueue)); +} + +_MTL_INLINE void MTL::CaptureScope::beginScope() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(beginScope)); +} + +_MTL_INLINE void MTL::CaptureScope::endScope() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endScope)); +} + +#pragma once + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, CommandBufferStatus) { + CommandBufferStatusNotEnqueued = 0, + CommandBufferStatusEnqueued = 1, + CommandBufferStatusCommitted = 2, + CommandBufferStatusScheduled = 3, + CommandBufferStatusCompleted = 4, + CommandBufferStatusError = 5, +}; + +_MTL_ENUM(NS::UInteger, CommandBufferError) { + CommandBufferErrorNone = 0, + CommandBufferErrorInternal = 1, + CommandBufferErrorTimeout = 2, + CommandBufferErrorPageFault = 3, + CommandBufferErrorBlacklisted = 4, + CommandBufferErrorAccessRevoked = 4, + CommandBufferErrorNotPermitted = 7, + CommandBufferErrorOutOfMemory = 8, + CommandBufferErrorInvalidResource = 9, + CommandBufferErrorMemoryless = 10, + CommandBufferErrorDeviceRemoved = 11, + CommandBufferErrorStackOverflow = 12, +}; + +_MTL_OPTIONS(NS::UInteger, CommandBufferErrorOption) { + CommandBufferErrorOptionNone = 0, + CommandBufferErrorOptionEncoderExecutionStatus = 1, +}; + +_MTL_ENUM(NS::Integer, CommandEncoderErrorState) { + CommandEncoderErrorStateUnknown = 0, + CommandEncoderErrorStateCompleted = 1, + CommandEncoderErrorStateAffected = 2, + CommandEncoderErrorStatePending = 3, + CommandEncoderErrorStateFaulted = 4, +}; + +class CommandBufferDescriptor : public NS::Copying +{ +public: + static class CommandBufferDescriptor* alloc(); + + class CommandBufferDescriptor* init(); + + bool retainedReferences() const; + void setRetainedReferences(bool retainedReferences); + + MTL::CommandBufferErrorOption errorOptions() const; + void setErrorOptions(MTL::CommandBufferErrorOption errorOptions); + + class LogState* logState() const; + void setLogState(const class LogState* logState); +}; + +class CommandBufferEncoderInfo : public NS::Referencing +{ +public: + NS::String* label() const; + + NS::Array* debugSignposts() const; + + MTL::CommandEncoderErrorState errorState() const; +}; + +_MTL_ENUM(NS::UInteger, DispatchType) { + DispatchTypeSerial = 0, + DispatchTypeConcurrent = 1, +}; + +class CommandBuffer; + +using CommandBufferHandler = void (^)(CommandBuffer*); + +using HandlerFunction = std::function; + +class CommandBuffer : public NS::Referencing +{ +public: + void addScheduledHandler(const HandlerFunction& function); + + void addCompletedHandler(const HandlerFunction& function); + + class Device* device() const; + + class CommandQueue* commandQueue() const; + + bool retainedReferences() const; + + MTL::CommandBufferErrorOption errorOptions() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + CFTimeInterval kernelStartTime() const; + + CFTimeInterval kernelEndTime() const; + + class LogContainer* logs() const; + + CFTimeInterval GPUStartTime() const; + + CFTimeInterval GPUEndTime() const; + + void enqueue(); + + void commit(); + + void addScheduledHandler(const MTL::CommandBufferHandler block); + + void presentDrawable(const class Drawable* drawable); + + void presentDrawableAtTime(const class Drawable* drawable, CFTimeInterval presentationTime); + + void presentDrawableAfterMinimumDuration(const class Drawable* drawable, CFTimeInterval duration); + + void waitUntilScheduled(); + + void addCompletedHandler(const MTL::CommandBufferHandler block); + + void waitUntilCompleted(); + + MTL::CommandBufferStatus status() const; + + NS::Error* error() const; + + class BlitCommandEncoder* blitCommandEncoder(); + + class RenderCommandEncoder* renderCommandEncoder(const class RenderPassDescriptor* renderPassDescriptor); + + class ComputeCommandEncoder* computeCommandEncoder(const class ComputePassDescriptor* computePassDescriptor); + + class BlitCommandEncoder* blitCommandEncoder(const class BlitPassDescriptor* blitPassDescriptor); + + class ComputeCommandEncoder* computeCommandEncoder(); + + class ComputeCommandEncoder* computeCommandEncoder(MTL::DispatchType dispatchType); + + void encodeWait(const class Event* event, uint64_t value); + + void encodeSignalEvent(const class Event* event, uint64_t value); + + class ParallelRenderCommandEncoder* parallelRenderCommandEncoder(const class RenderPassDescriptor* renderPassDescriptor); + + class ResourceStateCommandEncoder* resourceStateCommandEncoder(); + + class ResourceStateCommandEncoder* resourceStateCommandEncoder(const class ResourceStatePassDescriptor* resourceStatePassDescriptor); + + class AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder(); + + class AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder(const class AccelerationStructurePassDescriptor* descriptor); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); + + void useResidencySet(const class ResidencySet* residencySet); + + void useResidencySets(const class ResidencySet* const residencySets[], NS::UInteger count); +}; + +} + +_MTL_INLINE MTL::CommandBufferDescriptor* MTL::CommandBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCommandBufferDescriptor)); +} + +_MTL_INLINE MTL::CommandBufferDescriptor* MTL::CommandBufferDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE bool MTL::CommandBufferDescriptor::retainedReferences() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(retainedReferences)); +} + +_MTL_INLINE void MTL::CommandBufferDescriptor::setRetainedReferences(bool retainedReferences) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRetainedReferences_), retainedReferences); +} + +_MTL_INLINE MTL::CommandBufferErrorOption MTL::CommandBufferDescriptor::errorOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorOptions)); +} + +_MTL_INLINE void MTL::CommandBufferDescriptor::setErrorOptions(MTL::CommandBufferErrorOption errorOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setErrorOptions_), errorOptions); +} + +_MTL_INLINE MTL::LogState* MTL::CommandBufferDescriptor::logState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(logState)); +} + +_MTL_INLINE void MTL::CommandBufferDescriptor::setLogState(const MTL::LogState* logState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLogState_), logState); +} + +_MTL_INLINE NS::String* MTL::CommandBufferEncoderInfo::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE NS::Array* MTL::CommandBufferEncoderInfo::debugSignposts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(debugSignposts)); +} + +_MTL_INLINE MTL::CommandEncoderErrorState MTL::CommandBufferEncoderInfo::errorState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorState)); +} + +_MTL_INLINE void MTL::CommandBuffer::addScheduledHandler(const HandlerFunction& function) +{ + __block HandlerFunction blockFunction = function; + + addScheduledHandler(^(MTL::CommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +_MTL_INLINE void MTL::CommandBuffer::addCompletedHandler(const HandlerFunction& function) +{ + __block HandlerFunction blockFunction = function; + + addCompletedHandler(^(MTL::CommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +_MTL_INLINE MTL::Device* MTL::CommandBuffer::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::CommandQueue* MTL::CommandBuffer::commandQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandQueue)); +} + +_MTL_INLINE bool MTL::CommandBuffer::retainedReferences() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(retainedReferences)); +} + +_MTL_INLINE MTL::CommandBufferErrorOption MTL::CommandBuffer::errorOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorOptions)); +} + +_MTL_INLINE NS::String* MTL::CommandBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandBuffer::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::kernelStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(kernelStartTime)); +} + +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::kernelEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(kernelEndTime)); +} + +_MTL_INLINE MTL::LogContainer* MTL::CommandBuffer::logs() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(logs)); +} + +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::GPUStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(GPUStartTime)); +} + +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::GPUEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(GPUEndTime)); +} + +_MTL_INLINE void MTL::CommandBuffer::enqueue() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueue)); +} + +_MTL_INLINE void MTL::CommandBuffer::commit() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(commit)); +} + +_MTL_INLINE void MTL::CommandBuffer::addScheduledHandler(const MTL::CommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addScheduledHandler_), block); +} + +_MTL_INLINE void MTL::CommandBuffer::presentDrawable(const MTL::Drawable* drawable) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_), drawable); +} + +_MTL_INLINE void MTL::CommandBuffer::presentDrawableAtTime(const MTL::Drawable* drawable, CFTimeInterval presentationTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_atTime_), drawable, presentationTime); +} + +_MTL_INLINE void MTL::CommandBuffer::presentDrawableAfterMinimumDuration(const MTL::Drawable* drawable, CFTimeInterval duration) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_afterMinimumDuration_), drawable, duration); +} + +_MTL_INLINE void MTL::CommandBuffer::waitUntilScheduled() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilScheduled)); +} + +_MTL_INLINE void MTL::CommandBuffer::addCompletedHandler(const MTL::CommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addCompletedHandler_), block); +} + +_MTL_INLINE void MTL::CommandBuffer::waitUntilCompleted() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilCompleted)); +} + +_MTL_INLINE MTL::CommandBufferStatus MTL::CommandBuffer::status() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(status)); +} + +_MTL_INLINE NS::Error* MTL::CommandBuffer::error() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(error)); +} + +_MTL_INLINE MTL::BlitCommandEncoder* MTL::CommandBuffer::blitCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(blitCommandEncoder)); +} + +_MTL_INLINE MTL::RenderCommandEncoder* MTL::CommandBuffer::renderCommandEncoder(const MTL::RenderPassDescriptor* renderPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_), renderPassDescriptor); +} + +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder(const MTL::ComputePassDescriptor* computePassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoderWithDescriptor_), computePassDescriptor); +} + +_MTL_INLINE MTL::BlitCommandEncoder* MTL::CommandBuffer::blitCommandEncoder(const MTL::BlitPassDescriptor* blitPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(blitCommandEncoderWithDescriptor_), blitPassDescriptor); +} + +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoder)); +} + +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder(MTL::DispatchType dispatchType) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoderWithDispatchType_), dispatchType); +} + +_MTL_INLINE void MTL::CommandBuffer::encodeWait(const MTL::Event* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(encodeWaitForEvent_value_), event, value); +} + +_MTL_INLINE void MTL::CommandBuffer::encodeSignalEvent(const MTL::Event* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(encodeSignalEvent_value_), event, value); +} + +_MTL_INLINE MTL::ParallelRenderCommandEncoder* MTL::CommandBuffer::parallelRenderCommandEncoder(const MTL::RenderPassDescriptor* renderPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parallelRenderCommandEncoderWithDescriptor_), renderPassDescriptor); +} + +_MTL_INLINE MTL::ResourceStateCommandEncoder* MTL::CommandBuffer::resourceStateCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceStateCommandEncoder)); +} + +_MTL_INLINE MTL::ResourceStateCommandEncoder* MTL::CommandBuffer::resourceStateCommandEncoder(const MTL::ResourceStatePassDescriptor* resourceStatePassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceStateCommandEncoderWithDescriptor_), resourceStatePassDescriptor); +} + +_MTL_INLINE MTL::AccelerationStructureCommandEncoder* MTL::CommandBuffer::accelerationStructureCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureCommandEncoder)); +} + +_MTL_INLINE MTL::AccelerationStructureCommandEncoder* MTL::CommandBuffer::accelerationStructureCommandEncoder(const MTL::AccelerationStructurePassDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureCommandEncoderWithDescriptor_), descriptor); +} + +_MTL_INLINE void MTL::CommandBuffer::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +_MTL_INLINE void MTL::CommandBuffer::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} + +_MTL_INLINE void MTL::CommandBuffer::useResidencySet(const MTL::ResidencySet* residencySet) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResidencySet_), residencySet); +} + +_MTL_INLINE void MTL::CommandBuffer::useResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResidencySets_count_), residencySets, count); +} + +#pragma once + +namespace MTL +{ +class CommandQueue : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + class CommandBuffer* commandBuffer(); + + class CommandBuffer* commandBuffer(const class CommandBufferDescriptor* descriptor); + + class CommandBuffer* commandBufferWithUnretainedReferences(); + + void insertDebugCaptureBoundary(); + + void addResidencySet(const class ResidencySet* residencySet); + + void addResidencySets(const class ResidencySet* const residencySets[], NS::UInteger count); + + void removeResidencySet(const class ResidencySet* residencySet); + + void removeResidencySets(const class ResidencySet* const residencySets[], NS::UInteger count); +}; + +class CommandQueueDescriptor : public NS::Copying +{ +public: + static class CommandQueueDescriptor* alloc(); + + class CommandQueueDescriptor* init(); + + NS::UInteger maxCommandBufferCount() const; + void setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount); + + class LogState* logState() const; + void setLogState(const class LogState* logState); +}; + +} + +_MTL_INLINE NS::String* MTL::CommandQueue::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandQueue::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::CommandQueue::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBuffer() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBuffer)); +} + +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBuffer(const MTL::CommandBufferDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBufferWithUnretainedReferences() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithUnretainedReferences)); +} + +_MTL_INLINE void MTL::CommandQueue::insertDebugCaptureBoundary() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(insertDebugCaptureBoundary)); +} + +_MTL_INLINE void MTL::CommandQueue::addResidencySet(const MTL::ResidencySet* residencySet) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addResidencySet_), residencySet); +} + +_MTL_INLINE void MTL::CommandQueue::addResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addResidencySets_count_), residencySets, count); +} + +_MTL_INLINE void MTL::CommandQueue::removeResidencySet(const MTL::ResidencySet* residencySet) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeResidencySet_), residencySet); +} + +_MTL_INLINE void MTL::CommandQueue::removeResidencySets(const MTL::ResidencySet* const residencySets[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeResidencySets_count_), residencySets, count); +} + +_MTL_INLINE MTL::CommandQueueDescriptor* MTL::CommandQueueDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCommandQueueDescriptor)); +} + +_MTL_INLINE MTL::CommandQueueDescriptor* MTL::CommandQueueDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::CommandQueueDescriptor::maxCommandBufferCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCommandBufferCount)); +} + +_MTL_INLINE void MTL::CommandQueueDescriptor::setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCommandBufferCount_), maxCommandBufferCount); +} + +_MTL_INLINE MTL::LogState* MTL::CommandQueueDescriptor::logState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(logState)); +} + +_MTL_INLINE void MTL::CommandQueueDescriptor::setLogState(const MTL::LogState* logState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLogState_), logState); +} + +#pragma once + +namespace MTL +{ +struct DispatchThreadgroupsIndirectArguments +{ + uint32_t threadgroupsPerGrid[3]; +} _MTL_PACKED; + +struct StageInRegionIndirectArguments +{ + uint32_t stageInOrigin[3]; + uint32_t stageInSize[3]; +} _MTL_PACKED; + +class ComputeCommandEncoder : public NS::Referencing +{ +public: + MTL::DispatchType dispatchType() const; + + void setComputePipelineState(const class ComputePipelineState* state); + + void setBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range); + + void setBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void setBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index); + + void setVisibleFunctionTable(const class VisibleFunctionTable* visibleFunctionTable, NS::UInteger bufferIndex); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const visibleFunctionTables[], NS::Range range); + + void setIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setTexture(const class Texture* texture, NS::UInteger index); + + void setTextures(const class Texture* const textures[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setImageblockWidth(NS::UInteger width, NS::UInteger height); + + void setStageInRegion(MTL::Region region); + + void setStageInRegion(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void dispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup); + + void dispatchThreadgroups(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerThreadgroup); + + void dispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandbuffer, const class Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset); + + void memoryBarrier(MTL::BarrierScope scope); + + void memoryBarrier(const class Resource* const resources[], NS::UInteger count); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +} + +_MTL_INLINE MTL::DispatchType MTL::ComputeCommandEncoder::dispatchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchType)); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setComputePipelineState(const MTL::ComputePipelineState* state) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_), state); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_attributeStrides_withRange_), buffers, offsets, strides, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferOffset_attributeStride_atIndex_), offset, stride, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBytes_length_attributeStride_atIndex_), bytes, length, stride, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setVisibleFunctionTable(const MTL::VisibleFunctionTable* visibleFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atBufferIndex_), visibleFunctionTable, bufferIndex); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const visibleFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withBufferRange_), visibleFunctionTables, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_atIndex_), length, index); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setImageblockWidth(NS::UInteger width, NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockWidth_height_), width, height); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setStageInRegion(MTL::Region region) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegion_), region); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::setStageInRegion(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegionWithIndirectBuffer_indirectBufferOffset_), indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadgroups_threadsPerThreadgroup_), threadgroupsPerGrid, threadsPerThreadgroup); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreadgroups(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup_), indirectBuffer, indirectBufferOffset, threadsPerThreadgroup); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreads_threadsPerThreadgroup_), threadsPerGrid, threadsPerThreadgroup); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_withRange_), indirectCommandBuffer, executionRange); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandbuffer, const MTL::Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_), indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::memoryBarrier(MTL::BarrierScope scope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithScope_), scope); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::memoryBarrier(const MTL::Resource* const resources[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithResources_count_), resources, count); +} + +_MTL_INLINE void MTL::ComputeCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +#pragma once + +namespace MTL +{ +class ComputePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class ComputePassSampleBufferAttachmentDescriptor* alloc(); + + class ComputePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class ComputePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class ComputePassSampleBufferAttachmentDescriptorArray* alloc(); + + class ComputePassSampleBufferAttachmentDescriptorArray* init(); + + class ComputePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class ComputePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class ComputePassDescriptor : public NS::Copying +{ +public: + static class ComputePassDescriptor* alloc(); + + class ComputePassDescriptor* init(); + + static class ComputePassDescriptor* computePassDescriptor(); + + MTL::DispatchType dispatchType() const; + void setDispatchType(MTL::DispatchType dispatchType); + + class ComputePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassSampleBufferAttachmentDescriptor)); +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::ComputePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +_MTL_INLINE NS::UInteger MTL::ComputePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::ComputePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassSampleBufferAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::ComputePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassDescriptor)); +} + +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::computePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLComputePassDescriptor), _MTL_PRIVATE_SEL(computePassDescriptor)); +} + +_MTL_INLINE MTL::DispatchType MTL::ComputePassDescriptor::dispatchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchType)); +} + +_MTL_INLINE void MTL::ComputePassDescriptor::setDispatchType(MTL::DispatchType dispatchType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDispatchType_), dispatchType); +} + +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} + +#pragma once + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, Mutability) { + MutabilityDefault = 0, + MutabilityMutable = 1, + MutabilityImmutable = 2, +}; + +_MTL_ENUM(NS::Integer, ShaderValidation) { + ShaderValidationDefault = 0, + ShaderValidationEnabled = 1, + ShaderValidationDisabled = 2, +}; + +class PipelineBufferDescriptor : public NS::Copying +{ +public: + static class PipelineBufferDescriptor* alloc(); + + class PipelineBufferDescriptor* init(); + + MTL::Mutability mutability() const; + void setMutability(MTL::Mutability mutability); +}; + +class PipelineBufferDescriptorArray : public NS::Referencing +{ +public: + static class PipelineBufferDescriptorArray* alloc(); + + class PipelineBufferDescriptorArray* init(); + + class PipelineBufferDescriptor* object(NS::UInteger bufferIndex); + + void setObject(const class PipelineBufferDescriptor* buffer, NS::UInteger bufferIndex); +}; + +} + +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPipelineBufferDescriptor)); +} + +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Mutability MTL::PipelineBufferDescriptor::mutability() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mutability)); +} + +_MTL_INLINE void MTL::PipelineBufferDescriptor::setMutability(MTL::Mutability mutability) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMutability_), mutability); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::PipelineBufferDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPipelineBufferDescriptorArray)); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::PipelineBufferDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptorArray::object(NS::UInteger bufferIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), bufferIndex); +} + +_MTL_INLINE void MTL::PipelineBufferDescriptorArray::setObject(const MTL::PipelineBufferDescriptor* buffer, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), buffer, bufferIndex); +} + +namespace MTL +{ +class ComputePipelineReflection : public NS::Referencing +{ +public: + static class ComputePipelineReflection* alloc(); + + class ComputePipelineReflection* init(); + + NS::Array* bindings() const; + + NS::Array* arguments() const; +}; + +class ComputePipelineDescriptor : public NS::Copying +{ +public: + static class ComputePipelineDescriptor* alloc(); + + class ComputePipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* computeFunction() const; + void setComputeFunction(const class Function* computeFunction); + + bool threadGroupSizeIsMultipleOfThreadExecutionWidth() const; + void setThreadGroupSizeIsMultipleOfThreadExecutionWidth(bool threadGroupSizeIsMultipleOfThreadExecutionWidth); + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); + + class StageInputOutputDescriptor* stageInputDescriptor() const; + void setStageInputDescriptor(const class StageInputOutputDescriptor* stageInputDescriptor); + + class PipelineBufferDescriptorArray* buffers() const; + + bool supportIndirectCommandBuffers() const; + void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers); + + NS::Array* insertLibraries() const; + void setInsertLibraries(const NS::Array* insertLibraries); + + NS::Array* preloadedLibraries() const; + void setPreloadedLibraries(const NS::Array* preloadedLibraries); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + void reset(); + + class LinkedFunctions* linkedFunctions() const; + void setLinkedFunctions(const class LinkedFunctions* linkedFunctions); + + bool supportAddingBinaryFunctions() const; + void setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions); + + NS::UInteger maxCallStackDepth() const; + void setMaxCallStackDepth(NS::UInteger maxCallStackDepth); + + MTL::ShaderValidation shaderValidation() const; + void setShaderValidation(MTL::ShaderValidation shaderValidation); +}; + +class ComputePipelineState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + + NS::UInteger threadExecutionWidth() const; + + NS::UInteger staticThreadgroupMemoryLength() const; + + NS::UInteger imageblockMemoryLength(MTL::Size imageblockDimensions); + + bool supportIndirectCommandBuffers() const; + + MTL::ResourceID gpuResourceID() const; + + class FunctionHandle* functionHandle(const class Function* function); + + class ComputePipelineState* newComputePipelineState(const NS::Array* functions, NS::Error** error); + + class VisibleFunctionTable* newVisibleFunctionTable(const class VisibleFunctionTableDescriptor* descriptor); + + class IntersectionFunctionTable* newIntersectionFunctionTable(const class IntersectionFunctionTableDescriptor* descriptor); + + MTL::ShaderValidation shaderValidation() const; +}; + +} + +_MTL_INLINE MTL::ComputePipelineReflection* MTL::ComputePipelineReflection::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePipelineReflection)); +} + +_MTL_INLINE MTL::ComputePipelineReflection* MTL::ComputePipelineReflection::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::ComputePipelineReflection::bindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bindings)); +} + +_MTL_INLINE NS::Array* MTL::ComputePipelineReflection::arguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arguments)); +} + +_MTL_INLINE MTL::ComputePipelineDescriptor* MTL::ComputePipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePipelineDescriptor)); +} + +_MTL_INLINE MTL::ComputePipelineDescriptor* MTL::ComputePipelineDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::ComputePipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Function* MTL::ComputePipelineDescriptor::computeFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeFunction)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setComputeFunction(const MTL::Function* computeFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputeFunction_), computeFunction); +} + +_MTL_INLINE bool MTL::ComputePipelineDescriptor::threadGroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadGroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setThreadGroupSizeIsMultipleOfThreadExecutionWidth(bool threadGroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadGroupSizeIsMultipleOfThreadExecutionWidth_), threadGroupSizeIsMultipleOfThreadExecutionWidth); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineDescriptor::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::ComputePipelineDescriptor::stageInputDescriptor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stageInputDescriptor)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setStageInputDescriptor(const MTL::StageInputOutputDescriptor* stageInputDescriptor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInputDescriptor_), stageInputDescriptor); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::ComputePipelineDescriptor::buffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffers)); +} + +_MTL_INLINE bool MTL::ComputePipelineDescriptor::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers); +} + +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::insertLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(insertLibraries)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setInsertLibraries(const NS::Array* insertLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInsertLibraries_), insertLibraries); +} + +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::preloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preloadedLibraries)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setPreloadedLibraries(const NS::Array* preloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreloadedLibraries_), preloadedLibraries); +} + +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::ComputePipelineDescriptor::linkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(linkedFunctions)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setLinkedFunctions(const MTL::LinkedFunctions* linkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLinkedFunctions_), linkedFunctions); +} + +_MTL_INLINE bool MTL::ComputePipelineDescriptor::supportAddingBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingBinaryFunctions)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingBinaryFunctions_), supportAddingBinaryFunctions); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineDescriptor::maxCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCallStackDepth)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setMaxCallStackDepth(NS::UInteger maxCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCallStackDepth_), maxCallStackDepth); +} + +_MTL_INLINE MTL::ShaderValidation MTL::ComputePipelineDescriptor::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setShaderValidation(MTL::ShaderValidation shaderValidation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShaderValidation_), shaderValidation); +} + +_MTL_INLINE NS::String* MTL::ComputePipelineState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::Device* MTL::ComputePipelineState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::threadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadExecutionWidth)); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::staticThreadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(staticThreadgroupMemoryLength)); +} + +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::imageblockMemoryLength(MTL::Size imageblockDimensions) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockMemoryLengthForDimensions_), imageblockDimensions); +} + +_MTL_INLINE bool MTL::ComputePipelineState::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE MTL::ResourceID MTL::ComputePipelineState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE MTL::FunctionHandle* MTL::ComputePipelineState::functionHandle(const MTL::Function* function) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionHandleWithFunction_), function); +} + +_MTL_INLINE MTL::ComputePipelineState* MTL::ComputePipelineState::newComputePipelineState(const NS::Array* functions, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithAdditionalBinaryFunctions_error_), functions, error); +} + +_MTL_INLINE MTL::VisibleFunctionTable* MTL::ComputePipelineState::newVisibleFunctionTable(const MTL::VisibleFunctionTableDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newVisibleFunctionTableWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::IntersectionFunctionTable* MTL::ComputePipelineState::newIntersectionFunctionTable(const MTL::IntersectionFunctionTableDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionTableWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::ShaderValidation MTL::ComputePipelineState::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +#pragma once + +namespace MTL +{ +struct CounterResultTimestamp +{ + uint64_t timestamp; +} _MTL_PACKED; + +struct CounterResultStageUtilization +{ + uint64_t totalCycles; + uint64_t vertexCycles; + uint64_t tessellationCycles; + uint64_t postTessellationVertexCycles; + uint64_t fragmentCycles; + uint64_t renderTargetCycles; +} _MTL_PACKED; + +struct CounterResultStatistic +{ + uint64_t tessellationInputPatches; + uint64_t vertexInvocations; + uint64_t postTessellationVertexInvocations; + uint64_t clipperInvocations; + uint64_t clipperPrimitivesOut; + uint64_t fragmentInvocations; + uint64_t fragmentsPassed; + uint64_t computeKernelInvocations; +} _MTL_PACKED; + +_MTL_CONST(NS::ErrorDomain, CounterErrorDomain); + +using CommonCounter = NS::String*; + +_MTL_CONST(CommonCounter, CommonCounterTimestamp); +_MTL_CONST(CommonCounter, CommonCounterTessellationInputPatches); +_MTL_CONST(CommonCounter, CommonCounterVertexInvocations); +_MTL_CONST(CommonCounter, CommonCounterPostTessellationVertexInvocations); +_MTL_CONST(CommonCounter, CommonCounterClipperInvocations); +_MTL_CONST(CommonCounter, CommonCounterClipperPrimitivesOut); +_MTL_CONST(CommonCounter, CommonCounterFragmentInvocations); +_MTL_CONST(CommonCounter, CommonCounterFragmentsPassed); +_MTL_CONST(CommonCounter, CommonCounterComputeKernelInvocations); +_MTL_CONST(CommonCounter, CommonCounterTotalCycles); +_MTL_CONST(CommonCounter, CommonCounterVertexCycles); +_MTL_CONST(CommonCounter, CommonCounterTessellationCycles); +_MTL_CONST(CommonCounter, CommonCounterPostTessellationVertexCycles); +_MTL_CONST(CommonCounter, CommonCounterFragmentCycles); +_MTL_CONST(CommonCounter, CommonCounterRenderTargetWriteCycles); + +using CommonCounterSet = NS::String*; + +_MTL_CONST(CommonCounterSet, CommonCounterSetTimestamp); +_MTL_CONST(CommonCounterSet, CommonCounterSetStageUtilization); +_MTL_CONST(CommonCounterSet, CommonCounterSetStatistic); + +class Counter : public NS::Referencing +{ +public: + NS::String* name() const; +}; + +class CounterSet : public NS::Referencing +{ +public: + NS::String* name() const; + + NS::Array* counters() const; +}; + +class CounterSampleBufferDescriptor : public NS::Copying +{ +public: + static class CounterSampleBufferDescriptor* alloc(); + + class CounterSampleBufferDescriptor* init(); + + class CounterSet* counterSet() const; + void setCounterSet(const class CounterSet* counterSet); + + NS::String* label() const; + void setLabel(const NS::String* label); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); +}; + +class CounterSampleBuffer : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + + NS::UInteger sampleCount() const; + + NS::Data* resolveCounterRange(NS::Range range); +}; + +_MTL_ENUM(NS::Integer, CounterSampleBufferError) { + CounterSampleBufferErrorOutOfMemory = 0, + CounterSampleBufferErrorInvalid = 1, + CounterSampleBufferErrorInternal = 2, +}; + +} + +_MTL_PRIVATE_DEF_STR(NS::ErrorDomain, CounterErrorDomain); + +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTimestamp); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTessellationInputPatches); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterVertexInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterPostTessellationVertexInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterClipperInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterClipperPrimitivesOut); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentsPassed); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterComputeKernelInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTotalCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterVertexCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTessellationCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterPostTessellationVertexCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterRenderTargetWriteCycles); + +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetTimestamp); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetStageUtilization); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetStatistic); + +_MTL_INLINE NS::String* MTL::Counter::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::String* MTL::CounterSet::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::Array* MTL::CounterSet::counters() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counters)); +} + +_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCounterSampleBufferDescriptor)); +} + +_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSet* MTL::CounterSampleBufferDescriptor::counterSet() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counterSet)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setCounterSet(const MTL::CounterSet* counterSet) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCounterSet_), counterSet); +} + +_MTL_INLINE NS::String* MTL::CounterSampleBufferDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::StorageMode MTL::CounterSampleBufferDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +_MTL_INLINE NS::UInteger MTL::CounterSampleBufferDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +_MTL_INLINE MTL::Device* MTL::CounterSampleBuffer::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::CounterSampleBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE NS::UInteger MTL::CounterSampleBuffer::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE NS::Data* MTL::CounterSampleBuffer::resolveCounterRange(NS::Range range) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveCounterRange_), range); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, CompareFunction) { + CompareFunctionNever = 0, + CompareFunctionLess = 1, + CompareFunctionEqual = 2, + CompareFunctionLessEqual = 3, + CompareFunctionGreater = 4, + CompareFunctionNotEqual = 5, + CompareFunctionGreaterEqual = 6, + CompareFunctionAlways = 7, +}; + +_MTL_ENUM(NS::UInteger, StencilOperation) { + StencilOperationKeep = 0, + StencilOperationZero = 1, + StencilOperationReplace = 2, + StencilOperationIncrementClamp = 3, + StencilOperationDecrementClamp = 4, + StencilOperationInvert = 5, + StencilOperationIncrementWrap = 6, + StencilOperationDecrementWrap = 7, +}; + +class StencilDescriptor : public NS::Copying +{ +public: + static class StencilDescriptor* alloc(); + + class StencilDescriptor* init(); + + MTL::CompareFunction stencilCompareFunction() const; + void setStencilCompareFunction(MTL::CompareFunction stencilCompareFunction); + + MTL::StencilOperation stencilFailureOperation() const; + void setStencilFailureOperation(MTL::StencilOperation stencilFailureOperation); + + MTL::StencilOperation depthFailureOperation() const; + void setDepthFailureOperation(MTL::StencilOperation depthFailureOperation); + + MTL::StencilOperation depthStencilPassOperation() const; + void setDepthStencilPassOperation(MTL::StencilOperation depthStencilPassOperation); + + uint32_t readMask() const; + void setReadMask(uint32_t readMask); + + uint32_t writeMask() const; + void setWriteMask(uint32_t writeMask); +}; + +class DepthStencilDescriptor : public NS::Copying +{ +public: + static class DepthStencilDescriptor* alloc(); + + class DepthStencilDescriptor* init(); + + MTL::CompareFunction depthCompareFunction() const; + void setDepthCompareFunction(MTL::CompareFunction depthCompareFunction); + + bool depthWriteEnabled() const; + void setDepthWriteEnabled(bool depthWriteEnabled); + + class StencilDescriptor* frontFaceStencil() const; + void setFrontFaceStencil(const class StencilDescriptor* frontFaceStencil); + + class StencilDescriptor* backFaceStencil() const; + void setBackFaceStencil(const class StencilDescriptor* backFaceStencil); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class DepthStencilState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; +}; + +} + +_MTL_INLINE MTL::StencilDescriptor* MTL::StencilDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStencilDescriptor)); +} + +_MTL_INLINE MTL::StencilDescriptor* MTL::StencilDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CompareFunction MTL::StencilDescriptor::stencilCompareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilCompareFunction)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setStencilCompareFunction(MTL::CompareFunction stencilCompareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilCompareFunction_), stencilCompareFunction); +} + +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::stencilFailureOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilFailureOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setStencilFailureOperation(MTL::StencilOperation stencilFailureOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilFailureOperation_), stencilFailureOperation); +} + +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::depthFailureOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthFailureOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setDepthFailureOperation(MTL::StencilOperation depthFailureOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthFailureOperation_), depthFailureOperation); +} + +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::depthStencilPassOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthStencilPassOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setDepthStencilPassOperation(MTL::StencilOperation depthStencilPassOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStencilPassOperation_), depthStencilPassOperation); +} + +_MTL_INLINE uint32_t MTL::StencilDescriptor::readMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(readMask)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setReadMask(uint32_t readMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setReadMask_), readMask); +} + +_MTL_INLINE uint32_t MTL::StencilDescriptor::writeMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(writeMask)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setWriteMask(uint32_t writeMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWriteMask_), writeMask); +} + +_MTL_INLINE MTL::DepthStencilDescriptor* MTL::DepthStencilDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLDepthStencilDescriptor)); +} + +_MTL_INLINE MTL::DepthStencilDescriptor* MTL::DepthStencilDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CompareFunction MTL::DepthStencilDescriptor::depthCompareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthCompareFunction)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setDepthCompareFunction(MTL::CompareFunction depthCompareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthCompareFunction_), depthCompareFunction); +} + +_MTL_INLINE bool MTL::DepthStencilDescriptor::depthWriteEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthWriteEnabled)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setDepthWriteEnabled(bool depthWriteEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthWriteEnabled_), depthWriteEnabled); +} + +_MTL_INLINE MTL::StencilDescriptor* MTL::DepthStencilDescriptor::frontFaceStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(frontFaceStencil)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setFrontFaceStencil(const MTL::StencilDescriptor* frontFaceStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFrontFaceStencil_), frontFaceStencil); +} + +_MTL_INLINE MTL::StencilDescriptor* MTL::DepthStencilDescriptor::backFaceStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(backFaceStencil)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setBackFaceStencil(const MTL::StencilDescriptor* backFaceStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBackFaceStencil_), backFaceStencil); +} + +_MTL_INLINE NS::String* MTL::DepthStencilDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE NS::String* MTL::DepthStencilState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::Device* MTL::DepthStencilState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +#pragma once + +#include +#include + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOCompressionMethod) { + IOCompressionMethodZlib = 0, + IOCompressionMethodLZFSE = 1, + IOCompressionMethodLZ4 = 2, + IOCompressionMethodLZMA = 3, + IOCompressionMethodLZBitmap = 4, +}; + +_MTL_ENUM(NS::UInteger, FeatureSet) { + FeatureSet_iOS_GPUFamily1_v1 = 0, + FeatureSet_iOS_GPUFamily2_v1 = 1, + FeatureSet_iOS_GPUFamily1_v2 = 2, + FeatureSet_iOS_GPUFamily2_v2 = 3, + FeatureSet_iOS_GPUFamily3_v1 = 4, + FeatureSet_iOS_GPUFamily1_v3 = 5, + FeatureSet_iOS_GPUFamily2_v3 = 6, + FeatureSet_iOS_GPUFamily3_v2 = 7, + FeatureSet_iOS_GPUFamily1_v4 = 8, + FeatureSet_iOS_GPUFamily2_v4 = 9, + FeatureSet_iOS_GPUFamily3_v3 = 10, + FeatureSet_iOS_GPUFamily4_v1 = 11, + FeatureSet_iOS_GPUFamily1_v5 = 12, + FeatureSet_iOS_GPUFamily2_v5 = 13, + FeatureSet_iOS_GPUFamily3_v4 = 14, + FeatureSet_iOS_GPUFamily4_v2 = 15, + FeatureSet_iOS_GPUFamily5_v1 = 16, + FeatureSet_macOS_GPUFamily1_v1 = 10000, + FeatureSet_OSX_GPUFamily1_v1 = 10000, + FeatureSet_macOS_GPUFamily1_v2 = 10001, + FeatureSet_OSX_GPUFamily1_v2 = 10001, + FeatureSet_macOS_ReadWriteTextureTier2 = 10002, + FeatureSet_OSX_ReadWriteTextureTier2 = 10002, + FeatureSet_macOS_GPUFamily1_v3 = 10003, + FeatureSet_macOS_GPUFamily1_v4 = 10004, + FeatureSet_macOS_GPUFamily2_v1 = 10005, + FeatureSet_watchOS_GPUFamily1_v1 = 20000, + FeatureSet_WatchOS_GPUFamily1_v1 = 20000, + FeatureSet_watchOS_GPUFamily2_v1 = 20001, + FeatureSet_WatchOS_GPUFamily2_v1 = 20001, + FeatureSet_tvOS_GPUFamily1_v1 = 30000, + FeatureSet_TVOS_GPUFamily1_v1 = 30000, + FeatureSet_tvOS_GPUFamily1_v2 = 30001, + FeatureSet_tvOS_GPUFamily1_v3 = 30002, + FeatureSet_tvOS_GPUFamily2_v1 = 30003, + FeatureSet_tvOS_GPUFamily1_v4 = 30004, + FeatureSet_tvOS_GPUFamily2_v2 = 30005, +}; + +_MTL_ENUM(NS::Integer, GPUFamily) { + GPUFamilyApple1 = 1001, + GPUFamilyApple2 = 1002, + GPUFamilyApple3 = 1003, + GPUFamilyApple4 = 1004, + GPUFamilyApple5 = 1005, + GPUFamilyApple6 = 1006, + GPUFamilyApple7 = 1007, + GPUFamilyApple8 = 1008, + GPUFamilyApple9 = 1009, + GPUFamilyMac1 = 2001, + GPUFamilyMac2 = 2002, + GPUFamilyCommon1 = 3001, + GPUFamilyCommon2 = 3002, + GPUFamilyCommon3 = 3003, + GPUFamilyMacCatalyst1 = 4001, + GPUFamilyMacCatalyst2 = 4002, + GPUFamilyMetal3 = 5001, +}; + +_MTL_ENUM(NS::UInteger, DeviceLocation) { + DeviceLocationBuiltIn = 0, + DeviceLocationSlot = 1, + DeviceLocationExternal = 2, + DeviceLocationUnspecified = NS::UIntegerMax, +}; + +_MTL_OPTIONS(NS::UInteger, PipelineOption) { + PipelineOptionNone = 0, + PipelineOptionArgumentInfo = 1, + PipelineOptionBindingInfo = 1, + PipelineOptionBufferTypeInfo = 2, + PipelineOptionFailOnBinaryArchiveMiss = 4, +}; + +_MTL_ENUM(NS::UInteger, ReadWriteTextureTier) { + ReadWriteTextureTierNone = 0, + ReadWriteTextureTier1 = 1, + ReadWriteTextureTier2 = 2, +}; + +_MTL_ENUM(NS::UInteger, ArgumentBuffersTier) { + ArgumentBuffersTier1 = 0, + ArgumentBuffersTier2 = 1, +}; + +_MTL_ENUM(NS::UInteger, SparseTextureRegionAlignmentMode) { + SparseTextureRegionAlignmentModeOutward = 0, + SparseTextureRegionAlignmentModeInward = 1, +}; + +_MTL_ENUM(NS::Integer, SparsePageSize) { + SparsePageSize16 = 101, + SparsePageSize64 = 102, + SparsePageSize256 = 103, +}; + +struct AccelerationStructureSizes +{ + NS::UInteger accelerationStructureSize; + NS::UInteger buildScratchBufferSize; + NS::UInteger refitScratchBufferSize; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, CounterSamplingPoint) { + CounterSamplingPointAtStageBoundary = 0, + CounterSamplingPointAtDrawBoundary = 1, + CounterSamplingPointAtDispatchBoundary = 2, + CounterSamplingPointAtTileDispatchBoundary = 3, + CounterSamplingPointAtBlitBoundary = 4, +}; + +struct SizeAndAlign +{ + NS::UInteger size; + NS::UInteger align; +} _MTL_PACKED; + +class ArgumentDescriptor : public NS::Copying +{ +public: + static class ArgumentDescriptor* alloc(); + + class ArgumentDescriptor* init(); + + static class ArgumentDescriptor* argumentDescriptor(); + + MTL::DataType dataType() const; + void setDataType(MTL::DataType dataType); + + NS::UInteger index() const; + void setIndex(NS::UInteger index); + + NS::UInteger arrayLength() const; + void setArrayLength(NS::UInteger arrayLength); + + MTL::BindingAccess access() const; + void setAccess(MTL::BindingAccess access); + + MTL::TextureType textureType() const; + void setTextureType(MTL::TextureType textureType); + + NS::UInteger constantBlockAlignment() const; + void setConstantBlockAlignment(NS::UInteger constantBlockAlignment); +}; + +class Architecture : public NS::Copying +{ +public: + static class Architecture* alloc(); + + class Architecture* init(); + + NS::String* name() const; +}; + +using DeviceNotificationName = NS::String*; +_MTL_CONST(DeviceNotificationName, DeviceWasAddedNotification); +_MTL_CONST(DeviceNotificationName, DeviceRemovalRequestedNotification); +_MTL_CONST(DeviceNotificationName, DeviceWasRemovedNotification); +_MTL_CONST(NS::ErrorUserInfoKey, CommandBufferEncoderInfoErrorKey); + +using DeviceNotificationHandlerBlock = void (^)(class Device* pDevice, DeviceNotificationName notifyName); + +using DeviceNotificationHandlerFunction = std::function; + +using AutoreleasedComputePipelineReflection = class ComputePipelineReflection*; + +using AutoreleasedRenderPipelineReflection = class RenderPipelineReflection*; + +using NewLibraryCompletionHandler = void (^)(class Library*, NS::Error*); + +using NewLibraryCompletionHandlerFunction = std::function; + +using NewRenderPipelineStateCompletionHandler = void (^)(class RenderPipelineState*, NS::Error*); + +using NewRenderPipelineStateCompletionHandlerFunction = std::function; + +using NewRenderPipelineStateWithReflectionCompletionHandler = void (^)(class RenderPipelineState*, class RenderPipelineReflection*, NS::Error*); + +using NewRenderPipelineStateWithReflectionCompletionHandlerFunction = std::function; + +using NewComputePipelineStateCompletionHandler = void (^)(class ComputePipelineState*, NS::Error*); + +using NewComputePipelineStateCompletionHandlerFunction = std::function; + +using NewComputePipelineStateWithReflectionCompletionHandler = void (^)(class ComputePipelineState*, class ComputePipelineReflection*, NS::Error*); + +using NewComputePipelineStateWithReflectionCompletionHandlerFunction = std::function; + +using Timestamp = std::uint64_t; + +MTL::Device* CreateSystemDefaultDevice(); + +NS::Array* CopyAllDevices(); + +NS::Array* CopyAllDevicesWithObserver(NS::Object** pOutObserver, DeviceNotificationHandlerBlock handler); + +NS::Array* CopyAllDevicesWithObserver(NS::Object** pOutObserver, const DeviceNotificationHandlerFunction& handler); + +void RemoveDeviceObserver(const NS::Object* pObserver); + +class Device : public NS::Referencing +{ +public: + void newLibrary(const NS::String* pSource, const class CompileOptions* pOptions, const NewLibraryCompletionHandlerFunction& completionHandler); + + void newLibrary(const class StitchedLibraryDescriptor* pDescriptor, const MTL::NewLibraryCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* pDescriptor, const NewRenderPipelineStateCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class TileRenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class Function* pFunction, const NewComputePipelineStateCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class Function* pFunction, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class ComputePipelineDescriptor* pDescriptor, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + bool isHeadless() const; + + NS::String* name() const; + + uint64_t registryID() const; + + class Architecture* architecture() const; + + MTL::Size maxThreadsPerThreadgroup() const; + + bool lowPower() const; + + bool headless() const; + + bool removable() const; + + bool hasUnifiedMemory() const; + + uint64_t recommendedMaxWorkingSetSize() const; + + MTL::DeviceLocation location() const; + + NS::UInteger locationNumber() const; + + uint64_t maxTransferRate() const; + + bool depth24Stencil8PixelFormatSupported() const; + + MTL::ReadWriteTextureTier readWriteTextureSupport() const; + + MTL::ArgumentBuffersTier argumentBuffersSupport() const; + + bool rasterOrderGroupsSupported() const; + + bool supports32BitFloatFiltering() const; + + bool supports32BitMSAA() const; + + bool supportsQueryTextureLOD() const; + + bool supportsBCTextureCompression() const; + + bool supportsPullModelInterpolation() const; + + bool barycentricCoordsSupported() const; + + bool supportsShaderBarycentricCoordinates() const; + + NS::UInteger currentAllocatedSize() const; + + class LogState* newLogState(const class LogStateDescriptor* descriptor, NS::Error** error); + + class CommandQueue* newCommandQueue(); + + class CommandQueue* newCommandQueue(NS::UInteger maxCommandBufferCount); + + class CommandQueue* newCommandQueue(const class CommandQueueDescriptor* descriptor); + + MTL::SizeAndAlign heapTextureSizeAndAlign(const class TextureDescriptor* desc); + + MTL::SizeAndAlign heapBufferSizeAndAlign(NS::UInteger length, MTL::ResourceOptions options); + + class Heap* newHeap(const class HeapDescriptor* descriptor); + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options); + + class Buffer* newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options); + + class Buffer* newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options, void (^deallocator)(void*, NS::UInteger)); + + class DepthStencilState* newDepthStencilState(const class DepthStencilDescriptor* descriptor); + + class Texture* newTexture(const class TextureDescriptor* descriptor); + + class Texture* newTexture(const class TextureDescriptor* descriptor, const IOSurfaceRef iosurface, NS::UInteger plane); + + class Texture* newSharedTexture(const class TextureDescriptor* descriptor); + + class Texture* newSharedTexture(const class SharedTextureHandle* sharedHandle); + + class SamplerState* newSamplerState(const class SamplerDescriptor* descriptor); + + class Library* newDefaultLibrary(); + + class Library* newDefaultLibrary(const NS::Bundle* bundle, NS::Error** error); + + class Library* newLibrary(const NS::String* filepath, NS::Error** error); + + class Library* newLibrary(const NS::URL* url, NS::Error** error); + + class Library* newLibrary(const dispatch_data_t data, NS::Error** error); + + class Library* newLibrary(const NS::String* source, const class CompileOptions* options, NS::Error** error); + + void newLibrary(const NS::String* source, const class CompileOptions* options, const MTL::NewLibraryCompletionHandler completionHandler); + + class Library* newLibrary(const class StitchedLibraryDescriptor* descriptor, NS::Error** error); + + void newLibrary(const class StitchedLibraryDescriptor* descriptor, const MTL::NewLibraryCompletionHandler completionHandler); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, NS::Error** error); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, const MTL::NewRenderPipelineStateCompletionHandler completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + class ComputePipelineState* newComputePipelineState(const class Function* computeFunction, NS::Error** error); + + class ComputePipelineState* newComputePipelineState(const class Function* computeFunction, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error); + + void newComputePipelineState(const class Function* computeFunction, const MTL::NewComputePipelineStateCompletionHandler completionHandler); + + void newComputePipelineState(const class Function* computeFunction, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler); + + class ComputePipelineState* newComputePipelineState(const class ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error); + + void newComputePipelineState(const class ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler); + + class Fence* newFence(); + + bool supportsFeatureSet(MTL::FeatureSet featureSet); + + bool supportsFamily(MTL::GPUFamily gpuFamily); + + bool supportsTextureSampleCount(NS::UInteger sampleCount); + + NS::UInteger minimumLinearTextureAlignmentForPixelFormat(MTL::PixelFormat format); + + NS::UInteger minimumTextureBufferAlignmentForPixelFormat(MTL::PixelFormat format); + + class RenderPipelineState* newRenderPipelineState(const class TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + class RenderPipelineState* newRenderPipelineState(const class MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + NS::UInteger maxThreadgroupMemoryLength() const; + + NS::UInteger maxArgumentBufferSamplerCount() const; + + bool programmableSamplePositionsSupported() const; + + void getDefaultSamplePositions(MTL::SamplePosition* positions, NS::UInteger count); + + class ArgumentEncoder* newArgumentEncoder(const NS::Array* arguments); + + bool supportsRasterizationRateMap(NS::UInteger layerCount); + + class RasterizationRateMap* newRasterizationRateMap(const class RasterizationRateMapDescriptor* descriptor); + + class IndirectCommandBuffer* newIndirectCommandBuffer(const class IndirectCommandBufferDescriptor* descriptor, NS::UInteger maxCount, MTL::ResourceOptions options); + + class Event* newEvent(); + + class SharedEvent* newSharedEvent(); + + class SharedEvent* newSharedEvent(const class SharedEventHandle* sharedEventHandle); + + uint64_t peerGroupID() const; + + uint32_t peerIndex() const; + + uint32_t peerCount() const; + + class IOFileHandle* newIOHandle(const NS::URL* url, NS::Error** error); + + class IOCommandQueue* newIOCommandQueue(const class IOCommandQueueDescriptor* descriptor, NS::Error** error); + + class IOFileHandle* newIOHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error); + + class IOFileHandle* newIOFileHandle(const NS::URL* url, NS::Error** error); + + class IOFileHandle* newIOFileHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error); + + MTL::Size sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount); + + NS::UInteger sparseTileSizeInBytes() const; + + void convertSparsePixelRegions(const MTL::Region* pixelRegions, MTL::Region* tileRegions, MTL::Size tileSize, MTL::SparseTextureRegionAlignmentMode mode, NS::UInteger numRegions); + + void convertSparseTileRegions(const MTL::Region* tileRegions, MTL::Region* pixelRegions, MTL::Size tileSize, NS::UInteger numRegions); + + NS::UInteger sparseTileSizeInBytes(MTL::SparsePageSize sparsePageSize); + + MTL::Size sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount, MTL::SparsePageSize sparsePageSize); + + NS::UInteger maxBufferLength() const; + + NS::Array* counterSets() const; + + class CounterSampleBuffer* newCounterSampleBuffer(const class CounterSampleBufferDescriptor* descriptor, NS::Error** error); + + void sampleTimestamps(MTL::Timestamp* cpuTimestamp, MTL::Timestamp* gpuTimestamp); + + class ArgumentEncoder* newArgumentEncoder(const class BufferBinding* bufferBinding); + + bool supportsCounterSampling(MTL::CounterSamplingPoint samplingPoint); + + bool supportsVertexAmplificationCount(NS::UInteger count); + + bool supportsDynamicLibraries() const; + + bool supportsRenderDynamicLibraries() const; + + class DynamicLibrary* newDynamicLibrary(const class Library* library, NS::Error** error); + + class DynamicLibrary* newDynamicLibrary(const NS::URL* url, NS::Error** error); + + class BinaryArchive* newBinaryArchive(const class BinaryArchiveDescriptor* descriptor, NS::Error** error); + + bool supportsRaytracing() const; + + MTL::AccelerationStructureSizes accelerationStructureSizes(const class AccelerationStructureDescriptor* descriptor); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor); + + MTL::SizeAndAlign heapAccelerationStructureSizeAndAlign(NS::UInteger size); + + MTL::SizeAndAlign heapAccelerationStructureSizeAndAlign(const class AccelerationStructureDescriptor* descriptor); + + bool supportsFunctionPointers() const; + + bool supportsFunctionPointersFromRender() const; + + bool supportsRaytracingFromRender() const; + + bool supportsPrimitiveMotionBlur() const; + + bool shouldMaximizeConcurrentCompilation() const; + void setShouldMaximizeConcurrentCompilation(bool shouldMaximizeConcurrentCompilation); + + NS::UInteger maximumConcurrentCompilationTaskCount() const; + + class ResidencySet* newResidencySet(const class ResidencySetDescriptor* desc, NS::Error** error); +}; + +} + +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArgumentDescriptor)); +} + +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::argumentDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLArgumentDescriptor), _MTL_PRIVATE_SEL(argumentDescriptor)); +} + +_MTL_INLINE MTL::DataType MTL::ArgumentDescriptor::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setDataType(MTL::DataType dataType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDataType_), dataType); +} + +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setIndex(NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndex_), index); +} + +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setArrayLength(NS::UInteger arrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArrayLength_), arrayLength); +} + +_MTL_INLINE MTL::BindingAccess MTL::ArgumentDescriptor::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setAccess(MTL::BindingAccess access) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccess_), access); +} + +_MTL_INLINE MTL::TextureType MTL::ArgumentDescriptor::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setTextureType(MTL::TextureType textureType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextureType_), textureType); +} + +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::constantBlockAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantBlockAlignment)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setConstantBlockAlignment(NS::UInteger constantBlockAlignment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantBlockAlignment_), constantBlockAlignment); +} + +_MTL_INLINE MTL::Architecture* MTL::Architecture::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArchitecture)); +} + +_MTL_INLINE MTL::Architecture* MTL::Architecture::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::Architecture::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceWasAddedNotification); +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceRemovalRequestedNotification); +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceWasRemovedNotification); +_MTL_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, CommandBufferEncoderInfoErrorKey); + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +extern "C" MTL::Device* MTLCreateSystemDefaultDevice(); + +extern "C" NS::Array* MTLCopyAllDevices(); + +extern "C" NS::Array* MTLCopyAllDevicesWithObserver(NS::Object**, MTL::DeviceNotificationHandlerBlock); + +extern "C" void MTLRemoveDeviceObserver(const NS::Object*); + +#include + +_NS_EXPORT MTL::Device* MTL::CreateSystemDefaultDevice() +{ + return ::MTLCreateSystemDefaultDevice(); +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevices() +{ +#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 180000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + return ::MTLCopyAllDevices(); +#else + return nullptr; +#endif // __IPHONE_18 +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevicesWithObserver(NS::Object** pOutObserver, DeviceNotificationHandlerBlock handler) +{ +#if TARGET_OS_OSX + return ::MTLCopyAllDevicesWithObserver(pOutObserver, handler); +#else + (void)pOutObserver; + (void)handler; + + return nullptr; +#endif // TARGET_OS_OSX +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevicesWithObserver(NS::Object** pOutObserver, const DeviceNotificationHandlerFunction& handler) +{ + __block DeviceNotificationHandlerFunction function = handler; + + return CopyAllDevicesWithObserver(pOutObserver, ^(Device* pDevice, DeviceNotificationName pNotificationName) { function(pDevice, pNotificationName); }); +} + +_NS_EXPORT void MTL::RemoveDeviceObserver(const NS::Object* pObserver) +{ + (void)pObserver; +#if TARGET_OS_OSX + ::MTLRemoveDeviceObserver(pObserver); +#endif // TARGET_OS_OSX +} + +#endif // MTL_PRIVATE_IMPLEMENTATION + +_MTL_INLINE void MTL::Device::newLibrary(const NS::String* pSource, const CompileOptions* pOptions, const NewLibraryCompletionHandlerFunction& completionHandler) +{ + __block NewLibraryCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newLibrary(pSource, pOptions, ^(Library* pLibrary, NS::Error* pError) { blockCompletionHandler(pLibrary, pError); }); +} + +_MTL_INLINE void MTL::Device::newLibrary(const class StitchedLibraryDescriptor* pDescriptor, const MTL::NewLibraryCompletionHandlerFunction& completionHandler) +{ + __block NewLibraryCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newLibrary(pDescriptor, ^(Library* pLibrary, NS::Error* pError) { blockCompletionHandler(pLibrary, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const RenderPipelineDescriptor* pDescriptor, const NewRenderPipelineStateCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, ^(RenderPipelineState* pPipelineState, NS::Error* pError) { blockCompletionHandler(pPipelineState, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const RenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, options, ^(RenderPipelineState* pPipelineState, class RenderPipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const TileRenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, options, ^(RenderPipelineState* pPipelineState, class RenderPipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const class Function* pFunction, const NewComputePipelineStateCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pFunction, ^(ComputePipelineState* pPipelineState, NS::Error* pError) { blockCompletionHandler(pPipelineState, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const Function* pFunction, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pFunction, options, ^(ComputePipelineState* pPipelineState, ComputePipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const ComputePipelineDescriptor* pDescriptor, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pDescriptor, options, ^(ComputePipelineState* pPipelineState, ComputePipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE bool MTL::Device::isHeadless() const +{ + return headless(); +} + +_MTL_INLINE NS::String* MTL::Device::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE uint64_t MTL::Device::registryID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(registryID)); +} + +_MTL_INLINE MTL::Architecture* MTL::Device::architecture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(architecture)); +} + +_MTL_INLINE MTL::Size MTL::Device::maxThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxThreadsPerThreadgroup)); +} + +_MTL_INLINE bool MTL::Device::lowPower() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isLowPower)); +} + +_MTL_INLINE bool MTL::Device::headless() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isHeadless)); +} + +_MTL_INLINE bool MTL::Device::removable() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRemovable)); +} + +_MTL_INLINE bool MTL::Device::hasUnifiedMemory() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hasUnifiedMemory)); +} + +_MTL_INLINE uint64_t MTL::Device::recommendedMaxWorkingSetSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(recommendedMaxWorkingSetSize)); +} + +_MTL_INLINE MTL::DeviceLocation MTL::Device::location() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(location)); +} + +_MTL_INLINE NS::UInteger MTL::Device::locationNumber() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(locationNumber)); +} + +_MTL_INLINE uint64_t MTL::Device::maxTransferRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTransferRate)); +} + +_MTL_INLINE bool MTL::Device::depth24Stencil8PixelFormatSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(isDepth24Stencil8PixelFormatSupported)); +} + +_MTL_INLINE MTL::ReadWriteTextureTier MTL::Device::readWriteTextureSupport() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(readWriteTextureSupport)); +} + +_MTL_INLINE MTL::ArgumentBuffersTier MTL::Device::argumentBuffersSupport() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentBuffersSupport)); +} + +_MTL_INLINE bool MTL::Device::rasterOrderGroupsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areRasterOrderGroupsSupported)); +} + +_MTL_INLINE bool MTL::Device::supports32BitFloatFiltering() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supports32BitFloatFiltering)); +} + +_MTL_INLINE bool MTL::Device::supports32BitMSAA() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supports32BitMSAA)); +} + +_MTL_INLINE bool MTL::Device::supportsQueryTextureLOD() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsQueryTextureLOD)); +} + +_MTL_INLINE bool MTL::Device::supportsBCTextureCompression() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsBCTextureCompression)); +} + +_MTL_INLINE bool MTL::Device::supportsPullModelInterpolation() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsPullModelInterpolation)); +} + +_MTL_INLINE bool MTL::Device::barycentricCoordsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areBarycentricCoordsSupported)); +} + +_MTL_INLINE bool MTL::Device::supportsShaderBarycentricCoordinates() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsShaderBarycentricCoordinates)); +} + +_MTL_INLINE NS::UInteger MTL::Device::currentAllocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(currentAllocatedSize)); +} + +_MTL_INLINE MTL::LogState* MTL::Device::newLogState(const MTL::LogStateDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLogStateWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE MTL::CommandQueue* MTL::Device::newCommandQueue() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCommandQueue)); +} + +_MTL_INLINE MTL::CommandQueue* MTL::Device::newCommandQueue(NS::UInteger maxCommandBufferCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCommandQueueWithMaxCommandBufferCount_), maxCommandBufferCount); +} + +_MTL_INLINE MTL::CommandQueue* MTL::Device::newCommandQueue(const MTL::CommandQueueDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCommandQueueWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapTextureSizeAndAlign(const MTL::TextureDescriptor* desc) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapTextureSizeAndAlignWithDescriptor_), desc); +} + +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapBufferSizeAndAlign(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapBufferSizeAndAlignWithLength_options_), length, options); +} + +_MTL_INLINE MTL::Heap* MTL::Device::newHeap(const MTL::HeapDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newHeapWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_), length, options); +} + +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithBytes_length_options_), pointer, length, options); +} + +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options, void (^deallocator)(void*, NS::UInteger)) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithBytesNoCopy_length_options_deallocator_), pointer, length, options, deallocator); +} + +_MTL_INLINE MTL::DepthStencilState* MTL::Device::newDepthStencilState(const MTL::DepthStencilDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDepthStencilStateWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::Texture* MTL::Device::newTexture(const MTL::TextureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::Texture* MTL::Device::newTexture(const MTL::TextureDescriptor* descriptor, const IOSurfaceRef iosurface, NS::UInteger plane) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_iosurface_plane_), descriptor, iosurface, plane); +} + +_MTL_INLINE MTL::Texture* MTL::Device::newSharedTexture(const MTL::TextureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::Texture* MTL::Device::newSharedTexture(const MTL::SharedTextureHandle* sharedHandle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureWithHandle_), sharedHandle); +} + +_MTL_INLINE MTL::SamplerState* MTL::Device::newSamplerState(const MTL::SamplerDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSamplerStateWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::Library* MTL::Device::newDefaultLibrary() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDefaultLibrary)); +} + +_MTL_INLINE MTL::Library* MTL::Device::newDefaultLibrary(const NS::Bundle* bundle, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDefaultLibraryWithBundle_error_), bundle, error); +} + +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::String* filepath, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithFile_error_), filepath, error); +} + +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithURL_error_), url, error); +} + +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const dispatch_data_t data, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithData_error_), data, error); +} + +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::String* source, const MTL::CompileOptions* options, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithSource_options_error_), source, options, error); +} + +_MTL_INLINE void MTL::Device::newLibrary(const NS::String* source, const MTL::CompileOptions* options, const MTL::NewLibraryCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithSource_options_completionHandler_), source, options, completionHandler); +} + +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithStitchedDescriptor_error_), descriptor, error); +} + +_MTL_INLINE void MTL::Device::newLibrary(const MTL::StitchedLibraryDescriptor* descriptor, const MTL::NewLibraryCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithStitchedDescriptor_completionHandler_), descriptor, completionHandler); +} + +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, const MTL::NewRenderPipelineStateCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_error_), computeFunction, error); +} + +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_options_reflection_error_), computeFunction, options, reflection, error); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, const MTL::NewComputePipelineStateCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_completionHandler_), computeFunction, completionHandler); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_options_completionHandler_), computeFunction, options, completionHandler); +} + +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +_MTL_INLINE MTL::Fence* MTL::Device::newFence() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFence)); +} + +_MTL_INLINE bool MTL::Device::supportsFeatureSet(MTL::FeatureSet featureSet) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFeatureSet_), featureSet); +} + +_MTL_INLINE bool MTL::Device::supportsFamily(MTL::GPUFamily gpuFamily) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFamily_), gpuFamily); +} + +_MTL_INLINE bool MTL::Device::supportsTextureSampleCount(NS::UInteger sampleCount) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsTextureSampleCount_), sampleCount); +} + +_MTL_INLINE NS::UInteger MTL::Device::minimumLinearTextureAlignmentForPixelFormat(MTL::PixelFormat format) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minimumLinearTextureAlignmentForPixelFormat_), format); +} + +_MTL_INLINE NS::UInteger MTL::Device::minimumTextureBufferAlignmentForPixelFormat(MTL::PixelFormat format) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minimumTextureBufferAlignmentForPixelFormat_), format); +} + +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithTileDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithTileDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithMeshDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithMeshDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +_MTL_INLINE NS::UInteger MTL::Device::maxThreadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxThreadgroupMemoryLength)); +} + +_MTL_INLINE NS::UInteger MTL::Device::maxArgumentBufferSamplerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxArgumentBufferSamplerCount)); +} + +_MTL_INLINE bool MTL::Device::programmableSamplePositionsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areProgrammableSamplePositionsSupported)); +} + +_MTL_INLINE void MTL::Device::getDefaultSamplePositions(MTL::SamplePosition* positions, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getDefaultSamplePositions_count_), positions, count); +} + +_MTL_INLINE MTL::ArgumentEncoder* MTL::Device::newArgumentEncoder(const NS::Array* arguments) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithArguments_), arguments); +} + +_MTL_INLINE bool MTL::Device::supportsRasterizationRateMap(NS::UInteger layerCount) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRasterizationRateMapWithLayerCount_), layerCount); +} + +_MTL_INLINE MTL::RasterizationRateMap* MTL::Device::newRasterizationRateMap(const MTL::RasterizationRateMapDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRasterizationRateMapWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::IndirectCommandBuffer* MTL::Device::newIndirectCommandBuffer(const MTL::IndirectCommandBufferDescriptor* descriptor, NS::UInteger maxCount, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIndirectCommandBufferWithDescriptor_maxCommandCount_options_), descriptor, maxCount, options); +} + +_MTL_INLINE MTL::Event* MTL::Device::newEvent() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newEvent)); +} + +_MTL_INLINE MTL::SharedEvent* MTL::Device::newSharedEvent() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEvent)); +} + +_MTL_INLINE MTL::SharedEvent* MTL::Device::newSharedEvent(const MTL::SharedEventHandle* sharedEventHandle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEventWithHandle_), sharedEventHandle); +} + +_MTL_INLINE uint64_t MTL::Device::peerGroupID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerGroupID)); +} + +_MTL_INLINE uint32_t MTL::Device::peerIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerIndex)); +} + +_MTL_INLINE uint32_t MTL::Device::peerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerCount)); +} + +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOHandle(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOHandleWithURL_error_), url, error); +} + +_MTL_INLINE MTL::IOCommandQueue* MTL::Device::newIOCommandQueue(const MTL::IOCommandQueueDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOCommandQueueWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOHandleWithURL_compressionMethod_error_), url, compressionMethod, error); +} + +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOFileHandle(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOFileHandleWithURL_error_), url, error); +} + +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOFileHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOFileHandleWithURL_compressionMethod_error_), url, compressionMethod, error); +} + +_MTL_INLINE MTL::Size MTL::Device::sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_), textureType, pixelFormat, sampleCount); +} + +_MTL_INLINE NS::UInteger MTL::Device::sparseTileSizeInBytes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeInBytes)); +} + +_MTL_INLINE void MTL::Device::convertSparsePixelRegions(const MTL::Region* pixelRegions, MTL::Region* tileRegions, MTL::Size tileSize, MTL::SparseTextureRegionAlignmentMode mode, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions_), pixelRegions, tileRegions, tileSize, mode, numRegions); +} + +_MTL_INLINE void MTL::Device::convertSparseTileRegions(const MTL::Region* tileRegions, MTL::Region* pixelRegions, MTL::Size tileSize, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(convertSparseTileRegions_toPixelRegions_withTileSize_numRegions_), tileRegions, pixelRegions, tileSize, numRegions); +} + +_MTL_INLINE NS::UInteger MTL::Device::sparseTileSizeInBytes(MTL::SparsePageSize sparsePageSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeInBytesForSparsePageSize_), sparsePageSize); +} + +_MTL_INLINE MTL::Size MTL::Device::sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount, MTL::SparsePageSize sparsePageSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize_), textureType, pixelFormat, sampleCount, sparsePageSize); +} + +_MTL_INLINE NS::UInteger MTL::Device::maxBufferLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxBufferLength)); +} + +_MTL_INLINE NS::Array* MTL::Device::counterSets() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counterSets)); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::Device::newCounterSampleBuffer(const MTL::CounterSampleBufferDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCounterSampleBufferWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE void MTL::Device::sampleTimestamps(MTL::Timestamp* cpuTimestamp, MTL::Timestamp* gpuTimestamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleTimestamps_gpuTimestamp_), cpuTimestamp, gpuTimestamp); +} + +_MTL_INLINE MTL::ArgumentEncoder* MTL::Device::newArgumentEncoder(const MTL::BufferBinding* bufferBinding) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferBinding_), bufferBinding); +} + +_MTL_INLINE bool MTL::Device::supportsCounterSampling(MTL::CounterSamplingPoint samplingPoint) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsCounterSampling_), samplingPoint); +} + +_MTL_INLINE bool MTL::Device::supportsVertexAmplificationCount(NS::UInteger count) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsVertexAmplificationCount_), count); +} + +_MTL_INLINE bool MTL::Device::supportsDynamicLibraries() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsDynamicLibraries)); +} + +_MTL_INLINE bool MTL::Device::supportsRenderDynamicLibraries() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRenderDynamicLibraries)); +} + +_MTL_INLINE MTL::DynamicLibrary* MTL::Device::newDynamicLibrary(const MTL::Library* library, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDynamicLibrary_error_), library, error); +} + +_MTL_INLINE MTL::DynamicLibrary* MTL::Device::newDynamicLibrary(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDynamicLibraryWithURL_error_), url, error); +} + +_MTL_INLINE MTL::BinaryArchive* MTL::Device::newBinaryArchive(const MTL::BinaryArchiveDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBinaryArchiveWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE bool MTL::Device::supportsRaytracing() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRaytracing)); +} + +_MTL_INLINE MTL::AccelerationStructureSizes MTL::Device::accelerationStructureSizes(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureSizesWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Device::newAccelerationStructure(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_), size); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Device::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapAccelerationStructureSizeAndAlign(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapAccelerationStructureSizeAndAlignWithSize_), size); +} + +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapAccelerationStructureSizeAndAlign(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapAccelerationStructureSizeAndAlignWithDescriptor_), descriptor); +} + +_MTL_INLINE bool MTL::Device::supportsFunctionPointers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFunctionPointers)); +} + +_MTL_INLINE bool MTL::Device::supportsFunctionPointersFromRender() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFunctionPointersFromRender)); +} + +_MTL_INLINE bool MTL::Device::supportsRaytracingFromRender() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRaytracingFromRender)); +} + +_MTL_INLINE bool MTL::Device::supportsPrimitiveMotionBlur() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsPrimitiveMotionBlur)); +} + +_MTL_INLINE bool MTL::Device::shouldMaximizeConcurrentCompilation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shouldMaximizeConcurrentCompilation)); +} + +_MTL_INLINE void MTL::Device::setShouldMaximizeConcurrentCompilation(bool shouldMaximizeConcurrentCompilation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShouldMaximizeConcurrentCompilation_), shouldMaximizeConcurrentCompilation); +} + +_MTL_INLINE NS::UInteger MTL::Device::maximumConcurrentCompilationTaskCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maximumConcurrentCompilationTaskCount)); +} + +_MTL_INLINE MTL::ResidencySet* MTL::Device::newResidencySet(const MTL::ResidencySetDescriptor* desc, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newResidencySetWithDescriptor_error_), desc, error); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, DynamicLibraryError) { + DynamicLibraryErrorNone = 0, + DynamicLibraryErrorInvalidFile = 1, + DynamicLibraryErrorCompilationFailure = 2, + DynamicLibraryErrorUnresolvedInstallName = 3, + DynamicLibraryErrorDependencyLoadFailure = 4, + DynamicLibraryErrorUnsupported = 5, +}; + +class DynamicLibrary : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + NS::String* installName() const; + + bool serializeToURL(const NS::URL* url, NS::Error** error); +}; + +} + +_MTL_INLINE NS::String* MTL::DynamicLibrary::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::DynamicLibrary::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::DynamicLibrary::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::DynamicLibrary::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} + +_MTL_INLINE bool MTL::DynamicLibrary::serializeToURL(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error); +} + +#pragma once + +namespace MTL +{ +class Event : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class SharedEventListener : public NS::Referencing +{ +public: + static class SharedEventListener* alloc(); + + MTL::SharedEventListener* init(); + + MTL::SharedEventListener* init(const dispatch_queue_t dispatchQueue); + + dispatch_queue_t dispatchQueue() const; +}; + +using SharedEventNotificationBlock = void (^)(SharedEvent* pEvent, std::uint64_t value); + +class SharedEvent : public NS::Referencing +{ +public: + void notifyListener(const class SharedEventListener* listener, uint64_t value, const MTL::SharedEventNotificationBlock block); + + class SharedEventHandle* newSharedEventHandle(); + + bool waitUntilSignaledValue(uint64_t value, uint64_t milliseconds); + + uint64_t signaledValue() const; + void setSignaledValue(uint64_t signaledValue); +}; + +class SharedEventHandle : public NS::SecureCoding +{ +public: + static class SharedEventHandle* alloc(); + + class SharedEventHandle* init(); + + NS::String* label() const; +}; + +} + +_MTL_INLINE MTL::Device* MTL::Event::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::Event::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Event::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedEventListener)); +} + +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::init(const dispatch_queue_t dispatchQueue) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithDispatchQueue_), dispatchQueue); +} + +_MTL_INLINE dispatch_queue_t MTL::SharedEventListener::dispatchQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchQueue)); +} + +_MTL_INLINE void MTL::SharedEvent::notifyListener(const MTL::SharedEventListener* listener, uint64_t value, const MTL::SharedEventNotificationBlock block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(notifyListener_atValue_block_), listener, value, block); +} + +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEvent::newSharedEventHandle() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEventHandle)); +} + +_MTL_INLINE bool MTL::SharedEvent::waitUntilSignaledValue(uint64_t value, uint64_t milliseconds) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilSignaledValue_timeoutMS_), value, milliseconds); +} + +_MTL_INLINE uint64_t MTL::SharedEvent::signaledValue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(signaledValue)); +} + +_MTL_INLINE void MTL::SharedEvent::setSignaledValue(uint64_t signaledValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSignaledValue_), signaledValue); +} + +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEventHandle::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedEventHandle)); +} + +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEventHandle::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::SharedEventHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +#pragma once + +namespace MTL +{ +class Fence : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +} + +_MTL_INLINE MTL::Device* MTL::Fence::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::Fence::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Fence::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +#pragma once + +namespace MTL +{ +class FunctionConstantValues : public NS::Copying +{ +public: + static class FunctionConstantValues* alloc(); + + class FunctionConstantValues* init(); + + void setConstantValue(const void* value, MTL::DataType type, NS::UInteger index); + + void setConstantValues(const void* values, MTL::DataType type, NS::Range range); + + void setConstantValue(const void* value, MTL::DataType type, const NS::String* name); + + void reset(); +}; + +} + +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionConstantValues::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionConstantValues)); +} + +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionConstantValues::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValue(const void* value, MTL::DataType type, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValue_type_atIndex_), value, type, index); +} + +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValues(const void* values, MTL::DataType type, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValues_type_withRange_), values, type, range); +} + +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValue(const void* value, MTL::DataType type, const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValue_type_withName_), value, type, name); +} + +_MTL_INLINE void MTL::FunctionConstantValues::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, FunctionOptions) { + FunctionOptionNone = 0, + FunctionOptionCompileToBinary = 1, + FunctionOptionStoreFunctionInMetalScript = 2, + FunctionOptionFailOnBinaryArchiveMiss = 4, +}; + +class FunctionDescriptor : public NS::Copying +{ +public: + static class FunctionDescriptor* alloc(); + + class FunctionDescriptor* init(); + + static class FunctionDescriptor* functionDescriptor(); + + NS::String* name() const; + void setName(const NS::String* name); + + NS::String* specializedName() const; + void setSpecializedName(const NS::String* specializedName); + + class FunctionConstantValues* constantValues() const; + void setConstantValues(const class FunctionConstantValues* constantValues); + + MTL::FunctionOptions options() const; + void setOptions(MTL::FunctionOptions options); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); +}; + +class IntersectionFunctionDescriptor : public NS::Copying +{ +public: + static class IntersectionFunctionDescriptor* alloc(); + + class IntersectionFunctionDescriptor* init(); +}; + +} + +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionDescriptor)); +} + +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::functionDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLFunctionDescriptor), _MTL_PRIVATE_SEL(functionDescriptor)); +} + +_MTL_INLINE NS::String* MTL::FunctionDescriptor::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setName(const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setName_), name); +} + +_MTL_INLINE NS::String* MTL::FunctionDescriptor::specializedName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(specializedName)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setSpecializedName(const NS::String* specializedName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSpecializedName_), specializedName); +} + +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionDescriptor::constantValues() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantValues)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setConstantValues(const MTL::FunctionConstantValues* constantValues) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValues_), constantValues); +} + +_MTL_INLINE MTL::FunctionOptions MTL::FunctionDescriptor::options() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(options)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setOptions(MTL::FunctionOptions options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOptions_), options); +} + +_MTL_INLINE NS::Array* MTL::FunctionDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE MTL::IntersectionFunctionDescriptor* MTL::IntersectionFunctionDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIntersectionFunctionDescriptor)); +} + +_MTL_INLINE MTL::IntersectionFunctionDescriptor* MTL::IntersectionFunctionDescriptor::init() +{ + return NS::Object::init(); +} + +#pragma once + +#pragma once + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PatchType) { + PatchTypeNone = 0, + PatchTypeTriangle = 1, + PatchTypeQuad = 2, +}; + +class VertexAttribute : public NS::Referencing +{ +public: + static class VertexAttribute* alloc(); + + class VertexAttribute* init(); + + NS::String* name() const; + + NS::UInteger attributeIndex() const; + + MTL::DataType attributeType() const; + + bool active() const; + + bool patchData() const; + + bool patchControlPointData() const; +}; + +class Attribute : public NS::Referencing +{ +public: + static class Attribute* alloc(); + + class Attribute* init(); + + NS::String* name() const; + + NS::UInteger attributeIndex() const; + + MTL::DataType attributeType() const; + + bool active() const; + + bool patchData() const; + + bool patchControlPointData() const; +}; + +_MTL_ENUM(NS::UInteger, FunctionType) { + FunctionTypeVertex = 1, + FunctionTypeFragment = 2, + FunctionTypeKernel = 3, + FunctionTypeVisible = 5, + FunctionTypeIntersection = 6, + FunctionTypeMesh = 7, + FunctionTypeObject = 8, +}; + +class FunctionConstant : public NS::Referencing +{ +public: + static class FunctionConstant* alloc(); + + class FunctionConstant* init(); + + NS::String* name() const; + + MTL::DataType type() const; + + NS::UInteger index() const; + + bool required() const; +}; + +using AutoreleasedArgument = class Argument*; + +class Function : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::FunctionType functionType() const; + + MTL::PatchType patchType() const; + + NS::Integer patchControlPointCount() const; + + NS::Array* vertexAttributes() const; + + NS::Array* stageInputAttributes() const; + + NS::String* name() const; + + NS::Dictionary* functionConstantsDictionary() const; + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex); + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection); + + MTL::FunctionOptions options() const; +}; + +_MTL_ENUM(NS::UInteger, LanguageVersion) { + LanguageVersion1_0 = 65536, + LanguageVersion1_1 = 65537, + LanguageVersion1_2 = 65538, + LanguageVersion2_0 = 131072, + LanguageVersion2_1 = 131073, + LanguageVersion2_2 = 131074, + LanguageVersion2_3 = 131075, + LanguageVersion2_4 = 131076, + LanguageVersion3_0 = 196608, + LanguageVersion3_1 = 196609, + LanguageVersion3_2 = 196610, +}; + +_MTL_ENUM(NS::Integer, LibraryType) { + LibraryTypeExecutable = 0, + LibraryTypeDynamic = 1, +}; + +_MTL_ENUM(NS::Integer, LibraryOptimizationLevel) { + LibraryOptimizationLevelDefault = 0, + LibraryOptimizationLevelSize = 1, +}; + +_MTL_ENUM(NS::Integer, CompileSymbolVisibility) { + CompileSymbolVisibilityDefault = 0, + CompileSymbolVisibilityHidden = 1, +}; + +_MTL_ENUM(NS::Integer, MathMode) { + MathModeSafe = 0, + MathModeRelaxed = 1, + MathModeFast = 2, +}; + +_MTL_ENUM(NS::Integer, MathFloatingPointFunctions) { + MathFloatingPointFunctionsFast = 0, + MathFloatingPointFunctionsPrecise = 1, +}; + +class CompileOptions : public NS::Copying +{ +public: + static class CompileOptions* alloc(); + + class CompileOptions* init(); + + NS::Dictionary* preprocessorMacros() const; + void setPreprocessorMacros(const NS::Dictionary* preprocessorMacros); + + bool fastMathEnabled() const; + void setFastMathEnabled(bool fastMathEnabled); + + MTL::MathMode mathMode() const; + void setMathMode(MTL::MathMode mathMode); + + MTL::MathFloatingPointFunctions mathFloatingPointFunctions() const; + void setMathFloatingPointFunctions(MTL::MathFloatingPointFunctions mathFloatingPointFunctions); + + MTL::LanguageVersion languageVersion() const; + void setLanguageVersion(MTL::LanguageVersion languageVersion); + + MTL::LibraryType libraryType() const; + void setLibraryType(MTL::LibraryType libraryType); + + NS::String* installName() const; + void setInstallName(const NS::String* installName); + + NS::Array* libraries() const; + void setLibraries(const NS::Array* libraries); + + bool preserveInvariance() const; + void setPreserveInvariance(bool preserveInvariance); + + MTL::LibraryOptimizationLevel optimizationLevel() const; + void setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel); + + MTL::CompileSymbolVisibility compileSymbolVisibility() const; + void setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility); + + bool allowReferencingUndefinedSymbols() const; + void setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols); + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); + + bool enableLogging() const; + void setEnableLogging(bool enableLogging); +}; + +_MTL_ENUM(NS::UInteger, LibraryError) { + LibraryErrorUnsupported = 1, + LibraryErrorInternal = 2, + LibraryErrorCompileFailure = 3, + LibraryErrorCompileWarning = 4, + LibraryErrorFunctionNotFound = 5, + LibraryErrorFileNotFound = 6, +}; + +class Library : public NS::Referencing +{ +public: + void newFunction(const NS::String* pFunctionName, const class FunctionConstantValues* pConstantValues, const std::function& completionHandler); + + void newFunction(const class FunctionDescriptor* pDescriptor, const std::function& completionHandler); + + void newIntersectionFunction(const class IntersectionFunctionDescriptor* pDescriptor, const std::function& completionHandler); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + class Function* newFunction(const NS::String* functionName); + + class Function* newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, NS::Error** error); + + void newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)); + + void newFunction(const class FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); + + class Function* newFunction(const class FunctionDescriptor* descriptor, NS::Error** error); + + void newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); + + class Function* newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, NS::Error** error); + + NS::Array* functionNames() const; + + MTL::LibraryType type() const; + + NS::String* installName() const; +}; + +} + +_MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttribute)); +} + +_MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::VertexAttribute::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::UInteger MTL::VertexAttribute::attributeIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeIndex)); +} + +_MTL_INLINE MTL::DataType MTL::VertexAttribute::attributeType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeType)); +} + +_MTL_INLINE bool MTL::VertexAttribute::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +_MTL_INLINE bool MTL::VertexAttribute::patchData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchData)); +} + +_MTL_INLINE bool MTL::VertexAttribute::patchControlPointData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); +} + +_MTL_INLINE MTL::Attribute* MTL::Attribute::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttribute)); +} + +_MTL_INLINE MTL::Attribute* MTL::Attribute::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::Attribute::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::UInteger MTL::Attribute::attributeIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeIndex)); +} + +_MTL_INLINE MTL::DataType MTL::Attribute::attributeType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeType)); +} + +_MTL_INLINE bool MTL::Attribute::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +_MTL_INLINE bool MTL::Attribute::patchData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchData)); +} + +_MTL_INLINE bool MTL::Attribute::patchControlPointData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); +} + +_MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionConstant)); +} + +_MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::FunctionConstant::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE MTL::DataType MTL::FunctionConstant::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE NS::UInteger MTL::FunctionConstant::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +_MTL_INLINE bool MTL::FunctionConstant::required() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(required)); +} + +_MTL_INLINE NS::String* MTL::Function::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Function::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::Function::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::FunctionType MTL::Function::functionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionType)); +} + +_MTL_INLINE MTL::PatchType MTL::Function::patchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(patchType)); +} + +_MTL_INLINE NS::Integer MTL::Function::patchControlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(patchControlPointCount)); +} + +_MTL_INLINE NS::Array* MTL::Function::vertexAttributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexAttributes)); +} + +_MTL_INLINE NS::Array* MTL::Function::stageInputAttributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stageInputAttributes)); +} + +_MTL_INLINE NS::String* MTL::Function::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE NS::Dictionary* MTL::Function::functionConstantsDictionary() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionConstantsDictionary)); +} + +_MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_), bufferIndex); +} + +_MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_reflection_), bufferIndex, reflection); +} + +_MTL_INLINE MTL::FunctionOptions MTL::Function::options() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(options)); +} + +_MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCompileOptions)); +} + +_MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Dictionary* MTL::CompileOptions::preprocessorMacros() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preprocessorMacros)); +} + +_MTL_INLINE void MTL::CompileOptions::setPreprocessorMacros(const NS::Dictionary* preprocessorMacros) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreprocessorMacros_), preprocessorMacros); +} + +_MTL_INLINE bool MTL::CompileOptions::fastMathEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fastMathEnabled)); +} + +_MTL_INLINE void MTL::CompileOptions::setFastMathEnabled(bool fastMathEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFastMathEnabled_), fastMathEnabled); +} + +_MTL_INLINE MTL::MathMode MTL::CompileOptions::mathMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mathMode)); +} + +_MTL_INLINE void MTL::CompileOptions::setMathMode(MTL::MathMode mathMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMathMode_), mathMode); +} + +_MTL_INLINE MTL::MathFloatingPointFunctions MTL::CompileOptions::mathFloatingPointFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mathFloatingPointFunctions)); +} + +_MTL_INLINE void MTL::CompileOptions::setMathFloatingPointFunctions(MTL::MathFloatingPointFunctions mathFloatingPointFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMathFloatingPointFunctions_), mathFloatingPointFunctions); +} + +_MTL_INLINE MTL::LanguageVersion MTL::CompileOptions::languageVersion() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(languageVersion)); +} + +_MTL_INLINE void MTL::CompileOptions::setLanguageVersion(MTL::LanguageVersion languageVersion) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLanguageVersion_), languageVersion); +} + +_MTL_INLINE MTL::LibraryType MTL::CompileOptions::libraryType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(libraryType)); +} + +_MTL_INLINE void MTL::CompileOptions::setLibraryType(MTL::LibraryType libraryType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLibraryType_), libraryType); +} + +_MTL_INLINE NS::String* MTL::CompileOptions::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} + +_MTL_INLINE void MTL::CompileOptions::setInstallName(const NS::String* installName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstallName_), installName); +} + +_MTL_INLINE NS::Array* MTL::CompileOptions::libraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(libraries)); +} + +_MTL_INLINE void MTL::CompileOptions::setLibraries(const NS::Array* libraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLibraries_), libraries); +} + +_MTL_INLINE bool MTL::CompileOptions::preserveInvariance() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preserveInvariance)); +} + +_MTL_INLINE void MTL::CompileOptions::setPreserveInvariance(bool preserveInvariance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreserveInvariance_), preserveInvariance); +} + +_MTL_INLINE MTL::LibraryOptimizationLevel MTL::CompileOptions::optimizationLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizationLevel)); +} + +_MTL_INLINE void MTL::CompileOptions::setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOptimizationLevel_), optimizationLevel); +} + +_MTL_INLINE MTL::CompileSymbolVisibility MTL::CompileOptions::compileSymbolVisibility() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compileSymbolVisibility)); +} + +_MTL_INLINE void MTL::CompileOptions::setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompileSymbolVisibility_), compileSymbolVisibility); +} + +_MTL_INLINE bool MTL::CompileOptions::allowReferencingUndefinedSymbols() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowReferencingUndefinedSymbols)); +} + +_MTL_INLINE void MTL::CompileOptions::setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowReferencingUndefinedSymbols_), allowReferencingUndefinedSymbols); +} + +_MTL_INLINE NS::UInteger MTL::CompileOptions::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::CompileOptions::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +_MTL_INLINE bool MTL::CompileOptions::enableLogging() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(enableLogging)); +} + +_MTL_INLINE void MTL::CompileOptions::setEnableLogging(bool enableLogging) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEnableLogging_), enableLogging); +} + +_MTL_INLINE void MTL::Library::newFunction(const NS::String* pFunctionName, const FunctionConstantValues* pConstantValues, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newFunction(pFunctionName, pConstantValues, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +_MTL_INLINE void MTL::Library::newFunction(const FunctionDescriptor* pDescriptor, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +_MTL_INLINE void MTL::Library::newIntersectionFunction(const IntersectionFunctionDescriptor* pDescriptor, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newIntersectionFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +_MTL_INLINE NS::String* MTL::Library::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Library::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::Library::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* functionName) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_), functionName); +} + +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_error_), name, constantValues, error); +} + +_MTL_INLINE void MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_completionHandler_), name, constantValues, completionHandler); +} + +_MTL_INLINE void MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE void MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +_MTL_INLINE MTL::Function* MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_error_), descriptor, error); +} + +_MTL_INLINE NS::Array* MTL::Library::functionNames() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionNames)); +} + +_MTL_INLINE MTL::LibraryType MTL::Library::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE NS::String* MTL::Library::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} + +namespace MTL +{ +class FunctionHandle : public NS::Referencing +{ +public: + MTL::FunctionType functionType() const; + + NS::String* name() const; + + class Device* device() const; +}; + +} + +_MTL_INLINE MTL::FunctionType MTL::FunctionHandle::functionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionType)); +} + +_MTL_INLINE NS::String* MTL::FunctionHandle::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE MTL::Device* MTL::FunctionHandle::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, FunctionLogType) { + FunctionLogTypeValidation = 0, +}; + +class LogContainer : public NS::Referencing +{ +public: +}; + +class FunctionLogDebugLocation : public NS::Referencing +{ +public: + NS::String* functionName() const; + + NS::URL* URL() const; + + NS::UInteger line() const; + + NS::UInteger column() const; +}; + +class FunctionLog : public NS::Referencing +{ +public: + MTL::FunctionLogType type() const; + + NS::String* encoderLabel() const; + + class Function* function() const; + + class FunctionLogDebugLocation* debugLocation() const; +}; + +} + +_MTL_INLINE NS::String* MTL::FunctionLogDebugLocation::functionName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionName)); +} + +_MTL_INLINE NS::URL* MTL::FunctionLogDebugLocation::URL() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(URL)); +} + +_MTL_INLINE NS::UInteger MTL::FunctionLogDebugLocation::line() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(line)); +} + +_MTL_INLINE NS::UInteger MTL::FunctionLogDebugLocation::column() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(column)); +} + +_MTL_INLINE MTL::FunctionLogType MTL::FunctionLog::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE NS::String* MTL::FunctionLog::encoderLabel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(encoderLabel)); +} + +_MTL_INLINE MTL::Function* MTL::FunctionLog::function() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(function)); +} + +_MTL_INLINE MTL::FunctionLogDebugLocation* MTL::FunctionLog::debugLocation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(debugLocation)); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, StitchedLibraryOptions) { + StitchedLibraryOptionNone = 0, + StitchedLibraryOptionFailOnBinaryArchiveMiss = 1, + StitchedLibraryOptionStoreLibraryInMetalScript = 2, +}; + +class FunctionStitchingAttribute : public NS::Referencing +{ +public: +}; + +class FunctionStitchingAttributeAlwaysInline : public NS::Referencing +{ +public: + static class FunctionStitchingAttributeAlwaysInline* alloc(); + + class FunctionStitchingAttributeAlwaysInline* init(); +}; + +class FunctionStitchingNode : public NS::Copying +{ +public: +}; + +class FunctionStitchingInputNode : public NS::Referencing +{ +public: + static class FunctionStitchingInputNode* alloc(); + + class FunctionStitchingInputNode* init(); + + NS::UInteger argumentIndex() const; + void setArgumentIndex(NS::UInteger argumentIndex); + + MTL::FunctionStitchingInputNode* init(NS::UInteger argument); +}; + +class FunctionStitchingFunctionNode : public NS::Referencing +{ +public: + static class FunctionStitchingFunctionNode* alloc(); + + class FunctionStitchingFunctionNode* init(); + + NS::String* name() const; + void setName(const NS::String* name); + + NS::Array* arguments() const; + void setArguments(const NS::Array* arguments); + + NS::Array* controlDependencies() const; + void setControlDependencies(const NS::Array* controlDependencies); + + MTL::FunctionStitchingFunctionNode* init(const NS::String* name, const NS::Array* arguments, const NS::Array* controlDependencies); +}; + +class FunctionStitchingGraph : public NS::Copying +{ +public: + static class FunctionStitchingGraph* alloc(); + + class FunctionStitchingGraph* init(); + + NS::String* functionName() const; + void setFunctionName(const NS::String* functionName); + + NS::Array* nodes() const; + void setNodes(const NS::Array* nodes); + + class FunctionStitchingFunctionNode* outputNode() const; + void setOutputNode(const class FunctionStitchingFunctionNode* outputNode); + + NS::Array* attributes() const; + void setAttributes(const NS::Array* attributes); + + MTL::FunctionStitchingGraph* init(const NS::String* functionName, const NS::Array* nodes, const class FunctionStitchingFunctionNode* outputNode, const NS::Array* attributes); +}; + +class StitchedLibraryDescriptor : public NS::Copying +{ +public: + static class StitchedLibraryDescriptor* alloc(); + + class StitchedLibraryDescriptor* init(); + + NS::Array* functionGraphs() const; + void setFunctionGraphs(const NS::Array* functionGraphs); + + NS::Array* functions() const; + void setFunctions(const NS::Array* functions); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + MTL::StitchedLibraryOptions options() const; + void setOptions(MTL::StitchedLibraryOptions options); +}; + +} + +_MTL_INLINE MTL::FunctionStitchingAttributeAlwaysInline* MTL::FunctionStitchingAttributeAlwaysInline::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingAttributeAlwaysInline)); +} + +_MTL_INLINE MTL::FunctionStitchingAttributeAlwaysInline* MTL::FunctionStitchingAttributeAlwaysInline::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingInputNode)); +} + +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::FunctionStitchingInputNode::argumentIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndex)); +} + +_MTL_INLINE void MTL::FunctionStitchingInputNode::setArgumentIndex(NS::UInteger argumentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentIndex_), argumentIndex); +} + +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::init(NS::UInteger argument) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithArgumentIndex_), argument); +} + +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingFunctionNode)); +} + +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::FunctionStitchingFunctionNode::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setName(const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setName_), name); +} + +_MTL_INLINE NS::Array* MTL::FunctionStitchingFunctionNode::arguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arguments)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setArguments(const NS::Array* arguments) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArguments_), arguments); +} + +_MTL_INLINE NS::Array* MTL::FunctionStitchingFunctionNode::controlDependencies() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlDependencies)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setControlDependencies(const NS::Array* controlDependencies) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlDependencies_), controlDependencies); +} + +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::init(const NS::String* name, const NS::Array* arguments, const NS::Array* controlDependencies) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithName_arguments_controlDependencies_), name, arguments, controlDependencies); +} + +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingGraph)); +} + +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::FunctionStitchingGraph::functionName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionName)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setFunctionName(const NS::String* functionName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionName_), functionName); +} + +_MTL_INLINE NS::Array* MTL::FunctionStitchingGraph::nodes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(nodes)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setNodes(const NS::Array* nodes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setNodes_), nodes); +} + +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingGraph::outputNode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(outputNode)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setOutputNode(const MTL::FunctionStitchingFunctionNode* outputNode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOutputNode_), outputNode); +} + +_MTL_INLINE NS::Array* MTL::FunctionStitchingGraph::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setAttributes(const NS::Array* attributes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAttributes_), attributes); +} + +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::init(const NS::String* functionName, const NS::Array* nodes, const MTL::FunctionStitchingFunctionNode* outputNode, const NS::Array* attributes) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithFunctionName_nodes_outputNode_attributes_), functionName, nodes, outputNode, attributes); +} + +_MTL_INLINE MTL::StitchedLibraryDescriptor* MTL::StitchedLibraryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStitchedLibraryDescriptor)); +} + +_MTL_INLINE MTL::StitchedLibraryDescriptor* MTL::StitchedLibraryDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::StitchedLibraryDescriptor::functionGraphs() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionGraphs)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setFunctionGraphs(const NS::Array* functionGraphs) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionGraphs_), functionGraphs); +} + +_MTL_INLINE NS::Array* MTL::StitchedLibraryDescriptor::functions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functions)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setFunctions(const NS::Array* functions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_), functions); +} + +_MTL_INLINE NS::Array* MTL::StitchedLibraryDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE MTL::StitchedLibraryOptions MTL::StitchedLibraryDescriptor::options() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(options)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setOptions(MTL::StitchedLibraryOptions options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOptions_), options); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::Integer, HeapType) { + HeapTypeAutomatic = 0, + HeapTypePlacement = 1, + HeapTypeSparse = 2, +}; + +class HeapDescriptor : public NS::Copying +{ +public: + static class HeapDescriptor* alloc(); + + class HeapDescriptor* init(); + + NS::UInteger size() const; + void setSize(NS::UInteger size); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + MTL::CPUCacheMode cpuCacheMode() const; + void setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode); + + MTL::SparsePageSize sparsePageSize() const; + void setSparsePageSize(MTL::SparsePageSize sparsePageSize); + + MTL::HazardTrackingMode hazardTrackingMode() const; + void setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode); + + MTL::ResourceOptions resourceOptions() const; + void setResourceOptions(MTL::ResourceOptions resourceOptions); + + MTL::HeapType type() const; + void setType(MTL::HeapType type); +}; + +class Heap : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::StorageMode storageMode() const; + + MTL::CPUCacheMode cpuCacheMode() const; + + MTL::HazardTrackingMode hazardTrackingMode() const; + + MTL::ResourceOptions resourceOptions() const; + + NS::UInteger size() const; + + NS::UInteger usedSize() const; + + NS::UInteger currentAllocatedSize() const; + + NS::UInteger maxAvailableSize(NS::UInteger alignment); + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options); + + class Texture* newTexture(const class TextureDescriptor* descriptor); + + MTL::PurgeableState setPurgeableState(MTL::PurgeableState state); + + MTL::HeapType type() const; + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options, NS::UInteger offset); + + class Texture* newTexture(const class TextureDescriptor* descriptor, NS::UInteger offset); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size, NS::UInteger offset); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor, NS::UInteger offset); +}; + +} + +_MTL_INLINE MTL::HeapDescriptor* MTL::HeapDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLHeapDescriptor)); +} + +_MTL_INLINE MTL::HeapDescriptor* MTL::HeapDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::HeapDescriptor::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setSize(NS::UInteger size) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSize_), size); +} + +_MTL_INLINE MTL::StorageMode MTL::HeapDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +_MTL_INLINE MTL::CPUCacheMode MTL::HeapDescriptor::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCpuCacheMode_), cpuCacheMode); +} + +_MTL_INLINE MTL::SparsePageSize MTL::HeapDescriptor::sparsePageSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparsePageSize)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setSparsePageSize(MTL::SparsePageSize sparsePageSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSparsePageSize_), sparsePageSize); +} + +_MTL_INLINE MTL::HazardTrackingMode MTL::HeapDescriptor::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHazardTrackingMode_), hazardTrackingMode); +} + +_MTL_INLINE MTL::ResourceOptions MTL::HeapDescriptor::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setResourceOptions(MTL::ResourceOptions resourceOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResourceOptions_), resourceOptions); +} + +_MTL_INLINE MTL::HeapType MTL::HeapDescriptor::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setType(MTL::HeapType type) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setType_), type); +} + +_MTL_INLINE NS::String* MTL::Heap::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Heap::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Device* MTL::Heap::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::StorageMode MTL::Heap::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE MTL::CPUCacheMode MTL::Heap::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE MTL::HazardTrackingMode MTL::Heap::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE MTL::ResourceOptions MTL::Heap::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE NS::UInteger MTL::Heap::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +_MTL_INLINE NS::UInteger MTL::Heap::usedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usedSize)); +} + +_MTL_INLINE NS::UInteger MTL::Heap::currentAllocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(currentAllocatedSize)); +} + +_MTL_INLINE NS::UInteger MTL::Heap::maxAvailableSize(NS::UInteger alignment) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxAvailableSizeWithAlignment_), alignment); +} + +_MTL_INLINE MTL::Buffer* MTL::Heap::newBuffer(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_), length, options); +} + +_MTL_INLINE MTL::Texture* MTL::Heap::newTexture(const MTL::TextureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::PurgeableState MTL::Heap::setPurgeableState(MTL::PurgeableState state) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(setPurgeableState_), state); +} + +_MTL_INLINE MTL::HeapType MTL::Heap::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE MTL::Buffer* MTL::Heap::newBuffer(NS::UInteger length, MTL::ResourceOptions options, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_offset_), length, options, offset); +} + +_MTL_INLINE MTL::Texture* MTL::Heap::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_), descriptor, offset); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_), size); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_), descriptor); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(NS::UInteger size, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_offset_), size, offset); +} + +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_offset_), descriptor, offset); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, IndirectCommandType) { + IndirectCommandTypeDraw = 1, + IndirectCommandTypeDrawIndexed = 2, + IndirectCommandTypeDrawPatches = 4, + IndirectCommandTypeDrawIndexedPatches = 8, + IndirectCommandTypeConcurrentDispatch = 32, + IndirectCommandTypeConcurrentDispatchThreads = 64, + IndirectCommandTypeDrawMeshThreadgroups = 128, + IndirectCommandTypeDrawMeshThreads = 256, +}; + +struct IndirectCommandBufferExecutionRange +{ + uint32_t location; + uint32_t length; +} _MTL_PACKED; + +class IndirectCommandBufferDescriptor : public NS::Copying +{ +public: + static class IndirectCommandBufferDescriptor* alloc(); + + class IndirectCommandBufferDescriptor* init(); + + MTL::IndirectCommandType commandTypes() const; + void setCommandTypes(MTL::IndirectCommandType commandTypes); + + bool inheritPipelineState() const; + void setInheritPipelineState(bool inheritPipelineState); + + bool inheritBuffers() const; + void setInheritBuffers(bool inheritBuffers); + + NS::UInteger maxVertexBufferBindCount() const; + void setMaxVertexBufferBindCount(NS::UInteger maxVertexBufferBindCount); + + NS::UInteger maxFragmentBufferBindCount() const; + void setMaxFragmentBufferBindCount(NS::UInteger maxFragmentBufferBindCount); + + NS::UInteger maxKernelBufferBindCount() const; + void setMaxKernelBufferBindCount(NS::UInteger maxKernelBufferBindCount); + + NS::UInteger maxKernelThreadgroupMemoryBindCount() const; + void setMaxKernelThreadgroupMemoryBindCount(NS::UInteger maxKernelThreadgroupMemoryBindCount); + + NS::UInteger maxObjectBufferBindCount() const; + void setMaxObjectBufferBindCount(NS::UInteger maxObjectBufferBindCount); + + NS::UInteger maxMeshBufferBindCount() const; + void setMaxMeshBufferBindCount(NS::UInteger maxMeshBufferBindCount); + + NS::UInteger maxObjectThreadgroupMemoryBindCount() const; + void setMaxObjectThreadgroupMemoryBindCount(NS::UInteger maxObjectThreadgroupMemoryBindCount); + + bool supportRayTracing() const; + void setSupportRayTracing(bool supportRayTracing); + + bool supportDynamicAttributeStride() const; + void setSupportDynamicAttributeStride(bool supportDynamicAttributeStride); +}; + +class IndirectCommandBuffer : public NS::Referencing +{ +public: + NS::UInteger size() const; + + MTL::ResourceID gpuResourceID() const; + + void reset(NS::Range range); + + class IndirectRenderCommand* indirectRenderCommand(NS::UInteger commandIndex); + + class IndirectComputeCommand* indirectComputeCommand(NS::UInteger commandIndex); +}; + +} + +_MTL_INLINE MTL::IndirectCommandBufferDescriptor* MTL::IndirectCommandBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIndirectCommandBufferDescriptor)); +} + +_MTL_INLINE MTL::IndirectCommandBufferDescriptor* MTL::IndirectCommandBufferDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::IndirectCommandType MTL::IndirectCommandBufferDescriptor::commandTypes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandTypes)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setCommandTypes(MTL::IndirectCommandType commandTypes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCommandTypes_), commandTypes); +} + +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::inheritPipelineState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inheritPipelineState)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setInheritPipelineState(bool inheritPipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInheritPipelineState_), inheritPipelineState); +} + +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::inheritBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inheritBuffers)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setInheritBuffers(bool inheritBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInheritBuffers_), inheritBuffers); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxVertexBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxVertexBufferBindCount(NS::UInteger maxVertexBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexBufferBindCount_), maxVertexBufferBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxFragmentBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxFragmentBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxFragmentBufferBindCount(NS::UInteger maxFragmentBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxFragmentBufferBindCount_), maxFragmentBufferBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxKernelBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxKernelBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxKernelBufferBindCount(NS::UInteger maxKernelBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxKernelBufferBindCount_), maxKernelBufferBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxKernelThreadgroupMemoryBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxKernelThreadgroupMemoryBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxKernelThreadgroupMemoryBindCount(NS::UInteger maxKernelThreadgroupMemoryBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxKernelThreadgroupMemoryBindCount_), maxKernelThreadgroupMemoryBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxObjectBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxObjectBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxObjectBufferBindCount(NS::UInteger maxObjectBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxObjectBufferBindCount_), maxObjectBufferBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxMeshBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxMeshBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxMeshBufferBindCount(NS::UInteger maxMeshBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxMeshBufferBindCount_), maxMeshBufferBindCount); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxObjectThreadgroupMemoryBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxObjectThreadgroupMemoryBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxObjectThreadgroupMemoryBindCount(NS::UInteger maxObjectThreadgroupMemoryBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxObjectThreadgroupMemoryBindCount_), maxObjectThreadgroupMemoryBindCount); +} + +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::supportRayTracing() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportRayTracing)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setSupportRayTracing(bool supportRayTracing) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportRayTracing_), supportRayTracing); +} + +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::supportDynamicAttributeStride() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportDynamicAttributeStride)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setSupportDynamicAttributeStride(bool supportDynamicAttributeStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportDynamicAttributeStride_), supportDynamicAttributeStride); +} + +_MTL_INLINE NS::UInteger MTL::IndirectCommandBuffer::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +_MTL_INLINE MTL::ResourceID MTL::IndirectCommandBuffer::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE void MTL::IndirectCommandBuffer::reset(NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetWithRange_), range); +} + +_MTL_INLINE MTL::IndirectRenderCommand* MTL::IndirectCommandBuffer::indirectRenderCommand(NS::UInteger commandIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indirectRenderCommandAtIndex_), commandIndex); +} + +_MTL_INLINE MTL::IndirectComputeCommand* MTL::IndirectCommandBuffer::indirectComputeCommand(NS::UInteger commandIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indirectComputeCommandAtIndex_), commandIndex); +} + +#pragma once + +#pragma once + +#pragma once + +namespace MTL +{ +struct ClearColor +{ + static ClearColor Make(double red, double green, double blue, double alpha); + + ClearColor() = default; + + ClearColor(double red, double green, double blue, double alpha); + + double red; + double green; + double blue; + double alpha; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, LoadAction) { + LoadActionDontCare = 0, + LoadActionLoad = 1, + LoadActionClear = 2, +}; + +_MTL_ENUM(NS::UInteger, StoreAction) { + StoreActionDontCare = 0, + StoreActionStore = 1, + StoreActionMultisampleResolve = 2, + StoreActionStoreAndMultisampleResolve = 3, + StoreActionUnknown = 4, + StoreActionCustomSampleDepthStore = 5, +}; + +_MTL_OPTIONS(NS::UInteger, StoreActionOptions) { + StoreActionOptionNone = 0, + StoreActionOptionCustomSamplePositions = 1, + StoreActionOptionValidMask = 1, +}; + +class RenderPassAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassAttachmentDescriptor* alloc(); + + class RenderPassAttachmentDescriptor* init(); + + class Texture* texture() const; + void setTexture(const class Texture* texture); + + NS::UInteger level() const; + void setLevel(NS::UInteger level); + + NS::UInteger slice() const; + void setSlice(NS::UInteger slice); + + NS::UInteger depthPlane() const; + void setDepthPlane(NS::UInteger depthPlane); + + class Texture* resolveTexture() const; + void setResolveTexture(const class Texture* resolveTexture); + + NS::UInteger resolveLevel() const; + void setResolveLevel(NS::UInteger resolveLevel); + + NS::UInteger resolveSlice() const; + void setResolveSlice(NS::UInteger resolveSlice); + + NS::UInteger resolveDepthPlane() const; + void setResolveDepthPlane(NS::UInteger resolveDepthPlane); + + MTL::LoadAction loadAction() const; + void setLoadAction(MTL::LoadAction loadAction); + + MTL::StoreAction storeAction() const; + void setStoreAction(MTL::StoreAction storeAction); + + MTL::StoreActionOptions storeActionOptions() const; + void setStoreActionOptions(MTL::StoreActionOptions storeActionOptions); +}; + +class RenderPassColorAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassColorAttachmentDescriptor* alloc(); + + class RenderPassColorAttachmentDescriptor* init(); + + MTL::ClearColor clearColor() const; + void setClearColor(MTL::ClearColor clearColor); +}; + +_MTL_ENUM(NS::UInteger, MultisampleDepthResolveFilter) { + MultisampleDepthResolveFilterSample0 = 0, + MultisampleDepthResolveFilterMin = 1, + MultisampleDepthResolveFilterMax = 2, +}; + +class RenderPassDepthAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassDepthAttachmentDescriptor* alloc(); + + class RenderPassDepthAttachmentDescriptor* init(); + + double clearDepth() const; + void setClearDepth(double clearDepth); + + MTL::MultisampleDepthResolveFilter depthResolveFilter() const; + void setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter); +}; + +_MTL_ENUM(NS::UInteger, MultisampleStencilResolveFilter) { + MultisampleStencilResolveFilterSample0 = 0, + MultisampleStencilResolveFilterDepthResolvedSample = 1, +}; + +class RenderPassStencilAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassStencilAttachmentDescriptor* alloc(); + + class RenderPassStencilAttachmentDescriptor* init(); + + uint32_t clearStencil() const; + void setClearStencil(uint32_t clearStencil); + + MTL::MultisampleStencilResolveFilter stencilResolveFilter() const; + void setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter); +}; + +class RenderPassColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPassColorAttachmentDescriptorArray* alloc(); + + class RenderPassColorAttachmentDescriptorArray* init(); + + class RenderPassColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class RenderPassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassSampleBufferAttachmentDescriptor* alloc(); + + class RenderPassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfVertexSampleIndex() const; + void setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex); + + NS::UInteger endOfVertexSampleIndex() const; + void setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex); + + NS::UInteger startOfFragmentSampleIndex() const; + void setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex); + + NS::UInteger endOfFragmentSampleIndex() const; + void setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex); +}; + +class RenderPassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPassSampleBufferAttachmentDescriptorArray* alloc(); + + class RenderPassSampleBufferAttachmentDescriptorArray* init(); + + class RenderPassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class RenderPassDescriptor : public NS::Copying +{ +public: + static class RenderPassDescriptor* alloc(); + + class RenderPassDescriptor* init(); + + static class RenderPassDescriptor* renderPassDescriptor(); + + class RenderPassColorAttachmentDescriptorArray* colorAttachments() const; + + class RenderPassDepthAttachmentDescriptor* depthAttachment() const; + void setDepthAttachment(const class RenderPassDepthAttachmentDescriptor* depthAttachment); + + class RenderPassStencilAttachmentDescriptor* stencilAttachment() const; + void setStencilAttachment(const class RenderPassStencilAttachmentDescriptor* stencilAttachment); + + class Buffer* visibilityResultBuffer() const; + void setVisibilityResultBuffer(const class Buffer* visibilityResultBuffer); + + NS::UInteger renderTargetArrayLength() const; + void setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength); + + NS::UInteger imageblockSampleLength() const; + void setImageblockSampleLength(NS::UInteger imageblockSampleLength); + + NS::UInteger threadgroupMemoryLength() const; + void setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength); + + NS::UInteger tileWidth() const; + void setTileWidth(NS::UInteger tileWidth); + + NS::UInteger tileHeight() const; + void setTileHeight(NS::UInteger tileHeight); + + NS::UInteger defaultRasterSampleCount() const; + void setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount); + + NS::UInteger renderTargetWidth() const; + void setRenderTargetWidth(NS::UInteger renderTargetWidth); + + NS::UInteger renderTargetHeight() const; + void setRenderTargetHeight(NS::UInteger renderTargetHeight); + + void setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count); + + NS::UInteger getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count); + + class RasterizationRateMap* rasterizationRateMap() const; + void setRasterizationRateMap(const class RasterizationRateMap* rasterizationRateMap); + + class RenderPassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE MTL::ClearColor MTL::ClearColor::Make(double red, double green, double blue, double alpha) +{ + return ClearColor(red, green, blue, alpha); +} + +_MTL_INLINE MTL::ClearColor::ClearColor(double _red, double _green, double _blue, double _alpha) + : red(_red) + , green(_green) + , blue(_blue) + , alpha(_alpha) +{ +} + +_MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::texture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(texture)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setTexture(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_), texture); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::level() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(level)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLevel(NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLevel_), level); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::slice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(slice)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setSlice(NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSlice_), slice); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::depthPlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthPlane)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setDepthPlane(NS::UInteger depthPlane) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthPlane_), depthPlane); +} + +_MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::resolveTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveTexture)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveTexture(const MTL::Texture* resolveTexture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveTexture_), resolveTexture); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveLevel)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveLevel(NS::UInteger resolveLevel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveLevel_), resolveLevel); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveSlice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveSlice)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveSlice(NS::UInteger resolveSlice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveSlice_), resolveSlice); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveDepthPlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveDepthPlane)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveDepthPlane(NS::UInteger resolveDepthPlane) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveDepthPlane_), resolveDepthPlane); +} + +_MTL_INLINE MTL::LoadAction MTL::RenderPassAttachmentDescriptor::loadAction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(loadAction)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLoadAction(MTL::LoadAction loadAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLoadAction_), loadAction); +} + +_MTL_INLINE MTL::StoreAction MTL::RenderPassAttachmentDescriptor::storeAction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storeAction)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStoreAction_), storeAction); +} + +_MTL_INLINE MTL::StoreActionOptions MTL::RenderPassAttachmentDescriptor::storeActionOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storeActionOptions)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStoreActionOptions_), storeActionOptions); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ClearColor MTL::RenderPassColorAttachmentDescriptor::clearColor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearColor)); +} + +_MTL_INLINE void MTL::RenderPassColorAttachmentDescriptor::setClearColor(MTL::ClearColor clearColor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearColor_), clearColor); +} + +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassDepthAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE double MTL::RenderPassDepthAttachmentDescriptor::clearDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearDepth)); +} + +_MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setClearDepth(double clearDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearDepth_), clearDepth); +} + +_MTL_INLINE MTL::MultisampleDepthResolveFilter MTL::RenderPassDepthAttachmentDescriptor::depthResolveFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthResolveFilter)); +} + +_MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthResolveFilter_), depthResolveFilter); +} + +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassStencilAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE uint32_t MTL::RenderPassStencilAttachmentDescriptor::clearStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearStencil)); +} + +_MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setClearStencil(uint32_t clearStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearStencil_), clearStencil); +} + +_MTL_INLINE MTL::MultisampleStencilResolveFilter MTL::RenderPassStencilAttachmentDescriptor::stencilResolveFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilResolveFilter)); +} + +_MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilResolveFilter_), stencilResolveFilter); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::RenderPassColorAttachmentDescriptorArray::setObject(const MTL::RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::RenderPassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfVertexSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfVertexSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfVertexSampleIndex_), startOfVertexSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfVertexSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfVertexSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfVertexSampleIndex_), endOfVertexSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfFragmentSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfFragmentSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfFragmentSampleIndex_), startOfFragmentSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfFragmentSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfFragmentSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfFragmentSampleIndex_), endOfFragmentSampleIndex); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptorArray::setObject(const MTL::RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor)); +} + +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::renderPassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor), _MTL_PRIVATE_SEL(renderPassDescriptor)); +} + +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDescriptor::depthAttachment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachment)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setDepthAttachment(const MTL::RenderPassDepthAttachmentDescriptor* depthAttachment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachment_), depthAttachment); +} + +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassDescriptor::stencilAttachment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachment)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setStencilAttachment(const MTL::RenderPassStencilAttachmentDescriptor* stencilAttachment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachment_), stencilAttachment); +} + +_MTL_INLINE MTL::Buffer* MTL::RenderPassDescriptor::visibilityResultBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(visibilityResultBuffer)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setVisibilityResultBuffer(const MTL::Buffer* visibilityResultBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibilityResultBuffer_), visibilityResultBuffer); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetArrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetArrayLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetArrayLength_), renderTargetArrayLength); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::imageblockSampleLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockSampleLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setImageblockSampleLength(NS::UInteger imageblockSampleLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockSampleLength_), imageblockSampleLength); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::threadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_), threadgroupMemoryLength); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileWidth)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setTileWidth(NS::UInteger tileWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileWidth_), tileWidth); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileHeight)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setTileHeight(NS::UInteger tileHeight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileHeight_), tileHeight); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::defaultRasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(defaultRasterSampleCount)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDefaultRasterSampleCount_), defaultRasterSampleCount); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetWidth)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetWidth(NS::UInteger renderTargetWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetWidth_), renderTargetWidth); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetHeight)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetHeight(NS::UInteger renderTargetHeight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetHeight_), renderTargetHeight); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplePositions_count_), positions, count); +} + +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(getSamplePositions_count_), positions, count); +} + +_MTL_INLINE MTL::RasterizationRateMap* MTL::RenderPassDescriptor::rasterizationRateMap() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterizationRateMap)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRasterizationRateMap(const MTL::RasterizationRateMap* rasterizationRateMap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationRateMap_), rasterizationRateMap); +} + +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PrimitiveType) { + PrimitiveTypePoint = 0, + PrimitiveTypeLine = 1, + PrimitiveTypeLineStrip = 2, + PrimitiveTypeTriangle = 3, + PrimitiveTypeTriangleStrip = 4, +}; + +_MTL_ENUM(NS::UInteger, VisibilityResultMode) { + VisibilityResultModeDisabled = 0, + VisibilityResultModeBoolean = 1, + VisibilityResultModeCounting = 2, +}; + +struct ScissorRect +{ + NS::UInteger x; + NS::UInteger y; + NS::UInteger width; + NS::UInteger height; +} _MTL_PACKED; + +struct Viewport +{ + double originX; + double originY; + double width; + double height; + double znear; + double zfar; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, CullMode) { + CullModeNone = 0, + CullModeFront = 1, + CullModeBack = 2, +}; + +_MTL_ENUM(NS::UInteger, Winding) { + WindingClockwise = 0, + WindingCounterClockwise = 1, +}; + +_MTL_ENUM(NS::UInteger, DepthClipMode) { + DepthClipModeClip = 0, + DepthClipModeClamp = 1, +}; + +_MTL_ENUM(NS::UInteger, TriangleFillMode) { + TriangleFillModeFill = 0, + TriangleFillModeLines = 1, +}; + +struct DrawPrimitivesIndirectArguments +{ + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t vertexStart; + uint32_t baseInstance; +} _MTL_PACKED; + +struct DrawIndexedPrimitivesIndirectArguments +{ + uint32_t indexCount; + uint32_t instanceCount; + uint32_t indexStart; + int32_t baseVertex; + uint32_t baseInstance; +} _MTL_PACKED; + +struct VertexAmplificationViewMapping +{ + uint32_t viewportArrayIndexOffset; + uint32_t renderTargetArrayIndexOffset; +} _MTL_PACKED; + +struct DrawPatchIndirectArguments +{ + uint32_t patchCount; + uint32_t instanceCount; + uint32_t patchStart; + uint32_t baseInstance; +} _MTL_PACKED; + +struct QuadTessellationFactorsHalf +{ + uint16_t edgeTessellationFactor[4]; + uint16_t insideTessellationFactor[2]; +} _MTL_PACKED; + +struct TriangleTessellationFactorsHalf +{ + uint16_t edgeTessellationFactor[3]; + uint16_t insideTessellationFactor; +} _MTL_PACKED; + +_MTL_OPTIONS(NS::UInteger, RenderStages) { + RenderStageVertex = 1, + RenderStageFragment = 2, + RenderStageTile = 4, + RenderStageObject = 8, + RenderStageMesh = 16, +}; + +class RenderCommandEncoder : public NS::Referencing +{ +public: + void setRenderPipelineState(const class RenderPipelineState* pipelineState); + + void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setVertexBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range); + + void setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index); + + void setVertexTexture(const class Texture* texture, NS::UInteger index); + + void setVertexTextures(const class Texture* const textures[], NS::Range range); + + void setVertexSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setVertexSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setVertexSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setVertexSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setVertexVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setVertexVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setVertexIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setVertexIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setVertexAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setViewport(MTL::Viewport viewport); + + void setViewports(const MTL::Viewport* viewports, NS::UInteger count); + + void setFrontFacingWinding(MTL::Winding frontFacingWinding); + + void setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings); + + void setCullMode(MTL::CullMode cullMode); + + void setDepthClipMode(MTL::DepthClipMode depthClipMode); + + void setDepthBias(float depthBias, float slopeScale, float clamp); + + void setScissorRect(MTL::ScissorRect rect); + + void setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count); + + void setTriangleFillMode(MTL::TriangleFillMode fillMode); + + void setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setFragmentBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setFragmentBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setFragmentTexture(const class Texture* texture, NS::UInteger index); + + void setFragmentTextures(const class Texture* const textures[], NS::Range range); + + void setFragmentSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setFragmentSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setFragmentSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setFragmentSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setFragmentVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setFragmentVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setFragmentIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setFragmentIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setFragmentAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setBlendColor(float red, float green, float blue, float alpha); + + void setDepthStencilState(const class DepthStencilState* depthStencilState); + + void setStencilReferenceValue(uint32_t referenceValue); + + void setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue); + + void setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset); + + void setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex); + + void setDepthStoreAction(MTL::StoreAction storeAction); + + void setStencilStoreAction(MTL::StoreAction storeAction); + + void setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex); + + void setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setObjectBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setObjectBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setObjectBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setObjectTexture(const class Texture* texture, NS::UInteger index); + + void setObjectTextures(const class Texture* const textures[], NS::Range range); + + void setObjectSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setObjectSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setObjectSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setObjectSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range); + + void setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setMeshBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setMeshBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setMeshBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setMeshTexture(const class Texture* texture, NS::UInteger index); + + void setMeshTextures(const class Texture* const textures[], NS::Range range); + + void setMeshSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setMeshSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setMeshSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setMeshSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range); + + void drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawMeshThreadgroups(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance); + + void drawPrimitives(MTL::PrimitiveType primitiveType, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void textureBarrier(); + + void updateFence(const class Fence* fence, MTL::RenderStages stages); + + void waitForFence(const class Fence* fence, MTL::RenderStages stages); + + void setTessellationFactorBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void setTessellationFactorScale(float scale); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + NS::UInteger tileWidth() const; + + NS::UInteger tileHeight() const; + + void setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setTileBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setTileBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setTileBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setTileTexture(const class Texture* texture, NS::UInteger index); + + void setTileTextures(const class Texture* const textures[], NS::Range range); + + void setTileSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setTileSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setTileSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setTileSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setTileVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setTileVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setTileIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setTileIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setTileAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void dispatchThreadsPerTile(MTL::Size threadsPerTile); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void useHeap(const class Heap* heap, MTL::RenderStages stages); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandbuffer, const class Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset); + + void memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before); + + void memoryBarrier(const class Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setRenderPipelineState(const MTL::RenderPipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_), pipelineState); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_attributeStrides_withRange_), buffers, offsets, strides, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_attributeStride_atIndex_), offset, stride, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBytes_length_attributeStride_atIndex_), bytes, length, stride, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setViewport(MTL::Viewport viewport) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setViewport_), viewport); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setViewports(const MTL::Viewport* viewports, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setViewports_count_), viewports, count); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFrontFacingWinding(MTL::Winding frontFacingWinding) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFrontFacingWinding_), frontFacingWinding); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAmplificationCount_viewMappings_), count, viewMappings); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setCullMode(MTL::CullMode cullMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCullMode_), cullMode); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthClipMode(MTL::DepthClipMode depthClipMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthClipMode_), depthClipMode); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthBias(float depthBias, float slopeScale, float clamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthBias_slopeScale_clamp_), depthBias, slopeScale, clamp); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setScissorRect(MTL::ScissorRect rect) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScissorRect_), rect); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScissorRects_count_), scissorRects, count); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTriangleFillMode(MTL::TriangleFillMode fillMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleFillMode_), fillMode); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setBlendColor(float red, float green, float blue, float alpha) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBlendColorRed_green_blue_alpha_), red, green, blue, alpha); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStencilState(const MTL::DepthStencilState* depthStencilState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStencilState_), depthStencilState); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValue(uint32_t referenceValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilReferenceValue_), referenceValue); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilFrontReferenceValue_backReferenceValue_), frontReferenceValue, backReferenceValue); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibilityResultMode_offset_), mode, offset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreAction_atIndex_), storeAction, colorAttachmentIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreAction_), storeAction); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreAction_), storeAction); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreActionOptions_atIndex_), storeActionOptions, colorAttachmentIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreActionOptions_), storeActionOptions); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreActionOptions_), storeActionOptions); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectThreadgroupMemoryLength_atIndex_), length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadgroupsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), indirectBuffer, indirectBufferOffset, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_), primitiveType, vertexStart, vertexCount, instanceCount); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_), primitiveType, vertexStart, vertexCount); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_), primitiveType, vertexStart, vertexCount, instanceCount, baseInstance); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_indirectBuffer_indirectBufferOffset_), primitiveType, indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset_), primitiveType, indexType, indexBuffer, indexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::textureBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(textureBarrier)); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::updateFence(const MTL::Fence* fence, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_afterStages_), fence, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::waitForFence(const MTL::Fence* fence, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_beforeStages_), fence, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorBuffer_offset_instanceStride_), buffer, offset, instanceStride); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorScale(float scale) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorScale_), scale); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchIndexBuffer_patchIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileWidth)); +} + +_MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileHeight)); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBytes_length_atIndex_), bytes, length, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBufferOffset_atIndex_), offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileTexture_atIndex_), texture, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileTextures_withRange_), textures, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerState_atIndex_), sampler, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerStates_withRange_), samplers, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setTileAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::dispatchThreadsPerTile(MTL::Size threadsPerTile) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadsPerTile_), threadsPerTile); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_offset_atIndex_), length, offset, index); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_stages_), resource, usage, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_stages_), resources, count, usage, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_stages_), heap, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_stages_), heaps, count, stages); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_withRange_), indirectCommandBuffer, executionRange); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandbuffer, const MTL::Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_), indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithScope_afterStages_beforeStages_), scope, after, before); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(const MTL::Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithResources_count_afterStages_beforeStages_), resources, count, after, before); +} + +_MTL_INLINE void MTL::RenderCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +namespace MTL +{ +class IndirectRenderCommand : public NS::Referencing +{ +public: + void setRenderPipelineState(const class RenderPipelineState* pipelineState); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setFragmentBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance); + + void setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setObjectBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setMeshBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void setBarrier(); + + void clearBarrier(); + + void reset(); +}; + +class IndirectComputeCommand : public NS::Referencing +{ +public: + void setComputePipelineState(const class ComputePipelineState* pipelineState); + + void setKernelBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setKernelBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); + + void concurrentDispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup); + + void concurrentDispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup); + + void setBarrier(); + + void clearBarrier(); + + void setImageblockWidth(NS::UInteger width, NS::UInteger height); + + void reset(); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setStageInRegion(MTL::Region region); +}; + +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setRenderPipelineState(const MTL::RenderPipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_), pipelineState); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setFragmentBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_), primitiveType, vertexStart, vertexCount, instanceCount, baseInstance); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectThreadgroupMemoryLength_atIndex_), length, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setObjectBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setMeshBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadgroupsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::setBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBarrier)); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::clearBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(clearBarrier)); +} + +_MTL_INLINE void MTL::IndirectRenderCommand::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setComputePipelineState(const MTL::ComputePipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_), pipelineState); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setKernelBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setKernelBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setKernelBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setKernelBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::concurrentDispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(concurrentDispatchThreadgroups_threadsPerThreadgroup_), threadgroupsPerGrid, threadsPerThreadgroup); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::concurrentDispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(concurrentDispatchThreads_threadsPerThreadgroup_), threadsPerGrid, threadsPerThreadgroup); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBarrier)); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::clearBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(clearBarrier)); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setImageblockWidth(NS::UInteger width, NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockWidth_height_), width, height); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_atIndex_), length, index); +} + +_MTL_INLINE void MTL::IndirectComputeCommand::setStageInRegion(MTL::Region region) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegion_), region); +} + +#pragma once + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, IntersectionFunctionSignature) { + IntersectionFunctionSignatureNone = 0, + IntersectionFunctionSignatureInstancing = 1, + IntersectionFunctionSignatureTriangleData = 2, + IntersectionFunctionSignatureWorldSpaceData = 4, + IntersectionFunctionSignatureInstanceMotion = 8, + IntersectionFunctionSignaturePrimitiveMotion = 16, + IntersectionFunctionSignatureExtendedLimits = 32, + IntersectionFunctionSignatureMaxLevels = 64, + IntersectionFunctionSignatureCurveData = 128, +}; + +class IntersectionFunctionTableDescriptor : public NS::Copying +{ +public: + static class IntersectionFunctionTableDescriptor* alloc(); + + class IntersectionFunctionTableDescriptor* init(); + + static class IntersectionFunctionTableDescriptor* intersectionFunctionTableDescriptor(); + + NS::UInteger functionCount() const; + void setFunctionCount(NS::UInteger functionCount); +}; + +class IntersectionFunctionTable : public NS::Referencing +{ +public: + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + MTL::ResourceID gpuResourceID() const; + + void setFunction(const class FunctionHandle* function, NS::UInteger index); + + void setFunctions(const class FunctionHandle* const functions[], NS::Range range); + + void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); + + void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range); + + void setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); + + void setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range); + + void setVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range bufferRange); +}; + +} + +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor)); +} + +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::intersectionFunctionTableDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor), _MTL_PRIVATE_SEL(intersectionFunctionTableDescriptor)); +} + +_MTL_INLINE NS::UInteger MTL::IntersectionFunctionTableDescriptor::functionCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionCount)); +} + +_MTL_INLINE void MTL::IntersectionFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +_MTL_INLINE MTL::ResourceID MTL::IntersectionFunctionTable::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_atIndex_), signature, index); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_withRange_), signature, range); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_atIndex_), signature, index); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_withRange_), signature, range); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +_MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range bufferRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withBufferRange_), functionTables, bufferRange); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOStatus) { + IOStatusPending = 0, + IOStatusCancelled = 1, + IOStatusError = 2, + IOStatusComplete = 3, +}; + +using IOCommandBufferHandler = void (^)(class IOCommandBuffer*); + +using IOCommandBufferHandlerFunction = std::function; + +class IOCommandBuffer : public NS::Referencing +{ +public: + void addCompletedHandler(const MTL::IOCommandBufferHandlerFunction& function); + + void addCompletedHandler(const MTL::IOCommandBufferHandler block); + + void loadBytes(const void* pointer, NS::UInteger size, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void loadBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger size, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void loadTexture(const class Texture* texture, NS::UInteger slice, NS::UInteger level, MTL::Size size, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Origin destinationOrigin, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void copyStatusToBuffer(const class Buffer* buffer, NS::UInteger offset); + + void commit(); + + void waitUntilCompleted(); + + void tryCancel(); + + void addBarrier(); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); + + void enqueue(); + + void wait(const class SharedEvent* event, uint64_t value); + + void signalEvent(const class SharedEvent* event, uint64_t value); + + NS::String* label() const; + void setLabel(const NS::String* label); + + MTL::IOStatus status() const; + + NS::Error* error() const; +}; + +} + +_MTL_INLINE void MTL::IOCommandBuffer::addCompletedHandler(const MTL::IOCommandBufferHandlerFunction& function) +{ + __block IOCommandBufferHandlerFunction blockFunction = function; + + addCompletedHandler(^(IOCommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +_MTL_INLINE void MTL::IOCommandBuffer::addCompletedHandler(const MTL::IOCommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addCompletedHandler_), block); +} + +_MTL_INLINE void MTL::IOCommandBuffer::loadBytes(const void* pointer, NS::UInteger size, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadBytes_size_sourceHandle_sourceHandleOffset_), pointer, size, sourceHandle, sourceHandleOffset); +} + +_MTL_INLINE void MTL::IOCommandBuffer::loadBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger size, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadBuffer_offset_size_sourceHandle_sourceHandleOffset_), buffer, offset, size, sourceHandle, sourceHandleOffset); +} + +_MTL_INLINE void MTL::IOCommandBuffer::loadTexture(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level, MTL::Size size, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Origin destinationOrigin, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadTexture_slice_level_size_sourceBytesPerRow_sourceBytesPerImage_destinationOrigin_sourceHandle_sourceHandleOffset_), texture, slice, level, size, sourceBytesPerRow, sourceBytesPerImage, destinationOrigin, sourceHandle, sourceHandleOffset); +} + +_MTL_INLINE void MTL::IOCommandBuffer::copyStatusToBuffer(const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyStatusToBuffer_offset_), buffer, offset); +} + +_MTL_INLINE void MTL::IOCommandBuffer::commit() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(commit)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::waitUntilCompleted() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilCompleted)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::tryCancel() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(tryCancel)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::addBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addBarrier)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +_MTL_INLINE void MTL::IOCommandBuffer::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::enqueue() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueue)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::wait(const MTL::SharedEvent* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForEvent_value_), event, value); +} + +_MTL_INLINE void MTL::IOCommandBuffer::signalEvent(const MTL::SharedEvent* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(signalEvent_value_), event, value); +} + +_MTL_INLINE NS::String* MTL::IOCommandBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::IOStatus MTL::IOCommandBuffer::status() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(status)); +} + +_MTL_INLINE NS::Error* MTL::IOCommandBuffer::error() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(error)); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOPriority) { + IOPriorityHigh = 0, + IOPriorityNormal = 1, + IOPriorityLow = 2, +}; + +_MTL_ENUM(NS::Integer, IOCommandQueueType) { + IOCommandQueueTypeConcurrent = 0, + IOCommandQueueTypeSerial = 1, +}; + +_MTL_CONST(NS::ErrorDomain, IOErrorDomain); + +_MTL_ENUM(NS::Integer, IOError) { + IOErrorURLInvalid = 1, + IOErrorInternal = 2, +}; + +class IOCommandQueue : public NS::Referencing +{ +public: + void enqueueBarrier(); + + class IOCommandBuffer* commandBuffer(); + + class IOCommandBuffer* commandBufferWithUnretainedReferences(); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class IOScratchBuffer : public NS::Referencing +{ +public: + class Buffer* buffer() const; +}; + +class IOScratchBufferAllocator : public NS::Referencing +{ +public: + class IOScratchBuffer* newScratchBuffer(NS::UInteger minimumSize); +}; + +class IOCommandQueueDescriptor : public NS::Copying +{ +public: + static class IOCommandQueueDescriptor* alloc(); + + class IOCommandQueueDescriptor* init(); + + NS::UInteger maxCommandBufferCount() const; + void setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount); + + MTL::IOPriority priority() const; + void setPriority(MTL::IOPriority priority); + + MTL::IOCommandQueueType type() const; + void setType(MTL::IOCommandQueueType type); + + NS::UInteger maxCommandsInFlight() const; + void setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight); + + class IOScratchBufferAllocator* scratchBufferAllocator() const; + void setScratchBufferAllocator(const class IOScratchBufferAllocator* scratchBufferAllocator); +}; + +class IOFileHandle : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +} + +_MTL_PRIVATE_DEF_WEAK_CONST(NS::ErrorDomain, IOErrorDomain); + +_MTL_INLINE void MTL::IOCommandQueue::enqueueBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueueBarrier)); +} + +_MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBuffer() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBuffer)); +} + +_MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBufferWithUnretainedReferences() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithUnretainedReferences)); +} + +_MTL_INLINE NS::String* MTL::IOCommandQueue::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOCommandQueue::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Buffer* MTL::IOScratchBuffer::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +_MTL_INLINE MTL::IOScratchBuffer* MTL::IOScratchBufferAllocator::newScratchBuffer(NS::UInteger minimumSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newScratchBufferWithMinimumSize_), minimumSize); +} + +_MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIOCommandQueueDescriptor)); +} + +_MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandBufferCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCommandBufferCount)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCommandBufferCount_), maxCommandBufferCount); +} + +_MTL_INLINE MTL::IOPriority MTL::IOCommandQueueDescriptor::priority() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(priority)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setPriority(MTL::IOPriority priority) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPriority_), priority); +} + +_MTL_INLINE MTL::IOCommandQueueType MTL::IOCommandQueueDescriptor::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setType(MTL::IOCommandQueueType type) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setType_), type); +} + +_MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandsInFlight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCommandsInFlight)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCommandsInFlight_), maxCommandsInFlight); +} + +_MTL_INLINE MTL::IOScratchBufferAllocator* MTL::IOCommandQueueDescriptor::scratchBufferAllocator() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(scratchBufferAllocator)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setScratchBufferAllocator(const MTL::IOScratchBufferAllocator* scratchBufferAllocator) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScratchBufferAllocator_), scratchBufferAllocator); +} + +_MTL_INLINE NS::String* MTL::IOFileHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOFileHandle::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +#pragma once + +namespace MTL +{ +using IOCompresionContext=void*; + +_MTL_ENUM(NS::Integer, IOCompressionStatus) { + IOCompressionStatusComplete = 0, + IOCompressionStatusError = 1, +}; + +size_t IOCompressionContextDefaultChunkSize(); + +IOCompresionContext IOCreateCompressionContext(const char* path, IOCompressionMethod type, size_t chunkSize); + +void IOCompressionContextAppendData(IOCompresionContext context, const void* data, size_t size); + +IOCompressionStatus IOFlushAndDestroyCompressionContext(IOCompresionContext context); + +} + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +namespace MTL::Private { + +MTL_DEF_FUNC(MTLIOCompressionContextDefaultChunkSize, size_t (*)(void)); + +MTL_DEF_FUNC( MTLIOCreateCompressionContext, void* (*)(const char*, MTL::IOCompressionMethod, size_t) ); + +MTL_DEF_FUNC( MTLIOCompressionContextAppendData, void (*)(void*, const void*, size_t) ); + +MTL_DEF_FUNC( MTLIOFlushAndDestroyCompressionContext, MTL::IOCompressionStatus (*)(void*) ); + +} + +_NS_EXPORT size_t MTL::IOCompressionContextDefaultChunkSize() +{ + return MTL::Private::MTLIOCompressionContextDefaultChunkSize(); +} + +_NS_EXPORT void* MTL::IOCreateCompressionContext(const char* path, IOCompressionMethod type, size_t chunkSize) +{ + if ( MTL::Private::MTLIOCreateCompressionContext ) + { + return MTL::Private::MTLIOCreateCompressionContext( path, type, chunkSize ); + } + return nullptr; +} + +_NS_EXPORT void MTL::IOCompressionContextAppendData(void* context, const void* data, size_t size) +{ + if ( MTL::Private::MTLIOCompressionContextAppendData ) + { + MTL::Private::MTLIOCompressionContextAppendData( context, data, size ); + } +} + +_NS_EXPORT MTL::IOCompressionStatus MTL::IOFlushAndDestroyCompressionContext(void* context) +{ + if ( MTL::Private::MTLIOFlushAndDestroyCompressionContext ) + { + return MTL::Private::MTLIOFlushAndDestroyCompressionContext( context ); + } + return MTL::IOCompressionStatusError; +} + +#endif + +#pragma once + +namespace MTL +{ +class LinkedFunctions : public NS::Copying +{ +public: + static class LinkedFunctions* alloc(); + + class LinkedFunctions* init(); + + static class LinkedFunctions* linkedFunctions(); + + NS::Array* functions() const; + void setFunctions(const NS::Array* functions); + + NS::Array* binaryFunctions() const; + void setBinaryFunctions(const NS::Array* binaryFunctions); + + NS::Dictionary* groups() const; + void setGroups(const NS::Dictionary* groups); + + NS::Array* privateFunctions() const; + void setPrivateFunctions(const NS::Array* privateFunctions); +}; + +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLLinkedFunctions)); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::linkedFunctions() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLLinkedFunctions), _MTL_PRIVATE_SEL(linkedFunctions)); +} + +_MTL_INLINE NS::Array* MTL::LinkedFunctions::functions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setFunctions(const NS::Array* functions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_), functions); +} + +_MTL_INLINE NS::Array* MTL::LinkedFunctions::binaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryFunctions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setBinaryFunctions(const NS::Array* binaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryFunctions_), binaryFunctions); +} + +_MTL_INLINE NS::Dictionary* MTL::LinkedFunctions::groups() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(groups)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setGroups(const NS::Dictionary* groups) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setGroups_), groups); +} + +_MTL_INLINE NS::Array* MTL::LinkedFunctions::privateFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(privateFunctions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setPrivateFunctions(const NS::Array* privateFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrivateFunctions_), privateFunctions); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::Integer, LogLevel) { + LogLevelUndefined = 0, + LogLevelDebug = 1, + LogLevelInfo = 2, + LogLevelNotice = 3, + LogLevelError = 4, + LogLevelFault = 5, +}; + +class LogState : public NS::Referencing +{ +public: + void addLogHandler(void (^block)(NS::String*, NS::String*, MTL::LogLevel, NS::String*)); +}; + +class LogStateDescriptor : public NS::Copying +{ +public: + static class LogStateDescriptor* alloc(); + + class LogStateDescriptor* init(); + + MTL::LogLevel level() const; + void setLevel(MTL::LogLevel level); + + NS::Integer bufferSize() const; + void setBufferSize(NS::Integer bufferSize); +}; + +_MTL_CONST(NS::ErrorDomain, LogStateErrorDomain); + +_MTL_ENUM(NS::UInteger, LogStateError) { + LogStateErrorInvalidSize = 1, + LogStateErrorInvalid = 2, +}; + +} + +_MTL_PRIVATE_DEF_WEAK_CONST(NS::ErrorDomain, LogStateErrorDomain); + +_MTL_INLINE void MTL::LogState::addLogHandler(void (^block)(NS::String*, NS::String*, MTL::LogLevel, NS::String*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addLogHandler_), block); +} + +_MTL_INLINE MTL::LogStateDescriptor* MTL::LogStateDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLLogStateDescriptor)); +} + +_MTL_INLINE MTL::LogStateDescriptor* MTL::LogStateDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::LogLevel MTL::LogStateDescriptor::level() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(level)); +} + +_MTL_INLINE void MTL::LogStateDescriptor::setLevel(MTL::LogLevel level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLevel_), level); +} + +_MTL_INLINE NS::Integer MTL::LogStateDescriptor::bufferSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferSize)); +} + +_MTL_INLINE void MTL::LogStateDescriptor::setBufferSize(NS::Integer bufferSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferSize_), bufferSize); +} + +#pragma once + +namespace MTL +{ +class ParallelRenderCommandEncoder : public NS::Referencing +{ +public: + class RenderCommandEncoder* renderCommandEncoder(); + + void setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex); + + void setDepthStoreAction(MTL::StoreAction storeAction); + + void setStencilStoreAction(MTL::StoreAction storeAction); + + void setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex); + + void setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions); +}; + +} + +_MTL_INLINE MTL::RenderCommandEncoder* MTL::ParallelRenderCommandEncoder::renderCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderCommandEncoder)); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreAction_atIndex_), storeAction, colorAttachmentIndex); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setDepthStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreAction_), storeAction); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setStencilStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreAction_), storeAction); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreActionOptions_atIndex_), storeActionOptions, colorAttachmentIndex); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreActionOptions_), storeActionOptions); +} + +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreActionOptions_), storeActionOptions); +} + +#pragma once + +namespace MTL +{ +class RasterizationRateSampleArray : public NS::Referencing +{ +public: + static class RasterizationRateSampleArray* alloc(); + + class RasterizationRateSampleArray* init(); + + NS::Number* object(NS::UInteger index); + + void setObject(const NS::Number* value, NS::UInteger index); +}; + +class RasterizationRateLayerDescriptor : public NS::Copying +{ +public: + static class RasterizationRateLayerDescriptor* alloc(); + + MTL::RasterizationRateLayerDescriptor* init(); + + MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount); + + MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount, const float* horizontal, const float* vertical); + + MTL::Size sampleCount() const; + + MTL::Size maxSampleCount() const; + + float* horizontalSampleStorage() const; + + float* verticalSampleStorage() const; + + class RasterizationRateSampleArray* horizontal() const; + + class RasterizationRateSampleArray* vertical() const; + + void setSampleCount(MTL::Size sampleCount); +}; + +class RasterizationRateLayerArray : public NS::Referencing +{ +public: + static class RasterizationRateLayerArray* alloc(); + + class RasterizationRateLayerArray* init(); + + class RasterizationRateLayerDescriptor* object(NS::UInteger layerIndex); + + void setObject(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex); +}; + +class RasterizationRateMapDescriptor : public NS::Copying +{ +public: + static class RasterizationRateMapDescriptor* alloc(); + + class RasterizationRateMapDescriptor* init(); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, const class RasterizationRateLayerDescriptor* layer); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const class RasterizationRateLayerDescriptor* const* layers); + + class RasterizationRateLayerDescriptor* layer(NS::UInteger layerIndex); + + void setLayer(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex); + + class RasterizationRateLayerArray* layers() const; + + MTL::Size screenSize() const; + void setScreenSize(MTL::Size screenSize); + + NS::String* label() const; + void setLabel(const NS::String* label); + + NS::UInteger layerCount() const; +}; + +class RasterizationRateMap : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + + MTL::Size screenSize() const; + + MTL::Size physicalGranularity() const; + + NS::UInteger layerCount() const; + + MTL::SizeAndAlign parameterBufferSizeAndAlign() const; + + void copyParameterDataToBuffer(const class Buffer* buffer, NS::UInteger offset); + + MTL::Size physicalSize(NS::UInteger layerIndex); + + MTL::Coordinate2D mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex); + + MTL::Coordinate2D mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex); +}; + +} + +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateSampleArray)); +} + +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Number* MTL::RasterizationRateSampleArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +_MTL_INLINE void MTL::RasterizationRateSampleArray::setObject(const NS::Number* value, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), value, index); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerDescriptor)); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithSampleCount_), sampleCount); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount, const float* horizontal, const float* vertical) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithSampleCount_horizontal_vertical_), sampleCount, horizontal, vertical); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::maxSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxSampleCount)); +} + +_MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::horizontalSampleStorage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(horizontalSampleStorage)); +} + +_MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::verticalSampleStorage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(verticalSampleStorage)); +} + +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::horizontal() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(horizontal)); +} + +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::vertical() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertical)); +} + +_MTL_INLINE void MTL::RasterizationRateLayerDescriptor::setSampleCount(MTL::Size sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerArray)); +} + +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerArray::object(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), layerIndex); +} + +_MTL_INLINE void MTL::RasterizationRateLayerArray::setObject(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), layer, layerIndex); +} + +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor)); +} + +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_), screenSize); +} + +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, const MTL::RasterizationRateLayerDescriptor* layer) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layer_), screenSize, layer); +} + +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const MTL::RasterizationRateLayerDescriptor* const* layers) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layerCount_layers_), screenSize, layerCount, layers); +} + +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateMapDescriptor::layer(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerAtIndex_), layerIndex); +} + +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLayer(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLayer_atIndex_), layer, layerIndex); +} + +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateMapDescriptor::layers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layers)); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateMapDescriptor::screenSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(screenSize)); +} + +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setScreenSize(MTL::Size screenSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScreenSize_), screenSize); +} + +_MTL_INLINE NS::String* MTL::RasterizationRateMapDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE NS::UInteger MTL::RasterizationRateMapDescriptor::layerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerCount)); +} + +_MTL_INLINE MTL::Device* MTL::RasterizationRateMap::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::RasterizationRateMap::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::screenSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(screenSize)); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalGranularity() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(physicalGranularity)); +} + +_MTL_INLINE NS::UInteger MTL::RasterizationRateMap::layerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerCount)); +} + +_MTL_INLINE MTL::SizeAndAlign MTL::RasterizationRateMap::parameterBufferSizeAndAlign() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parameterBufferSizeAndAlign)); +} + +_MTL_INLINE void MTL::RasterizationRateMap::copyParameterDataToBuffer(const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyParameterDataToBuffer_offset_), buffer, offset); +} + +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalSize(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(physicalSizeForLayer_), layerIndex); +} + +_MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mapScreenToPhysicalCoordinates_forLayer_), screenCoordinates, layerIndex); +} + +_MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mapPhysicalToScreenCoordinates_forLayer_), physicalCoordinates, layerIndex); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, BlendFactor) { + BlendFactorZero = 0, + BlendFactorOne = 1, + BlendFactorSourceColor = 2, + BlendFactorOneMinusSourceColor = 3, + BlendFactorSourceAlpha = 4, + BlendFactorOneMinusSourceAlpha = 5, + BlendFactorDestinationColor = 6, + BlendFactorOneMinusDestinationColor = 7, + BlendFactorDestinationAlpha = 8, + BlendFactorOneMinusDestinationAlpha = 9, + BlendFactorSourceAlphaSaturated = 10, + BlendFactorBlendColor = 11, + BlendFactorOneMinusBlendColor = 12, + BlendFactorBlendAlpha = 13, + BlendFactorOneMinusBlendAlpha = 14, + BlendFactorSource1Color = 15, + BlendFactorOneMinusSource1Color = 16, + BlendFactorSource1Alpha = 17, + BlendFactorOneMinusSource1Alpha = 18, +}; + +_MTL_ENUM(NS::UInteger, BlendOperation) { + BlendOperationAdd = 0, + BlendOperationSubtract = 1, + BlendOperationReverseSubtract = 2, + BlendOperationMin = 3, + BlendOperationMax = 4, +}; + +_MTL_OPTIONS(NS::UInteger, ColorWriteMask) { + ColorWriteMaskNone = 0, + ColorWriteMaskRed = 8, + ColorWriteMaskGreen = 4, + ColorWriteMaskBlue = 2, + ColorWriteMaskAlpha = 1, + ColorWriteMaskAll = 15, +}; + +_MTL_ENUM(NS::UInteger, PrimitiveTopologyClass) { + PrimitiveTopologyClassUnspecified = 0, + PrimitiveTopologyClassPoint = 1, + PrimitiveTopologyClassLine = 2, + PrimitiveTopologyClassTriangle = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationPartitionMode) { + TessellationPartitionModePow2 = 0, + TessellationPartitionModeInteger = 1, + TessellationPartitionModeFractionalOdd = 2, + TessellationPartitionModeFractionalEven = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationFactorStepFunction) { + TessellationFactorStepFunctionConstant = 0, + TessellationFactorStepFunctionPerPatch = 1, + TessellationFactorStepFunctionPerInstance = 2, + TessellationFactorStepFunctionPerPatchAndPerInstance = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationFactorFormat) { + TessellationFactorFormatHalf = 0, +}; + +_MTL_ENUM(NS::UInteger, TessellationControlPointIndexType) { + TessellationControlPointIndexTypeNone = 0, + TessellationControlPointIndexTypeUInt16 = 1, + TessellationControlPointIndexTypeUInt32 = 2, +}; + +class RenderPipelineColorAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPipelineColorAttachmentDescriptor* alloc(); + + class RenderPipelineColorAttachmentDescriptor* init(); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + bool blendingEnabled() const; + void setBlendingEnabled(bool blendingEnabled); + + MTL::BlendFactor sourceRGBBlendFactor() const; + void setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor); + + MTL::BlendFactor destinationRGBBlendFactor() const; + void setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor); + + MTL::BlendOperation rgbBlendOperation() const; + void setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation); + + MTL::BlendFactor sourceAlphaBlendFactor() const; + void setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor); + + MTL::BlendFactor destinationAlphaBlendFactor() const; + void setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor); + + MTL::BlendOperation alphaBlendOperation() const; + void setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation); + + MTL::ColorWriteMask writeMask() const; + void setWriteMask(MTL::ColorWriteMask writeMask); +}; + +class RenderPipelineReflection : public NS::Referencing +{ +public: + static class RenderPipelineReflection* alloc(); + + class RenderPipelineReflection* init(); + + NS::Array* vertexBindings() const; + + NS::Array* fragmentBindings() const; + + NS::Array* tileBindings() const; + + NS::Array* objectBindings() const; + + NS::Array* meshBindings() const; + + NS::Array* vertexArguments() const; + + NS::Array* fragmentArguments() const; + + NS::Array* tileArguments() const; +}; + +class RenderPipelineDescriptor : public NS::Copying +{ +public: + static class RenderPipelineDescriptor* alloc(); + + class RenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* vertexFunction() const; + void setVertexFunction(const class Function* vertexFunction); + + class Function* fragmentFunction() const; + void setFragmentFunction(const class Function* fragmentFunction); + + class VertexDescriptor* vertexDescriptor() const; + void setVertexDescriptor(const class VertexDescriptor* vertexDescriptor); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + bool alphaToCoverageEnabled() const; + void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled); + + bool alphaToOneEnabled() const; + void setAlphaToOneEnabled(bool alphaToOneEnabled); + + bool rasterizationEnabled() const; + void setRasterizationEnabled(bool rasterizationEnabled); + + NS::UInteger maxVertexAmplificationCount() const; + void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount); + + class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + MTL::PixelFormat depthAttachmentPixelFormat() const; + void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat); + + MTL::PixelFormat stencilAttachmentPixelFormat() const; + void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat); + + MTL::PrimitiveTopologyClass inputPrimitiveTopology() const; + void setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology); + + MTL::TessellationPartitionMode tessellationPartitionMode() const; + void setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode); + + NS::UInteger maxTessellationFactor() const; + void setMaxTessellationFactor(NS::UInteger maxTessellationFactor); + + bool tessellationFactorScaleEnabled() const; + void setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled); + + MTL::TessellationFactorFormat tessellationFactorFormat() const; + void setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat); + + MTL::TessellationControlPointIndexType tessellationControlPointIndexType() const; + void setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType); + + MTL::TessellationFactorStepFunction tessellationFactorStepFunction() const; + void setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction); + + MTL::Winding tessellationOutputWindingOrder() const; + void setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder); + + class PipelineBufferDescriptorArray* vertexBuffers() const; + + class PipelineBufferDescriptorArray* fragmentBuffers() const; + + bool supportIndirectCommandBuffers() const; + void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + NS::Array* vertexPreloadedLibraries() const; + void setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries); + + NS::Array* fragmentPreloadedLibraries() const; + void setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries); + + class LinkedFunctions* vertexLinkedFunctions() const; + void setVertexLinkedFunctions(const class LinkedFunctions* vertexLinkedFunctions); + + class LinkedFunctions* fragmentLinkedFunctions() const; + void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions); + + bool supportAddingVertexBinaryFunctions() const; + void setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions); + + bool supportAddingFragmentBinaryFunctions() const; + void setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions); + + NS::UInteger maxVertexCallStackDepth() const; + void setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth); + + NS::UInteger maxFragmentCallStackDepth() const; + void setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth); + + void reset(); + + MTL::ShaderValidation shaderValidation() const; + void setShaderValidation(MTL::ShaderValidation shaderValidation); +}; + +class RenderPipelineFunctionsDescriptor : public NS::Copying +{ +public: + static class RenderPipelineFunctionsDescriptor* alloc(); + + class RenderPipelineFunctionsDescriptor* init(); + + NS::Array* vertexAdditionalBinaryFunctions() const; + void setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions); + + NS::Array* fragmentAdditionalBinaryFunctions() const; + void setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions); + + NS::Array* tileAdditionalBinaryFunctions() const; + void setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions); +}; + +class RenderPipelineState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + + bool threadgroupSizeMatchesTileSize() const; + + NS::UInteger imageblockSampleLength() const; + + NS::UInteger imageblockMemoryLength(MTL::Size imageblockDimensions); + + bool supportIndirectCommandBuffers() const; + + NS::UInteger maxTotalThreadsPerObjectThreadgroup() const; + + NS::UInteger maxTotalThreadsPerMeshThreadgroup() const; + + NS::UInteger objectThreadExecutionWidth() const; + + NS::UInteger meshThreadExecutionWidth() const; + + NS::UInteger maxTotalThreadgroupsPerMeshGrid() const; + + MTL::ResourceID gpuResourceID() const; + + class FunctionHandle* functionHandle(const class Function* function, MTL::RenderStages stage); + + class VisibleFunctionTable* newVisibleFunctionTable(const class VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage); + + class IntersectionFunctionTable* newIntersectionFunctionTable(const class IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error); + + MTL::ShaderValidation shaderValidation() const; +}; + +class RenderPipelineColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPipelineColorAttachmentDescriptorArray* alloc(); + + class RenderPipelineColorAttachmentDescriptorArray* init(); + + class RenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class TileRenderPipelineColorAttachmentDescriptor : public NS::Copying +{ +public: + static class TileRenderPipelineColorAttachmentDescriptor* alloc(); + + class TileRenderPipelineColorAttachmentDescriptor* init(); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); +}; + +class TileRenderPipelineColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class TileRenderPipelineColorAttachmentDescriptorArray* alloc(); + + class TileRenderPipelineColorAttachmentDescriptorArray* init(); + + class TileRenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class TileRenderPipelineDescriptor : public NS::Copying +{ +public: + static class TileRenderPipelineDescriptor* alloc(); + + class TileRenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* tileFunction() const; + void setTileFunction(const class Function* tileFunction); + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + class TileRenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + bool threadgroupSizeMatchesTileSize() const; + void setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize); + + class PipelineBufferDescriptorArray* tileBuffers() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + NS::Array* preloadedLibraries() const; + void setPreloadedLibraries(const NS::Array* preloadedLibraries); + + class LinkedFunctions* linkedFunctions() const; + void setLinkedFunctions(const class LinkedFunctions* linkedFunctions); + + bool supportAddingBinaryFunctions() const; + void setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions); + + NS::UInteger maxCallStackDepth() const; + void setMaxCallStackDepth(NS::UInteger maxCallStackDepth); + + void reset(); + + MTL::ShaderValidation shaderValidation() const; + void setShaderValidation(MTL::ShaderValidation shaderValidation); +}; + +class MeshRenderPipelineDescriptor : public NS::Copying +{ +public: + static class MeshRenderPipelineDescriptor* alloc(); + + class MeshRenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* objectFunction() const; + void setObjectFunction(const class Function* objectFunction); + + class Function* meshFunction() const; + void setMeshFunction(const class Function* meshFunction); + + class Function* fragmentFunction() const; + void setFragmentFunction(const class Function* fragmentFunction); + + NS::UInteger maxTotalThreadsPerObjectThreadgroup() const; + void setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup); + + NS::UInteger maxTotalThreadsPerMeshThreadgroup() const; + void setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup); + + bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const; + void setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth); + + bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const; + void setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth); + + NS::UInteger payloadMemoryLength() const; + void setPayloadMemoryLength(NS::UInteger payloadMemoryLength); + + NS::UInteger maxTotalThreadgroupsPerMeshGrid() const; + void setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid); + + class PipelineBufferDescriptorArray* objectBuffers() const; + + class PipelineBufferDescriptorArray* meshBuffers() const; + + class PipelineBufferDescriptorArray* fragmentBuffers() const; + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + bool alphaToCoverageEnabled() const; + void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled); + + bool alphaToOneEnabled() const; + void setAlphaToOneEnabled(bool alphaToOneEnabled); + + bool rasterizationEnabled() const; + void setRasterizationEnabled(bool rasterizationEnabled); + + NS::UInteger maxVertexAmplificationCount() const; + void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount); + + class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + MTL::PixelFormat depthAttachmentPixelFormat() const; + void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat); + + MTL::PixelFormat stencilAttachmentPixelFormat() const; + void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat); + + bool supportIndirectCommandBuffers() const; + void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + class LinkedFunctions* objectLinkedFunctions() const; + void setObjectLinkedFunctions(const class LinkedFunctions* objectLinkedFunctions); + + class LinkedFunctions* meshLinkedFunctions() const; + void setMeshLinkedFunctions(const class LinkedFunctions* meshLinkedFunctions); + + class LinkedFunctions* fragmentLinkedFunctions() const; + void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions); + + void reset(); + + MTL::ShaderValidation shaderValidation() const; + void setShaderValidation(MTL::ShaderValidation shaderValidation); +}; + +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptor)); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineColorAttachmentDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +_MTL_INLINE bool MTL::RenderPipelineColorAttachmentDescriptor::blendingEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isBlendingEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setBlendingEnabled(bool blendingEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBlendingEnabled_), blendingEnabled); +} + +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceRGBBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sourceRGBBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSourceRGBBlendFactor_), sourceRGBBlendFactor); +} + +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationRGBBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destinationRGBBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestinationRGBBlendFactor_), destinationRGBBlendFactor); +} + +_MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::rgbBlendOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rgbBlendOperation)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRgbBlendOperation_), rgbBlendOperation); +} + +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceAlphaBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sourceAlphaBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSourceAlphaBlendFactor_), sourceAlphaBlendFactor); +} + +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationAlphaBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destinationAlphaBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestinationAlphaBlendFactor_), destinationAlphaBlendFactor); +} + +_MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::alphaBlendOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alphaBlendOperation)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaBlendOperation_), alphaBlendOperation); +} + +_MTL_INLINE MTL::ColorWriteMask MTL::RenderPipelineColorAttachmentDescriptor::writeMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(writeMask)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setWriteMask(MTL::ColorWriteMask writeMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWriteMask_), writeMask); +} + +_MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineReflection)); +} + +_MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBindings)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBindings)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileBindings)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::objectBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectBindings)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::meshBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshBindings)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexArguments)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentArguments)); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileArguments)); +} + +_MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineDescriptor)); +} + +_MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::RenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::vertexFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexFunction(const MTL::Function* vertexFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFunction_), vertexFunction); +} + +_MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::fragmentFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction); +} + +_MTL_INLINE MTL::VertexDescriptor* MTL::RenderPipelineDescriptor::vertexDescriptor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexDescriptor)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexDescriptor(const MTL::VertexDescriptor* vertexDescriptor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexDescriptor_), vertexDescriptor); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToCoverageEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToOneEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::rasterizationEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRasterizationEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexAmplificationCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::depthAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat); +} + +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::stencilAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat); +} + +_MTL_INLINE MTL::PrimitiveTopologyClass MTL::RenderPipelineDescriptor::inputPrimitiveTopology() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inputPrimitiveTopology)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInputPrimitiveTopology_), inputPrimitiveTopology); +} + +_MTL_INLINE MTL::TessellationPartitionMode MTL::RenderPipelineDescriptor::tessellationPartitionMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationPartitionMode)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationPartitionMode_), tessellationPartitionMode); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxTessellationFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTessellationFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxTessellationFactor(NS::UInteger maxTessellationFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTessellationFactor_), maxTessellationFactor); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::tessellationFactorScaleEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isTessellationFactorScaleEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorScaleEnabled_), tessellationFactorScaleEnabled); +} + +_MTL_INLINE MTL::TessellationFactorFormat MTL::RenderPipelineDescriptor::tessellationFactorFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationFactorFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorFormat_), tessellationFactorFormat); +} + +_MTL_INLINE MTL::TessellationControlPointIndexType MTL::RenderPipelineDescriptor::tessellationControlPointIndexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationControlPointIndexType)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationControlPointIndexType_), tessellationControlPointIndexType); +} + +_MTL_INLINE MTL::TessellationFactorStepFunction MTL::RenderPipelineDescriptor::tessellationFactorStepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationFactorStepFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorStepFunction_), tessellationFactorStepFunction); +} + +_MTL_INLINE MTL::Winding MTL::RenderPipelineDescriptor::tessellationOutputWindingOrder() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationOutputWindingOrder)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationOutputWindingOrder_), tessellationOutputWindingOrder); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::vertexBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffers)); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::fragmentBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBuffers)); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::vertexPreloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexPreloadedLibraries)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexPreloadedLibraries_), vertexPreloadedLibraries); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::fragmentPreloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentPreloadedLibraries)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentPreloadedLibraries_), fragmentPreloadedLibraries); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::vertexLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexLinkedFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexLinkedFunctions(const MTL::LinkedFunctions* vertexLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexLinkedFunctions_), vertexLinkedFunctions); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::fragmentLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingVertexBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingVertexBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingVertexBinaryFunctions_), supportAddingVertexBinaryFunctions); +} + +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingFragmentBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingFragmentBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingFragmentBinaryFunctions_), supportAddingFragmentBinaryFunctions); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexCallStackDepth)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexCallStackDepth_), maxVertexCallStackDepth); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxFragmentCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxFragmentCallStackDepth)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxFragmentCallStackDepth_), maxFragmentCallStackDepth); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE MTL::ShaderValidation MTL::RenderPipelineDescriptor::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setShaderValidation(MTL::ShaderValidation shaderValidation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShaderValidation_), shaderValidation); +} + +_MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineFunctionsDescriptor)); +} + +_MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::vertexAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAdditionalBinaryFunctions_), vertexAdditionalBinaryFunctions); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::fragmentAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentAdditionalBinaryFunctions_), fragmentAdditionalBinaryFunctions); +} + +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::tileAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileAdditionalBinaryFunctions_), tileAdditionalBinaryFunctions); +} + +_MTL_INLINE NS::String* MTL::RenderPipelineState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::Device* MTL::RenderPipelineState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE bool MTL::RenderPipelineState::threadgroupSizeMatchesTileSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockSampleLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockSampleLength)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockMemoryLength(MTL::Size imageblockDimensions) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockMemoryLengthForDimensions_), imageblockDimensions); +} + +_MTL_INLINE bool MTL::RenderPipelineState::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerObjectThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerMeshThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::objectThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectThreadExecutionWidth)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::meshThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshThreadExecutionWidth)); +} + +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadgroupsPerMeshGrid() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid)); +} + +_MTL_INLINE MTL::ResourceID MTL::RenderPipelineState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE MTL::FunctionHandle* MTL::RenderPipelineState::functionHandle(const MTL::Function* function, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionHandleWithFunction_stage_), function, stage); +} + +_MTL_INLINE MTL::VisibleFunctionTable* MTL::RenderPipelineState::newVisibleFunctionTable(const MTL::VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newVisibleFunctionTableWithDescriptor_stage_), descriptor, stage); +} + +_MTL_INLINE MTL::IntersectionFunctionTable* MTL::RenderPipelineState::newIntersectionFunctionTable(const MTL::IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionTableWithDescriptor_stage_), descriptor, stage); +} + +_MTL_INLINE MTL::RenderPipelineState* MTL::RenderPipelineState::newRenderPipelineState(const MTL::RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithAdditionalBinaryFunctions_error_), additionalBinaryFunctions, error); +} + +_MTL_INLINE MTL::ShaderValidation MTL::RenderPipelineState::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptor)); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::PixelFormat MTL::TileRenderPipelineColorAttachmentDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineDescriptor)); +} + +_MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::TileRenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Function* MTL::TileRenderPipelineDescriptor::tileFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileFunction)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setTileFunction(const MTL::Function* tileFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileFunction_), tileFunction); +} + +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +_MTL_INLINE bool MTL::TileRenderPipelineDescriptor::threadgroupSizeMatchesTileSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupSizeMatchesTileSize_), threadgroupSizeMatchesTileSize); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::TileRenderPipelineDescriptor::tileBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileBuffers)); +} + +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +_MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::preloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preloadedLibraries)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setPreloadedLibraries(const NS::Array* preloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreloadedLibraries_), preloadedLibraries); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::TileRenderPipelineDescriptor::linkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(linkedFunctions)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLinkedFunctions(const MTL::LinkedFunctions* linkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLinkedFunctions_), linkedFunctions); +} + +_MTL_INLINE bool MTL::TileRenderPipelineDescriptor::supportAddingBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingBinaryFunctions)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingBinaryFunctions_), supportAddingBinaryFunctions); +} + +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCallStackDepth)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxCallStackDepth(NS::UInteger maxCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCallStackDepth_), maxCallStackDepth); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE MTL::ShaderValidation MTL::TileRenderPipelineDescriptor::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setShaderValidation(MTL::ShaderValidation shaderValidation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShaderValidation_), shaderValidation); +} + +_MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLMeshRenderPipelineDescriptor)); +} + +_MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::MeshRenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::objectFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectFunction(const MTL::Function* objectFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectFunction_), objectFunction); +} + +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::meshFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshFunction(const MTL::Function* meshFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshFunction_), meshFunction); +} + +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::fragmentFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerObjectThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerObjectThreadgroup_), maxTotalThreadsPerObjectThreadgroup); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerMeshThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerMeshThreadgroup_), maxTotalThreadsPerMeshThreadgroup); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectThreadgroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth_), objectThreadgroupSizeIsMultipleOfThreadExecutionWidth); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshThreadgroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth_), meshThreadgroupSizeIsMultipleOfThreadExecutionWidth); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::payloadMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(payloadMemoryLength)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setPayloadMemoryLength(NS::UInteger payloadMemoryLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPayloadMemoryLength_), payloadMemoryLength); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadgroupsPerMeshGrid() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadgroupsPerMeshGrid_), maxTotalThreadgroupsPerMeshGrid); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::objectBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectBuffers)); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::meshBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshBuffers)); +} + +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::fragmentBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBuffers)); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToCoverageEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToOneEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::rasterizationEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRasterizationEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled); +} + +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxVertexAmplificationCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount); +} + +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::MeshRenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +_MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::depthAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat); +} + +_MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::stencilAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat); +} + +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers); +} + +_MTL_INLINE NS::Array* MTL::MeshRenderPipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::objectLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectLinkedFunctions)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectLinkedFunctions(const MTL::LinkedFunctions* objectLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectLinkedFunctions_), objectLinkedFunctions); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::meshLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshLinkedFunctions)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshLinkedFunctions(const MTL::LinkedFunctions* meshLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshLinkedFunctions_), meshLinkedFunctions); +} + +_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::fragmentLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +_MTL_INLINE MTL::ShaderValidation MTL::MeshRenderPipelineDescriptor::shaderValidation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shaderValidation)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setShaderValidation(MTL::ShaderValidation shaderValidation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShaderValidation_), shaderValidation); +} + +#pragma once + +namespace MTL +{ +class ResidencySetDescriptor : public NS::Copying +{ +public: + static class ResidencySetDescriptor* alloc(); + + class ResidencySetDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + NS::UInteger initialCapacity() const; + void setInitialCapacity(NS::UInteger initialCapacity); +}; + +class ResidencySet : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + + uint64_t allocatedSize() const; + + void requestResidency(); + + void endResidency(); + + void addAllocation(const class Allocation* allocation); + + void addAllocations(const class Allocation* const allocations[], NS::UInteger count); + + void removeAllocation(const class Allocation* allocation); + + void removeAllocations(const class Allocation* const allocations[], NS::UInteger count); + + void removeAllAllocations(); + + bool containsAllocation(const class Allocation* anAllocation); + + NS::Array* allAllocations() const; + + NS::UInteger allocationCount() const; + + void commit(); +}; + +} + +_MTL_INLINE MTL::ResidencySetDescriptor* MTL::ResidencySetDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResidencySetDescriptor)); +} + +_MTL_INLINE MTL::ResidencySetDescriptor* MTL::ResidencySetDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::String* MTL::ResidencySetDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::ResidencySetDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE NS::UInteger MTL::ResidencySetDescriptor::initialCapacity() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initialCapacity)); +} + +_MTL_INLINE void MTL::ResidencySetDescriptor::setInitialCapacity(NS::UInteger initialCapacity) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInitialCapacity_), initialCapacity); +} + +_MTL_INLINE MTL::Device* MTL::ResidencySet::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE NS::String* MTL::ResidencySet::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE uint64_t MTL::ResidencySet::allocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allocatedSize)); +} + +_MTL_INLINE void MTL::ResidencySet::requestResidency() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(requestResidency)); +} + +_MTL_INLINE void MTL::ResidencySet::endResidency() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(endResidency)); +} + +_MTL_INLINE void MTL::ResidencySet::addAllocation(const MTL::Allocation* allocation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addAllocation_), allocation); +} + +_MTL_INLINE void MTL::ResidencySet::addAllocations(const MTL::Allocation* const allocations[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addAllocations_count_), allocations, count); +} + +_MTL_INLINE void MTL::ResidencySet::removeAllocation(const MTL::Allocation* allocation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeAllocation_), allocation); +} + +_MTL_INLINE void MTL::ResidencySet::removeAllocations(const MTL::Allocation* const allocations[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeAllocations_count_), allocations, count); +} + +_MTL_INLINE void MTL::ResidencySet::removeAllAllocations() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeAllAllocations)); +} + +_MTL_INLINE bool MTL::ResidencySet::containsAllocation(const MTL::Allocation* anAllocation) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(containsAllocation_), anAllocation); +} + +_MTL_INLINE NS::Array* MTL::ResidencySet::allAllocations() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allAllocations)); +} + +_MTL_INLINE NS::UInteger MTL::ResidencySet::allocationCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allocationCount)); +} + +_MTL_INLINE void MTL::ResidencySet::commit() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(commit)); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, SparseTextureMappingMode) { + SparseTextureMappingModeMap = 0, + SparseTextureMappingModeUnmap = 1, +}; + +struct MapIndirectArguments +{ + uint32_t regionOriginX; + uint32_t regionOriginY; + uint32_t regionOriginZ; + uint32_t regionSizeWidth; + uint32_t regionSizeHeight; + uint32_t regionSizeDepth; + uint32_t mipMapLevel; + uint32_t sliceId; +} _MTL_PACKED; + +class ResourceStateCommandEncoder : public NS::Referencing +{ +public: + void updateTextureMappings(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions); + + void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice); + + void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void moveTextureMappingsFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); +}; + +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMappings(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_), texture, mode, regions, mipLevels, slices, numRegions); +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_region_mipLevel_slice_), texture, mode, region, mipLevel, slice); +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_), texture, mode, indirectBuffer, indirectBufferOffset); +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +_MTL_INLINE void MTL::ResourceStateCommandEncoder::moveTextureMappingsFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} + +#pragma once + +namespace MTL +{ +class ResourceStatePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class ResourceStatePassSampleBufferAttachmentDescriptor* alloc(); + + class ResourceStatePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class ResourceStatePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class ResourceStatePassSampleBufferAttachmentDescriptorArray* alloc(); + + class ResourceStatePassSampleBufferAttachmentDescriptorArray* init(); + + class ResourceStatePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class ResourceStatePassDescriptor : public NS::Copying +{ +public: + static class ResourceStatePassDescriptor* alloc(); + + class ResourceStatePassDescriptor* init(); + + static class ResourceStatePassDescriptor* resourceStatePassDescriptor(); + + class ResourceStatePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptor)); +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::CounterSampleBuffer* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +_MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +_MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptorArray)); +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor)); +} + +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::resourceStatePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor), _MTL_PRIVATE_SEL(resourceStatePassDescriptor)); +} + +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} + +#pragma once + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, SamplerMinMagFilter) { + SamplerMinMagFilterNearest = 0, + SamplerMinMagFilterLinear = 1, +}; + +_MTL_ENUM(NS::UInteger, SamplerMipFilter) { + SamplerMipFilterNotMipmapped = 0, + SamplerMipFilterNearest = 1, + SamplerMipFilterLinear = 2, +}; + +_MTL_ENUM(NS::UInteger, SamplerAddressMode) { + SamplerAddressModeClampToEdge = 0, + SamplerAddressModeMirrorClampToEdge = 1, + SamplerAddressModeRepeat = 2, + SamplerAddressModeMirrorRepeat = 3, + SamplerAddressModeClampToZero = 4, + SamplerAddressModeClampToBorderColor = 5, +}; + +_MTL_ENUM(NS::UInteger, SamplerBorderColor) { + SamplerBorderColorTransparentBlack = 0, + SamplerBorderColorOpaqueBlack = 1, + SamplerBorderColorOpaqueWhite = 2, +}; + +class SamplerDescriptor : public NS::Copying +{ +public: + static class SamplerDescriptor* alloc(); + + class SamplerDescriptor* init(); + + MTL::SamplerMinMagFilter minFilter() const; + void setMinFilter(MTL::SamplerMinMagFilter minFilter); + + MTL::SamplerMinMagFilter magFilter() const; + void setMagFilter(MTL::SamplerMinMagFilter magFilter); + + MTL::SamplerMipFilter mipFilter() const; + void setMipFilter(MTL::SamplerMipFilter mipFilter); + + NS::UInteger maxAnisotropy() const; + void setMaxAnisotropy(NS::UInteger maxAnisotropy); + + MTL::SamplerAddressMode sAddressMode() const; + void setSAddressMode(MTL::SamplerAddressMode sAddressMode); + + MTL::SamplerAddressMode tAddressMode() const; + void setTAddressMode(MTL::SamplerAddressMode tAddressMode); + + MTL::SamplerAddressMode rAddressMode() const; + void setRAddressMode(MTL::SamplerAddressMode rAddressMode); + + MTL::SamplerBorderColor borderColor() const; + void setBorderColor(MTL::SamplerBorderColor borderColor); + + bool normalizedCoordinates() const; + void setNormalizedCoordinates(bool normalizedCoordinates); + + float lodMinClamp() const; + void setLodMinClamp(float lodMinClamp); + + float lodMaxClamp() const; + void setLodMaxClamp(float lodMaxClamp); + + bool lodAverage() const; + void setLodAverage(bool lodAverage); + + MTL::CompareFunction compareFunction() const; + void setCompareFunction(MTL::CompareFunction compareFunction); + + bool supportArgumentBuffers() const; + void setSupportArgumentBuffers(bool supportArgumentBuffers); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class SamplerState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + MTL::ResourceID gpuResourceID() const; +}; + +} + +_MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSamplerDescriptor)); +} + +_MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::minFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMinFilter(MTL::SamplerMinMagFilter minFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMinFilter_), minFilter); +} + +_MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::magFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(magFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMagFilter(MTL::SamplerMinMagFilter magFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMagFilter_), magFilter); +} + +_MTL_INLINE MTL::SamplerMipFilter MTL::SamplerDescriptor::mipFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMipFilter(MTL::SamplerMipFilter mipFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMipFilter_), mipFilter); +} + +_MTL_INLINE NS::UInteger MTL::SamplerDescriptor::maxAnisotropy() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxAnisotropy)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMaxAnisotropy(NS::UInteger maxAnisotropy) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxAnisotropy_), maxAnisotropy); +} + +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::sAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setSAddressMode(MTL::SamplerAddressMode sAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSAddressMode_), sAddressMode); +} + +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::tAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setTAddressMode(MTL::SamplerAddressMode tAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTAddressMode_), tAddressMode); +} + +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::rAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setRAddressMode(MTL::SamplerAddressMode rAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRAddressMode_), rAddressMode); +} + +_MTL_INLINE MTL::SamplerBorderColor MTL::SamplerDescriptor::borderColor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(borderColor)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setBorderColor(MTL::SamplerBorderColor borderColor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBorderColor_), borderColor); +} + +_MTL_INLINE bool MTL::SamplerDescriptor::normalizedCoordinates() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(normalizedCoordinates)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setNormalizedCoordinates(bool normalizedCoordinates) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setNormalizedCoordinates_), normalizedCoordinates); +} + +_MTL_INLINE float MTL::SamplerDescriptor::lodMinClamp() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodMinClamp)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodMinClamp(float lodMinClamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodMinClamp_), lodMinClamp); +} + +_MTL_INLINE float MTL::SamplerDescriptor::lodMaxClamp() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodMaxClamp)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodMaxClamp(float lodMaxClamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodMaxClamp_), lodMaxClamp); +} + +_MTL_INLINE bool MTL::SamplerDescriptor::lodAverage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodAverage)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodAverage(bool lodAverage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodAverage_), lodAverage); +} + +_MTL_INLINE MTL::CompareFunction MTL::SamplerDescriptor::compareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compareFunction)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setCompareFunction(MTL::CompareFunction compareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompareFunction_), compareFunction); +} + +_MTL_INLINE bool MTL::SamplerDescriptor::supportArgumentBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportArgumentBuffers)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setSupportArgumentBuffers(bool supportArgumentBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportArgumentBuffers_), supportArgumentBuffers); +} + +_MTL_INLINE NS::String* MTL::SamplerDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +_MTL_INLINE NS::String* MTL::SamplerState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE MTL::Device* MTL::SamplerState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +_MTL_INLINE MTL::ResourceID MTL::SamplerState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +#pragma once + +namespace MTL +{ + +static const NS::UInteger BufferLayoutStrideDynamic = NS::UIntegerMax; + +_MTL_ENUM(NS::UInteger, VertexFormat) { + VertexFormatInvalid = 0, + VertexFormatUChar2 = 1, + VertexFormatUChar3 = 2, + VertexFormatUChar4 = 3, + VertexFormatChar2 = 4, + VertexFormatChar3 = 5, + VertexFormatChar4 = 6, + VertexFormatUChar2Normalized = 7, + VertexFormatUChar3Normalized = 8, + VertexFormatUChar4Normalized = 9, + VertexFormatChar2Normalized = 10, + VertexFormatChar3Normalized = 11, + VertexFormatChar4Normalized = 12, + VertexFormatUShort2 = 13, + VertexFormatUShort3 = 14, + VertexFormatUShort4 = 15, + VertexFormatShort2 = 16, + VertexFormatShort3 = 17, + VertexFormatShort4 = 18, + VertexFormatUShort2Normalized = 19, + VertexFormatUShort3Normalized = 20, + VertexFormatUShort4Normalized = 21, + VertexFormatShort2Normalized = 22, + VertexFormatShort3Normalized = 23, + VertexFormatShort4Normalized = 24, + VertexFormatHalf2 = 25, + VertexFormatHalf3 = 26, + VertexFormatHalf4 = 27, + VertexFormatFloat = 28, + VertexFormatFloat2 = 29, + VertexFormatFloat3 = 30, + VertexFormatFloat4 = 31, + VertexFormatInt = 32, + VertexFormatInt2 = 33, + VertexFormatInt3 = 34, + VertexFormatInt4 = 35, + VertexFormatUInt = 36, + VertexFormatUInt2 = 37, + VertexFormatUInt3 = 38, + VertexFormatUInt4 = 39, + VertexFormatInt1010102Normalized = 40, + VertexFormatUInt1010102Normalized = 41, + VertexFormatUChar4Normalized_BGRA = 42, + VertexFormatUChar = 45, + VertexFormatChar = 46, + VertexFormatUCharNormalized = 47, + VertexFormatCharNormalized = 48, + VertexFormatUShort = 49, + VertexFormatShort = 50, + VertexFormatUShortNormalized = 51, + VertexFormatShortNormalized = 52, + VertexFormatHalf = 53, + VertexFormatFloatRG11B10 = 54, + VertexFormatFloatRGB9E5 = 55, +}; + +_MTL_ENUM(NS::UInteger, VertexStepFunction) { + VertexStepFunctionConstant = 0, + VertexStepFunctionPerVertex = 1, + VertexStepFunctionPerInstance = 2, + VertexStepFunctionPerPatch = 3, + VertexStepFunctionPerPatchControlPoint = 4, +}; + +class VertexBufferLayoutDescriptor : public NS::Copying +{ +public: + static class VertexBufferLayoutDescriptor* alloc(); + + class VertexBufferLayoutDescriptor* init(); + + NS::UInteger stride() const; + void setStride(NS::UInteger stride); + + MTL::VertexStepFunction stepFunction() const; + void setStepFunction(MTL::VertexStepFunction stepFunction); + + NS::UInteger stepRate() const; + void setStepRate(NS::UInteger stepRate); +}; + +class VertexBufferLayoutDescriptorArray : public NS::Referencing +{ +public: + static class VertexBufferLayoutDescriptorArray* alloc(); + + class VertexBufferLayoutDescriptorArray* init(); + + class VertexBufferLayoutDescriptor* object(NS::UInteger index); + + void setObject(const class VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index); +}; + +class VertexAttributeDescriptor : public NS::Copying +{ +public: + static class VertexAttributeDescriptor* alloc(); + + class VertexAttributeDescriptor* init(); + + MTL::VertexFormat format() const; + void setFormat(MTL::VertexFormat format); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + NS::UInteger bufferIndex() const; + void setBufferIndex(NS::UInteger bufferIndex); +}; + +class VertexAttributeDescriptorArray : public NS::Referencing +{ +public: + static class VertexAttributeDescriptorArray* alloc(); + + class VertexAttributeDescriptorArray* init(); + + class VertexAttributeDescriptor* object(NS::UInteger index); + + void setObject(const class VertexAttributeDescriptor* attributeDesc, NS::UInteger index); +}; + +class VertexDescriptor : public NS::Copying +{ +public: + static class VertexDescriptor* alloc(); + + class VertexDescriptor* init(); + + static class VertexDescriptor* vertexDescriptor(); + + class VertexBufferLayoutDescriptorArray* layouts() const; + + class VertexAttributeDescriptorArray* attributes() const; + + void reset(); +}; + +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptor)); +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStride(NS::UInteger stride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStride_), stride); +} + +_MTL_INLINE MTL::VertexStepFunction MTL::VertexBufferLayoutDescriptor::stepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepFunction)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepFunction(MTL::VertexStepFunction stepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction); +} + +_MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stepRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepRate)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepRate(NS::UInteger stepRate) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate); +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptorArray)); +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptorArray::setObject(const MTL::VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index); +} + +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptor)); +} + +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::VertexFormat MTL::VertexAttributeDescriptor::format() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(format)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setFormat(MTL::VertexFormat format) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFormat_), format); +} + +_MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +_MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::bufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferIndex)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex); +} + +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptorArray)); +} + +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptorArray::setObject(const MTL::VertexAttributeDescriptor* attributeDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index); +} + +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexDescriptor)); +} + +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::vertexDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLVertexDescriptor), _MTL_PRIVATE_SEL(vertexDescriptor)); +} + +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexDescriptor::layouts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layouts)); +} + +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexDescriptor::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +_MTL_INLINE void MTL::VertexDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +#pragma once + +namespace MTL +{ +class VisibleFunctionTableDescriptor : public NS::Copying +{ +public: + static class VisibleFunctionTableDescriptor* alloc(); + + class VisibleFunctionTableDescriptor* init(); + + static class VisibleFunctionTableDescriptor* visibleFunctionTableDescriptor(); + + NS::UInteger functionCount() const; + void setFunctionCount(NS::UInteger functionCount); +}; + +class VisibleFunctionTable : public NS::Referencing +{ +public: + MTL::ResourceID gpuResourceID() const; + + void setFunction(const class FunctionHandle* function, NS::UInteger index); + + void setFunctions(const class FunctionHandle* const functions[], NS::Range range); +}; + +} + +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor)); +} + +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::init() +{ + return NS::Object::init(); +} + +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::visibleFunctionTableDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor), _MTL_PRIVATE_SEL(visibleFunctionTableDescriptor)); +} + +_MTL_INLINE NS::UInteger MTL::VisibleFunctionTableDescriptor::functionCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionCount)); +} + +_MTL_INLINE void MTL::VisibleFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount); +} + +_MTL_INLINE MTL::ResourceID MTL::VisibleFunctionTable::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +_MTL_INLINE void MTL::VisibleFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index); +} + +_MTL_INLINE void MTL::VisibleFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range); +} + +#define METALCPP_VERSION_MAJOR 366 +#define METALCPP_VERSION_MINOR 11 +#define METALCPP_VERSION_PATCH 0 + +#define METALCPP_SUPPORTS_VERSION(major, minor, patch) \ + ((major < METALCPP_VERSION_MAJOR) || \ + (major == METALCPP_VERSION_MAJOR && minor < METALCPP_VERSION_MINOR) || \ + (major == METALCPP_VERSION_MAJOR && minor == METALCPP_VERSION_MINOR && patch <= METALCPP_VERSION_PATCH)) + +#define _MTLFX_EXPORT _NS_EXPORT +#define _MTLFX_EXTERN _NS_EXTERN +#define _MTLFX_INLINE _NS_INLINE +#define _MTLFX_PACKED _NS_PACKED + +#define _MTLFX_CONST( type, name ) _NS_CONST( type, name ) +#define _MTLFX_ENUM( type, name ) _NS_ENUM( type, name ) +#define _MTLFX_OPTIONS( type, name ) _NS_OPTIONS( type, name ) + +#define _MTLFX_VALIDATE_SIZE( mtlfx, name ) _NS_VALIDATE_SIZE( mtlfx, name ) +#define _MTLFX_VALIDATE_ENUM( mtlfx, name ) _NS_VALIDATE_ENUM( mtlfx, name ) + +#include + +#define _MTLFX_PRIVATE_CLS( symbol ) ( Private::Class::s_k##symbol ) +#define _MTLFX_PRIVATE_SEL( accessor ) ( Private::Selector::s_k##accessor ) + +#if defined( MTLFX_PRIVATE_IMPLEMENTATION ) + +#if defined( METALCPP_SYMBOL_VISIBILITY_HIDDEN ) +#define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("hidden" ) ) ) +#else +#define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("default" ) ) ) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _MTLFX_PRIVATE_IMPORT __attribute__( ( weak_import ) ) + +#ifdef __OBJC__ +#define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) ( ( __bridge void* ) objc_lookUpClass( #symbol ) ) +#define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) ( ( __bridge void* ) objc_getProtocol( #symbol ) ) +#else +#define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) objc_lookUpClass(#symbol) +#define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _MTLFX_PRIVATE_DEF_CLS( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) +#define _MTLFX_PRIVATE_DEF_PRO( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) +#define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) SEL s_k##accessor _MTLFX_PRIVATE_VISIBILITY = sel_registerName( symbol ) + +#include +#define MTLFX_DEF_FUNC( name, signature ) using Fn##name = signature; \ + Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) ) + +namespace MTLFX::Private +{ + template + + inline _Type const LoadSymbol(const char* pSymbol) + { + const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); + + return pAddress ? *pAddress : nullptr; + } +} // MTLFX::Private + +#if defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) + +#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \ + _MTLFX_EXTERN type const MTLFX##symbol _MTLFX_PRIVATE_IMPORT; \ + type const MTLFX::symbol = ( nullptr != &MTLFX##symbol ) ? MTLFX##ssymbol : nullptr + +#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \ + _MTLFX_EXTERN type const MTLFX##ssymbol _MTLFX_PRIVATE_IMPORT; \ + type const MTLFX::symbol = (nullptr != &MTLFX##ssymbol) ? MTLFX##ssymbol : nullptr + +#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) \ + _MTLFX_EXTERN type const MTLFX##ssymbol; \ + type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) + +#else + +#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \ + _MTLFX_EXTERN type const MTLFX##ssymbol; \ + type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) + +#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \ + _MTLFX_EXTERN type const MTLFX##ssymbol; \ + type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) + +#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) _MTLFX_PRIVATE_DEF_CONST( type, symbol ) + +#endif // defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) + +#else + +#define _MTLFX_PRIVATE_DEF_CLS( symbol ) extern void* s_k##symbol +#define _MTLFX_PRIVATE_DEF_PRO( symbol ) extern void* s_k##symbol +#define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) extern SEL s_k##accessor +#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) extern type const MTLFX::symbol +#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) extern type const MTLFX::symbol +#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) extern type const MTLFX::symbol + +#endif // MTLFX_PRIVATE_IMPLEMENTATION + +namespace MTLFX +{ + namespace Private + { + namespace Class + { + _MTLFX_PRIVATE_DEF_CLS( MTLFXSpatialScalerDescriptor ); + _MTLFX_PRIVATE_DEF_CLS( MTLFXTemporalScalerDescriptor ); + } // Class + } // Private +} // MTLFX + +namespace MTLFX +{ + namespace Private + { + namespace Protocol + { + _MTLFX_PRIVATE_DEF_PRO( MTLFXSpatialScaler ); + _MTLFX_PRIVATE_DEF_PRO( MTLFXTemporalScaler ); + } // Protocol + } // Private +} // MTLFX + +namespace MTLFX +{ + namespace Private + { + namespace Selector + { + _MTLFX_PRIVATE_DEF_SEL( colorProcessingMode, + "colorProcessingMode" ); + _MTLFX_PRIVATE_DEF_SEL( colorTexture, + "colorTexture" ); + _MTLFX_PRIVATE_DEF_SEL( colorTextureFormat, + "colorTextureFormat" ); + _MTLFX_PRIVATE_DEF_SEL( colorTextureUsage, + "colorTextureUsage" ); + _MTLFX_PRIVATE_DEF_SEL( depthTexture, + "depthTexture" ); + _MTLFX_PRIVATE_DEF_SEL( depthTextureFormat, + "depthTextureFormat" ); + _MTLFX_PRIVATE_DEF_SEL( depthTextureUsage, + "depthTextureUsage" ); + _MTLFX_PRIVATE_DEF_SEL( encodeToCommandBuffer_, + "encodeToCommandBuffer:" ); + _MTLFX_PRIVATE_DEF_SEL( exposureTexture, + "exposureTexture" ); + _MTLFX_PRIVATE_DEF_SEL( fence, + "fence" ); + _MTLFX_PRIVATE_DEF_SEL( inputContentHeight, + "inputContentHeight" ); + _MTLFX_PRIVATE_DEF_SEL( inputContentMaxScale, + "inputContentMaxScale" ); + _MTLFX_PRIVATE_DEF_SEL( inputContentMinScale, + "inputContentMinScale" ); + _MTLFX_PRIVATE_DEF_SEL( inputContentWidth, + "inputContentWidth" ); + _MTLFX_PRIVATE_DEF_SEL( inputHeight, + "inputHeight" ); + _MTLFX_PRIVATE_DEF_SEL( inputWidth, + "inputWidth" ); + _MTLFX_PRIVATE_DEF_SEL( isAutoExposureEnabled, + "isAutoExposureEnabled" ); + _MTLFX_PRIVATE_DEF_SEL( isDepthReversed, + "isDepthReversed" ); + _MTLFX_PRIVATE_DEF_SEL( isInputContentPropertiesEnabled, + "isInputContentPropertiesEnabled" ); + _MTLFX_PRIVATE_DEF_SEL( isReactiveMaskTextureEnabled, + "isReactiveMaskTextureEnabled" ); + _MTLFX_PRIVATE_DEF_SEL( jitterOffsetX, + "jitterOffsetX" ); + _MTLFX_PRIVATE_DEF_SEL( jitterOffsetY, + "jitterOffsetY" ); + _MTLFX_PRIVATE_DEF_SEL( motionTexture, + "motionTexture" ); + _MTLFX_PRIVATE_DEF_SEL( motionTextureFormat, + "motionTextureFormat" ); + _MTLFX_PRIVATE_DEF_SEL( motionTextureUsage, + "motionTextureUsage" ); + _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleX, + "motionVectorScaleX" ); + _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleY, + "motionVectorScaleY" ); + _MTLFX_PRIVATE_DEF_SEL( newSpatialScalerWithDevice_, + "newSpatialScalerWithDevice:" ); + _MTLFX_PRIVATE_DEF_SEL( newTemporalScalerWithDevice_, + "newTemporalScalerWithDevice:" ); + _MTLFX_PRIVATE_DEF_SEL( outputHeight, + "outputHeight" ); + _MTLFX_PRIVATE_DEF_SEL( outputTexture, + "outputTexture" ); + _MTLFX_PRIVATE_DEF_SEL( outputTextureFormat, + "outputTextureFormat" ); + _MTLFX_PRIVATE_DEF_SEL( outputTextureUsage, + "outputTextureUsage" ); + _MTLFX_PRIVATE_DEF_SEL( outputWidth, + "outputWidth" ); + _MTLFX_PRIVATE_DEF_SEL( preExposure, + "preExposure" ); + _MTLFX_PRIVATE_DEF_SEL( reactiveMaskTextureFormat, + "reactiveMaskTextureFormat" ); + _MTLFX_PRIVATE_DEF_SEL( reactiveTextureUsage, + "reactiveTextureUsage" ); + _MTLFX_PRIVATE_DEF_SEL( reactiveMaskTexture, + "reactiveMaskTexture" ); + _MTLFX_PRIVATE_DEF_SEL( reset, + "reset" ); + _MTLFX_PRIVATE_DEF_SEL( requiresSynchronousInitialization, + "requiresSynchronousInitialization" ); + _MTLFX_PRIVATE_DEF_SEL( setAutoExposureEnabled_, + "setAutoExposureEnabled:" ); + _MTLFX_PRIVATE_DEF_SEL( setColorProcessingMode_, + "setColorProcessingMode:" ); + _MTLFX_PRIVATE_DEF_SEL( setColorTexture_, + "setColorTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setColorTextureFormat_, + "setColorTextureFormat:" ); + _MTLFX_PRIVATE_DEF_SEL( setDepthReversed_, + "setDepthReversed:" ); + _MTLFX_PRIVATE_DEF_SEL( setDepthTexture_, + "setDepthTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setDepthTextureFormat_, + "setDepthTextureFormat:" ); + _MTLFX_PRIVATE_DEF_SEL( setExposureTexture_, + "setExposureTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setFence_, + "setFence:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputContentHeight_, + "setInputContentHeight:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputContentMaxScale_, + "setInputContentMaxScale:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputContentMinScale_, + "setInputContentMinScale:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputContentPropertiesEnabled_, + "setInputContentPropertiesEnabled:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputContentWidth_, + "setInputContentWidth:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputHeight_, + "setInputHeight:" ); + _MTLFX_PRIVATE_DEF_SEL( setInputWidth_, + "setInputWidth:" ); + _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetX_, + "setJitterOffsetX:" ); + _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetY_, + "setJitterOffsetY:" ); + _MTLFX_PRIVATE_DEF_SEL( setMotionTexture_, + "setMotionTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setMotionTextureFormat_, + "setMotionTextureFormat:" ); + _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleX_, + "setMotionVectorScaleX:" ); + _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleY_, + "setMotionVectorScaleY:" ); + _MTLFX_PRIVATE_DEF_SEL( setOutputHeight_, + "setOutputHeight:" ); + _MTLFX_PRIVATE_DEF_SEL( setOutputTexture_, + "setOutputTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setOutputTextureFormat_, + "setOutputTextureFormat:" ); + _MTLFX_PRIVATE_DEF_SEL( setOutputWidth_, + "setOutputWidth:" ); + _MTLFX_PRIVATE_DEF_SEL( setPreExposure_, + "setPreExposure:" ); + _MTLFX_PRIVATE_DEF_SEL( setReactiveMaskTexture_, + "setReactiveMaskTexture:" ); + _MTLFX_PRIVATE_DEF_SEL( setReactiveMaskTextureEnabled_, + "setReactiveMaskTextureEnabled:" ); + _MTLFX_PRIVATE_DEF_SEL( setReactiveMaskTextureFormat_, + "setReactiveMaskTextureFormat:" ); + _MTLFX_PRIVATE_DEF_SEL( setRequiresSynchronousInitialization_, + "setRequiresSynchronousInitialization:" ); + _MTLFX_PRIVATE_DEF_SEL( setReset_, + "setReset:" ); + _MTLFX_PRIVATE_DEF_SEL( supportedInputContentMaxScaleForDevice_, + "supportedInputContentMaxScaleForDevice:" ); + _MTLFX_PRIVATE_DEF_SEL( supportedInputContentMinScaleForDevice_, + "supportedInputContentMinScaleForDevice:" ); + _MTLFX_PRIVATE_DEF_SEL( supportsDevice_, + "supportsDevice:" ); + } // Selector + } // Private +} // MTLFX + +namespace MTLFX +{ + _MTLFX_ENUM( NS::Integer, SpatialScalerColorProcessingMode ) + { + SpatialScalerColorProcessingModePerceptual = 0, + SpatialScalerColorProcessingModeLinear = 1, + SpatialScalerColorProcessingModeHDR = 2 + }; + + class SpatialScalerDescriptor : public NS::Copying< SpatialScalerDescriptor > + { + public: + static class SpatialScalerDescriptor* alloc(); + class SpatialScalerDescriptor* init(); + + MTL::PixelFormat colorTextureFormat() const; + void setColorTextureFormat( MTL::PixelFormat format ); + + MTL::PixelFormat outputTextureFormat() const; + void setOutputTextureFormat( MTL::PixelFormat format ); + + NS::UInteger inputWidth() const; + void setInputWidth( NS::UInteger width ); + + NS::UInteger inputHeight() const; + void setInputHeight( NS::UInteger height ); + + NS::UInteger outputWidth() const; + void setOutputWidth( NS::UInteger width ); + + NS::UInteger outputHeight() const; + void setOutputHeight( NS::UInteger height ); + + SpatialScalerColorProcessingMode colorProcessingMode() const; + void setColorProcessingMode( SpatialScalerColorProcessingMode mode ); + + class SpatialScaler* newSpatialScaler( const MTL::Device* pDevice ); + + static bool supportsDevice( const MTL::Device* ); + }; + + class SpatialScaler : public NS::Referencing< SpatialScaler > + { + public: + MTL::TextureUsage colorTextureUsage() const; + MTL::TextureUsage outputTextureUsage() const; + + NS::UInteger inputContentWidth() const; + void setInputContentWidth( NS::UInteger width ); + + NS::UInteger inputContentHeight() const; + void setInputContentHeight( NS::UInteger height ); + + MTL::Texture* colorTexture() const; + void setColorTexture( MTL::Texture* pTexture ); + + MTL::Texture* outputTexture() const; + void setOutputTexture( MTL::Texture* pTexture ); + + MTL::PixelFormat colorTextureFormat() const; + MTL::PixelFormat outputTextureFormat() const; + NS::UInteger inputWidth() const; + NS::UInteger inputHeight() const; + NS::UInteger outputWidth() const; + NS::UInteger outputHeight() const; + SpatialScalerColorProcessingMode colorProcessingMode() const; + + MTL::Fence* fence() const; + void setFence( MTL::Fence* pFence ); + + void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ); + }; +} + +_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::alloc() +{ + return NS::Object::alloc< SpatialScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ) ); +} + +_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::init() +{ + return NS::Object::init< SpatialScalerDescriptor >(); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::colorTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::outputTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height ); +} + +_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerDescriptor::colorProcessingMode() const +{ + return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorProcessingMode( SpatialScalerColorProcessingMode mode ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorProcessingMode_ ), mode ); +} + +_MTLFX_INLINE MTLFX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice ) +{ + return Object::sendMessage< SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_ ), pDevice ); +} + +_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsDevice( const MTL::Device* pDevice ) +{ + return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::colorTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::outputTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::colorTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::setColorTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::outputTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::setOutputTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::colorTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::outputTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); +} + +_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScaler::colorProcessingMode() const +{ + return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) ); +} + +_MTLFX_INLINE MTL::Fence* MTLFX::SpatialScaler::fence() const +{ + return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::setFence( MTL::Fence* pFence ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence ); +} + +_MTLFX_INLINE void MTLFX::SpatialScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer ); +} + +namespace MTLFX +{ + class TemporalScalerDescriptor : public NS::Copying< TemporalScalerDescriptor > + { + public: + static class TemporalScalerDescriptor* alloc(); + class TemporalScalerDescriptor* init(); + + MTL::PixelFormat colorTextureFormat() const; + void setColorTextureFormat( MTL::PixelFormat format ); + + MTL::PixelFormat depthTextureFormat() const; + void setDepthTextureFormat( MTL::PixelFormat format ); + + MTL::PixelFormat motionTextureFormat() const; + void setMotionTextureFormat( MTL::PixelFormat format ); + + MTL::PixelFormat outputTextureFormat() const; + void setOutputTextureFormat( MTL::PixelFormat format ); + + NS::UInteger inputWidth() const; + void setInputWidth( NS::UInteger width ); + + NS::UInteger inputHeight() const; + void setInputHeight( NS::UInteger height ); + + NS::UInteger outputWidth() const; + void setOutputWidth( NS::UInteger width ); + + NS::UInteger outputHeight() const; + void setOutputHeight( NS::UInteger height ); + + bool isAutoExposureEnabled() const; + void setAutoExposureEnabled( bool enabled ); + + bool isInputContentPropertiesEnabled() const; + void setInputContentPropertiesEnabled( bool enabled ); + + bool requiresSynchronousInitialization() const; + void setRequiresSynchronousInitialization(bool requiresSynchronousInitialization); + + bool isReactiveMaskTextureEnabled() const; + void setReactiveMaskTextureEnabled( bool enabled ); + + MTL::PixelFormat reactiveMaskTextureFormat() const; + void setReactiveMaskTextureFormat( MTL::PixelFormat pixelFormat ); + + float inputContentMinScale() const; + void setInputContentMinScale( float scale ); + + float inputContentMaxScale() const; + void setInputContentMaxScale( float scale ); + + class TemporalScaler* newTemporalScaler( const MTL::Device* pDevice ) const; + + static float supportedInputContentMinScale( const MTL::Device* pDevice ); + static float supportedInputContentMaxScale( const MTL::Device* pDevice ); + + static bool supportsDevice( const MTL::Device* pDevice ); + }; + + class TemporalScaler : public NS::Referencing< TemporalScaler > + { + public: + MTL::TextureUsage colorTextureUsage() const; + MTL::TextureUsage depthTextureUsage() const; + MTL::TextureUsage motionTextureUsage() const; + MTL::TextureUsage outputTextureUsage() const; + + NS::UInteger inputContentWidth() const; + void setInputContentWidth( NS::UInteger width ); + + NS::UInteger inputContentHeight() const; + void setInputContentHeight( NS::UInteger height ); + + MTL::Texture* colorTexture() const; + void setColorTexture( MTL::Texture* pTexture ); + + MTL::Texture* depthTexture() const; + void setDepthTexture( MTL::Texture* pTexture ); + + MTL::Texture* motionTexture() const; + void setMotionTexture( MTL::Texture* pTexture ); + + MTL::Texture* outputTexture() const; + void setOutputTexture( MTL::Texture* pTexture ); + + MTL::Texture* exposureTexture() const; + void setExposureTexture( MTL::Texture* pTexture ); + + float preExposure() const; + void setPreExposure( float preExposure ); + + float jitterOffsetX() const; + void setJitterOffsetX( float offset ); + + float jitterOffsetY() const; + void setJitterOffsetY( float offset ); + + float motionVectorScaleX() const; + void setMotionVectorScaleX( float scale ); + + float motionVectorScaleY() const; + void setMotionVectorScaleY( float scale ); + + MTL::Texture* reactiveMaskTexture() const; + void setReactiveMaskTexture( MTL::Texture* reactiveMaskTexture ); + + MTL::TextureUsage reactiveTextureUsage() const; + + bool reset() const; + void setReset( bool reset ); + + bool isDepthReversed() const; + void setDepthReversed( bool depthReversed ); + + MTL::PixelFormat colorTextureFormat() const; + MTL::PixelFormat depthTextureFormat() const; + MTL::PixelFormat motionTextureFormat() const; + MTL::PixelFormat outputTextureFormat() const; + NS::UInteger inputWidth() const; + NS::UInteger inputHeight() const; + NS::UInteger outputWidth() const; + NS::UInteger outputHeight() const; + float inputContentMinScale() const; + float inputContentMaxScale() const; + + MTL::Fence* fence() const; + void setFence( MTL::Fence* pFence ); + + void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ); + }; +} + +_MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::alloc() +{ + return NS::Object::alloc< TemporalScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ) ); +} + +_MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::init() +{ + return NS::Object::init< TemporalScalerDescriptor >(); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::colorTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::depthTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setDepthTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTextureFormat_ ), format ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::motionTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setMotionTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTextureFormat_ ), format ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::outputTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isAutoExposureEnabled() const +{ + return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isAutoExposureEnabled ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setAutoExposureEnabled( bool enabled ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setAutoExposureEnabled_ ), enabled ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isInputContentPropertiesEnabled() const +{ + return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isInputContentPropertiesEnabled ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentPropertiesEnabled( bool enabled ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentPropertiesEnabled_ ), enabled ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::requiresSynchronousInitialization() const +{ + return Object::sendMessage< bool >( this, _MTL_PRIVATE_SEL( requiresSynchronousInitialization ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setRequiresSynchronousInitialization(bool requiresSynchronousInitialization) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setRequiresSynchronousInitialization_ ), requiresSynchronousInitialization ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isReactiveMaskTextureEnabled() const +{ + return Object::sendMessage< bool >( this, _MTL_PRIVATE_SEL( isReactiveMaskTextureEnabled ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setReactiveMaskTextureEnabled( bool enabled ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReactiveMaskTextureEnabled_ ), enabled ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::reactiveMaskTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTL_PRIVATE_SEL( reactiveMaskTextureFormat ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setReactiveMaskTextureFormat( MTL::PixelFormat pixelFormat ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReactiveMaskTextureFormat_ ), pixelFormat ); +} + +_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMinScale() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMinScale( float scale ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMinScale_ ), scale ); +} + +_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMaxScale() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMaxScale( float scale ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMaxScale_ ), scale ); +} + +_MTLFX_INLINE MTLFX::TemporalScaler* MTLFX::TemporalScalerDescriptor::newTemporalScaler( const MTL::Device* pDevice ) const +{ + return Object::sendMessage< TemporalScaler* >( this, _MTLFX_PRIVATE_SEL( newTemporalScalerWithDevice_ ), pDevice ); +} + +_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::supportedInputContentMinScale( const MTL::Device* pDevice ) +{ + float scale = 1.0f; + + if ( nullptr != methodSignatureForSelector( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportedInputContentMinScaleForDevice_ ) ) ) + { + scale = sendMessage< float >( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportedInputContentMinScaleForDevice_ ), pDevice ); + } + + return scale; +} + +_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::supportedInputContentMaxScale( const MTL::Device* pDevice ) +{ + float scale = 1.0f; + + if ( nullptr != methodSignatureForSelector( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportedInputContentMaxScaleForDevice_ ) ) ) + { + scale = sendMessage< float >( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportedInputContentMaxScaleForDevice_ ), pDevice ); + } + else if ( supportsDevice( pDevice ) ) + { + scale = 2.0f; + } + + return scale; +} + +_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::supportsDevice( const MTL::Device* pDevice ) +{ + return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::colorTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::depthTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( depthTextureUsage ) ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::motionTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( motionTextureUsage ) ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::outputTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentWidth( NS::UInteger width ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentHeight( NS::UInteger height ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::colorTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setColorTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::depthTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( depthTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setDepthTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::motionTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( motionTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::outputTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setOutputTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::exposureTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( exposureTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setExposureTexture( MTL::Texture* pTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setExposureTexture_ ), pTexture ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::preExposure() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( preExposure ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setPreExposure( float preExposure ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setPreExposure_ ), preExposure ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetX() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetX ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetX( float offset ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetX_ ), offset ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetY() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetY ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetY( float offset ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetY_ ), offset ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleX() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleX ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleX( float scale ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleX_ ), scale ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleY() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleY ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleY( float scale ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleY_ ), scale ); +} + +_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::reactiveMaskTexture() const +{ + return Object::sendMessage< MTL::Texture* >( this, _MTL_PRIVATE_SEL( reactiveMaskTexture ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setReactiveMaskTexture( MTL::Texture* reactiveMaskTexture ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReactiveMaskTexture_ ), reactiveMaskTexture ); +} + +_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::reactiveTextureUsage() const +{ + return Object::sendMessage< MTL::TextureUsage >( this, _MTL_PRIVATE_SEL( reactiveTextureUsage ) ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScaler::reset() const +{ + return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( reset ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setReset( bool reset ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReset_ ), reset ); +} + +_MTLFX_INLINE bool MTLFX::TemporalScaler::isDepthReversed() const +{ + return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isDepthReversed ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setDepthReversed( bool depthReversed ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthReversed_ ), depthReversed ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::colorTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::depthTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::motionTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) ); +} + +_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::outputTextureFormat() const +{ + return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputWidth() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); +} + +_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputHeight() const +{ + return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMinScale() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) ); +} + +_MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMaxScale() const +{ + return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) ); +} + +_MTLFX_INLINE MTL::Fence* MTLFX::TemporalScaler::fence() const +{ + return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::setFence( MTL::Fence* pFence ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence ); +} + +_MTLFX_INLINE void MTLFX::TemporalScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ) +{ + Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer ); +} + +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-common-utils.h b/Source/Cmlx/include-framework/mlx-backend-common-utils.h new file mode 100644 index 00000000..660ced1a --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-common-utils.h @@ -0,0 +1,207 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include +#include + +#include + +namespace mlx::core { + +// Return the directory that contains current shared library. +std::filesystem::path current_binary_dir(); + +inline int64_t +elem_to_loc(int elem, const Shape& shape, const Strides& strides) { + int64_t loc = 0; + for (int i = shape.size() - 1; i >= 0; --i) { + auto q_and_r = ldiv(elem, shape[i]); + loc += q_and_r.rem * strides[i]; + elem = q_and_r.quot; + } + return loc; +} + +inline int64_t elem_to_loc(int elem, const array& a) { + if (a.flags().row_contiguous) { + return elem; + } + return elem_to_loc(elem, a.shape(), a.strides()); +} + +inline Strides make_contiguous_strides(const Shape& shape) { + Strides strides(shape.size(), 1); + for (int i = shape.size() - 1; i > 0; i--) { + strides[i - 1] = strides[i] * shape[i]; + } + return strides; +} + +// Collapse dims that are contiguous to possibly route to a better kernel +// e.g. for x = transpose(array({0, 1, 2, 3, 4, 5, 6, 7}, {2, 2, 2}), {2, 0, 1}) +// should return {{2, 4}, {{1, 2}}}. +// +// When multiple arrays are passed they should all have the same shape. The +// collapsed axes are also the same so one shape is returned. +std::tuple> collapse_contiguous_dims( + const Shape& shape, + const std::vector& strides, + int64_t size_cap = std::numeric_limits::max()); + +inline std::tuple> collapse_contiguous_dims( + const std::vector& xs, + size_t size_cap = std::numeric_limits::max()) { + std::vector strides; + for (auto& x : xs) { + strides.emplace_back(x.strides()); + } + return collapse_contiguous_dims(xs[0].shape(), strides, size_cap); +} + +template > +inline auto collapse_contiguous_dims(Arrays&&... xs) { + return collapse_contiguous_dims( + std::vector{std::forward(xs)...}); +} + +// The single array version of the above. +std::pair collapse_contiguous_dims( + const Shape& shape, + const Strides& strides, + int64_t size_cap = std::numeric_limits::max()); +std::pair collapse_contiguous_dims( + const array& a, + int64_t size_cap = std::numeric_limits::max()); + +// Compute the thread block dimensions which fit the given +// input dimensions. +// - The thread block dimensions will be powers of two +// - The thread block size will be less than 2^pow2 +using Dims = std::tuple; +Dims get_block_dims_common(int dim0, int dim1, int dim2, int pow2 = 10); + +// Computes a 2D grid where each element is < UINT_MAX +// Assumes: +// - overall size (product of non-broadcasted dimensions) is < UINT_MAX^2 +// - shape and strides correspond to a contiguous (no holes) but +// possibly broadcasted array +Dims get_2d_grid_dims_common(const Shape& shape, const Strides& strides); + +// Same as above but we do an implicit division with divisor. +// Basically, equivalent to factorizing +// Prod(s \forall s in shape if strides[s] > 0) / divisor. +Dims get_2d_grid_dims_common( + const Shape& shape, + const Strides& strides, + size_t divisor); + +// Get both the block and a grid of blocks that covers dim0, dim1 and dim2. +std::pair get_grid_and_block_common(int dim0, int dim1, int dim2); + +struct ContiguousIterator { + inline void step() { + int dims = shape_.size(); + if (dims == 0) { + return; + } + int i = dims - 1; + while (pos_[i] == (shape_[i] - 1) && i > 0) { + pos_[i] = 0; + loc -= (shape_[i] - 1) * strides_[i]; + i--; + } + pos_[i]++; + loc += strides_[i]; + } + + void seek(int64_t n) { + loc = 0; + for (int i = shape_.size() - 1; i >= 0; --i) { + auto q_and_r = ldiv(n, shape_[i]); + loc += q_and_r.rem * strides_[i]; + pos_[i] = q_and_r.rem; + n = q_and_r.quot; + } + } + + void reset() { + loc = 0; + std::fill(pos_.begin(), pos_.end(), 0); + } + + ContiguousIterator() {}; + + explicit ContiguousIterator(const array& a) + : shape_(a.shape()), strides_(a.strides()) { + if (!shape_.empty()) { + std::tie(shape_, strides_) = collapse_contiguous_dims(shape_, strides_); + pos_ = Shape(shape_.size(), 0); + } + } + + explicit ContiguousIterator( + const Shape& shape, + const Strides& strides, + int dims) + : shape_(shape.begin(), shape.begin() + dims), + strides_(strides.begin(), strides.begin() + dims) { + if (!shape_.empty()) { + std::tie(shape_, strides_) = collapse_contiguous_dims(shape_, strides_); + pos_ = Shape(shape_.size(), 0); + } + } + + int64_t loc{0}; + + private: + Shape shape_; + Strides strides_; + Shape pos_; +}; + +inline auto check_contiguity(const Shape& shape, const Strides& strides) { + size_t no_broadcast_data_size = 1; + int64_t f_stride = 1; + int64_t b_stride = 1; + bool is_row_contiguous = true; + bool is_col_contiguous = true; + + for (int i = 0, ri = shape.size() - 1; ri >= 0; i++, ri--) { + is_col_contiguous &= strides[i] == f_stride || shape[i] == 1; + is_row_contiguous &= strides[ri] == b_stride || shape[ri] == 1; + f_stride *= shape[i]; + b_stride *= shape[ri]; + if (strides[i] > 0) { + no_broadcast_data_size *= shape[i]; + } + } + + return std::make_tuple( + no_broadcast_data_size, is_row_contiguous, is_col_contiguous); +} + +inline bool is_donatable(const array& in, const array& out) { + constexpr size_t donation_extra = 16384; + + return in.is_donatable() && in.itemsize() == out.itemsize() && + in.buffer_size() <= out.nbytes() + donation_extra; +} + +std::pair prepare_reshape(const array& in, const array& out); + +void shared_buffer_reshape( + const array& in, + const Strides& out_strides, + array& out); + +template +inline SmallVector remove_index(SmallVector vec, size_t index) { + vec.erase(std::next(vec.begin(), index)); + return vec; +} + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-cpu-encoder.h b/Source/Cmlx/include-framework/mlx-backend-cpu-encoder.h new file mode 100644 index 00000000..72423d5b --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-cpu-encoder.h @@ -0,0 +1,69 @@ +#ifdef __cplusplus +// Copyright © 2025 Apple Inc. + +#pragma once + +#include + +#include +#include + +namespace mlx::core::cpu { + +// Number of dispatches per scheduler task +constexpr int DISPATCHES_PER_TASK = 10; + +struct CommandEncoder { + CommandEncoder(Stream stream) : stream_(stream) {} + + CommandEncoder(const CommandEncoder&) = delete; + CommandEncoder& operator=(const CommandEncoder&) = delete; + CommandEncoder(CommandEncoder&&) = delete; + CommandEncoder& operator=(CommandEncoder&&) = delete; + + void set_input_array(const array& a) {} + void set_output_array(array& a) {} + + // Hold onto a temporary until any already scheduled tasks which use it as + // an input are complete. + void add_temporary(array arr) { + temporaries_.push_back(std::move(arr)); + } + + void add_temporaries(std::vector arrays) { + temporaries_.insert( + temporaries_.end(), + std::make_move_iterator(arrays.begin()), + std::make_move_iterator(arrays.end())); + } + + std::vector& temporaries() { + return temporaries_; + } + + template + void dispatch(F&& f, Args&&... args) { + num_ops_ = (num_ops_ + 1) % DISPATCHES_PER_TASK; + auto task = std::bind(std::forward(f), std::forward(args)...); + if (num_ops_ == 0) { + scheduler::notify_new_task(stream_); + auto task_wrap = [s = stream_, task = std::move(task)]() mutable { + task(); + scheduler::notify_task_completion(s); + }; + scheduler::enqueue(stream_, std::move(task_wrap)); + } else { + scheduler::enqueue(stream_, std::move(task)); + } + } + + private: + Stream stream_; + std::vector temporaries_; + int num_ops_{0}; +}; + +CommandEncoder& get_command_encoder(Stream stream); + +} // namespace mlx::core::cpu +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-gpu-eval.h b/Source/Cmlx/include-framework/mlx-backend-gpu-eval.h new file mode 100644 index 00000000..bedef920 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-gpu-eval.h @@ -0,0 +1,20 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include + +#include +#include + +namespace mlx::core::gpu { + +void new_stream(Stream stream); +void eval(array& arr); +void finalize(Stream s); +void synchronize(Stream s); + +} // namespace mlx::core::gpu +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-metal-device.h b/Source/Cmlx/include-framework/mlx-backend-metal-device.h new file mode 100644 index 00000000..65bd3814 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-metal-device.h @@ -0,0 +1,270 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace mlx::core::metal { + +using MTLFCList = + std::vector>; + +struct DeviceStream; + +struct CommandEncoder { + explicit CommandEncoder(DeviceStream& stream); + CommandEncoder(const CommandEncoder&) = delete; + CommandEncoder& operator=(const CommandEncoder&) = delete; + + struct ConcurrentContext { + ConcurrentContext(CommandEncoder& enc) : enc(enc) { + enc.concurrent_ = true; + } + ~ConcurrentContext() { + enc.concurrent_ = false; + enc.prev_outputs_.insert( + enc.concurrent_outputs_.begin(), enc.concurrent_outputs_.end()); + enc.concurrent_outputs_.clear(); + } + + private: + CommandEncoder& enc; + }; + + void set_input_array(const array& a, int idx, int64_t offset = 0); + void set_output_array(array& a, int idx, int64_t offset = 0); + void register_output_array(const array& a); + void dispatch_threadgroups(MTL::Size grid_dims, MTL::Size group_dims); + void dispatch_threads(MTL::Size grid_dims, MTL::Size group_dims); + void maybeInsertBarrier(); + void set_buffer(const MTL::Buffer* buf, int idx, int64_t offset = 0); + + void set_compute_pipeline_state(MTL::ComputePipelineState* kernel) { + enc_->setComputePipelineState(kernel); + } + + void wait_for_fence(MTL::Fence* fence) { + enc_->waitForFence(fence); + } + + void update_fence(MTL::Fence* fence) { + enc_->updateFence(fence); + } + + template >> + void set_vector_bytes(const Vec& vec, size_t nelems, int idx) { + enc_->setBytes(vec.data(), nelems * sizeof(typename Vec::value_type), idx); + } + template >> + void set_vector_bytes(const Vec& vec, int idx) { + return set_vector_bytes(vec, vec.size(), idx); + } + + template + void set_bytes(const T* v, int n, int idx) { + return enc_->setBytes(v, n * sizeof(T), idx); + } + + template + void set_bytes(const T& v, int idx) { + return enc_->setBytes(&v, sizeof(T), idx); + } + + void set_threadgroup_memory_length(size_t length, int idx) { + enc_->setThreadgroupMemoryLength(length, idx); + } + + ConcurrentContext start_concurrent() { + return ConcurrentContext(*this); + } + ~CommandEncoder(); + + // Inputs to all kernels in the encoder including temporaries + std::unordered_set& inputs() { + return all_inputs_; + }; + + // Outputs of all kernels in the encoder including temporaries + std::unordered_set& outputs() { + return all_outputs_; + }; + + void barrier(); + + private: + DeviceStream& stream_; + MTL::ComputeCommandEncoder* enc_; + bool needs_barrier_{false}; + bool concurrent_{false}; + std::unordered_set prev_outputs_; + std::unordered_set next_outputs_; + std::unordered_set concurrent_outputs_; + std::unordered_set all_inputs_; + std::unordered_set all_outputs_; +}; + +struct Fence { + Fence(MTL::Fence* fence) : fence(fence) {} + ~Fence() { + fence->release(); + } + MTL::Fence* fence; +}; + +struct DeviceStream { + DeviceStream(MTL::CommandQueue* queue) : queue(queue) {}; + ~DeviceStream() { + queue->release(); + if (buffer != nullptr) { + buffer->release(); + } + }; + MTL::CommandQueue* queue; + // A map of prior command encoder outputs to their corresponding fence + std::unordered_map> outputs; + // Used to allow thread-safe access to the outputs map + std::mutex fence_mtx; + + // Data updated between command buffers + MTL::CommandBuffer* buffer{nullptr}; + int buffer_ops{0}; + size_t buffer_sizes{0}; + + // The command encoder, fence, and temporaries are updated between command + // encoders + std::unique_ptr encoder{nullptr}; + std::shared_ptr fence; + std::vector temporaries; +}; + +class Device { + public: + Device(); + Device(const Device&) = delete; + Device& operator=(const Device&) = delete; + ~Device(); + + MTL::Device* mtl_device() { + return device_; + }; + + const std::string& get_architecture() { + return arch_; + } + + int get_architecture_gen() const { + return arch_gen_; + } + + void new_queue(int index); + + MTL::CommandQueue* get_queue(Stream stream); + + MTL::CommandBuffer* get_command_buffer(int index); + bool command_buffer_needs_commit(int index); + void commit_command_buffer(int index); + CommandEncoder& get_command_encoder(int index); + void end_encoding(int index); + + MTL::Library* get_library( + const std::string& name, + const std::string& path = ""); + + MTL::Library* get_library( + const std::string& name, + const std::function& builder); + + void clear_library(const std::string& name); + + MTL::ComputePipelineState* get_kernel( + const std::string& base_name, + MTL::Library* mtl_lib, + const std::string& hash_name = "", + const MTLFCList& func_consts = {}, + const std::vector& linked_functions = {}); + + MTL::ComputePipelineState* get_kernel( + const std::string& base_name, + const std::string& hash_name = "", + const MTLFCList& func_consts = {}, + const std::vector& linked_functions = {}); + + MTL::ArgumentEncoder* argument_encoder( + const std::vector& arg_descs) const; + + // Record temporary arrays for the given stream index + void add_temporary(array arr, int index); + void add_temporaries(std::vector arrays, int index); + + void set_residency_set(const MTL::ResidencySet* residency_set); + + private: + DeviceStream& get_stream_(int index) { + return stream_map_.find(index)->second; + } + MTL::Library* get_library_cache_(const std::string& name); + + MTL::Library* get_library_(const std::string& name); + MTL::Library* build_library_(const std::string& source_string); + + MTL::Function* get_function_(const std::string& name, MTL::Library* mtl_lib); + + MTL::Function* get_function_( + const std::string& name, + const std::string& specialized_name, + const MTLFCList& func_consts, + MTL::Library* mtl_lib); + + MTL::LinkedFunctions* get_linked_functions_( + const std::vector& funcs); + + MTL::ComputePipelineState* get_kernel_( + const std::string& name, + const MTL::Function* mtl_function); + + MTL::ComputePipelineState* get_kernel_( + const std::string& name, + const MTL::Function* mtl_function, + const MTL::LinkedFunctions* linked_functions); + + MTL::ComputePipelineState* get_kernel_( + const std::string& base_name, + MTL::Library* mtl_lib, + const std::string& hash_name, + const MTLFCList& func_consts = {}, + const std::vector& linked_functions = {}); + + MTL::Device* device_; + std::unordered_map stream_map_; + + std::shared_mutex kernel_mtx_; + std::shared_mutex library_mtx_; + std::unordered_map library_map_; + MTL::Library* default_library_; + std::unordered_map< + MTL::Library*, + std::unordered_map> + library_kernels_; + const MTL::ResidencySet* residency_set_{nullptr}; + std::string arch_; + int arch_gen_; + int max_ops_per_buffer_; + int max_mb_per_buffer_; +}; + +Device& device(mlx::core::Device); + +std::unique_ptr> new_scoped_memory_pool(); + +} // namespace mlx::core::metal +#endif diff --git a/Source/Cmlx/include-framework/mlx-backend-metal-utils.h b/Source/Cmlx/include-framework/mlx-backend-metal-utils.h new file mode 100644 index 00000000..b468c0e5 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-backend-metal-utils.h @@ -0,0 +1,86 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include + +#include +#include +#include + +namespace mlx::core { + +std::string type_to_name(const Dtype& t); +std::string type_to_name(const array& a); + +// Compute the grid and block dimensions, check backend-common-utils.h for docs. +MTL::Size get_block_dims(int dim0, int dim1, int dim2, int pow2 = 10); +MTL::Size get_2d_grid_dims(const Shape& shape, const Strides& strides); +MTL::Size +get_2d_grid_dims(const Shape& shape, const Strides& strides, size_t divisor); + +inline NS::String* make_string(std::ostringstream& os) { + std::string string = os.str(); + return NS::String::string(string.c_str(), NS::UTF8StringEncoding); +} + +inline void debug_set_stream_queue_label(MTL::CommandQueue* queue, int index) { +#ifdef MLX_METAL_DEBUG + std::ostringstream label; + label << "Stream " << index; + queue->setLabel(make_string(label)); +#endif +} + +inline void debug_set_primitive_buffer_label( + MTL::CommandBuffer* command_buffer, + Primitive& primitive) { +#ifdef MLX_METAL_DEBUG + std::ostringstream label; + if (auto cbuf_label = command_buffer->label(); cbuf_label) { + label << cbuf_label->utf8String(); + } + label << primitive.name(); + command_buffer->setLabel(make_string(label)); +#endif +} + +template +constexpr bool is_numeric_except_char = std::is_arithmetic_v && + !std::is_same_v && !std::is_same_v && + !std::is_same_v && !std::is_same_v; + +template +void concatenate(std::string& acc, T first) { + if constexpr (is_numeric_except_char) { + acc += std::to_string(first); + } else { + acc += first; + } +} + +template +void concatenate(std::string& acc, T first, Args... args) { + if constexpr (is_numeric_except_char) { + acc += std::to_string(first); + } else { + acc += first; + } + concatenate(acc, args...); +} + +inline int get_work_per_thread(Dtype dtype) { + return std::max(1, 8 / dtype.size()); +} +inline int get_work_per_thread(Dtype dtype, size_t size) { + constexpr size_t wpt_threshold = 1 << 16; + return size < wpt_threshold ? 1 : std::max(1, 8 / dtype.size()); +} + +inline size_t ceildiv(size_t n, size_t m) { + return (n + m - 1) / m; +} + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-primitives.h b/Source/Cmlx/include-framework/mlx-primitives.h new file mode 100644 index 00000000..1b165a94 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-primitives.h @@ -0,0 +1,2474 @@ +#ifdef __cplusplus +// Copyright © 2023-2024 Apple Inc. + +#pragma once + +#include + +#include +#include +#include +#include + +#define DEFINE_VMAP() \ + virtual std::pair, std::vector> vmap( \ + const std::vector& inputs, const std::vector& axes) \ + override; + +#define DEFINE_GRADS() \ + std::vector jvp( \ + const std::vector& primals, \ + const std::vector& tangents, \ + const std::vector& argnums) override; \ + \ + std::vector vjp( \ + const std::vector& primals, \ + const std::vector& cotangents, \ + const std::vector& argnums, \ + const std::vector& outputs) override; + +#define DEFINE_NAME(PRIMITIVE) \ + const char* name() const override { \ + return #PRIMITIVE; \ + } + +#define DEFINE_DEFAULT_IS_EQUIVALENT() \ + bool is_equivalent(const Primitive& other) const override { \ + return true; \ + } + +#define DEFINE_INPUT_OUTPUT_SHAPE() \ + std::vector output_shapes(const std::vector& inputs) \ + override { \ + return {inputs[0].shape()}; \ + } + +namespace mlx::core { + +// Abstract base class +class Primitive { + public: + explicit Primitive(Stream stream) : stream_(stream) {} + + /** The device the primitive will run on. */ + const Device& device() { + return stream().device; + } + + /** The stream the primitive will run on. */ + const Stream& stream() { + return stream_; + } + + /** + * A primitive must know how to evaluate itself on + * the CPU/GPU for the given inputs and populate the output arrays. + * + * To avoid unnecessary allocations, the evaluation function + * is responsible for allocating space for the array. + */ + virtual void eval_cpu( + const std::vector& inputs, + std::vector& outputs) = 0; + virtual void eval_gpu( + const std::vector& inputs, + std::vector& outputs) = 0; + + /** + * The Jacobian-vector product. + */ + virtual std::vector jvp( + const std::vector& primals, + const std::vector& tangents, + const std::vector& argnums); + + /** + * The vector-Jacobian product. + */ + virtual std::vector vjp( + const std::vector& primals, + const std::vector& cotangents, + const std::vector& argnums, + const std::vector& outputs); + + /** + * The primitive must know how to vectorize itself across + * the given axes. The output is a pair containing the output arrays + * representing the vectorized computation and the axes which + * corresponds to the vectorized dimensions of each output. + */ + virtual std::pair, std::vector> vmap( + const std::vector& inputs, + const std::vector& axes); + + /** Get the name of primitive. */ + virtual const char* name() const = 0; + + /** Equivalence check defaults to false unless overridden by the primitive */ + virtual bool is_equivalent(const Primitive& other) const { + return false; + } + + /** Get the output shapes of the primitive. This is not required to be + * implemented by derived classes, in which case it will throw. */ + virtual std::vector output_shapes(const std::vector& inputs); + + virtual ~Primitive() = default; + Primitive(const Primitive& other) = delete; + Primitive(Primitive&& other) = delete; + Primitive& operator=(const Primitive& other) = delete; + Primitive& operator=(Primitive&& other) = delete; + + private: + // Every primitive stores the stream it should run in + Stream stream_; +}; + +class UnaryPrimitive : public Primitive { + /** + * An abstract base class for a primitive with a single output. + */ + public: + explicit UnaryPrimitive(Stream stream) : Primitive(stream) {} + + virtual void eval_cpu(const std::vector& inputs, array& output) = 0; + virtual void eval_gpu(const std::vector& inputs, array& output) = 0; + + inline void eval_cpu( + const std::vector& inputs, + std::vector& outputs) override { + eval_cpu(inputs, outputs[0]); + } + inline void eval_gpu( + const std::vector& inputs, + std::vector& outputs) override { + eval_gpu(inputs, outputs[0]); + } + + virtual ~UnaryPrimitive() = default; + UnaryPrimitive(const UnaryPrimitive& other) = delete; + UnaryPrimitive(UnaryPrimitive&& other) = delete; + UnaryPrimitive& operator=(const UnaryPrimitive& other) = delete; + UnaryPrimitive& operator=(UnaryPrimitive&& other) = delete; +}; + +enum class QuantizationMode { Affine, Mxfp4 }; + +std::string quantization_mode_to_string(QuantizationMode mode); +QuantizationMode string_to_quantization_mode(const std::string& mode); + +class Abs : public UnaryPrimitive { + public: + explicit Abs(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Abs) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Add : public UnaryPrimitive { + public: + explicit Add(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Add) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class AddMM : public UnaryPrimitive { + public: + explicit AddMM(Stream stream, float alpha, float beta) + : UnaryPrimitive(stream), alpha_(alpha), beta_(beta) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_GRADS() + DEFINE_VMAP() + DEFINE_NAME(AddMM) + + bool is_equivalent(const Primitive& other) const override; + std::pair state() const { + return {alpha_, beta_}; + }; + + private: + const float alpha_; + const float beta_; +}; + +class Arange : public UnaryPrimitive { + public: + explicit Arange(Stream stream, double start, double stop, double step) + : UnaryPrimitive(stream), start_(start), stop_(stop), step_(step) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_NAME(Arange) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + std::tuple state() const { + return {start_, stop_, step_}; + }; + + private: + double start_; + double stop_; + double step_; +}; + +class ArcCos : public UnaryPrimitive { + public: + explicit ArcCos(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcCos) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcCosh : public UnaryPrimitive { + public: + explicit ArcCosh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcCosh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcSin : public UnaryPrimitive { + public: + explicit ArcSin(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcSin) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcSinh : public UnaryPrimitive { + public: + explicit ArcSinh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcSinh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcTan : public UnaryPrimitive { + public: + explicit ArcTan(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcTan) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcTan2 : public UnaryPrimitive { + public: + explicit ArcTan2(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcTan2) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArcTanh : public UnaryPrimitive { + public: + explicit ArcTanh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArcTanh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ArgPartition : public UnaryPrimitive { + public: + explicit ArgPartition(Stream stream, int kth, int axis) + : UnaryPrimitive(stream), kth_(kth), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArgPartition) + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + std::pair state() const { + return {kth_, axis_}; + }; + + private: + int kth_; + int axis_; +}; + +class ArgReduce : public UnaryPrimitive { + public: + enum ReduceType { + ArgMin, + ArgMax, + }; + + explicit ArgReduce(Stream stream, ReduceType reduce_type, int axis) + : UnaryPrimitive(stream), reduce_type_(reduce_type), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArgReduce) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + std::pair state() const { + return {reduce_type_, axis_}; + }; + + private: + ReduceType reduce_type_; + int axis_; +}; + +class ArgSort : public UnaryPrimitive { + public: + explicit ArgSort(Stream stream, int axis) + : UnaryPrimitive(stream), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ArgSort) + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + int state() const { + return axis_; + }; + + private: + int axis_; +}; + +class AsType : public UnaryPrimitive { + public: + explicit AsType(Stream stream, Dtype dtype) + : UnaryPrimitive(stream), dtype_(dtype) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(AsType) + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + Dtype state() const { + return dtype_; + }; + + private: + Dtype dtype_; +}; + +class AsStrided : public UnaryPrimitive { + public: + explicit AsStrided(Stream stream, Shape shape, Strides strides, size_t offset) + : UnaryPrimitive(stream), + shape_(std::move(shape)), + strides_(std::move(strides)), + offset_(offset) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_GRADS() + DEFINE_NAME(AsStrided) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple(shape_, strides_, offset_); + } + + private: + Shape shape_; + Strides strides_; + size_t offset_; + + void eval(const std::vector& inputs, array& out); +}; + +class BitwiseBinary : public UnaryPrimitive { + public: + enum Op { And, Or, Xor, LeftShift, RightShift }; + + explicit BitwiseBinary(Stream stream, Op op) + : UnaryPrimitive(stream), op_(op) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + + const char* name() const override { + switch (op_) { + case BitwiseBinary::And: + return "BitwiseAnd"; + case BitwiseBinary::Or: + return "BitwiseOr"; + case BitwiseBinary::Xor: + return "BitwiseXor"; + case BitwiseBinary::LeftShift: + return "LeftShift"; + case BitwiseBinary::RightShift: + return "RightShift"; + } + return ""; + } + + bool is_equivalent(const Primitive& other) const override; + DEFINE_INPUT_OUTPUT_SHAPE() + auto state() const { + return op_; + } + + private: + Op op_; +}; + +class BitwiseInvert : public UnaryPrimitive { + public: + explicit BitwiseInvert(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_NAME(BitwiseInvert) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class BlockMaskedMM : public UnaryPrimitive { + public: + explicit BlockMaskedMM(Stream stream, int block_size) + : UnaryPrimitive(stream), block_size_(block_size) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + std::vector vjp( + const std::vector& primals, + const std::vector& cotangents, + const std::vector& argnums, + const std::vector& outputs) override; + + DEFINE_NAME(BlockMaskedMM) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return block_size_; + } + + private: + int block_size_; +}; + +class GatherMM : public UnaryPrimitive { + public: + explicit GatherMM( + Stream stream, + bool left_sorted = false, + bool right_sorted = false) + : UnaryPrimitive(stream), + left_sorted_(left_sorted), + right_sorted_(right_sorted) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + std::vector vjp( + const std::vector& primals, + const std::vector& cotangents, + const std::vector& argnums, + const std::vector& outputs) override; + + DEFINE_NAME(GatherMM) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_pair(left_sorted_, right_sorted_); + } + + private: + bool left_sorted_; + bool right_sorted_; +}; + +class SegmentedMM : public UnaryPrimitive { + public: + explicit SegmentedMM(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_NAME(SegmentedMM) +}; + +class BroadcastAxes : public UnaryPrimitive { + public: + explicit BroadcastAxes(Stream stream, std::vector ignore_axes = {}) + : UnaryPrimitive(stream), ignore_axes_(std::move(ignore_axes)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(BroadcastAxes) + bool is_equivalent(const Primitive& other) const override; + static Shape output_shape( + const std::vector& inputs, + const std::vector& ignore_axes); + std::vector output_shapes(const std::vector& inputs) override; + auto state() const { + return ignore_axes_; + } + + private: + void eval(const std::vector& inputs, array& out); + std::vector ignore_axes_; +}; + +class Broadcast : public UnaryPrimitive { + public: + explicit Broadcast(Stream stream, const Shape& shape) + : UnaryPrimitive(stream), shape_(shape) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Broadcast) + static Shape output_shape(const std::vector& inputs); + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + Shape state() const { + return shape_; + }; + + private: + Shape shape_; + + void eval(const std::vector& inputs, array& out); +}; + +class Ceil : public UnaryPrimitive { + public: + explicit Ceil(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Ceil) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Compiled : public Primitive { + public: + /* + * The inputs, outputs and tape are either tracers or constants. + * - The tape should not contain the inputs, but it should contain the + * outputs. + * - The tape should also have only one array per primitive for multi-output + * primitives. + * - The constant_ids contains ids of arrays in the input list that are safe + * to treat as scalar constants. + */ + explicit Compiled( + Stream stream, + std::vector inputs, + std::vector outputs, + std::vector tape, + std::unordered_set constant_ids); + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_GRADS() + const char* name() const override; + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + + std::string lib_name() const { + return kernel_lib_; + } + + private: + const std::vector inputs_; + const std::vector outputs_; + const std::vector tape_; + const std::unordered_set constant_ids_; + const std::function is_constant_; + + mutable std::string name_; + std::string kernel_lib_; +}; + +class Concatenate : public UnaryPrimitive { + public: + explicit Concatenate(Stream stream, int axis) + : UnaryPrimitive(stream), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Concatenate) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + auto state() const { + return axis_; + } + + private: + int axis_; +}; + +class Conjugate : public UnaryPrimitive { + public: + explicit Conjugate(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_NAME(Conjugate) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Contiguous : public UnaryPrimitive { + public: + explicit Contiguous(Stream stream, bool allow_col_major) + : UnaryPrimitive(stream), allow_col_major_(allow_col_major) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Contiguous) + DEFINE_INPUT_OUTPUT_SHAPE() + + bool is_equivalent(const Primitive& other) const override; + + private: + bool allow_col_major_; +}; + +class Convolution : public UnaryPrimitive { + public: + explicit Convolution( + Stream stream, + const std::vector& kernel_strides, + const std::vector& padding_lo, + const std::vector& padding_hi, + const std::vector& kernel_dilation, + const std::vector& input_dilation, + const int groups = 1, + const bool flip = false) + : UnaryPrimitive(stream), + padding_lo_(padding_lo), + padding_hi_(padding_hi), + kernel_strides_(kernel_strides), + kernel_dilation_(kernel_dilation), + input_dilation_(input_dilation), + groups_(groups), + flip_(flip) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + std::vector vjp( + const std::vector& primals, + const std::vector& cotangents, + const std::vector& argnums, + const std::vector& outputs) override; + + DEFINE_VMAP() + DEFINE_NAME(Convolution) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple( + kernel_strides_, + padding_lo_, + padding_hi_, + kernel_dilation_, + input_dilation_, + groups_, + flip_); + } + + private: + std::vector padding_lo_; + std::vector padding_hi_; + std::vector kernel_strides_; + std::vector kernel_dilation_; + std::vector input_dilation_; + int groups_; + bool flip_; +}; + +class Copy : public UnaryPrimitive { + public: + explicit Copy(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Copy) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() + + private: + void eval(const std::vector& inputs, array& out); +}; + +class Cos : public UnaryPrimitive { + public: + explicit Cos(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Cos) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Cosh : public UnaryPrimitive { + public: + explicit Cosh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Cosh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class CustomTransforms : public Primitive { + public: + explicit CustomTransforms( + Stream stream, + int num_outputs, + std::function( + const std::vector&, + const std::vector&, + const std::vector&)> vjp, + std::function( + const std::vector&, + const std::vector&, + const std::vector&)> jvp, + std::function, std::vector>( + const std::vector&, + const std::vector&)> vmap) + : Primitive(stream), + num_outputs_(num_outputs), + vjp_fun_(std::move(vjp)), + jvp_fun_(std::move(jvp)), + vmap_fun_(std::move(vmap)) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_GRADS(); + DEFINE_VMAP(); + DEFINE_NAME(CustomTransforms); + + private: + void eval(const std::vector& inputs, std::vector& outputs); + + int num_outputs_; + + std::function( + const std::vector&, + const std::vector&, + const std::vector&)> + vjp_fun_; + std::function( + const std::vector&, + const std::vector&, + const std::vector&)> + jvp_fun_; + std::function, std::vector>( + const std::vector&, + const std::vector&)> + vmap_fun_; +}; + +class Depends : public Primitive { + public: + explicit Depends(Stream stream) : Primitive(stream) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + std::vector vjp( + const std::vector& primals, + const std::vector& cotan, + const std::vector& argnums, + const std::vector& outputs) override; + + DEFINE_NAME(Depends); + + private: + void eval(const std::vector& inputs, std::vector& outputs); +}; + +class Divide : public UnaryPrimitive { + public: + explicit Divide(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Divide) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class DivMod : public Primitive { + public: + explicit DivMod(Stream stream) : Primitive(stream) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(DivMod) + DEFINE_DEFAULT_IS_EQUIVALENT() + std::vector output_shapes(const std::vector& inputs) override { + return std::vector{inputs[0].shape(), inputs[0].shape()}; + } +}; + +class Select : public UnaryPrimitive { + public: + explicit Select(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Select) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Remainder : public UnaryPrimitive { + public: + explicit Remainder(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Remainder) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Equal : public UnaryPrimitive { + public: + explicit Equal(Stream stream, bool equal_nan = false) + : UnaryPrimitive(stream), equal_nan_(equal_nan) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() + + const char* name() const override { + if (equal_nan_) { + return "NaNEqual"; + } else { + return "Equal"; + } + } + auto state() const { + return equal_nan_; + }; + + private: + bool equal_nan_; +}; + +class Erf : public UnaryPrimitive { + public: + explicit Erf(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Erf) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ErfInv : public UnaryPrimitive { + public: + explicit ErfInv(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ErfInv) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Exp : public UnaryPrimitive { + public: + explicit Exp(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Exp) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Expm1 : public UnaryPrimitive { + public: + explicit Expm1(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Expm1) + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class ExpandDims : public UnaryPrimitive { + public: + explicit ExpandDims(Stream stream, std::vector axes) + : UnaryPrimitive(stream), axes_(std::move(axes)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(ExpandDims) + + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + + static Shape output_shape(const array& input, const std::vector& axes); + auto state() const { + return axes_; + } + + private: + void eval(const std::vector& inputs, array& out); + std::vector axes_; +}; + +class FFT : public UnaryPrimitive { + public: + explicit FFT( + Stream stream, + const std::vector& axes, + bool inverse, + bool real) + : UnaryPrimitive(stream), axes_(axes), inverse_(inverse), real_(real) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(FFT) + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple(axes_, inverse_, real_); + } + + private: + std::vector axes_; + bool inverse_; + bool real_; +}; + +class Flatten : public UnaryPrimitive { + public: + explicit Flatten(Stream stream, int start_axis, int end_axis) + : UnaryPrimitive(stream), start_axis_(start_axis), end_axis_(end_axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Flatten) + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + + static Shape output_shape(const array& input, int start_axis, int end_axis); + auto state() const { + return std::make_pair(start_axis_, end_axis_); + } + + private: + int start_axis_; + int end_axis_; + void eval(const std::vector& inputs, array& out); +}; + +class Floor : public UnaryPrimitive { + public: + explicit Floor(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Floor) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Full : public UnaryPrimitive { + public: + explicit Full(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Full) + DEFINE_DEFAULT_IS_EQUIVALENT() +}; + +class Gather : public UnaryPrimitive { + public: + explicit Gather(Stream stream, std::vector axes, Shape slice_sizes) + : UnaryPrimitive(stream), + axes_(std::move(axes)), + slice_sizes_(std::move(slice_sizes)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Gather) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + std::pair, Shape> state() const { + return {axes_, slice_sizes_}; + } + + private: + std::vector axes_; + Shape slice_sizes_; +}; + +class GatherAxis : public UnaryPrimitive { + public: + explicit GatherAxis(Stream stream, int axis) + : UnaryPrimitive(stream), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(GatherAxis) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + auto state() const { + return axis_; + } + + private: + int axis_; +}; + +class Greater : public UnaryPrimitive { + public: + explicit Greater(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Greater) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class GreaterEqual : public UnaryPrimitive { + public: + explicit GreaterEqual(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(GreaterEqual) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Hadamard : public UnaryPrimitive { + public: + explicit Hadamard(Stream stream, float scale) + : UnaryPrimitive(stream), scale_(scale) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Hadamard) + DEFINE_INPUT_OUTPUT_SHAPE() + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return scale_; + } + + private: + float scale_; +}; + +class Imag : public UnaryPrimitive { + public: + explicit Imag(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Imag) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Less : public UnaryPrimitive { + public: + explicit Less(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Less) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LessEqual : public UnaryPrimitive { + public: + explicit LessEqual(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LessEqual) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Load : public UnaryPrimitive { + public: + explicit Load( + Stream stream, + std::shared_ptr reader, + size_t offset, + bool swap_endianness = false) + : UnaryPrimitive(stream), + reader_(std::move(reader)), + offset_(offset), + swap_endianness_(swap_endianness) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_NAME(Load) + + private: + std::shared_ptr reader_; + size_t offset_; + bool swap_endianness_; +}; + +class Log : public UnaryPrimitive { + public: + enum Base { two, ten, e }; + + explicit Log(Stream stream, Base base) + : UnaryPrimitive(stream), base_(base) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() + + Base state() const { + return base_; + }; + + const char* name() const override { + switch (base_) { + case e: + return "Log"; + case two: + return "Log2"; + case ten: + return "Log10"; + } + return ""; + } + + private: + Base base_; +}; + +class Log1p : public UnaryPrimitive { + public: + explicit Log1p(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Log1p) + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LogicalNot : public UnaryPrimitive { + public: + explicit LogicalNot(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LogicalNot) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LogicalAnd : public UnaryPrimitive { + public: + explicit LogicalAnd(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LogicalAnd) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LogicalOr : public UnaryPrimitive { + public: + explicit LogicalOr(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LogicalOr) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LogAddExp : public UnaryPrimitive { + public: + explicit LogAddExp(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LogAddExp) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class LogSumExp : public UnaryPrimitive { + public: + explicit LogSumExp(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(LogSumExp) + DEFINE_DEFAULT_IS_EQUIVALENT() + std::vector output_shapes(const std::vector& inputs) override; +}; + +class Matmul : public UnaryPrimitive { + public: + explicit Matmul(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_GRADS() + DEFINE_VMAP() + DEFINE_NAME(Matmul) + DEFINE_DEFAULT_IS_EQUIVALENT() + std::vector output_shapes(const std::vector& inputs) override; +}; + +class Maximum : public UnaryPrimitive { + public: + explicit Maximum(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Maximum) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Minimum : public UnaryPrimitive { + public: + explicit Minimum(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Minimum) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Multiply : public UnaryPrimitive { + public: + explicit Multiply(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Multiply) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Negative : public UnaryPrimitive { + public: + explicit Negative(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Negative) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class NotEqual : public UnaryPrimitive { + public: + explicit NotEqual(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(NotEqual) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class NumberOfElements : public UnaryPrimitive { + public: + explicit NumberOfElements( + Stream stream, + std::vector axes, + bool inverted, + Dtype dtype) + : UnaryPrimitive(stream), + axes_(std::move(axes)), + inverted_(inverted), + dtype_(dtype) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_NAME(NumberOfElements) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override { + return {{}}; + } + std::tuple, bool, Dtype> state() const { + return {axes_, inverted_, dtype_}; + } + + private: + std::vector axes_; + bool inverted_; + Dtype dtype_; + + void eval(const std::vector& inputs, array& out); +}; + +class Pad : public UnaryPrimitive { + public: + explicit Pad( + Stream stream, + const std::vector& axes, + const Shape& low_pad_size, + const Shape& high_pad_size) + : UnaryPrimitive(stream), + axes_(axes), + low_pad_size_(low_pad_size), + high_pad_size_(high_pad_size) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Pad) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple(axes_, low_pad_size_, high_pad_size_); + } + + private: + std::vector axes_; + Shape low_pad_size_; + Shape high_pad_size_; +}; + +class Partition : public UnaryPrimitive { + public: + explicit Partition(Stream stream, int kth, int axis) + : UnaryPrimitive(stream), kth_(kth), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Partition) + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_pair(kth_, axis_); + }; + + private: + int kth_; + int axis_; +}; + +class Power : public UnaryPrimitive { + public: + explicit Power(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Power) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class QuantizedMatmul : public UnaryPrimitive { + public: + explicit QuantizedMatmul( + Stream stream, + int group_size, + int bits, + QuantizationMode mode, + bool transpose) + : UnaryPrimitive(stream), + group_size_(group_size), + bits_(bits), + mode_(mode), + transpose_(transpose) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(QuantizedMatmul) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + auto state() const { + return std::make_tuple(group_size_, bits_, mode_, transpose_); + } + + private: + int group_size_; + int bits_; + QuantizationMode mode_; + bool transpose_; +}; + +class GatherQMM : public UnaryPrimitive { + public: + explicit GatherQMM( + Stream stream, + int group_size, + int bits, + QuantizationMode mode, + bool transpose, + bool left_sorted = false, + bool right_sorted = false) + : UnaryPrimitive(stream), + group_size_(group_size), + bits_(bits), + mode_(mode), + transpose_(transpose), + left_sorted_(left_sorted), + right_sorted_(right_sorted) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(GatherQMM) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple( + group_size_, bits_, mode_, transpose_, left_sorted_, right_sorted_); + } + + private: + int group_size_; + int bits_; + QuantizationMode mode_; + bool transpose_; + bool left_sorted_; + bool right_sorted_; +}; + +class RandomBits : public UnaryPrimitive { + public: + explicit RandomBits(Stream stream, const Shape& shape, int width) + : UnaryPrimitive(stream), shape_(shape), width_(width) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_NAME(RandomBits) + bool is_equivalent(const Primitive& other) const override; + std::pair state() const { + return {shape_, width_}; + }; + + private: + Shape shape_; + int width_; +}; + +class Real : public UnaryPrimitive { + public: + explicit Real(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Real) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Reshape : public UnaryPrimitive { + public: + explicit Reshape(Stream stream, const Shape& shape) + : UnaryPrimitive(stream), shape_(shape) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Reshape) + bool is_equivalent(const Primitive& other) const override; + Shape state() const { + return shape_; + }; + static Shape output_shape(const array& input, Shape shape); + std::vector output_shapes(const std::vector& inputs) override; + + private: + Shape shape_; +}; + +class Reduce : public UnaryPrimitive { + public: + enum ReduceType { And, Or, Sum, Prod, Min, Max }; + + explicit Reduce( + Stream stream, + ReduceType reduce_type, + const std::vector& axes) + : UnaryPrimitive(stream), reduce_type_(reduce_type), axes_(axes) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + + std::vector vjp( + const std::vector& primals, + const std::vector& cotangents, + const std::vector& argnums, + const std::vector& outputs) override; + + std::vector output_shapes(const std::vector& inputs) override; + + const char* name() const override { + switch (reduce_type_) { + case And: + return "And"; + case Or: + return "Or"; + case Sum: + return "Sum"; + case Prod: + return "Prod"; + case Min: + return "Min"; + case Max: + return "Max"; + } + return ""; + } + + bool is_equivalent(const Primitive& other) const override; + std::pair> state() const { + return {reduce_type_, axes_}; + }; + + private: + ReduceType reduce_type_; + std::vector axes_; +}; + +class Round : public UnaryPrimitive { + public: + explicit Round(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Round) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Scan : public UnaryPrimitive { + public: + enum ReduceType { Max, Min, Sum, Prod, LogAddExp }; + + explicit Scan( + Stream stream, + ReduceType reduce_type, + int axis, + bool reverse, + bool inclusive) + : UnaryPrimitive(stream), + reduce_type_(reduce_type), + axis_(axis), + reverse_(reverse), + inclusive_(inclusive) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS(); + + const char* name() const override { + switch (reduce_type_) { + case Sum: + return "CumSum"; + case Prod: + return "CumProd"; + case Min: + return "CumMin"; + case Max: + return "CumMax"; + case LogAddExp: + return "CumLogAddExp"; + } + return ""; + } + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple(reduce_type_, axis_, reverse_, inclusive_); + } + + private: + ReduceType reduce_type_; + int axis_; + bool reverse_; + bool inclusive_; +}; + +class Scatter : public UnaryPrimitive { + public: + enum ReduceType { Max, Min, Sum, Prod, None }; + + explicit Scatter( + Stream stream, + ReduceType reduce_type, + const std::vector& axes) + : UnaryPrimitive(stream), reduce_type_(reduce_type), axes_(axes) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP(); + DEFINE_GRADS(); + + const char* name() const override { + switch (reduce_type_) { + case Sum: + return "ScatterSum"; + case Prod: + return "ScatterProd"; + case Min: + return "ScatterMin"; + case Max: + return "ScatterMax"; + case None: + return "Scatter"; + } + return ""; + } + + bool is_equivalent(const Primitive& other) const override; + std::pair> state() const { + return {reduce_type_, axes_}; + }; + + private: + ReduceType reduce_type_; + std::vector axes_; +}; + +class ScatterAxis : public UnaryPrimitive { + public: + enum ReduceType { Sum, None }; + + explicit ScatterAxis(Stream stream, ReduceType reduce_type, int axis) + : UnaryPrimitive(stream), reduce_type_(reduce_type), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + + const char* name() const override { + switch (reduce_type_) { + case Sum: + return "ScatterAxisSum"; + case None: + return "ScatterAxis"; + } + return ""; + } + + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + std::pair state() const { + return {reduce_type_, axis_}; + } + + private: + ReduceType reduce_type_; + int axis_; +}; + +class Sigmoid : public UnaryPrimitive { + public: + explicit Sigmoid(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Sigmoid) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Sign : public UnaryPrimitive { + public: + explicit Sign(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Sign) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Sin : public UnaryPrimitive { + public: + explicit Sin(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Sin) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Sinh : public UnaryPrimitive { + public: + explicit Sinh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Sinh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Slice : public UnaryPrimitive { + public: + explicit Slice( + Stream stream, + const Shape& start_indices, + const Shape& end_indices, + const Shape& strides) + : UnaryPrimitive(stream), + start_indices_(start_indices), + end_indices_(end_indices), + strides_(strides) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Slice) + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_tuple(start_indices_, end_indices_, strides_); + } + + private: + Shape start_indices_; + Shape end_indices_; + Shape strides_; +}; + +class SliceUpdate : public UnaryPrimitive { + public: + explicit SliceUpdate( + Stream stream, + const Shape& start_indices, + const Shape& end_indices, + const Shape& strides) + : UnaryPrimitive(stream), + start_indices_(start_indices), + end_indices_(end_indices), + strides_(strides) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(SliceUpdate) + bool is_equivalent(const Primitive& other) const override; + DEFINE_INPUT_OUTPUT_SHAPE() + auto state() const { + return std::make_tuple(start_indices_, end_indices_, strides_); + } + + private: + Shape start_indices_; + Shape end_indices_; + Shape strides_; +}; + +class DynamicSlice : public UnaryPrimitive { + public: + explicit DynamicSlice(Stream stream, std::vector axes, Shape slice_size) + : UnaryPrimitive(stream), + axes_(std::move(axes)), + slice_size_(std::move(slice_size)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(DynamicSlice) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + auto state() const { + return std::make_pair(axes_, slice_size_); + } + + private: + std::vector axes_; + Shape slice_size_; +}; + +class DynamicSliceUpdate : public UnaryPrimitive { + public: + explicit DynamicSliceUpdate(Stream stream, std::vector axes) + : UnaryPrimitive(stream), axes_(std::move(axes)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(DynamicSliceUpdate) + bool is_equivalent(const Primitive& other) const override; + DEFINE_INPUT_OUTPUT_SHAPE() + auto state() const { + return axes_; + } + + private: + std::vector axes_; +}; + +class Softmax : public UnaryPrimitive { + public: + explicit Softmax(Stream stream, bool precise) + : UnaryPrimitive(stream), precise_(precise) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Softmax) + DEFINE_INPUT_OUTPUT_SHAPE() + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return precise_; + }; + + private: + bool precise_; +}; + +class Sort : public UnaryPrimitive { + public: + explicit Sort(Stream stream, int axis) + : UnaryPrimitive(stream), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Sort) + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return axis_; + } + + private: + int axis_; +}; + +class Split : public Primitive { + public: + explicit Split(Stream stream, const Shape& indices, int axis) + : Primitive(stream), indices_(indices), axis_(axis) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Split) + bool is_equivalent(const Primitive& other) const override; + std::pair state() const { + return {indices_, axis_}; + }; + + private: + void eval(const std::vector& inputs, std::vector& outputs); + + Shape indices_; + int axis_; +}; + +class Square : public UnaryPrimitive { + public: + explicit Square(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Square) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Sqrt : public UnaryPrimitive { + public: + explicit Sqrt(Stream stream, bool recip = false) + : UnaryPrimitive(stream), recip_(recip) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_INPUT_OUTPUT_SHAPE() + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return recip_; + } + + const char* name() const override { + if (recip_) { + return "Rsqrt"; + } else { + return "Sqrt"; + } + } + + private: + bool recip_; +}; + +class StopGradient : public UnaryPrimitive { + public: + explicit StopGradient(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_NAME(StopGradient) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() + + private: + void eval(const std::vector& inputs, array& out); +}; + +class Subtract : public UnaryPrimitive { + public: + explicit Subtract(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Subtract) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Squeeze : public UnaryPrimitive { + public: + explicit Squeeze(Stream stream, std::vector axes) + : UnaryPrimitive(stream), axes_(std::move(axes)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Squeeze) + + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + + static Shape output_shape(const array& input, const std::vector& axes); + auto state() const { + return axes_; + }; + + private: + void eval(const std::vector& inputs, array& out); + std::vector axes_; +}; + +class Tan : public UnaryPrimitive { + public: + explicit Tan(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Tan) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Tanh : public UnaryPrimitive { + public: + explicit Tanh(Stream stream) : UnaryPrimitive(stream) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Tanh) + DEFINE_DEFAULT_IS_EQUIVALENT() + DEFINE_INPUT_OUTPUT_SHAPE() +}; + +class Unflatten : public UnaryPrimitive { + public: + explicit Unflatten(Stream stream, int axis, Shape shape) + : UnaryPrimitive(stream), axis_(axis), shape_(std::move(shape)) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Unflatten) + std::vector output_shapes(const std::vector& inputs) override; + bool is_equivalent(const Primitive& other) const override; + + static Shape output_shape(const array& input, int axis, const Shape& shape); + auto state() const { + return std::make_pair(axis_, shape_); + } + + private: + int axis_; + Shape shape_; + void eval(const std::vector& inputs, array& out); +}; + +class View : public UnaryPrimitive { + public: + explicit View(Stream stream, Dtype dtype) + : UnaryPrimitive(stream), dtype_(dtype) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + const char* name() const override; + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return dtype_; + } + + private: + Dtype dtype_; + mutable std::string name_; +}; + +class Transpose : public UnaryPrimitive { + public: + explicit Transpose(Stream stream, const std::vector& axes) + : UnaryPrimitive(stream), axes_(axes) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + + DEFINE_VMAP() + DEFINE_GRADS() + DEFINE_NAME(Transpose) + bool is_equivalent(const Primitive& other) const override; + std::vector output_shapes(const std::vector& inputs) override; + std::vector state() const { + return axes_; + }; + + private: + std::vector axes_; + + void eval(const std::vector& inputs, array& out); +}; + +/* QR Factorization primitive. */ +class QRF : public Primitive { + public: + explicit QRF(Stream stream) : Primitive(stream) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_NAME(QRF) +}; + +/* SVD primitive. */ +class SVD : public Primitive { + public: + explicit SVD(Stream stream, bool compute_uv) + : Primitive(stream), compute_uv_(compute_uv) {} + + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_NAME(SVD) + auto state() const { + return compute_uv_; + } + + private: + bool compute_uv_; +}; + +/* Matrix inversion primitive. */ +class Inverse : public UnaryPrimitive { + public: + explicit Inverse(Stream stream, bool tri, bool upper) + : UnaryPrimitive(stream), tri_(tri), upper_(upper) {} + + void eval_cpu(const std::vector& inputs, array& output) override; + void eval_gpu(const std::vector& inputs, array& output) override; + + DEFINE_VMAP() + DEFINE_NAME(Inverse) + auto state() const { + return std::make_pair(tri_, upper_); + } + + private: + bool tri_; + bool upper_; +}; + +class Cholesky : public UnaryPrimitive { + public: + explicit Cholesky(Stream stream, bool upper) + : UnaryPrimitive(stream), upper_(upper) {} + + void eval_cpu(const std::vector& inputs, array& out) override; + void eval_gpu(const std::vector& inputs, array& out) override; + auto state() const { + return upper_; + } + + DEFINE_VMAP() + DEFINE_NAME(Cholesky) + + private: + bool upper_; +}; + +class Eig : public Primitive { + public: + explicit Eig(Stream stream, bool compute_eigenvectors) + : Primitive(stream), compute_eigenvectors_(compute_eigenvectors) {} + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_NAME(Eig) + + std::vector output_shapes(const std::vector& inputs) override; + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return compute_eigenvectors_; + } + + private: + bool compute_eigenvectors_; +}; + +class Eigh : public Primitive { + public: + explicit Eigh(Stream stream, std::string uplo, bool compute_eigenvectors) + : Primitive(stream), + uplo_(std::move(uplo)), + compute_eigenvectors_(compute_eigenvectors) {} + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_VMAP() + DEFINE_NAME(Eigh) + + std::vector output_shapes(const std::vector& inputs) override; + + bool is_equivalent(const Primitive& other) const override; + auto state() const { + return std::make_pair(uplo_, compute_eigenvectors_); + } + + private: + std::string uplo_; + bool compute_eigenvectors_; +}; + +/* LU Factorization primitive. */ +class LUF : public Primitive { + public: + explicit LUF(Stream stream) : Primitive(stream) {} + void eval_cpu(const std::vector& inputs, std::vector& outputs) + override; + void eval_gpu(const std::vector& inputs, std::vector& outputs) + override; + + DEFINE_NAME(LUF) +}; + +} // namespace mlx::core +#endif diff --git a/Source/Cmlx/include-framework/mlx-scheduler.h b/Source/Cmlx/include-framework/mlx-scheduler.h new file mode 100644 index 00000000..c43aecf5 --- /dev/null +++ b/Source/Cmlx/include-framework/mlx-scheduler.h @@ -0,0 +1,186 @@ +#ifdef __cplusplus +// Copyright © 2023 Apple Inc. + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace mlx::core::scheduler { + +struct StreamThread { + std::mutex mtx; + std::queue> q; + std::condition_variable cond; + bool stop; + std::thread thread; + + StreamThread() : stop(false), thread(&StreamThread::thread_fn, this) {} + + ~StreamThread() { + { + std::lock_guard lk(mtx); + stop = true; + } + cond.notify_one(); + thread.join(); + } + + void thread_fn() { + while (true) { + std::function task; + { + std::unique_lock lk(mtx); + cond.wait(lk, [this] { return !this->q.empty() || this->stop; }); + if (q.empty() && stop) { + return; + } + task = std::move(q.front()); + q.pop(); + } + + task(); + } + } + + template + void enqueue(F&& f) { + { + std::lock_guard lk(mtx); + if (stop) { + throw std::runtime_error( + "Cannot enqueue work after stream is stopped."); + } + q.emplace(std::forward(f)); + } + cond.notify_one(); + } +}; + +class Scheduler { + public: + Scheduler() : n_active_tasks_(0) { + if (is_available(Device::gpu)) { + default_streams_.insert({Device::gpu, new_stream(Device::gpu)}); + } + default_streams_.insert({Device::cpu, new_stream(Device::cpu)}); + } + + // Not copyable or moveable + Scheduler(const Scheduler&) = delete; + Scheduler(Scheduler&&) = delete; + Scheduler& operator=(const Scheduler&) = delete; + Scheduler& operator=(Scheduler&&) = delete; + + Stream new_stream(const Device& d) { + streams_.emplace_back(streams_.size(), d); + if (d == Device::gpu) { + threads_.push_back(nullptr); + gpu::new_stream(streams_.back()); + } else { + threads_.push_back(new StreamThread{}); + } + return streams_.back(); + } + + template + void enqueue(const Stream& stream, F&& f); + + Stream get_default_stream(const Device& d) const { + return default_streams_.at(d.type); + } + Stream get_stream(int index) const { + return streams_.at(index); + } + + void set_default_stream(const Stream& s) { + default_streams_.at(s.device.type) = s; + } + + void notify_new_task(const Stream& stream) { + { + std::lock_guard lk(mtx); + n_active_tasks_++; + } + completion_cv.notify_all(); + } + + void notify_task_completion(const Stream& stream) { + { + std::lock_guard lk(mtx); + n_active_tasks_--; + } + completion_cv.notify_all(); + } + + int n_active_tasks() const { + return n_active_tasks_; + } + + void wait_for_one() { + std::unique_lock lk(mtx); + int n_tasks_old = n_active_tasks(); + if (n_tasks_old > 1) { + completion_cv.wait(lk, [this, n_tasks_old] { + return this->n_active_tasks() < n_tasks_old; + }); + } + } + + ~Scheduler() { + for (auto s : streams_) { + synchronize(s); + } + for (auto t : threads_) { + if (t != nullptr) { + delete t; + } + } + } + + private: + int n_active_tasks_; + std::vector threads_; + std::vector streams_; + std::unordered_map default_streams_; + std::condition_variable completion_cv; + std::mutex mtx; +}; + +template +void Scheduler::enqueue(const Stream& stream, F&& f) { + threads_[stream.index]->enqueue(std::forward(f)); +} + +Scheduler& scheduler(); + +template +void enqueue(const Stream& stream, F&& f) { + scheduler().enqueue(stream, std::forward(f)); +} + +inline int n_active_tasks() { + return scheduler().n_active_tasks(); +} + +inline void notify_new_task(const Stream& stream) { + scheduler().notify_new_task(stream); +} + +inline void notify_task_completion(const Stream& stream) { + scheduler().notify_task_completion(stream); +} + +inline void wait_for_one() { + scheduler().wait_for_one(); +} + +} // namespace mlx::core::scheduler +#endif diff --git a/tools/update-mlx.sh b/tools/update-mlx.sh index 54fd3546..56096a2a 100755 --- a/tools/update-mlx.sh +++ b/tools/update-mlx.sh @@ -69,19 +69,35 @@ for x in \ types/bf16.h \ io/load.h \ export_impl.h \ - threadpool.h + threadpool.h \ + scheduler.h \ + primitives.h \ + backend/metal/device.h \ + backend/metal/utils.h \ + backend/common/utils.h \ + backend/cpu/encoder.h \ + backend/gpu/eval.h do # guard the contents for non c++ callers h=mlx-`echo $x | tr / -` d=Source/Cmlx/include-framework/$h echo "#ifdef __cplusplus" > $d - cat Source/Cmlx/mlx/mlx/$x | sed -e 's:backend/:backend-:g' -e 's:cuda/:cuda-:g' -e 's:gpu/:gpu-:g' -e 's:metal/:metal-:g' -e 's:distributed/:distributed-:g' -e 's:types/:types-:' -e 's:io/:io-:' -e 's:#include "mlx/:#include :g' >> $d + cat Source/Cmlx/mlx/mlx/$x | sed -e 's:backend/:backend-:g' -e 's:cuda/:cuda-:g' -e 's:gpu/:gpu-:g' -e 's:metal/:metal-:g' -e 's:distributed/:distributed-:g' -e 's:types/:types-:' -e 's:io/:io-:' -e 's:common/:common-:' -e 's:cpu/:cpu-:' -e 's:#include "mlx/:#include :g' -e 's:Metal/Metal.hpp:Cmlx/Metal.hpp:g' >> $d echo "#endif" >> $d # add to Cmlx echo "#include " >> Source/Cmlx/include-framework/Cmlx.h done +# build & copy in the Metal.hpp header +(cd Source/Cmlx/metal-cpp; ./SingleHeader/MakeSingleHeader.py -o ../include-framework/Metal.hpp.in Foundation/Foundation.hpp QuartzCore/QuartzCore.hpp Metal/Metal.hpp MetalFX/MetalFX.hpp) + +echo "#ifdef __cplusplus" > Source/Cmlx/include-framework/Metal.hpp +cat Source/Cmlx/include-framework/Metal.hpp.in >> Source/Cmlx/include-framework/Metal.hpp +echo "#endif" >> Source/Cmlx/include-framework/Metal.hpp +rm Source/Cmlx/include-framework/Metal.hpp.in + +echo "#include " >> Source/Cmlx/include-framework/Cmlx.h # run the command to do the build-time code generation diff --git a/xcode/MLX.xcodeproj/project.pbxproj b/xcode/MLX.xcodeproj/project.pbxproj index 76ed91b0..5f6b327d 100644 --- a/xcode/MLX.xcodeproj/project.pbxproj +++ b/xcode/MLX.xcodeproj/project.pbxproj @@ -975,15 +975,21 @@ ); target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; }; - C3CB09A12EAC2EF70029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */ = { + C3CB32A82EB1677C0029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */ = { isa = PBXFileSystemSynchronizedBuildFileExceptionSet; publicHeaders = ( Cmlx.h, + Metal.hpp, "mlx-allocator.h", "mlx-array.h", + "mlx-backend-common-utils.h", + "mlx-backend-cpu-encoder.h", "mlx-backend-cuda-cuda.h", "mlx-backend-gpu-available.h", + "mlx-backend-gpu-eval.h", + "mlx-backend-metal-device.h", "mlx-backend-metal-metal.h", + "mlx-backend-metal-utils.h", "mlx-c-array.h", "mlx-c-closure.h", "mlx-c-compile.h", @@ -1027,7 +1033,9 @@ "mlx-linalg.h", "mlx-memory.h", "mlx-ops.h", + "mlx-primitives.h", "mlx-random.h", + "mlx-scheduler.h", "mlx-small_vector.h", "mlx-stream.h", "mlx-threadpool.h", @@ -1040,7 +1048,7 @@ ); target = C3AE8EE52EAAA3C5000BD280 /* Cmlx */; }; - C3CB0BCF2EAC301E0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */ = { + C3CB32A92EB168CD0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */ = { isa = PBXFileSystemSynchronizedBuildFileExceptionSet; membershipExceptions = ( metal/arange.h, @@ -1370,7 +1378,7 @@ C3AE98112EAAAAAD000BD280 /* mlx-generated */ = { isa = PBXFileSystemSynchronizedRootGroup; exceptions = ( - C3CB0BCF2EAC301E0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */, + C3CB32A92EB168CD0029A645 /* Exceptions for "mlx-generated" folder in "Cmlx" target */, ); path = "mlx-generated"; sourceTree = ""; @@ -1391,7 +1399,7 @@ C3CBE24A2EABF7870029A645 /* include-framework */ = { isa = PBXFileSystemSynchronizedRootGroup; exceptions = ( - C3CB09A12EAC2EF70029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */, + C3CB32A82EB1677C0029A645 /* Exceptions for "include-framework" folder in "Cmlx" target */, ); path = "include-framework"; sourceTree = "";