summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2023-12-31 20:55:15 +0100
committerGravatar Liam2024-01-18 21:12:30 -0500
commit590d9b7e1d875e0403fb87cfcd4a8d52c50e2b81 (patch)
treeb9eb43c5a4af892d5fda77fac241099c166c2380 /src/core/hle
parentSMMU: Fix software rendering and cleanup (diff)
downloadyuzu-590d9b7e1d875e0403fb87cfcd4a8d52c50e2b81.tar.gz
yuzu-590d9b7e1d875e0403fb87cfcd4a8d52c50e2b81.tar.xz
yuzu-590d9b7e1d875e0403fb87cfcd4a8d52c50e2b81.zip
Core: Clang format and other small issues.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/hle_ipc.cpp2
-rw-r--r--src/core/hle/service/nvdrv/core/container.cpp8
-rw-r--r--src/core/hle/service/nvdrv/core/container.h8
-rw-r--r--src/core/hle/service/nvdrv/core/heap_mapper.cpp25
-rw-r--r--src/core/hle/service/nvdrv/core/nvmap.cpp8
-rw-r--r--src/core/hle/service/nvdrv/core/nvmap.h11
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp4
-rw-r--r--src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp10
-rw-r--r--src/core/hle/service/nvnflinger/fb_share_buffer_manager.h3
11 files changed, 52 insertions, 31 deletions
diff --git a/src/core/hle/service/hle_ipc.cpp b/src/core/hle/service/hle_ipc.cpp
index 9f6274c7d..e491dd260 100644
--- a/src/core/hle/service/hle_ipc.cpp
+++ b/src/core/hle/service/hle_ipc.cpp
@@ -12,6 +12,7 @@
12#include "common/common_types.h" 12#include "common/common_types.h"
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/scratch_buffer.h" 14#include "common/scratch_buffer.h"
15#include "core/guest_memory.h"
15#include "core/hle/kernel/k_auto_object.h" 16#include "core/hle/kernel/k_auto_object.h"
16#include "core/hle/kernel/k_handle_table.h" 17#include "core/hle/kernel/k_handle_table.h"
17#include "core/hle/kernel/k_process.h" 18#include "core/hle/kernel/k_process.h"
@@ -22,7 +23,6 @@
22#include "core/hle/service/hle_ipc.h" 23#include "core/hle/service/hle_ipc.h"
23#include "core/hle/service/ipc_helpers.h" 24#include "core/hle/service/ipc_helpers.h"
24#include "core/memory.h" 25#include "core/memory.h"
25#include "core/guest_memory.h"
26 26
27namespace Service { 27namespace Service {
28 28
diff --git a/src/core/hle/service/nvdrv/core/container.cpp b/src/core/hle/service/nvdrv/core/container.cpp
index 4d3a9d696..d04b7f5ff 100644
--- a/src/core/hle/service/nvdrv/core/container.cpp
+++ b/src/core/hle/service/nvdrv/core/container.cpp
@@ -16,6 +16,12 @@
16 16
17namespace Service::Nvidia::NvCore { 17namespace Service::Nvidia::NvCore {
18 18
19Session::Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_)
20 : id{id_}, process{process_}, smmu_id{smmu_id_},
21 has_preallocated_area{}, mapper{}, is_active{} {}
22
23Session::~Session() = default;
24
19struct ContainerImpl { 25struct ContainerImpl {
20 explicit ContainerImpl(Container& core, Tegra::Host1x::Host1x& host1x_) 26 explicit ContainerImpl(Container& core, Tegra::Host1x::Host1x& host1x_)
21 : host1x{host1x_}, file{core, host1x_}, manager{host1x_}, device_file_data{} {} 27 : host1x{host1x_}, file{core, host1x_}, manager{host1x_}, device_file_data{} {}
@@ -54,8 +60,8 @@ size_t Container::OpenSession(Kernel::KProcess* process) {
54 impl->id_pool.pop_front(); 60 impl->id_pool.pop_front();
55 impl->sessions[new_id] = Session{new_id, process, smmu_id}; 61 impl->sessions[new_id] = Session{new_id, process, smmu_id};
56 } else { 62 } else {
57 impl->sessions.emplace_back(new_id, process, smmu_id);
58 new_id = impl->new_ids++; 63 new_id = impl->new_ids++;
64 impl->sessions.emplace_back(new_id, process, smmu_id);
59 } 65 }
60 auto& session = impl->sessions[new_id]; 66 auto& session = impl->sessions[new_id];
61 session.is_active = true; 67 session.is_active = true;
diff --git a/src/core/hle/service/nvdrv/core/container.h b/src/core/hle/service/nvdrv/core/container.h
index 86705cbc8..4b8452844 100644
--- a/src/core/hle/service/nvdrv/core/container.h
+++ b/src/core/hle/service/nvdrv/core/container.h
@@ -27,6 +27,14 @@ class SyncpointManager;
27struct ContainerImpl; 27struct ContainerImpl;
28 28
29struct Session { 29struct Session {
30 Session(size_t id_, Kernel::KProcess* process_, size_t smmu_id_);
31 ~Session();
32
33 Session(const Session&) = delete;
34 Session& operator=(const Session&) = delete;
35 Session(Session&&) = default;
36 Session& operator=(Session&&) = default;
37
30 size_t id; 38 size_t id;
31 Kernel::KProcess* process; 39 Kernel::KProcess* process;
32 size_t smmu_id; 40 size_t smmu_id;
diff --git a/src/core/hle/service/nvdrv/core/heap_mapper.cpp b/src/core/hle/service/nvdrv/core/heap_mapper.cpp
index 59d993bc6..c29191b92 100644
--- a/src/core/hle/service/nvdrv/core/heap_mapper.cpp
+++ b/src/core/hle/service/nvdrv/core/heap_mapper.cpp
@@ -124,10 +124,11 @@ DAddr HeapMapper::Map(VAddr start, size_t size) {
124 m_internal->base_set.clear(); 124 m_internal->base_set.clear();
125 const IntervalType interval{start, start + size}; 125 const IntervalType interval{start, start + size};
126 m_internal->base_set.insert(interval); 126 m_internal->base_set.insert(interval);
127 m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size, [this](VAddr start_addr, VAddr end_addr, int){ 127 m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size,
128 const IntervalType other{start_addr, end_addr}; 128 [this](VAddr start_addr, VAddr end_addr, int) {
129 m_internal->base_set.subtract(other); 129 const IntervalType other{start_addr, end_addr};
130 }); 130 m_internal->base_set.subtract(other);
131 });
131 if (!m_internal->base_set.empty()) { 132 if (!m_internal->base_set.empty()) {
132 auto it = m_internal->base_set.begin(); 133 auto it = m_internal->base_set.begin();
133 auto end_it = m_internal->base_set.end(); 134 auto end_it = m_internal->base_set.end();
@@ -136,7 +137,8 @@ DAddr HeapMapper::Map(VAddr start, size_t size) {
136 const VAddr inter_addr = it->lower(); 137 const VAddr inter_addr = it->lower();
137 const size_t offset = inter_addr - m_vaddress; 138 const size_t offset = inter_addr - m_vaddress;
138 const size_t sub_size = inter_addr_end - inter_addr; 139 const size_t sub_size = inter_addr_end - inter_addr;
139 m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size, m_smmu_id); 140 m_internal->device_memory.Map(m_daddress + offset, m_vaddress + offset, sub_size,
141 m_smmu_id);
140 } 142 }
141 } 143 }
142 m_internal->mapping_overlaps += std::make_pair(interval, 1); 144 m_internal->mapping_overlaps += std::make_pair(interval, 1);
@@ -147,12 +149,13 @@ DAddr HeapMapper::Map(VAddr start, size_t size) {
147void HeapMapper::Unmap(VAddr start, size_t size) { 149void HeapMapper::Unmap(VAddr start, size_t size) {
148 std::scoped_lock lk(m_internal->guard); 150 std::scoped_lock lk(m_internal->guard);
149 m_internal->base_set.clear(); 151 m_internal->base_set.clear();
150 m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size, [this](VAddr start_addr, VAddr end_addr, int value) { 152 m_internal->ForEachInOverlapCounter(m_internal->mapping_overlaps, start, size,
151 if (value <= 1) { 153 [this](VAddr start_addr, VAddr end_addr, int value) {
152 const IntervalType other{start_addr, end_addr}; 154 if (value <= 1) {
153 m_internal->base_set.insert(other); 155 const IntervalType other{start_addr, end_addr};
154 } 156 m_internal->base_set.insert(other);
155 }); 157 }
158 });
156 if (!m_internal->base_set.empty()) { 159 if (!m_internal->base_set.empty()) {
157 auto it = m_internal->base_set.begin(); 160 auto it = m_internal->base_set.begin();
158 auto end_it = m_internal->base_set.end(); 161 auto end_it = m_internal->base_set.end();
diff --git a/src/core/hle/service/nvdrv/core/nvmap.cpp b/src/core/hle/service/nvdrv/core/nvmap.cpp
index 296b4d8d2..6e59d4fe1 100644
--- a/src/core/hle/service/nvdrv/core/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/core/nvmap.cpp
@@ -13,8 +13,8 @@
13#include "core/memory.h" 13#include "core/memory.h"
14#include "video_core/host1x/host1x.h" 14#include "video_core/host1x/host1x.h"
15 15
16
17using Core::Memory::YUZU_PAGESIZE; 16using Core::Memory::YUZU_PAGESIZE;
17constexpr size_t BIG_PAGE_SIZE = YUZU_PAGESIZE * 16;
18 18
19namespace Service::Nvidia::NvCore { 19namespace Service::Nvidia::NvCore {
20NvMap::Handle::Handle(u64 size_, Id id_) 20NvMap::Handle::Handle(u64 size_, Id id_)
@@ -96,8 +96,9 @@ void NvMap::UnmapHandle(Handle& handle_description) {
96 const size_t map_size = handle_description.aligned_size; 96 const size_t map_size = handle_description.aligned_size;
97 if (!handle_description.in_heap) { 97 if (!handle_description.in_heap) {
98 auto& smmu = host1x.MemoryManager(); 98 auto& smmu = host1x.MemoryManager();
99 size_t aligned_up = Common::AlignUp(map_size, BIG_PAGE_SIZE);
99 smmu.Unmap(handle_description.d_address, map_size); 100 smmu.Unmap(handle_description.d_address, map_size);
100 smmu.Free(handle_description.d_address, static_cast<size_t>(map_size)); 101 smmu.Free(handle_description.d_address, static_cast<size_t>(aligned_up));
101 handle_description.d_address = 0; 102 handle_description.d_address = 0;
102 return; 103 return;
103 } 104 }
@@ -206,7 +207,8 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, bool low_area_pin) {
206 handle_description->d_address = session->mapper->Map(vaddress, map_size); 207 handle_description->d_address = session->mapper->Map(vaddress, map_size);
207 handle_description->in_heap = true; 208 handle_description->in_heap = true;
208 } else { 209 } else {
209 while ((address = smmu.Allocate(map_size)) == 0) { 210 size_t aligned_up = Common::AlignUp(map_size, BIG_PAGE_SIZE);
211 while ((address = smmu.Allocate(aligned_up)) == 0) {
210 // Free handles until the allocation succeeds 212 // Free handles until the allocation succeeds
211 std::scoped_lock queueLock(unmap_queue_lock); 213 std::scoped_lock queueLock(unmap_queue_lock);
212 if (auto freeHandleDesc{unmap_queue.front()}) { 214 if (auto freeHandleDesc{unmap_queue.front()}) {
diff --git a/src/core/hle/service/nvdrv/core/nvmap.h b/src/core/hle/service/nvdrv/core/nvmap.h
index 119efc38d..aa5cd21ec 100644
--- a/src/core/hle/service/nvdrv/core/nvmap.h
+++ b/src/core/hle/service/nvdrv/core/nvmap.h
@@ -63,8 +63,8 @@ public:
63 } flags{}; 63 } flags{};
64 static_assert(sizeof(Flags) == sizeof(u32)); 64 static_assert(sizeof(Flags) == sizeof(u32));
65 65
66 VAddr address{}; //!< The memory location in the guest's AS that this handle corresponds to, 66 VAddr address{}; //!< The memory location in the guest's AS that this handle corresponds to,
67 //!< this can also be in the nvdrv tmem 67 //!< this can also be in the nvdrv tmem
68 bool is_shared_mem_mapped{}; //!< If this nvmap has been mapped with the MapSharedMem IPC 68 bool is_shared_mem_mapped{}; //!< If this nvmap has been mapped with the MapSharedMem IPC
69 //!< call 69 //!< call
70 70
@@ -73,8 +73,8 @@ public:
73 bool in_heap{}; 73 bool in_heap{};
74 size_t session_id{}; 74 size_t session_id{};
75 75
76 DAddr d_address{}; //!< The memory location in the device's AS that this handle corresponds to, 76 DAddr d_address{}; //!< The memory location in the device's AS that this handle corresponds
77 //!< this can also be in the nvdrv tmem 77 //!< to, this can also be in the nvdrv tmem
78 78
79 Handle(u64 size, Id id); 79 Handle(u64 size, Id id);
80 80
@@ -82,7 +82,8 @@ public:
82 * @brief Sets up the handle with the given memory config, can allocate memory from the tmem 82 * @brief Sets up the handle with the given memory config, can allocate memory from the tmem
83 * if a 0 address is passed 83 * if a 0 address is passed
84 */ 84 */
85 [[nodiscard]] NvResult Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress, size_t pSessionId); 85 [[nodiscard]] NvResult Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress,
86 size_t pSessionId);
86 87
87 /** 88 /**
88 * @brief Increases the dupe counter of the handle for the given session 89 * @brief Increases the dupe counter of the handle for the given session
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
index b44b17a82..718e0fecd 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
@@ -4,8 +4,8 @@
4#pragma once 4#pragma once
5 5
6#include <deque> 6#include <deque>
7#include <vector>
8#include <unordered_map> 7#include <unordered_map>
8#include <vector>
9 9
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/swap.h" 11#include "common/swap.h"
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index d4c93ea5d..a27bed29b 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -69,7 +69,7 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
69} 69}
70 70
71void nvhost_vic::OnOpen(size_t session_id, DeviceFD fd) { 71void nvhost_vic::OnOpen(size_t session_id, DeviceFD fd) {
72 sessions[fd] = session_id; 72 sessions[fd] = session_id;
73} 73}
74 74
75void nvhost_vic::OnClose(DeviceFD fd) { 75void nvhost_vic::OnClose(DeviceFD fd) {
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 24f49ddcd..08ee8ec24 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -123,8 +123,8 @@ NvResult nvmap::IocAlloc(IocAllocParams& params, DeviceFD fd) {
123 return NvResult::InsufficientMemory; 123 return NvResult::InsufficientMemory;
124 } 124 }
125 125
126 const auto result = 126 const auto result = handle_description->Alloc(params.flags, params.align, params.kind,
127 handle_description->Alloc(params.flags, params.align, params.kind, params.address, sessions[fd]); 127 params.address, sessions[fd]);
128 if (result != NvResult::Success) { 128 if (result != NvResult::Success) {
129 LOG_CRITICAL(Service_NVDRV, "Object failed to allocate, handle={:08X}", params.handle); 129 LOG_CRITICAL(Service_NVDRV, "Object failed to allocate, handle={:08X}", params.handle);
130 return result; 130 return result;
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp
index d36eff4ec..86e272b41 100644
--- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp
+++ b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp
@@ -92,7 +92,8 @@ Result FreeNvMapHandle(Nvidia::Devices::nvmap& nvmap, u32 handle, Nvidia::Device
92 Nvidia::Devices::nvmap::IocFreeParams free_params{ 92 Nvidia::Devices::nvmap::IocFreeParams free_params{
93 .handle = handle, 93 .handle = handle,
94 }; 94 };
95 R_UNLESS(nvmap.IocFree(free_params, nvmap_fd) == Nvidia::NvResult::Success, VI::ResultOperationFailed); 95 R_UNLESS(nvmap.IocFree(free_params, nvmap_fd) == Nvidia::NvResult::Success,
96 VI::ResultOperationFailed);
96 97
97 // We succeeded. 98 // We succeeded.
98 R_SUCCEED(); 99 R_SUCCEED();
@@ -109,7 +110,8 @@ Result AllocNvMapHandle(Nvidia::Devices::nvmap& nvmap, u32 handle, Common::Proce
109 .kind = 0, 110 .kind = 0,
110 .address = GetInteger(buffer), 111 .address = GetInteger(buffer),
111 }; 112 };
112 R_UNLESS(nvmap.IocAlloc(alloc_params, nvmap_fd) == Nvidia::NvResult::Success, VI::ResultOperationFailed); 113 R_UNLESS(nvmap.IocAlloc(alloc_params, nvmap_fd) == Nvidia::NvResult::Success,
114 VI::ResultOperationFailed);
113 115
114 // We succeeded. 116 // We succeeded.
115 R_SUCCEED(); 117 R_SUCCEED();
@@ -201,8 +203,8 @@ Result FbShareBufferManager::Initialize(u64* out_buffer_id, u64* out_layer_id, u
201 m_nvmap_fd = m_nvdrv->Open("/dev/nvmap", m_session_id); 203 m_nvmap_fd = m_nvdrv->Open("/dev/nvmap", m_session_id);
202 204
203 // Create an nvmap handle for the buffer and assign the memory to it. 205 // Create an nvmap handle for the buffer and assign the memory to it.
204 R_TRY(AllocateHandleForBuffer(std::addressof(m_buffer_nvmap_handle), *m_nvdrv, m_nvmap_fd, map_address, 206 R_TRY(AllocateHandleForBuffer(std::addressof(m_buffer_nvmap_handle), *m_nvdrv, m_nvmap_fd,
205 SharedBufferSize)); 207 map_address, SharedBufferSize));
206 208
207 // Record the display id. 209 // Record the display id.
208 m_display_id = display_id; 210 m_display_id = display_id;
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h
index 4b1a3d430..d2ec7a9b9 100644
--- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h
+++ b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h
@@ -4,9 +4,9 @@
4#pragma once 4#pragma once
5 5
6#include "common/math_util.h" 6#include "common/math_util.h"
7#include "core/hle/service/nvdrv/nvdata.h"
7#include "core/hle/service/nvnflinger/nvnflinger.h" 8#include "core/hle/service/nvnflinger/nvnflinger.h"
8#include "core/hle/service/nvnflinger/ui/fence.h" 9#include "core/hle/service/nvnflinger/ui/fence.h"
9#include "core/hle/service/nvdrv/nvdata.h"
10 10
11namespace Kernel { 11namespace Kernel {
12class KPageGroup; 12class KPageGroup;
@@ -62,7 +62,6 @@ private:
62 Core::System& m_system; 62 Core::System& m_system;
63 Nvnflinger& m_flinger; 63 Nvnflinger& m_flinger;
64 std::shared_ptr<Nvidia::Module> m_nvdrv; 64 std::shared_ptr<Nvidia::Module> m_nvdrv;
65
66}; 65};
67 66
68} // namespace Service::Nvnflinger 67} // namespace Service::Nvnflinger