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:
authorManuel Castilla <manzanillawork@gmail.com>2021-07-22 19:35:08 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-07-22 19:51:51 +0300
commit1a91c5732032621ff58677178a93f5e6a9d2b8f8 (patch)
tree9e44fd40a7442c767996083e80844458db968151 /source/blender/compositor
parentb1bf4c2a056958165058552e5e95039c7de726c2 (diff)
Compositor: Fix crash when using empty input sources
It's the case of Image or Movie Clip node when not selecting any source or an empty one. Render methods expect an output buffer with size, only render operations with resolution.
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/intern/COM_FullFrameExecutionModel.cc19
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cc13
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h2
3 files changed, 30 insertions, 4 deletions
diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
index 9f6904bb306..bd3a481d691 100644
--- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
+++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc
@@ -20,6 +20,7 @@
#include "COM_Debug.h"
#include "COM_ExecutionGroup.h"
#include "COM_ReadBufferOperation.h"
+#include "COM_ViewerOperation.h"
#include "COM_WorkScheduler.h"
#include "BLT_translation.h"
@@ -100,11 +101,15 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op)
const bool has_outputs = op->getNumberOfOutputSockets() > 0;
MemoryBuffer *op_buf = has_outputs ? create_operation_buffer(op) : nullptr;
- Span<rcti> areas = active_buffers_.get_areas_to_render(op);
- op->render(op_buf, areas, input_bufs);
+ if (op->getWidth() > 0 && op->getHeight() > 0) {
+ Span<rcti> areas = active_buffers_.get_areas_to_render(op);
+ op->render(op_buf, areas, input_bufs);
+ DebugInfo::operation_rendered(op, op_buf);
+ }
+ /* Even if operation has no resolution set the empty buffer. It will be clipped with a
+ * TranslateOperation from convert resolutions if linked to an operation with resolution. */
active_buffers_.set_rendered_buffer(op, std::unique_ptr<MemoryBuffer>(op_buf));
- DebugInfo::operation_rendered(op, op_buf);
operation_finished(op);
}
@@ -118,10 +123,16 @@ void FullFrameExecutionModel::render_operations()
WorkScheduler::start(this->context_);
for (eCompositorPriority priority : priorities_) {
for (NodeOperation *op : operations_) {
- if (op->isOutputOperation(is_rendering) && op->getRenderPriority() == priority) {
+ const bool has_size = op->getWidth() > 0 && op->getHeight() > 0;
+ const bool is_priority_output = op->isOutputOperation(is_rendering) &&
+ op->getRenderPriority() == priority;
+ if (is_priority_output && has_size) {
render_output_dependencies(op);
render_operation(op);
}
+ else if (is_priority_output && !has_size && op->isActiveViewerOutput()) {
+ static_cast<ViewerOperation *>(op)->clear_display_buffer();
+ }
}
}
WorkScheduler::stop();
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc
index e47396e14a1..37a45ac32cb 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cc
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cc
@@ -246,4 +246,17 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(output),
updateImage(&area);
}
+void ViewerOperation::clear_display_buffer()
+{
+ BLI_assert(isActiveViewerOutput());
+ initImage();
+ size_t buf_bytes = (size_t)m_ibuf->y * m_ibuf->x * COM_DATA_TYPE_COLOR_CHANNELS * sizeof(float);
+ if (buf_bytes > 0) {
+ memset(m_outputBuffer, 0, buf_bytes);
+ rcti display_area;
+ BLI_rcti_init(&display_area, 0, m_ibuf->x, 0, m_ibuf->y);
+ updateImage(&display_area);
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index ed05a7a282d..06ac501a535 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -131,6 +131,8 @@ class ViewerOperation : public MultiThreadedOperation {
const rcti &area,
Span<MemoryBuffer *> inputs) override;
+ void clear_display_buffer();
+
private:
void updateImage(const rcti *rect);
void initImage();