Blender V5.0
types_float2.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#pragma once
6
7#include "util/types_base.h"
8#include "util/types_int2.h"
9
11
12#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
13struct float2 {
14 float x, y;
15
16# ifndef __KERNEL_GPU__
17 __forceinline float operator[](int i) const;
18 __forceinline float &operator[](int i);
19# endif
20};
21
22# ifndef __KERNEL_GPU__
24{
25 util_assert(i >= 0);
26 util_assert(i < 2);
27 return *(&x + i);
28}
29
31{
32 util_assert(i >= 0);
33 util_assert(i < 2);
34 return *(&x + i);
35}
36# endif
37
38ccl_device_inline float2 make_float2(const float x, const float y)
39{
40 float2 a = {x, y};
41 return a;
42}
43#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
44
46{
47 return {f, f};
48}
49
51{
52 return make_float2((float)i.x, (float)i.y);
53}
54
56{
57 return make_int2((int)f.x, (int)f.y);
58}
59
60#if defined __METAL_PRINTF__
61# define print_float2(label, a) metal::os_log_default.log_debug(label ": %.8f %.8f", a.x, a.y)
62#else
63ccl_device_inline void print_float2(const ccl_private char *label, const float2 a)
64{
65# ifdef __KERNEL_PRINTF__
66 printf("%s: %.8f %.8f\n", label, (double)a.x, (double)a.y);
67# endif
68}
69#endif
70
#define util_assert(statement)
#define ccl_private
#define ccl_device_inline
#define __forceinline
#define CCL_NAMESPACE_END
#define printf(...)
#define make_float2
float x
float y
__forceinline float operator[](int i) const
float2()=default
i
Definition text_draw.cc:230
ccl_device_inline int2 make_int2(const float2 f)
ccl_device_inline void print_float2(const ccl_private char *label, const float2 a)