2025-12-26 09:55:52 +08:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2022-06-30 07:27:49 +08:00
|
|
|
// SPDX-FileCopyrightText: 2021 yuzu Emulator Project
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2021-11-05 22:52:31 +08:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2022-09-01 11:45:22 +08:00
|
|
|
#include "common/assert.h"
|
2021-11-05 22:52:31 +08:00
|
|
|
#include "video_core/control/channel_state.h"
|
|
|
|
|
#include "video_core/control/scheduler.h"
|
|
|
|
|
#include "video_core/gpu.h"
|
|
|
|
|
|
|
|
|
|
namespace Tegra::Control {
|
|
|
|
|
|
2026-05-01 08:04:30 +08:00
|
|
|
void Scheduler::Push(GPU& gpu, s32 channel, CommandList&& entries) {
|
2026-01-18 10:45:18 +08:00
|
|
|
std::shared_ptr<ChannelState> channel_state;
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock lk(scheduling_guard);
|
|
|
|
|
auto it = channels.find(channel);
|
|
|
|
|
ASSERT(it != channels.end());
|
|
|
|
|
channel_state = it->second;
|
|
|
|
|
gpu.BindChannel(channel_state->bind_id);
|
|
|
|
|
}
|
|
|
|
|
// Process commands outside the lock to reduce contention.
|
|
|
|
|
// Multiple channels can prepare their commands in parallel.
|
2026-05-01 08:04:30 +08:00
|
|
|
channel_state->payload->dma_pusher.Push(std::move(entries));
|
|
|
|
|
channel_state->payload->dma_pusher.DispatchCalls();
|
2021-11-05 22:52:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Scheduler::DeclareChannel(std::shared_ptr<ChannelState> new_channel) {
|
|
|
|
|
s32 channel = new_channel->bind_id;
|
2022-09-01 11:45:22 +08:00
|
|
|
std::unique_lock lk(scheduling_guard);
|
2021-11-05 22:52:31 +08:00
|
|
|
channels.emplace(channel, new_channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Tegra::Control
|