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-09-18 20:04:47 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-09-19 22:13:45 +0300
commitf256bfb3e26c32af12c82dbd32d4b3bcfba252f3 (patch)
treef1d4298df2e644813ae0c50dab21686192b8e7ae /source/blender/compositor/intern
parent942c471ce9692379d6b935b97c6f6019fec0c8a1 (diff)
Compositor: Fix crash exporting buffers on debug
ImBuf allocates 4 channels, use copying to support buffers with 1 and 3 channels.
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r--source/blender/compositor/intern/COM_Debug.cc12
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cc2
2 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc
index 007085ee528..f2dcba65b7c 100644
--- a/source/blender/compositor/intern/COM_Debug.cc
+++ b/source/blender/compositor/intern/COM_Debug.cc
@@ -468,11 +468,13 @@ static std::string get_operations_export_dir()
void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render)
{
- ImBuf *ibuf = IMB_allocFromBuffer(nullptr,
- render->getBuffer(),
- render->getWidth(),
- render->getHeight(),
- render->get_num_channels());
+ const int width = render->getWidth();
+ const int height = render->getHeight();
+ const int num_channels = render->get_num_channels();
+
+ ImBuf *ibuf = IMB_allocImBuf(width, height, 8 * num_channels, IB_rectfloat);
+ MemoryBuffer mem_ibuf(ibuf->rect_float, 4, width, height);
+ mem_ibuf.copy_from(render, render->get_rect(), 0, num_channels, 0);
const std::string file_name = operation_class_name(op) + "_" + std::to_string(op->get_id()) +
".png";
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc
index 1fbf502fea6..5327be50b53 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cc
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc
@@ -32,7 +32,7 @@
BLI_assert((buf)->get_rect().ymax >= (y) + BLI_rcti_size_y(&(area)))
#define ASSERT_VALID_ELEM_SIZE(buf, channel_offset, elem_size) \
- BLI_assert((buf)->get_num_channels() <= (channel_offset) + (elem_size))
+ BLI_assert((buf)->get_num_channels() >= (channel_offset) + (elem_size))
namespace blender::compositor {