[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59188] trunk/blender/source/blender/ compositor/operations: Fix for #36468, "Buffer Groups" option changes compositing output.
Lukas Toenne
lukas.toenne at googlemail.com
Fri Aug 16 15:11:15 CEST 2013
Revision: 59188
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59188
Author: lukastoenne
Date: 2013-08-16 13:11:15 +0000 (Fri, 16 Aug 2013)
Log Message:
-----------
Fix for #36468, "Buffer Groups" option changes compositing output.
Problem is that the read/write buffer operations only work with actual
image inputs. If a singular value is used as group input no actual
buffer will be created, the write operation does not schedule any chunks
and the ReadBufferOperation subsequently returns zero
(MemoryBuffer::read).
The fix uses the (0,0) resolution to detect single value input of the
WriteBufferOperation. The actual resolution is then clamped to (1,1) to
ensure we have a single pixel to store the value in. A m_single_value
flag is also set, so we can reliably distinguish this from genuine image
resolutions without having to check m_width/m_height later on.
The ReadBufferOperation copies this flag from the associated
WriteBufferOperation and if set will always return the single value from
pixel (0,0).
Modified Paths:
--------------
trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.h
trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.h
Modified: trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.cpp 2013-08-16 13:06:40 UTC (rev 59187)
+++ trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.cpp 2013-08-16 13:11:15 UTC (rev 59188)
@@ -27,6 +27,7 @@
ReadBufferOperation::ReadBufferOperation() : NodeOperation()
{
this->addOutputSocket(COM_DT_COLOR);
+ this->m_single_value = false;
this->m_offset = 0;
this->m_buffer = NULL;
}
@@ -47,11 +48,17 @@
if (this->m_memoryProxy->getExecutor()) {
this->m_memoryProxy->getExecutor()->setResolution(resolution);
}
+
+ m_single_value = operation->isSingleValue();
}
}
void ReadBufferOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
- if (sampler == COM_PS_NEAREST) {
+ if (m_single_value) {
+ /* 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 {
@@ -61,7 +68,13 @@
void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler)
{
- m_buffer->readEWA(output, x, y, dx, dy, sampler);
+ if (m_single_value) {
+ /* write buffer has a single value stored at (0,0) */
+ m_buffer->read(output, 0, 0);
+ }
+ else {
+ m_buffer->readEWA(output, x, y, dx, dy, sampler);
+ }
}
bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
Modified: trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.h 2013-08-16 13:06:40 UTC (rev 59187)
+++ trunk/blender/source/blender/compositor/operations/COM_ReadBufferOperation.h 2013-08-16 13:11:15 UTC (rev 59188)
@@ -29,6 +29,7 @@
class ReadBufferOperation : public NodeOperation {
private:
MemoryProxy *m_memoryProxy;
+ bool m_single_value; /* single value stored in buffer, copied from associated write operation */
unsigned int m_offset;
MemoryBuffer *m_buffer;
public:
Modified: trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp 2013-08-16 13:06:40 UTC (rev 59187)
+++ trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp 2013-08-16 13:11:15 UTC (rev 59188)
@@ -174,6 +174,21 @@
delete clKernelsToCleanUp;
}
+void WriteBufferOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+{
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ /* make sure there is at least one pixel stored in case the input is a single value */
+ m_single_value = false;
+ if (resolution[0] == 0) {
+ resolution[0] = 1;
+ m_single_value = true;
+ }
+ if (resolution[1] == 0) {
+ resolution[1] = 1;
+ m_single_value = true;
+ }
+}
+
void WriteBufferOperation::readResolutionFromInputSocket()
{
NodeOperation *inputOperation = this->getInputOperation(0);
Modified: trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.h 2013-08-16 13:06:40 UTC (rev 59187)
+++ trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.h 2013-08-16 13:11:15 UTC (rev 59188)
@@ -32,6 +32,7 @@
*/
class WriteBufferOperation : public NodeOperation {
MemoryProxy *m_memoryProxy;
+ bool m_single_value; /* single value stored in buffer */
NodeOperation *m_input;
public:
WriteBufferOperation();
@@ -40,11 +41,13 @@
MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
void executePixel(float output[4], float x, float y, PixelSampler sampler);
const bool isWriteBufferOperation() const { return true; }
+ bool isSingleValue() const { return m_single_value; }
void executeRegion(rcti *rect, unsigned int tileNumber);
void initExecution();
void deinitExecution();
void executeOpenCLRegion(OpenCLDevice *device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void readResolutionFromInputSocket();
inline NodeOperation *getInput() {
return m_input;
More information about the Bf-blender-cvs
mailing list