diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_array b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_array new file mode 100644 index 00000000..41f686b1 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_array @@ -0,0 +1,308 @@ +//===-- metal_array -------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_ARRAY +#define __METAL_ARRAY + +#include + +#if defined(__HAVE_ARRAY__) +namespace metal { + +template +struct array { + // Use implicitly declared constructors and equality member functions as array + // is an aggregate type. + + METAL_FUNC constexpr size_t size() const thread { return N; } + METAL_FUNC constexpr size_t max_size() const thread { return N; } + METAL_FUNC constexpr bool empty() const thread { return N == 0; } + + METAL_FUNC thread T &front() thread { + assert(!empty()); + return __elems[0]; + } + METAL_FUNC constexpr const thread T &front() const thread { + assert(!empty()); + return __elems[0]; + } + + METAL_FUNC thread T &back() thread { + assert(!empty()); + return __elems[N - (N != 0)]; + } + METAL_FUNC constexpr const thread T &back() const thread { + assert(!empty()); + return __elems[N - (N != 0)]; + } + + METAL_FUNC thread T &operator[](size_t pos) thread { + assert(pos < size()); + return __elems[pos]; + } + METAL_FUNC constexpr const thread T &operator[](size_t pos) const thread { + assert(pos < size()); + return __elems[pos]; + } + + METAL_FUNC thread T *data() thread { return __elems; } + METAL_FUNC constexpr const thread T *data() const thread { return __elems; } + + METAL_FUNC constexpr size_t size() const device { return N; } + METAL_FUNC constexpr size_t max_size() const device { return N; } + METAL_FUNC constexpr bool empty() const device { return N == 0; } + + METAL_FUNC device T &front() device { + assert(!empty()); + return __elems[0]; + } + METAL_FUNC constexpr const device T &front() const device { + assert(!empty()); + return __elems[0]; + } + + METAL_FUNC device T &back() device { + assert(!empty()); + return __elems[N - (N != 0)]; + } + METAL_FUNC constexpr const device T &back() const device { + assert(!empty()); + return __elems[N - (N != 0)]; + } + + METAL_FUNC device T &operator[](size_t pos) device { + assert(pos < size()); + return __elems[pos]; + } + METAL_FUNC constexpr const device T &operator[](size_t pos) const device { + assert(pos < size()); + return __elems[pos]; + } + + METAL_FUNC device T *data() device { return __elems; } + METAL_FUNC constexpr const device T *data() const device { return __elems; } + + METAL_FUNC constexpr size_t size() const constant { return N; } + METAL_FUNC constexpr size_t max_size() const constant { return N; } + METAL_FUNC constexpr bool empty() const constant { return N == 0; } + + METAL_FUNC constexpr const constant T &front() const constant { + assert(!empty()); + return __elems[0]; + } + + METAL_FUNC constexpr const constant T &back() const constant { + assert(!empty()); + return __elems[N - (N != 0)]; + } + + METAL_FUNC constexpr const constant T &operator[](size_t pos) const constant { + assert(pos < size()); + return __elems[pos]; + } + + METAL_FUNC constexpr const constant T *data() const constant { return __elems; } + + METAL_FUNC constexpr size_t size() const threadgroup { return N; } + METAL_FUNC constexpr size_t max_size() const threadgroup { return N; } + METAL_FUNC constexpr bool empty() const threadgroup { return N == 0; } + + METAL_FUNC threadgroup T &front() threadgroup { + assert(!empty()); + return __elems[0]; + } + METAL_FUNC constexpr const threadgroup T &front() const threadgroup { + assert(!empty()); + return __elems[0]; + } + + METAL_FUNC threadgroup T &back() threadgroup { + assert(!empty()); + return __elems[N - (N != 0)]; + } + METAL_FUNC constexpr const threadgroup T &back() const threadgroup { + assert(!empty()); + return __elems[N - (N != 0)]; + } + + METAL_FUNC threadgroup T &operator[](size_t pos) threadgroup { + assert(pos < size()); + return __elems[pos]; + } + METAL_FUNC constexpr const threadgroup T &operator[](size_t pos) const threadgroup { + assert(pos < size()); + return __elems[pos]; + } + + METAL_FUNC threadgroup T *data() threadgroup { return __elems; } + METAL_FUNC constexpr const threadgroup T *data() const threadgroup { return __elems; } + + + + T __elems[N ? N : 1]; +}; + +template +struct array_ref { + METAL_FUNC constexpr array_ref() thread : d(nullptr), sz(0) {} + METAL_FUNC constexpr array_ref(const thread T &elt) thread : d(&elt), sz(1) {} + METAL_FUNC constexpr array_ref(const thread T *data, size_t size) thread : d(data), sz(size) {} + template METAL_FUNC constexpr array_ref(const thread T (&data)[N]) thread : d(data), sz(N) {} + template METAL_FUNC constexpr array_ref(const thread array &data) thread : d(data.data()), sz(data.size()) {} + + METAL_FUNC constexpr size_t size() const thread { return sz; } + METAL_FUNC constexpr bool empty() const thread { return sz == 0; } + + METAL_FUNC constexpr const thread T &front() const thread { + assert(!empty()); + return d[0]; + } + METAL_FUNC constexpr const thread T &back() const thread { + assert(!empty()); + return d[sz - 1]; + } + METAL_FUNC constexpr const thread T &operator[](size_t pos) const thread { + assert(pos < size()); + return d[pos]; + } + METAL_FUNC constexpr const thread T *data() const thread { return d; } + +private: + const thread T *d; + size_t sz; +}; + +template +struct array_ref { + METAL_FUNC constexpr array_ref() thread : d(nullptr), sz(0) {} + METAL_FUNC constexpr array_ref(const device T &elt) thread : d(&elt), sz(1) {} + METAL_FUNC constexpr array_ref(const device T *data, size_t size) thread : d(data), sz(size) {} + template METAL_FUNC constexpr array_ref(const device T (&data)[N]) thread : d(data), sz(N) {} + template METAL_FUNC constexpr array_ref(const device array &data) thread : d(data.data()), sz(data.size()) {} + + METAL_FUNC constexpr size_t size() const thread { return sz; } + METAL_FUNC constexpr bool empty() const thread { return sz == 0; } + + METAL_FUNC constexpr const device T &front() const thread { + assert(!empty()); + return d[0]; + } + METAL_FUNC constexpr const device T &back() const thread { + assert(!empty()); + return d[sz - 1]; + } + METAL_FUNC constexpr const device T &operator[](size_t pos) const thread { + assert(pos < size()); + return d[pos]; + } + METAL_FUNC constexpr const device T *data() const thread { return d; } + +private: + const device T *d; + size_t sz; +}; + +template +struct array_ref { + METAL_FUNC constexpr array_ref() thread : d(nullptr), sz(0) {} + METAL_FUNC constexpr array_ref(const constant T &elt) thread : d(&elt), sz(1) {} + METAL_FUNC constexpr array_ref(const constant T *data, size_t size) thread : d(data), sz(size) {} + template METAL_FUNC constexpr array_ref(const constant T (&data)[N]) thread : d(data), sz(N) {} + template METAL_FUNC constexpr array_ref(const constant array &data) thread : d(data.data()), sz(data.size()) {} + + METAL_FUNC constexpr size_t size() const thread { return sz; } + METAL_FUNC constexpr bool empty() const thread { return sz == 0; } + + METAL_FUNC constexpr const constant T &front() const thread { + assert(!empty()); + return d[0]; + } + METAL_FUNC constexpr const constant T &back() const thread { + assert(!empty()); + return d[sz - 1]; + } + METAL_FUNC constexpr const constant T &operator[](size_t pos) const thread { + assert(pos < size()); + return d[pos]; + } + METAL_FUNC constexpr const constant T *data() const thread { return d; } + +private: + const constant T *d; + size_t sz; +}; + +template +struct array_ref { + METAL_FUNC constexpr array_ref() thread : d(nullptr), sz(0) {} + METAL_FUNC constexpr array_ref(const threadgroup T &elt) thread : d(&elt), sz(1) {} + METAL_FUNC constexpr array_ref(const threadgroup T *data, size_t size) thread : d(data), sz(size) {} + template METAL_FUNC constexpr array_ref(const threadgroup T (&data)[N]) thread : d(data), sz(N) {} + template METAL_FUNC constexpr array_ref(const threadgroup array &data) thread : d(data.data()), sz(data.size()) {} + + METAL_FUNC constexpr size_t size() const thread { return sz; } + METAL_FUNC constexpr bool empty() const thread { return sz == 0; } + + METAL_FUNC constexpr const threadgroup T &front() const thread { + assert(!empty()); + return d[0]; + } + METAL_FUNC constexpr const threadgroup T &back() const thread { + assert(!empty()); + return d[sz - 1]; + } + METAL_FUNC constexpr const threadgroup T &operator[](size_t pos) const thread { + assert(pos < size()); + return d[pos]; + } + METAL_FUNC constexpr const threadgroup T *data() const thread { return d; } + +private: + const threadgroup T *d; + size_t sz; +}; + + +template +METAL_FUNC constexpr array_ref make_array_ref(const thread T &elt) { return array_ref(elt); } +template +METAL_FUNC constexpr array_ref make_array_ref(const thread T *data, size_t size) { return array_ref(data, size); } +template +METAL_FUNC constexpr array_ref make_array_ref(const thread T (&data)[N]) { return array_ref(data); } +template +METAL_FUNC constexpr array_ref make_array_ref(const thread array &data) { return array_ref(data); } + +template +METAL_FUNC constexpr array_ref make_array_ref(const device T &elt) { return array_ref(elt); } +template +METAL_FUNC constexpr array_ref make_array_ref(const device T *data, size_t size) { return array_ref(data, size); } +template +METAL_FUNC constexpr array_ref make_array_ref(const device T (&data)[N]) { return array_ref(data); } +template +METAL_FUNC constexpr array_ref make_array_ref(const device array &data) { return array_ref(data); } + +template +METAL_FUNC constexpr array_ref make_array_ref(const constant T &elt) { return array_ref(elt); } +template +METAL_FUNC constexpr array_ref make_array_ref(const constant T *data, size_t size) { return array_ref(data, size); } +template +METAL_FUNC constexpr array_ref make_array_ref(const constant T (&data)[N]) { return array_ref(data); } +template +METAL_FUNC constexpr array_ref make_array_ref(const constant array &data) { return array_ref(data); } + +template +METAL_FUNC constexpr array_ref make_array_ref(const threadgroup T &elt) { return array_ref(elt); } +template +METAL_FUNC constexpr array_ref make_array_ref(const threadgroup T *data, size_t size) { return array_ref(data, size); } +template +METAL_FUNC constexpr array_ref make_array_ref(const threadgroup T (&data)[N]) { return array_ref(data); } +template +METAL_FUNC constexpr array_ref make_array_ref(const threadgroup array &data) { return array_ref(data); } + + + +} +#endif // defined(__HAVE_ARRAY__) + +#endif // __METAL_ARRAY diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_assert b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_assert new file mode 100644 index 00000000..83867ff1 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_assert @@ -0,0 +1,18 @@ +//===-- metal_assert ------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_ASSERT +#define __METAL_ASSERT + +// TODO: This header is intended for internal use only and it is subject to +// changes -- seet + +#if defined(NDEBUG) || !defined(__HAVE_ASSERT__) +#define assert(condition) ((void) 0) +#else +// TODO: To be implemented -- see +#define assert(condition) ((void) 0) +#endif + +#endif // __METAL_ASSERT diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_atomic b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_atomic new file mode 100644 index 00000000..aacd093e --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_atomic @@ -0,0 +1,198 @@ +//===-- metal_atomic ------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_ATOMIC +#define __METAL_ATOMIC + +#include + +namespace metal +{ +// Metal 1.1 s2.3: Atomic Data Types. + +template +struct _atomic +{ + _atomic() threadgroup = default; + _atomic() device = delete; + _atomic(const threadgroup _atomic &) threadgroup = delete; + _atomic(const device _atomic &) threadgroup = delete; + _atomic(const threadgroup _atomic &) device = delete; + _atomic(const device _atomic &) device = delete; + threadgroup _atomic &operator=(const threadgroup _atomic &) threadgroup = delete; + threadgroup _atomic &operator=(const device _atomic &) threadgroup = delete; + device _atomic &operator=(const threadgroup _atomic &) device = delete; + device _atomic &operator=(const device _atomic &) device = delete; +}; + +template +struct _atomic, is_same>::value>::type> +{ + _atomic() threadgroup = default; + _atomic() device = delete; + _atomic(const threadgroup _atomic &) threadgroup = delete; + _atomic(const device _atomic &) threadgroup = delete; + _atomic(const threadgroup _atomic &) device = delete; + _atomic(const device _atomic &) device = delete; + threadgroup _atomic &operator=(const threadgroup _atomic &) threadgroup = delete; + threadgroup _atomic &operator=(const device _atomic &) threadgroup = delete; + device _atomic &operator=(const threadgroup _atomic &) device = delete; + device _atomic &operator=(const device _atomic &) device = delete; + + T __s; +}; +typedef _atomic atomic_int; +typedef _atomic atomic_uint; + + +// TODO: Add section number and title -- see . +// Metal 2.0 sX.Y: Title. + + +// Metal 1.1 s5.12.1: Atomic Store Functions. + +#if defined(__HAVE_RELAXED_ORDER_ATOMIC__) +#define METAL_VALID_STORE_ORDER(O) +#endif + +template ::value>::type> +METAL_FUNC void atomic_store_explicit(volatile threadgroup _atomic *object, U desired, memory_order order) METAL_CONST_ARG(order) METAL_VALID_STORE_ORDER(order) +{ + __metal_atomic_store_explicit(&object->__s, decltype(object->__s)(desired), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template ::value>::type> +METAL_FUNC void atomic_store_explicit(volatile device _atomic *object, U desired, memory_order order) METAL_CONST_ARG(order) METAL_VALID_STORE_ORDER(order) +{ + __metal_atomic_store_explicit(&object->__s, decltype(object->__s)(desired), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} + +#if defined(__HAVE_RELAXED_ORDER_ATOMIC__) +#define METAL_VALID_LOAD_ORDER(O) +#endif + +// Metal 1.1 s5.12.2: Atomic Load Functions. + +template +METAL_FUNC T atomic_load_explicit(const volatile threadgroup _atomic *object, memory_order order) METAL_CONST_ARG(order) METAL_VALID_LOAD_ORDER(order) +{ + return T(__metal_atomic_load_explicit(&object->__s, int(order), __METAL_MEMORY_SCOPE_THREADGROUP__)); +} +template +METAL_FUNC T atomic_load_explicit(const volatile device _atomic *object, memory_order order) METAL_CONST_ARG(order) METAL_VALID_LOAD_ORDER(order) +{ + return T(__metal_atomic_load_explicit(&object->__s, int(order), __METAL_MEMORY_SCOPE_DEVICE__)); +} + +// Metal 1.1 s5.12.3: Atomic Exchange Functions. + +template ::value>::type> +METAL_FUNC T atomic_exchange_explicit(volatile threadgroup _atomic *object, U desired, memory_order order) METAL_CONST_ARG(order) +{ + return T(__metal_atomic_exchange_explicit(&object->__s, decltype(object->__s)(desired), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__)); +} +template ::value>::type> +METAL_FUNC T atomic_exchange_explicit(volatile device _atomic *object, U desired, memory_order order) METAL_CONST_ARG(order) +{ + return T(__metal_atomic_exchange_explicit(&object->__s , decltype(object->__s)(desired), int(order), __METAL_MEMORY_SCOPE_DEVICE__)); +} + +// Metal 1.1 s5.12.4: Atomic Compare and Exchange Functions. + +#if defined(__HAVE_RELAXED_ORDER_ATOMIC__) +#define METAL_VALID_COMPARE_EXCHANGE_FAILURE_ORDER(O) +#define METAL_COMPATIBLE_COMPARE_EXCHANGE_ORDERS(S, F) +#endif + +template ::value>::type> +METAL_FUNC bool atomic_compare_exchange_weak_explicit(volatile threadgroup _atomic *object, thread T *expected, U desired, memory_order success, memory_order failure) METAL_CONST_ARG(success) METAL_CONST_ARG(failure) METAL_VALID_COMPARE_EXCHANGE_FAILURE_ORDER(failure) METAL_COMPATIBLE_COMPARE_EXCHANGE_ORDERS(success, failure) +{ + decltype(object->__s) next_expected(*expected); + bool swapped = __metal_atomic_compare_exchange_weak_explicit(&object->__s, &next_expected, decltype(object->__s)(desired), int(success), int(failure), __METAL_MEMORY_SCOPE_THREADGROUP__); + *expected = T(next_expected); + return swapped; +} +template ::value>::type> +METAL_FUNC bool atomic_compare_exchange_weak_explicit(volatile device _atomic *object, thread T *expected, U desired, memory_order success, memory_order failure) METAL_CONST_ARG(success) METAL_CONST_ARG(failure) METAL_VALID_COMPARE_EXCHANGE_FAILURE_ORDER(failure) METAL_COMPATIBLE_COMPARE_EXCHANGE_ORDERS(success, failure) +{ + decltype(object->__s) next_expected(*expected); + bool swapped = __metal_atomic_compare_exchange_weak_explicit(&object->__s, &next_expected, decltype(object->__s)(desired), int(success), int(failure), __METAL_MEMORY_SCOPE_DEVICE__); + *expected = T(next_expected); + return swapped; +} + +// Metal 1.1 s5.12.5: Atomic Fetch and Modify Functions. + +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_add_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_add_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_add_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_add_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_and_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_and_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_and_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_and_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_max_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_max_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_max_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_max_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_min_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_min_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_min_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_min_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_or_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_or_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_or_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_or_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_sub_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_sub_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_sub_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_sub_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_xor_explicit(volatile threadgroup _atomic *object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_xor_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +template , is_same>::value && is_convertible::value>::type> +METAL_FUNC T atomic_fetch_xor_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_xor_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} +} // namespace metal + +#endif // __METAL_ATOMIC diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_common b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_common new file mode 100644 index 00000000..e4dea906 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_common @@ -0,0 +1,86 @@ +//===-- metal_common ------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_COMMON +#define __METAL_COMMON + +#include + +// Metal 1.1 s5.2: Common Functions. + +namespace metal +{ + +namespace fast +{ +template ::value, _math_fast_or_precise_ternary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O clamp(T x, U minval, V maxval) +{ + return __metal_clamp(_O(x), _O(minval), _O(maxval), _METAL_FAST_MATH); +} + +template >::value>::type> +METAL_FUNC T saturate(T x) +{ + return __metal_saturate(x, _METAL_FAST_MATH); +} +} // namespace fast + +namespace precise +{ +template ::value, _math_fast_or_precise_ternary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O clamp(T x, U minval, V maxval) +{ + return __metal_clamp(_O(x), _O(minval), _O(maxval), _METAL_PRECISE_MATH); +} + +template >::value>::type> +METAL_FUNC T saturate(T x) +{ + return __metal_saturate(x, _METAL_PRECISE_MATH); +} +} // namespace precise + +template ::value, _math_ternary_func_operand_type_t>::type> +METAL_FUNC _O clamp(T x, U minval, V maxval) +{ + return __metal_clamp(_O(x), _O(minval), _O(maxval), _METAL_MAYBE_FAST_MATH); +} + +template ::value>::type> +METAL_FUNC T saturate(T x) +{ + return __metal_saturate(x, _METAL_MAYBE_FAST_MATH); +} +} // namespace metal + +namespace metal +{ +template ::value, _math_ternary_func_operand_type_t>::type> +METAL_FUNC _O mix(T x, U y, V a) +{ + return __metal_mix(_O(x), _O(y), _O(a)); +} + +template ::value>::type> +METAL_FUNC T sign(T x) +{ + return __metal_sign(x); +} + +template ::value, _math_ternary_func_operand_type_t>::type> +METAL_FUNC _O smoothstep(T edge0, U edge1, V x) +{ + _O t = clamp((_O(x) - _O(edge0)) / (_O(edge1) - _O(edge0)), _O(0), _O(1)); + return t * t * (_O(3) - _O(2) * t); +} + +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O step(T edge, U x) +{ + return _O(_O(x) >= _O(edge)); +} +} // namespace metal + +#endif // __METAL_COMMON diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_compute b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_compute new file mode 100644 index 00000000..620814de --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_compute @@ -0,0 +1,80 @@ +//===-- metal_compute -----------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_COMPUTE +#define __METAL_COMPUTE + +namespace metal +{ +// Metal 1.1 s5.8: Compute Functions. + +enum class mem_flags +{ + mem_none = 0, + mem_device = 1, + mem_threadgroup = 2, +#if defined(__HAVE_TEXTURE_READWRITE__) + mem_texture = 4, +#endif + mem_device_and_threadgroup METAL_DEPRECATED("use mem_device or mem_threadgroup instead") = mem_device | mem_threadgroup +}; + +#if defined(__HAVE_MEMFLAG_OPERATORS__) +METAL_FUNC constexpr mem_flags operator|(mem_flags x, mem_flags y) +{ + return static_cast(static_cast(x) | static_cast(y)); +} + +METAL_FUNC constexpr mem_flags operator&(mem_flags x, mem_flags y) +{ + return static_cast(static_cast(x) & static_cast(y)); +} + +METAL_FUNC constexpr mem_flags operator^(mem_flags x, mem_flags y) +{ + return static_cast(static_cast(x) ^ static_cast(y)); +} + +METAL_FUNC constexpr mem_flags operator~(mem_flags x) +{ + return static_cast(~static_cast(x)); +} +#endif + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" +template <> +struct _constarg_traits +{ + constexpr static METAL_INTERNAL bool check(mem_flags flags) + { + return flags == flags; + } +}; +#pragma clang diagnostic pop + +METAL_FUNC void threadgroup_barrier(mem_flags flags) +{ + __metal_wg_barrier(int(flags), __METAL_MEMORY_SCOPE_THREADGROUP__); +} + +#if defined(__HAVE_SIMDGROUP_BARRIER__) +METAL_FUNC void simdgroup_barrier(mem_flags flags) +{ + // TODO: We should be using _METAL_MEM_SCOPE_WORKGROUP -- see . + __metal_simdgroup_barrier(int(flags), __METAL_MEMORY_SCOPE_THREADGROUP__); +} +#endif // defined(__HAVE_SIMDGROUP_BARRIER__) + +#if defined(__HAVE_DRAW_INDIRECT__) +struct MTLDispatchThreadgroupsIndirectArguments +{ + uint threadgroupsPerGrid[3]; +}; +#endif + + +} // namespace metal + +#endif // __METAL_COMPUTE diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_config b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_config new file mode 100644 index 00000000..78e26576 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_config @@ -0,0 +1,323 @@ +#ifndef __METAL_CONFIG +#define __METAL_CONFIG + +#if __METAL_VERSION__ == 100 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_IGNORE_ATTRIBUTE_INCOMPATIBLE_TYPE__ 1 +#define __HAVE_NO_ADDR_SPACE_REF__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_VECTOR_CONVERSION_IN_ARRAY_INIT__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __METAL_VERSION__ == 110 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_IGNORE_ATTRIBUTE_INCOMPATIBLE_TYPE__ 1 +#define __HAVE_NO_ADDR_SPACE_REF__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_VECTOR_CONVERSION_IN_ARRAY_INIT__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __METAL_VERSION__ == 120 +#define __HAVE_16B_COORDS__ 1 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_BORDER_COLOR__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_EARLY_FRAGMENT_TEST__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_FUNCTION_CONSTANTS__ 1 +#define __HAVE_IGNORE_ATTRIBUTE_INCOMPATIBLE_TYPE__ 1 +#define __HAVE_INTEGER_BIT_EDIT_FUNCTIONS__ 1 +#define __HAVE_MEMFLAG_OPERATORS__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_TESSELLATION__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TEXTURE_READWRITE__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_FRAGMENT__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_VERTEX__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_UNIONS__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __METAL_VERSION__ == 200 +#define __HAVE_16B_COORDS__ 1 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_ANISOTROPY_LOD_MIN_MAX__ 1 +#define __HAVE_ARBITRARY_GRID_SIZE__ 1 +#define __HAVE_ARRAY__ 1 +#define __HAVE_ARRAYS_OF_SAMPLERS__ 1 +#define __HAVE_ARRAYS_OF_TEXTURES__ 1 +#define __HAVE_BORDER_COLOR__ 1 +#define __HAVE_COPY_ASSIGNABLE_TEXTURE__ 1 +#define __HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__ 1 +#define __HAVE_DEPENDENT_BUFFER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_COLOR_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_SAMPLER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_TEXTURE_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_THREADGROUP_ATTRIBUTE__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_EARLY_FRAGMENT_TEST__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_FUNCTION_CONSTANTS__ 1 +#define __HAVE_INDIRECT_ARGUMENT_BUFFER__ 1 +#define __HAVE_INDIRECT_WRITABLE_TEXTURES__ 1 +#define __HAVE_INTEGER_BIT_EDIT_FUNCTIONS__ 1 +#define __HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__ 1 +#define __HAVE_MEMFLAG_OPERATORS__ 1 +#define __HAVE_NON_CONSTEXPR_ATTRIBUTE_INDICES__ 1 +#define __HAVE_NULL_TEXTURE__ 1 +#define __HAVE_QUADGROUP__ 1 +#define __HAVE_RASTER_ORDER_GROUP__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_SIMDGROUP__ 1 +#define __HAVE_SIMDGROUP_BARRIER__ 1 +#define __HAVE_TESSELLATION__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TEXTURE_READWRITE__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_FRAGMENT__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_VERTEX__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_UNIFORM__ 1 +#define __HAVE_UNIONS__ 1 +#define __HAVE_VIEWPORT_ARRAY_INDEX__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __METAL_VERSION__ == 210 +#define __HAVE_16B_COORDS__ 1 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_ANISOTROPY_LOD_MIN_MAX__ 1 +#define __HAVE_ARBITRARY_GRID_SIZE__ 1 +#define __HAVE_ARRAY__ 1 +#define __HAVE_ARRAYS_OF_SAMPLERS__ 1 +#define __HAVE_ARRAYS_OF_TEXTURES__ 1 +#define __HAVE_BORDER_COLOR__ 1 +#define __HAVE_COPY_ASSIGNABLE_TEXTURE__ 1 +#define __HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__ 1 +#define __HAVE_DEPENDENT_BUFFER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_COLOR_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_SAMPLER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_TEXTURE_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_THREADGROUP_ATTRIBUTE__ 1 +#define __HAVE_DEPTH_2D_MS_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DISCARD_FRAGMENT_NORETURN__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_EARLY_FRAGMENT_TEST__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_FMAX3__ 1 +#define __HAVE_FMEDIAN3__ 1 +#define __HAVE_FMIN3__ 1 +#define __HAVE_FUNCTION_CONSTANTS__ 1 +#define __HAVE_INDIRECT_ARGUMENT_BUFFER__ 1 +#define __HAVE_INDIRECT_NON_STRUCT_BUFFERS__ 1 +#define __HAVE_INDIRECT_WRITABLE_TEXTURES__ 1 +#define __HAVE_INHERITANCE__ 1 +#define __HAVE_INTEGER_BIT_EDIT_FUNCTIONS__ 1 +#define __HAVE_MAD24__ 1 +#define __HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__ 1 +#define __HAVE_MAX3__ 1 +#define __HAVE_MAX_TOTAL_THREADS_PER_THREADGROUP__ 1 +#define __HAVE_MEDIAN3__ 1 +#define __HAVE_MEMFLAG_OPERATORS__ 1 +#define __HAVE_MIN3__ 1 +#define __HAVE_MUL24__ 1 +#define __HAVE_NON_CONSTEXPR_ATTRIBUTE_INDICES__ 1 +#define __HAVE_NULL_TEXTURE__ 1 +#define __HAVE_PACKED_VECTOR_COMPONENTS__ 1 +#define __HAVE_PROHIBIT_CXX11_DECL_SPEC_ATTRS__ 1 +#define __HAVE_QUADGROUP__ 1 +#define __HAVE_QUADGROUP_BALLOT__ 1 +#define __HAVE_QUADGROUP_BROADCAST_FIRST__ 1 +#define __HAVE_QUADGROUP_ONCE__ 1 +#define __HAVE_QUADGROUP_REDUCTION__ 1 +#define __HAVE_QUADGROUP_SHUFFLE_ROTATE_DOWN__ 1 +#define __HAVE_QUADGROUP_SHUFFLE_ROTATE_UP__ 1 +#define __HAVE_RASTER_ORDER_GROUP__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_SAMPLER_REDUCTION__ 1 +#define __HAVE_SIMDGROUP__ 1 +#define __HAVE_SIMDGROUP_BALLOT__ 1 +#define __HAVE_SIMDGROUP_BARRIER__ 1 +#define __HAVE_SIMDGROUP_BROADCAST_FIRST__ 1 +#define __HAVE_SIMDGROUP_ONCE__ 1 +#define __HAVE_SIMDGROUP_REDUCTION__ 1 +#define __HAVE_SIMDGROUP_SHUFFLE_ROTATE_DOWN__ 1 +#define __HAVE_SIMDGROUP_SHUFFLE_ROTATE_UP__ 1 +#define __HAVE_STENCIL_FEEDBACK__ 1 +#define __HAVE_TESSELLATION__ 1 +#define __HAVE_TEXTURE_2D_MS_ARRAY__ 1 +#define __HAVE_TEXTURE_BUFFER__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TEXTURE_READWRITE__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_FRAGMENT__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_VERTEX__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_UNBOXED_PACKED_VECTORS__ 1 +#define __HAVE_UNIFORM__ 1 +#define __HAVE_UNIONS__ 1 +#define __HAVE_VIEWPORT_ARRAY_INDEX__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __METAL_VERSION__ == 220 +#define __HAVE_16B_COORDS__ 1 +#define __HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__ 1 +#define __HAVE_ANISOTROPY_LOD_MIN_MAX__ 1 +#define __HAVE_ARBITRARY_GRID_SIZE__ 1 +#define __HAVE_ARRAY__ 1 +#define __HAVE_ARRAYS_OF_SAMPLERS__ 1 +#define __HAVE_ARRAYS_OF_TEXTURES__ 1 +#define __HAVE_BORDER_COLOR__ 1 +#define __HAVE_COPY_ASSIGNABLE_TEXTURE__ 1 +#define __HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__ 1 +#define __HAVE_DEPENDENT_BUFFER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_COLOR_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_SAMPLER_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_TEXTURE_ATTRIBUTE__ 1 +#define __HAVE_DEPENDENT_THREADGROUP_ATTRIBUTE__ 1 +#define __HAVE_DEPTH_2D_MS_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_ARRAY__ 1 +#define __HAVE_DEPTH_CUBE_READ__ 1 +#define __HAVE_DISCARD_FRAGMENT_NORETURN__ 1 +#define __HAVE_DRAW_INDIRECT__ 1 +#define __HAVE_EARLY_FRAGMENT_TEST__ 1 +#define __HAVE_FMA__ 1 +#define __HAVE_FMAX3__ 1 +#define __HAVE_FMEDIAN3__ 1 +#define __HAVE_FMIN3__ 1 +#define __HAVE_FUNCTION_CONSTANTS__ 1 +#define __HAVE_INDIRECT_ARGUMENT_BUFFER__ 1 +#define __HAVE_INDIRECT_COMMAND_BUFFER__ 1 +#define __HAVE_INDIRECT_NON_STRUCT_BUFFERS__ 1 +#define __HAVE_INDIRECT_WRITABLE_TEXTURES__ 1 +#define __HAVE_INHERITANCE__ 1 +#define __HAVE_INTEGER_BIT_EDIT_FUNCTIONS__ 1 +#define __HAVE_MAD24__ 1 +#define __HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__ 1 +#define __HAVE_MAX3__ 1 +#define __HAVE_MAX_TOTAL_THREADS_PER_THREADGROUP__ 1 +#define __HAVE_MEDIAN3__ 1 +#define __HAVE_MEMFLAG_OPERATORS__ 1 +#define __HAVE_MIN3__ 1 +#define __HAVE_MIN_LOD_CLAMP__ 1 +#define __HAVE_MUL24__ 1 +#define __HAVE_NON_CONSTEXPR_ATTRIBUTE_INDICES__ 1 +#define __HAVE_NULL_TEXTURE__ 1 +#define __HAVE_PACKED_VECTOR_COMPONENTS__ 1 +#define __HAVE_PROHIBIT_CXX11_DECL_SPEC_ATTRS__ 1 +#define __HAVE_QUADGROUP__ 1 +#define __HAVE_QUADGROUP_BALLOT__ 1 +#define __HAVE_QUADGROUP_BROADCAST_FIRST__ 1 +#define __HAVE_QUADGROUP_ONCE__ 1 +#define __HAVE_QUADGROUP_REDUCTION__ 1 +#define __HAVE_QUADGROUP_SHUFFLE_ROTATE_DOWN__ 1 +#define __HAVE_QUADGROUP_SHUFFLE_ROTATE_UP__ 1 +#define __HAVE_RASTER_ORDER_GROUP__ 1 +#define __HAVE_RELAXED_ORDER_ATOMIC__ 1 +#define __HAVE_RENDER_TARGET_ARRAY_INDEX__ 1 +#define __HAVE_SAMPLER_REDUCTION__ 1 +#define __HAVE_SIMDGROUP__ 1 +#define __HAVE_SIMDGROUP_BALLOT__ 1 +#define __HAVE_SIMDGROUP_BARRIER__ 1 +#define __HAVE_SIMDGROUP_BROADCAST_FIRST__ 1 +#define __HAVE_SIMDGROUP_ONCE__ 1 +#define __HAVE_SIMDGROUP_REDUCTION__ 1 +#define __HAVE_SIMDGROUP_SHUFFLE_ROTATE_DOWN__ 1 +#define __HAVE_SIMDGROUP_SHUFFLE_ROTATE_UP__ 1 +#define __HAVE_SPARSE_TEXTURES__ 1 +#define __HAVE_STENCIL_FEEDBACK__ 1 +#define __HAVE_TESSELLATION__ 1 +#define __HAVE_TEXTURE_2D_MS_ARRAY__ 1 +#define __HAVE_TEXTURE_BUFFER__ 1 +#define __HAVE_TEXTURE_CUBE_ARRAY__ 1 +#define __HAVE_TEXTURE_CUBE_READ__ 1 +#define __HAVE_TEXTURE_CUBE_WRITE__ 1 +#define __HAVE_TEXTURE_READWRITE__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_FRAGMENT__ 1 +#define __HAVE_TEXTURE_WRITABLE_FROM_VERTEX__ 1 +#define __HAVE_TRACING__ 1 +#define __HAVE_TRIG_PI__ 1 +#define __HAVE_UNBOXED_PACKED_VECTORS__ 1 +#define __HAVE_UNIFORM__ 1 +#define __HAVE_UNIONS__ 1 +#define __HAVE_VIEWPORT_ARRAY_INDEX__ 1 +#define __HAVE_ZERO_LOD_ARG__ 1 +#endif + +#if __AIR_VERSION__ == 10800 +#define __HAVE_AIR_FRACT__ 1 +#define __HAVE_AIR_LDEXP__ 1 +#define __HAVE_CLZ_ZERO_UNDEF__ 1 +#define __HAVE_CTZ_ZERO_UNDEF__ 1 +#endif + +#if __AIR_VERSION__ == 11100 +#define __HAVE_AIR_FRACT__ 1 +#define __HAVE_AIR_LDEXP__ 1 +#define __HAVE_CLZ_ZERO_UNDEF__ 1 +#define __HAVE_CTZ_ZERO_UNDEF__ 1 +#endif + +#if __AIR_VERSION__ == 20000 +#define __HAVE_AIR_FRACT__ 1 +#define __HAVE_AIR_LDEXP__ 1 +#define __HAVE_CLZ_ZERO_UNDEF__ 1 +#define __HAVE_CTZ_ZERO_UNDEF__ 1 +#endif + +#if __AIR_VERSION__ == 20100 +#define __HAVE_AIR_FRACT__ 1 +#define __HAVE_AIR_LDEXP__ 1 +#define __HAVE_CLZ_ZERO_UNDEF__ 1 +#define __HAVE_CTZ_ZERO_UNDEF__ 1 +#endif + +#if __AIR_VERSION__ == 20200 +#define __HAVE_AIR_FRACT__ 1 +#define __HAVE_AIR_LDEXP__ 1 +#define __HAVE_CLZ_ZERO_UNDEF__ 1 +#define __HAVE_CTZ_ZERO_UNDEF__ 1 +#endif + + +#endif // __METAL_CONFIG diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_extended_vector b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_extended_vector new file mode 100644 index 00000000..22afbd93 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_extended_vector @@ -0,0 +1,278 @@ +//===-- metal_extended_vector ---------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_EXTENDED_VECTOR +#define __METAL_EXTENDED_VECTOR + +typedef __attribute__((__ext_vector_type__(2))) bool bool2; +typedef __attribute__((__ext_vector_type__(3))) bool bool3; +typedef __attribute__((__ext_vector_type__(4))) bool bool4; +typedef struct __Reserved_Name__Do_not_use_bool8 bool8; +typedef struct __Reserved_Name__Do_not_use_bool16 bool16; + +typedef __attribute__((__ext_vector_type__(2))) char char2; +typedef __attribute__((__ext_vector_type__(3))) char char3; +typedef __attribute__((__ext_vector_type__(4))) char char4; +typedef struct __Reserved_Name__Do_not_use_char8 char8; +typedef struct __Reserved_Name__Do_not_use_char16 char16; + +typedef __attribute__((__ext_vector_type__(2))) unsigned char uchar2; +typedef __attribute__((__ext_vector_type__(3))) unsigned char uchar3; +typedef __attribute__((__ext_vector_type__(4))) unsigned char uchar4; +typedef struct __Reserved_Name__Do_not_use_uchar16 uchar8; +typedef struct __Reserved_Name__Do_not_use_uchar16 uchar16; + +typedef __attribute__((__ext_vector_type__(2))) short short2; +typedef __attribute__((__ext_vector_type__(3))) short short3; +typedef __attribute__((__ext_vector_type__(4))) short short4; +typedef struct __Reserved_Name__Do_not_use_short8 short8; +typedef struct __Reserved_Name__Do_not_use_short16 short16; + +typedef __attribute__((__ext_vector_type__(2))) unsigned short ushort2; +typedef __attribute__((__ext_vector_type__(3))) unsigned short ushort3; +typedef __attribute__((__ext_vector_type__(4))) unsigned short ushort4; +typedef struct __Reserved_Name__Do_not_use_ushort8 ushort8; +typedef struct __Reserved_Name__Do_not_use_ushort16 ushort16; + +typedef __attribute__((__ext_vector_type__(2))) int int2; +typedef __attribute__((__ext_vector_type__(3))) int int3; +typedef __attribute__((__ext_vector_type__(4))) int int4; +typedef struct __Reserved_Name__Do_not_use_int8 int8; +typedef struct __Reserved_Name__Do_not_use_int16 int16; + +typedef __attribute__((__ext_vector_type__(2))) unsigned int uint2; +typedef __attribute__((__ext_vector_type__(3))) unsigned int uint3; +typedef __attribute__((__ext_vector_type__(4))) unsigned int uint4; +typedef struct __Reserved_Name__Do_not_use_uint8 uint8; +typedef struct __Reserved_Name__Do_not_use_uint16 uint16; + +typedef struct __Reserved_Name__Do_not_use_long2 long2; +typedef struct __Reserved_Name__Do_not_use_long3 long3; +typedef struct __Reserved_Name__Do_not_use_long4 long4; +typedef struct __Reserved_Name__Do_not_use_long8 long8; +typedef struct __Reserved_Name__Do_not_use_long16 long16; + +typedef struct __Reserved_Name__Do_not_use_ulong2 ulong2; +typedef struct __Reserved_Name__Do_not_use_ulong3 ulong3; +typedef struct __Reserved_Name__Do_not_use_ulong4 ulong4; +typedef struct __Reserved_Name__Do_not_use_ulong8 ulong8; +typedef struct __Reserved_Name__Do_not_use_ulong16 ulong16; + +typedef struct __Reserved_Name__Do_not_use_llong2 llong2; +typedef struct __Reserved_Name__Do_not_use_llong3 llong3; +typedef struct __Reserved_Name__Do_not_use_llong4 llong4; +typedef struct __Reserved_Name__Do_not_use_llong8 llong8; +typedef struct __Reserved_Name__Do_not_use_llong16 llong16; + +typedef struct __Reserved_Name__Do_not_use_ullong2 ullong2; +typedef struct __Reserved_Name__Do_not_use_ullong3 ullong3; +typedef struct __Reserved_Name__Do_not_use_ullong4 ullong4; +typedef struct __Reserved_Name__Do_not_use_ullong8 ullong8; +typedef struct __Reserved_Name__Do_not_use_ullong16 ullong16; + +typedef __attribute__((__ext_vector_type__(2))) half half2; +typedef __attribute__((__ext_vector_type__(3))) half half3; +typedef __attribute__((__ext_vector_type__(4))) half half4; +typedef struct __Reserved_Name__Do_not_use_half8 half8; +typedef struct __Reserved_Name__Do_not_use_half16 half16; + +typedef __attribute__((__ext_vector_type__(2))) float float2; +typedef __attribute__((__ext_vector_type__(3))) float float3; +typedef __attribute__((__ext_vector_type__(4))) float float4; +typedef struct __Reserved_Name__Do_not_use_float8 float8; +typedef struct __Reserved_Name__Do_not_use_float16 float16; + +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef __attribute__((__ext_vector_type__(2))) double double2; +typedef __attribute__((__ext_vector_type__(3))) double double3; +typedef __attribute__((__ext_vector_type__(4))) double double4; +#else +typedef struct __Reserved_Name__Do_not_use_double2 double2; +typedef struct __Reserved_Name__Do_not_use_double3 double3; +typedef struct __Reserved_Name__Do_not_use_double4 double4; +#endif +typedef struct __Reserved_Name__Do_not_use_double8 double8; +typedef struct __Reserved_Name__Do_not_use_double16 double16; + +typedef struct __Reserved_Name__Do_not_use_quad2 quad2; +typedef struct __Reserved_Name__Do_not_use_quad3 quad3; +typedef struct __Reserved_Name__Do_not_use_quad4 quad4; +typedef struct __Reserved_Name__Do_not_use_quad8 quad8; +typedef struct __Reserved_Name__Do_not_use_quad16 quad16; + +typedef bool2 vector_bool2; +typedef bool3 vector_bool3; +typedef bool4 vector_bool4; +typedef bool8 vector_bool8; +typedef bool16 vector_bool16; + +typedef char2 vector_char2; +typedef char3 vector_char3; +typedef char4 vector_char4; +typedef char8 vector_char8; +typedef char16 vector_char16; + +typedef uchar2 vector_uchar2; +typedef uchar3 vector_uchar3; +typedef uchar4 vector_uchar4; +typedef uchar8 vector_uchar8; +typedef uchar16 vector_uchar16; + +typedef short2 vector_short2; +typedef short3 vector_short3; +typedef short4 vector_short4; +typedef short8 vector_short8; +typedef short16 vector_short16; + +typedef ushort2 vector_ushort2; +typedef ushort3 vector_ushort3; +typedef ushort4 vector_ushort4; +typedef ushort8 vector_ushort8; +typedef ushort16 vector_ushort16; + +typedef int2 vector_int2; +typedef int3 vector_int3; +typedef int4 vector_int4; +typedef int8 vector_int8; +typedef int16 vector_int16; + +typedef uint2 vector_uint2; +typedef uint3 vector_uint3; +typedef uint4 vector_uint4; +typedef uint8 vector_uint8; +typedef uint16 vector_uint16; + +typedef long2 vector_long2; +typedef long3 vector_long3; +typedef long4 vector_long4; +typedef long8 vector_long8; +typedef long16 vector_long16; + +typedef ulong2 vector_ulong2; +typedef ulong3 vector_ulong3; +typedef ulong4 vector_ulong4; +typedef ulong8 vector_ulong8; +typedef ulong16 vector_ulong16; + +typedef half2 vector_half2; +typedef half3 vector_half3; +typedef half4 vector_half4; +typedef half8 vector_half8; +typedef half16 vector_half16; + +typedef float2 vector_float2; +typedef float3 vector_float3; +typedef float4 vector_float4; +typedef float8 vector_float8; +typedef float16 vector_float16; + +typedef double2 vector_double2; +typedef double3 vector_double3; +typedef double4 vector_double4; +typedef double8 vector_double8; +typedef double16 vector_double16; + +typedef quad2 vector_quad2; +typedef quad3 vector_quad3; +typedef quad4 vector_quad4; +typedef quad8 vector_quad8; +typedef quad16 vector_quad16; + +namespace metal +{ +typedef ::bool2 bool2; +typedef ::bool3 bool3; +typedef ::bool4 bool4; +typedef ::bool8 bool8; +typedef ::bool16 bool16; + +typedef ::char2 char2; +typedef ::char3 char3; +typedef ::char4 char4; +typedef ::char8 char8; +typedef ::char16 char16; + +typedef ::uchar2 uchar2; +typedef ::uchar3 uchar3; +typedef ::uchar4 uchar4; +typedef ::uchar8 uchar8; +typedef ::uchar16 uchar16; + +typedef ::short2 short2; +typedef ::short3 short3; +typedef ::short4 short4; +typedef ::short8 short8; +typedef ::short16 short16; + +typedef ::ushort2 ushort2; +typedef ::ushort3 ushort3; +typedef ::ushort4 ushort4; +typedef ::ushort8 ushort8; +typedef ::ushort16 ushort16; + +typedef ::int2 int2; +typedef ::int3 int3; +typedef ::int4 int4; +typedef ::int8 int8; +typedef ::int16 int16; + +typedef ::uint2 uint2; +typedef ::uint3 uint3; +typedef ::uint4 uint4; +typedef ::uint8 uint8; +typedef ::uint16 uint16; + +typedef ::long2 long2; +typedef ::long3 long3; +typedef ::long4 long4; +typedef ::long8 long8; +typedef ::long16 long16; + +typedef ::ulong2 ulong2; +typedef ::ulong3 ulong3; +typedef ::ulong4 ulong4; +typedef ::ulong8 ulong8; +typedef ::ulong16 ulong16; + +typedef ::llong2 llong2; +typedef ::llong3 llong3; +typedef ::llong4 llong4; +typedef ::llong8 llong8; +typedef ::llong16 llong16; + +typedef ::ullong2 ullong2; +typedef ::ullong3 ullong3; +typedef ::ullong4 ullong4; +typedef ::ullong8 ullong8; +typedef ::ullong16 ullong16; + +typedef ::half2 half2; +typedef ::half3 half3; +typedef ::half4 half4; +typedef ::half8 half8; +typedef ::half16 half16; + +typedef ::float2 float2; +typedef ::float3 float3; +typedef ::float4 float4; +typedef ::float8 float8; +typedef ::float16 float16; + +typedef ::double2 double2; +typedef ::double3 double3; +typedef ::double4 double4; +typedef ::double8 double8; +typedef ::double16 double16; + +typedef ::quad2 quad2; +typedef ::quad3 quad3; +typedef ::quad4 quad4; +typedef ::quad8 quad8; +typedef ::quad16 quad16; + +template +using vec = T __attribute__((__ext_vector_type__(N))); +} + +#endif // __METAL_EXTENDED_VECTOR diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_functional b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_functional new file mode 100644 index 00000000..3d2add29 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_functional @@ -0,0 +1,230 @@ +//===-- metal_functional --------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_FUNCTIONAL +#define __METAL_FUNCTIONAL + +namespace metal +{ +template +struct plus +{ + typedef T first_argument_type; + typedef T second_argument_type; + typedef T result_type; + + T operator()(const thread T &a, const thread T &b) const thread + { + return a + b; + } + T operator()(const thread T &a, const device T &b) const thread + { + return a + b; + } + T operator()(const thread T &a, const constant T &b) const thread + { + return a + b; + } + T operator()(const thread T &a, const threadgroup T &b) const thread + { + return a + b; + } + T operator()(const device T &a, const thread T &b) const thread + { + return a + b; + } + T operator()(const device T &a, const device T &b) const thread + { + return a + b; + } + T operator()(const device T &a, const constant T &b) const thread + { + return a + b; + } + T operator()(const device T &a, const threadgroup T &b) const thread + { + return a + b; + } + T operator()(const constant T &a, const thread T &b) const thread + { + return a + b; + } + T operator()(const constant T &a, const device T &b) const thread + { + return a + b; + } + T operator()(const constant T &a, const constant T &b) const thread + { + return a + b; + } + T operator()(const constant T &a, const threadgroup T &b) const thread + { + return a + b; + } + T operator()(const threadgroup T &a, const thread T &b) const thread + { + return a + b; + } + T operator()(const threadgroup T &a, const device T &b) const thread + { + return a + b; + } + T operator()(const threadgroup T &a, const constant T &b) const thread + { + return a + b; + } + T operator()(const threadgroup T &a, const threadgroup T &b) const thread + { + return a + b; + } +}; + +template +struct minus +{ + typedef T first_argument_type; + typedef T second_argument_type; + typedef T result_type; + + T operator()(const thread T &a, const thread T &b) const thread + { + return a - b; + } + T operator()(const thread T &a, const device T &b) const thread + { + return a - b; + } + T operator()(const thread T &a, const constant T &b) const thread + { + return a - b; + } + T operator()(const thread T &a, const threadgroup T &b) const thread + { + return a - b; + } + T operator()(const device T &a, const thread T &b) const thread + { + return a - b; + } + T operator()(const device T &a, const device T &b) const thread + { + return a - b; + } + T operator()(const device T &a, const constant T &b) const thread + { + return a - b; + } + T operator()(const device T &a, const threadgroup T &b) const thread + { + return a - b; + } + T operator()(const constant T &a, const thread T &b) const thread + { + return a - b; + } + T operator()(const constant T &a, const device T &b) const thread + { + return a - b; + } + T operator()(const constant T &a, const constant T &b) const thread + { + return a - b; + } + T operator()(const constant T &a, const threadgroup T &b) const thread + { + return a - b; + } + T operator()(const threadgroup T &a, const thread T &b) const thread + { + return a - b; + } + T operator()(const threadgroup T &a, const device T &b) const thread + { + return a - b; + } + T operator()(const threadgroup T &a, const constant T &b) const thread + { + return a - b; + } + T operator()(const threadgroup T &a, const threadgroup T &b) const thread + { + return a - b; + } +}; + +template +struct multiplies +{ + typedef T first_argument_type; + typedef T second_argument_type; + typedef T result_type; + + T operator()(const thread T &a, const thread T &b) const thread + { + return a * b; + } + T operator()(const thread T &a, const device T &b) const thread + { + return a * b; + } + T operator()(const thread T &a, const constant T &b) const thread + { + return a * b; + } + T operator()(const thread T &a, const threadgroup T &b) const thread + { + return a * b; + } + T operator()(const device T &a, const thread T &b) const thread + { + return a * b; + } + T operator()(const device T &a, const device T &b) const thread + { + return a * b; + } + T operator()(const device T &a, const constant T &b) const thread + { + return a * b; + } + T operator()(const device T &a, const threadgroup T &b) const thread + { + return a * b; + } + T operator()(const constant T &a, const thread T &b) const thread + { + return a * b; + } + T operator()(const constant T &a, const device T &b) const thread + { + return a * b; + } + T operator()(const constant T &a, const constant T &b) const thread + { + return a * b; + } + T operator()(const constant T &a, const threadgroup T &b) const thread + { + return a * b; + } + T operator()(const threadgroup T &a, const thread T &b) const thread + { + return a * b; + } + T operator()(const threadgroup T &a, const device T &b) const thread + { + return a * b; + } + T operator()(const threadgroup T &a, const constant T &b) const thread + { + return a * b; + } + T operator()(const threadgroup T &a, const threadgroup T &b) const thread + { + return a * b; + } +}; +} // namespace metal + +#endif // __METAL_FUNCTIONAL diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_geometric b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_geometric new file mode 100644 index 00000000..bdfc5b8e --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_geometric @@ -0,0 +1,378 @@ +//===-- metal_geometric ---------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_GEOMETRIC +#define __METAL_GEOMETRIC + +#include +#include + +#pragma METAL internals : enable +namespace metal +{ +// Metal 1.1 s5.7: Geometric Functions. + +template +struct _fp_range_traits_impl; + +template <> +struct _fp_range_traits_impl +{ + constexpr static constant half scale_down = 0x1.0p-10; + constexpr static constant half scale_down_inv = 0x1.0p+10; + constexpr static constant half scale_up = 0x1.0p+8; + constexpr static constant half scale_up_inv = 0x1.0p-8; +}; +template <> +struct _fp_range_traits_impl +{ + constexpr static constant float scale_down = 0x1.0p-66; + constexpr static constant float scale_down_inv = 0x1.0p+66; + constexpr static constant float scale_up = 0x1.0p+64; + constexpr static constant float scale_up_inv = 0x1.0p-64; +}; +#if defined(__HAVE_NATIVE_DOUBLE__) +template <> +struct _fp_range_traits_impl +{ + constexpr static constant double scale_down = 0x1.0p-514; + constexpr static constant double scale_down_inv = 0x1.0p+514; + constexpr static constant double scale_up = 0x1.0p+512; + constexpr static constant double scale_up_inv = 0x1.0p-512; +}; +#endif + +template +struct _fp_range_traits : _fp_range_traits_impl> +{ +}; + +template +struct _geometric_binary_func_operand_type +{ + using type = void; +}; + +// We shipped a version of Metal using overloded functions to implement binary +// functions instead of template functions. For any pair of scalar or vector +// types T, U for which a call to the overloaded version of foo +// `foo(T(x), U(y))` was valid (including via implicit conversion sequences), +// the call to the templated version must also be valid. +// +// The general form of the binary geometric function is `O foo(T, U)`; O is the +// floating-point vector arithmetic type the function operates with. The +// arguments (of type T and U) are cast to O before being passed to the +// builtin. The rules to deduce O from the pair are as follows: +// +// 1) If T and U are both the same floating-point vector type, identity +// conversion is triggered. +template +struct _geometric_binary_func_operand_type::value>::type> +{ + using type = T; +}; + +// 2) If T or U is a floating-point vector type, and the other is a +// floating-point or integral scalar type, then O is the floating-point +// vector type. +template +struct _geometric_binary_func_operand_type::value ^ _is_fp_vector::value) && (_is_scalar::value ^ _is_scalar::value)>::type> +{ + using type = typename conditional<_is_fp_vector::value, T, U>::type; +}; + +template +using _geometric_binary_func_operand_type_t = typename _geometric_binary_func_operand_type::type; +template +struct _geometric_binary_func_enable : bool_constant>::value> +{ +}; + +template +struct _geometric_ternary_func_operand_type +{ + using type = void; +}; + +// Something similar happens for ternary functions in the form O foo(T, U, V): +// +// 1) If T, U, and V are the same floating-point vector type, identify +// conversion is triggered. +template +struct _geometric_ternary_func_operand_type::value>::type> +{ + using type = T; +}; + +// 2) If T, U, V are three different type, one of them is a floating-point +// vector type and the others are floating-point or scalar types, then O is +// the floating-point vector type. +template +struct _geometric_ternary_func_operand_type::value + _is_fp_vector::value + _is_fp_vector::value) == 1 && (_is_scalar::value + _is_scalar::value + _is_scalar::value) == 2 && (!is_same::value && !is_same::value && !is_same::value)>::type> +{ + using type = typename conditional<_is_fp_vector::value, T, U>::type; +}; + +// 3) If T has the same type of U, or T has the same type of V, or U has the +// same type of V, then the rules for geometric binary functions are applied +// to the two different types. +template +struct _geometric_ternary_func_operand_type::value>::type> : _geometric_binary_func_operand_type +{ +}; +template +struct _geometric_ternary_func_operand_type::value>::type> : _geometric_binary_func_operand_type +{ +}; +template +struct _geometric_ternary_func_operand_type::value>::type> : _geometric_binary_func_operand_type +{ +}; + +template +using _geometric_ternary_func_operand_type_t = typename _geometric_ternary_func_operand_type::type; +template +struct _geometric_ternary_func_enable : bool_constant>::value> +{ +}; + +// The geometric cross function operands rules are an extension of the +// geometric binary function rules. An extra restriction applies: the O vector +// type must be 3-elements wide. +template +struct _geometric_cross_func_operand_type : _geometric_binary_func_operand_type +{ +}; + +template +using _geometric_cross_func_operand_type_t = typename _geometric_cross_func_operand_type::type; +template +struct _geometric_cross_func_enable : bool_constant>::value && vec_elements<_geometric_cross_func_operand_type_t>::value == 3> +{ +}; + +// The geometric refraction function operand rules are an extension of the +// geometric binary function rules. An extra restriction applies: the second +// operand must be a scalar type. +template +struct _geometric_refract_func_operand_type : _geometric_binary_func_operand_type +{ +}; + +template +using _geometric_refract_func_operand_type_t = typename _geometric_refract_func_operand_type::type; +template +struct _geometric_refract_func_enable : bool_constant>::value && is_scalar::value> +{ +}; + +template ::value, _geometric_binary_func_operand_type_t>::type> +METAL_FUNC make_scalar_t<_O> dot(T x, U y) +{ + return __metal_dot(_O(x), _O(y)); +} + +template ::value>::type> +METAL_FUNC make_scalar_t length_squared(T x) +{ + return dot(x, x); +} + +namespace fast +{ +template ::value && is_same>::value>::type> +METAL_FUNC make_scalar_t length(T x) +{ + return fast::sqrt(length_squared(x)); +} + +template ::value && is_same>::value>::type> +METAL_FUNC T normalize(T x) +{ + return x * fast::rsqrt(length_squared(x)); +} + +template ::value, _geometric_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC make_scalar_t<_O> distance(T x, U y) +{ + return fast::length(_O(x) - _O(y)); +} +} // namespace fast + +namespace precise +{ +template ::value && is_same>::value>::type> +METAL_FUNC make_scalar_t length(T x) +{ + using R = make_scalar_t; + + R len_sq = length_squared(x); + if (isinf(len_sq)) + { + len_sq = length_squared(x * _fp_range_traits::scale_down); + return _fp_range_traits::scale_down_inv * precise::sqrt(len_sq); + } + if (len_sq < numeric_limits::min() / numeric_limits::epsilon()) + { + len_sq = length_squared(x * _fp_range_traits::scale_up); + return _fp_range_traits::scale_up_inv * precise::sqrt(len_sq); + } + return precise::sqrt(len_sq); +} + +template ::value && is_same>::value>::type> +METAL_FUNC T normalize(T x) +{ + using R = make_scalar_t; + + if (any(isinf(x))) + return numeric_limits::quiet_NaN(); + + R len_sq = length_squared(x); + if (isinf(len_sq)) + { + x *= _fp_range_traits::scale_down; + len_sq = length_squared(x); + if (isinf(len_sq)) + return copysign(select(T(0), T(1), isinf(x)), x); + } + else if (len_sq < numeric_limits::min() / numeric_limits::epsilon()) + { + x *= _fp_range_traits::scale_up; + len_sq = length_squared(x); + if (len_sq == R(0)) + return x; + } + return x * precise::rsqrt(len_sq); +} + +template ::value, _geometric_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC make_scalar_t<_O> distance(T x, U y) +{ + return precise::length(_O(x) - _O(y)); +} +} // namespace precise + +template +struct _length_impl +{ + METAL_FUNC make_scalar_t operator()(T x) const thread + { + return sqrt(length_squared(x)); + } +}; + +template +struct _length_impl>::value>::type> +{ + METAL_FUNC make_scalar_t operator()(T x) const thread + { +#if defined(__FAST_MATH__) + return fast::length(x); +#else + return precise::length(x); +#endif + } +}; + +template ::value>::type> +METAL_FUNC make_scalar_t length(T x) +{ + return _length_impl()(x); +} + +template +struct _normalize_impl +{ + METAL_FUNC T operator()(T x) const thread + { + return x * rsqrt(length_squared(x)); + } +}; + +template +struct _normalize_impl>::value>::type> +{ + METAL_FUNC T operator()(T x) const thread + { +#if defined(__FAST_MATH__) + return fast::normalize(x); +#else + return precise::normalize(x); +#endif + } +}; + +template ::value>::type> +METAL_FUNC T normalize(T x) +{ + return _normalize_impl()(x); +} + +template +struct _distance_impl +{ + METAL_FUNC make_scalar_t operator()(T x, T y) const thread + { + return length(x - y); + } +}; + +template +struct _distance_impl>::value>::type> +{ + METAL_FUNC make_scalar_t operator()(T x, T y) const thread + { +#if defined(__FAST_MATH__) + return fast::distance(x, y); +#else + return precise::distance(x, y); +#endif + } +}; + +template ::value, _geometric_binary_func_operand_type_t>::type> +METAL_FUNC make_scalar_t<_O> distance(T x, U y) +{ + return _distance_impl<_O>()(_O(x), _O(y)); +} + +template ::value, _geometric_binary_func_operand_type_t>::type> +METAL_FUNC make_scalar_t<_O> distance_squared(T x, U y) +{ + return length_squared(_O(x) - _O(y)); +} + +template ::value, _geometric_ternary_func_operand_type_t>::type> +METAL_FUNC _O faceforward(T n, U i, V nref) +{ + return dot(_O(nref), _O(i)) < make_scalar_t<_O>(0) ? _O(n) : _O(-n); +} + +template ::value, _geometric_binary_func_operand_type_t>::type> +METAL_FUNC _O reflect(T i, U n) +{ + return _O(i) - make_scalar_t<_O>(2) * dot(_O(n), _O(i)) * _O(n); +} + +template ::value, _geometric_refract_func_operand_type_t>::type> +METAL_FUNC _O refract(T i, U n, V eta) +{ + using R = make_scalar_t<_O>; + + R k = R(1) - R(eta) * R(eta) * (R(1) - dot(_O(n), _O(i)) * dot(_O(n), _O(i))); + if (k < R(0)) + return {0}; + return R(eta) * _O(i) - (R(eta) * dot(_O(n), _O(i)) + sqrt(k)) * _O(n); +} + +template ::value, _geometric_cross_func_operand_type_t>::type> +METAL_FUNC _O cross(T x, U y) +{ + return {(_O(x)[1] * _O(y)[2]) - (_O(y)[1] * _O(x)[2]), (_O(x)[2] * _O(y)[0]) - (_O(y)[2] * _O(x)[0]), (_O(x)[0] * _O(y)[1]) - (_O(y)[0] * _O(x)[1])}; +} +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_GEOMETRIC diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_graphics b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_graphics new file mode 100644 index 00000000..462f63fa --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_graphics @@ -0,0 +1,100 @@ +//===-- metal_graphics ----------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_GRAPHICS +#define __METAL_GRAPHICS + +#include + +namespace metal +{ +// Metal 1.1 s5.9: Graphics Functions. + +// Metal 1.1 s5.9.1.1: Fragment Functions -- Derivatives. + +template , half>, is_same, float>>::value>::type> +METAL_FUNC T dfdx(T p) +{ + return __metal_dfdx(p); +} + +template , half>, is_same, float>>::value>::type> +METAL_FUNC T dfdy(T p) +{ + return __metal_dfdy(p); +} + +template , half>, is_same, float>>::value>::type> +METAL_FUNC T fwidth(T p) +{ + return __metal_fwidth(p); +} + +#if defined(__HAVE_SEPARATE_SHADING_RATES__) +// TODO: Metal X.Y sZ.W Fragment Functions – Samples -- update version and +// section number, see . + +enum class fragment_rate +{ + raster = 0, + color = 1 +}; + +METAL_FUNC uint get_num_samples(fragment_rate rate = fragment_rate::raster) +{ + return __metal_get_num_samples(int(rate)); +} + +METAL_FUNC float2 get_sample_position(uint indx, fragment_rate rate = fragment_rate::raster) +{ + return __metal_get_sample_position(indx, int(rate)); +} + +#else +// Metal 1.1 s5.9.1.2 Fragment Functions – Samples + +METAL_FUNC uint get_num_samples() +{ + return __metal_get_num_samples(0); +} + +METAL_FUNC float2 get_sample_position(uint indx) +{ + return __metal_get_sample_position(indx, 0); +} +#endif + +// Metal 1.1 s5.9.1.3: Fragment Functions -- Flow Control. + +#if defined(__HAVE_DISCARD_FRAGMENT_NORETURN__) +METAL_FUNC METAL_NORETURN void discard_fragment() +#else +METAL_FUNC void discard_fragment() +#endif +{ + __metal_discard_fragment(); +} + +#if defined(__HAVE_DRAW_INDIRECT__) +typedef struct +{ + uint vertexCount; + uint instanceCount; + uint vertexStart; + uint baseInstance; +} MTLDrawPrimitivesIndirectArguments; + +typedef struct +{ + uint indexCount; + uint instanceCount; + uint indexStart; + uint baseVertex; + uint baseInstance; +} MTLDrawIndexedPrimitivesIndirectArguments; +#endif + +} // namespace metal + +#endif // __METAL_GRAPHICS diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_indirect_command_buffer b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_indirect_command_buffer new file mode 100644 index 00000000..5e1ce93e --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_indirect_command_buffer @@ -0,0 +1,267 @@ +//===-- metal_indirect_command_buffer -------------------------------------===// +// Copyright (c) 2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_INDIRECT_COMMAND_BUFFER +#define __METAL_INDIRECT_COMMAND_BUFFER + +namespace metal +{ + +#if defined(__HAVE_INDIRECT_COMMAND_BUFFER__) +// TODO: Fix comment for the section and title. +// Metal 2.2
: Indirect Command Buffers + +#pragma METAL internals : enable + +template +struct _is_metal_buffer_pointee_impl : bool_constant<__is_metal_buffer_pointee(T)> +{ +}; + +template +struct is_metal_buffer_pointee : _is_metal_buffer_pointee_impl> +{ +}; + +struct compute_command; + +struct compute_command_buffer +{ +private: + compute_command_buffer_t t; + friend struct compute_command; +}; + +struct compute_pipeline_state +{ +private: + compute_pipeline_state_t t; + friend struct compute_command; +}; + +struct compute_command +{ + METAL_FUNC compute_command(thread compute_command_buffer &cmd_buf, uint index) thread + : buf(cmd_buf.t), index(index) + { + __metal_acquire_compute_command(buf, index); + } + + METAL_FUNC compute_command(const thread compute_command &that) thread = delete; + + METAL_FUNC ~compute_command() thread + { + __metal_release_compute_command(buf, index); + } + + METAL_FUNC thread compute_command &operator=(const thread compute_command &that) thread = delete; + + const thread compute_command &operator,(const thread compute_command &that) const thread = delete; + + METAL_FUNC void set_compute_pipeline_state(compute_pipeline_state pipeline_state) thread + { + __metal_set_pipeline_state_compute_command(buf, index, pipeline_state.t); + } + + template ::value>::type> + METAL_FUNC void set_kernel_buffer(device T *buffer, uint bind_point) thread + { + __metal_set_kernel_buffer_compute_command(buf, index, static_cast(buffer), bind_point); + } + template ::value>::type> + METAL_FUNC void set_kernel_buffer(constant T *buffer, uint bind_point) thread + { + __metal_set_kernel_buffer_compute_command(buf, index, static_cast(buffer), bind_point); + } + + METAL_FUNC void dispatch_threadgroups(uint3 threadgroups, uint3 threads_per_threadgroup) thread + { + __metal_dispatch_threadgroups_compute_command(buf, index, threadgroups, threads_per_threadgroup); + } + + METAL_FUNC void concurrent_dispatch_threadgroups(uint3 threadgroups, uint3 threads_per_threadgroup) thread + { + __metal_concurrent_dispatch_threadgroups_compute_command(buf, index, threadgroups, threads_per_threadgroup); + } + + METAL_FUNC void nop() thread + { + __metal_nop_compute_command(buf, index); + } + + METAL_FUNC void stop() thread + { + __metal_stop_compute_command(buf, index); + } + +private: + compute_command_buffer_t buf; + uint index; +}; + +struct render_command; + +struct render_command_buffer +{ +private: + render_command_buffer_t t; + friend struct render_command; +}; + +struct render_pipeline_state +{ +private: + render_pipeline_state_t t; + friend struct render_command; +}; + +enum class primitive_type +{ + point, + line, + line_strip, + triangle, + triangle_strip +}; + +struct render_command +{ + METAL_FUNC render_command(thread render_command_buffer &cmd_buf, uint index) thread + : buf(cmd_buf.t), index(index) + { + __metal_acquire_render_command(buf, index); + } + + METAL_FUNC render_command(const thread render_command &that) thread = delete; + + METAL_FUNC ~render_command() thread + { + __metal_release_render_command(buf, index); + } + + METAL_FUNC thread render_command &operator=(const thread render_command &that) thread = delete; + + const thread render_command &operator,(const thread render_command &that) const thread = delete; + + METAL_FUNC void set_render_pipeline_state(render_pipeline_state pipeline_state) thread + { + __metal_set_pipeline_state_render_command(buf, index, pipeline_state.t); + } + + template ::value>::type> + METAL_FUNC void set_vertex_buffer(device T *buffer, uint bind_point) thread + { + __metal_set_vertex_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + template ::value>::type> + METAL_FUNC void set_vertex_buffer(constant T *buffer, uint bind_point) thread + { + __metal_set_vertex_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + + template ::value>::type> + METAL_FUNC void set_fragment_buffer(device T *buffer, uint bind_point) thread + { + __metal_set_fragment_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + template ::value>::type> + METAL_FUNC void set_fragment_buffer(constant T *buffer, uint bind_point) thread + { + __metal_set_fragment_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + + template ::value>::type> + METAL_FUNC void set_tile_buffer(device T *buffer, uint bind_point) thread + { + __metal_set_tile_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + template ::value>::type> + METAL_FUNC void set_tile_buffer(constant T *buffer, uint bind_point) thread + { + __metal_set_tile_buffer_render_command(buf, index, static_cast(buffer), bind_point); + } + + METAL_FUNC void draw_primitives(primitive_type type, uint vertex_start, uint vertex_count, uint instance_count, uint base_instance) thread + { + __metal_draw_primitives_render_command(buf, index, uint(type), vertex_start, vertex_count, instance_count, base_instance); + } + + template , is_same>>::type> + METAL_FUNC void draw_indexed_primitives(primitive_type type, uint index_count, device T *index_buffer, uint index_start, uint instance_count, uint base_vertex, uint base_instance) thread + { + __metal_draw_indexed_primitives_render_command(buf, index, uint(type), index_count, static_cast(index_buffer), index_start, instance_count, base_vertex, base_instance); + } + template , is_same>>::type> + METAL_FUNC void draw_indexed_primitives(primitive_type type, uint index_count, constant T *index_buffer, uint index_start, uint instance_count, uint base_vertex, uint base_instance) thread + { + __metal_draw_indexed_primitives_render_command(buf, index, uint(type), index_count, static_cast(index_buffer), index_start, instance_count, base_vertex, base_instance); + } + + template , is_same>>::type> + METAL_FUNC void set_tessellation_factor_buffer(device T *buffer, uint offset, uint instance_stride) thread + { + __metal_set_tessellation_factor_buffer_render_command(buf, index, static_cast(buffer), offset, instance_stride); + } + template , is_same>>::type> + METAL_FUNC void set_tessellation_factor_buffer(constant T *buffer, uint offset, uint instance_stride) thread + { + __metal_set_tessellation_factor_buffer_render_command(buf, index, static_cast(buffer), offset, instance_stride); + } + + METAL_FUNC void set_tessellation_factor_scale(half scale) thread + { + __metal_set_tessellation_factor_scale_render_command(buf, index, scale); + } + + METAL_FUNC void draw_patches(uint num_patch_control_points, uint patch_start, uint patch_count, device uint *patch_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), instance_count, base_instance); + } + METAL_FUNC void draw_patches(uint num_patch_control_points, uint patch_start, uint patch_count, constant uint *patch_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), instance_count, base_instance); + } + + METAL_FUNC void draw_indexed_patches(uint num_patch_control_points, uint patch_start, uint patch_count, device uint *patch_index_buffer, device void *control_point_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_indexed_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), control_point_index_buffer, instance_count, base_instance); + } + METAL_FUNC void draw_indexed_patches(uint num_patch_control_points, uint patch_start, uint patch_count, device uint *patch_index_buffer, constant void *control_point_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_indexed_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), control_point_index_buffer, instance_count, base_instance); + } + METAL_FUNC void draw_indexed_patches(uint num_patch_control_points, uint patch_start, uint patch_count, constant uint *patch_index_buffer, device void *control_point_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_indexed_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), control_point_index_buffer, instance_count, base_instance); + } + METAL_FUNC void draw_indexed_patches(uint num_patch_control_points, uint patch_start, uint patch_count, constant uint *patch_index_buffer, constant void *control_point_index_buffer, uint instance_count, uint base_instance) thread + { + __metal_draw_indexed_patches_render_command(buf, index, num_patch_control_points, patch_start, patch_count, static_cast(patch_index_buffer), control_point_index_buffer, instance_count, base_instance); + } + + METAL_FUNC void dispatch_threads_per_tile(uint2 threads_per_tile) thread + { + __metal_dispatch_threads_per_tile_render_command(buf, index, threads_per_tile); + } + + METAL_FUNC void nop() thread + { + __metal_nop_render_command(buf, index); + } + + METAL_FUNC void stop() thread + { + __metal_stop_render_command(buf, index); + } + +private: + render_command_buffer_t buf; + uint index; +}; + +#endif // defined (__HAVE_INDIRECT_COMMAND_BUFFER__) + +} // namespace metal + +#endif // __METAL_INDIRECT_COMMAND_BUFFER diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_initializer_list b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_initializer_list new file mode 100644 index 00000000..2dbe1ba3 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_initializer_list @@ -0,0 +1,47 @@ +//===-- metal_initializer_list --------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_INITIALIZER_LIST +#define __METAL_INITIALIZER_LIST + +namespace metal +{ +template +struct initializer_list +{ + typedef T value_type; + typedef const thread T& reference; + typedef const thread T& const_reference; + typedef size_t size_type; + + typedef const thread T *iterator; + typedef const thread T *const_iterator; + + constexpr initializer_list() thread + : elems(nullptr), count(0) + { + } + + size_type size() const thread + { + return count; + } + + const_iterator begin() const thread + { + return elems; + } + + const_iterator end() const thread + { + return elems + count; + } + +private: + const thread value_type *elems; + size_type count; +}; +} // namespace metal + +#endif // __METAL_INITIALIZER_LIST diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer new file mode 100644 index 00000000..c0452dec --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer @@ -0,0 +1,1497 @@ +//===-- metal_integer -----------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_INTEGER +#define __METAL_INTEGER + +#include + +#pragma METAL internals : enable +namespace metal +{ +// Metal 1.1 s5.3: Integer Functions. + +#if defined(__HAVE_MAD24__) +template , int>, is_same, uint>>::value>::type> +METAL_FUNC T mad24(T x, T y, T z) +{ + return __metal_mad24(x, y, z); +} +#endif + +#if defined(__HAVE_MUL24__) +template , int>, is_same, uint>>::value>::type> +METAL_FUNC T mul24(T x, T y) +{ + return __metal_mul24(x, y); +} +#endif +} // namespace metal +#pragma METAL internals : disable + +// TODO: The following is old code about to be rewritten by Alex. +namespace metal { + // 5.4 Integer Functions +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL uchar _air_clz_i8(uchar x, bool is_zero_undef) __asm("air.clz.i8"); +#else + METAL_INTERNAL uchar _air_clz_i8(uchar x) __asm("air.clz.i8"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL uchar _air_ctz_i8(uchar x, bool is_zero_undef) __asm("air.ctz.i8"); +#else + METAL_INTERNAL uchar _air_ctz_i8(uchar x) __asm("air.ctz.i8"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL ushort _air_clz_i16(ushort x, bool is_zero_undef) __asm("air.clz.i16"); +#else + METAL_INTERNAL ushort _air_clz_i16(ushort x) __asm("air.clz.i16"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL ushort _air_ctz_i16(ushort x, bool is_zero_undef) __asm("air.ctz.i16"); +#else + METAL_INTERNAL ushort _air_ctz_i16(ushort x) __asm("air.ctz.i16"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL uint _air_clz_i32(uint x, bool is_zero_undef) __asm("air.clz.i32"); +#else + METAL_INTERNAL uint _air_clz_i32(uint x) __asm("air.clz.i32"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL uint _air_ctz_i32(uint x, bool is_zero_undef) __asm("air.ctz.i32"); +#else + METAL_INTERNAL uint _air_ctz_i32(uint x) __asm("air.ctz.i32"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v2i8(vec x, bool is_zero_undef) __asm("air.clz.v2i8"); +#else + METAL_INTERNAL vec _air_clz_v2i8(vec x) __asm("air.clz.v2i8"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v2i8(vec x, bool is_zero_undef) __asm("air.ctz.v2i8"); +#else + METAL_INTERNAL vec _air_ctz_v2i8(vec x) __asm("air.ctz.v2i8"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v2i16(vec x, bool is_zero_undef) __asm("air.clz.v2i16"); +#else + METAL_INTERNAL vec _air_clz_v2i16(vec x) __asm("air.clz.v2i16"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v2i16(vec x, bool is_zero_undef) __asm("air.ctz.v2i16"); +#else + METAL_INTERNAL vec _air_ctz_v2i16(vec x) __asm("air.ctz.v2i16"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v2i32(vec x, bool is_zero_undef) __asm("air.clz.v2i32"); +#else + METAL_INTERNAL vec _air_clz_v2i32(vec x) __asm("air.clz.v2i32"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v2i32(vec x, bool is_zero_undef) __asm("air.ctz.v2i32"); +#else + METAL_INTERNAL vec _air_ctz_v2i32(vec x) __asm("air.ctz.v2i32"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v3i8(vec x, bool is_zero_undef) __asm("air.clz.v3i8"); +#else + METAL_INTERNAL vec _air_clz_v3i8(vec x) __asm("air.clz.v3i8"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v3i8(vec x, bool is_zero_undef) __asm("air.ctz.v3i8"); +#else + METAL_INTERNAL vec _air_ctz_v3i8(vec x) __asm("air.ctz.v3i8"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v3i16(vec x, bool is_zero_undef) __asm("air.clz.v3i16"); +#else + METAL_INTERNAL vec _air_clz_v3i16(vec x) __asm("air.clz.v3i16"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v3i16(vec x, bool is_zero_undef) __asm("air.ctz.v3i16"); +#else + METAL_INTERNAL vec _air_ctz_v3i16(vec x) __asm("air.ctz.v3i16"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v3i32(vec x, bool is_zero_undef) __asm("air.clz.v3i32"); +#else + METAL_INTERNAL vec _air_clz_v3i32(vec x) __asm("air.clz.v3i32"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v3i32(vec x, bool is_zero_undef) __asm("air.ctz.v3i32"); +#else + METAL_INTERNAL vec _air_ctz_v3i32(vec x) __asm("air.ctz.v3i32"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v4i8(vec x, bool is_zero_undef) __asm("air.clz.v4i8"); +#else + METAL_INTERNAL vec _air_clz_v4i8(vec x) __asm("air.clz.v4i8"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v4i8(vec x, bool is_zero_undef) __asm("air.ctz.v4i8"); +#else + METAL_INTERNAL vec _air_ctz_v4i8(vec x) __asm("air.ctz.v4i8"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v4i16(vec x, bool is_zero_undef) __asm("air.clz.v4i16"); +#else + METAL_INTERNAL vec _air_clz_v4i16(vec x) __asm("air.clz.v4i16"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v4i16(vec x, bool is_zero_undef) __asm("air.ctz.v4i16"); +#else + METAL_INTERNAL vec _air_ctz_v4i16(vec x) __asm("air.ctz.v4i16"); +#endif +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_clz_v4i32(vec x, bool is_zero_undef) __asm("air.clz.v4i32"); +#else + METAL_INTERNAL vec _air_clz_v4i32(vec x) __asm("air.clz.v4i32"); +#endif +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + METAL_INTERNAL vec _air_ctz_v4i32(vec x, bool is_zero_undef) __asm("air.ctz.v4i32"); +#else + METAL_INTERNAL vec _air_ctz_v4i32(vec x) __asm("air.ctz.v4i32"); +#endif + + METAL_ASM char abs(char x) __asm("air.abs.s.i8"); + METAL_ASM uchar absdiff(char x, char y) __asm("air.abs_diff.s.i8"); + METAL_ASM char addsat(char x, char y) __asm("air.add_sat.s.i8"); + METAL_ASM char hadd(char x, char y) __asm("air.hadd.s.i8"); + METAL_ASM char rhadd(char x, char y) __asm("air.rhadd.s.i8"); + METAL_ASM char clamp(char x, char minval, char maxval) __asm("air.clamp.s.i8"); + METAL_FUNC char clz(char x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i8(as_type(x), false)); +#else + return static_cast(_air_clz_i8(as_type(x))); +#endif + } + METAL_FUNC char ctz(char x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i8(as_type(x), false)); +#else + return static_cast(_air_ctz_i8(as_type(x))); +#endif + } + METAL_ASM char madhi(char a, char b, char c) __asm("air.mad_hi.s.i8"); + METAL_ASM char madsat(char a, char b, char c) __asm("air.mad_sat.s.i8"); + METAL_ASM char max(char x, char y) __asm("air.max.s.i8"); + METAL_ASM char min(char x, char y) __asm("air.min.s.i8"); + METAL_ASM char mulhi(char x, char y) __asm("air.mul_hi.s.i8"); + METAL_ASM char rotate(char v, char i) __asm("air.rotate.i8"); + METAL_ASM char subsat(char x, char y) __asm("air.sub_sat.s.i8"); + METAL_ASM char popcount(char x) __asm("air.popcount.i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC char extract_bits(char x, uint offset, uint bits) { + if (bits == 0) + return 0; + uchar xu = as_type(x) >> offset; + uchar signmask = uchar(1) << (bits - 1); + uchar mask1 = ((~xu & signmask) << 1) - 1; + uchar mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type(xu); + } + METAL_FUNC uchar insert_bits(uchar base, uchar insert, uint offset, uint bits); + METAL_FUNC char insert_bits(char base, char insert, uint offset, uint bits) { + return as_type(insert_bits(as_type(base), as_type(insert), offset, bits)); + } + METAL_FUNC uchar reverse_bits(uchar x); + METAL_FUNC char reverse_bits(char x) { + return as_type(reverse_bits(as_type(x))); + } +#else + METAL_ASM char extract_bits(char x, uint offset, uint bits) __asm("air.extract_bits.s.i8"); + METAL_ASM char insert_bits(char base, char insert, uint offset, uint bits) __asm("air.insert_bits.s.i8"); + METAL_ASM char reverse_bits(char x) __asm("air.reverse_bits.i8"); +#endif +#endif + METAL_ASM uchar abs(uchar x) __asm("air.abs.u.i8"); + METAL_ASM uchar absdiff(uchar x, uchar y) __asm("air.abs_diff.u.i8"); + METAL_ASM uchar addsat(uchar x, uchar y) __asm("air.add_sat.u.i8"); + METAL_ASM uchar hadd(uchar x, uchar y) __asm("air.hadd.u.i8"); + METAL_ASM uchar rhadd(uchar x, uchar y) __asm("air.rhadd.u.i8"); + METAL_ASM uchar clamp(uchar x, uchar minval, uchar maxval) __asm("air.clamp.u.i8"); + METAL_FUNC uchar clz(uchar x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i8(as_type(x), false)); +#else + return static_cast(_air_clz_i8(as_type(x))); +#endif + } + METAL_FUNC uchar ctz(uchar x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i8(as_type(x), false)); +#else + return static_cast(_air_ctz_i8(as_type(x))); +#endif + } + METAL_ASM uchar madhi(uchar a, uchar b, uchar c) __asm("air.mad_hi.u.i8"); + METAL_ASM uchar madsat(uchar a, uchar b, uchar c) __asm("air.mad_sat.u.i8"); + METAL_ASM uchar max(uchar x, uchar y) __asm("air.max.u.i8"); + METAL_ASM uchar min(uchar x, uchar y) __asm("air.min.u.i8"); + METAL_ASM uchar mulhi(uchar x, uchar y) __asm("air.mul_hi.u.i8"); + METAL_ASM uchar rotate(uchar v, uchar i) __asm("air.rotate.i8"); + METAL_ASM uchar subsat(uchar x, uchar y) __asm("air.sub_sat.u.i8"); + METAL_ASM uchar popcount(uchar x) __asm("air.popcount.i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC uchar extract_bits(uchar x, uint offset, uint bits) { + if (bits == 8) + return x; + return (x >> offset) & ((uchar(1) << bits) - uchar(1)); + } + METAL_FUNC uchar insert_bits(uchar base, uchar insert, uint offset, uint bits) { + if (bits == 8) + return insert; + uchar mask = ((uchar(1) << bits) - uchar(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC uchar reverse_bits(uchar x) { + x = ((x & uchar(0x55)) << 1) | ((x & uchar(0xAA)) >> 1); + x = ((x & uchar(0x33)) << 2) | ((x & uchar(0xCC)) >> 2); + return (x << 4) | (x >> 4); + } +#else + METAL_ASM uchar extract_bits(uchar x, uint offset, uint bits) __asm("air.extract_bits.u.i8"); + METAL_ASM uchar insert_bits(uchar base, uchar insert, uint offset, uint bits) __asm("air.insert_bits.u.i8"); + METAL_ASM uchar reverse_bits(uchar x) __asm("air.reverse_bits.i8"); +#endif +#endif + METAL_ASM short abs(short x) __asm("air.abs.s.i16"); + METAL_ASM ushort absdiff(short x, short y) __asm("air.abs_diff.s.i16"); + METAL_ASM short addsat(short x, short y) __asm("air.add_sat.s.i16"); + METAL_ASM short hadd(short x, short y) __asm("air.hadd.s.i16"); + METAL_ASM short rhadd(short x, short y) __asm("air.rhadd.s.i16"); + METAL_ASM short clamp(short x, short minval, short maxval) __asm("air.clamp.s.i16"); + METAL_FUNC short clz(short x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i16(as_type(x), false)); +#else + return static_cast(_air_clz_i16(as_type(x))); +#endif + } + METAL_FUNC short ctz(short x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i16(as_type(x), false)); +#else + return static_cast(_air_ctz_i16(as_type(x))); +#endif + } + METAL_ASM short madhi(short a, short b, short c) __asm("air.mad_hi.s.i16"); + METAL_ASM short madsat(short a, short b, short c) __asm("air.mad_sat.s.i16"); + METAL_ASM short max(short x, short y) __asm("air.max.s.i16"); + METAL_ASM short min(short x, short y) __asm("air.min.s.i16"); + METAL_ASM short mulhi(short x, short y) __asm("air.mul_hi.s.i16"); + METAL_ASM short rotate(short v, short i) __asm("air.rotate.i16"); + METAL_ASM short subsat(short x, short y) __asm("air.sub_sat.s.i16"); + METAL_ASM short popcount(short x) __asm("air.popcount.i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC short extract_bits(short x, uint offset, uint bits) { + if (bits == 0) + return 0; + ushort xu = as_type(x) >> offset; + ushort signmask = ushort(1) << (bits - 1); + ushort mask1 = ((~xu & signmask) << 1) - 1; + ushort mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type(xu); + } + METAL_FUNC ushort insert_bits(ushort base, ushort insert, uint offset, uint bits); + METAL_FUNC short insert_bits(short base, short insert, uint offset, uint bits) { + return as_type(insert_bits(as_type(base), as_type(insert), offset, bits)); + } + METAL_FUNC ushort reverse_bits(ushort x); + METAL_FUNC short reverse_bits(short x) { + return as_type(reverse_bits(as_type(x))); + } +#else + METAL_ASM short extract_bits(short x, uint offset, uint bits) __asm("air.extract_bits.s.i16"); + METAL_ASM short insert_bits(short base, short insert, uint offset, uint bits) __asm("air.insert_bits.s.i16"); + METAL_ASM short reverse_bits(short x) __asm("air.reverse_bits.i16"); +#endif +#endif + METAL_ASM ushort abs(ushort x) __asm("air.abs.u.i16"); + METAL_ASM ushort absdiff(ushort x, ushort y) __asm("air.abs_diff.u.i16"); + METAL_ASM ushort addsat(ushort x, ushort y) __asm("air.add_sat.u.i16"); + METAL_ASM ushort hadd(ushort x, ushort y) __asm("air.hadd.u.i16"); + METAL_ASM ushort rhadd(ushort x, ushort y) __asm("air.rhadd.u.i16"); + METAL_ASM ushort clamp(ushort x, ushort minval, ushort maxval) __asm("air.clamp.u.i16"); + METAL_FUNC ushort clz(ushort x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i16(as_type(x), false)); +#else + return static_cast(_air_clz_i16(as_type(x))); +#endif + } + METAL_FUNC ushort ctz(ushort x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i16(as_type(x), false)); +#else + return static_cast(_air_ctz_i16(as_type(x))); +#endif + } + METAL_ASM ushort madhi(ushort a, ushort b, ushort c) __asm("air.mad_hi.u.i16"); + METAL_ASM ushort madsat(ushort a, ushort b, ushort c) __asm("air.mad_sat.u.i16"); + METAL_ASM ushort max(ushort x, ushort y) __asm("air.max.u.i16"); + METAL_ASM ushort min(ushort x, ushort y) __asm("air.min.u.i16"); + METAL_ASM ushort mulhi(ushort x, ushort y) __asm("air.mul_hi.u.i16"); + METAL_ASM ushort rotate(ushort v, ushort i) __asm("air.rotate.i16"); + METAL_ASM ushort subsat(ushort x, ushort y) __asm("air.sub_sat.u.i16"); + METAL_ASM ushort popcount(ushort x) __asm("air.popcount.i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC ushort extract_bits(ushort x, uint offset, uint bits) { + if (bits == 16) + return x; + return (x >> offset) & ((ushort(1) << bits) - ushort(1)); + } + METAL_FUNC ushort insert_bits(ushort base, ushort insert, uint offset, uint bits) { + if (bits == 16) + return insert; + ushort mask = ((ushort(1) << bits) - ushort(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC ushort reverse_bits(ushort x) { + x = ((x & ushort(0x5555)) << 1) | ((x & ushort(0xAAAA)) >> 1); + x = ((x & ushort(0x3333)) << 2) | ((x & ushort(0xCCCC)) >> 2); + x = ((x & ushort(0x0F0F)) << 4) | ((x & ushort(0xF0F0)) >> 4); + return (x << 8) | (x >> 8); + } +#else + METAL_ASM ushort extract_bits(ushort x, uint offset, uint bits) __asm("air.extract_bits.u.i16"); + METAL_ASM ushort insert_bits(ushort base, ushort insert, uint offset, uint bits) __asm("air.insert_bits.u.i16"); + METAL_ASM ushort reverse_bits(ushort x) __asm("air.reverse_bits.i16"); +#endif +#endif + METAL_ASM int abs(int x) __asm("air.abs.s.i32"); + METAL_ASM uint absdiff(int x, int y) __asm("air.abs_diff.s.i32"); + METAL_ASM int addsat(int x, int y) __asm("air.add_sat.s.i32"); + METAL_ASM int hadd(int x, int y) __asm("air.hadd.s.i32"); + METAL_ASM int rhadd(int x, int y) __asm("air.rhadd.s.i32"); + METAL_ASM int clamp(int x, int minval, int maxval) __asm("air.clamp.s.i32"); + METAL_FUNC int clz(int x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i32(as_type(x), false)); +#else + return static_cast(_air_clz_i32(as_type(x))); +#endif + } + METAL_FUNC int ctz(int x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i32(as_type(x), false)); +#else + return static_cast(_air_ctz_i32(as_type(x))); +#endif + } + METAL_ASM int madhi(int a, int b, int c) __asm("air.mad_hi.s.i32"); + METAL_ASM int madsat(int a, int b, int c) __asm("air.mad_sat.s.i32"); + METAL_ASM int max(int x, int y) __asm("air.max.s.i32"); + METAL_ASM int min(int x, int y) __asm("air.min.s.i32"); + METAL_ASM int mulhi(int x, int y) __asm("air.mul_hi.s.i32"); + METAL_ASM int rotate(int v, int i) __asm("air.rotate.i32"); + METAL_ASM int subsat(int x, int y) __asm("air.sub_sat.s.i32"); + METAL_ASM int popcount(int x) __asm("air.popcount.i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC int extract_bits(int x, uint offset, uint bits) { + if (bits == 0) + return 0; + uint xu = as_type(x) >> offset; + uint signmask = uint(1) << (bits - 1); + uint mask1 = ((~xu & signmask) << 1) - 1; + uint mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type(xu); + } + METAL_FUNC uint insert_bits(uint base, uint insert, uint offset, uint bits); + METAL_FUNC int insert_bits(int base, int insert, uint offset, uint bits) { + return as_type(insert_bits(as_type(base), as_type(insert), offset, bits)); + } + METAL_FUNC uint reverse_bits(uint x); + METAL_FUNC int reverse_bits(int x) { + return as_type(reverse_bits(as_type(x))); + } +#else + METAL_ASM int extract_bits(int x, uint offset, uint bits) __asm("air.extract_bits.s.i32"); + METAL_ASM int insert_bits(int base, int insert, uint offset, uint bits) __asm("air.insert_bits.s.i32"); + METAL_ASM int reverse_bits(int x) __asm("air.reverse_bits.i32"); +#endif +#endif + METAL_ASM uint abs(uint x) __asm("air.abs.u.i32"); + METAL_ASM uint absdiff(uint x, uint y) __asm("air.abs_diff.u.i32"); + METAL_ASM uint addsat(uint x, uint y) __asm("air.add_sat.u.i32"); + METAL_ASM uint hadd(uint x, uint y) __asm("air.hadd.u.i32"); + METAL_ASM uint rhadd(uint x, uint y) __asm("air.rhadd.u.i32"); + METAL_ASM uint clamp(uint x, uint minval, uint maxval) __asm("air.clamp.u.i32"); + METAL_FUNC uint clz(uint x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast(_air_clz_i32(as_type(x), false)); +#else + return static_cast(_air_clz_i32(as_type(x))); +#endif + } + METAL_FUNC uint ctz(uint x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast(_air_ctz_i32(as_type(x), false)); +#else + return static_cast(_air_ctz_i32(as_type(x))); +#endif + } + METAL_ASM uint madhi(uint a, uint b, uint c) __asm("air.mad_hi.u.i32"); + METAL_ASM uint madsat(uint a, uint b, uint c) __asm("air.mad_sat.u.i32"); + METAL_ASM uint max(uint x, uint y) __asm("air.max.u.i32"); + METAL_ASM uint min(uint x, uint y) __asm("air.min.u.i32"); + METAL_ASM uint mulhi(uint x, uint y) __asm("air.mul_hi.u.i32"); + METAL_ASM uint rotate(uint v, uint i) __asm("air.rotate.i32"); + METAL_ASM uint subsat(uint x, uint y) __asm("air.sub_sat.u.i32"); + METAL_ASM uint popcount(uint x) __asm("air.popcount.i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC uint extract_bits(uint x, uint offset, uint bits) { + if (bits == 32) + return x; + return (x >> offset) & ((uint(1) << bits) - uint(1)); + } + METAL_FUNC uint insert_bits(uint base, uint insert, uint offset, uint bits) { + if (bits == 32) + return insert; + uint mask = ((uint(1) << bits) - uint(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC uint reverse_bits(uint x) { + x = ((x & uint(0x55555555)) << 1) | ((x & uint(0xAAAAAAAA)) >> 1); + x = ((x & uint(0x33333333)) << 2) | ((x & uint(0xCCCCCCCC)) >> 2); + x = ((x & uint(0x0F0F0F0F)) << 4) | ((x & uint(0xF0F0F0F0)) >> 4); + x = ((x & uint(0x00FF00FF)) << 8) | ((x & uint(0xFF00FF00)) >> 8); + return (x << 16) | (x >> 16); + } +#else + METAL_ASM uint extract_bits(uint x, uint offset, uint bits) __asm("air.extract_bits.u.i32"); + METAL_ASM uint insert_bits(uint base, uint insert, uint offset, uint bits) __asm("air.insert_bits.u.i32"); + METAL_ASM uint reverse_bits(uint x) __asm("air.reverse_bits.i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v2i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v2i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v2i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v2i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v2i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v2i8"); + METAL_FUNC vec clamp(vec x, char minval, char maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v2i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v2i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v2i8"); + METAL_FUNC vec max(vec x, char y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v2i8"); + METAL_FUNC vec min(vec x, char y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v2i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v2i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v2i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v2i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v2i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v2i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v2i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v2i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v2i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v2i8"); + METAL_FUNC vec clamp(vec x, uchar minval, uchar maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v2i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v2i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v2i8"); + METAL_FUNC vec max(vec x, uchar y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v2i8"); + METAL_FUNC vec min(vec x, uchar y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v2i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v2i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 8) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 8) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55)) << 1) | ((x & vec(0xAA)) >> 1); + x = ((x & vec(0x33)) << 2) | ((x & vec(0xCC)) >> 2); + return (x << 4) | (x >> 4); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v2i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v2i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v2i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v2i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v2i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v2i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v2i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v2i16"); + METAL_FUNC vec clamp(vec x, short minval, short maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v2i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v2i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v2i16"); + METAL_FUNC vec max(vec x, short y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v2i16"); + METAL_FUNC vec min(vec x, short y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v2i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v2i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v2i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v2i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v2i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v2i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v2i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v2i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v2i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v2i16"); + METAL_FUNC vec clamp(vec x, ushort minval, ushort maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v2i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v2i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v2i16"); + METAL_FUNC vec max(vec x, ushort y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v2i16"); + METAL_FUNC vec min(vec x, ushort y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v2i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v2i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 16) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 16) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x5555)) << 1) | ((x & vec(0xAAAA)) >> 1); + x = ((x & vec(0x3333)) << 2) | ((x & vec(0xCCCC)) >> 2); + x = ((x & vec(0x0F0F)) << 4) | ((x & vec(0xF0F0)) >> 4); + return (x << 8) | (x >> 8); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v2i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v2i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v2i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v2i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v2i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v2i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v2i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v2i32"); + METAL_FUNC vec clamp(vec x, int minval, int maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v2i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v2i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v2i32"); + METAL_FUNC vec max(vec x, int y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v2i32"); + METAL_FUNC vec min(vec x, int y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v2i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v2i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v2i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v2i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v2i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v2i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v2i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v2i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v2i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v2i32"); + METAL_FUNC vec clamp(vec x, uint minval, uint maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v2i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v2i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v2i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v2i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v2i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v2i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v2i32"); + METAL_FUNC vec max(vec x, uint y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v2i32"); + METAL_FUNC vec min(vec x, uint y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v2i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v2i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v2i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v2i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 32) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 32) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55555555)) << 1) | ((x & vec(0xAAAAAAAA)) >> 1); + x = ((x & vec(0x33333333)) << 2) | ((x & vec(0xCCCCCCCC)) >> 2); + x = ((x & vec(0x0F0F0F0F)) << 4) | ((x & vec(0xF0F0F0F0)) >> 4); + x = ((x & vec(0x00FF00FF)) << 8) | ((x & vec(0xFF00FF00)) >> 8); + return (x << 16) | (x >> 16); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v2i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v2i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v2i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v3i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v3i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v3i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v3i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v3i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v3i8"); + METAL_FUNC vec clamp(vec x, char minval, char maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v3i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v3i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v3i8"); + METAL_FUNC vec max(vec x, char y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v3i8"); + METAL_FUNC vec min(vec x, char y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v3i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v3i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v3i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v3i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v3i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v3i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v3i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v3i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v3i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v3i8"); + METAL_FUNC vec clamp(vec x, uchar minval, uchar maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v3i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v3i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v3i8"); + METAL_FUNC vec max(vec x, uchar y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v3i8"); + METAL_FUNC vec min(vec x, uchar y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v3i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v3i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 8) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 8) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55)) << 1) | ((x & vec(0xAA)) >> 1); + x = ((x & vec(0x33)) << 2) | ((x & vec(0xCC)) >> 2); + return (x << 4) | (x >> 4); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v3i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v3i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v3i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v3i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v3i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v3i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v3i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v3i16"); + METAL_FUNC vec clamp(vec x, short minval, short maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v3i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v3i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v3i16"); + METAL_FUNC vec max(vec x, short y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v3i16"); + METAL_FUNC vec min(vec x, short y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v3i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v3i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v3i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v3i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v3i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v3i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v3i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v3i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v3i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v3i16"); + METAL_FUNC vec clamp(vec x, ushort minval, ushort maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v3i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v3i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v3i16"); + METAL_FUNC vec max(vec x, ushort y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v3i16"); + METAL_FUNC vec min(vec x, ushort y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v3i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v3i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 16) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 16) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x5555)) << 1) | ((x & vec(0xAAAA)) >> 1); + x = ((x & vec(0x3333)) << 2) | ((x & vec(0xCCCC)) >> 2); + x = ((x & vec(0x0F0F)) << 4) | ((x & vec(0xF0F0)) >> 4); + return (x << 8) | (x >> 8); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v3i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v3i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v3i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v3i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v3i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v3i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v3i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v3i32"); + METAL_FUNC vec clamp(vec x, int minval, int maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v3i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v3i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v3i32"); + METAL_FUNC vec max(vec x, int y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v3i32"); + METAL_FUNC vec min(vec x, int y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v3i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v3i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v3i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v3i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v3i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v3i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v3i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v3i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v3i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v3i32"); + METAL_FUNC vec clamp(vec x, uint minval, uint maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v3i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v3i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v3i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v3i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v3i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v3i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v3i32"); + METAL_FUNC vec max(vec x, uint y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v3i32"); + METAL_FUNC vec min(vec x, uint y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v3i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v3i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v3i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v3i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 32) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 32) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55555555)) << 1) | ((x & vec(0xAAAAAAAA)) >> 1); + x = ((x & vec(0x33333333)) << 2) | ((x & vec(0xCCCCCCCC)) >> 2); + x = ((x & vec(0x0F0F0F0F)) << 4) | ((x & vec(0xF0F0F0F0)) >> 4); + x = ((x & vec(0x00FF00FF)) << 8) | ((x & vec(0xFF00FF00)) >> 8); + return (x << 16) | (x >> 16); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v3i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v3i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v3i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v4i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v4i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v4i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v4i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v4i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v4i8"); + METAL_FUNC vec clamp(vec x, char minval, char maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v4i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v4i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v4i8"); + METAL_FUNC vec max(vec x, char y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v4i8"); + METAL_FUNC vec min(vec x, char y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v4i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v4i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v4i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v4i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v4i8"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v4i8"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v4i8"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v4i8"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v4i8"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v4i8"); + METAL_FUNC vec clamp(vec x, uchar minval, uchar maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i8(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i8(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i8(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i8(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v4i8"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v4i8"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v4i8"); + METAL_FUNC vec max(vec x, uchar y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v4i8"); + METAL_FUNC vec min(vec x, uchar y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v4i8"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i8"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v4i8"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i8"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 8) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 8) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55)) << 1) | ((x & vec(0xAA)) >> 1); + x = ((x & vec(0x33)) << 2) | ((x & vec(0xCC)) >> 2); + return (x << 4) | (x >> 4); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v4i8"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v4i8"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i8"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v4i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v4i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v4i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v4i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v4i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v4i16"); + METAL_FUNC vec clamp(vec x, short minval, short maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v4i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v4i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v4i16"); + METAL_FUNC vec max(vec x, short y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v4i16"); + METAL_FUNC vec min(vec x, short y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v4i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v4i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v4i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v4i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v4i16"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v4i16"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v4i16"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v4i16"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v4i16"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v4i16"); + METAL_FUNC vec clamp(vec x, ushort minval, ushort maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i16(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i16(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i16(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i16(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v4i16"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v4i16"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v4i16"); + METAL_FUNC vec max(vec x, ushort y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v4i16"); + METAL_FUNC vec min(vec x, ushort y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v4i16"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i16"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v4i16"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i16"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 16) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 16) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x5555)) << 1) | ((x & vec(0xAAAA)) >> 1); + x = ((x & vec(0x3333)) << 2) | ((x & vec(0xCCCC)) >> 2); + x = ((x & vec(0x0F0F)) << 4) | ((x & vec(0xF0F0)) >> 4); + return (x << 8) | (x >> 8); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v4i16"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v4i16"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i16"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.s.v4i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.s.v4i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.s.v4i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.s.v4i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.s.v4i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.s.v4i32"); + METAL_FUNC vec clamp(vec x, int minval, int maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.s.v4i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.s.v4i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.s.v4i32"); + METAL_FUNC vec max(vec x, int y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.s.v4i32"); + METAL_FUNC vec min(vec x, int y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.s.v4i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.s.v4i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 0) + return 0; + vec xu = as_type>(x) >> offset; + vec signmask = vec(1) << (bits - 1); + vec mask1 = ((~xu & signmask) << 1) - 1; + vec mask2 = ~(((xu & signmask) << 1) - 1); + xu = (xu & mask1) | mask2; + return as_type>(xu); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits); + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + return as_type>(insert_bits(as_type>(base), as_type>(insert), offset, bits)); + } + METAL_FUNC vec reverse_bits(vec x); + METAL_FUNC vec reverse_bits(vec x) { + return as_type>(reverse_bits(as_type>(x))); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.s.v4i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.s.v4i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i32"); +#endif +#endif + METAL_ASM vec abs(vec x) __asm("air.abs.u.v4i32"); + METAL_ASM vec absdiff(vec x, vec y) __asm("air.abs_diff.u.v4i32"); + METAL_ASM vec addsat(vec x, vec y) __asm("air.add_sat.u.v4i32"); + METAL_ASM vec hadd(vec x, vec y) __asm("air.hadd.u.v4i32"); + METAL_ASM vec rhadd(vec x, vec y) __asm("air.rhadd.u.v4i32"); + METAL_ASM vec clamp(vec x, vec minval, vec maxval) __asm("air.clamp.u.v4i32"); + METAL_FUNC vec clamp(vec x, uint minval, uint maxval) { return clamp(x,vec(minval),vec(maxval)); } + METAL_FUNC vec clz(vec x) { +#if defined(__HAVE_CLZ_ZERO_UNDEF__) + return static_cast>(_air_clz_v4i32(as_type>(x), false)); +#else + return static_cast>(_air_clz_v4i32(as_type>(x))); +#endif + } + METAL_FUNC vec ctz(vec x) { +#if defined(__HAVE_CTZ_ZERO_UNDEF__) + return static_cast>(_air_ctz_v4i32(as_type>(x), false)); +#else + return static_cast>(_air_ctz_v4i32(as_type>(x))); +#endif + } + METAL_ASM vec madhi(vec a, vec b, vec c) __asm("air.mad_hi.u.v4i32"); + METAL_ASM vec madsat(vec a, vec b, vec c) __asm("air.mad_sat.u.v4i32"); + METAL_ASM vec max(vec x, vec y) __asm("air.max.u.v4i32"); + METAL_FUNC vec max(vec x, uint y) { return max(x,vec(y)); } + METAL_ASM vec min(vec x, vec y) __asm("air.min.u.v4i32"); + METAL_FUNC vec min(vec x, uint y) { return min(x,vec(y)); } + METAL_ASM vec mulhi(vec x, vec y) __asm("air.mul_hi.u.v4i32"); + METAL_ASM vec rotate(vec v, vec i) __asm("air.rotate.v4i32"); + METAL_ASM vec subsat(vec x, vec y) __asm("air.sub_sat.u.v4i32"); + METAL_ASM vec popcount(vec x) __asm("air.popcount.v4i32"); +#if defined(__HAVE_INTEGER_BIT_EDIT_FUNCTIONS__) +#if !defined(__HAVE_INTEGER_BIT_EDIT_AIR_FUNCTIONS__) + METAL_FUNC vec extract_bits(vec x, uint offset, uint bits) { + if (bits == 32) + return x; + return (x >> offset) & ((vec(1) << bits) - vec(1)); + } + METAL_FUNC vec insert_bits(vec base, vec insert, uint offset, uint bits) { + if (bits == 32) + return insert; + vec mask = ((vec(1) << bits) - vec(1)) << offset; + return (base & ~mask) | ((insert << offset) & mask); + } + METAL_FUNC vec reverse_bits(vec x) { + x = ((x & vec(0x55555555)) << 1) | ((x & vec(0xAAAAAAAA)) >> 1); + x = ((x & vec(0x33333333)) << 2) | ((x & vec(0xCCCCCCCC)) >> 2); + x = ((x & vec(0x0F0F0F0F)) << 4) | ((x & vec(0xF0F0F0F0)) >> 4); + x = ((x & vec(0x00FF00FF)) << 8) | ((x & vec(0xFF00FF00)) >> 8); + return (x << 16) | (x >> 16); + } +#else + METAL_ASM vec extract_bits(vec x, uint offset, uint bits) __asm("air.extract_bits.u.v4i32"); + METAL_ASM vec insert_bits(vec base, vec insert, uint offset, uint bits) __asm("air.insert_bits.u.v4i32"); + METAL_ASM vec reverse_bits(vec x) __asm("air.reverse_bits.v4i32"); +#endif +#endif +} // namespace metal + +#endif // __METAL_INTEGER diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer_math b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer_math new file mode 100644 index 00000000..70babf10 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_integer_math @@ -0,0 +1,141 @@ +//===-- metal_integer_math ------------------------------------------------===// +// Copyright (c) 2015-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_INTEGER_MATH +#define __METAL_INTEGER_MATH + +#include +#include + +#pragma METAL internals : enable +namespace metal +{ +template +struct _integer_ternary_func_enable : false_type +{ +}; + +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template <> +struct _integer_ternary_func_enable : true_type +{ +}; +template +struct _integer_ternary_func_enable : _integer_ternary_func_enable +{ +}; +template +struct _integer_ternary_func_enable : _integer_ternary_func_enable +{ +}; + +#if defined(__HAVE_MAX3__) +template +struct _max3_impl; + +template +struct _max3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_max3(x, y, z); + } +}; + +template +struct _max3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_fmax3(x, y, z, _METAL_MAYBE_FAST_MATH); + } +}; + +template ::value || is_floating_point::value>::type> +METAL_FUNC T max3(T x, T y, T z) +{ + return _max3_impl()(x, y, z); +} +#endif + +#if defined(__HAVE_MEDIAN3__) +template +struct _median3_impl; + +template +struct _median3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_median3(x, y, z); + } +}; + +template +struct _median3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_fmedian3(x, y, z, _METAL_MAYBE_FAST_MATH); + } +}; + +template ::value || is_floating_point::value>::type> +METAL_FUNC T median3(T x, T y, T z) +{ + return _median3_impl()(x, y, z); +} +#endif + +#if defined(__HAVE_MIN3__) +template +struct _min3_impl; + +template +struct _min3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_min3(x, y, z); + } +}; + +template +struct _min3_impl::value>::type> +{ + METAL_FUNC T operator()(T x, T y, T z) const thread + { + return __metal_fmin3(x, y, z, _METAL_MAYBE_FAST_MATH); + } +}; + +template ::value || is_floating_point::value>::type> +METAL_FUNC T min3(T x, T y, T z) +{ + return _min3_impl()(x, y, z); +} +#endif +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_INTEGER_MATH diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_limits b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_limits new file mode 100644 index 00000000..24efee26 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_limits @@ -0,0 +1,174 @@ +//===-- metal_limits ------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_LIMITS +#define __METAL_LIMITS + +#pragma METAL internals : enable +namespace metal +{ +enum float_round_style +{ + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3 +}; + +enum float_denorm_style +{ + denorm_indeterminate = -1, + denorm_absent = 0, + denorm_present = 1 +}; + +template +struct _numeric_limits_impl +{ + static constexpr constant bool is_specialized = false; + static constexpr constant bool is_signed = false; + static constexpr constant bool is_integer = false; + static constexpr constant bool is_exact = false; + static constexpr constant bool has_infinity = false; + static constexpr constant bool has_quiet_NaN = false; + static constexpr constant bool has_signaling_NaN = false; + static constexpr constant float_denorm_style has_denorm = denorm_absent; + static constexpr constant bool has_denorm_loss = false; + static constexpr constant float_round_style round_style = round_toward_zero; + static constexpr constant bool is_iec559 = false; + static constexpr constant bool is_bounded = false; + static constexpr constant bool is_modulo = false; + static constexpr constant int digits = 0; + static constexpr constant int digits10 = 0; + static constexpr constant int max_digits10 = 0; + static constexpr constant int radix = 0; + static constexpr constant int min_exponent = 0; + static constexpr constant int min_exponent10 = 0; + static constexpr constant int max_exponent = 0; + static constexpr constant int max_exponent10 = 0; + static constexpr constant bool traps = false; + static constexpr constant bool tinyness_before = false; + + static constexpr T min() + { + return T(); + } + static constexpr T lowest() + { + return T(); + } + static constexpr T max() + { + return T(); + } + static constexpr T epsilon() + { + return T(); + } + static constexpr T round_error() + { + return T(); + } + static constexpr T infinity() + { + return T(); + } + static constexpr T quiet_NaN() + { + return T(); + } + static constexpr T signaling_NaN() + { + return T(); + } + static constexpr T denorm_min() + { + return T(); + } +}; + +// TODO: Implement all the other members -- see . +template <> +struct _numeric_limits_impl +{ + static constexpr constant bool has_quiet_NaN = true; + + static constexpr half min() + { + return HALF_MIN; + } + static constexpr half max() + { + return HALF_MAX; + } + static constexpr half epsilon() + { + return HALF_EPSILON; + } + static constexpr half quiet_NaN() + { + return __builtin_nanh(""); + } +}; + +// TODO: Implement all the other members -- see . +template <> +struct _numeric_limits_impl +{ + static constexpr constant bool has_quiet_NaN = true; + + static constexpr float min() + { + return FLT_MIN; + } + static constexpr float max() + { + return FLT_MAX; + } + static constexpr float epsilon() + { + return FLT_EPSILON; + } + static constexpr float quiet_NaN() + { + return __builtin_nanf(""); + } +}; + +#if defined(__HAVE_NATIVE_DOUBLE__) +// TODO: Implement all the other members -- see . +template <> +struct _numeric_limits_impl +{ + static constexpr constant bool has_quiet_NaN = true; + + static constexpr double min() + { + return DBL_MIN; + } + static constexpr double max() + { + return DBL_MAX; + } + static constexpr double epsilon() + { + return DBL_EPSILON; + } + static constexpr double quiet_NaN() + { + return __builtin_nan(""); + } +}; +#endif + +template +struct numeric_limits : _numeric_limits_impl> +{ +}; + +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_LIMITS diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math new file mode 100644 index 00000000..74b482e3 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math @@ -0,0 +1,2304 @@ +//===-- metal_math --------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_MATH +#define __METAL_MATH + +#include +#include +#include + +namespace metal { +// Metal 1.1 s5.5: Math Functions. + + +namespace fast +{ +template >::value>::type> +METAL_FUNC T abs(T x) +{ + return __metal_fabs(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T acos(T x) +{ + return __metal_acos(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T acosh(T x) +{ + return __metal_acosh(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T asin(T x) +{ + return __metal_asin(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T asinh(T x) +{ + return __metal_asinh(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T atan(T y_over_x) +{ + return __metal_atan(y_over_x, _METAL_FAST_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O atan2(T y, U x) +{ + return __metal_atan2(_O(y), _O(x), _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T atanh(T x) +{ + return __metal_atanh(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T ceil(T x) +{ + return __metal_ceil(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T cos(T x) +{ + return __metal_cos(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T cosh(T x) +{ + return __metal_cosh(x, _METAL_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T cospi(T x) +{ + return __metal_cospi(x, _METAL_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T exp(T x) +{ + return __metal_exp(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T exp10(T x) +{ + return __metal_exp10(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T exp2(T x) +{ + return __metal_exp2(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T fabs(T x) +{ + return __metal_fabs(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T floor(T x) +{ + return __metal_floor(x, _METAL_FAST_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmax(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_FAST_MATH); +} +#if defined(__HAVE_FMAX3__) +template >::value>::type> +METAL_FUNC T fmax3(T x, T y, T z) +{ + return __metal_fmax3(x, y, z, _METAL_FAST_MATH); +} +#endif +#if defined(__HAVE_FMEDIAN3__) +template >::value>::type> +METAL_FUNC T fmedian3(T x, T y, T z) +{ + return __metal_fmedian3(x, y, z, _METAL_FAST_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmin(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_FAST_MATH); +} +#if defined(__HAVE_FMIN3__) +template >::value>::type> +METAL_FUNC T fmin3(T x, T y, T z) +{ + return __metal_fmin3(x, y, z, _METAL_FAST_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmod(T x, U y) +{ + return __metal_fmod(_O(x), _O(y), _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T log(T x) +{ + return __metal_log(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T log2(T x) +{ + return __metal_log2(x, _METAL_FAST_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O max(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_FAST_MATH); +} +#if defined(__HAVE_MAX3__) +template >::value>::type> +METAL_FUNC T max3(T x, T y, T z) +{ + return __metal_fmax3(x, y, z, _METAL_FAST_MATH); +} +#endif +#if defined(__HAVE_MEDIAN3__) +template >::value>::type> +METAL_FUNC T median3(T x, T y, T z) +{ + return __metal_fmedian3(x, y, z, _METAL_FAST_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O min(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_FAST_MATH); +} +#if defined(__HAVE_MIN3__) +template >::value>::type> +METAL_FUNC T min3(T x, T y, T z) +{ + return __metal_fmin3(x, y, z, _METAL_FAST_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O pow(T x, U y) +{ + return __metal_pow(_O(x), _O(y), _METAL_FAST_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O powr(T x, U y) +{ + return __metal_powr(_O(x), _O(y), _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T rint(T x) +{ + return __metal_rint(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T round(T x) +{ + return __metal_round(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T rsqrt(T x) +{ + return __metal_rsqrt(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T sin(T x) +{ + return __metal_sin(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T sinh(T x) +{ + return __metal_sinh(x, _METAL_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T sinpi(T x) +{ + return __metal_sinpi(x, _METAL_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T sqrt(T x) +{ + return __metal_sqrt(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T tan(T x) +{ + return __metal_tan(x, _METAL_FAST_MATH); +} +template >::value>::type> +METAL_FUNC T tanh(T x) +{ + return __metal_tanh(x, _METAL_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T tanpi(T x) +{ + return __metal_tanpi(x, _METAL_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T trunc(T x) +{ + return __metal_trunc(x, _METAL_FAST_MATH); +} +} // namespace fast + +namespace precise +{ +template >::value>::type> +METAL_FUNC T abs(T x) +{ + return __metal_fabs(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T acos(T x) +{ + return __metal_acos(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T acosh(T x) +{ + return __metal_acosh(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T asin(T x) +{ + return __metal_asin(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T asinh(T x) +{ + return __metal_asinh(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T atan(T y_over_x) +{ + return __metal_atan(y_over_x, _METAL_PRECISE_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O atan2(T y, U x) +{ + return __metal_atan2(_O(y), _O(x), _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T atanh(T x) +{ + return __metal_atanh(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T ceil(T x) +{ + return __metal_ceil(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T cos(T x) +{ + return __metal_cos(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T cosh(T x) +{ + return __metal_cosh(x, _METAL_PRECISE_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T cospi(T x) +{ + return __metal_cospi(x, _METAL_PRECISE_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T exp(T x) +{ + return __metal_exp(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T exp10(T x) +{ + return __metal_exp10(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T exp2(T x) +{ + return __metal_exp2(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T fabs(T x) +{ + return __metal_fabs(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T floor(T x) +{ + return __metal_floor(x, _METAL_PRECISE_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmax(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_PRECISE_MATH); +} +#if defined(__HAVE_FMAX3__) +template >::value>::type> +METAL_FUNC T fmax3(T x, T y, T z) +{ + return __metal_fmax3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +#if defined(__HAVE_FMEDIAN3__) +template >::value>::type> +METAL_FUNC T fmedian3(T x, T y, T z) +{ + return __metal_fmedian3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmin(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_PRECISE_MATH); +} +#if defined(__HAVE_FMIN3__) +template >::value>::type> +METAL_FUNC T fmin3(T x, T y, T z) +{ + return __metal_fmin3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O fmod(T x, U y) +{ + return __metal_fmod(_O(x), _O(y), _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T log(T x) +{ + return __metal_log(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T log2(T x) +{ + return __metal_log2(x, _METAL_PRECISE_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O max(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_PRECISE_MATH); +} +#if defined(__HAVE_MAX3__) +template >::value>::type> +METAL_FUNC T max3(T x, T y, T z) +{ + return __metal_fmax3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +#if defined(__HAVE_MEDIAN3__) +template >::value>::type> +METAL_FUNC T median3(T x, T y, T z) +{ + return __metal_fmedian3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O min(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_PRECISE_MATH); +} +#if defined(__HAVE_MIN3__) +template >::value>::type> +METAL_FUNC T min3(T x, T y, T z) +{ + return __metal_fmin3(x, y, z, _METAL_PRECISE_MATH); +} +#endif +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O pow(T x, U y) +{ + return __metal_pow(_O(x), _O(y), _METAL_PRECISE_MATH); +} +template ::value, _math_fast_or_precise_binary_func_operand_type_t>::type, typename _E = typename enable_if>::value>::type> +METAL_FUNC _O powr(T x, U y) +{ + return __metal_powr(_O(x), _O(y), _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T rint(T x) +{ + return __metal_rint(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T round(T x) +{ + return __metal_round(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T rsqrt(T x) +{ + return __metal_rsqrt(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T sin(T x) +{ + return __metal_sin(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T sinh(T x) +{ + return __metal_sinh(x, _METAL_PRECISE_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T sinpi(T x) +{ + return __metal_sinpi(x, _METAL_PRECISE_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T sqrt(T x) +{ + return __metal_sqrt(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T tan(T x) +{ + return __metal_tan(x, _METAL_PRECISE_MATH); +} +template >::value>::type> +METAL_FUNC T tanh(T x) +{ + return __metal_tanh(x, _METAL_PRECISE_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T tanpi(T x) +{ + return __metal_tanpi(x, _METAL_PRECISE_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template >::value>::type> +METAL_FUNC T trunc(T x) +{ + return __metal_trunc(x, _METAL_PRECISE_MATH); +} +} // namespace precise + +template ::value>::type> +METAL_FUNC T abs(T x) +{ + return __metal_fabs(x, _METAL_PRECISE_MATH); +} +template ::value>::type> +METAL_FUNC T acos(T x) +{ + return __metal_acos(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T acosh(T x) +{ + return __metal_acosh(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T asin(T x) +{ + return __metal_asin(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T asinh(T x) +{ + return __metal_asinh(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T atan(T y_over_x) +{ + return __metal_atan(y_over_x, _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O atan2(T y, U x) +{ + return __metal_atan2(_O(y), _O(x), _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T atanh(T x) +{ + return __metal_atanh(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T ceil(T x) +{ + return __metal_ceil(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T cos(T x) +{ + return __metal_cos(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T cosh(T x) +{ + return __metal_cosh(x, _METAL_MAYBE_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T cospi(T x) +{ + return __metal_cospi(x, _METAL_MAYBE_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T exp(T x) +{ + return __metal_exp(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T exp10(T x) +{ + return __metal_exp10(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T exp2(T x) +{ + return __metal_exp2(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T fabs(T x) +{ + return __metal_fabs(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T floor(T x) +{ + return __metal_floor(x, _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O fmax(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +#if defined(__HAVE_FMAX3__) +template ::value>::type> +METAL_FUNC T fmax3(T x, T y, T z) +{ + return __metal_fmax3(x, y, z, _METAL_MAYBE_FAST_MATH); +} +#endif +#if defined(__HAVE_FMEDIAN3__) +template ::value>::type> +METAL_FUNC T fmedian3(T x, T y, T z) +{ + return __metal_fmedian3(x, y, z, _METAL_MAYBE_FAST_MATH); +} +#endif +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O fmin(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +#if defined(__HAVE_FMIN3__) +template ::value>::type> +METAL_FUNC T fmin3(T x, T y, T z) +{ + return __metal_fmin3(x, y, z, _METAL_MAYBE_FAST_MATH); +} +#endif +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O fmod(T x, U y) +{ + return __metal_fmod(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T log(T x) +{ + return __metal_log(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T log2(T x) +{ + return __metal_log2(x, _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O max(T x, U y) +{ + return __metal_fmax(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O min(T x, U y) +{ + return __metal_fmin(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O pow(T x, U y) +{ + return __metal_pow(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +template ::value, _math_binary_func_operand_type_t>::type> +METAL_FUNC _O powr(T x, U y) +{ + return __metal_powr(_O(x), _O(y), _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T rint(T x) +{ + return __metal_rint(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T round(T x) +{ + return __metal_round(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T rsqrt(T x) +{ + return __metal_rsqrt(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T sin(T x) +{ + return __metal_sin(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T sinh(T x) +{ + return __metal_sinh(x, _METAL_MAYBE_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T sinpi(T x) +{ + return __metal_sinpi(x, _METAL_MAYBE_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T sqrt(T x) +{ + return __metal_sqrt(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T tan(T x) +{ + return __metal_tan(x, _METAL_MAYBE_FAST_MATH); +} +template ::value>::type> +METAL_FUNC T tanh(T x) +{ + return __metal_tanh(x, _METAL_MAYBE_FAST_MATH); +} +#if defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T tanpi(T x) +{ + return __metal_tanpi(x, _METAL_MAYBE_FAST_MATH); +} +#endif // defined(__HAVE_TRIG_PI__) +template ::value>::type> +METAL_FUNC T trunc(T x) +{ + return __metal_trunc(x, _METAL_MAYBE_FAST_MATH); +} + +#define _AIR_PREFIX_half "" +#if defined(__FAST_MATH__) +#define _AIR_PREFIX_float "fast_" +#else +#define _AIR_PREFIX_float "" +#endif +#define _AIR_PREFIX_double "" + + // Forward declaration of some functions implemented in metal + // namespace and called directly by corresponding functions in + // fast and precise namespaces directly i.e. copysign in fast + // and precise namespaces call metal::copysign. + METAL_FUNC half copysign(half, half); + METAL_FUNC half fdim(half, half); + METAL_FUNC half frexp(half, thread int&); + METAL_FUNC int ilogb(half); + METAL_FUNC half ldexp(half, int); + METAL_FUNC half modf(half, thread half&); + METAL_FUNC float copysign(float, float); + METAL_FUNC float fdim(float, float); + METAL_FUNC float frexp(float, thread int&); + METAL_FUNC int ilogb(float); + METAL_FUNC float ldexp(float, int); + METAL_FUNC float modf(float, thread float&); +#if defined(__HAVE_NATIVE_DOUBLE__) + METAL_FUNC double copysign(double, double); + METAL_FUNC double fdim(double, double); + METAL_FUNC double frexp(double, thread int&); + METAL_FUNC int ilogb(double); + METAL_FUNC double ldexp(double, int); + METAL_FUNC double modf(double, thread double&); +#endif + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#if defined(__HAVE_NATIVE_DOUBLE__) + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#endif + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#if defined(__HAVE_NATIVE_DOUBLE__) + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#endif + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#if defined(__HAVE_NATIVE_DOUBLE__) + METAL_FUNC vec copysign(vec, vec); + METAL_FUNC vec fdim(vec, vec); + METAL_FUNC vec frexp(vec, thread vec&); + METAL_FUNC vec ilogb(vec); + METAL_FUNC vec ldexp(vec, vec); + METAL_FUNC vec modf(vec, thread vec&); +#endif + +namespace fast { + // Forward declarations + METAL_FUNC float copysign(float x, float y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM float fma(float a, float b, float c) __asm("air.fma.f32"); +#endif + + METAL_ASM float fract(float x) __asm("air.fast_fract.f32"); + + METAL_FUNC float frexp(float x, thread int &exp) { + return metal::frexp(x, exp); + } + METAL_FUNC int ilogb(float x) { + return metal::ilogb(x); + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM float ldexp(float x, int k) __asm("air.fast_ldexp.f32"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC float ldexp(float x, int k) { + return metal::ldexp(x, k); + } +#endif + METAL_FUNC float fdim(float x, float y) { + return metal::fdim(x, y); + } + METAL_ASM float log10(float x) __asm("air.fast_log10.f32"); + + METAL_FUNC float modf(float x, thread float &intval) { + return metal::modf(x, intval); + } + METAL_ASM float sincos(float x, thread float &cosval) __asm("air.fast_sincos.f32"); + + //METAL_ASM float trunc(float x) __asm("air.fast_trunc.f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v2f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.fast_ldexp.v2f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fast_fract.v2f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.fast_log10.v2f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.fast_sincos.v2f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.fast_trunc.v2f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v3f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.fast_ldexp.v3f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fast_fract.v3f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.fast_log10.v3f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.fast_sincos.v3f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.fast_trunc.v3f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v4f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + ret_val[3] = frexp(x[3], temp_exponent); + exponent[3] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + ret_val[3] = ilogb(x[3]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.fast_ldexp.v4f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + ret_val[3] = ldexp(x[3], k[3]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + ret_val[3] = fdim(x[3], y[3]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fast_fract.v4f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + ret_val[3] = fract(x[3]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.fast_log10.v4f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.fast_sincos.v4f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.fast_trunc.v4f32"); +} // namespace fast + +namespace precise { + // Forward declarations + METAL_FUNC float copysign(float x, float y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM float fma(float a, float b, float c) __asm("air.fma.f32"); +#endif + +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM float fract(float x) __asm("air.fract.f32"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC float fract(float x) { + if (metal::isinf(x)) + return float(0); + if (metal::isnan(x)) + return x; + return fmin(x - floor(x), float(0x1.fffffep-1)); + } +#endif + + METAL_FUNC float frexp(float x, thread int &exp) { + return metal::frexp(x, exp); + } + METAL_FUNC int ilogb(float x) { + return metal::ilogb(x); + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM float ldexp(float x, int k) __asm("air.ldexp.f32"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC float ldexp(float x, int k) { + return metal::ldexp(x, k); + } +#endif + METAL_FUNC float fdim(float x, float y) { + return metal::fdim(x, y); + } + METAL_ASM float log10(float x) __asm("air.log10.f32"); + + METAL_FUNC float modf(float x, thread float &intval) { + return metal::modf(x, intval); + } + METAL_ASM float sincos(float x, thread float &cosval) __asm("air.sincos.f32"); + + //METAL_ASM float trunc(float x) __asm("air.trunc.f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v2f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.ldexp.v2f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fract.v2f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v2f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.sincos.v2f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.trunc.v2f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v3f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.ldexp.v3f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fract.v3f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v3f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.sincos.v3f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.trunc.v3f32"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + return metal::copysign(x, y); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v4f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + ret_val[3] = frexp(x[3], temp_exponent); + exponent[3] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + ret_val[3] = ilogb(x[3]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air.ldexp.v4f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + ret_val[3] = ldexp(x[3], k[3]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + ret_val[3] = fdim(x[3], y[3]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air.fract.v4f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + ret_val[3] = fract(x[3]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v4f32"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + return metal::modf(x, intval); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air.sincos.v4f32"); + + //METAL_ASM vec trunc(vec x) __asm("air.trunc.v4f32"); +} // namespace precise + + // Forward declarations + METAL_FUNC half copysign(half x, half y) { + ushort iy = as_type(y) & (ushort)(0x8000); + ushort ret = (as_type(x) & (ushort)(0x8000 - 1ULL)) | iy; + return as_type(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM half fma(half a, half b, half c) __asm("air.fma.f16"); +#endif + + METAL_ASM half fract(half x) __asm("air.fract.f16"); + + METAL_FUNC half frexp(half x, thread int &exp) { + if ((as_type(x) & (ushort)(0x7c00)) == (ushort)(0x7c00)) { + exp = 0; + return x; + } + + // This will evaluate to true on G3 for denorms + if (x == 0.0f) { + exp = 0; + return 0.0f; + } + + ushort xi = as_type(x); + int e = (xi & 0x7c00) >> 10; + // subnormal + if (e == 0) { + // subnormal mantissa + 1.0f + half t = as_type((ushort)((xi & (ushort)0x03ff) | (ushort)0x3c00)); + t = t - 1.0f; + xi = as_type(copysign(t, x)); + e = -14 + ((xi & 0x7c00) >> 10); + } + + e -= 14; + exp = e; + return as_type((ushort)((xi & (0x8000 | 0x03ff)) | 0x3800)); + } + METAL_FUNC int ilogb(half x) { + ushort ux = as_type(x) & (ushort)(0x7fff); + short exp = ux >> (ushort)(10); + + if(((uint)(exp) - (uint)(1)) >= (uint)(30)) { + // +-0, +-denormal, +-inf, NaN + if(x == half(0)) + return FP_ILOGB0; + + if(metal::isnan(x)) + return FP_ILOGBNAN; + + if(ux == (ushort)(0x7c00)) + return INT_MAX; + + ux |= (ushort)(0x3c00); + half f = as_type(ux) - half(1); + exp = as_type(f) >> (ushort)(10); + + return exp - short(15 + 14); + } + + return exp - short(15); + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM half ldexp(half x, int k) __asm("air." _AIR_PREFIX_half "ldexp.f16"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC half ldexp(half x, int k) { + if (x==0.0f) return 0.0f; + ushort ux = as_type(x); + int exp = (ux & (ushort)(0x7c00)) >> 10; + ushort sign = ux & (ushort)(0x8000); + ushort m = ux & (~(ushort)(0x7c00)); + + // If inf or nan + if (exp == ((ushort)(0x7c00) >> 10)) + return x; + + // if k > (power of minimum subnormal + max exponent), simply return inf of same sign + if (k > (30 + 10 + 14)) + return as_type((ushort)(0x7c00 | sign)); + + // subnormal + if (exp == 0) { + half t = as_type((ushort)(m | 0x3c00)); + x = t - copysign(half(1), x); + ux = as_type(x); + exp = ((ux & (ushort)(0x7c00)) >> 10) - (14); + m = ux & (~(ushort)(0x7c00)); + } + + int e = (int)(exp) + k; + if (e >= (30+1)) // return inf of same sign as x + return as_type((ushort)((ushort)(0x7c00) | sign)); + + if (e <= 0) // return 0.0f of same sign as x + return as_type((ushort)((ushort)(0) | sign)); + + return as_type((ushort)(m | ((ushort)(e) << 10))); + } +#endif + METAL_FUNC half fdim(half x, half y) { + bool xNan = x != x; + bool yNan = y != y; + if (xNan || yNan) + return as_type((ushort)0x7e00); + + half t = x - y; + + // When either x or y are nan, t is nan and t < 0 evaluate to false + // When x == y == +/-INFINITY, t is nan but x == y evaluate to true. + return select(t, half(0), bool(t < half(0)) || bool(x == y)); + } + METAL_ASM half log10(half x) __asm("air.log10.f16"); + + METAL_FUNC half modf(half x, thread half &intval) { + intval = trunc(x); + bool isinf_x = isinf(x); + return copysign(select(x - intval, half(0), isinf_x), x); + } + METAL_ASM half sincos(half x, thread half &cosval) __asm("air." _AIR_PREFIX_half "sincos.f16"); + + //METAL_ASM half trunc(half x) __asm("air." _AIR_PREFIX_half "trunc.f16"); + // Forward declarations + METAL_FUNC float copysign(float x, float y) { + uint iy = as_type(y) & (uint)(0x80000000); + uint ret = (as_type(x) & (uint)(0x80000000 - 1ULL)) | iy; + return as_type(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM float fma(float a, float b, float c) __asm("air.fma.f32"); +#endif + + METAL_FUNC float fract(float x) { +#if defined(__FAST_MATH__) + return fast::fract(x); +#else + return precise::fract(x); +#endif + } + + METAL_FUNC float frexp(float x, thread int &exp) { + if ((as_type(x) & (uint)(0x7f800000)) == (uint)(0x7f800000)) { + exp = 0; + return x; + } + + // This will evaluate to true on G3 for denorms + if (x == 0.0f) { + exp = 0; + return 0.0f; + } + + uint xi = as_type(x); + int e = (xi & 0x7f800000) >> 23; + // subnormal + if (e == 0) { + // subnormal mantissa + 1.0f + float t = as_type((uint)((xi & (uint)0x007fffff) | (uint)0x3f800000)); + t = t - 1.0f; + xi = as_type(copysign(t, x)); + e = -126 + ((xi & 0x7f800000) >> 23); + } + + e -= 126; + exp = e; + return as_type((uint)((xi & (0x80000000 | 0x007fffff)) | 0x3f000000)); + } + METAL_FUNC int ilogb(float x) { + uint ux = as_type(x) & (uint)(0x7fffffff); + int exp = ux >> (uint)(23); + + if(((uint)(exp) - (uint)(1)) >= (uint)(254)) { + // +-0, +-denormal, +-inf, NaN + if(x == float(0)) + return FP_ILOGB0; + + if(metal::isnan(x)) + return FP_ILOGBNAN; + + if(ux == (uint)(0x7f800000)) + return INT_MAX; + + ux |= (uint)(0x3f800000); + float f = as_type(ux) - float(1); + exp = as_type(f) >> (uint)(23); + + return exp - int(127 + 126); + } + + return exp - int(127); + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM float ldexp(float x, int k) __asm("air." _AIR_PREFIX_float "ldexp.f32"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC float ldexp(float x, int k) { + if (x==0.0f) return 0.0f; + uint ux = as_type(x); + int exp = (ux & (uint)(0x7f800000)) >> 23; + uint sign = ux & (uint)(0x80000000); + uint m = ux & (~(uint)(0x7f800000)); + + // If inf or nan + if (exp == ((uint)(0x7f800000) >> 23)) + return x; + + // if k > (power of minimum subnormal + max exponent), simply return inf of same sign + if (k > (254 + 23 + 126)) + return as_type((uint)(0x7f800000 | sign)); + + // subnormal + if (exp == 0) { + float t = as_type((uint)(m | 0x3f800000)); + x = t - copysign(float(1), x); + ux = as_type(x); + exp = ((ux & (uint)(0x7f800000)) >> 23) - (126); + m = ux & (~(uint)(0x7f800000)); + } + + int e = (int)(exp) + k; + if (e >= (254+1)) // return inf of same sign as x + return as_type((uint)((uint)(0x7f800000) | sign)); + + if (e <= 0) // return 0.0f of same sign as x + return as_type((uint)((uint)(0) | sign)); + + return as_type((uint)(m | ((uint)(e) << 23))); + } +#endif + METAL_FUNC float fdim(float x, float y) { + bool xNan = x != x; + bool yNan = y != y; + if (xNan || yNan) + return as_type(0x7fc00000); + + float t = x - y; + + // When either x or y are nan, t is nan and t < 0 evaluate to false + // When x == y == +/-INFINITY, t is nan but x == y evaluate to true. + return select(t, float(0), bool(t < float(0)) || bool(x == y)); + } + METAL_FUNC float log10(float x) { +#if defined(__FAST_MATH__) + return fast::log10(x); +#else + return precise::log10(x); +#endif + } + + METAL_FUNC float modf(float x, thread float &intval) { + intval = trunc(x); + bool isinf_x = isinf(x); + return copysign(select(x - intval, float(0), isinf_x), x); + } + METAL_ASM float sincos(float x, thread float &cosval) __asm("air." _AIR_PREFIX_float "sincos.f32"); + + //METAL_ASM float trunc(float x) __asm("air." _AIR_PREFIX_float "trunc.f32"); +#if defined(__HAVE_NATIVE_DOUBLE__) + // Forward declarations + METAL_FUNC double copysign(double x, double y) { + unsigned __metal_internal_int64_t iy = as_type(y) & (unsigned __metal_internal_int64_t)(0x8000000000000000); + unsigned __metal_internal_int64_t ret = (as_type(x) & (unsigned __metal_internal_int64_t)(0x8000000000000000 - 1ULL)) | iy; + return as_type(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM double fma(double a, double b, double c) __asm("air.fma.f64"); +#endif + +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM double fract(double x) __asm("air." _AIR_PREFIX_double "fract.f64"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC double fract(double x) { + if (metal::isinf(x)) + return double(0); + if (metal::isnan(x)) + return x; + return fmin(x - floor(x), double(0x1.fffffep-1)); + } +#endif + + METAL_FUNC double frexp(double x, thread int &exp) { + if ((as_type(x) & (unsigned __metal_internal_int64_t)(0x7ff0000000000000)) == (unsigned __metal_internal_int64_t)(0x7ff0000000000000)) { + exp = 0; + return x; + } + + // This will evaluate to true on G3 for denorms + if (x == 0.0f) { + exp = 0; + return 0.0f; + } + + unsigned __metal_internal_int64_t xi = as_type(x); + int e = (xi & 0x7ff0000000000000) >> 52; + // subnormal + if (e == 0) { + // subnormal mantissa + 1.0f + double t = as_type((unsigned __metal_internal_int64_t)((xi & (unsigned __metal_internal_int64_t)0x000fffffffffffff) | (unsigned __metal_internal_int64_t)0x3ff0000000000000)); + t = t - 1.0f; + xi = as_type(copysign(t, x)); + e = -1022 + ((xi & 0x7ff0000000000000) >> 52); + } + + e -= 1022; + exp = e; + return as_type((unsigned __metal_internal_int64_t)((xi & (0x8000000000000000 | 0x000fffffffffffff)) | 0x3fe0000000000000)); + } + METAL_FUNC int ilogb(double x) { + unsigned __metal_internal_int64_t ux = as_type(x) & (unsigned __metal_internal_int64_t)(0x7fffffffffffffff); + __metal_internal_int64_t exp = ux >> (unsigned __metal_internal_int64_t)(52); + + if(((unsigned __metal_internal_int64_t)(exp) - (unsigned __metal_internal_int64_t)(1)) >= (unsigned __metal_internal_int64_t)(2046)) { + // +-0, +-denormal, +-inf, NaN + if(x == double(0)) + return FP_ILOGB0; + + if(metal::isnan(x)) + return FP_ILOGBNAN; + + if(ux == (unsigned __metal_internal_int64_t)(0x7ff0000000000000)) + return INT_MAX; + + ux |= (unsigned __metal_internal_int64_t)(0x3ff0000000000000); + double f = as_type(ux) - double(1); + exp = as_type(f) >> (unsigned __metal_internal_int64_t)(52); + + return exp - __metal_internal_int64_t(1023 + 1022); + } + + return exp - __metal_internal_int64_t(1023); + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM double ldexp(double x, int k) __asm("air." _AIR_PREFIX_double "ldexp.f64"); +#else + //TODO: fract and ldexp should call air function/builtins + METAL_FUNC double ldexp(double x, int k) { + if (x==0.0f) return 0.0f; + unsigned __metal_internal_int64_t ux = as_type(x); + int exp = (ux & (unsigned __metal_internal_int64_t)(0x7ff0000000000000)) >> 52; + unsigned __metal_internal_int64_t sign = ux & (unsigned __metal_internal_int64_t)(0x8000000000000000); + unsigned __metal_internal_int64_t m = ux & (~(unsigned __metal_internal_int64_t)(0x7ff0000000000000)); + + // If inf or nan + if (exp == ((unsigned __metal_internal_int64_t)(0x7ff0000000000000) >> 52)) + return x; + + // if k > (power of minimum subnormal + max exponent), simply return inf of same sign + if (k > (2046 + 52 + 1022)) + return as_type((unsigned __metal_internal_int64_t)(0x7ff0000000000000 | sign)); + + // subnormal + if (exp == 0) { + double t = as_type((unsigned __metal_internal_int64_t)(m | 0x3ff0000000000000)); + x = t - copysign(double(1), x); + ux = as_type(x); + exp = ((ux & (unsigned __metal_internal_int64_t)(0x7ff0000000000000)) >> 52) - (1022); + m = ux & (~(unsigned __metal_internal_int64_t)(0x7ff0000000000000)); + } + + int e = (int)(exp) + k; + if (e >= (2046+1)) // return inf of same sign as x + return as_type((unsigned __metal_internal_int64_t)((unsigned __metal_internal_int64_t)(0x7ff0000000000000) | sign)); + + if (e <= 0) // return 0.0f of same sign as x + return as_type((unsigned __metal_internal_int64_t)((unsigned __metal_internal_int64_t)(0) | sign)); + + return as_type((unsigned __metal_internal_int64_t)(m | ((unsigned __metal_internal_int64_t)(e) << 52))); + } +#endif + METAL_FUNC double fdim(double x, double y) { + bool xNan = x != x; + bool yNan = y != y; + if (xNan || yNan) + return as_type(0x7ff8000000000000); + + double t = x - y; + + // When either x or y are nan, t is nan and t < 0 evaluate to false + // When x == y == +/-INFINITY, t is nan but x == y evaluate to true. + return select(t, double(0), bool(t < double(0)) || bool(x == y)); + } + METAL_ASM double log10(double x) __asm("air.log10.f64"); + + METAL_FUNC double modf(double x, thread double &intval) { + intval = trunc(x); + bool isinf_x = isinf(x); + return copysign(select(x - intval, double(0), isinf_x), x); + } + METAL_ASM double sincos(double x, thread double &cosval) __asm("air." _AIR_PREFIX_double "sincos.f64"); + + //METAL_ASM double trunc(double x) __asm("air." _AIR_PREFIX_double "trunc.f64"); +#endif + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000); + vec ret = (as_type>(x) & (vec)(0x8000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v2f16"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_half "ldexp.v2f16"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_half "fract.v2f16"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v2f16"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_half "sincos.v2f16"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_half "trunc.v2f16"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x80000000); + vec ret = (as_type>(x) & (vec)(0x80000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v2f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_float "ldexp.v2f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_float "fract.v2f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + return ret_val; + } +#endif + METAL_FUNC vec log10(vec x) { +#if defined(__FAST_MATH__) + return fast::log10(x); +#else + return precise::log10(x); +#endif + } + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_float "sincos.v2f32"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_float "trunc.v2f32"); +#if defined(__HAVE_NATIVE_DOUBLE__) + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000000000000000); + vec ret = (as_type>(x) & (vec)(0x8000000000000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v2f64"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_double "ldexp.v2f64"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_double "fract.v2f64"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v2f64"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_double "sincos.v2f64"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_double "trunc.v2f64"); +#endif + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000); + vec ret = (as_type>(x) & (vec)(0x8000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v3f16"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_half "ldexp.v3f16"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_half "fract.v3f16"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v3f16"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_half "sincos.v3f16"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_half "trunc.v3f16"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x80000000); + vec ret = (as_type>(x) & (vec)(0x80000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v3f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_float "ldexp.v3f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_float "fract.v3f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + return ret_val; + } +#endif + METAL_FUNC vec log10(vec x) { +#if defined(__FAST_MATH__) + return fast::log10(x); +#else + return precise::log10(x); +#endif + } + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_float "sincos.v3f32"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_float "trunc.v3f32"); +#if defined(__HAVE_NATIVE_DOUBLE__) + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000000000000000); + vec ret = (as_type>(x) & (vec)(0x8000000000000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v3f64"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_double "ldexp.v3f64"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_double "fract.v3f64"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v3f64"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_double "sincos.v3f64"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_double "trunc.v3f64"); +#endif + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000); + vec ret = (as_type>(x) & (vec)(0x8000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v4f16"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + ret_val[3] = frexp(x[3], temp_exponent); + exponent[3] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + ret_val[3] = ilogb(x[3]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_half "ldexp.v4f16"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + ret_val[3] = ldexp(x[3], k[3]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + ret_val[3] = fdim(x[3], y[3]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_half "fract.v4f16"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + ret_val[3] = fract(x[3]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v4f16"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_half "sincos.v4f16"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_half "trunc.v4f16"); + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x80000000); + vec ret = (as_type>(x) & (vec)(0x80000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v4f32"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + ret_val[3] = frexp(x[3], temp_exponent); + exponent[3] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + ret_val[3] = ilogb(x[3]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_float "ldexp.v4f32"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + ret_val[3] = ldexp(x[3], k[3]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + ret_val[3] = fdim(x[3], y[3]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_float "fract.v4f32"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + ret_val[3] = fract(x[3]); + return ret_val; + } +#endif + METAL_FUNC vec log10(vec x) { +#if defined(__FAST_MATH__) + return fast::log10(x); +#else + return precise::log10(x); +#endif + } + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_float "sincos.v4f32"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_float "trunc.v4f32"); +#if defined(__HAVE_NATIVE_DOUBLE__) + // Forward declarations + METAL_FUNC vec copysign(vec x, vec y) { + vec iy = as_type>(y) & (vec)(0x8000000000000000); + vec ret = (as_type>(x) & (vec)(0x8000000000000000 - 1ULL)) | iy; + return as_type>(ret); + } + +#if defined(__HAVE_FMA__) + METAL_ASM vec fma(vec a, vec b, vec c) __asm("air.fma.v4f64"); +#endif + + METAL_FUNC vec frexp(vec x, thread vec &exponent) { + int temp_exponent; + vec ret_val; + ret_val[0] = frexp(x[0], temp_exponent); + exponent[0] = temp_exponent; + ret_val[1] = frexp(x[1], temp_exponent); + exponent[1] = temp_exponent; + ret_val[2] = frexp(x[2], temp_exponent); + exponent[2] = temp_exponent; + ret_val[3] = frexp(x[3], temp_exponent); + exponent[3] = temp_exponent; + return ret_val; + } + METAL_FUNC vec ilogb(vec x) { + vec ret_val; + ret_val[0] = ilogb(x[0]); + ret_val[1] = ilogb(x[1]); + ret_val[2] = ilogb(x[2]); + ret_val[3] = ilogb(x[3]); + return ret_val; + } +#if defined(__HAVE_AIR_LDEXP__) + METAL_ASM vec ldexp(vec x, vec k) __asm("air." _AIR_PREFIX_double "ldexp.v4f64"); +#else + METAL_FUNC vec ldexp(vec x, vec k) { + vec ret_val; + ret_val[0] = ldexp(x[0], k[0]); + ret_val[1] = ldexp(x[1], k[1]); + ret_val[2] = ldexp(x[2], k[2]); + ret_val[3] = ldexp(x[3], k[3]); + return ret_val; + } +#endif + METAL_FUNC vec fdim(vec x, vec y) { + vec ret_val; + ret_val[0] = fdim(x[0], y[0]); + ret_val[1] = fdim(x[1], y[1]); + ret_val[2] = fdim(x[2], y[2]); + ret_val[3] = fdim(x[3], y[3]); + return ret_val; + } +#if defined(__HAVE_AIR_FRACT__) + METAL_ASM vec fract(vec x) __asm("air." _AIR_PREFIX_double "fract.v4f64"); +#else + METAL_FUNC vec fract(vec x) { + vec ret_val; + ret_val[0] = fract(x[0]); + ret_val[1] = fract(x[1]); + ret_val[2] = fract(x[2]); + ret_val[3] = fract(x[3]); + return ret_val; + } +#endif + METAL_ASM vec log10(vec x) __asm("air.log10.v4f64"); + + METAL_FUNC vec modf(vec x, thread vec &intval) { + intval = trunc(x); + vec isinf_x = isinf(x); + return copysign(select(x - intval, vec(0), isinf_x), x); + } + METAL_ASM vec sincos(vec x, thread vec &cosval) __asm("air." _AIR_PREFIX_double "sincos.v4f64"); + + //METAL_ASM vec trunc(vec x) __asm("air." _AIR_PREFIX_double "trunc.v4f64"); +#endif +} // namespace metal + +#endif // __METAL_MATH diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math_utils b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math_utils new file mode 100644 index 00000000..ace3700a --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_math_utils @@ -0,0 +1,230 @@ +//===-- metal_math_utils --------------------------------------------------===// +// Copyright (c) 2015-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_MATH_UTILS +#define __METAL_MATH_UTILS + +#define _METAL_PRECISE_MATH false +#define _METAL_FAST_MATH true +#if defined(__FAST_MATH__) +#define _METAL_MAYBE_FAST_MATH _METAL_FAST_MATH +#else +#define _METAL_MAYBE_FAST_MATH _METAL_PRECISE_MATH +#endif + +#pragma METAL internals : enable +namespace metal +{ +template +struct _is_scalar : bool_constant::value && is_arithmetic::value> +{ +}; + +template +struct _is_fp_vector : bool_constant::value && is_vector::value> +{ +}; + +template +struct _math_binary_func_operand_type +{ + using type = void; +}; + +// We shipped a version of Metal using overloded functions to implement binary +// functions instead of template functions. For any pair of scalar or vector +// types T, U for which a call to the overloaded version of foo +// `foo(T(x), U(y))` was valid (including via implicit conversion sequences), +// the call to the templated version must also be valid. +// +// The general form of the binary math function is `O foo(T, U)`; O is the +// floating-point arithmetic type the function operates with. The arguments (of +// type T and U) are cast to O before being passed to the builtin. +// The rules to deduce O from the pair are as follows: +// +// 1) If T and U are both the same floating-point type, identity conversion is +// triggered. +template +struct _math_binary_func_operand_type::value>::type> +{ + using type = T; +}; + +// 2) If T or U is a floating-point vector type, and the other is a +// floating-point or integral scalar type, then O is the floating-point +// vector type. +template +struct _math_binary_func_operand_type::value ^ _is_fp_vector::value) && (_is_scalar::value ^ _is_scalar::value)>::type> +{ + using type = typename conditional<_is_fp_vector::value, T, U>::type; +}; + +// 3) If T is a floating-point scalar type, and U is an integral scalar type, or +// reciprocally, then O is the floating-point scalar type. +template +struct _math_binary_func_operand_type::value && _is_scalar::value && (is_floating_point::value ^ is_floating_point::value)>::type> +{ + using type = typename conditional::value, T, U>::type; +}; + +// The rules described above work when half, float, and potentially double +// versions of a given binary function were available. In the precise or fast +// namespaces, only `float` versions of functions were available, and an +// additional rule applies. +template +struct _math_fast_or_precise_binary_func_operand_type : _math_binary_func_operand_type +{ +}; + +// 4) In the fast or precise namespaces, when T or U is float, and the other is +// a scalar type, then O is float. +template +struct _math_fast_or_precise_binary_func_operand_type::value && _is_scalar::value) || (is_same::value && _is_scalar::value)>::type> +{ + using type = float; +}; + +// Here are some examples: +// // Case 1: +// half x1, y1; +// half res = foo(x1, y1); +// half2 x2, y2; +// half2 res = foo(x2, y2); +// +// // Case 2: +// int x3; +// half2 y3; +// half2 res = foo(x3, y3); // equivalent to `half2 res = foo(half2(x3), y3)` +// +// // Case 3: +// half x4; +// int y4; +// half res = foo(x4, y4); // equivalent to `half foo(x4, half(y4))` +// +// // Case 4: +// float x6; +// half y6; +// fast::foo(x6, y6); // equivalent to `float foo(x6, float(y6))` +// +// The following are invalid: +// // The calls would be ambiguous: +// float x6; +// half y6; +// foo(x6, y6); +// +// half2 x7; +// float2 y7; +// foo(x7, y7); +// +// char x8; +// int y8; +// foo(x8, y8); +// +// // This call was and is invalid: no implicit conversion from int2 to half2 +// half2 x9; +// int2 y9; +// foo(x9, y9); + +template +using _math_binary_func_operand_type_t = typename _math_binary_func_operand_type::type; +template +using _math_fast_or_precise_binary_func_operand_type_t = typename _math_fast_or_precise_binary_func_operand_type::type; +template +struct _math_binary_func_enable : bool_constant>::value> +{ +}; +template +struct _math_fast_or_precise_binary_func_enable : bool_constant>::value> +{ +}; + +template +struct _math_ternary_func_operand_type +{ + using type = void; +}; + +// We shipped a version of Metal using overloded functions to implement ternary +// functions instead of template functions. For any tria of scalar or vector +// types T, U, V for which a call to the overloaded version of foo +// `foo(T(x), U(y), V(z))` was valid (including via implicit conversion +// sequences), the call to the templated version must also be valid. +// +// The general form of the ternary math function is `O foo(T, U, V)`; O is the +// floating-point arithmetic type the function operates with. The arguments (of +// type T, U, and V) are cast to O before being passed to the builtin. +// The rules to deduce O from the triad are as follows: +// +// 1) If T, U, and V are the same floating-point type, identity conversion is +// triggered. +template +struct _math_ternary_func_operand_type::value>::type> +{ + using type = T; +}; + +// 2) If only one of T, U, V is a floating-point vector type, and the others +// are integral scalar types, then O is the floating point vector type. +template +struct _math_ternary_func_operand_type::value + _is_fp_vector::value + _is_fp_vector::value) == 1 && (_is_scalar::value + _is_scalar::value + _is_scalar::value) == 2 && (!is_same::value && !is_same::value && !is_same::value)>::type> +{ + using type = typename conditional<_is_fp_vector::value, T, U>::type; +}; + +// 3) If only one of T, U, V is a floating-point scalar type, and the others +// are integral scalar types, then O is the floating point scalar type. +template +struct _math_ternary_func_operand_type::value && _is_scalar::value && _is_scalar::value && (is_floating_point::value + is_floating_point::value + is_floating_point::value) == 1 && (!is_same::value && !is_same::value && !is_same::value)>::type> +{ + using type = typename conditional::value, T, typename conditional::value, U, V>::type>::type; +}; + +// 4) If T = U, then O only depends on T and V only; if T = V or U = V, then O +// depends on T and U only. +template +struct _math_ternary_func_operand_type::value>::type> : _math_binary_func_operand_type +{ +}; +template +struct _math_ternary_func_operand_type::value>::type> : _math_binary_func_operand_type +{ +}; +template +struct _math_ternary_func_operand_type::value>::type> : _math_binary_func_operand_type +{ +}; + +// The rules described above work when half, float, and potentially double +// versions of a given ternary function were available. In the precise or fast +// namespaces, only `float` versions of functions were available, and an +// additional rule applies. +template +struct _math_fast_or_precise_ternary_func_operand_type : _math_ternary_func_operand_type +{ +}; + +// 5) In the fast or precise namespaces, when at least one of T, U, or V is +// float, and all the others are scalar types, then O is float. +template +struct _math_fast_or_precise_ternary_func_operand_type::value || is_same::value || is_same::value) && (_is_scalar::value && _is_scalar::value && _is_scalar::value)>::type> +{ + using type = float; +}; + +template +using _math_ternary_func_operand_type_t = typename _math_ternary_func_operand_type::type; +template +using _math_fast_or_precise_ternary_func_operand_type_t = typename _math_fast_or_precise_ternary_func_operand_type::type; +template +struct _math_ternary_func_enable : bool_constant>::value> +{ +}; +template +struct _math_fast_or_precise_ternary_func_enable : bool_constant>::value> +{ +}; +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_MATH_UTILS diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_matrix b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_matrix new file mode 100644 index 00000000..2d930833 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_matrix @@ -0,0 +1,1386 @@ +//===-- metal_matrix ------------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_MATRIX_H +#define __METAL_MATRIX_H + +#include +#include +#include +#include +#include + +#pragma METAL internals : enable +namespace metal { +// Metal 1.1 s2.2: Vector and Matrix Data Types. + +template ::value && is_floating_point::value && Cols >=2 && Rows >= 2>::type> +struct matrix +{ + vec columns[Cols]; + +private: + template + static vec build_col(initializer_list col, _integer_sequence) + { + return {(R < col.size() ? *(col.begin() + R) : U())...}; + } + template + static vec build_diag_col(int c, T val, _integer_sequence) + { + return {(c == R ? val : 0)...}; + } +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template + static vec build_full_col(int c, initializer_list elems, _integer_sequence) + { + return {*(elems.begin() + c * Rows + R)...}; + } +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + + struct cols_init_tag + { + }; + struct cols_all_tag + { + }; +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + struct elems_all_tag + { + }; +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + + template + METAL_FUNC explicit matrix(T val, _integer_sequence) thread + : columns{build_diag_col(C, val, _make_integer_sequence())...} + { + } + + template + METAL_FUNC explicit matrix(cols_init_tag, initializer_list> cols, _integer_sequence) thread + : columns{(C < cols.size() ? *(cols.begin() + C) : vec())...} + { + } + + template >...>::value>::type> + METAL_FUNC explicit matrix(cols_all_tag, U... cols) thread + : columns{vec(cols)...} + { + } + +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template ...>::value>::type> + METAL_FUNC explicit matrix(elems_all_tag, U... elems) thread + : matrix({T(elems)...}, _make_integer_sequence()) + { + } + template + METAL_FUNC explicit matrix(initializer_list elems, _integer_sequence) thread + : columns{build_full_col(C, elems, _make_integer_sequence())...} + { + } +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template + METAL_FUNC explicit matrix(T val, _integer_sequence) constant + : columns{build_diag_col(C, val, _make_integer_sequence())...} + { + } + + template + METAL_FUNC explicit matrix(cols_init_tag, initializer_list> cols, _integer_sequence) constant + : columns{(C < cols.size() ? *(cols.begin() + C) : vec())...} + { + } + + template >...>::value>::type> + METAL_FUNC explicit matrix(cols_all_tag, U... cols) constant + : columns{vec(cols)...} + { + } + +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template ...>::value>::type> + METAL_FUNC explicit matrix(elems_all_tag, U... elems) constant + : matrix({T(elems)...}, _make_integer_sequence()) + { + } + template + METAL_FUNC explicit matrix(initializer_list elems, _integer_sequence) constant + : columns{build_full_col(C, elems, _make_integer_sequence())...} + { + } +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + + template + METAL_FUNC explicit matrix(const thread matrix &that, _integer_sequence) thread + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const device matrix &that, _integer_sequence) thread + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const constant matrix &that, _integer_sequence) thread + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const threadgroup matrix &that, _integer_sequence) thread + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const thread matrix &that, _integer_sequence) constant + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const device matrix &that, _integer_sequence) constant + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const constant matrix &that, _integer_sequence) constant + : columns{vec(that.columns[C])...} + { + } + template + METAL_FUNC explicit matrix(const threadgroup matrix &that, _integer_sequence) constant + : columns{vec(that.columns[C])...} + { + } + +public: + METAL_FUNC matrix() thread = default; + + METAL_FUNC matrix(initializer_list> cols) thread + : matrix(cols_init_tag(), cols, _make_integer_sequence()) + { + } + template ::type> + METAL_FUNC explicit matrix(initializer_list... cols) thread + : columns{build_col(cols, _make_integer_sequence())...} + { + } + + METAL_FUNC explicit matrix(T val) thread + : matrix(val, _make_integer_sequence()) + { + } + +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template ::type> + METAL_FUNC explicit matrix(U... vals) thread + : matrix(conditional_t(), vals...) + { + } +#else + template ::type> + METAL_FUNC explicit matrix(U... vals) thread + : matrix(cols_all_tag(), vals...) + { + } +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + METAL_FUNC matrix() constant = default; + + METAL_FUNC matrix(initializer_list> cols) constant + : matrix(cols_init_tag(), cols, _make_integer_sequence()) + { + } + template ::type> + METAL_FUNC explicit matrix(initializer_list... cols) constant + : columns{build_col(cols, _make_integer_sequence())...} + { + } + + METAL_FUNC explicit matrix(T val) constant + : matrix(val, _make_integer_sequence()) + { + } + +#if defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + template ::type> + METAL_FUNC explicit matrix(U... vals) constant + : matrix(conditional_t(), vals...) + { + } +#else + template ::type> + METAL_FUNC explicit matrix(U... vals) constant + : matrix(cols_all_tag(), vals...) + { + } +#endif // defined(__HAVE_MATRIX_MULTIPLE_SCALAR_CONSTRUCTORS__) + + METAL_FUNC matrix(const thread matrix &that) thread = default; + + template + METAL_FUNC explicit matrix(const thread matrix &that) thread + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const device matrix &that) thread = default; + + template + METAL_FUNC explicit matrix(const device matrix &that) thread + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const constant matrix &that) thread = default; + + template + METAL_FUNC explicit matrix(const constant matrix &that) thread + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const threadgroup matrix &that) thread = default; + + template + METAL_FUNC explicit matrix(const threadgroup matrix &that) thread + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const thread matrix &that) constant = default; + + template + METAL_FUNC explicit matrix(const thread matrix &that) constant + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const device matrix &that) constant = default; + + template + METAL_FUNC explicit matrix(const device matrix &that) constant + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const constant matrix &that) constant = default; + + template + METAL_FUNC explicit matrix(const constant matrix &that) constant + : matrix(that, _make_integer_sequence()) + { + } + METAL_FUNC matrix(const threadgroup matrix &that) constant = default; + + template + METAL_FUNC explicit matrix(const threadgroup matrix &that) constant + : matrix(that, _make_integer_sequence()) + { + } + +public: + METAL_FUNC thread vec &operator[](int r) thread + { + return columns[r]; + } + METAL_FUNC device vec &operator[](int r) device + { + return columns[r]; + } + METAL_FUNC threadgroup vec &operator[](int r) threadgroup + { + return columns[r]; + } + + METAL_FUNC const thread vec &operator[](int r) const thread + { + return columns[r]; + } + METAL_FUNC const device vec &operator[](int r) const device + { + return columns[r]; + } + METAL_FUNC const constant vec &operator[](int r) const constant + { + return columns[r]; + } + METAL_FUNC const threadgroup vec &operator[](int r) const threadgroup + { + return columns[r]; + } + +private: + template + static void _make_compound_foreach(thread matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(thread matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b); + } + template + static void _make_compound_foreach(device matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(device matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b); + } + template + static void _make_compound_foreach(threadgroup matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(threadgroup matrix &a, vec b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b); + } + + template + static void _make_compound_foreach(thread matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(thread matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(thread matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(thread matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(thread matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(thread matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(thread matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(thread matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(device matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(device matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(device matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(device matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(device matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(device matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(device matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(device matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const thread matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const device matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const constant matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - sizeof...(C)] = op(a[Cols - sizeof...(C)], b[Cols - sizeof...(C)]); + _make_compound_foreach(a, b, op, _make_integer_sequence()); + } + template + static void _make_compound_foreach(threadgroup matrix &a, const threadgroup matrix &b, O op, _integer_sequence) + { + a[Cols - 1] = op(a[Cols - 1], b[Cols - 1]); + } + +public: + METAL_FUNC thread matrix &operator+=(const thread matrix &that) thread + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator-=(const thread matrix &that) thread + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator+=(const device matrix &that) thread + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator-=(const device matrix &that) thread + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator+=(const constant matrix &that) thread + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator-=(const constant matrix &that) thread + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator+=(const threadgroup matrix &that) thread + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC thread matrix &operator-=(const threadgroup matrix &that) thread + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator+=(const thread matrix &that) device + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator-=(const thread matrix &that) device + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator+=(const device matrix &that) device + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator-=(const device matrix &that) device + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator+=(const constant matrix &that) device + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator-=(const constant matrix &that) device + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator+=(const threadgroup matrix &that) device + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator-=(const threadgroup matrix &that) device + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator+=(const thread matrix &that) threadgroup + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator-=(const thread matrix &that) threadgroup + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator+=(const device matrix &that) threadgroup + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator-=(const device matrix &that) threadgroup + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator+=(const constant matrix &that) threadgroup + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator-=(const constant matrix &that) threadgroup + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator+=(const threadgroup matrix &that) threadgroup + { + _make_compound_foreach(*this, that, plus>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator-=(const threadgroup matrix &that) threadgroup + { + _make_compound_foreach(*this, that, minus>(), _make_integer_sequence()); + return *this; + } + + METAL_FUNC thread matrix &operator*=(T val) thread + { + _make_compound_foreach(*this, vec(val), multiplies>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC device matrix &operator*=(T val) device + { + _make_compound_foreach(*this, vec(val), multiplies>(), _make_integer_sequence()); + return *this; + } + METAL_FUNC threadgroup matrix &operator*=(T val) threadgroup + { + _make_compound_foreach(*this, vec(val), multiplies>(), _make_integer_sequence()); + return *this; + } +}; + +typedef matrix half2x2; +typedef matrix half2x3; +typedef matrix half2x4; +typedef matrix half3x2; +typedef matrix half3x3; +typedef matrix half3x4; +typedef matrix half4x2; +typedef matrix half4x3; +typedef matrix half4x4; +typedef matrix float2x2; +typedef matrix float2x3; +typedef matrix float2x4; +typedef matrix float3x2; +typedef matrix float3x3; +typedef matrix float3x4; +typedef matrix float4x2; +typedef matrix float4x3; +typedef matrix float4x4; +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double2x2; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double2x3; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double2x4; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double3x2; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double3x3; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double3x4; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double4x2; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double4x3; +#endif +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef matrix double4x4; +#endif + +// Metal 1.1 s3.2: Matrix Operators. + +template +METAL_FUNC matrix operator*(T a, const thread matrix &b) +{ + return _matrix_scalar_product_impl(b, a, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(const thread matrix &a, T b) +{ + return b * a; +} +template +METAL_FUNC vec operator*(vec a, const thread matrix &b) +{ + return _vector_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec operator*(const thread matrix &a, vec b) +{ + return _matrix_vector_product_impl(vec(), a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(T a, const device matrix &b) +{ + return _matrix_scalar_product_impl(b, a, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(const device matrix &a, T b) +{ + return b * a; +} +template +METAL_FUNC vec operator*(vec a, const device matrix &b) +{ + return _vector_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec operator*(const device matrix &a, vec b) +{ + return _matrix_vector_product_impl(vec(), a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(T a, const constant matrix &b) +{ + return _matrix_scalar_product_impl(b, a, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(const constant matrix &a, T b) +{ + return b * a; +} +template +METAL_FUNC vec operator*(vec a, const constant matrix &b) +{ + return _vector_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec operator*(const constant matrix &a, vec b) +{ + return _matrix_vector_product_impl(vec(), a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(T a, const threadgroup matrix &b) +{ + return _matrix_scalar_product_impl(b, a, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator*(const threadgroup matrix &a, T b) +{ + return b * a; +} +template +METAL_FUNC vec operator*(vec a, const threadgroup matrix &b) +{ + return _vector_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec operator*(const threadgroup matrix &a, vec b) +{ + return _matrix_vector_product_impl(vec(), a, b, _make_integer_sequence()); +} + +template +METAL_FUNC matrix _matrix_scalar_product_impl(const thread matrix &a, T b, _integer_sequence) +{ + return {(a[C] * vec(b))...}; +} +template +METAL_FUNC vec _vector_matrix_product_impl(vec a, const thread matrix &b, _integer_sequence) +{ + return {dot(a, b[C])...}; +} + +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const thread matrix &a, vec b, _integer_sequence) +{ + return _matrix_vector_product_impl(tmp + a[K - sizeof...(H)] * b[K - sizeof...(H)], a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const thread matrix &a, vec b, _integer_sequence) +{ + return tmp + a[K - 1] * b[K - 1]; +} +template +METAL_FUNC matrix _matrix_scalar_product_impl(const device matrix &a, T b, _integer_sequence) +{ + return {(a[C] * vec(b))...}; +} +template +METAL_FUNC vec _vector_matrix_product_impl(vec a, const device matrix &b, _integer_sequence) +{ + return {dot(a, b[C])...}; +} + +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const device matrix &a, vec b, _integer_sequence) +{ + return _matrix_vector_product_impl(tmp + a[K - sizeof...(H)] * b[K - sizeof...(H)], a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const device matrix &a, vec b, _integer_sequence) +{ + return tmp + a[K - 1] * b[K - 1]; +} +template +METAL_FUNC matrix _matrix_scalar_product_impl(const constant matrix &a, T b, _integer_sequence) +{ + return {(a[C] * vec(b))...}; +} +template +METAL_FUNC vec _vector_matrix_product_impl(vec a, const constant matrix &b, _integer_sequence) +{ + return {dot(a, b[C])...}; +} + +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const constant matrix &a, vec b, _integer_sequence) +{ + return _matrix_vector_product_impl(tmp + a[K - sizeof...(H)] * b[K - sizeof...(H)], a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const constant matrix &a, vec b, _integer_sequence) +{ + return tmp + a[K - 1] * b[K - 1]; +} +template +METAL_FUNC matrix _matrix_scalar_product_impl(const threadgroup matrix &a, T b, _integer_sequence) +{ + return {(a[C] * vec(b))...}; +} +template +METAL_FUNC vec _vector_matrix_product_impl(vec a, const threadgroup matrix &b, _integer_sequence) +{ + return {dot(a, b[C])...}; +} + +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const threadgroup matrix &a, vec b, _integer_sequence) +{ + return _matrix_vector_product_impl(tmp + a[K - sizeof...(H)] * b[K - sizeof...(H)], a, b, _make_integer_sequence()); +} +template +METAL_FUNC vec _matrix_vector_product_impl(vec tmp, const threadgroup matrix &a, vec b, _integer_sequence) +{ + return tmp + a[K - 1] * b[K - 1]; +} + +template +METAL_FUNC matrix operator+(const thread matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const thread matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const thread matrix &a, const thread matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const thread matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const thread matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const thread matrix &a, const device matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const thread matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const thread matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const thread matrix &a, const constant matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const thread matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const thread matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const thread matrix &a, const threadgroup matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const device matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const device matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const device matrix &a, const thread matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const device matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const device matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const device matrix &a, const device matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const device matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const device matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const device matrix &a, const constant matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const device matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const device matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const device matrix &a, const threadgroup matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const constant matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const constant matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const constant matrix &a, const thread matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const constant matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const constant matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const constant matrix &a, const device matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const constant matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const constant matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const constant matrix &a, const constant matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const constant matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const constant matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const constant matrix &a, const threadgroup matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const threadgroup matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const threadgroup matrix &a, const thread matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const threadgroup matrix &a, const thread matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const threadgroup matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const threadgroup matrix &a, const device matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const threadgroup matrix &a, const device matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const threadgroup matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const threadgroup matrix &a, const constant matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const threadgroup matrix &a, const constant matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} +template +METAL_FUNC matrix operator+(const threadgroup matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp += b; +} +template +METAL_FUNC matrix operator-(const threadgroup matrix &a, const threadgroup matrix &b) +{ + matrix tmp = a; + return tmp -= b; +} +template +METAL_FUNC matrix operator*(const threadgroup matrix &a, const threadgroup matrix &b) +{ + return _matrix_matrix_product_impl(a, b, _make_integer_sequence()); +} + +template +METAL_FUNC matrix _matrix_matrix_product_impl(const thread matrix &a, const thread matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const thread matrix &a, const device matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const thread matrix &a, const constant matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const thread matrix &a, const threadgroup matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const device matrix &a, const thread matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const device matrix &a, const device matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const device matrix &a, const constant matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const device matrix &a, const threadgroup matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const constant matrix &a, const thread matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const constant matrix &a, const device matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const constant matrix &a, const constant matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const constant matrix &a, const threadgroup matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const threadgroup matrix &a, const thread matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const threadgroup matrix &a, const device matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const threadgroup matrix &a, const constant matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} +template +METAL_FUNC matrix _matrix_matrix_product_impl(const threadgroup matrix &a, const threadgroup matrix &b, _integer_sequence) +{ + return {a * b[C]...}; +} + +template +METAL_FUNC thread vec &operator*=(thread vec &a, const thread matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC thread vec &operator*=(thread vec &a, const device matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC thread vec &operator*=(thread vec &a, const constant matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC thread vec &operator*=(thread vec &a, const threadgroup matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC device vec &operator*=(device vec &a, const thread matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC device vec &operator*=(device vec &a, const device matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC device vec &operator*=(device vec &a, const constant matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC device vec &operator*=(device vec &a, const threadgroup matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC threadgroup vec &operator*=(threadgroup vec &a, const thread matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC threadgroup vec &operator*=(threadgroup vec &a, const device matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC threadgroup vec &operator*=(threadgroup vec &a, const constant matrix &b) +{ + return a = a * b; +} +template +METAL_FUNC threadgroup vec &operator*=(threadgroup vec &a, const threadgroup matrix &b) +{ + return a = a * b; +} + +// Metal 1.1 s5.6: Matrix Functions. + +template +METAL_FUNC matrix transpose(const thread matrix &a) +{ + return _transpose_impl(a, _make_integer_sequence()); +} +template +METAL_FUNC T determinant(const thread matrix &a) +{ + return _determinant_impl(a, 0, _make_determinant_rows(_make_integer_sequence()), _make_integer_sequence()); +} + +template +METAL_FUNC matrix _transpose_impl(const thread matrix &a, _integer_sequence) +{ + return {_transpose_row(R, a, _make_integer_sequence())...}; +} +template +METAL_FUNC vec _transpose_row(int r, const thread matrix &a, _integer_sequence) +{ + return {a[C][r]...}; +} + +template +METAL_FUNC T _determinant_impl(const thread matrix &a, int c, vec rows, _integer_sequence) +{ + return _make_accumulation(((R & 1 ? -1 : 1) * a[c][rows[R]] * _determinant_impl(a, c + 1, _remove_determinant_row(rows, R, _make_integer_sequence()), _make_integer_sequence()))...); +} +template +METAL_FUNC T _determinant_impl(const thread matrix &a, int c, vec rows, _integer_sequence) +{ + return a[c][rows[0]] * a[c + 1][rows[1]] - a[c][rows[1]] * a[c + 1][rows[0]]; +} +template +METAL_FUNC matrix transpose(const device matrix &a) +{ + return _transpose_impl(a, _make_integer_sequence()); +} +template +METAL_FUNC T determinant(const device matrix &a) +{ + return _determinant_impl(a, 0, _make_determinant_rows(_make_integer_sequence()), _make_integer_sequence()); +} + +template +METAL_FUNC matrix _transpose_impl(const device matrix &a, _integer_sequence) +{ + return {_transpose_row(R, a, _make_integer_sequence())...}; +} +template +METAL_FUNC vec _transpose_row(int r, const device matrix &a, _integer_sequence) +{ + return {a[C][r]...}; +} + +template +METAL_FUNC T _determinant_impl(const device matrix &a, int c, vec rows, _integer_sequence) +{ + return _make_accumulation(((R & 1 ? -1 : 1) * a[c][rows[R]] * _determinant_impl(a, c + 1, _remove_determinant_row(rows, R, _make_integer_sequence()), _make_integer_sequence()))...); +} +template +METAL_FUNC T _determinant_impl(const device matrix &a, int c, vec rows, _integer_sequence) +{ + return a[c][rows[0]] * a[c + 1][rows[1]] - a[c][rows[1]] * a[c + 1][rows[0]]; +} +template +METAL_FUNC matrix transpose(const constant matrix &a) +{ + return _transpose_impl(a, _make_integer_sequence()); +} +template +METAL_FUNC T determinant(const constant matrix &a) +{ + return _determinant_impl(a, 0, _make_determinant_rows(_make_integer_sequence()), _make_integer_sequence()); +} + +template +METAL_FUNC matrix _transpose_impl(const constant matrix &a, _integer_sequence) +{ + return {_transpose_row(R, a, _make_integer_sequence())...}; +} +template +METAL_FUNC vec _transpose_row(int r, const constant matrix &a, _integer_sequence) +{ + return {a[C][r]...}; +} + +template +METAL_FUNC T _determinant_impl(const constant matrix &a, int c, vec rows, _integer_sequence) +{ + return _make_accumulation(((R & 1 ? -1 : 1) * a[c][rows[R]] * _determinant_impl(a, c + 1, _remove_determinant_row(rows, R, _make_integer_sequence()), _make_integer_sequence()))...); +} +template +METAL_FUNC T _determinant_impl(const constant matrix &a, int c, vec rows, _integer_sequence) +{ + return a[c][rows[0]] * a[c + 1][rows[1]] - a[c][rows[1]] * a[c + 1][rows[0]]; +} +template +METAL_FUNC matrix transpose(const threadgroup matrix &a) +{ + return _transpose_impl(a, _make_integer_sequence()); +} +template +METAL_FUNC T determinant(const threadgroup matrix &a) +{ + return _determinant_impl(a, 0, _make_determinant_rows(_make_integer_sequence()), _make_integer_sequence()); +} + +template +METAL_FUNC matrix _transpose_impl(const threadgroup matrix &a, _integer_sequence) +{ + return {_transpose_row(R, a, _make_integer_sequence())...}; +} +template +METAL_FUNC vec _transpose_row(int r, const threadgroup matrix &a, _integer_sequence) +{ + return {a[C][r]...}; +} + +template +METAL_FUNC T _determinant_impl(const threadgroup matrix &a, int c, vec rows, _integer_sequence) +{ + return _make_accumulation(((R & 1 ? -1 : 1) * a[c][rows[R]] * _determinant_impl(a, c + 1, _remove_determinant_row(rows, R, _make_integer_sequence()), _make_integer_sequence()))...); +} +template +METAL_FUNC T _determinant_impl(const threadgroup matrix &a, int c, vec rows, _integer_sequence) +{ + return a[c][rows[0]] * a[c + 1][rows[1]] - a[c][rows[1]] * a[c + 1][rows[0]]; +} + +template +METAL_FUNC vec _make_determinant_rows(_integer_sequence) +{ + return {R...}; +} +template +METAL_FUNC vec _remove_determinant_row(vec rows, int r, _integer_sequence) +{ + return {rows[R < r ? R : R + 1]...}; +} +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_MATRIX_H diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_numeric b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_numeric new file mode 100644 index 00000000..f395f2e4 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_numeric @@ -0,0 +1,22 @@ +//===-- metal_numeric -----------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_NUMERIC +#define __METAL_NUMERIC + +namespace metal +{ +template +METAL_FUNC T _make_accumulation(T val) +{ + return val; +} +template +METAL_FUNC T _make_accumulation(T acc, T val, U... vals) +{ + return _make_accumulation(acc + val, vals...); +} +} // namespace metal + +#endif // __METAL_NUMERIC diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_pack b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_pack new file mode 100644 index 00000000..e7cb3a44 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_pack @@ -0,0 +1,133 @@ +//===-- metal_pack --------------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_PACK +#define __METAL_PACK + +namespace metal +{ +// Metal 1.1 s5.11: Pack and Unpack Functions. + +METAL_FUNC float4 unpack_unorm4x8_to_float(uint x) +{ + return __metal_unpack_unorm4x8(x, float4()); +} +METAL_FUNC float4 unpack_snorm4x8_to_float(uint x) +{ + return __metal_unpack_snorm4x8(x, float4()); +} +METAL_FUNC half4 unpack_unorm4x8_to_half(uint x) +{ + return __metal_unpack_unorm4x8(x, half4()); +} +METAL_FUNC half4 unpack_snorm4x8_to_half(uint x) +{ + return __metal_unpack_snorm4x8(x, half4()); +} + +METAL_FUNC float4 unpack_unorm4x8_srgb_to_float(uint x) +{ + return __metal_unpack_unorm4x8_srgb(x, float4()); +} +METAL_FUNC half4 unpack_unorm4x8_srgb_to_half(uint x) +{ + return __metal_unpack_unorm4x8_srgb(x, half4()); +} + +METAL_FUNC float2 unpack_unorm2x16_to_float(uint x) +{ + return __metal_unpack_unorm2x16(x, float2()); +} +METAL_FUNC float2 unpack_snorm2x16_to_float(uint x) +{ + return __metal_unpack_snorm2x16(x, float2()); +} +METAL_FUNC half2 unpack_unorm2x16_to_half(uint x) +{ + return __metal_unpack_unorm2x16(x, half2()); +} +METAL_FUNC half2 unpack_snorm2x16_to_half(uint x) +{ + return __metal_unpack_snorm2x16(x, half2()); +} + +METAL_FUNC float4 unpack_unorm10a2_to_float(uint x) +{ + return __metal_unpack_unorm_rgb10a2(x, float4()); +} +METAL_FUNC float3 unpack_unorm565_to_float(ushort x) +{ + return __metal_unpack_unorm_rgb565(x, float3()); +} +METAL_FUNC half4 unpack_unorm10a2_to_half(uint x) +{ + return __metal_unpack_unorm_rgb10a2(x, half4()); +} +METAL_FUNC half3 unpack_unorm565_to_half(ushort x) +{ + return __metal_unpack_unorm_rgb565(x, half3()); +} + +METAL_FUNC uint pack_float_to_unorm4x8(float4 x) +{ + return __metal_pack_unorm4x8(x); +} +METAL_FUNC uint pack_float_to_snorm4x8(float4 x) +{ + return __metal_pack_snorm4x8(x); +} +METAL_FUNC uint pack_half_to_unorm4x8(half4 x) +{ + return __metal_pack_unorm4x8(x); +} +METAL_FUNC uint pack_half_to_snorm4x8(half4 x) +{ + return __metal_pack_snorm4x8(x); +} + +METAL_FUNC uint pack_float_to_srgb_unorm4x8(float4 x) +{ + return __metal_pack_unorm4x8_srgb(x); +} +METAL_FUNC uint pack_half_to_srgb_unorm4x8(half4 x) +{ + return __metal_pack_unorm4x8_srgb(x); +} + +METAL_FUNC uint pack_float_to_unorm2x16(float2 x) +{ + return __metal_pack_unorm2x16(x); +} +METAL_FUNC uint pack_float_to_snorm2x16(float2 x) +{ + return __metal_pack_snorm2x16(x); +} +METAL_FUNC uint pack_half_to_unorm2x16(half2 x) +{ + return __metal_pack_unorm2x16(x); +} +METAL_FUNC uint pack_half_to_snorm2x16(half2 x) +{ + return __metal_pack_snorm2x16(x); +} + +METAL_FUNC uint pack_float_to_unorm10a2(float4 x) +{ + return __metal_pack_unorm_rgb10a2(x); +} +METAL_FUNC ushort pack_float_to_unorm565(float3 x) +{ + return __metal_pack_unorm_rgb565(x); +} +METAL_FUNC uint pack_half_to_unorm10a2(half4 x) +{ + return __metal_pack_unorm_rgb10a2(x); +} +METAL_FUNC ushort pack_half_to_unorm565(half3 x) +{ + return __metal_pack_unorm_rgb565(x); +} +} // namespace metal + +#endif // __METAL_PACK diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_packed_vector b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_packed_vector new file mode 100644 index 00000000..ef90e97a --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_packed_vector @@ -0,0 +1,200 @@ +//===-- metal_packed_vector -----------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_PACKED_VECTOR +#define __METAL_PACKED_VECTOR + +typedef __attribute__((__packed_vector_type__(2))) bool packed_bool2; +typedef __attribute__((__packed_vector_type__(3))) bool packed_bool3; +typedef __attribute__((__packed_vector_type__(4))) bool packed_bool4; +typedef struct __Reserved_Name__Do_not_use_packed_bool8 packed_bool8; +typedef struct __Reserved_Name__Do_not_use_packed_bool16 packed_bool16; + +typedef __attribute__((__packed_vector_type__(2))) char packed_char2; +typedef __attribute__((__packed_vector_type__(3))) char packed_char3; +typedef __attribute__((__packed_vector_type__(4))) char packed_char4; +typedef struct __Reserved_Name__Do_not_use_packed_char8 packed_char8; +typedef struct __Reserved_Name__Do_not_use_packed_char16 packed_char16; + +typedef __attribute__((__packed_vector_type__(2))) unsigned char packed_uchar2; +typedef __attribute__((__packed_vector_type__(3))) unsigned char packed_uchar3; +typedef __attribute__((__packed_vector_type__(4))) unsigned char packed_uchar4; +typedef struct __Reserved_Name__Do_not_use_packed_uchar16 packed_uchar8; +typedef struct __Reserved_Name__Do_not_use_packed_uchar16 packed_uchar16; + +typedef __attribute__((__packed_vector_type__(2))) short packed_short2; +typedef __attribute__((__packed_vector_type__(3))) short packed_short3; +typedef __attribute__((__packed_vector_type__(4))) short packed_short4; +typedef struct __Reserved_Name__Do_not_use_packed_short8 packed_short8; +typedef struct __Reserved_Name__Do_not_use_packed_short16 packed_short16; + +typedef __attribute__((__packed_vector_type__(2))) unsigned short packed_ushort2; +typedef __attribute__((__packed_vector_type__(3))) unsigned short packed_ushort3; +typedef __attribute__((__packed_vector_type__(4))) unsigned short packed_ushort4; +typedef struct __Reserved_Name__Do_not_use_packed_ushort8 packed_ushort8; +typedef struct __Reserved_Name__Do_not_use_packed_ushort16 packed_ushort16; + +typedef __attribute__((__packed_vector_type__(2))) int packed_int2; +typedef __attribute__((__packed_vector_type__(3))) int packed_int3; +typedef __attribute__((__packed_vector_type__(4))) int packed_int4; +typedef struct __Reserved_Name__Do_not_use_packed_int8 packed_int8; +typedef struct __Reserved_Name__Do_not_use_packed_int16 packed_int16; + +typedef __attribute__((__packed_vector_type__(2))) unsigned int packed_uint2; +typedef __attribute__((__packed_vector_type__(3))) unsigned int packed_uint3; +typedef __attribute__((__packed_vector_type__(4))) unsigned int packed_uint4; +typedef struct __Reserved_Name__Do_not_use_packed_uint8 packed_uint8; +typedef struct __Reserved_Name__Do_not_use_packed_uint16 packed_uint16; + +typedef struct __Reserved_Name__Do_not_use_packed_long2 packed_long2; +typedef struct __Reserved_Name__Do_not_use_packed_long3 packed_long3; +typedef struct __Reserved_Name__Do_not_use_packed_long4 packed_long4; +typedef struct __Reserved_Name__Do_not_use_packed_long8 packed_long8; +typedef struct __Reserved_Name__Do_not_use_packed_long16 packed_long16; + +typedef struct __Reserved_Name__Do_not_use_packed_ulong2 packed_ulong2; +typedef struct __Reserved_Name__Do_not_use_packed_ulong3 packed_ulong3; +typedef struct __Reserved_Name__Do_not_use_packed_ulong4 packed_ulong4; +typedef struct __Reserved_Name__Do_not_use_packed_ulong8 packed_ulong8; +typedef struct __Reserved_Name__Do_not_use_packed_ulong16 packed_ulong16; + +typedef struct __Reserved_Name__Do_not_use_packed_llong2 packed_llong2; +typedef struct __Reserved_Name__Do_not_use_packed_llong3 packed_llong3; +typedef struct __Reserved_Name__Do_not_use_packed_llong4 packed_llong4; +typedef struct __Reserved_Name__Do_not_use_packed_llong8 packed_llong8; +typedef struct __Reserved_Name__Do_not_use_packed_llong16 packed_llong16; + +typedef struct __Reserved_Name__Do_not_use_packed_ullong2 packed_ullong2; +typedef struct __Reserved_Name__Do_not_use_packed_ullong3 packed_ullong3; +typedef struct __Reserved_Name__Do_not_use_packed_ullong4 packed_ullong4; +typedef struct __Reserved_Name__Do_not_use_packed_ullong8 packed_ullong8; +typedef struct __Reserved_Name__Do_not_use_packed_ullong16 packed_ullong16; + +typedef __attribute__((__packed_vector_type__(2))) half packed_half2; +typedef __attribute__((__packed_vector_type__(3))) half packed_half3; +typedef __attribute__((__packed_vector_type__(4))) half packed_half4; +typedef struct __Reserved_Name__Do_not_use_packed_half8 packed_half8; +typedef struct __Reserved_Name__Do_not_use_packed_half16 packed_half16; + +typedef __attribute__((__packed_vector_type__(2))) float packed_float2; +typedef __attribute__((__packed_vector_type__(3))) float packed_float3; +typedef __attribute__((__packed_vector_type__(4))) float packed_float4; +typedef struct __Reserved_Name__Do_not_use_packed_float8 packed_float8; +typedef struct __Reserved_Name__Do_not_use_packed_float16 packed_float16; + +#if defined(__HAVE_NATIVE_DOUBLE__) +typedef __attribute__((__packed_vector_type__(2))) double packed_double2; +typedef __attribute__((__packed_vector_type__(3))) double packed_double3; +typedef __attribute__((__packed_vector_type__(4))) double packed_double4; +#else +typedef struct __Reserved_Name__Do_not_use_packed_double2 packed_double2; +typedef struct __Reserved_Name__Do_not_use_packed_double3 packed_double3; +typedef struct __Reserved_Name__Do_not_use_packed_double4 packed_double4; +#endif +typedef struct __Reserved_Name__Do_not_use_packed_double8 packed_double8; +typedef struct __Reserved_Name__Do_not_use_packed_double16 packed_double16; + +typedef struct __Reserved_Name__Do_not_use_packed_quad2 packed_quad2; +typedef struct __Reserved_Name__Do_not_use_packed_quad3 packed_quad3; +typedef struct __Reserved_Name__Do_not_use_packed_quad4 packed_quad4; +typedef struct __Reserved_Name__Do_not_use_packed_quad8 packed_quad8; +typedef struct __Reserved_Name__Do_not_use_packed_quad16 packed_quad16; + +namespace metal +{ +typedef ::packed_bool2 packed_bool2; +typedef ::packed_bool3 packed_bool3; +typedef ::packed_bool4 packed_bool4; +typedef ::packed_bool8 packed_bool8; +typedef ::packed_bool16 packed_bool16; + +typedef ::packed_char2 packed_char2; +typedef ::packed_char3 packed_char3; +typedef ::packed_char4 packed_char4; +typedef ::packed_char8 packed_char8; +typedef ::packed_char16 packed_char16; + +typedef ::packed_uchar2 packed_uchar2; +typedef ::packed_uchar3 packed_uchar3; +typedef ::packed_uchar4 packed_uchar4; +typedef ::packed_uchar8 packed_uchar8; +typedef ::packed_uchar16 packed_uchar16; + +typedef ::packed_short2 packed_short2; +typedef ::packed_short3 packed_short3; +typedef ::packed_short4 packed_short4; +typedef ::packed_short8 packed_short8; +typedef ::packed_short16 packed_short16; + +typedef ::packed_ushort2 packed_ushort2; +typedef ::packed_ushort3 packed_ushort3; +typedef ::packed_ushort4 packed_ushort4; +typedef ::packed_ushort8 packed_ushort8; +typedef ::packed_ushort16 packed_ushort16; + +typedef ::packed_int2 packed_int2; +typedef ::packed_int3 packed_int3; +typedef ::packed_int4 packed_int4; +typedef ::packed_int8 packed_int8; +typedef ::packed_int16 packed_int16; + +typedef ::packed_uint2 packed_uint2; +typedef ::packed_uint3 packed_uint3; +typedef ::packed_uint4 packed_uint4; +typedef ::packed_uint8 packed_uint8; +typedef ::packed_uint16 packed_uint16; + +typedef ::packed_long2 packed_long2; +typedef ::packed_long3 packed_long3; +typedef ::packed_long4 packed_long4; +typedef ::packed_long8 packed_long8; +typedef ::packed_long16 packed_long16; + +typedef ::packed_ulong2 packed_ulong2; +typedef ::packed_ulong3 packed_ulong3; +typedef ::packed_ulong4 packed_ulong4; +typedef ::packed_ulong8 packed_ulong8; +typedef ::packed_ulong16 packed_ulong16; + +typedef ::packed_llong2 packed_llong2; +typedef ::packed_llong3 packed_llong3; +typedef ::packed_llong4 packed_llong4; +typedef ::packed_llong8 packed_llong8; +typedef ::packed_llong16 packed_llong16; + +typedef ::packed_ullong2 packed_ullong2; +typedef ::packed_ullong3 packed_ullong3; +typedef ::packed_ullong4 packed_ullong4; +typedef ::packed_ullong8 packed_ullong8; +typedef ::packed_ullong16 packed_ullong16; + +typedef ::packed_half2 packed_half2; +typedef ::packed_half3 packed_half3; +typedef ::packed_half4 packed_half4; +typedef ::packed_half8 packed_half8; +typedef ::packed_half16 packed_half16; + +typedef ::packed_float2 packed_float2; +typedef ::packed_float3 packed_float3; +typedef ::packed_float4 packed_float4; +typedef ::packed_float8 packed_float8; +typedef ::packed_float16 packed_float16; + +typedef ::packed_double2 packed_double2; +typedef ::packed_double3 packed_double3; +typedef ::packed_double4 packed_double4; +typedef ::packed_double8 packed_double8; +typedef ::packed_double16 packed_double16; + +typedef ::packed_quad2 packed_quad2; +typedef ::packed_quad3 packed_quad3; +typedef ::packed_quad4 packed_quad4; +typedef ::packed_quad8 packed_quad8; +typedef ::packed_quad16 packed_quad16; + +template +using packed_vec = T __attribute__((__packed_vector_type__(N))); +} + +#endif // __METAL_PACKED_VECTOR diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_quadgroup b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_quadgroup new file mode 100644 index 00000000..50f49592 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_quadgroup @@ -0,0 +1,250 @@ +//===-- metal_quadgroup ---------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_QUADGROUP +#define __METAL_QUADGROUP + +#include + +namespace metal { + +#if defined(__HAVE_QUADGROUP__) +// TODO: Specify the appropriate section for quadgroups. +// Metal 2.2 s5.: Quadgroup Functions. + +#pragma METAL internals : enable +template +struct __is_valid_quadgroup_type : false_type +{ +}; + +template +struct __is_valid_quadgroup_type, half> || + is_same_v, float> || +#if defined(__HAVE_NATIVE_DOUBLE__) + is_same_v, double> || +#endif + is_same_v, char> || + is_same_v, uchar> || + is_same_v, signed char> || + is_same_v, short> || + is_same_v, ushort> || + is_same_v, int> || + is_same_v, uint>>::type> : true_type +{ +}; + +template +struct __is_valid_quadgroup_integral_type : false_type +{ +}; + +template +struct __is_valid_quadgroup_integral_type, char> || + is_same_v, uchar> || + is_same_v, signed char> || + is_same_v, short> || + is_same_v, ushort> || + is_same_v, int> || + is_same_v, uint>>::type> : true_type +{ +}; +#pragma METAL internals : disable + +#if defined(__HAVE_QUADGROUP_BALLOT__) +struct quad_vote { + typedef ushort vote_t; + + METAL_FUNC explicit constexpr quad_vote(vote_t v = 0) thread : v(v & 0xf) + { + } + + METAL_FUNC explicit constexpr operator vote_t() const thread + { + return v; + } + + bool all() const thread + { + return __metal_quad_vote_all(v); + } + + bool any() const thread + { + return __metal_quad_vote_any(v); + } + +private: + vote_t v; +}; + +METAL_FUNC quad_vote quad_active_threads_mask() +{ + return quad_vote(__metal_quad_active_threads_mask()); +} + +METAL_FUNC bool quad_all(bool expr) +{ + return __metal_quad_all(expr); +} +#endif // defined(__HAVE_QUADGROUP_BALLOT__) + +#if defined(__HAVE_QUADGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T quad_and(T data) +{ + return __metal_quad_and(data); +} +#endif // defined(__HAVE_QUADGROUP_REDUCTION__) + +#if defined(__HAVE_QUADGROUP_BALLOT__) +METAL_FUNC bool quad_any(bool expr) +{ + return __metal_quad_any(expr); +} +#endif // defined(__HAVE_QUADGROUP_BALLOT__) + +#if defined(__HAVE_QUADGROUP_BALLOT__) +METAL_FUNC quad_vote quad_ballot(bool expr) +{ + return quad_vote(__metal_quad_ballot(expr)); +} +#endif // defined(__HAVE_QUADGROUP_BALLOT__) + +template ::value>::type> +METAL_FUNC T quad_broadcast(T data, ushort broadcast_lane_id) +{ + return __metal_quad_broadcast(data, broadcast_lane_id); +} + +#if defined(__HAVE_QUADGROUP_BROADCAST_FIRST__) +template ::value>::type> +METAL_FUNC T quad_broadcast_first(T data) +{ + return __metal_quad_broadcast_first(data); +} +#endif // defined(__HAVE_QUADGROUP_BROADCAST_FIRST__) + +#if defined(__HAVE_QUADGROUP_REDUCTION__) +METAL_FUNC bool quad_is_helper_thread() +{ + return __metal_quad_is_helper_thread(); +} + +template ::value>::type> +METAL_FUNC T quad_max(T data) +{ + return __metal_quad_max(data); +} + +template ::value>::type> +METAL_FUNC T quad_min(T data) +{ + return __metal_quad_min(data); +} +#endif // defined(__HAVE_QUADGROUP_REDUCTION__) + +#if defined(__HAVE_QUADGROUP_ONCE__) +METAL_FUNC bool quad_once() +{ + return __metal_quad_once(); +} +#endif // defined(__HAVE_QUADGROUP_ONCE__) + +#if defined(__HAVE_QUADGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T quad_or(T data) +{ + return __metal_quad_or(data); +} + +template ::value>::type> +METAL_FUNC T quad_prefix_exclusive_product(T data) +{ + return __metal_quad_prefix_exclusive_product(data); +} + +template ::value>::type> +METAL_FUNC T quad_prefix_exclusive_sum(T data) +{ + return __metal_quad_prefix_exclusive_sum(data); +} + +template ::value>::type> +METAL_FUNC T quad_prefix_inclusive_product(T data) +{ + return __metal_quad_prefix_inclusive_product(data); +} + +template ::value>::type> +METAL_FUNC T quad_prefix_inclusive_sum(T data) +{ + return __metal_quad_prefix_inclusive_sum(data); +} + +template ::value>::type> +METAL_FUNC T quad_product(T data) +{ + return __metal_quad_product(data); +} +#endif // defined(__HAVE_QUADGROUP_REDUCTION__) + +template ::value>::type> +METAL_FUNC T quad_shuffle(T data, ushort quad_lane_id) +{ + return __metal_quad_shuffle(data, quad_lane_id); +} + +template ::value>::type> +METAL_FUNC T quad_shuffle_down(T data, ushort delta) +{ + return __metal_quad_shuffle_down(data, delta); +} + +template ::value>::type> +METAL_FUNC T quad_shuffle_up(T data, ushort delta) +{ + return __metal_quad_shuffle_up(data, delta); +} + +#if defined(__HAVE_QUADGROUP_SHUFFLE_ROTATE_DOWN__) +template ::value>::type> +METAL_FUNC T quad_shuffle_rotate_down(T data, ushort delta) +{ + return __metal_quad_shuffle_rotate_down(data, delta); +} +#endif // defined(__HAVE_QUADGROUP_SHUFFLE_ROTATE_UP__) + +#if defined(__HAVE_QUADGROUP_SHUFFLE_ROTATE_UP__) +template ::value>::type> +METAL_FUNC T quad_shuffle_rotate_up(T data, ushort delta) +{ + return __metal_quad_shuffle_rotate_up(data, delta); +} +#endif // defined(__HAVE_QUADGROUP_SHUFFLE_ROTATE_UP__) + +template ::value>::type> +METAL_FUNC T quad_shuffle_xor(T data, ushort mask) +{ + return __metal_quad_shuffle_xor(data, mask); +} + +#if defined(__HAVE_QUADGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T quad_sum(T data) +{ + return __metal_quad_sum(data); +} + +template ::value>::type> +METAL_FUNC T quad_xor(T data) +{ + return __metal_quad_xor(data); +} +#endif // defined(__HAVE_QUADGROUP_REDUCTION__) +#endif // defined(__HAVE_QUADGROUP__) + +} // namespace metal + +#endif // __METAL_QUADGROUP diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_relational b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_relational new file mode 100644 index 00000000..beac830f --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_relational @@ -0,0 +1,200 @@ +//===-- metal_relational --------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_RELATIONAL +#define __METAL_RELATIONAL + +#pragma METAL internals : enable +namespace metal +{ +// Metal 1.1 s5.4: Relational Functions. + +template +struct _fp_encoding_traits_impl; + +template +struct _fp_encoding_traits_impl +{ + typedef typename _fp_encoding_traits_impl::encoding_type __attribute__((ext_vector_type(N))) encoding_type; + constexpr static constant encoding_type bit_width = sizeof(encoding_type) * CHAR_BIT; + constexpr static constant encoding_type sign_mask = _fp_encoding_traits_impl::sign_mask; + constexpr static constant encoding_type inf_mask = _fp_encoding_traits_impl::inf_mask; + constexpr static constant encoding_type min_mask = _fp_encoding_traits_impl::min_mask; +}; +template +struct _fp_encoding_traits_impl +{ + typedef typename _fp_encoding_traits_impl::encoding_type __attribute__((packed_vector_type(N))) encoding_type; + constexpr static constant encoding_type bit_width = sizeof(encoding_type) * CHAR_BIT; + constexpr static constant encoding_type sign_mask = _fp_encoding_traits_impl::sign_mask; + constexpr static constant encoding_type inf_mask = _fp_encoding_traits_impl::inf_mask; + constexpr static constant encoding_type min_mask = _fp_encoding_traits_impl::min_mask; +}; +template <> +struct _fp_encoding_traits_impl +{ + typedef ushort encoding_type; + constexpr static constant encoding_type bit_width = sizeof(encoding_type) * CHAR_BIT; + constexpr static constant encoding_type sign_mask = 0x8000; + constexpr static constant encoding_type inf_mask = 0x7c00; + constexpr static constant encoding_type min_mask = 0x0400; +}; +template <> +struct _fp_encoding_traits_impl +{ + typedef uint encoding_type; + constexpr static constant encoding_type bit_width = sizeof(encoding_type) * CHAR_BIT; + constexpr static constant encoding_type sign_mask = 0x80000000; + constexpr static constant encoding_type inf_mask = 0x7f800000; + constexpr static constant encoding_type min_mask = 0x00800000; +}; +#if defined(__HAVE_NATIVE_DOUBLE__) +template <> +struct _fp_encoding_traits_impl +{ + typedef unsigned __metal_internal_int64_t encoding_type; + constexpr static constant encoding_type bit_width = sizeof(encoding_type) * CHAR_BIT; + constexpr static constant encoding_type sign_mask = 0x8000000000000000; + constexpr static constant encoding_type inf_mask = 0x7ff0000000000000; + constexpr static constant encoding_type min_mask = 0x0010000000000000; +}; +#endif + +template +struct _fp_encoding_traits : _fp_encoding_traits_impl> +{ +}; + +template +struct _relational_select_operand_type +{ + typedef void type; +}; + +// We shipped a version of Metal using overloded functions to implement the +// select function instead of using a single template function. For any pair of +// scalar or vector types T, U for which a call to the overloaded version of +// select `select(T(x), U(y), c)` was valid (including via implicit conversion +// sequences), the call to the templated version must also be valid. +// +// Conversion of the third parameter into a boolean vector is not supported. +// +// The general form of the select function is `O select(T, U, B)`; O is the +// arithmetic type the function operates with. The arguments of type `T` and `U` +// are cast to `O` before being passed to the builtin. The argument of type `B` +// is either a `bool` -- if both `T` and `U` are scalar -- or a vector which +// length matches the length of `O`. The rules to deduce O from the pair +// are as follows: +// +// 1) If T and U are both the same arithmetic type, identity conversion is +// triggered. +template +struct _relational_select_operand_type::value>::type> +{ + typedef T type; +}; + +// 2) If T or U is a vector type, and the other is an arithmetic scalar type, +// then O is the vector type. +template +struct _relational_select_operand_type::value ^ is_vector::value) && ((is_scalar::value && is_arithmetic::value) ^ (is_scalar::value && is_arithmetic::value))>::type> +{ + typedef conditional_t::value, T, U> type; +}; + +template +using _relational_select_operand_type_t = typename _relational_select_operand_type::type; +template +struct _relational_select_enable : bool_constant>::value> +{ +}; + +template +struct _make_bool_impl; + +template +struct _make_bool_impl::value && is_scalar::value>::type> +{ + typedef bool type; +}; +template +struct _make_bool_impl +{ + typedef bool __attribute__((ext_vector_type(N))) type; +}; +template +struct _make_bool_impl +{ + typedef bool __attribute__((packed_vector_type(N))) type; +}; + +template +struct _make_bool : _make_bool_impl> +{ +}; +template +using _make_bool_t = typename _make_bool::type; + +template , bool>::value>::type> +METAL_FUNC bool all(T x) +{ + return __metal_all(x); +} + +template , bool>::value>::type> +METAL_FUNC bool any(T x) +{ + return __metal_any(x); +} + +template ::value>::type> +METAL_FUNC _make_bool_t isinf(T x) +{ + return (__builtin_astype(x, typename _fp_encoding_traits::encoding_type) & ~_fp_encoding_traits::sign_mask) == _fp_encoding_traits::inf_mask; +} + +template ::value>::type> +METAL_FUNC _make_bool_t isfinite(T x) +{ + return (__builtin_astype(x, typename _fp_encoding_traits::encoding_type) & ~_fp_encoding_traits::sign_mask) < _fp_encoding_traits::inf_mask; +} +template ::value>::type> +METAL_FUNC _make_bool_t isnan(T x) +{ + return (__builtin_astype(x, typename _fp_encoding_traits::encoding_type) & ~_fp_encoding_traits::sign_mask) > _fp_encoding_traits::inf_mask; +} + +template ::value>::type> +METAL_FUNC _make_bool_t isnormal(T x) +{ + return typename _fp_encoding_traits::encoding_type((__builtin_astype(x, typename _fp_encoding_traits::encoding_type) & ~_fp_encoding_traits::sign_mask) - _fp_encoding_traits::min_mask) < typename _fp_encoding_traits::encoding_type(_fp_encoding_traits::inf_mask - _fp_encoding_traits::min_mask); +} + +template ::value>::type> +METAL_FUNC _make_bool_t isunordered(T x, T y) +{ + return isnan(x) || isnan(y); +} + +template ::value>::type> +METAL_FUNC _make_bool_t isordered(T x, T y) +{ + return !isunordered(x, y); +} + +template ::value, _relational_select_operand_type_t>::type> +METAL_FUNC _O select(T x, U y, _make_bool_t<_O> c) +{ + return __metal_select(_O(x), _O(y), c); +} + +template ::value>::type> +METAL_FUNC _make_bool_t signbit(T x) +{ + return (__builtin_astype(x, typename _fp_encoding_traits::encoding_type) >> (_fp_encoding_traits::bit_width - 1)) == 1; +} +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_RELATIONAL diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_simdgroup b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_simdgroup new file mode 100644 index 00000000..1218d2e7 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_simdgroup @@ -0,0 +1,253 @@ +//===-- metal_simdgroup ---------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_SIMDGROUP +#define __METAL_SIMDGROUP + +#include + +namespace metal +{ + +#if defined(__HAVE_SIMDGROUP__) +// Metal 2.0 s5.13: SIMD-group Functions. + +#pragma METAL internals : enable +template +struct __is_valid_simdgroup_type : false_type +{ +}; + +template +struct __is_valid_simdgroup_type, half> || + is_same_v, float> || +#if defined(__HAVE_NATIVE_DOUBLE__) + is_same_v, double> || +#endif + is_same_v, char> || + is_same_v, uchar> || + is_same_v, signed char> || + is_same_v, short> || + is_same_v, ushort> || + is_same_v, int> || + is_same_v, uint>>::type> : true_type +{ +}; + +template +struct __is_valid_simdgroup_integral_type : false_type +{ +}; + +template +struct __is_valid_simdgroup_integral_type, char> || + is_same_v, uchar> || + is_same_v, signed char> || + is_same_v, short> || + is_same_v, ushort> || + is_same_v, int> || + is_same_v, uint>>::type> : true_type +{ +}; +#pragma METAL internals : disable + +#if defined(__HAVE_SIMDGROUP_BALLOT__) +struct simd_vote { +#if defined(__METAL_MACOS__) + // TODO: Use the appropriate 64bit type. See + typedef unsigned __metal_internal_int64_t vote_t; +#endif // defined(__METAL_MACOS__) + + METAL_FUNC explicit constexpr simd_vote(vote_t v = 0) thread : v(v) + { + } + + METAL_FUNC explicit constexpr operator vote_t() const thread + { + return v; + } + + bool all() const thread + { + return __metal_simd_vote_all(v); + } + + bool any() const thread + { + return __metal_simd_vote_any(v); + } + +private: + vote_t v; +}; + +METAL_FUNC simd_vote simd_active_threads_mask() +{ + return simd_vote(__metal_simd_active_threads_mask()); +} + +METAL_FUNC bool simd_all(bool expr) +{ + return __metal_simd_all(expr); +} +#endif // defined(__HAVE_SIMDGROUP_BALLOT__) + +#if defined(__HAVE_SIMDGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T simd_and(T data) +{ + return __metal_simd_and(data); +} +#endif // defined(__HAVE_SIMDGROUP_REDUCTION__) + +#if defined(__HAVE_SIMDGROUP_BALLOT__) +METAL_FUNC bool simd_any(bool expr) +{ + return __metal_simd_any(expr); +} +#endif // defined(__HAVE_SIMDGROUP_BALLOT__) + +#if defined(__HAVE_SIMDGROUP_BALLOT__) +METAL_FUNC simd_vote simd_ballot(bool expr) +{ + return simd_vote(__metal_simd_ballot(expr, simd_vote::vote_t(0))); +} +#endif // defined(__HAVE_SIMDGROUP_BALLOT__) + +template ::value>::type> +METAL_FUNC T simd_broadcast(T data, ushort broadcast_lane_id) +{ + return __metal_simd_broadcast(data, broadcast_lane_id); +} + +#if defined(__HAVE_SIMDGROUP_BROADCAST_FIRST__) +template ::value>::type> +METAL_FUNC T simd_broadcast_first(T data) +{ + return __metal_simd_broadcast_first(data); +} +#endif // defined(__HAVE_SIMDGROUP_BROADCAST_FIRST__) + +#if defined(__HAVE_SIMDGROUP_REDUCTION__) +METAL_FUNC bool simd_is_helper_thread() +{ + return __metal_simd_is_helper_thread(); +} + +template ::value>::type> +METAL_FUNC T simd_max(T data) +{ + return __metal_simd_max(data); +} + +template ::value>::type> +METAL_FUNC T simd_min(T data) +{ + return __metal_simd_min(data); +} +#endif // defined(__HAVE_SIMDGROUP_REDUCTION__) + +#if defined(__HAVE_SIMDGROUP_ONCE__) +METAL_FUNC bool simd_once() +{ + return __metal_simd_once(); +} +#endif // defined(__HAVE_SIMDGROUP_ONCE__) + +#if defined(__HAVE_SIMDGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T simd_or(T data) +{ + return __metal_simd_or(data); +} + +template ::value>::type> +METAL_FUNC T simd_prefix_exclusive_product(T data) +{ + return __metal_simd_prefix_exclusive_product(data); +} + +template ::value>::type> +METAL_FUNC T simd_prefix_exclusive_sum(T data) +{ + return __metal_simd_prefix_exclusive_sum(data); +} + +template ::value>::type> +METAL_FUNC T simd_prefix_inclusive_product(T data) +{ + return __metal_simd_prefix_inclusive_product(data); +} + +template ::value>::type> +METAL_FUNC T simd_prefix_inclusive_sum(T data) +{ + return __metal_simd_prefix_inclusive_sum(data); +} + +template ::value>::type> +METAL_FUNC T simd_product(T data) +{ + return __metal_simd_product(data); +} +#endif // defined(__HAVE_SIMDGROUP_REDUCTION__) + +template ::value>::type> +METAL_FUNC T simd_shuffle(T data, ushort simd_lane_id) +{ + return __metal_simd_shuffle(data, simd_lane_id); +} + +template ::value>::type> +METAL_FUNC T simd_shuffle_down(T data, ushort delta) +{ + return __metal_simd_shuffle_down(data, delta); +} + +#if defined(__HAVE_SIMDGROUP_SHUFFLE_ROTATE_DOWN__) +template ::value>::type> +METAL_FUNC T simd_shuffle_rotate_down(T data, ushort delta) +{ + return __metal_simd_shuffle_rotate_down(data, delta); +} +#endif // defined(__HAVE_SIMDGROUP_SHUFFLE_ROTATE_UP__) + +#if defined(__HAVE_SIMDGROUP_SHUFFLE_ROTATE_UP__) +template ::value>::type> +METAL_FUNC T simd_shuffle_rotate_up(T data, ushort delta) +{ + return __metal_simd_shuffle_rotate_up(data, delta); +} +#endif // defined(__HAVE_SIMDGROUP_SHUFFLE_ROTATE_UP__) + +template ::value>::type> +METAL_FUNC T simd_shuffle_up(T data, ushort delta) +{ + return __metal_simd_shuffle_up(data, delta); +} + +template ::value>::type> +METAL_FUNC T simd_shuffle_xor(T data, ushort mask) +{ + return __metal_simd_shuffle_xor(data, mask); +} + +#if defined(__HAVE_SIMDGROUP_REDUCTION__) +template ::value>::type> +METAL_FUNC T simd_sum(T data) +{ + return __metal_simd_sum(data); +} + +template ::value>::type> +METAL_FUNC T simd_xor(T data) +{ + return __metal_simd_xor(data); +} +#endif // defined(__HAVE_SIMDGROUP_REDUCTION__) +#endif // defined(__HAVE_SIMDGROUP__) + +} // namespace metal + +#endif // __METAL_SIMDGROUP diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib new file mode 100644 index 00000000..de79613e --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib @@ -0,0 +1,26 @@ +#ifndef __METAL_STDLIB +#define __METAL_STDLIB + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // __METAL_STDLIB diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.fast-relaxed-math-64.pch new file mode 100644 index 00000000..02d548d8 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.no-fast-math-64.pch new file mode 100644 index 00000000..a8987610 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_1.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.fast-relaxed-math-64.pch new file mode 100644 index 00000000..7066e0a6 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.no-fast-math-64.pch new file mode 100644 index 00000000..73962a30 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.1_2.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.fast-relaxed-math-64.pch new file mode 100644 index 00000000..c81ca9a7 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.no-fast-math-64.pch new file mode 100644 index 00000000..e2fafdee Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_0.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.fast-relaxed-math-64.pch new file mode 100644 index 00000000..d08aa022 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.no-fast-math-64.pch new file mode 100644 index 00000000..d1d5669d Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_1.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.fast-relaxed-math-64.pch new file mode 100644 index 00000000..5bc09e93 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.no-fast-math-64.pch new file mode 100644 index 00000000..c33a5bc6 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.2_2.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.fast-relaxed-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.fast-relaxed-math-64.pch new file mode 100644 index 00000000..02d548d8 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.fast-relaxed-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.no-fast-math-64.pch b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.no-fast-math-64.pch new file mode 100644 index 00000000..a8987610 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_stdlib.no-fast-math-64.pch differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tessellation b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tessellation new file mode 100644 index 00000000..85bf10ba --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tessellation @@ -0,0 +1,73 @@ +//===-- metal_tessellation ------------------------------------------------===// +// Copyright (c) 2016 Apple Inc. All rights reserved +// +// This header is for internal use only. This header may disappear between +// releases. +//===----------------------------------------------------------------------===// + +#ifndef __METAL_TESSELLATION +#define __METAL_TESSELLATION + +#if defined(__HAVE_TESSELLATION__) + +namespace metal +{ + +template +class patch_control_point; + +template +class patch_control_point::type> +{ + patch_control_point() thread = default; + +public: + thread patch_control_point &operator=(const thread patch_control_point &) thread = delete; + thread patch_control_point &operator=(const constant patch_control_point&) thread = delete; + thread patch_control_point *operator&() thread = delete; + const thread patch_control_point *operator&() const thread = delete; + + // Return number of control points. + size_t size() const thread + { + return __metal_get_num_patch_control_points(); + } + + T operator[](size_t pos) const thread + { + return control_point_function(static_cast(pos), pcp); + } + +private: + // Return T for the control point at pos. + METAL_PURE static T control_point_function(int, patch_control_point_t); + +private: + patch_control_point_t pcp; +}; + +// Metal Tessellation structures +struct MTLQuadTessellationFactorsHalf +{ + half edgeTessellationFactor[4]; + half insideTessellationFactor[2]; +}; + +struct MTLTriangleTessellationFactorsHalf +{ + half edgeTessellationFactor[3]; + half insideTessellationFactor; +}; + +struct MTLDrawPatchIndirectArguments +{ + uint patchCount; + uint instanceCount; + uint patchStart; + uint baseInstance; +}; + +} // namespace metal + +#endif // __HAVE_TESSELLATION__ +#endif // __METAL_TESSELLATION diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_texture b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_texture new file mode 100644 index 00000000..b3b766f7 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_texture @@ -0,0 +1,10564 @@ +//===-- metal_texture -----------------------------------------------------===// +// Copyright (c) 2014-2016 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_TEXTURE +#define __METAL_TEXTURE + +#if defined(__HAVE_ARRAY__) +#include +#endif +#include + +#pragma METAL internals : enable +namespace metal { +enum class access +{ + sample, + read, + write, +#if defined(__HAVE_TEXTURE_READWRITE__) + read_write +#endif +}; + +enum class coord +{ + normalized = 0, + pixel = 1 +}; +enum class filter +{ + nearest = 0, + linear = 1, +}; +enum class s_address +{ + clamp_to_zero = 0, + clamp_to_edge = 1, + repeat = 2, + mirrored_repeat = 3, +#if defined(__HAVE_BORDER_COLOR__) + clamp_to_border = 4 +#endif +}; +enum class t_address +{ + clamp_to_zero = 0, + clamp_to_edge = 1, + repeat = 2, + mirrored_repeat = 3, +#if defined(__HAVE_BORDER_COLOR__) + clamp_to_border = 4 +#endif +}; +enum class r_address +{ + clamp_to_zero = 0, + clamp_to_edge = 1, + repeat = 2, + mirrored_repeat = 3, +#if defined(__HAVE_BORDER_COLOR__) + clamp_to_border = 4 +#endif +}; +enum class address +{ + clamp_to_zero = 0, + clamp_to_edge = 1, + repeat = 2, + mirrored_repeat = 3, +#if defined(__HAVE_BORDER_COLOR__) + clamp_to_border = 4 +#endif +}; +enum class mip_filter +{ + none = 0, + nearest = 1, + linear = 2 +}; +enum class compare_func +{ + less = 1, + less_equal = 2, + greater = 3, + greater_equal = 4, + equal = 5, + not_equal = 6, +#if defined(__HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__) + always = 7, + never = 8 +#endif +}; +enum class mag_filter +{ + nearest = 0, + linear = 1, +}; +enum class min_filter +{ + nearest = 0, + linear = 1, +}; + +struct __max_anisotropy +{ + METAL_FUNC constexpr explicit __max_anisotropy(int v) thread + : value(v - 1) // Given value 1 to 16 is stored as 4 bits 0 to 15. + { + } + uchar value : 4; +}; +struct __lod_clamp +{ + METAL_FUNC constexpr explicit __lod_clamp(float min, float max) thread + : bits((convert(max) << 16) | convert(min)) + { + } + uint bits; + +private: + METAL_FUNC static constexpr float clamp(float x, float absmax) + { + return (x > absmax) ? absmax : (x < -absmax) ? -absmax : x; + } + METAL_FUNC static constexpr uint convert(float x) + { + return as_type(static_cast(__builtin_isfinite(x) ? clamp(x, HALF_MAX) : x)); + } +}; + +#if defined(__HAVE_ANISOTROPY_LOD_MIN_MAX__) +using max_anisotropy = __max_anisotropy; +using lod_clamp = __lod_clamp; +#endif + +#if defined(__HAVE_BORDER_COLOR__) +enum class border_color +{ + transparent_black = 0, + opaque_black = 1, + opaque_white = 2 +}; +#endif + +#if defined(__HAVE_SAMPLER_REDUCTION__) +enum class reduction +{ + weighted_average = 0, + minimum = 1, + maximum = 2 +}; +#endif + +// Metal 1.1 s2.6: Samplers. +struct sampler +{ +private: + using __uint64_t = unsigned __metal_internal_int64_t; + +public: +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread sampler& operator&() const thread = delete; +#endif +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant sampler& operator&() const constant = delete; +#endif + + METAL_FUNC constexpr sampler() thread : val(build()) + { + } + template + METAL_FUNC constexpr sampler(Ts... t) thread : val(build(t...)) + { + } + METAL_FUNC constexpr sampler() constant : val(build()) + { + } + template + METAL_FUNC constexpr sampler(Ts... t) constant : val(build(t...)) + { + } + + METAL_FUNC constexpr sampler(const thread sampler &) thread = default; + METAL_FUNC constexpr sampler(const constant sampler &) thread = default; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC constexpr sampler(const device sampler &) thread = default; +#endif + METAL_FUNC constexpr sampler(const thread sampler &) constant = default; + METAL_FUNC constexpr sampler(const constant sampler &) constant = default; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC constexpr sampler(const device sampler &) constant = default; +#endif + +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC thread sampler &operator=(const thread sampler &that) thread = default; +#else + thread sampler &operator=(const thread sampler&) thread = delete; +#endif +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC thread sampler &operator=(const constant sampler &that) thread = default; +#else + thread sampler &operator=(const constant sampler&) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC thread sampler &operator=(const device sampler &that) thread = default; +#else + thread sampler &operator=(const device sampler&) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC device sampler &operator=(const thread sampler &that) device = default; +#else + device sampler &operator=(const thread sampler&) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC device sampler &operator=(const constant sampler &that) device = default; +#else + device sampler &operator=(const constant sampler&) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_ARRAYS_OF_SAMPLERS__) + METAL_FUNC device sampler &operator=(const device sampler &that) device = default; +#else + device sampler &operator=(const device sampler&) device = delete; +#endif +#endif + +private : + sampler_t val; + +private: + // Values to help calculate offsets. + constexpr const static constant unsigned s_address_bits = 3; // bits[2:0] s_address mode + constexpr const static constant unsigned t_address_bits = 3; // bits[5:3] t_address mode + constexpr const static constant unsigned r_address_bits = 3; // bits[8:6] r_address mode + constexpr const static constant unsigned mag_filter_bits = 2; // bits[10:9] mag filter mode + constexpr const static constant unsigned min_filter_bits = 2; // bits[12:11] min filter mode + constexpr const static constant unsigned mip_filter_bits = 2; // bits[14:13] mip filter mode + constexpr const static constant unsigned normalized_bits = 1; // bits[15:15] normalized mode + constexpr const static constant unsigned compare_bits = 4; // bits[19:16] compare func + constexpr const static constant unsigned anisotropy_bits = 4; // bits[23:20] max anisotropy level + constexpr const static constant unsigned lod_clamp_bits = 32; // bits[39:24] lod min value + // bits[55:40] lod max value + constexpr const static constant unsigned border_color_bits = 2; // bits[57:56] border_color + constexpr const static constant unsigned reduction_bits = 2; // bits[59:58] reduction + // bits[62:60] reserved + constexpr const static constant unsigned marker_bit = 63; // bits[63:63] constant sampler indicator. + + constexpr const static constant unsigned s_address_base = 0; + constexpr const static constant unsigned t_address_base = s_address_base + s_address_bits; + constexpr const static constant unsigned r_address_base = t_address_base + t_address_bits; + constexpr const static constant unsigned mag_filter_base = r_address_base + r_address_bits; + constexpr const static constant unsigned min_filter_base = mag_filter_base + mag_filter_bits; + constexpr const static constant unsigned mip_filter_base = min_filter_base + min_filter_bits; + constexpr const static constant unsigned normalized_base = mip_filter_base + mip_filter_bits; + constexpr const static constant unsigned compare_base = normalized_base + normalized_bits; + constexpr const static constant unsigned anisotropy_base = compare_base + compare_bits; + constexpr const static constant unsigned lod_clamp_base = anisotropy_base + anisotropy_bits; + constexpr const static constant unsigned border_color_base = lod_clamp_base + lod_clamp_bits; + constexpr const static constant unsigned reduction_base = border_color_base + border_color_bits; + + constexpr const static constant __uint64_t s_address_mask = ((1ULL << s_address_bits ) - 1) << s_address_base; + constexpr const static constant __uint64_t t_address_mask = ((1ULL << t_address_bits ) - 1) << t_address_base; + constexpr const static constant __uint64_t r_address_mask = ((1ULL << r_address_bits ) - 1) << r_address_base; + constexpr const static constant __uint64_t mag_filter_mask = ((1ULL << mag_filter_bits ) - 1) << mag_filter_base; + constexpr const static constant __uint64_t min_filter_mask = ((1ULL << min_filter_bits ) - 1) << min_filter_base; + constexpr const static constant __uint64_t mip_filter_mask = ((1ULL << mip_filter_bits ) - 1) << mip_filter_base; + constexpr const static constant __uint64_t normalized_mask = ((1ULL << normalized_bits ) - 1) << normalized_base; + constexpr const static constant __uint64_t compare_mask = ((1ULL << compare_bits ) - 1) << compare_base; + constexpr const static constant __uint64_t anisotropy_mask = ((1ULL << anisotropy_bits ) - 1) << anisotropy_base; + constexpr const static constant __uint64_t lod_clamp_mask = ((1ULL << lod_clamp_bits ) - 1) << lod_clamp_base; + constexpr const static constant __uint64_t border_color_mask = ((1ULL << border_color_bits) - 1) << border_color_base; + constexpr const static constant __uint64_t reduction_mask = ((1ULL << reduction_bits ) - 1) << reduction_base; + +#if defined(__HAVE_ALWAYS_NEVER_COMPARE_FUNCTION__) + constexpr const static constant compare_func default_compare_func = compare_func::never; +#else + constexpr const static constant compare_func default_compare_func = compare_func::none; +#endif + constexpr const static constant auto default_anisotropy = __max_anisotropy(1); + constexpr const static constant auto default_lod_clamp = __lod_clamp(0.0, FLT_MAX); + + static constexpr __uint64_t build() + { + return (__uint64_t(1) << marker_bit) | + (__uint64_t(default_lod_clamp.bits) << lod_clamp_base) | + (__uint64_t(default_anisotropy.value) << anisotropy_base) | + (__uint64_t(default_compare_func) << compare_base) | + (__uint64_t(address::clamp_to_edge) << s_address_base) | + (__uint64_t(address::clamp_to_edge) << t_address_base) | + (__uint64_t(address::clamp_to_edge) << r_address_base); + } + + template + static constexpr __uint64_t build(coord mode, Ts... t) + { + return (__uint64_t(mode) << normalized_base) | (build(t...) & ~normalized_mask); + } + + template + static constexpr __uint64_t build(s_address mode, Ts... t) + { + return (__uint64_t(mode) << s_address_base) | (build(t...) & ~s_address_mask); + } + + template + static constexpr __uint64_t build(t_address mode, Ts... t) + { + return (__uint64_t(mode) << t_address_base) | (build(t...) & ~t_address_mask); + } + + template + static constexpr __uint64_t build(r_address mode, Ts... t) + { + return (__uint64_t(mode) << r_address_base) | (build(t...) & ~r_address_mask); + } + + template + static constexpr __uint64_t build(address mode, Ts... t) + { + return (__uint64_t(mode) << s_address_base) | + (__uint64_t(mode) << t_address_base) | + (__uint64_t(mode) << r_address_base) | + (build(t...) & ~(s_address_mask | t_address_mask | r_address_mask)); + } + + template + static constexpr __uint64_t build(mag_filter mode, Ts... t) + { + return (__uint64_t(mode) << mag_filter_base) | (build(t...) & ~mag_filter_mask); + } + + template + static constexpr __uint64_t build(min_filter mode, Ts... t) + { + return (__uint64_t(mode) << min_filter_base) | (build(t...) & ~min_filter_mask); + } + + template + static constexpr __uint64_t build(filter mode, Ts... t) + { + return (__uint64_t(mode) << mag_filter_base) | + (__uint64_t(mode) << min_filter_base) | + (build(t...) & ~(mag_filter_mask | min_filter_mask)); + } + + template + static constexpr __uint64_t build(mip_filter mode, Ts... t) + { + return (__uint64_t(mode) << mip_filter_base) | (build(t...) & ~mip_filter_mask); + } + + template + static constexpr __uint64_t build(compare_func mode, Ts... t) + { + return (__uint64_t(mode) << compare_base) | (build(t...) & ~compare_mask); + } + +#if defined(__HAVE_ANISOTROPY_LOD_MIN_MAX__) + template + static constexpr __uint64_t build(max_anisotropy aniso, Ts... t) + { + return (__uint64_t(aniso.value) << anisotropy_base) | (build(t...) & ~anisotropy_mask); + } + + template + static constexpr __uint64_t build(lod_clamp lod, Ts... t) + { + return (__uint64_t(lod.bits) << lod_clamp_base) | (build(t...) & ~lod_clamp_mask); + } +#endif + +#if defined(__HAVE_BORDER_COLOR__) + template + static constexpr __uint64_t build(border_color mode, Ts... t) + { + return (__uint64_t(mode) << border_color_base) | (build(t...) & ~border_color_mask); + } +#endif + +#if defined(__HAVE_SAMPLER_REDUCTION__) + template + static constexpr __uint64_t build(reduction mode, Ts... t) + { + return (__uint64_t(mode) << reduction_base) | (build(t...) & ~reduction_mask); + } +#endif + +private: + template + friend struct texture1d; + template + friend struct texture1d_array; + template + friend struct texture2d; + template + friend struct texture2d_array; + template + friend struct texture3d; + template + friend struct texturecube; +#if defined(__HAVE_TEXTURE_CUBE_ARRAY__) + template + friend struct texturecube_array; +#endif + template + friend struct texture2d_ms; +#if defined(__HAVE_TEXTURE_2D_MS_ARRAY__) + template + friend struct texture2d_ms_array; +#endif + template + friend struct depth2d; + template + friend struct depth2d_array; + template + friend struct depthcube; +#if defined(__HAVE_DEPTH_CUBE_ARRAY__) + template + friend struct depthcube_array; +#endif + template + friend struct depth2d_ms; +#if defined(__HAVE_DEPTH_2D_MS_ARRAY__) + template + friend struct depth2d_ms_array; +#endif +}; + +#if defined(__HAVE_SPARSE_TEXTURES__) +// TODO: This is not stable yet. The code related to sparse textures and +// min_lod_clamp will change. +template >::value>::type> +class checked_color { + T __value; + bool __status; + +public: + METAL_FUNC constexpr checked_color(T value, bool nack) thread + : __value(value), __status(nack) + { + } + + // Indicates whether all memory addressed to retrieve the value was mapped. + METAL_FUNC constexpr bool resident() const thread + { + return !__status; + } + METAL_FUNC constexpr T const value() const thread + { + return __value; + } + + METAL_FUNC constexpr operator T() const thread + { + return value(); + } +}; +#endif + +struct bias +{ + METAL_FUNC constexpr bias(float value) thread + : value(value) + { + } + float value; +}; + +struct level +{ + METAL_FUNC constexpr level(float lod) thread + : lod(lod) + { + } + float lod; +}; + +#if defined(__HAVE_MIN_LOD_CLAMP__) +// TODO: This is not stable yet. +struct min_lod_clamp +{ + METAL_FUNC constexpr min_lod_clamp(float value) thread + : value(value) + { + } + float value; +}; +#endif + +// To allow level to be used in constant argument checks. +template <> +struct _constarg_traits +{ + constexpr static METAL_INTERNAL bool check(level l) + { + return _constarg_traits::check(l.lod); + } +}; + +struct gradient2d +{ + METAL_FUNC constexpr gradient2d(float2 dPdx, float2 dPdy) thread + : dPdx(dPdx), dPdy(dPdy) + { + } + float2 dPdx; + float2 dPdy; +}; + +struct gradient3d +{ + METAL_FUNC constexpr gradient3d(float3 dPdx, float3 dPdy) thread + : dPdx(dPdx), dPdy(dPdy) + { + } + float3 dPdx; + float3 dPdy; +}; + +struct gradientcube +{ + METAL_FUNC constexpr gradientcube(float3 dPdx, float3 dPdy) thread + : dPdx(dPdx), dPdy(dPdy) + { + } + float3 dPdx; + float3 dPdy; +}; + +enum class component +{ + x, + y, + z, + w +}; + +METAL_INTERNAL constexpr static inline bool _is_zero(uint a) +{ + return a == 0; +} +METAL_INTERNAL constexpr static inline bool _is_zero(level a) +{ + return a.lod == 0; +} +#define METAL_ZERO_ARG(A) \ + METAL_ENABLE_IF(_is_zero(A), "'" #A "' argument value must be 0") + +#if defined(__HAVE_ZERO_LOD_ARG__) +#define METAL_VALID_LOD_ARG(A) \ + METAL_CONST_ARG(A) \ + METAL_ZERO_ARG(A) +#else +#define METAL_VALID_LOD_ARG(A) +#endif + +#if defined(__HAVE_ZERO_LOD_ARG__) +#define METAL_VALID_LEVEL_ARG(A) \ + METAL_CONST_ARG(A) \ + METAL_ZERO_ARG(A) +#else +#define METAL_VALID_LEVEL_ARG(A) +#endif + +// Metal 1.1 s2.5: Textures. +template +struct texture1d; +template +struct texture1d_array; +template +struct texture2d; +template +struct texture2d_array; +template +struct texture3d; +template +struct texturecube; +#if defined(__HAVE_TEXTURE_CUBE_ARRAY__) +template +struct texturecube_array; +#endif +template +struct texture2d_ms; +#if defined(__HAVE_TEXTURE_2D_MS_ARRAY__) +template +struct texture2d_ms_array; +#endif +#if defined(__HAVE_TEXTURE_BUFFER__) +template +struct texture_buffer; +#endif +template +struct depth2d; +template +struct depth2d_array; +template +struct depthcube; +#if defined(__HAVE_DEPTH_CUBE_ARRAY__) +template +struct depthcube_array; +#endif +template +struct depth2d_ms; +#if defined(__HAVE_DEPTH_2D_MS_ARRAY__) +template +struct depth2d_ms_array; +#endif + +#if defined(__HAVE_NULL_TEXTURE__) +// Metal 1.2 s5.10.15: Null Texture Functions. +template METAL_FUNC bool is_null_texture(texture1d tex); +template METAL_FUNC bool is_null_texture(texture1d_array tex); +template METAL_FUNC bool is_null_texture(texture2d tex); +template METAL_FUNC bool is_null_texture(texture2d_array tex); +template METAL_FUNC bool is_null_texture(texture3d tex); +template METAL_FUNC bool is_null_texture(texturecube tex); +#if defined(__HAVE_TEXTURE_CUBE_ARRAY__) +template METAL_FUNC bool is_null_texture(texturecube_array tex); +#endif +template METAL_FUNC bool is_null_texture(texture2d_ms tex); +#if defined(__HAVE_TEXTURE_2D_MS_ARRAY__) +template METAL_FUNC bool is_null_texture(texture2d_ms_array tex); +#endif +#if defined(__HAVE_TEXTURE_BUFFER__) +template METAL_FUNC bool is_null_texture(texture_buffer tex); +#endif +template METAL_FUNC bool is_null_texture(depth2d tex); +template METAL_FUNC bool is_null_texture(depth2d_array tex); +template METAL_FUNC bool is_null_texture(depthcube tex); +#if defined(__HAVE_DEPTH_CUBE_ARRAY__) +template METAL_FUNC bool is_null_texture(depthcube_array tex); +#endif +template METAL_FUNC bool is_null_texture(depth2d_ms tex); +#if defined(__HAVE_DEPTH_2D_MS_ARRAY__) +template METAL_FUNC bool is_null_texture(depth2d_ms_array tex); +#endif +#endif + +template +struct _is_color_texture_channel_impl : bool_constant<__is_metal_color_texture_channel(T)> +{ +}; + +template +struct is_color_texture_channel : _is_color_texture_channel_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_color_texture_channel_v = is_color_texture_channel::value; +#endif + + +template +struct _is_depth_texture_channel_impl : bool_constant<__is_metal_depth_texture_channel(T)> +{ +}; + +template +struct is_depth_texture_channel : _is_depth_texture_channel_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_depth_texture_channel_v = is_depth_texture_channel::value; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) +#if !defined(__HAVE_INDIRECT_WRITABLE_TEXTURES__) +#define _is_valid_default_construct(_a) (_a == access::read || _a == access::sample) +#elif !defined(__HAVE_TEXTURE_READWRITE__) +#define _is_valid_default_construct(_a) (_a == access::read || _a == access::sample || _a == access::write) +#else +#define _is_valid_default_construct(_a) (_a == access::read || _a == access::sample || _a == access::write || _a == access::read_write) +#endif +#define _err_default_construct_msg "Default constructor for textures must use access::sample or access::read as the access qualifier" +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) +#if !defined(__HAVE_INDIRECT_WRITABLE_TEXTURES__) +#define _is_valid_copy_assign(_a) (_a == access::read || _a == access::sample) +#elif !defined(__HAVE_TEXTURE_READWRITE__) +#define _is_valid_copy_assign(_a) (_a == access::read || _a == access::sample || _a == access::write) +#else +#define _is_valid_copy_assign(_a) (_a == access::read || _a == access::sample || _a == access::write || _a == access::read_write) +#endif +#define _err_copy_assign_msg "Assignment of textures supports only texture with access::sample or access::read access qualifier" +#endif + +#define _is_valid_sample(_a) (_a == access::sample) +#define _err_sample_access_msg "Texture sampling supports only texture with access::sample access qualifier" + +#if defined(__HAVE_TEXTURE_READWRITE__) +#define _is_valid_read(_a) (_a == access::sample || _a == access::read || _a == access::read_write) +#define _err_read_access_msg "Texture reading supports only texture with access::sample, access::read, or access::read_write as the access qualifier" +#define _is_valid_write(_a) (_a == access::write || _a == access::read_write) +#define _err_write_access_msg "Texture writing supports only texture with access::write or access::read_write as the access qualifier" +#else +#define _is_valid_read(_a) (_a == access::sample || _a == access::read) +#define _err_read_access_msg "Texture reading supports only texture with access::read or access::sample as the access qualifier" +#define _is_valid_write(_a) (_a == access::write) +#define _err_write_access_msg "Texture writing supports only texture with access::write or access::read_write as the access qualifier" +#endif + +#define _is_valid_gather(_a) (_a == access::sample) +#define _err_gather_access_msg "Texture gather supports only texture with access::sample access qualifier" + +#define _is_valid_ms_access(_a) (_a == access::read) +#define _err_ms_access "Multisample textures must have access qualifier access::read" + +#define _is_valid_texture_buffer_access(_a) (_a == access::read || _a == access::write || _a == access::read_write) +#define _err_texture_buffer_access "Texture buffers must have access qualifier access::read, access::write, or access::read_write" + +#define _is_valid_depth_access(_a) (_a == access::sample || _a == access::read) +#define _err_depth_access "Depth textures must have access qualifier access::read or access::sample" + + +template +struct texture1d::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d &operator&() const thread = delete; +#endif + + const thread texture1d &operator,(const thread texture1d &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d &operator,(const device texture1d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d &operator,(const constant texture1d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d &operator,(const thread texture1d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d &operator,(const device texture1d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d &operator,(const constant texture1d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d &operator,(const thread texture1d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d &operator,(const device texture1d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d &operator,(const constant texture1d &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture1d() thread : t(__metal_get_null_texture_1d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture1d() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture1d() constant : t(__metal_get_null_texture_1d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture1d() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d &operator=(const thread texture1d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d &operator=(const thread texture1d &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d &operator=(const device texture1d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d &operator=(const device texture1d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d &operator=(const constant texture1d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d &operator=(const constant texture1d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d &operator=(const thread texture1d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d &operator=(const thread texture1d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d &operator=(const device texture1d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d &operator=(const device texture1d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d &operator=(const constant texture1d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d &operator=(const constant texture1d &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_t(t, s.val, coord, false, 0, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_t(t, coord, color, lod, int(a)); + } +#endif + + METAL_FUNC void fence() thread + { + __metal_fence_texture_1d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_1d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_1d_t(t); + } +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_1d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_1d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_1d_t(t); + } +#endif + +private: + texture_1d_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture1d); +#endif +}; + +template +struct texture1d_array::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d_array &operator&() const thread = delete; +#endif + + const thread texture1d_array &operator,(const thread texture1d_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d_array &operator,(const device texture1d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d_array &operator,(const constant texture1d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d_array &operator,(const thread texture1d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d_array &operator,(const device texture1d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d_array &operator,(const constant texture1d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture1d_array &operator,(const thread texture1d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture1d_array &operator,(const device texture1d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture1d_array &operator,(const constant texture1d_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture1d_array() thread : t(__metal_get_null_texture_1d_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture1d_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture1d_array() constant : t(__metal_get_null_texture_1d_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture1d_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d_array &operator=(const thread texture1d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d_array &operator=(const thread texture1d_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d_array &operator=(const device texture1d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d_array &operator=(const device texture1d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture1d_array &operator=(const constant texture1d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture1d_array &operator=(const constant texture1d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d_array &operator=(const thread texture1d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d_array &operator=(const thread texture1d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d_array &operator=(const device texture1d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d_array &operator=(const device texture1d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture1d_array &operator=(const constant texture1d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture1d_array &operator=(const constant texture1d_array &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_1d_array_t(t, s.val, coord, array, false, 0, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort array, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort array, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint array, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint array, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort array, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort array, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint array, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint array, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord, ushort array, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort coord, ushort array, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint coord, uint array, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint coord, uint array, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_1d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort array, ushort lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint array, uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort array, ushort lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint array, uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord, ushort array, ushort lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord, uint array, uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_1d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_1d_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_1d_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_1d_array_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_texture_1d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_1d_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_texture_1d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_1d_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant METAL_CONST_ARG(lod) METAL_ZERO_ARG(lod) + { + return __metal_get_width_texture_1d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_texture_1d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_1d_array_t(t); + } +#endif + +private: + texture_1d_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture1d_array); +#endif +}; + +template +struct texture2d::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d &operator&() const thread = delete; +#endif + + const thread texture2d &operator,(const thread texture2d &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d &operator,(const device texture2d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d &operator,(const constant texture2d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d &operator,(const thread texture2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d &operator,(const device texture2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d &operator,(const constant texture2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d &operator,(const thread texture2d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d &operator,(const device texture2d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d &operator,(const constant texture2d &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d() thread : t(__metal_get_null_texture_2d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture2d() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d() constant : t(__metal_get_null_texture_2d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture2d() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d &operator=(const thread texture2d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d &operator=(const thread texture2d &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d &operator=(const device texture2d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d &operator=(const device texture2d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d &operator=(const constant texture2d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d &operator=(const constant texture2d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d &operator=(const thread texture2d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d &operator=(const thread texture2d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d &operator=(const device texture2d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d &operator=(const device texture2d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d &operator=(const constant texture2d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d &operator=(const constant texture2d &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, gradient2d options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_t(t, coord, color, lod, int(a)); + } +#endif + + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0), component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_t(t, s.val, coord, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_2d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_2d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_2d_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_texture_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_texture_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_2d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_texture_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_texture_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_2d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_texture_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_texture_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_2d_t(t); + } +#endif + +private: + texture_2d_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture2d); +#endif +}; + +template +struct texture2d_array::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_array &operator&() const thread = delete; +#endif + + const thread texture2d_array &operator,(const thread texture2d_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_array &operator,(const device texture2d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_array &operator,(const constant texture2d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_array &operator,(const thread texture2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_array &operator,(const device texture2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_array &operator,(const constant texture2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_array &operator,(const thread texture2d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_array &operator,(const device texture2d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_array &operator,(const constant texture2d_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_array() thread : t(__metal_get_null_texture_2d_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture2d_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_array() constant : t(__metal_get_null_texture_2d_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture2d_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_array &operator=(const thread texture2d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d_array &operator=(const thread texture2d_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_array &operator=(const device texture2d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d_array &operator=(const device texture2d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_array &operator=(const constant texture2d_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture2d_array &operator=(const constant texture2d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_array &operator=(const thread texture2d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d_array &operator=(const thread texture2d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_array &operator=(const device texture2d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d_array &operator=(const device texture2d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_array &operator=(const constant texture2d_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture2d_array &operator=(const constant texture2d_array &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_2d_array_t(t, coord, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort array, ushort lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint array, uint lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort array, ushort lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint array, uint lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort array, ushort lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint array, uint lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_2d_array_t(t, coord, array, color, lod, int(a)); + } +#endif + + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0), component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_2d_array_t(t, s.val, coord, array, true, offset, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_2d_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_2d_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_2d_array_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_texture_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_2d_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_texture_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_2d_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_texture_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_texture_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_2d_array_t(t); + } +#endif + +private: + texture_2d_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture2d_array); +#endif +}; + +template +struct texture3d::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture3d &operator&() const thread = delete; +#endif + + const thread texture3d &operator,(const thread texture3d &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture3d &operator,(const device texture3d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture3d &operator,(const constant texture3d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture3d &operator,(const thread texture3d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture3d &operator,(const device texture3d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture3d &operator,(const constant texture3d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture3d &operator,(const thread texture3d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture3d &operator,(const device texture3d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture3d &operator,(const constant texture3d &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture3d() thread : t(__metal_get_null_texture_3d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture3d() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture3d() constant : t(__metal_get_null_texture_3d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture3d() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture3d &operator=(const thread texture3d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture3d &operator=(const thread texture3d &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture3d &operator=(const device texture3d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture3d &operator=(const device texture3d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture3d &operator=(const constant texture3d &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture3d &operator=(const constant texture3d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture3d &operator=(const thread texture3d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture3d &operator=(const thread texture3d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture3d &operator=(const device texture3d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture3d &operator=(const device texture3d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture3d &operator=(const constant texture3d &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture3d &operator=(const constant texture3d &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float3 coord, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradient3d grad_options, min_lod_clamp min_lod_clamp_options, int3 offset = int3(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_3d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort3 coord, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort3 coord, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint3 coord, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint3 coord, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort3 coord, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort3 coord, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint3 coord, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint3 coord, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort3 coord, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort3 coord, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint3 coord, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_3d_t(t, coord, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint3 coord, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_3d_t(t, coord, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort3 coord, ushort lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint3 coord, uint lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort3 coord, ushort lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint3 coord, uint lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort3 coord, ushort lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint3 coord, uint lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + __metal_write_texture_3d_t(t, coord, color, lod, int(a)); + } +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_3d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_3d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_3d_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_texture_3d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_texture_3d_t(t, lod); + } + METAL_FUNC uint get_depth(uint lod = 0) const thread + { + return __metal_get_depth_texture_3d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_3d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_texture_3d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_texture_3d_t(t, lod); + } + METAL_FUNC uint get_depth(uint lod = 0) const device + { + return __metal_get_depth_texture_3d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_3d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_texture_3d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_texture_3d_t(t, lod); + } + METAL_FUNC uint get_depth(uint lod = 0) const constant + { + return __metal_get_depth_texture_3d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_3d_t(t); + } +#endif + +private: + texture_3d_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture3d); +#endif +}; + +template +struct texturecube::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube &operator&() const thread = delete; +#endif + + const thread texturecube &operator,(const thread texturecube &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube &operator,(const device texturecube &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube &operator,(const constant texturecube &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube &operator,(const thread texturecube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube &operator,(const device texturecube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube &operator,(const constant texturecube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube &operator,(const thread texturecube &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube &operator,(const device texturecube &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube &operator,(const constant texturecube &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texturecube() thread : t(__metal_get_null_texture_cube_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texturecube() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texturecube() constant : t(__metal_get_null_texture_cube_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texturecube() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube &operator=(const thread texturecube &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube &operator=(const thread texturecube &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube &operator=(const device texturecube &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube &operator=(const device texturecube &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube &operator=(const constant texturecube &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube &operator=(const constant texturecube &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube &operator=(const thread texturecube &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube &operator=(const thread texturecube &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube &operator=(const device texturecube &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube &operator=(const device texturecube &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube &operator=(const constant texturecube &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube &operator=(const constant texturecube &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_TEXTURE_CUBE_READ__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_t(t, coord, face, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_t(t, coord, face, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_TEXTURE_CUBE_WRITE__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_t(t, coord, face, color, lod, int(a)); + } +#endif +#endif + + METAL_FUNC vec gather(sampler s, float3 coord, component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_t(t, s.val, coord, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_cube_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_cube_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_cube_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_texture_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_texture_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_cube_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_texture_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_texture_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_cube_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_texture_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_texture_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_cube_t(t); + } +#endif + +private: + texture_cube_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texturecube); +#endif +}; + +#if defined(__HAVE_TEXTURE_CUBE_ARRAY__) +template +struct texturecube_array::value>::type> +{ +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube_array &operator&() const thread = delete; +#endif + + const thread texturecube_array &operator,(const thread texturecube_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube_array &operator,(const device texturecube_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube_array &operator,(const constant texturecube_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube_array &operator,(const thread texturecube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube_array &operator,(const device texturecube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube_array &operator,(const constant texturecube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texturecube_array &operator,(const thread texturecube_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texturecube_array &operator,(const device texturecube_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texturecube_array &operator,(const constant texturecube_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texturecube_array() thread : t(__metal_get_null_texture_cube_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texturecube_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texturecube_array() constant : t(__metal_get_null_texture_cube_array_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texturecube_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube_array &operator=(const thread texturecube_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube_array &operator=(const thread texturecube_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube_array &operator=(const device texturecube_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube_array &operator=(const device texturecube_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texturecube_array &operator=(const constant texturecube_array &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texturecube_array &operator=(const constant texturecube_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube_array &operator=(const thread texturecube_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube_array &operator=(const thread texturecube_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube_array &operator=(const device texturecube_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube_array &operator=(const device texturecube_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texturecube_array &operator=(const constant texturecube_array &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texturecube_array &operator=(const constant texturecube_array &) device = delete; +#endif +#endif + + METAL_FUNC vec sample(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr), vec()); + } + METAL_FUNC vec sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC vec sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack, vec()); + return {v, nack}; + } + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack, vec()); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color> check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + vec v = __metal_sample_texture_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint array, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint array, uint lod = 0) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint array, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint array, uint lod = 0) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint face, uint array, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + return __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint face, uint array, uint lod = 0) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_read(a), _err_read_access_msg); + bool nack; + vec v = __metal_read_texture_cube_array_t(t, coord, face, array, lod, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort array, ushort lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint array, uint lod = 0) const thread METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort array, ushort lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint array, uint lod = 0) const device METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort2 coord, ushort face, ushort array, ushort lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint2 coord, uint face, uint array, uint lod = 0) const constant METAL_VALID_LOD_ARG(lod) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_write(a), _err_write_access_msg); + return __metal_write_texture_cube_array_t(t, coord, face, array, color, lod, int(a)); + } +#endif + + METAL_FUNC vec gather(sampler s, float3 coord, uint array, component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array, component c = component::x) const thread METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, uint array, component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array, component c = component::x) const device METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, uint array, component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array, component c = component::x) const constant METAL_CONST_ARG(c) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_texture_cube_array_t(t, s.val, coord, array, int(c), int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + +#if defined(__HAVE_TEXTURE_READWRITE__) + METAL_FUNC void fence() thread + { + __metal_fence_texture_cube_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_cube_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_cube_array_t(t); + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_texture_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_texture_cube_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_texture_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_texture_cube_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_texture_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_texture_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_texture_cube_array_t(t); + } +#endif + +private: + texture_cube_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texturecube_array); +#endif +}; +#endif // defined(__HAVE_TEXTURE_CUBE_ARRAY__) + +template +struct texture2d_ms::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_ms_access(a), _err_ms_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms &operator&() const thread = delete; +#endif + + const thread texture2d_ms &operator,(const thread texture2d_ms &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms &operator,(const device texture2d_ms &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms &operator,(const constant texture2d_ms &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms &operator,(const thread texture2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms &operator,(const device texture2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms &operator,(const constant texture2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms &operator,(const thread texture2d_ms &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms &operator,(const device texture2d_ms &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms &operator,(const constant texture2d_ms &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_ms() thread : t(__metal_get_null_texture_2d_ms_t()) + { + } +#else + texture2d_ms() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_ms() constant : t(__metal_get_null_texture_2d_ms_t()) + { + } +#else + texture2d_ms() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms &operator=(const thread texture2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms &operator=(const thread texture2d_ms &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms &operator=(const device texture2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms &operator=(const device texture2d_ms &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms &operator=(const constant texture2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms &operator=(const constant texture2d_ms &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms &operator=(const thread texture2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms &operator=(const thread texture2d_ms &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms &operator=(const device texture2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms &operator=(const device texture2d_ms &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms &operator=(const constant texture2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms &operator=(const constant texture2d_ms &) device = delete; +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort sample) const thread + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort sample) const thread + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint sample) const thread + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint sample) const thread + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort sample) const device + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort sample) const device + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint sample) const device + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint sample) const device + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort sample) const constant + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort sample) const constant + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint sample) const constant + { + return __metal_read_texture_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint sample) const constant + { + bool nack; + vec v = __metal_read_texture_2d_ms_t(t, coord, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width() const thread + { + return __metal_get_width_texture_2d_ms_t(t); + } + METAL_FUNC uint get_height() const thread + { + return __metal_get_height_texture_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const thread + { + return __metal_get_num_samples_texture_2d_ms_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const device + { + return __metal_get_width_texture_2d_ms_t(t); + } + METAL_FUNC uint get_height() const device + { + return __metal_get_height_texture_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const device + { + return __metal_get_num_samples_texture_2d_ms_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const constant + { + return __metal_get_width_texture_2d_ms_t(t); + } + METAL_FUNC uint get_height() const constant + { + return __metal_get_height_texture_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const constant + { + return __metal_get_num_samples_texture_2d_ms_t(t); + } +#endif + +private: + texture_2d_ms_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture2d_ms); +#endif +}; + +#if defined(__HAVE_TEXTURE_2D_MS_ARRAY__) +template +struct texture2d_ms_array::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_ms_access(a), _err_ms_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms_array &operator&() const thread = delete; +#endif + + const thread texture2d_ms_array &operator,(const thread texture2d_ms_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms_array &operator,(const device texture2d_ms_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms_array &operator,(const constant texture2d_ms_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms_array &operator,(const thread texture2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms_array &operator,(const device texture2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms_array &operator,(const constant texture2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture2d_ms_array &operator,(const thread texture2d_ms_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture2d_ms_array &operator,(const device texture2d_ms_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture2d_ms_array &operator,(const constant texture2d_ms_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_ms_array() thread : t(__metal_get_null_texture_2d_ms_array_t()) + { + } +#else + texture2d_ms_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture2d_ms_array() constant : t(__metal_get_null_texture_2d_ms_array_t()) + { + } +#else + texture2d_ms_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms_array &operator=(const thread texture2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms_array &operator=(const thread texture2d_ms_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms_array &operator=(const device texture2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms_array &operator=(const device texture2d_ms_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture2d_ms_array &operator=(const constant texture2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread texture2d_ms_array &operator=(const constant texture2d_ms_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms_array &operator=(const thread texture2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms_array &operator=(const thread texture2d_ms_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms_array &operator=(const device texture2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms_array &operator=(const device texture2d_ms_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture2d_ms_array &operator=(const constant texture2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device texture2d_ms_array &operator=(const constant texture2d_ms_array &) device = delete; +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort sample) const thread + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort sample) const thread + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint sample) const thread + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint sample) const thread + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort sample) const device + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort sample) const device + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint sample) const device + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint sample) const device + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort2 coord, ushort array, ushort sample) const constant + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(ushort2 coord, ushort array, ushort sample) const constant + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + METAL_FUNC vec read(uint2 coord, uint array, uint sample) const constant + { + return __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_read(uint2 coord, uint array, uint sample) const constant + { + bool nack; + vec v = __metal_read_texture_2d_ms_array_t(t, coord, array, sample, int(a), &nack, vec()); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width() const thread + { + return __metal_get_width_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const thread + { + return __metal_get_height_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const thread + { + return __metal_get_num_samples_texture_2d_ms_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const device + { + return __metal_get_width_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const device + { + return __metal_get_height_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const device + { + return __metal_get_num_samples_texture_2d_ms_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const constant + { + return __metal_get_width_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const constant + { + return __metal_get_height_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_texture_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const constant + { + return __metal_get_num_samples_texture_2d_ms_array_t(t); + } +#endif + +private: + texture_2d_ms_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture2d_ms_array); +#endif +}; +#endif // defined(__HAVE_TEXTURE_2D_MS_ARRAY__) + +#if defined(__HAVE_TEXTURE_BUFFER__) +template +struct texture_buffer::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_texture_buffer_access(a), _err_texture_buffer_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture_buffer &operator&() const thread = delete; +#endif + + const thread texture_buffer &operator,(const thread texture_buffer &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture_buffer &operator,(const device texture_buffer &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture_buffer &operator,(const constant texture_buffer &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture_buffer &operator,(const thread texture_buffer &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture_buffer &operator,(const device texture_buffer &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture_buffer &operator,(const constant texture_buffer &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread texture_buffer &operator,(const thread texture_buffer &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device texture_buffer &operator,(const device texture_buffer &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant texture_buffer &operator,(const constant texture_buffer &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture_buffer() thread : t(__metal_get_null_texture_buffer_1d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture_buffer() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC texture_buffer() constant : t(__metal_get_null_texture_buffer_1d_t()) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_default_construct(a), _err_default_construct_msg); + } +#else + texture_buffer() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture_buffer &operator=(const thread texture_buffer &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture_buffer &operator=(const thread texture_buffer &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture_buffer &operator=(const device texture_buffer &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture_buffer &operator=(const device texture_buffer &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread texture_buffer &operator=(const constant texture_buffer &that) thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + thread texture_buffer &operator=(const constant texture_buffer &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture_buffer &operator=(const thread texture_buffer &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture_buffer &operator=(const thread texture_buffer &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture_buffer &operator=(const device texture_buffer &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture_buffer &operator=(const device texture_buffer &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device texture_buffer &operator=(const constant texture_buffer &that) device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_copy_assign(a), _err_copy_assign_msg); + t = that.t; + return *this; + } +#else + device texture_buffer &operator=(const constant texture_buffer &) device = delete; +#endif +#endif + + METAL_FUNC uint get_width() const thread + { + return __metal_get_width_texture_buffer_1d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const device + { + return __metal_get_width_texture_buffer_1d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const constant + { + return __metal_get_width_texture_buffer_1d_t(t); + } +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord) const thread + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec read(uint coord) const thread + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord) const device + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec read(uint coord) const device + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC vec read(ushort coord) const constant + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#endif + METAL_FUNC vec read(uint coord) const constant + { + return __metal_read_texture_buffer_1d_t(t, coord, int(a), static_cast(nullptr), vec()); + } +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord) const thread + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord) const thread + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord) const device + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord) const device + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC void write(vec color, ushort coord) const constant + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } +#endif + METAL_FUNC void write(vec color, uint coord) const constant + { + __metal_write_texture_buffer_1d_t(t, coord, color, int(a)); + } + + METAL_FUNC void fence() thread + { + __metal_fence_texture_buffer_1d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() device + { + __metal_fence_texture_buffer_1d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC void fence() constant + { + __metal_fence_texture_buffer_1d_t(t); + } +#endif + +private: + texture_buffer_1d_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(texture_buffer); +#endif +}; +#endif // defined(__HAVE_TEXTURE_BUFFER__) + +template +struct depth2d::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_depth_access(a), _err_depth_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d &operator&() const thread = delete; +#endif + + const thread depth2d &operator,(const thread depth2d &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d &operator,(const device depth2d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d &operator,(const constant depth2d &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d &operator,(const thread depth2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d &operator,(const device depth2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d &operator,(const constant depth2d &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d &operator,(const thread depth2d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d &operator,(const device depth2d &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d &operator,(const constant depth2d &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d() thread : t(__metal_get_null_depth_2d_t()) + { + } +#else + depth2d() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d() constant : t(__metal_get_null_depth_2d_t()) + { + } +#else + depth2d() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d &operator=(const thread depth2d &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d &operator=(const thread depth2d &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d &operator=(const device depth2d &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d &operator=(const device depth2d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d &operator=(const constant depth2d &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d &operator=(const constant depth2d &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d &operator=(const thread depth2d &that) device + { + t = that.t; + return *this; + } +#else + device depth2d &operator=(const thread depth2d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d &operator=(const device depth2d &that) device + { + t = that.t; + return *this; + } +#else + device depth2d &operator=(const device depth2d &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d &operator=(const constant depth2d &that) device + { + t = that.t; + return *this; + } +#else + device depth2d &operator=(const constant depth2d &) device = delete; +#endif +#endif + + METAL_FUNC T sample(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t(t, s.val, coord, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const thread METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const thread METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const device METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const device METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const constant METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, level options, int2 offset = int2(0)) const constant METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort lod = 0) const thread + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint lod = 0) const thread + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort lod = 0) const device + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort lod = 0) const device + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint lod = 0) const device + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint lod = 0) const device + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort lod = 0) const constant + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint lod = 0) const constant + { + return __metal_read_depth_2d_t(t, coord, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_2d_t(t, coord, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_t(t, s.val, coord, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_t(t, s.val, coord, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_depth_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_depth_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_depth_2d_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_depth_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_depth_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_depth_2d_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_depth_2d_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_depth_2d_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_depth_2d_t(t); + } +#endif + +private: + depth_2d_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depth2d); +#endif +}; + +template +struct depth2d_array::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_depth_access(a), _err_depth_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_array &operator&() const thread = delete; +#endif + + const thread depth2d_array &operator,(const thread depth2d_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_array &operator,(const device depth2d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_array &operator,(const constant depth2d_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_array &operator,(const thread depth2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_array &operator,(const device depth2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_array &operator,(const constant depth2d_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_array &operator,(const thread depth2d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_array &operator,(const device depth2d_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_array &operator,(const constant depth2d_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_array() thread : t(__metal_get_null_depth_2d_array_t()) + { + } +#else + depth2d_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_array() constant : t(__metal_get_null_depth_2d_array_t()) + { + } +#else + depth2d_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_array &operator=(const thread depth2d_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_array &operator=(const thread depth2d_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_array &operator=(const device depth2d_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_array &operator=(const device depth2d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_array &operator=(const constant depth2d_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_array &operator=(const constant depth2d_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_array &operator=(const thread depth2d_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_array &operator=(const thread depth2d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_array &operator=(const device depth2d_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_array &operator=(const device depth2d_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_array &operator=(const constant depth2d_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_array &operator=(const constant depth2d_array &) device = delete; +#endif +#endif + + METAL_FUNC T sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, level options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t(t, s.val, coord, array, true, offset, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, true, offset, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float2 coord, uint array, gradient2d grad_options, min_lod_clamp min_lod_clamp_options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_2d_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, true, offset, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const thread METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const thread METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const device METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const device METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const constant METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, level options, int2 offset = int2(0)) const constant METAL_VALID_LOD_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float2 coord, uint array, float compare_value, min_lod_clamp options, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort lod = 0) const thread + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint lod = 0) const thread + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort lod = 0) const device + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort lod = 0) const device + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint lod = 0) const device + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint lod = 0) const device + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort lod = 0) const constant + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint lod = 0) const constant + { + return __metal_read_depth_2d_array_t(t, coord, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_2d_array_t(t, coord, array, lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float2 coord, uint array, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_2d_array_t(t, s.val, coord, array, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float2 coord, uint array, float compare_value, int2 offset = int2(0)) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_2d_array_t(t, s.val, coord, array, compare_value, true, offset, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_depth_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_depth_2d_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_depth_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_depth_2d_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_depth_2d_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_depth_2d_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_depth_2d_array_t(t); + } +#endif + +private: + depth_2d_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depth2d_array); +#endif +}; + +template +struct depthcube::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_depth_access(a), _err_depth_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube &operator&() const thread = delete; +#endif + + const thread depthcube &operator,(const thread depthcube &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube &operator,(const device depthcube &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube &operator,(const constant depthcube &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube &operator,(const thread depthcube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube &operator,(const device depthcube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube &operator,(const constant depthcube &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube &operator,(const thread depthcube &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube &operator,(const device depthcube &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube &operator,(const constant depthcube &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depthcube() thread : t(__metal_get_null_depth_cube_t()) + { + } +#else + depthcube() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depthcube() constant : t(__metal_get_null_depth_cube_t()) + { + } +#else + depthcube() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube &operator=(const thread depthcube &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube &operator=(const thread depthcube &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube &operator=(const device depthcube &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube &operator=(const device depthcube &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube &operator=(const constant depthcube &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube &operator=(const constant depthcube &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube &operator=(const thread depthcube &that) device + { + t = that.t; + return *this; + } +#else + device depthcube &operator=(const thread depthcube &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube &operator=(const device depthcube &that) device + { + t = that.t; + return *this; + } +#else + device depthcube &operator=(const device depthcube &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube &operator=(const constant depthcube &that) device + { + t = that.t; + return *this; + } +#else + device depthcube &operator=(const constant depthcube &) device = delete; +#endif +#endif + + METAL_FUNC T sample(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t(t, s.val, coord, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_t_grad(t, s.val, coord, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, level options) const thread METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, level options) const device METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, level options) const constant METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, float compare_value, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_t(t, s.val, coord, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } +#endif +#endif + +#if defined(__HAVE_DEPTH_CUBE_READ__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort lod = 0) const thread + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint lod = 0) const thread + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort lod = 0) const device + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort lod = 0) const device + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint lod = 0) const device + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint lod = 0) const device + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort lod = 0) const constant + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint lod = 0) const constant + { + return __metal_read_depth_cube_t(t, coord, face, lod, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_cube_t(t, coord, face, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + + METAL_FUNC vec gather(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_t(t, s.val, coord, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_t(t, s.val, coord, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_t(t, s.val, coord, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_t(t, s.val, coord, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_t(t, s.val, coord, int(a), static_cast(nullptr)); + } +#if defined (__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_t(t, s.val, coord, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather_compare(sampler s, float3 coord, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float3 coord, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float3 coord, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_t(t, s.val, coord, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_depth_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_depth_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_depth_cube_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_depth_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_depth_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_depth_cube_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_depth_cube_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_depth_cube_t(t, lod); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_depth_cube_t(t); + } +#endif + +private: + depth_cube_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depthcube); +#endif +}; + +#if defined(__HAVE_DEPTH_CUBE_ARRAY__) +template +struct depthcube_array::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_depth_access(a), _err_depth_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube_array &operator&() const thread = delete; +#endif + + const thread depthcube_array &operator,(const thread depthcube_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube_array &operator,(const device depthcube_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube_array &operator,(const constant depthcube_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube_array &operator,(const thread depthcube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube_array &operator,(const device depthcube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube_array &operator,(const constant depthcube_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depthcube_array &operator,(const thread depthcube_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depthcube_array &operator,(const device depthcube_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depthcube_array &operator,(const constant depthcube_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depthcube_array() thread : t(__metal_get_null_depth_cube_array_t()) + { + } +#else + depthcube_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depthcube_array() constant : t(__metal_get_null_depth_cube_array_t()) + { + } +#else + depthcube_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube_array &operator=(const thread depthcube_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube_array &operator=(const thread depthcube_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube_array &operator=(const device depthcube_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube_array &operator=(const device depthcube_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depthcube_array &operator=(const constant depthcube_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depthcube_array &operator=(const constant depthcube_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube_array &operator=(const thread depthcube_array &that) device + { + t = that.t; + return *this; + } +#else + device depthcube_array &operator=(const thread depthcube_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube_array &operator=(const device depthcube_array &that) device + { + t = that.t; + return *this; + } +#else + device depthcube_array &operator=(const device depthcube_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depthcube_array &operator=(const constant depthcube_array &that) device + { + t = that.t; + return *this; + } +#else + device depthcube_array &operator=(const constant depthcube_array &) device = delete; +#endif +#endif + + METAL_FUNC T sample(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, level options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, level options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, options.value, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, level options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t(t, s.val, coord, array, false, bias_options.value, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, options.dPdx, options.dPdy, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample(sampler s, float3 coord, uint array, gradientcube grad_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_depth_cube_array_t_grad(t, s.val, coord, array, grad_options.dPdx, grad_options.dPdy, min_lod_clamp_options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const thread METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, bias bias_options, min_lod_clamp min_lod_clamp_options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const thread METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const device METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, bias bias_options, min_lod_clamp min_lod_clamp_options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const device METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const constant METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), static_cast(nullptr)); + } + METAL_FUNC T sample_compare(sampler s, float3 coord, uint array, float compare_value, bias bias_options, min_lod_clamp min_lod_clamp_options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + return __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, bias_options.value, min_lod_clamp_options.value, int(a), static_cast(nullptr)); + } +#endif +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, 0.0f, int(a), &nack); + return {v, nack}; + } + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, level options) const constant METAL_VALID_LEVEL_ARG(options) + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, true, options.lod, 0.0f, int(a), &nack); + return {v, nack}; + } +#if defined(__HAVE_MIN_LOD_CLAMP__) + METAL_FUNC checked_color check_sample_compare(sampler s, float3 coord, uint array, float compare_value, min_lod_clamp options) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_sample(a), _err_sample_access_msg); + bool nack; + T v = __metal_sample_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, false, 0.0f, options.value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const thread + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint array, uint lod = 0) const thread + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint array, uint lod = 0) const thread + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const device + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const device + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint array, uint lod = 0) const device + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint array, uint lod = 0) const device + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const constant + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort face, ushort array, ushort lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint face, uint array, uint lod = 0) const constant + { + return __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint face, uint array, uint lod = 0) const constant + { + bool nack; + T v = __metal_read_depth_cube_array_t(t, coord, face, array, lod, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather(sampler s, float3 coord, uint array) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_depth_cube_array_t(t, s.val, coord, array, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC vec gather_compare(sampler s, float3 coord, uint array, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, uint array, float compare_value) const thread + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float3 coord, uint array, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, uint array, float compare_value) const device + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC vec gather_compare(sampler s, float3 coord, uint array, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + return __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color> check_gather_compare(sampler s, float3 coord, uint array, float compare_value) const constant + { + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_gather(a), _err_gather_access_msg); + bool nack; + vec v = __metal_gather_compare_depth_cube_array_t(t, s.val, coord, array, compare_value, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width(uint lod = 0) const thread + { + return __metal_get_width_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const thread + { + return __metal_get_height_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_depth_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const thread + { + return __metal_get_num_mip_levels_depth_cube_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const device + { + return __metal_get_width_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const device + { + return __metal_get_height_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_depth_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const device + { + return __metal_get_num_mip_levels_depth_cube_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width(uint lod = 0) const constant + { + return __metal_get_width_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_height(uint lod = 0) const constant + { + return __metal_get_height_depth_cube_array_t(t, lod); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_depth_cube_array_t(t); + } + METAL_FUNC uint get_num_mip_levels() const constant + { + return __metal_get_num_mip_levels_depth_cube_array_t(t); + } +#endif + +private: + depth_cube_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depthcube_array); +#endif +}; +#endif // defined(__HAVE_DEPTH_CUBE_ARRAY__) + +template +struct depth2d_ms::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_ms_access(a), _err_ms_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms &operator&() const thread = delete; +#endif + + const thread depth2d_ms &operator,(const thread depth2d_ms &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms &operator,(const device depth2d_ms &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms &operator,(const constant depth2d_ms &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms &operator,(const thread depth2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms &operator,(const device depth2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms &operator,(const constant depth2d_ms &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms &operator,(const thread depth2d_ms &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms &operator,(const device depth2d_ms &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms &operator,(const constant depth2d_ms &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_ms() thread : t(__metal_get_null_depth_2d_ms_t()) + { + } +#else + depth2d_ms() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_ms() constant : t(__metal_get_null_depth_2d_ms_t()) + { + } +#else + depth2d_ms() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms &operator=(const thread depth2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms &operator=(const thread depth2d_ms &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms &operator=(const device depth2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms &operator=(const device depth2d_ms &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms &operator=(const constant depth2d_ms &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms &operator=(const constant depth2d_ms &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms &operator=(const thread depth2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms &operator=(const thread depth2d_ms &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms &operator=(const device depth2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms &operator=(const device depth2d_ms &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms &operator=(const constant depth2d_ms &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms &operator=(const constant depth2d_ms &) device = delete; +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort sample) const thread + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort sample) const thread + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint sample) const thread + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint sample) const thread + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort sample) const device + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort sample) const device + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint sample) const device + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint sample) const device + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort sample) const constant + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort sample) const constant + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint sample) const constant + { + return __metal_read_depth_2d_ms_t(t, coord, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint sample) const constant + { + bool nack; + T v = __metal_read_depth_2d_ms_t(t, coord, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width() const thread + { + return __metal_get_width_depth_2d_ms_t(t); + } + METAL_FUNC uint get_height() const thread + { + return __metal_get_height_depth_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const thread + { + return __metal_get_num_samples_depth_2d_ms_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const device + { + return __metal_get_width_depth_2d_ms_t(t); + } + METAL_FUNC uint get_height() const device + { + return __metal_get_height_depth_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const device + { + return __metal_get_num_samples_depth_2d_ms_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const constant + { + return __metal_get_width_depth_2d_ms_t(t); + } + METAL_FUNC uint get_height() const constant + { + return __metal_get_height_depth_2d_ms_t(t); + } + METAL_FUNC uint get_num_samples() const constant + { + return __metal_get_num_samples_depth_2d_ms_t(t); + } +#endif + +private: + depth_2d_ms_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depth2d_ms); +#endif +}; + +#if defined(__HAVE_DEPTH_2D_MS_ARRAY__) +template +struct depth2d_ms_array::value>::type> +{ + // TODO: Using static assert prevents usage of SFINAE. We need to remove it + // -- see . + static_assert(_is_valid_ms_access(a), _err_ms_access); +#if !defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms_array &operator&() const thread = delete; +#endif + + const thread depth2d_ms_array &operator,(const thread depth2d_ms_array &) const thread = delete; +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms_array &operator,(const device depth2d_ms_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms_array &operator,(const constant depth2d_ms_array &) const thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms_array &operator,(const thread depth2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms_array &operator,(const device depth2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms_array &operator,(const constant depth2d_ms_array &) const device = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const thread depth2d_ms_array &operator,(const thread depth2d_ms_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const device depth2d_ms_array &operator,(const device depth2d_ms_array &) const constant = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + const constant depth2d_ms_array &operator,(const constant depth2d_ms_array &) const constant = delete; +#endif + +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_ms_array() thread : t(__metal_get_null_depth_2d_ms_array_t()) + { + } +#else + depth2d_ms_array() thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_DEFAULT_CONSTRUCTABLE_TEXTURE__) && defined(__HAVE_NULL_TEXTURE__) + METAL_FUNC depth2d_ms_array() constant : t(__metal_get_null_depth_2d_ms_array_t()) + { + } +#else + depth2d_ms_array() constant = delete; +#endif +#endif + +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms_array &operator=(const thread depth2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms_array &operator=(const thread depth2d_ms_array &) thread = delete; +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms_array &operator=(const device depth2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms_array &operator=(const device depth2d_ms_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC thread depth2d_ms_array &operator=(const constant depth2d_ms_array &that) thread + { + t = that.t; + return *this; + } +#else + thread depth2d_ms_array &operator=(const constant depth2d_ms_array &) thread = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms_array &operator=(const thread depth2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms_array &operator=(const thread depth2d_ms_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms_array &operator=(const device depth2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms_array &operator=(const device depth2d_ms_array &) device = delete; +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_COPY_ASSIGNABLE_TEXTURE__) + METAL_FUNC device depth2d_ms_array &operator=(const constant depth2d_ms_array &that) device + { + t = that.t; + return *this; + } +#else + device depth2d_ms_array &operator=(const constant depth2d_ms_array &) device = delete; +#endif +#endif + +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort sample) const thread + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort sample) const thread + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint sample) const thread + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint sample) const thread + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort sample) const device + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort sample) const device + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint sample) const device + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint sample) const device + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) +#if defined(__HAVE_16B_COORDS__) + METAL_FUNC T read(ushort2 coord, ushort array, ushort sample) const constant + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(ushort2 coord, ushort array, ushort sample) const constant + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + METAL_FUNC T read(uint2 coord, uint array, uint sample) const constant + { + return __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), static_cast(nullptr)); + } +#if defined(__HAVE_SPARSE_TEXTURES__) + METAL_FUNC checked_color check_read(uint2 coord, uint array, uint sample) const constant + { + bool nack; + T v = __metal_read_depth_2d_ms_array_t(t, coord, array, sample, int(a), &nack); + return {v, nack}; + } +#endif +#endif + + METAL_FUNC uint get_width() const thread + { + return __metal_get_width_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const thread + { + return __metal_get_height_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const thread + { + return __metal_get_array_size_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const thread + { + return __metal_get_num_samples_depth_2d_ms_array_t(t); + } +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const device + { + return __metal_get_width_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const device + { + return __metal_get_height_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const device + { + return __metal_get_array_size_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const device + { + return __metal_get_num_samples_depth_2d_ms_array_t(t); + } +#endif +#if defined(__HAVE_INDIRECT_ARGUMENT_BUFFER__) + METAL_FUNC uint get_width() const constant + { + return __metal_get_width_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_height() const constant + { + return __metal_get_height_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_array_size() const constant + { + return __metal_get_array_size_depth_2d_ms_array_t(t); + } + METAL_FUNC uint get_num_samples() const constant + { + return __metal_get_num_samples_depth_2d_ms_array_t(t); + } +#endif + +private: + depth_2d_ms_array_t t; + +#if defined(__HAVE_NULL_TEXTURE__) + friend METAL_FUNC bool metal::is_null_texture(depth2d_ms_array); +#endif +}; +#endif // defined(__HAVE_DEPTH_2D_MS_ARRAY__) + +#if defined(__HAVE_NULL_TEXTURE__) +template +METAL_FUNC bool is_null_texture(texture1d tex) +{ + return __metal_is_null_texture_1d_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(texture1d_array tex) +{ + return __metal_is_null_texture_1d_array_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(texture2d tex) +{ + return __metal_is_null_texture_2d_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(texture2d_array tex) +{ + return __metal_is_null_texture_2d_array_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(texture3d tex) +{ + return __metal_is_null_texture_3d_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(texturecube tex) +{ + return __metal_is_null_texture_cube_t(tex.t); +} +#if defined(__HAVE_TEXTURE_CUBE_ARRAY__) +template +METAL_FUNC bool is_null_texture(texturecube_array tex) +{ + return __metal_is_null_texture_cube_array_t(tex.t); +} +#endif +template +METAL_FUNC bool is_null_texture(texture2d_ms tex) +{ + return __metal_is_null_texture_2d_ms_t(tex.t); +} +#if defined (__HAVE_TEXTURE_2D_MS_ARRAY__) +template +METAL_FUNC bool is_null_texture(texture2d_ms_array tex) +{ + return __metal_is_null_texture_2d_ms_array_t(tex.t); +} +#endif +#if defined(__HAVE_TEXTURE_BUFFER__) +template +METAL_FUNC bool is_null_texture(texture_buffer tex) +{ + return __metal_is_null_texture_buffer_1d_t(tex.t); +} +#endif // defined(__HAVE_TEXTURE_BUFFER__) +template +METAL_FUNC bool is_null_texture(depth2d tex) +{ + return __metal_is_null_depth_2d_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(depth2d_array tex) +{ + return __metal_is_null_depth_2d_array_t(tex.t); +} +template +METAL_FUNC bool is_null_texture(depthcube tex) +{ + return __metal_is_null_depth_cube_t(tex.t); +} +#if defined(__HAVE_DEPTH_CUBE_ARRAY__) +template +METAL_FUNC bool is_null_texture(depthcube_array tex) +{ + return __metal_is_null_depth_cube_array_t(tex.t); +} +#endif +template +METAL_FUNC bool is_null_texture(depth2d_ms tex) +{ + return __metal_is_null_depth_2d_ms_t(tex.t); +} +#if defined(__HAVE_DEPTH_2D_MS_ARRAY__) +template +METAL_FUNC bool is_null_texture(depth2d_ms_array tex) +{ + return __metal_is_null_depth_2d_ms_array_t(tex.t); +} +#endif +#endif // defined(__HAVE_NULL_TEXTURE__) +} // namespace metal +#pragma METAL internals : disable + +#endif // __METAL_TEXTURE diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tracing b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tracing new file mode 100644 index 00000000..244686be --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_tracing @@ -0,0 +1,435 @@ +//===-- metal_tracing -----------------------------------------------------===// +// Copyright (c) 2018 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_TRACING +#define __METAL_TRACING + +#if defined(__HAVE_TRACING__) + +using namespace metal; + +uint32_t kernel_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + uint3 thread_position_in_grid, + device void *trace_buffer) + __asm("_metal_kernel_thread_tracepoint"); + +uint32_t vertex_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + uint vertex_id, uint instance_id, + device void *trace_buffer) + __asm("_metal_vertex_thread_tracepoint"); + +uint32_t fragment_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + float4 position, uint sample_id, + device void *trace_buffer) + __asm("_metal_fragment_thread_tracepoint"); + +uint32_t post_tesselation_vertex_thread_tracepoint( + constant uint32_t *module_id, uint32_t id, + uint patch_id, uint instance_id, + device void *trace_buffer) + __asm("_metal_post_tesselation_vertex_thread_tracepoint"); + +void waypoint_tracepoint(constant uint32_t *module_id, uint32_t id, + uint32_t thread_id, device void *trace_buffer) + __asm("_metal_waypoint_tracepoint"); + +void variable_tracepoint(constant uint32_t *module_id, uint32_t id, + const thread void *address, + uint32_t thread_id, device void *trace_buffer) + __asm("_metal_variable_tracepoint.p0i8"); + +void data_tracepoint(constant uint32_t *module_id, uint32_t id, + const thread void *address, unsigned size, + uint32_t thread_id, device void *trace_buffer) + __asm("_metal_data_tracepoint.p0i8"); + +void data_tracepoint(constant uint32_t *module_id, uint32_t id, + const threadgroup void *address, unsigned size, + uint32_t thread_id, device void *trace_buffer) + __asm("_metal_data_tracepoint.p3i8"); + +#pragma METAL internals : enable + +#include + +namespace { +struct TraceBuffer { + inline uint32_t get_thread_id() device; + inline device void *reserve(uint32_t size) device; + +private: + // Thread-id counter. + atomic_uint thread_id; + + // The size of the trace buffer including the header. + const uint32_t trace_stream_size; + + // The position of the trace stream. + atomic_uint trace_stream_position; +}; + +struct KernelTraceBuffer : TraceBuffer { + inline bool is_in_region_of_interest( + uint3 the_thread_position_in_grid) const device; + +private: + uint3 thread_position_in_grid[2]; +}; + +struct VertexTraceBuffer : TraceBuffer { + inline bool is_in_region_of_interest(uint the_vertex_id, + uint the_instance_id) const device; + +private: + uint instance_id; + uint vertex_count; + uint vertex_ids[1]; + +}; + +struct FragmentTraceBuffer : TraceBuffer { + inline bool is_in_region_of_interest(float4 the_position, + uint the_sample_id) const device; + +private: + float4 position[2]; + uint sample_id[2]; +}; + +struct PostTesselationVertexTraceBuffer : TraceBuffer { + inline bool is_in_region_of_interest(uint the_patch_id, + uint the_instance_id) const device; + +private: + uint instance_id; + uint patch_count; + uint patch_ids[1]; +}; +} + +template , is_same>::value && is_convertible::value>::type> +__attribute__((no_tracepoint)) T my_atomic_fetch_add_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_add_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} + +template , is_same>::value && is_convertible::value>::type> +__attribute__((no_tracepoint)) T my_atomic_fetch_sub_explicit(volatile device _atomic* object, U operand, memory_order order) METAL_CONST_ARG(order) +{ + return __metal_atomic_fetch_sub_explicit(&object->__s, T(operand), int(order), __METAL_MEMORY_SCOPE_DEVICE__); +} + +template , bool>::value>::type> +__attribute__((no_tracepoint)) bool my_all(T x) +{ + return __metal_all(x); +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +uint32_t TraceBuffer::get_thread_id() device { + // TODO: Handle overflow of thread-ids. + return my_atomic_fetch_add_explicit(&thread_id, 1, memory_order_relaxed); +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +device void *TraceBuffer::reserve(uint32_t size) device { + // NOTE: Ignore the overflow that could theoretically happen here. + uint32_t position = my_atomic_fetch_add_explicit(&trace_stream_position, size, + memory_order_relaxed); + if ((position + size) >= trace_stream_size) { + my_atomic_fetch_sub_explicit(&trace_stream_position, size, + memory_order_relaxed); + return nullptr; + } + return ((device uint8_t *) this) + position; +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +bool KernelTraceBuffer::is_in_region_of_interest( + uint3 the_thread_position_in_grid) const device { + return (my_all(thread_position_in_grid[0] <= the_thread_position_in_grid) && + my_all(the_thread_position_in_grid <= thread_position_in_grid[1])); +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +bool VertexTraceBuffer::is_in_region_of_interest( + uint the_vertex_id, uint the_instance_id) const device { + if (instance_id == the_instance_id) { + device auto *ids = &vertex_ids[0]; + for (unsigned i = 0; i != vertex_count; ++i) + if (the_vertex_id == ids[i]) + return true; + } + return false; +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +bool FragmentTraceBuffer::is_in_region_of_interest( + float4 the_position, uint the_sample_id) const device { + return (my_all(position[0] <= the_position) && + my_all(the_position <= position[1]) && + (sample_id[0] <= the_sample_id) && (the_sample_id <= sample_id[1])); +} + +METAL_INTERNAL __attribute__((no_tracepoint)) +bool PostTesselationVertexTraceBuffer::is_in_region_of_interest( + uint the_patch_id, uint the_instance_id) const device { + if (instance_id == the_instance_id) { + device auto *ids = &patch_ids[0]; + for (unsigned i = 0; i != patch_count; ++i) + if (the_patch_id == ids[i]) + return true; + } + return false; +} + +#pragma METAL internals : disable + +#define MEMCPY __builtin_memcpy + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +uint32_t kernel_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + uint3 thread_position_in_grid, + device void *trace_buffer) { + device auto *tb = (device KernelTraceBuffer *) trace_buffer; + + if (!tb->is_in_region_of_interest(thread_position_in_grid)) + return 0; + + uint32_t thread_id = tb->get_thread_id(); + if (thread_id == 0) + return 0; + + device uint8_t *stream = + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + + sizeof (thread_position_in_grid)); + if (!stream) + return 0; + + MEMCPY(stream, &thread_id, sizeof(thread_id)); + stream += sizeof(thread_id); + + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); + MEMCPY(stream, &real_id, sizeof(real_id)); + stream += sizeof(real_id); + + MEMCPY(stream, &thread_position_in_grid, + sizeof(thread_position_in_grid)); + stream += sizeof(thread_position_in_grid); + + return thread_id; +} + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +uint32_t vertex_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + uint vertex_id, uint instance_id, + device void *trace_buffer) { + device auto *tb = (device VertexTraceBuffer *) trace_buffer; + + if (!tb->is_in_region_of_interest(vertex_id, instance_id)) + return 0; + + uint32_t thread_id = tb->get_thread_id(); + if (thread_id == 0) + return 0; + + device uint8_t *stream = + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + + sizeof(vertex_id) + sizeof(instance_id)); + if (!stream) + return 0; + + MEMCPY(stream, &thread_id, sizeof(thread_id)); + stream += sizeof(thread_id); + + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); + MEMCPY(stream, &real_id, sizeof(real_id)); + stream += sizeof(real_id); + + MEMCPY(stream, &vertex_id, sizeof(vertex_id)); + stream += sizeof(vertex_id); + + MEMCPY(stream, &instance_id, sizeof(instance_id)); + stream += sizeof(instance_id); + + return thread_id; +} + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +uint32_t fragment_thread_tracepoint(constant uint32_t *module_id, uint32_t id, + float4 position, uint sample_id, + device void *trace_buffer) { + device auto *tb = (device FragmentTraceBuffer *) trace_buffer; + + if (!tb->is_in_region_of_interest(position, sample_id)) + return 0; + + uint32_t thread_id = tb->get_thread_id(); + if (thread_id == 0) + return 0; + + device uint8_t *stream = + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + + sizeof(position) + sizeof(sample_id)); + if (!stream) + return 0; + + MEMCPY(stream, &thread_id, sizeof(thread_id)); + stream += sizeof(thread_id); + + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); + MEMCPY(stream, &real_id, sizeof(real_id)); + stream += sizeof(real_id); + + MEMCPY(stream, &position, sizeof(position)); + stream += sizeof(position); + + MEMCPY(stream, &sample_id, sizeof(sample_id)); + stream += sizeof(sample_id); + + return thread_id; +} + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +uint32_t post_tesselation_vertex_thread_tracepoint( + constant uint32_t *module_id, uint32_t id, + uint patch_id, uint instance_id, + device void *trace_buffer) { + device auto *tb = (device PostTesselationVertexTraceBuffer *) trace_buffer; + + if (!tb->is_in_region_of_interest(patch_id, instance_id)) + return 0; + + uint32_t thread_id = tb->get_thread_id(); + if (thread_id == 0) + return 0; + + device uint8_t *stream = + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + + sizeof(patch_id) + sizeof(instance_id)); + if (!stream) + return 0; + + MEMCPY(stream, &thread_id, sizeof(thread_id)); + stream += sizeof(thread_id); + + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); + MEMCPY(stream, &real_id, sizeof(real_id)); + stream += sizeof(real_id); + + MEMCPY(stream, &patch_id, sizeof(patch_id)); + stream += sizeof(patch_id); + + MEMCPY(stream, &instance_id, sizeof(instance_id)); + stream += sizeof(instance_id); + + return 0; +} + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +void waypoint_tracepoint(constant uint32_t *module_id, uint32_t id, + uint32_t thread_id, device void *trace_buffer) { + if (thread_id == 0) + return; + + device TraceBuffer *tb = (device TraceBuffer *) trace_buffer; + device uint8_t *stream = + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id)); + if (!stream) + return; + + MEMCPY(stream, &thread_id, sizeof(thread_id)); + stream += sizeof(thread_id); + + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); + MEMCPY(stream, &real_id, sizeof(real_id)); + stream += sizeof(real_id); +} + +#define VARIABLE_TRACEPOINT(AS) \ + METAL_INTERNAL __attribute__((no_tracepoint)) \ + static void variable_tracepoint_impl(constant uint32_t *module_id, uint32_t id, \ + const AS void *address, \ + uint32_t thread_id, device void *trace_buffer) { \ + if (thread_id == 0) \ + return; \ + \ + device TraceBuffer *tb = (device TraceBuffer *) trace_buffer; \ + device uint8_t *stream = \ + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + \ + sizeof(address)); \ + if (!stream) \ + return; \ + \ + MEMCPY(stream, &thread_id, sizeof(thread_id)); \ + stream += sizeof(thread_id); \ + \ + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); \ + MEMCPY(stream, &real_id, sizeof(real_id)); \ + stream += sizeof(real_id); \ + \ + MEMCPY(stream, &address, sizeof(address)); \ + stream += sizeof(address); \ + } + +VARIABLE_TRACEPOINT(thread) + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +void variable_tracepoint(constant uint32_t *module_id, uint32_t id, + const thread void *address, + uint32_t thread_id, device void *trace_buffer) { + variable_tracepoint_impl(module_id, id, address, thread_id, trace_buffer); +} + +#define STATIC_DATA_TRACEPOINT(AS) \ + METAL_INTERNAL __attribute__((no_tracepoint)) \ + static void static_data_tracepoint_impl(constant uint32_t *module_id, uint32_t id, \ + const AS void *address, uint32_t size, \ + uint32_t thread_id, device void *trace_buffer) { \ + if (thread_id == 0) \ + return; \ + \ + device TraceBuffer *tb = (device TraceBuffer *) trace_buffer; \ + uint32_t adjusted_size = (size + 3) & ~0x3; \ + device uint8_t *stream = \ + (device uint8_t *) tb->reserve(sizeof(id) + sizeof(thread_id) + \ + sizeof(address) + adjusted_size); \ + if (!stream) \ + return; \ + \ + MEMCPY(stream, &thread_id, sizeof(thread_id)); \ + stream += sizeof(thread_id); \ + \ + uint32_t real_id = (*module_id << 24) | ((id << 8) >> 8); \ + MEMCPY(stream, &real_id, sizeof(real_id)); \ + stream += sizeof(real_id); \ + \ + MEMCPY(stream, &address, sizeof(address)); \ + stream += sizeof(address); \ + \ + MEMCPY(stream, address, size); \ + stream += size; \ + } + +STATIC_DATA_TRACEPOINT(thread) + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +void data_tracepoint(constant uint32_t *module_id, uint32_t id, + const thread void *address, unsigned size, + uint32_t thread_id, device void *trace_buffer) { + static_data_tracepoint_impl(module_id, id, address, size, thread_id, trace_buffer); +} + +STATIC_DATA_TRACEPOINT(threadgroup) + +METAL_INTERNAL __attribute__((noinline, no_tracepoint, weak)) +void data_tracepoint(constant uint32_t *module_id, uint32_t id, + const threadgroup void *address, unsigned size, + uint32_t thread_id, device void *trace_buffer) { + static_data_tracepoint_impl(module_id, id, address, size, thread_id, trace_buffer); +} + +#endif // defined(__HAVE_TRACING__) + +#endif // __METAL_TRACING diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_type_traits b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_type_traits new file mode 100644 index 00000000..c109cdc2 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_type_traits @@ -0,0 +1,331 @@ +//===-- metal_type_traits -------------------------------------------------===// +// Copyright (c) 2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_TYPE_TRAITS +#define __METAL_TYPE_TRAITS + +#pragma METAL internals : enable +namespace metal +{ +template +struct enable_if +{ +}; +template +struct enable_if +{ + typedef T type; +}; +template +using enable_if_t = typename enable_if::type; + +template +struct conditional +{ + typedef T type; +}; +template +struct conditional +{ + typedef F type; +}; +template +using conditional_t = typename conditional::type; + +template +struct remove_volatile +{ + typedef T type; +}; +template +struct remove_volatile +{ + typedef T type; +}; +template +using remove_volatile_t = typename remove_volatile::type; + +template +struct remove_const +{ + typedef T type; +}; +template +struct remove_const +{ + typedef T type; +}; +template +using remove_const_t = typename remove_const::type; + +template +struct remove_cv +{ + typedef remove_volatile_t> type; +}; + +template +using remove_cv_t = typename remove_cv::type; + +template +struct integral_constant +{ + typedef T value_type; + typedef integral_constant type; + static constant constexpr T value = v; +}; + +template +using bool_constant = integral_constant; +using true_type = bool_constant; +using false_type = bool_constant; + +template +struct _is_integral_impl : bool_constant<__is_integral(T)> +{ +}; +template +struct _is_integral_impl : _is_integral_impl +{ +}; +template +struct _is_integral_impl : _is_integral_impl +{ +}; + +template +struct is_integral : _is_integral_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_integral_v = is_integral::value; +#endif + +template +struct _is_floating_point_impl : bool_constant<__is_floating_point(T)> +{ +}; +template +struct _is_floating_point_impl : _is_floating_point_impl +{ +}; +template +struct _is_floating_point_impl : _is_floating_point_impl +{ +}; + +template +struct is_floating_point : _is_floating_point_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_floating_point_v = is_floating_point::value; +#endif + +template +struct _is_scalar_impl : bool_constant<__is_scalar(T)> +{ +}; + +template +struct is_scalar : _is_scalar_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_scalar_v = is_scalar::value; +#endif + +template +struct _is_vector_impl : false_type +{ +}; +template +struct _is_vector_impl : true_type +{ +}; +template +struct _is_vector_impl : true_type +{ +}; + +template +struct is_vector : _is_vector_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_vector_v = is_vector::value; +#endif + +template +struct _is_arithmetic_impl : bool_constant<__is_arithmetic(T)> +{ +}; +template +struct _is_arithmetic_impl : _is_arithmetic_impl +{ +}; +template +struct _is_arithmetic_impl : _is_arithmetic_impl +{ +}; + +template +struct is_arithmetic : _is_arithmetic_impl> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_arithmetic_v = is_arithmetic::value; +#endif + +template +struct is_convertible : bool_constant<__is_convertible_to(U, V)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_convertible_v = is_convertible::value; +#endif + +template +struct is_same : bool_constant<__is_same(U, V)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_same_v = is_same::value; +#endif + +template +struct is_class : bool_constant<__is_class(T)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_class_v = is_class::value; +#endif + +template +struct is_signed : bool_constant<__is_signed(T)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_signed_v = is_signed::value; +#endif + +template +struct is_unsigned : bool_constant<__is_unsigned(T)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_unsigned_v = is_unsigned::value; +#endif + +template +struct is_enum : bool_constant<__is_enum(T)> +{ +}; +#ifdef __cpp_variable_templates +template +constexpr constant bool is_enum_v = is_enum::value; +#endif + +template +struct _vec_elements_impl : integral_constant +{ +}; +template +struct _vec_elements_impl : integral_constant +{ +}; +template +struct _vec_elements_impl : integral_constant +{ +}; +template +struct vec_elements : _vec_elements_impl> +{ +}; +#ifdef __cpp_variables_templates +template +constexpr constant size_t vec_elements_v = vec_elements::value; +#endif + +template +struct _make_scalar_impl +{ + typedef T type; +}; +template +struct _make_scalar_impl +{ + typedef T type; +}; +template +struct _make_scalar_impl +{ + typedef T type; +}; +template +struct make_scalar : _make_scalar_impl> +{ +}; +template +using make_scalar_t = typename make_scalar::type; + +template +struct underlying_type +{ + typedef __underlying_type(T) type; +}; +template +using underlying_type_t = typename underlying_type::type; + +template +struct _disjunction : false_type +{ +}; +template +struct _disjunction : T +{ +}; +template +struct _disjunction : conditional_t> +{ +}; +#ifdef __cpp_variable_templates +template +using disjunction = _disjunction; +template +constexpr constant bool disjunction_v = disjunction::value; +#endif + +template +struct _conjunction : true_type +{ +}; +template +struct _conjunction : T +{ +}; +template +struct _conjunction : conditional_t, T> +{ +}; +#ifdef __cpp_variable_templates +template +using conjunction = _conjunction; +template +constexpr constant bool conjunction_v = conjunction::value; +#endif +} +#pragma METAL internals : disable + +#endif // __METAL_TYPE_TRAITS diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types new file mode 100644 index 00000000..e42d93af --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types @@ -0,0 +1,286 @@ +//===-- metal_types -------------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_TYPES +#define __METAL_TYPES + +#include + +#define METAL_ALIGN(L) __attribute__((aligned(L))) +#define METAL_ASM +#define METAL_CONST __attribute__((const)) +#define METAL_DEPRECATED(M) __attribute__((deprecated(M))) +#define METAL_ENABLE_IF(P, M) __attribute__((enable_if(P, M))) +#define METAL_FUNC inline __attribute__((__always_inline__)) +#define METAL_INTERNAL +#define METAL_NON_NULL_RETURN __attribute__((returns_nonnull)) +#define METAL_NORETURN __attribute__((noreturn)) +#define METAL_NOTHROW __attribute__((nothrow)) +#define METAL_PURE __attribute__((pure)) +#define METAL_UNAVAILABLE(M) __attribute__((unavailable(M))) +#define METAL_IMPLICIT +#define METAL_EXPLICIT explicit METAL_ENABLE_IF(true, "") + +// TODO: This is only used by the builtin library. To be removed -- see +// . +#define __INLINE__ __attribute__((__always_inline__)) + +// Metal 1.1 s2.1: Scalar Data Types. +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef struct __Reserved_Name__Do_not_use_ulong ulong; +typedef struct __Reserved_Name__Do_not_use_llong llong; +typedef struct __Reserved_Name__Do_not_use_ullong ullong; +typedef struct __Reserved_Name__Do_not_use_quad quad; +typedef struct __Reserved_Name__Do_not_use_complex complex; +typedef struct __Reserved_Name__Do_not_use_imaginary imaginary; + +typedef __INT8_TYPE__ int8_t; +typedef __UINT8_TYPE__ uint8_t; +typedef __INT16_TYPE__ int16_t; +typedef __UINT16_TYPE__ uint16_t; +typedef __INT32_TYPE__ int32_t; +typedef __UINT32_TYPE__ uint32_t; +#if 0 +// TODO: We shall be using the macro defined by the compiler to define +// int64_t, uint64_t -- see . +#if 0 +typedef __INT64_TYPE__ int64_t; +typedef __UINT64_TYPE__ uint64_t; +#else +typedef __metal_internal_int64_t int64_t; +typedef unsigned __metal_internal_int64_t uint64_t; +#endif +#else +typedef struct __Reserved_Name__Do_not_use_packed_int64_t int64_t; +typedef struct __Reserved_Name__Do_not_use_packed_uint64_t uint64_t; +#endif + +// TODO: We shall be using the macro defined by the compiler to define +// ptrdiff_t, size_t, intptr_t, uintptr_t -- see . +#if 0 +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; +typedef __INTPTR_TYPE__ intptr_t; +typedef __UINTPTR_TYPE__ uintptr_t; +#else +typedef __metal_internal_int64_t ptrdiff_t; +typedef unsigned __metal_internal_int64_t size_t; +typedef __metal_internal_int64_t intptr_t; +typedef unsigned __metal_internal_int64_t uintptr_t; +#endif + +namespace metal +{ +typedef ::uchar uchar; +typedef ::ushort ushort; +typedef ::uint uint; +typedef ::ulong ulong; +typedef ::llong llong; +typedef ::ullong ullong; +typedef ::quad quad; +typedef ::complex complex; +typedef ::imaginary imaginary; + +typedef ::int8_t int8_t; +typedef ::uint8_t uint8_t; +typedef ::int16_t int16_t; +typedef ::uint16_t uint16_t; +typedef ::int32_t int32_t; +typedef ::uint32_t uint32_t; +typedef ::int64_t int64_t; +typedef ::uint64_t uint64_t; + +typedef ::ptrdiff_t ptrdiff_t; +typedef ::size_t size_t; +typedef ::intptr_t intptr_t; +typedef ::uintptr_t uintptr_t; +} + +#include +#include + +#include + +#pragma METAL internals : enable +namespace metal +{ +// This is intended to be used by the METAL_CONST_ARG macro. Each type that may +// be interested in being used in constant argument checks must specialize this +// trait. +template +struct _constarg_traits +{ + // Must return true if T is a constant argument, false otherwise. A possible + // specialization would be to force a constexpr computation on t, such as + // the t == t expression. + constexpr static bool check(const thread T &t) + { + return false; + } + constexpr static bool check(const threadgroup T &t) + { + return false; + } + constexpr static bool check(const constant T &t) + { + return false; + } + constexpr static bool check(const device T &t) + { + return false; + } +}; +#define METAL_CONST_ARG(A) METAL_ENABLE_IF(_constarg_traits::check(A), "'" #A "' argument must be known at compile-time") + +template +struct _constarg_traits::value && !is_vector::value>::type> +{ + constexpr static bool check(T a) + { + return a != 0 || a == 0; + } +}; +template +struct _constarg_traits::value>::type> +{ + constexpr static bool check(T a) + { + return _constarg_traits>::check(static_cast>(a)); + } +}; +} // namespace metal +#pragma METAL internals : disable + +#if defined(__HAVE_TESSELLATION__) +#include +#endif + +#if defined(__HAVE_FUNCTION_CONSTANTS__) +#define is_function_constant_defined(c) __metal_is_function_constant_defined(c) +#endif + +namespace metal { +// Metal 2.0 s5.12.1: Memory Order. +enum memory_order { + memory_order_relaxed = __METAL_MEMORY_ORDER_RELAXED__, +}; + +} // namespace metal + +// TODO: All these constants should be set by the compiler using preprocessor +// macros/builtins to guarantee interoperability with other languages. +// +// FIXME: Determine if these constants should be defined here and we should +// switch to using an Metal flags instead of CL flags. + +#define CHAR_BIT 8 /* size of char in bits */ +#define SCHAR_MAX 127 /* min value for a signed char */ +#define SCHAR_MIN (-128) /* max value for a signed char */ +#define UCHAR_MAX 255 /* max value for an unsigned char */ +#define CHAR_MAX SCHAR_MAX /* max value for a char */ +#define CHAR_MIN SCHAR_MIN /* min value for a char */ +#define USHRT_MAX 65535 /* max value for an unsigned short */ +#define SHRT_MAX 32767 /* max value for a short */ +#define SHRT_MIN (-32768) /* min value for a short */ +#define UINT_MAX 0xffffffff /* max value for an unsigned int */ +#define INT_MAX 2147483647 /* max value for an int */ +#define INT_MIN (-2147483647 - 1) /* min value for an int */ + +#define FLT_DIG 6 +#define FLT_MANT_DIG 24 +#define FLT_MAX_10_EXP +38 +#define FLT_MAX_EXP +128 +#define FLT_MIN_10_EXP -37 +#define FLT_MIN_EXP -125 +#define FLT_RADIX 2 +#define FLT_MAX 0x1.fffffep127f +#define FLT_MIN 0x1.0p-126f +#define FLT_EPSILON 0x1.0p-23f + +#define FP_ILOGB0 INT_MIN +#define FP_ILOGBNAN INT_MIN + +#define MAXFLOAT 0x1.fffffep+127f +#define HUGE_VALF __builtin_huge_valf() +#define INFINITY __builtin_inff() +#define NAN __builtin_nanf("") + +#define M_E_F 2.71828182845904523536028747135266250f /* e */ +#define M_LOG2E_F 1.44269504088896340735992468100189214f /* log 2e */ +#define M_LOG10E_F 0.434294481903251827651128918916605082f /* log 10e */ +#define M_LN2_F 0.693147180559945309417232121458176568f /* log e2 */ +#define M_LN10_F 2.3025850929940456840179914546843642f /* log e10 */ +#define M_PI_F 3.14159265358979323846264338327950288f /* pi */ +#define M_PI_2_F 1.57079632679489661923132169163975144f /* pi/2 */ +#define M_PI_4_F 0.785398163397448309615660845819875721f /* pi/4 */ +#define M_1_PI_F 0.318309886183790671537767526745028724f /* 1/pi */ +#define M_2_PI_F 0.636619772367581343075535053490057448f /* 2/pi */ +#define M_2_SQRTPI_F 1.12837916709551257389615890312154517f /* 2/sqrt(pi) */ +#define M_SQRT2_F 1.41421356237309504880168872420969808f /* sqrt(2) */ +#define M_SQRT1_2_F 0.707106781186547524400844362104849039f /* 1/sqrt(2) */ + +#define HALF_DIG 2 +#define HALF_MANT_DIG 11 +#define HALF_MAX_10_EXP +4 +#define HALF_MAX_EXP +16 +#define HALF_MIN_10_EXP -4 +#define HALF_MIN_EXP -13 +#define HALF_RADIX 2 +#define HALF_MAX 0x1.ffcp15h +#define HALF_MIN 0x1.0p-14h +#define HALF_EPSILON 0x1.0p-10h + +#define MAXHALF 0x1.ffcp15h +#define HUGE_VALH ((half)INFINITY) + +#define M_E_H 2.71828182845904523536028747135266250h /* e */ +#define M_LOG2E_H 1.44269504088896340735992468100189214h /* log 2e */ +#define M_LOG10E_H 0.434294481903251827651128918916605082h /* log 10e */ +#define M_LN2_H 0.693147180559945309417232121458176568h /* log e2 */ +#define M_LN10_H 2.3025850929940456840179914546843642h /* log e10 */ +#define M_PI_H 3.14159265358979323846264338327950288h /* pi */ +#define M_PI_2_H 1.57079632679489661923132169163975144h /* pi/2 */ +#define M_PI_4_H 0.785398163397448309615660845819875721h /* pi/4 */ +#define M_1_PI_H 0.318309886183790671537767526745028724h /* 1/pi */ +#define M_2_PI_H 0.636619772367581343075535053490057448h /* 2/pi */ +#define M_2_SQRTPI_H 1.12837916709551257389615890312154517h /* 2/sqrt(pi) */ +#define M_SQRT2_H 1.41421356237309504880168872420969808h /* sqrt(2) */ +#define M_SQRT1_2_H 0.707106781186547524400844362104849039h /* 1/sqrt(2) */ + +#if defined(__HAVE_NATIVE_DOUBLE__) +#define DBL_DIG 15 +#define DBL_MANT_DIG 53 +#define DBL_MAX_10_EXP +308 +#define DBL_MAX_EXP +1024 +#define DBL_MIN_10_EXP -307 +#define DBL_MIN_EXP -1021 +#define DBL_RADIX 2 +#define DBL_MAX 0x1.fffffffffffffp1023 +#define DBL_MIN 0x1.0p-1022 +#define DBL_EPSILON 0x1.0p-52 + +#define HUGE_VAL __builtin_huge_val() + +#define M_E 2.71828182845904523536028747135266250 /* e */ +#define M_LOG2E 1.44269504088896340735992468100189214 /* log 2e */ +#define M_LOG10E 0.434294481903251827651128918916605082 /* log 10e */ +#define M_LN2 0.693147180559945309417232121458176568 /* log e2 */ +#define M_LN10 2.30258509299404568401799145468436421 /* log e10 */ +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ +#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ +#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ +#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ +#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ +#endif + +// TODO: Temporary workaround, needed till all the clients are moved to +// explicitly include the simd headers -- see . +namespace simd = metal; + +#endif // __METAL_TYPES diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types.h b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types.h new file mode 100644 index 00000000..062034dd --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_types.h @@ -0,0 +1,13 @@ +//===-- metal_types_h -----------------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +// TODO: This file is a temporary workaround. It is going to be removed soon -- +// see . + +#ifndef __METAL_TYPES_H +#define __METAL_TYPES_H + +#include + +#endif // __METAL_TYPES_H diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_uniform b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_uniform new file mode 100644 index 00000000..87576f0a --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_uniform @@ -0,0 +1,1060 @@ +//===-- metal_uniform -----------------------------------------------------===// +// Copyright (c) 2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_UNIFORM +#define __METAL_UNIFORM + +#ifdef __HAVE_UNIFORM__ + +#include + +#pragma METAL internals : enable +namespace metal { +template +struct uniform; + +template +struct _is_uniform_impl : false_type +{ +}; +template +struct _is_uniform_impl> : true_type +{ +}; + +template +struct is_uniform : _is_uniform_impl> +{ +}; +template +constexpr constant bool is_uniform_v = is_uniform::value; + +template +struct remove_uniform +{ + typedef T value_type; +}; +template +struct remove_uniform +{ + typedef const typename remove_uniform::value_type value_type; +}; +template +struct remove_uniform +{ + typedef volatile typename remove_uniform::value_type value_type; +}; +template +struct remove_uniform> +{ + typedef T value_type; +}; +template +using remove_uniform_t = typename remove_uniform::value_type; + +template +struct _is_arg_uniform : _constarg_traits +{ +}; +template +struct _is_arg_uniform> +{ + static constexpr bool check(const thread uniform &) { return true; } + static constexpr bool check(const device uniform &) { return true; } + static constexpr bool check(const constant uniform &) { return true; } + static constexpr bool check(const threadgroup uniform &) { return true; } +}; + +template +struct _is_explicit_convertible_impl +{ +private: + template + static true_type test(thread void *); + + template + static false_type test(...); + +public: + using type = decltype(test(nullptr)); +}; + +template +struct _is_explicit_convertible : _is_explicit_convertible_impl::type +{ +}; +template +constexpr constant bool _is_explicit_convertible_v = _is_explicit_convertible::value; + +#define METAL_ARG_UNIFORM(x, N) \ + METAL_ENABLE_IF(_is_arg_uniform::check(x), "operand " #N " is not a uniform value") + +template +METAL_FUNC constexpr uniform make_uniform(T x) +{ + return uniform(x, uniform::_tag_init); +} + +template +struct uniform>::type> +{ + typedef T value_type; + + T __v; + + constexpr uniform() thread = default; + + template && is_convertible_v>::type> + constexpr uniform(U u) thread METAL_ARG_UNIFORM(u, 1) : __v(u) + { + } + + constexpr uniform() constant = default; + + template && is_convertible_v>::type> + constexpr uniform(U u) constant METAL_ARG_UNIFORM(u, 1) : __v(u) + { + } + + constexpr uniform() threadgroup = default; + + template && is_convertible_v>::type> + constexpr uniform(U u) threadgroup METAL_ARG_UNIFORM(u, 1) : __v(u) + { + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator U() const thread + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator uniform() const thread + { + return make_uniform(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator U() const thread + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator uniform() const thread + { + return make_uniform(U(__v)); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator U() const device + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator uniform() const device + { + return make_uniform(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator U() const device + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator uniform() const device + { + return make_uniform(U(__v)); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator U() const constant + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator uniform() const constant + { + return make_uniform(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator U() const constant + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator uniform() const constant + { + return make_uniform(U(__v)); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator U() const threadgroup + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && is_convertible_v>::type> + constexpr METAL_FUNC METAL_IMPLICIT operator uniform() const threadgroup + { + return make_uniform(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator U() const threadgroup + { + __builtin_assume(__metal_is_uniform(__v)); + return U(__v); + } + + template && !is_convertible_v && _is_explicit_convertible_v>::type> + constexpr METAL_FUNC METAL_EXPLICIT operator uniform() const threadgroup + { + return make_uniform(U(__v)); + } + + + template + constexpr typename enable_if>, thread uniform &>::type operator=(U u) thread METAL_ARG_UNIFORM(u, 1) + { + __v = remove_uniform_t(u); + return *this; + } + + template + constexpr typename enable_if>, device uniform &>::type operator=(U u) device METAL_ARG_UNIFORM(u, 1) + { + __v = remove_uniform_t(u); + return *this; + } + + template + constexpr typename enable_if>, threadgroup uniform &>::type operator=(U u) threadgroup METAL_ARG_UNIFORM(u, 1) + { + __v = remove_uniform_t(u); + return *this; + } + + +private: + enum _tag { _tag_init }; + template && is_convertible_v>::type> + constexpr uniform(U u, _tag) thread : __v(u) + { + } + + template + friend constexpr uniform make_uniform(U); +}; + +template class P> +using _binop_uniform_constraints_t = typename enable_if< + (is_uniform_v || is_uniform_v) && + P>::value && P>::value && + ((is_vector_v> && + is_vector_v> && + is_convertible_v, remove_uniform_t>) || + !is_vector_v> || + !is_vector_v>)>::type; + +template class P> +using _binop_uniform_l_constraints_t = typename enable_if< + is_uniform_v && + P>::value && P::value && + ((is_vector_v> && is_vector_v && + is_convertible_v, V>) || + !is_vector_v> || !is_vector_v)>::type; + +template class P> +using _binop_uniform_r_constraints_t = typename enable_if< + is_uniform_v && + P::value && P>::value && + ((is_vector_v && is_vector_v> && + is_convertible_v>) || + !is_vector_v || !is_vector_v>)>::type; + +template class P> +using _op_assign_uniform_constraints_t = typename enable_if< + is_uniform_v && is_same_v> && + P>::value && + P>::value && + ((is_vector_v> && + is_vector_v> && + is_convertible_v, remove_uniform_t>) || + !is_vector_v> || + !is_vector_v>)>::type; + +template class P> +using _unop_uniform_constraints_t = + typename enable_if && + P>::value>::type; + +template +using _inc_dec_uniform_constraints_t = + typename enable_if && + is_arithmetic_v> && + !is_same_v>, bool>>::type; + +template +using _is_convertible_to_bool = is_convertible; + +// Binary arithmetic operators. +template > +constexpr METAL_FUNC uniform() + remove_uniform_t())> +operator+(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() + remove_uniform_t())>(remove_uniform_t(u) + remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() + V()) +operator+(U u, V v) +{ + return remove_uniform_t(u) + V(v); +} + +template > +constexpr METAL_FUNC decltype(U() + remove_uniform_t()) +operator+(U u, V v) +{ + return U(u) + remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() - remove_uniform_t())> +operator-(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() - remove_uniform_t())>(remove_uniform_t(u) - remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() - V()) +operator-(U u, V v) +{ + return remove_uniform_t(u) - V(v); +} + +template > +constexpr METAL_FUNC decltype(U() - remove_uniform_t()) +operator-(U u, V v) +{ + return U(u) - remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() * remove_uniform_t())> +operator*(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() * remove_uniform_t())>(remove_uniform_t(u) * remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() * V()) +operator*(U u, V v) +{ + return remove_uniform_t(u) * V(v); +} + +template > +constexpr METAL_FUNC decltype(U() * remove_uniform_t()) +operator*(U u, V v) +{ + return U(u) * remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() / remove_uniform_t())> +operator/(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() / remove_uniform_t())>(remove_uniform_t(u) / remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() / V()) +operator/(U u, V v) +{ + return remove_uniform_t(u) / V(v); +} + +template > +constexpr METAL_FUNC decltype(U() / remove_uniform_t()) +operator/(U u, V v) +{ + return U(u) / remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() % remove_uniform_t())> +operator%(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() % remove_uniform_t())>(remove_uniform_t(u) % remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() % V()) +operator%(U u, V v) +{ + return remove_uniform_t(u) % V(v); +} + +template > +constexpr METAL_FUNC decltype(U() % remove_uniform_t()) +operator%(U u, V v) +{ + return U(u) % remove_uniform_t(v); +} + +// Unary arithmetic operators. +template > +constexpr METAL_FUNC uniform())> +operator+(U u) METAL_ARG_UNIFORM(u, 1) +{ + return make_uniform())>(+remove_uniform_t(u)); +} + +template > +constexpr METAL_FUNC uniform())> +operator-(U u) METAL_ARG_UNIFORM(u, 1) +{ + return make_uniform())>(-remove_uniform_t(u)); +} + +// Relational operators. +template > +constexpr METAL_FUNC uniform() == remove_uniform_t())> +operator==(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() == remove_uniform_t())>(remove_uniform_t(u) == remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() == V()) +operator==(U u, V v) +{ + return remove_uniform_t(u) == V(v); +} + +template > +constexpr METAL_FUNC decltype(U() == remove_uniform_t()) +operator==(U u, V v) +{ + return U(u) == remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() != remove_uniform_t())> +operator!=(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() != remove_uniform_t())>(remove_uniform_t(u) != remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() != V()) +operator!=(U u, V v) +{ + return remove_uniform_t(u) != V(v); +} + +template > +constexpr METAL_FUNC decltype(U() != remove_uniform_t()) +operator!=(U u, V v) +{ + return U(u) != remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() < remove_uniform_t())> +operator<(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() < remove_uniform_t())>(remove_uniform_t(u) < remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() < V()) +operator<(U u, V v) +{ + return remove_uniform_t(u) < V(v); +} + +template > +constexpr METAL_FUNC decltype(U() < remove_uniform_t()) +operator<(U u, V v) +{ + return U(u) < remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() > remove_uniform_t())> +operator>(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() > remove_uniform_t())>(remove_uniform_t(u) > remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() > V()) +operator>(U u, V v) +{ + return remove_uniform_t(u) > V(v); +} + +template > +constexpr METAL_FUNC decltype(U() > remove_uniform_t()) +operator>(U u, V v) +{ + return U(u) > remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() <= remove_uniform_t())> +operator<=(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() <= remove_uniform_t())>(remove_uniform_t(u) <= remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() <= V()) +operator<=(U u, V v) +{ + return remove_uniform_t(u) <= V(v); +} + +template > +constexpr METAL_FUNC decltype(U() <= remove_uniform_t()) +operator<=(U u, V v) +{ + return U(u) <= remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() >= remove_uniform_t())> +operator>=(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() >= remove_uniform_t())>(remove_uniform_t(u) >= remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() >= V()) +operator>=(U u, V v) +{ + return remove_uniform_t(u) >= V(v); +} + +template > +constexpr METAL_FUNC decltype(U() >= remove_uniform_t()) +operator>=(U u, V v) +{ + return U(u) >= remove_uniform_t(v); +} + + +// Shift operators. + +template > +constexpr METAL_FUNC uniform() << remove_uniform_t())> +operator<<(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() << remove_uniform_t())>(remove_uniform_t(u) << remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() << V()) +operator<<(U u, V v) +{ + return remove_uniform_t(u) << V(v); +} + +template > +constexpr METAL_FUNC decltype(U() << remove_uniform_t()) +operator<<(U u, V v) +{ + return U(u) << remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() >> remove_uniform_t())> +operator>>(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() >> remove_uniform_t())>(remove_uniform_t(u) >> remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() >> V()) +operator>>(U u, V v) +{ + return remove_uniform_t(u) >> V(v); +} + +template > +constexpr METAL_FUNC decltype(U() >> remove_uniform_t()) +operator>>(U u, V v) +{ + return U(u) >> remove_uniform_t(v); +} + + +// Binary logic operators. + +template > +constexpr METAL_FUNC uniform() && remove_uniform_t())> +operator&&(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() && remove_uniform_t())>(remove_uniform_t(u) && remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() && V()) +operator&&(U u, V v) +{ + return remove_uniform_t(u) && V(v); +} + +template > +constexpr METAL_FUNC decltype(U() && remove_uniform_t()) +operator&&(U u, V v) +{ + return U(u) && remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() || remove_uniform_t())> +operator||(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() || remove_uniform_t())>(remove_uniform_t(u) || remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() || V()) +operator||(U u, V v) +{ + return remove_uniform_t(u) || V(v); +} + +template > +constexpr METAL_FUNC decltype(U() || remove_uniform_t()) +operator||(U u, V v) +{ + return U(u) || remove_uniform_t(v); +} + +// Unary logic operators. +template > +constexpr METAL_FUNC uniform())> +operator!(U u) METAL_ARG_UNIFORM(u, 1) +{ + return make_uniform())>(!remove_uniform_t(u)); +} + +// Binary bitwise operators. + +template > +constexpr METAL_FUNC uniform() & remove_uniform_t())> +operator&(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() & remove_uniform_t())>(remove_uniform_t(u) & remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() & V()) +operator&(U u, V v) +{ + return remove_uniform_t(u) & V(v); +} + +template > +constexpr METAL_FUNC decltype(U() & remove_uniform_t()) +operator&(U u, V v) +{ + return U(u) & remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() | remove_uniform_t())> +operator|(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() | remove_uniform_t())>(remove_uniform_t(u) | remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() | V()) +operator|(U u, V v) +{ + return remove_uniform_t(u) | V(v); +} + +template > +constexpr METAL_FUNC decltype(U() | remove_uniform_t()) +operator|(U u, V v) +{ + return U(u) | remove_uniform_t(v); +} + + +template > +constexpr METAL_FUNC uniform() ^ remove_uniform_t())> +operator^(U u, V v) METAL_ARG_UNIFORM(u, 1) METAL_ARG_UNIFORM(v, 2) +{ + return make_uniform() ^ remove_uniform_t())>(remove_uniform_t(u) ^ remove_uniform_t(v)); +} + +template > +constexpr METAL_FUNC decltype(remove_uniform_t() ^ V()) +operator^(U u, V v) +{ + return remove_uniform_t(u) ^ V(v); +} + +template > +constexpr METAL_FUNC decltype(U() ^ remove_uniform_t()) +operator^(U u, V v) +{ + return U(u) ^ remove_uniform_t(v); +} + + +// Unary bitwise operators. +template > +constexpr METAL_FUNC uniform())> +operator~(U u)METAL_ARG_UNIFORM(u, 1) +{ + return make_uniform())>(~remove_uniform_t(u)); +} + +// Increment operators (thread address space). +template > +constexpr METAL_FUNC thread U &operator++(thread U &u) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator++(thread U &u, int) +{ + U res = u; + ++u; + return res; +} + +template > +constexpr METAL_FUNC thread U &operator--(thread U &u) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator--(thread U &u, int) +{ + U res = u; + --u; + return res; +} + +// Compound assignment operators (thread address space). +template > +constexpr METAL_FUNC thread U &operator+=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator-=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator*=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) * remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator/=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) / remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator%=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) % remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator<<=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) << remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator>>=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) >> remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator&=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) & remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator|=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) | remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC thread U &operator^=(thread U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) ^ remove_uniform_t(v); + return u; +} + +// Increment operators (device address space). +template > +constexpr METAL_FUNC device U &operator++(device U &u) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator++(device U &u, int) +{ + U res = u; + ++u; + return res; +} + +template > +constexpr METAL_FUNC device U &operator--(device U &u) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator--(device U &u, int) +{ + U res = u; + --u; + return res; +} + +// Compound assignment operators (device address space). +template > +constexpr METAL_FUNC device U &operator+=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator-=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator*=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) * remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator/=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) / remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator%=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) % remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator<<=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) << remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator>>=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) >> remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator&=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) & remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator|=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) | remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC device U &operator^=(device U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) ^ remove_uniform_t(v); + return u; +} + +// Increment operators (threadgroup address space). +template > +constexpr METAL_FUNC threadgroup U &operator++(threadgroup U &u) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator++(threadgroup U &u, int) +{ + U res = u; + ++u; + return res; +} + +template > +constexpr METAL_FUNC threadgroup U &operator--(threadgroup U &u) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(1); + return u; +} + +template > +constexpr METAL_FUNC U operator--(threadgroup U &u, int) +{ + U res = u; + --u; + return res; +} + +// Compound assignment operators (threadgroup address space). +template > +constexpr METAL_FUNC threadgroup U &operator+=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) + remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator-=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) - remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator*=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) * remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator/=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) / remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator%=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) % remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator<<=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) << remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator>>=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) >> remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator&=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) & remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator|=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) | remove_uniform_t(v); + return u; +} + +template > +constexpr METAL_FUNC threadgroup U &operator^=(threadgroup U &u, V v) METAL_ARG_UNIFORM(v, 2) +{ + u.__v = remove_uniform_t(u) ^ remove_uniform_t(v); + return u; +} + +} +#pragma METAL internals : disable + +#endif + +#endif diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_utility b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_utility new file mode 100644 index 00000000..d9b2d046 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/metal_utility @@ -0,0 +1,29 @@ +//===-- metal_initializer_list --------------------------------------------===// +// Copyright (c) 2014-2017 Apple Inc. All rights reserved +//===----------------------------------------------------------------------===// + +#ifndef __METAL_UTILITY +#define __METAL_UTILITY + +namespace metal +{ +template +struct _integer_sequence +{ + typedef T value_type; + static constexpr size_t size() + { + return sizeof...(I); + } +}; +template +using _make_integer_sequence = __make_integer_seq<_integer_sequence, T, N>; +#ifdef __cpp_variable_templates +template +using integer_sequence = _integer_sequence; +template +using make_integer_sequence = _make_integer_sequence; +#endif +} // namespace metal + +#endif // __METAL_UTILITY diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/matrix_types.h b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/matrix_types.h new file mode 100644 index 00000000..a31d6b1c --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/matrix_types.h @@ -0,0 +1,72 @@ +/* Copyright (c) 2014 Apple, Inc. All rights reserved. + * + * This header defines float matrix types that are also defined on the host. + * Though the implementations are different, the host and device will have the + * same size, alignment, and storage formats. These matrices + * are stored in column-major order, and implemented as arrays of column + * vectors. You should think of matrices as abstract mathematical + * objects that you use to perform arithmetic without worrying about the + * details of the underlying representation. + * + * WARNING: vectors of length three are internally represented as length four + * vectors with one element of padding (for alignment purposes). This means + * that when a floatNx3 or doubleNx3 is viewed as a vector, it appears to + * have 4*N elements instead of the expected 3*N (with one padding element + * at the end of each column). The matrix elements are laid out in the + * elements field as follows: + * + * { 0, 1, 2, x, 3, 4, 5, x, ... } + * + * (where the scalar indices used above indicate the conceptual column- + * major storage order). If you aren't monkeying around with the internal + * storage details of matrices, you don't need to worry about this at all. + * Consider this yet another good reason to avoid doing so. + */ + +#ifndef __SIMD_MATRIX_TYPES_HEADER__ +#define __SIMD_MATRIX_TYPES_HEADER__ + +#include + +using matrix_half2x2 = metal::half2x2; +using matrix_half3x2 = metal::half3x2; +using matrix_half4x2 = metal::half4x2; + +using matrix_half2x3 = metal::half2x3; +using matrix_half3x3 = metal::half3x3; +using matrix_half4x3 = metal::half4x3; + +using matrix_half2x4 = metal::half2x4; +using matrix_half3x4 = metal::half3x4; +using matrix_half4x4 = metal::half4x4; + +using matrix_float2x2 = metal::float2x2; +using matrix_float3x2 = metal::float3x2; +using matrix_float4x2 = metal::float4x2; + +using matrix_float2x3 = metal::float2x3; +using matrix_float3x3 = metal::float3x3; +using matrix_float4x3 = metal::float4x3; + +using matrix_float2x4 = metal::float2x4; +using matrix_float3x4 = metal::float3x4; +using matrix_float4x4 = metal::float4x4; + +#if defined(__HAVE_NATIVE_DOUBLE__) +using matrix_double2x2 = metal::double2x2; +using matrix_double3x2 = metal::double3x2; +using matrix_double4x2 = metal::double4x2; + +using matrix_double2x3 = metal::double2x3; +using matrix_double3x3 = metal::double3x3; +using matrix_double4x3 = metal::double4x3; + +using matrix_double2x4 = metal::double2x4; +using matrix_double3x4 = metal::double3x4; +using matrix_double4x4 = metal::double4x4; +#endif + +// We just need to export the metal namespace as simd here. +namespace simd = metal; + +#endif /* __SIMD_MATRIX_TYPES_HEADER__ */ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/packed.h b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/packed.h new file mode 100644 index 00000000..ee46360c --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/packed.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2016-2017 Apple, Inc. All rights reserved. + * + * This is a version of simd/packed.h suitatable to be used with the Metal + * compiler. The main differences are: + * + * - Support for 3 elements packed vectors. + * - Depending on the Metal language standard, access to array elements via + * component name -- e.g. .x, .y, ... -- might be enabled. + */ + +#ifndef __SIMD_PACKED_HEADER__ +#define __SIMD_PACKED_HEADER__ + +// Metal packed vector types are always defined, we just need to export the +// metal namespace as simd here. +namespace simd = metal; + +#endif /* __SIMD_PACKED_HEADER__ */ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/simd.h b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/simd.h new file mode 100644 index 00000000..78b496e7 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/simd.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2014 Apple, Inc. All rights reserved. + * + * This header provides small vector (SIMD) and matrix types, and basic + * arithmetic and mathematical functions for them. The vast majority of these + * operations are implemented as header inlines, as they can be performed + * using just a few instructions on most processors. + * + * These functions are broken into two groups; vector and matrix. This header + * includes all of them, but these may also be included separately. Consult + * these two headers for detailed documentation of what types and operations + * are available. + */ + +#ifndef __SIMD_HEADER__ +#define __SIMD_HEADER__ + +#include +#include +#include + +#endif /* __SIMD_HEADER__ */ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/vector_types.h b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/vector_types.h new file mode 100644 index 00000000..d2e93d93 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/lib/clang/802.6/include/metal/simd/vector_types.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * This is a version of simd/vector_types.h suitatable to be used with the Metal + * compiler. + * + */ + +#ifndef __SIMD_VECTOR_TYPES_HEADER__ +#define __SIMD_VECTOR_TYPES_HEADER__ + +// Metal vector types are always defined, we just need to export the metal +// namespace as simd here. +namespace simd = metal; + +#endif /* __SIMD_VECTOR_TYPES_HEADER__ */ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libComposeFilters.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libComposeFilters.dylib new file mode 100755 index 00000000..5c485796 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libComposeFilters.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompiler.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompiler.dylib new file mode 100755 index 00000000..1b607ad2 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompiler.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImpl.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImpl.dylib new file mode 100755 index 00000000..764daa2f Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImpl.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImplLazy.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImplLazy.dylib new file mode 100755 index 00000000..f8b290ba Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libGPUCompilerImplLazy.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libLLVM.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libLLVM.dylib new file mode 100755 index 00000000..d3a8f0d7 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libLLVM.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libmetal_timestamp.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libmetal_timestamp.dylib new file mode 100755 index 00000000..8034d0a1 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/GPUCompiler/3802/Libraries/libmetal_timestamp.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Libraries/libMTLCompilerHelper.dylib b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Libraries/libMTLCompilerHelper.dylib new file mode 100755 index 00000000..f39c9497 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Libraries/libMTLCompilerHelper.dylib differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/MTLCompiler b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/MTLCompiler new file mode 100755 index 00000000..62444b35 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/MTLCompiler differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/Info.plist b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/Info.plist new file mode 100644 index 00000000..15c36d3f --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/Info.plist @@ -0,0 +1,48 @@ + + + + + BuildMachineOSBuild + 20A241133 + CFBundleDevelopmentRegion + en + CFBundleExecutable + MTLCompiler + CFBundleIdentifier + com.apple.MTLCompiler + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + MTLCompiler + CFBundlePackageType + FMWK + CFBundleShortVersionString + 263.9 + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 263.9 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 13E6049a + DTPlatformName + macosx + DTPlatformVersion + 12.7 + DTSDKBuild + 21G806 + DTSDKName + macosx12.7.internal + DTXcode + 1330 + DTXcodeBuild + 13E6049a + LSMinimumSystemVersion + 12.7 + + diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/libmetal_boundscheck.a b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/libmetal_boundscheck.a new file mode 100644 index 00000000..e542b4c9 Binary files /dev/null and b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/libmetal_boundscheck.a differ diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/version.plist b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/version.plist new file mode 100644 index 00000000..24de6e36 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/Resources/version.plist @@ -0,0 +1,16 @@ + + + + + BuildVersion + 18 + CFBundleShortVersionString + 263.9 + CFBundleVersion + 263.9 + ProjectName + Metal + SourceVersion + 263009000000000 + + diff --git a/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/_CodeSignature/CodeResources b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/_CodeSignature/CodeResources new file mode 100755 index 00000000..5eff7591 --- /dev/null +++ b/Universal-Binaries/12.7.6-3802/System/Library/PrivateFrameworks/MTLCompiler/3802/_CodeSignature/CodeResources @@ -0,0 +1,37 @@ + + + + + files + + files2 + + rules + + ^.* + + omit + + weight + 20 + + + rules2 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 0.0 + + ^.* + + omit + + weight + 20 + + + + diff --git a/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/Metal b/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/Metal new file mode 100755 index 00000000..611f201d Binary files /dev/null and b/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/Metal differ diff --git a/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/MetalOld.dylib b/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/MetalOld.dylib new file mode 100755 index 00000000..837fb4e9 Binary files /dev/null and b/Universal-Binaries/13.2.1-24/System/Library/Frameworks/Metal.framework/Versions/A/MetalOld.dylib differ diff --git a/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage b/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage new file mode 100755 index 00000000..7aa52ae3 Binary files /dev/null and b/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage differ diff --git a/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImageOld.dylib b/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImageOld.dylib new file mode 100755 index 00000000..438c0c1d Binary files /dev/null and b/Universal-Binaries/14.0 Beta 3-24/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImageOld.dylib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage.metallib new file mode 100644 index 00000000..62a52bbe Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV2.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV2.metallib new file mode 100644 index 00000000..c5ada795 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV2.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV3.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV3.metallib new file mode 100644 index 00000000..7c68ff68 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurStitchableV3.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV2.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV2.metallib new file mode 100644 index 00000000..0451e265 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV2.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV3.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV3.metallib new file mode 100644 index 00000000..c48baaf7 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/CIPortraitBlurV3.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters.metallib new file mode 100644 index 00000000..bcd36a43 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters_stitchable.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters_stitchable.metallib new file mode 100644 index 00000000..a9fc1973 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_filters_stitchable.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib.metallib new file mode 100644 index 00000000..a6e95052 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_h.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_h.metallib new file mode 100644 index 00000000..f80a744f Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_h.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable.metallib new file mode 100644 index 00000000..28e0ff6b Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable_h.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable_h.metallib new file mode 100644 index 00000000..c8e99086 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/ci_stdlib_stitchable_h.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/default.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/default.metallib new file mode 100644 index 00000000..f97d5ec3 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources/default.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/MLCompute.framework/Versions/A/Resources/default.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/MLCompute.framework/Versions/A/Resources/default.metallib new file mode 100644 index 00000000..e41df33f Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/MLCompute.framework/Versions/A/Resources/default.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSCore.framework/Versions/A/Resources/default.metallib b/Universal-Binaries/14.6.1/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSCore.framework/Versions/A/Resources/default.metallib new file mode 100644 index 00000000..ca0b1ee3 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSCore.framework/Versions/A/Resources/default.metallib differ diff --git a/Universal-Binaries/14.6.1/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/Resources/default.metallib b/Universal-Binaries/14.6.1/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/Resources/default.metallib new file mode 100644 index 00000000..62639b67 Binary files /dev/null and b/Universal-Binaries/14.6.1/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/Resources/default.metallib differ