Files
test2/source/blender/compositor/tests/COM_NodeOperation_test.cc
Aras Pranckevicius f5f7024040 Cleanup: Remove now-unused "tiled" compositor implementation
New ("fullframe") CPU compositor backend is being used now, and all the code
related to "tiled" CPU compositor is just never used anymore. The new backend
is faster, uses less memory, better matches GPU compositor, etc.

TL;DR: 20 thousand lines of code gone.

This commit:
- Removes various bits and pieces related to "tiled" compositor (execution
  groups, one-pixel-at-a-time node processing, read/write buffer operations
  related to node execution groups).
- "GPU" (OpenCL) execution device, that was only used by several nodes of
  the tiled compositor.
  - With that, remove CLEW external library too, since nothing within Blender
    uses OpenCL directly anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/118819
2024-02-28 16:59:16 +01:00

153 lines
3.5 KiB
C++

/* SPDX-FileCopyrightText: 2021 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "testing/testing.h"
#include "COM_ConstantOperation.h"
namespace blender::compositor::tests {
class NonHashedOperation : public NodeOperation {
public:
NonHashedOperation(int id)
{
set_id(id);
add_output_socket(DataType::Value);
set_canvas({0, 2, 0, 3});
}
};
class NonHashedConstantOperation : public ConstantOperation {
float constant_;
public:
NonHashedConstantOperation(int id)
{
set_id(id);
add_output_socket(DataType::Value);
set_canvas({0, 2, 0, 3});
constant_ = 1.0f;
}
const float *get_constant_elem() override
{
return &constant_;
}
void set_constant(float value)
{
constant_ = value;
}
};
class HashedOperation : public NodeOperation {
private:
int param1;
float param2;
public:
HashedOperation(NodeOperation &input, int width, int height)
{
add_input_socket(DataType::Value);
add_output_socket(DataType::Color);
set_canvas({0, width, 0, height});
param1 = 2;
param2 = 7.0f;
get_input_socket(0)->set_link(input.get_output_socket());
}
void set_param1(int value)
{
param1 = value;
}
void hash_output_params() override
{
hash_params(param1, param2);
}
};
static void test_non_equal_hashes_compare(NodeOperationHash &h1,
NodeOperationHash &h2,
NodeOperationHash &h3)
{
if (h1 < h2) {
if (h3 < h1) {
EXPECT_TRUE(h3 < h2);
}
else if (h3 < h2) {
EXPECT_TRUE(h1 < h3);
}
else {
EXPECT_TRUE(h1 < h3);
EXPECT_TRUE(h2 < h3);
}
}
else {
EXPECT_TRUE(h2 < h1);
}
}
TEST(NodeOperation, generate_hash)
{
/* Constant input. */
{
NonHashedConstantOperation input_op1(1);
input_op1.set_constant(1.0f);
EXPECT_EQ(input_op1.generate_hash(), std::nullopt);
HashedOperation op1(input_op1, 6, 4);
std::optional<NodeOperationHash> hash1_opt = op1.generate_hash();
EXPECT_NE(hash1_opt, std::nullopt);
NodeOperationHash hash1 = *hash1_opt;
NonHashedConstantOperation input_op2(1);
input_op2.set_constant(1.0f);
HashedOperation op2(input_op2, 6, 4);
NodeOperationHash hash2 = *op2.generate_hash();
EXPECT_EQ(hash1, hash2);
input_op2.set_constant(3.0f);
hash2 = *op2.generate_hash();
EXPECT_NE(hash1, hash2);
}
/* Non constant input. */
{
NonHashedOperation input_op(1);
EXPECT_EQ(input_op.generate_hash(), std::nullopt);
HashedOperation op1(input_op, 6, 4);
HashedOperation op2(input_op, 6, 4);
NodeOperationHash hash1 = *op1.generate_hash();
NodeOperationHash hash2 = *op2.generate_hash();
EXPECT_EQ(hash1, hash2);
op1.set_param1(-1);
hash1 = *op1.generate_hash();
EXPECT_NE(hash1, hash2);
HashedOperation op3(input_op, 11, 14);
NodeOperationHash hash3 = *op3.generate_hash();
EXPECT_NE(hash2, hash3);
EXPECT_NE(hash1, hash3);
test_non_equal_hashes_compare(hash1, hash2, hash3);
test_non_equal_hashes_compare(hash3, hash2, hash1);
test_non_equal_hashes_compare(hash2, hash3, hash1);
test_non_equal_hashes_compare(hash3, hash1, hash2);
NonHashedOperation input_op2(2);
HashedOperation op4(input_op2, 11, 14);
NodeOperationHash hash4 = *op4.generate_hash();
EXPECT_NE(hash3, hash4);
input_op2.set_id(1);
hash4 = *op4.generate_hash();
EXPECT_EQ(hash3, hash4);
}
}
} // namespace blender::compositor::tests