2024-03-05 21:49:07 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 suyu Emulator Project
|
2022-06-30 01:27:49 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2021-11-05 15:52:31 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2022-09-01 05:45:22 +02:00
|
|
|
#include "common/assert.h"
|
2021-11-05 15:52:31 +01:00
|
|
|
#include "video_core/control/channel_state.h"
|
|
|
|
#include "video_core/control/scheduler.h"
|
|
|
|
#include "video_core/gpu.h"
|
|
|
|
|
|
|
|
namespace Tegra::Control {
|
|
|
|
Scheduler::Scheduler(GPU& gpu_) : gpu{gpu_} {}
|
|
|
|
|
|
|
|
Scheduler::~Scheduler() = default;
|
|
|
|
|
|
|
|
void Scheduler::Push(s32 channel, CommandList&& entries) {
|
2022-09-01 05:45:22 +02:00
|
|
|
std::unique_lock lk(scheduling_guard);
|
2021-11-05 15:52:31 +01:00
|
|
|
auto it = channels.find(channel);
|
2022-09-01 05:45:22 +02:00
|
|
|
ASSERT(it != channels.end());
|
2021-11-05 15:52:31 +01:00
|
|
|
auto channel_state = it->second;
|
|
|
|
gpu.BindChannel(channel_state->bind_id);
|
|
|
|
channel_state->dma_pusher->Push(std::move(entries));
|
|
|
|
channel_state->dma_pusher->DispatchCalls();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scheduler::DeclareChannel(std::shared_ptr<ChannelState> new_channel) {
|
|
|
|
s32 channel = new_channel->bind_id;
|
2022-09-01 05:45:22 +02:00
|
|
|
std::unique_lock lk(scheduling_guard);
|
2021-11-05 15:52:31 +01:00
|
|
|
channels.emplace(channel, new_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Tegra::Control
|