Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-09-20 18:59:20 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-09-21 15:55:54 +0300
commit08031197250aeecbaca3803254e6f25b8c7b7b37 (patch)
tree6fe7ab045f0dc0a423d6557c4073f34309ef4740 /intern/cycles/test
parentfa6b1007bad065440950cd67deb16a04f368856f (diff)
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity, new shadow catcher, revamped sampling settings, subsurface scattering anisotropy, new GPU volume sampling, improved PMJ sampling pattern, and more. Some features have also been removed or changed, breaking backwards compatibility. Including the removal of the OpenCL backend, for which alternatives are under development. Release notes and code docs: https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles https://wiki.blender.org/wiki/Source/Render/Cycles Credits: * Sergey Sharybin * Brecht Van Lommel * Patrick Mours (OptiX backend) * Christophe Hery (subsurface scattering anisotropy) * William Leeson (PMJ sampling pattern) * Alaska (various fixes and tweaks) * Thomas Dinges (various fixes) For the full commit history, see the cycles-x branch. This squashes together all the changes since intermediate changes would often fail building or tests. Ref T87839, T87837, T87836 Fixes T90734, T89353, T80267, T80267, T77185, T69800
Diffstat (limited to 'intern/cycles/test')
-rw-r--r--intern/cycles/test/CMakeLists.txt5
-rw-r--r--intern/cycles/test/integrator_adaptive_sampling_test.cpp116
-rw-r--r--intern/cycles/test/integrator_render_scheduler_test.cpp37
-rw-r--r--intern/cycles/test/integrator_tile_test.cpp47
-rw-r--r--intern/cycles/test/render_graph_finalize_test.cpp2
-rw-r--r--intern/cycles/test/util_math_test.cpp61
-rw-r--r--intern/cycles/test/util_string_test.cpp36
7 files changed, 303 insertions, 1 deletions
diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt
index 65a692acd03..0f6b435813f 100644
--- a/intern/cycles/test/CMakeLists.txt
+++ b/intern/cycles/test/CMakeLists.txt
@@ -32,6 +32,7 @@ set(INC
set(ALL_CYCLES_LIBRARIES
cycles_device
cycles_kernel
+ cycles_integrator
cycles_render
cycles_bvh
cycles_graph
@@ -45,8 +46,12 @@ include_directories(${INC})
cycles_link_directories()
set(SRC
+ integrator_adaptive_sampling_test.cpp
+ integrator_render_scheduler_test.cpp
+ integrator_tile_test.cpp
render_graph_finalize_test.cpp
util_aligned_malloc_test.cpp
+ util_math_test.cpp
util_path_test.cpp
util_string_test.cpp
util_task_test.cpp
diff --git a/intern/cycles/test/integrator_adaptive_sampling_test.cpp b/intern/cycles/test/integrator_adaptive_sampling_test.cpp
new file mode 100644
index 00000000000..3ed6a23125d
--- /dev/null
+++ b/intern/cycles/test/integrator_adaptive_sampling_test.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2011-2021 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "testing/testing.h"
+
+#include "integrator/adaptive_sampling.h"
+#include "util/util_vector.h"
+
+CCL_NAMESPACE_BEGIN
+
+TEST(AdaptiveSampling, schedule_samples)
+{
+ AdaptiveSampling adaptive_sampling;
+ adaptive_sampling.use = true;
+ adaptive_sampling.min_samples = 0;
+ adaptive_sampling.adaptive_step = 4;
+
+ for (int sample = 2; sample < 32; ++sample) {
+ for (int num_samples = 8; num_samples < 32; ++num_samples) {
+ const int num_samples_aligned = adaptive_sampling.align_samples(sample, num_samples);
+ /* NOTE: `sample + num_samples_aligned` is the number of samples after rendering, so need
+ * to convert this to the 0-based index of the last sample. */
+ EXPECT_TRUE(adaptive_sampling.need_filter(sample + num_samples_aligned - 1));
+ }
+ }
+}
+
+TEST(AdaptiveSampling, align_samples)
+{
+ AdaptiveSampling adaptive_sampling;
+ adaptive_sampling.use = true;
+ adaptive_sampling.min_samples = 11 /* rounded of sqrt(128) */;
+ adaptive_sampling.adaptive_step = 4;
+
+ /* Filtering will happen at the following samples:
+ * 15, 19, 23, 27, 31, 35, 39, 43 */
+
+ /* Requested sample and number of samples will result in number of samples lower than
+ * `min_samples`. */
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 4), 4);
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 7), 7);
+
+ /* Request number of samples higher than the minimum samples before filter, but prior to the
+ * first sample at which filtering will happen. */
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 15), 15);
+
+ /* When rendering many samples from the very beginning, limit number of samples by the first
+ * sample at which filtering is to happen. */
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 16), 16);
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 17), 16);
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 20), 16);
+ EXPECT_EQ(adaptive_sampling.align_samples(0, 60), 16);
+
+ /* Similar to above, but start sample is not 0. */
+ EXPECT_EQ(adaptive_sampling.align_samples(9, 8), 7);
+ EXPECT_EQ(adaptive_sampling.align_samples(9, 20), 7);
+ EXPECT_EQ(adaptive_sampling.align_samples(9, 60), 7);
+
+ /* Start sample is past the minimum required samples, but prior to the first filter sample. */
+ EXPECT_EQ(adaptive_sampling.align_samples(12, 6), 4);
+ EXPECT_EQ(adaptive_sampling.align_samples(12, 20), 4);
+ EXPECT_EQ(adaptive_sampling.align_samples(12, 60), 4);
+
+ /* Start sample is the sample which is to be filtered. */
+ EXPECT_EQ(adaptive_sampling.align_samples(15, 4), 1);
+ EXPECT_EQ(adaptive_sampling.align_samples(15, 6), 1);
+ EXPECT_EQ(adaptive_sampling.align_samples(15, 10), 1);
+ EXPECT_EQ(adaptive_sampling.align_samples(58, 2), 2);
+
+ /* Start sample is past the sample which is to be filtered. */
+ EXPECT_EQ(adaptive_sampling.align_samples(16, 3), 3);
+ EXPECT_EQ(adaptive_sampling.align_samples(16, 4), 4);
+ EXPECT_EQ(adaptive_sampling.align_samples(16, 5), 4);
+ EXPECT_EQ(adaptive_sampling.align_samples(16, 10), 4);
+
+ /* Should never exceed requested number of samples. */
+ EXPECT_EQ(adaptive_sampling.align_samples(15, 2), 1);
+ EXPECT_EQ(adaptive_sampling.align_samples(16, 2), 2);
+ EXPECT_EQ(adaptive_sampling.align_samples(17, 2), 2);
+ EXPECT_EQ(adaptive_sampling.align_samples(18, 2), 2);
+}
+
+TEST(AdaptiveSampling, need_filter)
+{
+ AdaptiveSampling adaptive_sampling;
+ adaptive_sampling.use = true;
+ adaptive_sampling.min_samples = 11 /* rounded of sqrt(128) */;
+ adaptive_sampling.adaptive_step = 4;
+
+ const vector<int> expected_samples_to_filter = {
+ {15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59}};
+
+ vector<int> actual_samples_to_filter;
+ for (int sample = 0; sample < 60; ++sample) {
+ if (adaptive_sampling.need_filter(sample)) {
+ actual_samples_to_filter.push_back(sample);
+ }
+ }
+
+ EXPECT_EQ(actual_samples_to_filter, expected_samples_to_filter);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/test/integrator_render_scheduler_test.cpp b/intern/cycles/test/integrator_render_scheduler_test.cpp
new file mode 100644
index 00000000000..b4efbc2d1a7
--- /dev/null
+++ b/intern/cycles/test/integrator_render_scheduler_test.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011-2021 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "testing/testing.h"
+
+#include "integrator/render_scheduler.h"
+
+CCL_NAMESPACE_BEGIN
+
+TEST(IntegratorRenderScheduler, calculate_resolution_divider_for_resolution)
+{
+ EXPECT_EQ(calculate_resolution_divider_for_resolution(1920, 1080, 1920), 1);
+ EXPECT_EQ(calculate_resolution_divider_for_resolution(1920, 1080, 960), 2);
+ EXPECT_EQ(calculate_resolution_divider_for_resolution(1920, 1080, 480), 4);
+}
+
+TEST(IntegratorRenderScheduler, calculate_resolution_for_divider)
+{
+ EXPECT_EQ(calculate_resolution_for_divider(1920, 1080, 1), 1440);
+ EXPECT_EQ(calculate_resolution_for_divider(1920, 1080, 2), 720);
+ EXPECT_EQ(calculate_resolution_for_divider(1920, 1080, 4), 360);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/test/integrator_tile_test.cpp b/intern/cycles/test/integrator_tile_test.cpp
new file mode 100644
index 00000000000..5bb57b48c3c
--- /dev/null
+++ b/intern/cycles/test/integrator_tile_test.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011-2021 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "testing/testing.h"
+
+#include "integrator/tile.h"
+#include "util/util_math.h"
+
+CCL_NAMESPACE_BEGIN
+
+TEST(tile_calculate_best_size, Basic)
+{
+ /* Make sure CPU-like case is handled properly. */
+ EXPECT_EQ(tile_calculate_best_size(make_int2(1920, 1080), 1, 1), TileSize(1, 1, 1));
+ EXPECT_EQ(tile_calculate_best_size(make_int2(1920, 1080), 100, 1), TileSize(1, 1, 1));
+
+ /* Enough path states to fit an entire image with all samples. */
+ EXPECT_EQ(tile_calculate_best_size(make_int2(1920, 1080), 1, 1920 * 1080),
+ TileSize(1920, 1080, 1));
+ EXPECT_EQ(tile_calculate_best_size(make_int2(1920, 1080), 100, 1920 * 1080 * 100),
+ TileSize(1920, 1080, 100));
+}
+
+TEST(tile_calculate_best_size, Extreme)
+{
+ EXPECT_EQ(tile_calculate_best_size(make_int2(32, 32), 262144, 131072), TileSize(1, 1, 512));
+ EXPECT_EQ(tile_calculate_best_size(make_int2(32, 32), 1048576, 131072), TileSize(1, 1, 1024));
+ EXPECT_EQ(tile_calculate_best_size(make_int2(32, 32), 10485760, 131072), TileSize(1, 1, 4096));
+
+ EXPECT_EQ(tile_calculate_best_size(make_int2(32, 32), 8192 * 8192 * 2, 1024),
+ TileSize(1, 1, 1024));
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/test/render_graph_finalize_test.cpp b/intern/cycles/test/render_graph_finalize_test.cpp
index da9b29314a7..19c211fe5f7 100644
--- a/intern/cycles/test/render_graph_finalize_test.cpp
+++ b/intern/cycles/test/render_graph_finalize_test.cpp
@@ -181,7 +181,7 @@ class RenderGraph : public testing::Test {
util_logging_start();
util_logging_verbosity_set(1);
- device_cpu = Device::create(device_info, stats, profiler, true);
+ device_cpu = Device::create(device_info, stats, profiler);
scene = new Scene(scene_params, device_cpu);
}
diff --git a/intern/cycles/test/util_math_test.cpp b/intern/cycles/test/util_math_test.cpp
new file mode 100644
index 00000000000..b6ce3ef0cf3
--- /dev/null
+++ b/intern/cycles/test/util_math_test.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011-2021 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "testing/testing.h"
+
+#include "util/util_math.h"
+
+CCL_NAMESPACE_BEGIN
+
+TEST(math, next_power_of_two)
+{
+ EXPECT_EQ(next_power_of_two(0), 1);
+ EXPECT_EQ(next_power_of_two(1), 2);
+ EXPECT_EQ(next_power_of_two(2), 4);
+ EXPECT_EQ(next_power_of_two(3), 4);
+ EXPECT_EQ(next_power_of_two(4), 8);
+}
+
+TEST(math, prev_power_of_two)
+{
+ EXPECT_EQ(prev_power_of_two(0), 0);
+
+ EXPECT_EQ(prev_power_of_two(1), 1);
+ EXPECT_EQ(prev_power_of_two(2), 1);
+
+ EXPECT_EQ(prev_power_of_two(3), 2);
+ EXPECT_EQ(prev_power_of_two(4), 2);
+
+ EXPECT_EQ(prev_power_of_two(5), 4);
+ EXPECT_EQ(prev_power_of_two(6), 4);
+ EXPECT_EQ(prev_power_of_two(7), 4);
+ EXPECT_EQ(prev_power_of_two(8), 4);
+}
+
+TEST(math, reverse_integer_bits)
+{
+ EXPECT_EQ(reverse_integer_bits(0xFFFFFFFF), 0xFFFFFFFF);
+ EXPECT_EQ(reverse_integer_bits(0x00000000), 0x00000000);
+ EXPECT_EQ(reverse_integer_bits(0x1), 0x80000000);
+ EXPECT_EQ(reverse_integer_bits(0x80000000), 0x1);
+ EXPECT_EQ(reverse_integer_bits(0xFFFF0000), 0x0000FFFF);
+ EXPECT_EQ(reverse_integer_bits(0x0000FFFF), 0xFFFF0000);
+ EXPECT_EQ(reverse_integer_bits(0x00FF0000), 0x0000FF00);
+ EXPECT_EQ(reverse_integer_bits(0x0000FF00), 0x00FF0000);
+ EXPECT_EQ(reverse_integer_bits(0xAAAAAAAA), 0x55555555);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/test/util_string_test.cpp b/intern/cycles/test/util_string_test.cpp
index 97f8daa65de..c9022d1b132 100644
--- a/intern/cycles/test/util_string_test.cpp
+++ b/intern/cycles/test/util_string_test.cpp
@@ -281,4 +281,40 @@ TEST(util_string_remove_trademark, r_space_middle)
EXPECT_EQ(str, "foo bar baz");
}
+/* ******** Tests for string_startswith() ******** */
+
+TEST(string_startswith, basic)
+{
+ EXPECT_TRUE(string_startswith("", ""));
+
+ EXPECT_FALSE(string_startswith("", "World"));
+ EXPECT_TRUE(string_startswith("Hello", ""));
+
+ EXPECT_FALSE(string_startswith("Hello", "World"));
+
+ EXPECT_TRUE(string_startswith("Hello", "Hello"));
+ EXPECT_TRUE(string_startswith("Hello", "He"));
+ EXPECT_TRUE(string_startswith("Hello", "H"));
+
+ EXPECT_FALSE(string_startswith("Hello", "e"));
+ EXPECT_FALSE(string_startswith("Hello", "HelloWorld"));
+}
+
+TEST(string_endswith, basic)
+{
+ EXPECT_TRUE(string_endswith("", ""));
+
+ EXPECT_FALSE(string_endswith("", "World"));
+ EXPECT_TRUE(string_endswith("Hello", ""));
+
+ EXPECT_FALSE(string_endswith("Hello", "World"));
+
+ EXPECT_TRUE(string_endswith("Hello", "Hello"));
+ EXPECT_TRUE(string_endswith("Hello", "lo"));
+ EXPECT_TRUE(string_endswith("Hello", "o"));
+
+ EXPECT_FALSE(string_endswith("Hello", "e"));
+ EXPECT_FALSE(string_endswith("Hello", "WorldHello"));
+}
+
CCL_NAMESPACE_END