44 changed files with 648 additions and 252 deletions
-
12src/core/core.cpp
-
9src/core/core.h
-
2src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
-
19src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
-
4src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
-
10src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
-
9src/core/hle/service/nvflinger/nvflinger.cpp
-
40src/video_core/CMakeLists.txt
-
25src/video_core/cdma_pusher.cpp
-
15src/video_core/cdma_pusher.h
-
2src/video_core/control/channel_state.cpp
-
2src/video_core/control/channel_state.h
-
4src/video_core/control/channel_state_cache.h
-
2src/video_core/control/scheduler.cpp
-
2src/video_core/control/scheduler.h
-
26src/video_core/dma_pusher.h
-
63src/video_core/engines/puller.cpp
-
1src/video_core/engines/puller.h
-
12src/video_core/fence_manager.h
-
197src/video_core/gpu.cpp
-
19src/video_core/gpu.h
-
6src/video_core/gpu_thread.cpp
-
2src/video_core/gpu_thread.h
-
36src/video_core/host1x/codecs/codec.cpp
-
14src/video_core/host1x/codecs/codec.h
-
4src/video_core/host1x/codecs/h264.cpp
-
6src/video_core/host1x/codecs/h264.h
-
4src/video_core/host1x/codecs/vp8.cpp
-
5src/video_core/host1x/codecs/vp8.h
-
8src/video_core/host1x/codecs/vp9.cpp
-
12src/video_core/host1x/codecs/vp9.h
-
0src/video_core/host1x/codecs/vp9_types.h
-
35src/video_core/host1x/control.cpp
-
17src/video_core/host1x/control.h
-
33src/video_core/host1x/host1x.h
-
6src/video_core/host1x/nvdec.cpp
-
7src/video_core/host1x/nvdec.h
-
4src/video_core/host1x/nvdec_common.h
-
10src/video_core/host1x/sync_manager.cpp
-
6src/video_core/host1x/sync_manager.h
-
93src/video_core/host1x/syncpoint_manager.cpp
-
99src/video_core/host1x/syncpoint_manager.h
-
9src/video_core/host1x/vic.cpp
-
7src/video_core/host1x/vic.h
@ -0,0 +1,35 @@ |
|||||
|
// Copyright 2022 yuzu Emulator Project
|
||||
|
// Licensed under GPLv3 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include "common/assert.h"
|
||||
|
#include "video_core/gpu.h"
|
||||
|
#include "video_core/host1x/control.h"
|
||||
|
#include "video_core/host1x/host1x.h"
|
||||
|
|
||||
|
namespace Tegra::Host1x { |
||||
|
|
||||
|
Control::Control(GPU& gpu_) : gpu(gpu_) {} |
||||
|
|
||||
|
Control::~Control() = default; |
||||
|
|
||||
|
void Control::ProcessMethod(Method method, u32 argument) { |
||||
|
switch (method) { |
||||
|
case Method::LoadSyncptPayload32: |
||||
|
syncpoint_value = argument; |
||||
|
break; |
||||
|
case Method::WaitSyncpt: |
||||
|
case Method::WaitSyncpt32: |
||||
|
Execute(argument); |
||||
|
break; |
||||
|
default: |
||||
|
UNIMPLEMENTED_MSG("Control method 0x{:X}", static_cast<u32>(method)); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void Control::Execute(u32 data) { |
||||
|
gpu.Host1x().GetSyncpointManager().WaitHost(data, syncpoint_value); |
||||
|
} |
||||
|
|
||||
|
} // namespace Tegra::Host1x
|
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright 2022 yuzu Emulator Project |
||||
|
// Licensed under GPLv3 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include "common/common_types.h" |
||||
|
|
||||
|
#include "video_core/host1x/syncpoint_manager.h" |
||||
|
|
||||
|
namespace Tegra { |
||||
|
|
||||
|
namespace Host1x { |
||||
|
|
||||
|
class Host1x { |
||||
|
public: |
||||
|
Host1x() : syncpoint_manager{} {} |
||||
|
|
||||
|
SyncpointManager& GetSyncpointManager() { |
||||
|
return syncpoint_manager; |
||||
|
} |
||||
|
|
||||
|
const SyncpointManager& GetSyncpointManager() const { |
||||
|
return syncpoint_manager; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
SyncpointManager syncpoint_manager; |
||||
|
}; |
||||
|
|
||||
|
} // namespace Host1x |
||||
|
|
||||
|
} // namespace Tegra |
||||
@ -0,0 +1,93 @@ |
|||||
|
// Copyright 2021 yuzu Emulator Project
|
||||
|
// Licensed under GPLv3 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include "video_core/host1x/syncpoint_manager.h"
|
||||
|
|
||||
|
namespace Tegra { |
||||
|
|
||||
|
namespace Host1x { |
||||
|
|
||||
|
SyncpointManager::ActionHandle SyncpointManager::RegisterAction( |
||||
|
std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, |
||||
|
std::function<void(void)>& action) { |
||||
|
if (syncpoint.load(std::memory_order_acquire) >= expected_value) { |
||||
|
action(); |
||||
|
return {}; |
||||
|
} |
||||
|
|
||||
|
std::unique_lock<std::mutex> lk(guard); |
||||
|
if (syncpoint.load(std::memory_order_relaxed) >= expected_value) { |
||||
|
action(); |
||||
|
return {}; |
||||
|
} |
||||
|
auto it = action_storage.begin(); |
||||
|
while (it != action_storage.end()) { |
||||
|
if (it->expected_value >= expected_value) { |
||||
|
break; |
||||
|
} |
||||
|
++it; |
||||
|
} |
||||
|
return action_storage.emplace(it, expected_value, action); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, |
||||
|
ActionHandle& handle) { |
||||
|
std::unique_lock<std::mutex> lk(guard); |
||||
|
action_storage.erase(handle); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle) { |
||||
|
DeregisterAction(guest_action_storage[syncpoint_id], handle); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle) { |
||||
|
DeregisterAction(host_action_storage[syncpoint_id], handle); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::IncrementGuest(u32 syncpoint_id) { |
||||
|
Increment(syncpoints_guest[syncpoint_id], wait_guest_cv, guest_action_storage[syncpoint_id]); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::IncrementHost(u32 syncpoint_id) { |
||||
|
Increment(syncpoints_host[syncpoint_id], wait_host_cv, host_action_storage[syncpoint_id]); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::WaitGuest(u32 syncpoint_id, u32 expected_value) { |
||||
|
Wait(syncpoints_guest[syncpoint_id], wait_guest_cv, expected_value); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::WaitHost(u32 syncpoint_id, u32 expected_value) { |
||||
|
Wait(syncpoints_host[syncpoint_id], wait_host_cv, expected_value); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::Increment(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, |
||||
|
std::list<RegisteredAction>& action_storage) { |
||||
|
auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1}; |
||||
|
|
||||
|
std::unique_lock<std::mutex> lk(guard); |
||||
|
auto it = action_storage.begin(); |
||||
|
while (it != action_storage.end()) { |
||||
|
if (it->expected_value > new_value) { |
||||
|
break; |
||||
|
} |
||||
|
it->action(); |
||||
|
it = action_storage.erase(it); |
||||
|
} |
||||
|
wait_cv.notify_all(); |
||||
|
} |
||||
|
|
||||
|
void SyncpointManager::Wait(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, |
||||
|
u32 expected_value) { |
||||
|
const auto pred = [&]() { return syncpoint.load(std::memory_order_acquire) >= expected_value; }; |
||||
|
if (pred()) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
std::unique_lock<std::mutex> lk(guard); |
||||
|
wait_cv.wait(lk, pred); |
||||
|
} |
||||
|
|
||||
|
} // namespace Host1x
|
||||
|
|
||||
|
} // namespace Tegra
|
||||
@ -0,0 +1,99 @@ |
|||||
|
// Copyright 2021 yuzu Emulator Project |
||||
|
// Licensed under GPLv3 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <array> |
||||
|
#include <atomic> |
||||
|
#include <condition_variable> |
||||
|
#include <functional> |
||||
|
#include <list> |
||||
|
#include <mutex> |
||||
|
|
||||
|
#include "common/common_types.h" |
||||
|
|
||||
|
namespace Tegra { |
||||
|
|
||||
|
namespace Host1x { |
||||
|
|
||||
|
class SyncpointManager { |
||||
|
public: |
||||
|
u32 GetGuestSyncpointValue(u32 id) { |
||||
|
return syncpoints_guest[id].load(std::memory_order_acquire); |
||||
|
} |
||||
|
|
||||
|
u32 GetHostSyncpointValue(u32 id) { |
||||
|
return syncpoints_host[id].load(std::memory_order_acquire); |
||||
|
} |
||||
|
|
||||
|
struct RegisteredAction { |
||||
|
RegisteredAction(u32 expected_value_, std::function<void(void)>& action_) |
||||
|
: expected_value{expected_value_}, action{action_} {} |
||||
|
u32 expected_value; |
||||
|
std::function<void(void)> action; |
||||
|
}; |
||||
|
using ActionHandle = std::list<RegisteredAction>::iterator; |
||||
|
|
||||
|
template <typename Func> |
||||
|
ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { |
||||
|
std::function<void(void)> func(action); |
||||
|
return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], |
||||
|
expected_value, func); |
||||
|
} |
||||
|
|
||||
|
template <typename Func> |
||||
|
ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { |
||||
|
std::function<void(void)> func(action); |
||||
|
return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], |
||||
|
expected_value, func); |
||||
|
} |
||||
|
|
||||
|
void DeregisterGuestAction(u32 syncpoint_id,ActionHandle& handle); |
||||
|
|
||||
|
void DeregisterHostAction(u32 syncpoint_id,ActionHandle& handle); |
||||
|
|
||||
|
void IncrementGuest(u32 syncpoint_id); |
||||
|
|
||||
|
void IncrementHost(u32 syncpoint_id); |
||||
|
|
||||
|
void WaitGuest(u32 syncpoint_id, u32 expected_value); |
||||
|
|
||||
|
void WaitHost(u32 syncpoint_id, u32 expected_value); |
||||
|
|
||||
|
bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) { |
||||
|
return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value; |
||||
|
} |
||||
|
|
||||
|
bool IsReadyHost(u32 syncpoint_id, u32 expected_value) { |
||||
|
return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
void Increment(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, |
||||
|
std::list<RegisteredAction>& action_storage); |
||||
|
|
||||
|
ActionHandle RegisterAction(std::atomic<u32>& syncpoint, |
||||
|
std::list<RegisteredAction>& action_storage, u32 expected_value, |
||||
|
std::function<void(void)>& action); |
||||
|
|
||||
|
void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); |
||||
|
|
||||
|
void Wait(std::atomic<u32>& syncpoint, std::condition_variable& wait_cv, u32 expected_value); |
||||
|
|
||||
|
static constexpr size_t NUM_MAX_SYNCPOINTS = 192; |
||||
|
|
||||
|
std::array<std::atomic<u32>, NUM_MAX_SYNCPOINTS> syncpoints_guest{}; |
||||
|
std::array<std::atomic<u32>, NUM_MAX_SYNCPOINTS> syncpoints_host{}; |
||||
|
|
||||
|
std::array<std::list<RegisteredAction>, NUM_MAX_SYNCPOINTS> guest_action_storage; |
||||
|
std::array<std::list<RegisteredAction>, NUM_MAX_SYNCPOINTS> host_action_storage; |
||||
|
|
||||
|
std::mutex guard; |
||||
|
std::condition_variable wait_guest_cv; |
||||
|
std::condition_variable wait_host_cv; |
||||
|
}; |
||||
|
|
||||
|
} // namespace Host1x |
||||
|
|
||||
|
} // namespace Tegra |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue