diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2015-01-19 20:13:26 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2015-01-19 20:17:50 +0300 |
commit | 35d3b6316b21ad9ae7eb96a7a541c4051eae3441 (patch) | |
tree | dd4eea63f9229d87041e2f5a5679d05f1360afea /source/blender/compositor/operations/COM_RenderLayersProg.cpp | |
parent | a8fa291b8c539da7669463ef622d5c61ee9c90e7 (diff) |
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.
Diffstat (limited to 'source/blender/compositor/operations/COM_RenderLayersProg.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_RenderLayersProg.cpp | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp index 06f4f6d77cf..f1990453fc6 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp @@ -111,15 +111,6 @@ void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, Pi BLI_bicubic_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y); break; } - - if (this->m_elementsize == 1) { - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; - } - else if (this->m_elementsize == 3) { - output[3] = 1.0f; - } } void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) @@ -145,7 +136,16 @@ void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y #endif if (this->m_inputBuffer == NULL) { - zero_v4(output); + int elemsize = this->m_elementsize; + if (elemsize == 1) { + output[0] = 0.0f; + } + else if (elemsize == 3) { + zero_v3(output); + } else { + BLI_assert(elemsize == 4); + zero_v4(output); + } } else { doInterpolation(output, x, y, sampler); @@ -204,15 +204,12 @@ void RenderLayersAlphaProg::executePixelSampled(float output[4], float x, float float *inputBuffer = this->getInputBuffer(); if (inputBuffer == NULL) { - zero_v4(output); + output[0] = 0.0f; } else { float temp[4]; doInterpolation(temp, x, y, sampler); output[0] = temp[3]; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; } } @@ -227,7 +224,7 @@ RenderLayersColorOperation::RenderLayersColorOperation() : RenderLayersBaseProg( RenderLayersCyclesOperation::RenderLayersCyclesOperation(int pass) : RenderLayersBaseProg(pass, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Depth Operation ******** */ @@ -245,16 +242,10 @@ void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { output[0] = 0.0f; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; } else { unsigned int offset = (iy * this->getWidth() + ix); output[0] = inputBuffer[offset]; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; } } @@ -262,21 +253,21 @@ void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float RenderLayersDiffuseOperation::RenderLayersDiffuseOperation() : RenderLayersBaseProg(SCE_PASS_DIFFUSE, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Emit Operation ******** */ RenderLayersEmitOperation::RenderLayersEmitOperation() : RenderLayersBaseProg(SCE_PASS_EMIT, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Environment Operation ******** */ RenderLayersEnvironmentOperation::RenderLayersEnvironmentOperation() : RenderLayersBaseProg(SCE_PASS_ENVIRONMENT, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Image Operation ******** */ @@ -290,7 +281,7 @@ RenderLayersColorProg::RenderLayersColorProg() : RenderLayersBaseProg(SCE_PASS_C RenderLayersIndirectOperation::RenderLayersIndirectOperation() : RenderLayersBaseProg(SCE_PASS_INDIRECT, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Material Index Operation ******** */ @@ -325,28 +316,28 @@ RenderLayersObjectIndexOperation::RenderLayersObjectIndexOperation() : RenderLay RenderLayersReflectionOperation::RenderLayersReflectionOperation() : RenderLayersBaseProg(SCE_PASS_REFLECT, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Refraction Operation ******** */ RenderLayersRefractionOperation::RenderLayersRefractionOperation() : RenderLayersBaseProg(SCE_PASS_REFRACT, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Shadow Operation ******** */ RenderLayersShadowOperation::RenderLayersShadowOperation() : RenderLayersBaseProg(SCE_PASS_SHADOW, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Specular Operation ******** */ RenderLayersSpecularOperation::RenderLayersSpecularOperation() : RenderLayersBaseProg(SCE_PASS_SPEC, 3) { - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_VECTOR); } /* ******** Render Layers Speed Operation ******** */ |