From 35d3b6316b21ad9ae7eb96a7a541c4051eae3441 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 19 Jan 2015 18:13:26 +0100 Subject: D627: Memory usage optimization for the compositor. The compostor used a fixed size of 4 floats to hold pixel data. this patch will select size of a pixel based on its type. It uses 1 float for Value, 3 float for vector and 4 floats for color data types. When benchmarking on shots (opening shot of caminandes) we get a reduction of memory of 30% and a tiny speedup as less data transformations needs to take place (but these are negligable. More information of the patch can be found on https://developer.blender.org/D627 and http://wiki.blender.org/index.php/Dev:Ref/Proposals/Compositor2014_p1.1_TD Developers: jbakker & mdewanchand Thanks for Sergey for his indept review. --- .../operations/COM_ReadBufferOperation.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source/blender/compositor/operations/COM_ReadBufferOperation.cpp') diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 47d5fc6bcca..709c30f4015 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -24,9 +24,9 @@ #include "COM_WriteBufferOperation.h" #include "COM_defines.h" -ReadBufferOperation::ReadBufferOperation() : NodeOperation() +ReadBufferOperation::ReadBufferOperation(DataType datatype) : NodeOperation() { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(datatype); this->m_single_value = false; this->m_offset = 0; this->m_buffer = NULL; @@ -58,11 +58,20 @@ void ReadBufferOperation::executePixelSampled(float output[4], float x, float y, /* write buffer has a single value stored at (0,0) */ m_buffer->read(output, 0, 0); } - else if (sampler == COM_PS_NEAREST) { - m_buffer->read(output, x, y); - } else { - m_buffer->readBilinear(output, x, y); + switch (sampler) { + case COM_PS_NEAREST: + m_buffer->read(output, x, y); + break; + case COM_PS_BILINEAR: + default: + m_buffer->readBilinear(output, x, y); + break; + case COM_PS_BICUBIC: + m_buffer->readBilinear(output, x, y); + break; + } + } } -- cgit v1.2.3