summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2022-09-01 05:45:22 +0200
committerGravatar Fernando Sahmkow2022-10-06 21:00:54 +0200
commitca3db0d7c94a20668781830ff852dbf512598efb (patch)
treeedd20d669000e980169db27a896adc09078ceeaa /src/video_core
parentstate_tracker: workaround channel setup for homebrew (diff)
downloadyuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.gz
yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.xz
yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.zip
General: address feedback
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/control/channel_state.cpp7
-rw-r--r--src/video_core/control/channel_state.h4
-rw-r--r--src/video_core/control/channel_state_cache.h2
-rw-r--r--src/video_core/control/scheduler.cpp6
-rw-r--r--src/video_core/control/scheduler.h2
-rw-r--r--src/video_core/engines/maxwell_dma.h2
-rw-r--r--src/video_core/gpu.cpp2
-rw-r--r--src/video_core/host1x/host1x.h2
-rw-r--r--src/video_core/host1x/syncpoint_manager.cpp12
-rw-r--r--src/video_core/host1x/syncpoint_manager.h24
-rw-r--r--src/video_core/memory_manager.h2
11 files changed, 32 insertions, 33 deletions
diff --git a/src/video_core/control/channel_state.cpp b/src/video_core/control/channel_state.cpp
index b04922ac0..cdecc3a91 100644
--- a/src/video_core/control/channel_state.cpp
+++ b/src/video_core/control/channel_state.cpp
@@ -14,10 +14,7 @@
14 14
15namespace Tegra::Control { 15namespace Tegra::Control {
16 16
17ChannelState::ChannelState(s32 bind_id_) { 17ChannelState::ChannelState(s32 bind_id_) : bind_id{bind_id_}, initialized{} {}
18 bind_id = bind_id_;
19 initiated = false;
20}
21 18
22void ChannelState::Init(Core::System& system, GPU& gpu) { 19void ChannelState::Init(Core::System& system, GPU& gpu) {
23 ASSERT(memory_manager); 20 ASSERT(memory_manager);
@@ -27,7 +24,7 @@ void ChannelState::Init(Core::System& system, GPU& gpu) {
27 kepler_compute = std::make_unique<Engines::KeplerCompute>(system, *memory_manager); 24 kepler_compute = std::make_unique<Engines::KeplerCompute>(system, *memory_manager);
28 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(system, *memory_manager); 25 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(system, *memory_manager);
29 kepler_memory = std::make_unique<Engines::KeplerMemory>(system, *memory_manager); 26 kepler_memory = std::make_unique<Engines::KeplerMemory>(system, *memory_manager);
30 initiated = true; 27 initialized = true;
31} 28}
32 29
33void ChannelState::BindRasterizer(VideoCore::RasterizerInterface* rasterizer) { 30void ChannelState::BindRasterizer(VideoCore::RasterizerInterface* rasterizer) {
diff --git a/src/video_core/control/channel_state.h b/src/video_core/control/channel_state.h
index 305b21cba..3a7b9872c 100644
--- a/src/video_core/control/channel_state.h
+++ b/src/video_core/control/channel_state.h
@@ -34,7 +34,7 @@ class DmaPusher;
34namespace Control { 34namespace Control {
35 35
36struct ChannelState { 36struct ChannelState {
37 ChannelState(s32 bind_id); 37 explicit ChannelState(s32 bind_id);
38 ChannelState(const ChannelState& state) = delete; 38 ChannelState(const ChannelState& state) = delete;
39 ChannelState& operator=(const ChannelState&) = delete; 39 ChannelState& operator=(const ChannelState&) = delete;
40 ChannelState(ChannelState&& other) noexcept = default; 40 ChannelState(ChannelState&& other) noexcept = default;
@@ -60,7 +60,7 @@ struct ChannelState {
60 60
61 std::unique_ptr<DmaPusher> dma_pusher; 61 std::unique_ptr<DmaPusher> dma_pusher;
62 62
63 bool initiated{}; 63 bool initialized{};
64}; 64};
65 65
66} // namespace Control 66} // namespace Control
diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h
index 5246192a8..584a0c26c 100644
--- a/src/video_core/control/channel_state_cache.h
+++ b/src/video_core/control/channel_state_cache.h
@@ -32,7 +32,7 @@ namespace VideoCommon {
32class ChannelInfo { 32class ChannelInfo {
33public: 33public:
34 ChannelInfo() = delete; 34 ChannelInfo() = delete;
35 ChannelInfo(Tegra::Control::ChannelState& state); 35 explicit ChannelInfo(Tegra::Control::ChannelState& state);
36 ChannelInfo(const ChannelInfo& state) = delete; 36 ChannelInfo(const ChannelInfo& state) = delete;
37 ChannelInfo& operator=(const ChannelInfo&) = delete; 37 ChannelInfo& operator=(const ChannelInfo&) = delete;
38 ChannelInfo(ChannelInfo&& other) = default; 38 ChannelInfo(ChannelInfo&& other) = default;
diff --git a/src/video_core/control/scheduler.cpp b/src/video_core/control/scheduler.cpp
index 733042690..f7cbe204e 100644
--- a/src/video_core/control/scheduler.cpp
+++ b/src/video_core/control/scheduler.cpp
@@ -3,6 +3,7 @@
3 3
4#include <memory> 4#include <memory>
5 5
6#include "common/assert.h"
6#include "video_core/control/channel_state.h" 7#include "video_core/control/channel_state.h"
7#include "video_core/control/scheduler.h" 8#include "video_core/control/scheduler.h"
8#include "video_core/gpu.h" 9#include "video_core/gpu.h"
@@ -13,8 +14,9 @@ Scheduler::Scheduler(GPU& gpu_) : gpu{gpu_} {}
13Scheduler::~Scheduler() = default; 14Scheduler::~Scheduler() = default;
14 15
15void Scheduler::Push(s32 channel, CommandList&& entries) { 16void Scheduler::Push(s32 channel, CommandList&& entries) {
16 std::unique_lock<std::mutex> lk(scheduling_guard); 17 std::unique_lock lk(scheduling_guard);
17 auto it = channels.find(channel); 18 auto it = channels.find(channel);
19 ASSERT(it != channels.end());
18 auto channel_state = it->second; 20 auto channel_state = it->second;
19 gpu.BindChannel(channel_state->bind_id); 21 gpu.BindChannel(channel_state->bind_id);
20 channel_state->dma_pusher->Push(std::move(entries)); 22 channel_state->dma_pusher->Push(std::move(entries));
@@ -23,7 +25,7 @@ void Scheduler::Push(s32 channel, CommandList&& entries) {
23 25
24void Scheduler::DeclareChannel(std::shared_ptr<ChannelState> new_channel) { 26void Scheduler::DeclareChannel(std::shared_ptr<ChannelState> new_channel) {
25 s32 channel = new_channel->bind_id; 27 s32 channel = new_channel->bind_id;
26 std::unique_lock<std::mutex> lk(scheduling_guard); 28 std::unique_lock lk(scheduling_guard);
27 channels.emplace(channel, new_channel); 29 channels.emplace(channel, new_channel);
28} 30}
29 31
diff --git a/src/video_core/control/scheduler.h b/src/video_core/control/scheduler.h
index 305a01e0a..44addf61c 100644
--- a/src/video_core/control/scheduler.h
+++ b/src/video_core/control/scheduler.h
@@ -19,7 +19,7 @@ struct ChannelState;
19 19
20class Scheduler { 20class Scheduler {
21public: 21public:
22 Scheduler(GPU& gpu_); 22 explicit Scheduler(GPU& gpu_);
23 ~Scheduler(); 23 ~Scheduler();
24 24
25 void Push(s32 channel, CommandList&& entries); 25 void Push(s32 channel, CommandList&& entries);
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h
index 9c5d567a6..bc48320ce 100644
--- a/src/video_core/engines/maxwell_dma.h
+++ b/src/video_core/engines/maxwell_dma.h
@@ -195,7 +195,7 @@ public:
195 BitField<24, 2, u32> num_dst_components_minus_one; 195 BitField<24, 2, u32> num_dst_components_minus_one;
196 }; 196 };
197 197
198 Swizzle GetComponent(size_t i) { 198 Swizzle GetComponent(size_t i) const {
199 const u32 raw = dst_components_raw; 199 const u32 raw = dst_components_raw;
200 return static_cast<Swizzle>((raw >> (i * 3)) & 0x7); 200 return static_cast<Swizzle>((raw >> (i * 3)) & 0x7);
201 } 201 }
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index d7a3dd96b..28b38273e 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -355,7 +355,7 @@ struct GPU::Impl {
355 355
356 std::condition_variable sync_cv; 356 std::condition_variable sync_cv;
357 357
358 std::list<std::function<void(void)>> sync_requests; 358 std::list<std::function<void()>> sync_requests;
359 std::atomic<u64> current_sync_fence{}; 359 std::atomic<u64> current_sync_fence{};
360 u64 last_sync_fence{}; 360 u64 last_sync_fence{};
361 std::mutex sync_request_mutex; 361 std::mutex sync_request_mutex;
diff --git a/src/video_core/host1x/host1x.h b/src/video_core/host1x/host1x.h
index 7ecf853d9..57082ae54 100644
--- a/src/video_core/host1x/host1x.h
+++ b/src/video_core/host1x/host1x.h
@@ -19,7 +19,7 @@ namespace Host1x {
19 19
20class Host1x { 20class Host1x {
21public: 21public:
22 Host1x(Core::System& system); 22 explicit Host1x(Core::System& system);
23 23
24 SyncpointManager& GetSyncpointManager() { 24 SyncpointManager& GetSyncpointManager() {
25 return syncpoint_manager; 25 return syncpoint_manager;
diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp
index 4471bacae..326e8355a 100644
--- a/src/video_core/host1x/syncpoint_manager.cpp
+++ b/src/video_core/host1x/syncpoint_manager.cpp
@@ -12,13 +12,13 @@ MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192));
12 12
13SyncpointManager::ActionHandle SyncpointManager::RegisterAction( 13SyncpointManager::ActionHandle SyncpointManager::RegisterAction(
14 std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, 14 std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value,
15 std::function<void(void)>& action) { 15 std::function<void()>&& action) {
16 if (syncpoint.load(std::memory_order_acquire) >= expected_value) { 16 if (syncpoint.load(std::memory_order_acquire) >= expected_value) {
17 action(); 17 action();
18 return {}; 18 return {};
19 } 19 }
20 20
21 std::unique_lock<std::mutex> lk(guard); 21 std::unique_lock lk(guard);
22 if (syncpoint.load(std::memory_order_relaxed) >= expected_value) { 22 if (syncpoint.load(std::memory_order_relaxed) >= expected_value) {
23 action(); 23 action();
24 return {}; 24 return {};
@@ -30,12 +30,12 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction(
30 } 30 }
31 ++it; 31 ++it;
32 } 32 }
33 return action_storage.emplace(it, expected_value, action); 33 return action_storage.emplace(it, expected_value, std::move(action));
34} 34}
35 35
36void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, 36void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage,
37 ActionHandle& handle) { 37 ActionHandle& handle) {
38 std::unique_lock<std::mutex> lk(guard); 38 std::unique_lock lk(guard);
39 action_storage.erase(handle); 39 action_storage.erase(handle);
40} 40}
41 41
@@ -68,7 +68,7 @@ void SyncpointManager::Increment(std::atomic<u32>& syncpoint, std::condition_var
68 std::list<RegisteredAction>& action_storage) { 68 std::list<RegisteredAction>& action_storage) {
69 auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1}; 69 auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1};
70 70
71 std::unique_lock<std::mutex> lk(guard); 71 std::unique_lock lk(guard);
72 auto it = action_storage.begin(); 72 auto it = action_storage.begin();
73 while (it != action_storage.end()) { 73 while (it != action_storage.end()) {
74 if (it->expected_value > new_value) { 74 if (it->expected_value > new_value) {
@@ -87,7 +87,7 @@ void SyncpointManager::Wait(std::atomic<u32>& syncpoint, std::condition_variable
87 return; 87 return;
88 } 88 }
89 89
90 std::unique_lock<std::mutex> lk(guard); 90 std::unique_lock lk(guard);
91 wait_cv.wait(lk, pred); 91 wait_cv.wait(lk, pred);
92} 92}
93 93
diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h
index 72220a09a..50a264e23 100644
--- a/src/video_core/host1x/syncpoint_manager.h
+++ b/src/video_core/host1x/syncpoint_manager.h
@@ -18,34 +18,34 @@ namespace Host1x {
18 18
19class SyncpointManager { 19class SyncpointManager {
20public: 20public:
21 u32 GetGuestSyncpointValue(u32 id) { 21 u32 GetGuestSyncpointValue(u32 id) const {
22 return syncpoints_guest[id].load(std::memory_order_acquire); 22 return syncpoints_guest[id].load(std::memory_order_acquire);
23 } 23 }
24 24
25 u32 GetHostSyncpointValue(u32 id) { 25 u32 GetHostSyncpointValue(u32 id) const {
26 return syncpoints_host[id].load(std::memory_order_acquire); 26 return syncpoints_host[id].load(std::memory_order_acquire);
27 } 27 }
28 28
29 struct RegisteredAction { 29 struct RegisteredAction {
30 RegisteredAction(u32 expected_value_, std::function<void(void)>& action_) 30 explicit RegisteredAction(u32 expected_value_, std::function<void()>&& action_)
31 : expected_value{expected_value_}, action{action_} {} 31 : expected_value{expected_value_}, action{std::move(action_)} {}
32 u32 expected_value; 32 u32 expected_value;
33 std::function<void(void)> action; 33 std::function<void()> action;
34 }; 34 };
35 using ActionHandle = std::list<RegisteredAction>::iterator; 35 using ActionHandle = std::list<RegisteredAction>::iterator;
36 36
37 template <typename Func> 37 template <typename Func>
38 ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { 38 ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) {
39 std::function<void(void)> func(action); 39 std::function<void()> func(action);
40 return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], 40 return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id],
41 expected_value, func); 41 expected_value, std::move(func));
42 } 42 }
43 43
44 template <typename Func> 44 template <typename Func>
45 ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { 45 ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) {
46 std::function<void(void)> func(action); 46 std::function<void()> func(action);
47 return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], 47 return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id],
48 expected_value, func); 48 expected_value, std::move(func));
49 } 49 }
50 50
51 void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); 51 void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle);
@@ -60,11 +60,11 @@ public:
60 60
61 void WaitHost(u32 syncpoint_id, u32 expected_value); 61 void WaitHost(u32 syncpoint_id, u32 expected_value);
62 62
63 bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) { 63 bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) const {
64 return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value; 64 return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value;
65 } 65 }
66 66
67 bool IsReadyHost(u32 syncpoint_id, u32 expected_value) { 67 bool IsReadyHost(u32 syncpoint_id, u32 expected_value) const {
68 return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value; 68 return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value;
69 } 69 }
70 70
@@ -74,7 +74,7 @@ private:
74 74
75 ActionHandle RegisterAction(std::atomic<u32>& syncpoint, 75 ActionHandle RegisterAction(std::atomic<u32>& syncpoint,
76 std::list<RegisteredAction>& action_storage, u32 expected_value, 76 std::list<RegisteredAction>& action_storage, u32 expected_value,
77 std::function<void(void)>& action); 77 std::function<void()>&& action);
78 78
79 void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); 79 void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle);
80 80
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index ae4fd98df..f992e29f3 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -126,7 +126,7 @@ private:
126 void WriteBlockImpl(GPUVAddr gpu_dest_addr, const void* src_buffer, std::size_t size); 126 void WriteBlockImpl(GPUVAddr gpu_dest_addr, const void* src_buffer, std::size_t size);
127 127
128 template <bool is_big_page> 128 template <bool is_big_page>
129 [[nodiscard]] inline std::size_t PageEntryIndex(GPUVAddr gpu_addr) const { 129 [[nodiscard]] std::size_t PageEntryIndex(GPUVAddr gpu_addr) const {
130 if constexpr (is_big_page) { 130 if constexpr (is_big_page) {
131 return (gpu_addr >> big_page_bits) & big_page_table_mask; 131 return (gpu_addr >> big_page_bits) & big_page_table_mask;
132 } else { 132 } else {