#include "gpu/command_buffer/service/scheduler_dfs.h"
#include <algorithm>
#include <cstddef>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/hash/md5_constexpr.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "gpu/command_buffer/common/scheduling_priority.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/config/gpu_preferences.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
namespace gpu {
namespace {
Task;
uint64_t GetTaskFlowId(uint32_t sequence_id, uint32_t order_num) { … }
}
SchedulerDfs::SchedulingState::SchedulingState() = default;
SchedulerDfs::SchedulingState::SchedulingState(const SchedulingState& other) =
default;
SchedulerDfs::SchedulingState::~SchedulingState() = default;
void SchedulerDfs::SchedulingState::WriteIntoTrace(
perfetto::TracedValue context) const { … }
bool SchedulerDfs::SchedulingState::operator==(
const SchedulerDfs::SchedulingState& rhs) const { … }
SchedulerDfs::PerThreadState::PerThreadState() = default;
SchedulerDfs::PerThreadState::PerThreadState(PerThreadState&& other) = default;
SchedulerDfs::PerThreadState::~PerThreadState() = default;
SchedulerDfs::PerThreadState& SchedulerDfs::PerThreadState::operator=(
PerThreadState&& other) = default;
SchedulerDfs::Sequence::Sequence(
SchedulerDfs* scheduler,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
SchedulingPriority priority)
: … { … }
SchedulerDfs::Sequence::~Sequence() { … }
bool SchedulerDfs::Sequence::ShouldYieldTo(const Sequence* other) const { … }
void SchedulerDfs::Sequence::SetEnabled(bool enabled) { … }
SchedulerDfs::SchedulingState SchedulerDfs::Sequence::SetScheduled() { … }
void SchedulerDfs::Sequence::UpdateRunningPriority() { … }
void SchedulerDfs::Sequence::ContinueTask(base::OnceClosure task_closure) { … }
uint32_t SchedulerDfs::Sequence::AddTask(
base::OnceClosure task_closure,
std::vector<SyncToken> wait_fences,
const SyncToken& release,
TaskGraph::ReportingCallback report_callback) { … }
uint32_t SchedulerDfs::Sequence::BeginTask(base::OnceClosure* task_closure) { … }
void SchedulerDfs::Sequence::FinishTask() { … }
void SchedulerDfs::Sequence::OnFrontTaskUnblocked() { … }
SchedulerDfs::SchedulerDfs(TaskGraph* task_graph) : … { … }
SchedulerDfs::~SchedulerDfs() { … }
SequenceId SchedulerDfs::CreateSequence(
SchedulingPriority priority,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
SequenceId SchedulerDfs::CreateSequenceForTesting(SchedulingPriority priority) { … }
void SchedulerDfs::DestroySequence(SequenceId sequence_id) { … }
void SchedulerDfs::CreateSyncPointClientState(
SequenceId sequence_id,
CommandBufferNamespace namespace_id,
CommandBufferId command_buffer_id) { … }
SchedulerDfs::Sequence* SchedulerDfs::GetSequence(SequenceId sequence_id) { … }
void SchedulerDfs::EnableSequence(SequenceId sequence_id) { … }
void SchedulerDfs::DisableSequence(SequenceId sequence_id) { … }
SchedulingPriority SchedulerDfs::GetSequenceDefaultPriority(
SequenceId sequence_id) { … }
void SchedulerDfs::SetSequencePriority(SequenceId sequence_id,
SchedulingPriority priority) { … }
void SchedulerDfs::ScheduleTask(Task task) { … }
void SchedulerDfs::ScheduleTasks(std::vector<Task> tasks) { … }
void SchedulerDfs::ScheduleTaskHelper(Task task) { … }
void SchedulerDfs::ContinueTask(SequenceId sequence_id,
TaskCallback task_callback) { … }
void SchedulerDfs::ContinueTask(SequenceId sequence_id,
base::OnceClosure task_closure) { … }
bool SchedulerDfs::ShouldYield(SequenceId sequence_id) { … }
base::SingleThreadTaskRunner* SchedulerDfs::GetTaskRunnerForTesting(
SequenceId sequence_id) { … }
void SchedulerDfs::TryScheduleSequence(Sequence* sequence) { … }
const std::vector<SchedulerDfs::SchedulingState>&
SchedulerDfs::GetSortedRunnableSequences(
base::SingleThreadTaskRunner* task_runner) { … }
bool SchedulerDfs::HasAnyUnblockedTasksOnRunner(
const base::SingleThreadTaskRunner* task_runner) const { … }
SchedulerDfs::Sequence* SchedulerDfs::FindNextTaskFromRoot(
Sequence* root_sequence) { … }
SchedulerDfs::Sequence* SchedulerDfs::FindNextTask() { … }
void SchedulerDfs::RunNextTask() { … }
void SchedulerDfs::ExecuteSequence(const SequenceId sequence_id) { … }
}