Blender V5.3
util_types_spherical_harmonics_test.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2026 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
9
10#include <gmock/gmock.h>
11#include <gtest/gtest.h>
12
13#include "util/log.h"
14
16
17/* Use as:
18 * float3 vector1;
19 * float3 vector2;
20 * EXPECT_THAT(vector1, IsNearFloat3(vector2)); */
21MATCHER_P2(IsNearFloat3, expected, eps, "")
22{
23 for (int i = 0; i < 3; ++i) {
24 if (fabsf(arg[i] - expected[i]) > eps) {
25 *result_listener << "component " << i << " should be " << expected[i];
26 return false;
27 }
28 }
29 return true;
30}
31
32class PackedSphericalHarmonicsTest : public ::testing::Test {
33 void SetUp() override
34 {
35 /* The micro-architecture check is not needed here, but use it here as a demonstration of how
36 * it can be implemented in a clear way. */
37 // GTEST_SKIP() << "Test skipped due to uarch capability";
38 }
39};
40
42{
44
46
47 for (int i = 0; i < PackedSphericalHarmonicsRest::MAX_COEFFICIENTS; ++i) {
48 EXPECT_THAT(spherical_harmonics_rest_get_coefficient(sh_rest, i),
49 IsNearFloat3(make_float3(0.0f, 0.0f, 0.0f), 1.0f / 127.0f));
50 }
51
52 spherical_harmonics_rest_set_coefficient(sh_rest, 1, make_float3(0.1f, -0.2f, 0.3f));
53 EXPECT_THAT(spherical_harmonics_rest_get_coefficient(sh_rest, 1),
54 IsNearFloat3(make_float3(0.1f, -0.2f, 0.3f), 1.0f / 127.0f));
55}
56
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
TEST_F(FFmpegTest, libaom_av1_AV_PIX_FMT_YUV420P)
const btScalar eps
Definition poly34.cpp:11
#define fabsf
ccl_static_constexpr int MAX_COEFFICIENTS
ccl_device_forceinline void spherical_harmonics_rest_fill_zero(ccl_global PackedSphericalHarmonicsRest &packed_spherical_harmonics_rest)
ccl_device_forceinline float3 spherical_harmonics_rest_get_coefficient(const ccl_global PackedSphericalHarmonicsRest &packed_spherical_harmonics_rest, const int index)
ccl_device_forceinline void spherical_harmonics_rest_set_coefficient(ccl_global PackedSphericalHarmonicsRest &packed_spherical_harmonics_rest, const int index, const float3 value)
MATCHER_P2(IsNearFloat3, expected, eps, "")