[Bf-blender-cvs] [98c527ad75f] temp-compositor-single-threaded-operation: Merge branch 'master' into temp-compositor-single-threaded-operation

Jeroen Bakker noreply at git.blender.org
Fri Apr 2 16:28:41 CEST 2021


Commit: 98c527ad75f88bece9404c664d813ca91bdbfda6
Author: Jeroen Bakker
Date:   Fri Apr 2 16:28:36 2021 +0200
Branches: temp-compositor-single-threaded-operation
https://developer.blender.org/rB98c527ad75f88bece9404c664d813ca91bdbfda6

Merge branch 'master' into temp-compositor-single-threaded-operation

===================================================================



===================================================================

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.cc
index cee43233716,d218de92544..711b3278c6f
--- a/source/blender/compositor/intern/COM_Enums.cc
+++ b/source/blender/compositor/intern/COM_Enums.cc
@@@ -35,10 -35,6 +35,10 @@@ std::ostream &operator<<(std::ostream &
        os << "Priority::Low";
        break;
      }
-     case CompositorPriority::Unset: {
++    case eCompositorPriority::Unset: {
 +      os << "Priority::Unset";
 +      break;
 +    }
    }
    return os;
  }
diff --cc source/blender/compositor/intern/COM_ExecutionGroup.cc
index f8ba56e863b,80d453bf7f9..ccd78ba6cd1
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cc
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc
@@@ -157,8 -157,7 +157,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);
@@@ -361,10 -359,12 +361,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++;
@@@ -427,15 -427,11 +427,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];
@@@ -509,13 -504,69 +509,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::scheduleChunk(unsigned int chunkNumber)
 -{
 -  WorkPackage &work_package = m_work_packages[chunkNumber];
 -  if (work_package.state == eWorkPackageState::NotScheduled) {
 -    work_package.state = eWorkPackageState::Scheduled;
 -    WorkScheduler::schedule(&work_package);
 -    return true;
 -  }
 -  return false;
 -}
 -
 -bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
 -                                               const int chunk_x,
 -                                               const int chunk_y)
 +bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, WorkPackage &work_package)
  {
 -  if (chunk_x < 0 || chunk_x >= (int)this->m_x_chunks_len) {
 -    return true;
 -  }
 -  if (chunk_y < 0 || chunk_y >= (int)this->m_y_chunks_len) {
 -    return true;
 -  }
 -
    // Check if chunk is already executed or scheduled and not yet executed.
-   if (work_package.state == eChunkExecutionState::Executed) {
 -  const int chunk_index = chunk_y * this->m_x_chunks_len + chunk_x;
 -  WorkPackage &work_package = m_work_packages[chunk_index];
+   if (work_package.state == eWorkPackageState::Executed) {
      return true;
    }
-   if (work_package.state == eChunkExecutionState::Scheduled) {
+   if (work_package.state == eWorkPackageState::Scheduled) {
      return false;
    }
  
diff --cc source/blender/compositor/intern/COM_ExecutionSystem.cc
index cb2c05c5217,e22dc17837b..563b4cf4a38
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cc
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc
@@@ -179,62 -179,6 +179,63 @@@ static void init_execution_groups_for_e
    }
  }
  
 +/**
 + * Link all work packages with the work packages they depend on.
 + */
 +static void link_work_packages(blender::Vector<ExecutionGroup *> &groups)
 +{
 +  for (ExecutionGroup *group : groups) {
 +    for (WorkPackage &work_package : group->get_work_packages()) {
 +      for (ReadBufferOperation *read_operation : group->get_read_buffer_operations()) {
 +        rcti area = {0};
 +        group->getOutputOperation()->determineDependingAreaOfInterest(
 +            &work_package.rect, read_operation, &area);
 +        ExecutionGroup *parent = read_operation->getMemoryProxy()->getExecutor();
 +        parent->link_child_work_packages(&work_package, &area);
 +      }
 +    }
 +  }
 +}
 +
 +static void schedule_root_work_packages(blender::Vector<ExecutionGroup *> &groups)
 +{
 +  for (ExecutionGroup *group : groups) {
 +    for (WorkPackage &work_package : group->get_work_packages()) {
-       if (work_package.state != eChunkExecutionState::NotScheduled) {
++      if (work_package.state != eWorkPackageState::NotScheduled) {
 +        continue;
 +      }
-       if (work_package.priority == CompositorPriority::Unset) {
++      if (work_package.priority == eCompositorPriority::Unset) {
 +        continue;
 +      }
 +      if (work_package.num_parents == 0) {
 +        WorkScheduler::schedule(&work_package);
 +      }
 +    }
 +  }
 +}
 +
- static void mark_priority(WorkPackage &work_package, CompositorPriority priority)
++static void mark_priority(WorkPackage &work_package, eCompositorPriority priority)
 +{
-   if (work_package.state != eChunkExecutionState::NotScheduled) {
++  if (work_package.state != eWorkPackageState::NotScheduled) {
 +    return;
 +  }
-   if (work_package.priority != CompositorPriority::Unset) {
++  if (work_package.priority != eCompositorPriority::Unset) {
 +    return;
 +  }
 +  work_package.priority = priority;
 +  for (WorkPackage *parent : work_package.parents) {
 +    mark_priority(*parent, priority);
 +  }
 +}
 +
- static void mark_priority(blender::Vector<WorkPackage> &work_packages, CompositorPriority priority)
++static void mark_priority(blender::Vector<WorkPackage> &work_packages,
++                          eCompositorPriority priority)
 +{
 +  for (WorkPackage &work_package : work_packages) {
 +    mark_priority(work_package, priority);
 +  }
 +}
 +
  void ExecutionSystem::execute()
  {
    const bNodeTree *editingtree = this->m_context.getbNodeTree();
@@@ -247,14 -191,12 +248,14 @@@
    link_write_buffers(m_operations);
    init_non_write_operations_for_execution(m_operations, m_context.getbNodeTree());
    init_execution_groups_for_execution(m_groups, m_context.getChunksize());
 +  link_work_packages(m_groups);
  
    WorkScheduler::start(this->m_context);
 +  editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | Started"));
-   execute_groups(CompositorPriority::High);
+   execute_groups(eCompositorPriority::High);
    if (!this->getContext().isFastCalculation()) {
-     execute_groups(CompositorPriority::Medium);
-     execute_groups(CompositorPriority::Low);
+     execute_groups(eCompositorPriority::Medium);
+     execute_groups(eCompositorPriority::Low);
    }
    WorkScheduler::finish();
    WorkScheduler::stop();
@@@ -270,52 -212,12 +271,52 @@@
    }
  }
  
 +static bool is_completed(Vector<ExecutionGroup *> &groups)
 +{
 +

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list