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.
This commit is contained in:
@@ -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 ******** */
|
||||
|
||||
Reference in New Issue
Block a user