// SPDX-FileCopyrightText: 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include #include #include #include "common/fiber.h" #include "video_core/dma_pusher.h" namespace Tegra { class GPU; namespace Control { struct ChannelState; class Scheduler { public: explicit Scheduler(GPU& gpu_); ~Scheduler(); void Init(); void Resume(); void Yield(); void Push(s32 channel, CommandList&& entries); void DeclareChannel(std::shared_ptr new_channel); private: void ChannelLoop(size_t gpfifo_id, s32 channel_id); std::unordered_map> channels; std::unordered_map channel_gpfifo_ids; std::mutex scheduling_guard; std::shared_ptr master_control; struct GPFifoContext { bool is_active; std::shared_ptr context; std::deque pending_work; std::atomic working{}; std::mutex guard; s32 bind_id; }; std::deque gpfifos; std::deque free_fifos; GPU& gpu; size_t current_fifo_rotation_id{}; GPFifoContext* current_fifo{}; }; } // namespace Control } // namespace Tegra