[Bf-blender-cvs] [90d6ee8b6c3] temp-viewport-compositor-compiler: Viewport Compositor: Pre-store result texture pool
Omar Emara
noreply at git.blender.org
Mon Mar 14 12:01:11 CET 2022
Commit: 90d6ee8b6c3269aee05adcafd016051e4d65fa6c
Author: Omar Emara
Date: Mon Mar 14 09:45:54 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rB90d6ee8b6c3269aee05adcafd016051e4d65fa6c
Viewport Compositor: Pre-store result texture pool
Store the texture pool of the result during construction to avoid
passing it every time during allocation.
===================================================================
M source/blender/nodes/NOD_compositor_execute.hh
M source/blender/nodes/composite/nodes/node_composite_image.cc
M source/blender/nodes/composite/nodes/node_composite_transform.cc
M source/blender/nodes/intern/node_compositor_execute.cc
===================================================================
diff --git a/source/blender/nodes/NOD_compositor_execute.hh b/source/blender/nodes/NOD_compositor_execute.hh
index a3b1290a38f..0d95210a448 100644
--- a/source/blender/nodes/NOD_compositor_execute.hh
+++ b/source/blender/nodes/NOD_compositor_execute.hh
@@ -227,8 +227,9 @@ class Result {
* the result is not a texture, this member points to a valid dummy GPU texture. See class
* description above. */
GPUTexture *texture = nullptr;
- /* The texture pool used to allocate the texture of the result. */
- TexturePool *texture_pool = nullptr;
+ /* The texture pool used to allocate the texture of the result, this should be initialized during
+ * construction. */
+ TexturePool &texture_pool;
/* The number of users currently referencing and using this result. */
int reference_count = 0;
/* If the result is a single value, this member stores the value of the result. While this member
@@ -242,15 +243,15 @@ class Result {
Transformation2D transformation = Transformation2D::identity();
public:
- Result(ResultType type);
+ Result(ResultType type, TexturePool &texture_pool);
/* Declare the result to be a texture result and allocate a texture of an appropriate type with
* the given size from the given texture pool. */
- void allocate_texture(int2 size, TexturePool *texture_pool);
+ void allocate_texture(int2 size);
/* Declare the result to be a single value result and allocate a dummy texture of an appropriate
* type from the given texture pool. See class description for more information. */
- void allocate_single_value(TexturePool *texture_pool);
+ void allocate_single_value();
/* Bind the texture of the result to the texture image unit with the given name in the currently
* bound given shader. */
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc
index a62399fd719..0b9c1c82d95 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_image.cc
@@ -479,13 +479,13 @@ class ImageOperation : public NodeOperation {
GPUTexture *image_texture = get_image_texture();
/* The image texture is invalid or missing, allocate a single zero output. */
if (!image_texture) {
- result.allocate_single_value(&context().texture_pool());
+ result.allocate_single_value();
return;
}
const int width = GPU_texture_width(image_texture);
const int height = GPU_texture_height(image_texture);
- result.allocate_texture(int2{width, height}, &context().texture_pool());
+ result.allocate_texture(int2{width, height});
}
void execute() override
@@ -717,7 +717,7 @@ class RenderLayerOperation : public NodeOperation {
const int height = GPU_texture_height(pass_texture);
Result &image_result = get_result("Image");
- image_result.allocate_texture(int2{width, height}, &context().texture_pool());
+ image_result.allocate_texture(int2{width, height});
}
void execute() override
diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.cc b/source/blender/nodes/composite/nodes/node_composite_transform.cc
index 1095773839a..209bf3de1a4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_transform.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_transform.cc
@@ -66,10 +66,10 @@ class TransformOperation : public NodeOperation {
const Result &input = get_input("Image");
Result &result = get_result("Image");
if (input.is_texture) {
- result.allocate_texture(input.size(), &texture_pool());
+ result.allocate_texture(input.size());
}
else {
- result.allocate_single_value(&texture_pool());
+ result.allocate_single_value();
}
}
diff --git a/source/blender/nodes/intern/node_compositor_execute.cc b/source/blender/nodes/intern/node_compositor_execute.cc
index 02a569ed73a..e387f349ad1 100644
--- a/source/blender/nodes/intern/node_compositor_execute.cc
+++ b/source/blender/nodes/intern/node_compositor_execute.cc
@@ -141,42 +141,40 @@ bool operator!=(const Domain &a, const Domain &b)
* Result.
*/
-Result::Result(ResultType type) : type(type)
+Result::Result(ResultType type, TexturePool &texture_pool) : type(type), texture_pool(texture_pool)
{
}
-void Result::allocate_texture(int2 size, TexturePool *texture_pool)
+void Result::allocate_texture(int2 size)
{
is_texture = true;
- this->texture_pool = texture_pool;
switch (type) {
case ResultType::Float:
- texture = texture_pool->acquire_float(size);
+ texture = texture_pool.acquire_float(size);
return;
case ResultType::Vector:
- texture = texture_pool->acquire_vector(size);
+ texture = texture_pool.acquire_vector(size);
return;
case ResultType::Color:
- texture = texture_pool->acquire_color(size);
+ texture = texture_pool.acquire_color(size);
return;
}
}
-void Result::allocate_single_value(TexturePool *texture_pool)
+void Result::allocate_single_value()
{
is_texture = false;
- this->texture_pool = texture_pool;
/* Allocate a dummy texture of size 1x1. */
const int2 dummy_texture_size{1, 1};
switch (type) {
case ResultType::Float:
- texture = texture_pool->acquire_float(dummy_texture_size);
+ texture = texture_pool.acquire_float(dummy_texture_size);
return;
case ResultType::Vector:
- texture = texture_pool->acquire_vector(dummy_texture_size);
+ texture = texture_pool.acquire_vector(dummy_texture_size);
return;
case ResultType::Color:
- texture = texture_pool->acquire_color(dummy_texture_size);
+ texture = texture_pool.acquire_color(dummy_texture_size);
return;
}
}
@@ -239,7 +237,7 @@ void Result::release()
{
reference_count--;
if (reference_count == 0) {
- texture_pool->release(texture);
+ texture_pool.release(texture);
}
}
@@ -492,7 +490,9 @@ NodeOperation::NodeOperation(Context &context, DNode node) : Operation(context),
{
/* Populate the output results. */
for (const OutputSocketRef *output : node->outputs()) {
- populate_result(output->identifier(), Result(get_node_socket_result_type(output)));
+ const ResultType result_type = get_node_socket_result_type(output);
+ const Result result = Result(result_type, texture_pool());
+ populate_result(output->identifier(), result);
}
/* Populate the input descriptors. */
@@ -557,7 +557,7 @@ void NodeOperation::pre_allocate()
{
/* Allocate the unlinked inputs results. */
for (Result &result : unlinked_inputs_results_) {
- result.allocate_single_value(&texture_pool());
+ result.allocate_single_value();
}
}
@@ -613,7 +613,8 @@ void NodeOperation::populate_results_for_unlinked_inputs()
/* Construct a result of an appropriate type, add it to the results vector, and map the input
* to it. */
- Result result = Result(get_node_socket_result_type(origin.socket_ref()));
+ const ResultType result_type = get_node_socket_result_type(origin.socket_ref());
+ const Result result = Result(result_type, texture_pool());
unlinked_inputs_results_.append(result);
map_input_to_result(input->identifier(), &unlinked_inputs_results_.last());
@@ -682,10 +683,10 @@ void ConversionProcessorOperation::allocate()
Result &result = get_result();
const Result &input = get_input();
if (input.is_texture) {
- result.allocate_texture(input.size(), &texture_pool());
+ result.allocate_texture(input.size());
}
else {
- result.allocate_single_value(&texture_pool());
+ result.allocate_single_value();
}
}
@@ -738,7 +739,7 @@ ConvertFloatToVectorProcessorOperation::ConvertFloatToVectorProcessorOperation(C
input_descriptor.type = ResultType::Float;
input_descriptor.is_domain = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(ResultType::Vector));
+ populate_result(Result(ResultType::Vector, texture_pool()));
}
void ConvertFloatToVectorProcessorOperation::execute_single(const Result &input, Result &output)
@@ -764,7 +765,7 @@ ConvertFloatToColorProcessorOperation::ConvertFloatToColorProcessorOperation(Con
input_descriptor.type = ResultType::Float;
input_descriptor.is_domain = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(ResultType::Color));
+ populate_result(Result(ResultType::Color, texture_pool()));
}
void ConvertFloatToColorProcessorOperation::execute_single(const Result &input, Result &output)
@@ -789,7 +790,7 @@ ConvertColorToFloatProcessorOperation::ConvertColorToFloatProcessorOperation(Con
input_descriptor.type = ResultType::Color;
input_descriptor.is_domain = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(ResultType::Float));
+ populate_result(Result(ResultType::Float, texture_pool()));
}
void ConvertColorToFloatProcessorOperation::execute_single(const Result &input, Result &output)
@@ -813,7 +814,7 @@ ConvertVectorToFloatProcessorOperation::ConvertVectorToFloatProcessorOperation(C
input_descriptor.type = ResultType::Vector;
input_descriptor.is_domain = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(ResultType::Float));
+ populate_result(Result(ResultType::Float, texture_pool()));
}
void ConvertVectorToFloatProcessorOperation::execute_single(const Result &input, Result &output)
@@ -839,7 +840,7 @@ ConvertVectorToColorProcessorOperation::ConvertVectorToColorProcessorOperation(C
input_descriptor.type = ResultType::Vector;
input_descriptor.is_domain = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(ResultType::Color));
+ populate_result(Result(ResultType::Color, texture_pool()));
}
void ConvertVectorToColorProcessorOperation::execute_single(const Result &input, Result &output)
@@ -866,12 +867,12 @@ RealizeOnDomainProcessorOperation::RealizeOnDomainProcessorOperation(Context &co
input_descriptor.type = type;
input_descriptor.skip_realization = true;
declare_input_descriptor(input_descriptor);
- populate_result(Result(type));
+ populate_result(Result(type
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list