[Bf-blender-cvs] [e9fae9eda15] temp-compositor-scheduling: Merge branch 'master' into temp-compositor-scheduling
Jeroen Bakker
noreply at git.blender.org
Tue Apr 6 16:25:36 CEST 2021
Commit: e9fae9eda159b36bbd7d84638d230d4d11da9dc6
Author: Jeroen Bakker
Date: Tue Apr 6 14:43:53 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBe9fae9eda159b36bbd7d84638d230d4d11da9dc6
Merge branch 'master' into temp-compositor-scheduling
===================================================================
===================================================================
diff --cc release/scripts/addons
index 08e9ab150d1,ebe76f3a7ba..b4d5d760e8c
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 08e9ab150d105ba4de2b977b94ab794efd6fd1f2
-Subproject commit ebe76f3a7ba96b3881567def29b7e2527e018e9a
++Subproject commit b4d5d760e8c1e46aaea046e327955b66fdc91f46
diff --cc source/blender/compositor/COM_defines.h
index 9e3f99cd49d,c5ff2b3adc6..f2042f25d4d
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@@ -52,69 -52,6 +52,21 @@@ constexpr int COM_data_type_num_channel
constexpr int COM_DATA_TYPE_VALUE_CHANNELS = COM_data_type_num_channels(DataType::Value);
constexpr int COM_DATA_TYPE_COLOR_CHANNELS = COM_data_type_num_channels(DataType::Color);
- /**
- * \brief Possible quality settings
- * \see CompositorContext.quality
- * \ingroup Execution
- */
- enum class CompositorQuality {
- /** \brief High quality setting */
- High = 0,
- /** \brief Medium quality setting */
- Medium = 1,
- /** \brief Low quality setting */
- Low = 2,
- };
-
- /**
- * \brief Possible priority settings
- * \ingroup Execution
- */
- enum class CompositorPriority {
- /** \brief High quality setting */
- High = 2,
- /** \brief Medium quality setting */
- Medium = 1,
- /** \brief Low quality setting */
- Low = 0,
- /** No priority set. Is used to mark WorkPackages that aren't used. */
- Unset = -1,
- };
-
+enum class eSchedulingMode {
+ /**
+ * Input based scheduling mode. Scheduling starts from input nodes. When a work package is
+ * finished, other work packages are scheduled where all inputs have been executed..
+ */
+ InputToOutput,
+
+ /**
+ * Scheduling mode where outputs are scheduled when all its inputs have been completed. When
+ * inputs aren't completed it tries to schedule these inputs recursivly.
+ */
+ OutputToInput,
+};
+static constexpr eSchedulingMode COM_SCHEDULING_MODE = eSchedulingMode::OutputToInput;
+
- /**
- * \brief the execution state of a chunk in an ExecutionGroup
- * \ingroup Execution
- */
- enum class eChunkExecutionState {
- /**
- * \brief chunk is not yet scheduled
- */
- NotScheduled = 0,
- /**
- * \brief chunk is scheduled, but not yet executed
- */
- Scheduled = 1,
- /**
- * \brief chunk is executed.
- */
- Executed = 2,
- };
-
// configurable items
// chunk size determination
diff --cc source/blender/compositor/intern/COM_CPUDevice.cc
index fc2543c807c,29a82bec636..18b7b9f351c
--- a/source/blender/compositor/intern/COM_CPUDevice.cc
+++ b/source/blender/compositor/intern/COM_CPUDevice.cc
@@@ -35,7 -35,6 +35,7 @@@ void CPUDevice::execute(WorkPackage *wo
executionGroup->getOutputOperation()->executeRegion(&work_package->rect, chunkNumber);
executionGroup->finalizeChunkExecution(chunkNumber, nullptr);
- work_package->state = eChunkExecutionState::Executed;
++ work_package->state = eWorkPackageState::Executed;
}
} // namespace blender::compositor
diff --cc source/blender/compositor/intern/COM_Enums.h
index 00000000000,f65ce3e856e..0ab8a9053c1
mode 000000,100644..100644
--- a/source/blender/compositor/intern/COM_Enums.h
+++ b/source/blender/compositor/intern/COM_Enums.h
@@@ -1,0 -1,76 +1,88 @@@
+ /*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2021, Blender Foundation.
+ */
+
+ #pragma once
+
+ #include "COM_defines.h"
+
+ #include <ostream>
+
+ namespace blender::compositor {
+
+ /**
+ * \brief Possible quality settings
+ * \see CompositorContext.quality
+ * \ingroup Execution
+ */
+ enum class eCompositorQuality {
+ /** \brief High quality setting */
+ High = 0,
+ /** \brief Medium quality setting */
+ Medium = 1,
+ /** \brief Low quality setting */
+ Low = 2,
+ };
+
+ /**
+ * \brief Possible priority settings
+ * \ingroup Execution
+ */
+ enum class eCompositorPriority {
+ /** \brief High quality setting */
+ High = 2,
+ /** \brief Medium quality setting */
+ Medium = 1,
+ /** \brief Low quality setting */
+ Low = 0,
++ /**
++ * No priority set. Is used to mark WorkPackages that aren't needed to be scheduled (yet).
++ *
++ * When executing the compositor marks all dependend work packages with a High priority. Work
++ * packages with the high priority are scheduled. After completed medium priority work packages
++ * are determined and scheduled.
++ *
++ * The Unset marks work packages that don't have been selected for the current priority that
++ * is being executed. They might be selected when executing the other priority or aren't needed
++ * at all. The later can happen when the tile is moved completely out the visible viewport.
++ */
++ Unset = -1,
+ };
+
+ /**
+ * \brief the execution state of a chunk in an ExecutionGroup
+ * \ingroup Execution
+ */
+ enum class eWorkPackageState {
+ /**
+ * \brief chunk is not yet scheduled
+ */
+ NotScheduled = 0,
+ /**
+ * \brief chunk is scheduled, but not yet executed
+ */
+ Scheduled = 1,
+ /**
+ * \brief chunk is executed.
+ */
+ Executed = 2,
+ };
+
+ std::ostream &operator<<(std::ostream &os, const eCompositorPriority &priority);
+ std::ostream &operator<<(std::ostream &os, const eWorkPackageState &execution_state);
+
+ } // namespace blender::compositor
diff --cc source/blender/compositor/intern/COM_ExecutionGroup.cc
index 89b1e3bbc72,80d453bf7f9..5e14df87eb7
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cc
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc
@@@ -161,8 -157,7 +156,8 @@@ void ExecutionGroup::init_work_packages
if (this->m_chunks_len != 0) {
m_work_packages.resize(this->m_chunks_len);
for (unsigned int index = 0; index < m_chunks_len; index++) {
- m_work_packages[index].state = eChunkExecutionState::NotScheduled;
- m_work_packages[index].priority = CompositorPriority::Unset;
+ m_work_packages[index].state = eWorkPackageState::NotScheduled;
++ m_work_packages[index].priority = eCompositorPriority::Unset;
m_work_packages[index].execution_group = this;
m_work_packages[index].chunk_number = index;
determineChunkRect(&m_work_packages[index].rect, index);
@@@ -365,10 -359,12 +360,10 @@@ void ExecutionGroup::execute(ExecutionS
index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated;
index++) {
chunk_index = chunk_order[index];
- int yChunk = chunk_index / this->m_x_chunks_len;
- int xChunk = chunk_index - (yChunk * this->m_x_chunks_len);
- const WorkPackage &work_package = m_work_packages[chunk_index];
+ WorkPackage &work_package = m_work_packages[chunk_index];
switch (work_package.state) {
- case eChunkExecutionState::NotScheduled: {
+ case eWorkPackageState::NotScheduled: {
- scheduleChunkWhenPossible(graph, xChunk, yChunk);
+ scheduleChunkWhenPossible(graph, work_package);
finished = false;
startEvaluated = true;
numberEvaluated++;
@@@ -431,15 -427,11 +426,15 @@@ MemoryBuffer *ExecutionGroup::construct
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
WorkPackage &work_package = m_work_packages[chunkNumber];
- if (work_package.state == eWorkPackageState::Scheduled) {
- work_package.state = eWorkPackageState::Executed;
+ for (WorkPackage *child : work_package.children) {
+ if (child->parent_finished()) {
+ if (COM_SCHEDULING_MODE == eSchedulingMode::InputToOutput &&
- child->priority != CompositorPriority::Unset) {
++ child->priority != eCompositorPriority::Unset) {
+ WorkScheduler::schedule(child);
+ }
+ }
}
- atomic_add_and_fetch_u(&this->m_chunks_finished, 1);
if (memoryBuffers) {
for (unsigned int index = 0; index < this->m_max_read_buffer_offset; index++) {
MemoryBuffer *buffer = memoryBuffers[index];
@@@ -513,13 -504,69 +508,13 @@@ MemoryBuffer *ExecutionGroup::allocateO
return nullptr;
}
-bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
-{
- if (this->m_flags.single_threaded) {
- return scheduleChunkWhenPossible(graph, 0, 0);
- }
- // find all chunks inside the rect
- // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
-
- int indexx, indexy;
- int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0);
- int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin);
- int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0);
- int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin);
- int minxchunk = minx / (int)m_chunkSize;
- int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize;
- int minychunk = miny / (int)m_chunkSize;
- int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize;
- minxchunk = max_ii(minxchunk, 0);
- minychunk = max_ii(minychunk, 0);
- maxxchunk = min_ii(maxxchunk, (int)m_x_chunks_len);
- maxychunk = min_ii(maxychunk, (int)m_y_chunks_len);
-
- bool result = true;
- for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
- for (indexy = minychunk; indexy < maxychunk; indexy++) {
- if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
- result = false;
- }
- }
- }
-
- return result;
-}
-
-bool ExecutionGroup:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list