Blender V4.3
math_int3.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifndef __UTIL_MATH_INT3_H__
6#define __UTIL_MATH_INT3_H__
7
8#ifndef __UTIL_MATH_H__
9# error "Do not include this file directly, include util/types.h instead."
10#endif
11
13
14#if !defined(__KERNEL_METAL__)
16{
17# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__)
18 return int3(_mm_min_epi32(a.m128, b.m128));
19# else
20 return make_int3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
21# endif
22}
23
25{
26# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__)
27 return int3(_mm_max_epi32(a.m128, b.m128));
28# else
29 return make_int3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
30# endif
31}
32
33ccl_device_inline int3 clamp(const int3 a, int mn, int mx)
34{
35# ifdef __KERNEL_SSE__
36 return min(max(a, make_int3(mn)), make_int3(mx));
37# else
38 return make_int3(clamp(a.x, mn, mx), clamp(a.y, mn, mx), clamp(a.z, mn, mx));
39# endif
40}
41
42ccl_device_inline int3 clamp(const int3 a, int3 &mn, int mx)
43{
44# ifdef __KERNEL_SSE__
45 return min(max(a, mn), make_int3(mx));
46# else
47 return make_int3(clamp(a.x, mn.x, mx), clamp(a.y, mn.y, mx), clamp(a.z, mn.z, mx));
48# endif
49}
50
52{
53 return a.x == b.x && a.y == b.y && a.z == b.z;
54}
55
57{
58 return !(a == b);
59}
60
62{
63 return a.x < b.x && a.y < b.y && a.z < b.z;
64}
65
67{
68# ifdef __KERNEL_SSE__
69 return int3(_mm_add_epi32(a.m128, b.m128));
70# else
71 return make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
72# endif
73}
74
76{
77# ifdef __KERNEL_SSE__
78 return int3(_mm_sub_epi32(a.m128, b.m128));
79# else
80 return make_int3(a.x - b.x, a.y - b.y, a.z - b.z);
81# endif
82}
83#endif /* !__KERNEL_METAL__ */
84
86
87#endif /* __UTIL_MATH_INT3_H__ */
local_group_size(16, 16) .push_constant(Type b
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_forceinline int3 make_int3(const int x, const int y, const int z)
ccl_device_inline int3 operator+(const int3 a, const int3 b)
Definition math_int3.h:66
ccl_device_inline bool operator<(const int3 a, const int3 b)
Definition math_int3.h:61
ccl_device_inline int3 operator-(const int3 a, const int3 b)
Definition math_int3.h:75
ccl_device_inline bool operator==(const int3 a, const int3 b)
Definition math_int3.h:51
ccl_device_inline int3 clamp(const int3 a, int mn, int mx)
Definition math_int3.h:33
ccl_device_inline bool operator!=(const int3 a, const int3 b)
Definition math_int3.h:56
#define min(a, b)
Definition sort.c:32
float max