Blender
V5.3
intern
cycles
test
util_math_float4_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
Float4Test
:
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
(
Float4Test
,
fmod
)
24
{
25
{
26
const
float4
c =
fmod
(
make_float4
(1.2f, 2.3f, 3.4f, 4.5f), 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
EXPECT_NEAR
(c.
w
, 0.5f, 1e-6f);
31
}
32
33
{
34
const
float4
c =
fmod
(
make_float4
(1.2f, 2.3f, 3.4f, 0.9f), 1.2f);
35
EXPECT_NEAR
(c.
x
, 0.0f, 1e-6f);
36
EXPECT_NEAR
(c.
y
, 1.1f, 1e-6f);
37
EXPECT_NEAR
(c.
z
, 1.0f, 1e-6f);
38
EXPECT_NEAR
(c.
w
, 0.9f, 1e-6f);
39
}
40
41
{
42
const
float4
c =
fmod
(
make_float4
(1.2f, 2.3f, 3.4f, 0.0f), 1000000.0f);
43
EXPECT_NEAR
(c.
x
, 1.2f, 1e-6f);
44
EXPECT_NEAR
(c.
y
, 2.3f, 1e-6f);
45
EXPECT_NEAR
(c.
z
, 3.4f, 1e-6f);
46
}
47
48
{
49
const
float4
c =
fmod
(
make_float4
(1999999.2f, 2000000.3f, 2000001.4f, 0.0f), 1000000.0f);
50
EXPECT_NEAR
(c.
x
, 999999.25f, 1e-6f);
51
EXPECT_NEAR
(c.
y
, 0.25f, 1e-6f);
52
EXPECT_NEAR
(c.
z
, 1.375f, 1e-6f);
53
}
54
55
{
56
const
float4
c =
fmod
(
make_float4
(5.1f, -5.1f, 0.0f, 0.0f), 3.0f);
57
EXPECT_NEAR
(c.
x
, 2.1f, 1e-6f);
58
EXPECT_NEAR
(c.
y
, -2.1, 1e-6f);
59
EXPECT_NEAR
(c.
z
, 0.0f, 1e-6f);
60
}
61
62
{
63
const
float4
c =
fmod
(
make_float4
(5.1f, -5.1f, 0.0f, 0.0f), -3.0f);
64
EXPECT_NEAR
(c.
x
, 2.1f, 1e-6f);
65
EXPECT_NEAR
(c.
y
, -2.1, 1e-6f);
66
}
67
}
68
69
CCL_NAMESPACE_END
Float4Test
Definition
util_math_float4_test.cpp:14
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
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
make_float4
#define make_float4
Definition
radial_tiling_shared.hh:90
float4
Definition
sky_math.h:224
float4::y
float y
Definition
sky_math.h:225
float4::z
float z
Definition
sky_math.h:225
float4::x
float x
Definition
sky_math.h:225
float4::w
float w
Definition
sky_math.h:225
math.h
Generated on
for Blender by
doxygen
1.18.0