Blender
V5.3
intern
cycles
test
util_math_float3_test.cpp
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011-2025 Blender Foundation
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
/* Note: These fixtures test default micro-architecture optimization defined in the
6
* util/optimization.h. */
7
8
#include <gtest/gtest.h>
9
10
#include "
util/math.h
"
11
12
CCL_NAMESPACE_BEGIN
13
14
class
Float3Test
:
public
::testing::Test {
15
void
SetUp()
override
16
{
17
/* The micro-architecture check is not needed here, but use it here as a demonstration of how
18
* it can be implemented in a clear way. */
19
// GTEST_SKIP() << "Test skipped due to uarch capability";
20
}
21
};
22
23
TEST_F
(
Float3Test
,
fmod
)
24
{
25
{
26
const
float3
c =
fmod
(
make_float3
(1.2f, 2.3f, 3.4f), 1.0f);
27
EXPECT_NEAR
(c.
x
, 0.2f, 1e-6f);
28
EXPECT_NEAR
(c.
y
, 0.3f, 1e-6f);
29
EXPECT_NEAR
(c.
z
, 0.4f, 1e-6f);
30
}
31
32
{
33
const
float3
c =
fmod
(
make_float3
(1.2f, 2.3f, 3.4f), 1.2f);
34
EXPECT_NEAR
(c.
x
, 0.0f, 1e-6f);
35
EXPECT_NEAR
(c.
y
, 1.1f, 1e-6f);
36
EXPECT_NEAR
(c.
z
, 1.0f, 1e-6f);
37
}
38
39
{
40
const
float3
c =
fmod
(
make_float3
(1.2f, 2.3f, 3.4f), 1000000.0f);
41
EXPECT_NEAR
(c.
x
, 1.2f, 1e-6f);
42
EXPECT_NEAR
(c.
y
, 2.3f, 1e-6f);
43
EXPECT_NEAR
(c.
z
, 3.4f, 1e-6f);
44
}
45
46
{
47
const
float3
c =
fmod
(
make_float3
(1999999.2f, 2000000.3f, 2000001.4f), 1000000.0f);
48
EXPECT_NEAR
(c.
x
, 999999.25f, 1e-6f);
49
EXPECT_NEAR
(c.
y
, 0.25f, 1e-6f);
50
EXPECT_NEAR
(c.
z
, 1.375f, 1e-6f);
51
}
52
53
{
54
const
float3
c =
fmod
(
make_float3
(5.1f, -5.1f, 0.0f), 3.0f);
55
EXPECT_NEAR
(c.
x
, 2.1f, 1e-6f);
56
EXPECT_NEAR
(c.
y
, -2.1, 1e-6f);
57
EXPECT_NEAR
(c.
z
, 0.0f, 1e-6f);
58
}
59
60
{
61
const
float3
c =
fmod
(
make_float3
(5.1f, -5.1f, 0.0f), -3.0f);
62
EXPECT_NEAR
(c.
x
, 2.1f, 1e-6f);
63
EXPECT_NEAR
(c.
y
, -2.1, 1e-6f);
64
}
65
}
66
67
CCL_NAMESPACE_END
Float3Test
Definition
util_math_float3_test.cpp:14
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
make_float3
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
Definition
device/metal/compat.h:206
TEST_F
TEST_F(FFmpegTest, libaom_av1_AV_PIX_FMT_YUV420P)
Definition
ffmpeg_codecs.cc:174
EXPECT_NEAR
#define EXPECT_NEAR(result, expect, threshold)
Definition
gpu_shader_test_lib.bsl.hh:201
fmod
ccl_device_inline float2 fmod(const float2 a, const float b)
Definition
math_float2.h:231
CCL_NAMESPACE_BEGIN
Definition
python.cpp:41
float3
Definition
sky_math.h:135
float3::z
float z
Definition
sky_math.h:136
float3::y
float y
Definition
sky_math.h:136
float3::x
float x
Definition
sky_math.h:136
math.h
Generated on
for Blender by
doxygen
1.18.0