summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Liam White2022-04-13 21:02:55 +0200
committerGravatar Fernando Sahmkow2022-10-06 21:00:53 +0200
commitafab6c143cb486c7d14f1509cd04049ad08d3a65 (patch)
treefb3a35b23be7dd5b2c502ec550c027760257c6f3 /src/core
parentVideoCore: Implement formats needed for N64 emulation. (diff)
downloadyuzu-afab6c143cb486c7d14f1509cd04049ad08d3a65.tar.gz
yuzu-afab6c143cb486c7d14f1509cd04049ad08d3a65.tar.xz
yuzu-afab6c143cb486c7d14f1509cd04049ad08d3a65.zip
General: Fix compilation for GCC
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/nvdrv/core/nvmap.cpp38
-rw-r--r--src/core/hle/service/nvdrv/core/nvmap.h1
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp3
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp8
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp4
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp4
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h1
-rw-r--r--src/core/hle/service/vi/vi.cpp1
9 files changed, 39 insertions, 23 deletions
diff --git a/src/core/hle/service/nvdrv/core/nvmap.cpp b/src/core/hle/service/nvdrv/core/nvmap.cpp
index 86d825af9..b02dbb9c9 100644
--- a/src/core/hle/service/nvdrv/core/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/core/nvmap.cpp
@@ -13,7 +13,8 @@
13using Core::Memory::YUZU_PAGESIZE; 13using Core::Memory::YUZU_PAGESIZE;
14 14
15namespace Service::Nvidia::NvCore { 15namespace Service::Nvidia::NvCore {
16NvMap::Handle::Handle(u64 size, Id id) : size(size), aligned_size(size), orig_size(size), id(id) { 16NvMap::Handle::Handle(u64 size_, Id id_)
17 : size(size_), aligned_size(size), orig_size(size), id(id_) {
17 flags.raw = 0; 18 flags.raw = 0;
18} 19}
19 20
@@ -21,19 +22,21 @@ NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress)
21 std::scoped_lock lock(mutex); 22 std::scoped_lock lock(mutex);
22 23
23 // Handles cannot be allocated twice 24 // Handles cannot be allocated twice
24 if (allocated) 25 if (allocated) {
25 return NvResult::AccessDenied; 26 return NvResult::AccessDenied;
27 }
26 28
27 flags = pFlags; 29 flags = pFlags;
28 kind = pKind; 30 kind = pKind;
29 align = pAlign < YUZU_PAGESIZE ? YUZU_PAGESIZE : pAlign; 31 align = pAlign < YUZU_PAGESIZE ? YUZU_PAGESIZE : pAlign;
30 32
31 // This flag is only applicable for handles with an address passed 33 // This flag is only applicable for handles with an address passed
32 if (pAddress) 34 if (pAddress) {
33 flags.keep_uncached_after_free = 0; 35 flags.keep_uncached_after_free.Assign(0);
34 else 36 } else {
35 LOG_CRITICAL(Service_NVDRV, 37 LOG_CRITICAL(Service_NVDRV,
36 "Mapping nvmap handles without a CPU side address is unimplemented!"); 38 "Mapping nvmap handles without a CPU side address is unimplemented!");
39 }
37 40
38 size = Common::AlignUp(size, YUZU_PAGESIZE); 41 size = Common::AlignUp(size, YUZU_PAGESIZE);
39 aligned_size = Common::AlignUp(size, align); 42 aligned_size = Common::AlignUp(size, align);
@@ -48,17 +51,19 @@ NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress)
48 51
49NvResult NvMap::Handle::Duplicate(bool internal_session) { 52NvResult NvMap::Handle::Duplicate(bool internal_session) {
50 // Unallocated handles cannot be duplicated as duplication requires memory accounting (in HOS) 53 // Unallocated handles cannot be duplicated as duplication requires memory accounting (in HOS)
51 if (!allocated) [[unlikely]] 54 if (!allocated) [[unlikely]] {
52 return NvResult::BadValue; 55 return NvResult::BadValue;
56 }
53 57
54 std::scoped_lock lock(mutex); 58 std::scoped_lock lock(mutex);
55 59
56 // If we internally use FromId the duplication tracking of handles won't work accurately due to 60 // If we internally use FromId the duplication tracking of handles won't work accurately due to
57 // us not implementing per-process handle refs. 61 // us not implementing per-process handle refs.
58 if (internal_session) 62 if (internal_session) {
59 internal_dupes++; 63 internal_dupes++;
60 else 64 } else {
61 dupes++; 65 dupes++;
66 }
62 67
63 return NvResult::Success; 68 return NvResult::Success;
64} 69}
@@ -92,8 +97,9 @@ bool NvMap::TryRemoveHandle(const Handle& handle_description) {
92 std::scoped_lock lock(handles_lock); 97 std::scoped_lock lock(handles_lock);
93 98
94 auto it{handles.find(handle_description.id)}; 99 auto it{handles.find(handle_description.id)};
95 if (it != handles.end()) 100 if (it != handles.end()) {
96 handles.erase(it); 101 handles.erase(it);
102 }
97 103
98 return true; 104 return true;
99 } else { 105 } else {
@@ -102,8 +108,9 @@ bool NvMap::TryRemoveHandle(const Handle& handle_description) {
102} 108}
103 109
104NvResult NvMap::CreateHandle(u64 size, std::shared_ptr<NvMap::Handle>& result_out) { 110NvResult NvMap::CreateHandle(u64 size, std::shared_ptr<NvMap::Handle>& result_out) {
105 if (!size) [[unlikely]] 111 if (!size) [[unlikely]] {
106 return NvResult::BadValue; 112 return NvResult::BadValue;
113 }
107 114
108 u32 id{next_handle_id.fetch_add(HandleIdIncrement, std::memory_order_relaxed)}; 115 u32 id{next_handle_id.fetch_add(HandleIdIncrement, std::memory_order_relaxed)};
109 auto handle_description{std::make_shared<Handle>(size, id)}; 116 auto handle_description{std::make_shared<Handle>(size, id)};
@@ -133,8 +140,9 @@ VAddr NvMap::GetHandleAddress(Handle::Id handle) {
133 140
134u32 NvMap::PinHandle(NvMap::Handle::Id handle) { 141u32 NvMap::PinHandle(NvMap::Handle::Id handle) {
135 auto handle_description{GetHandle(handle)}; 142 auto handle_description{GetHandle(handle)};
136 if (!handle_description) [[unlikely]] 143 if (!handle_description) [[unlikely]] {
137 return 0; 144 return 0;
145 }
138 146
139 std::scoped_lock lock(handle_description->mutex); 147 std::scoped_lock lock(handle_description->mutex);
140 if (!handle_description->pins) { 148 if (!handle_description->pins) {
@@ -183,8 +191,9 @@ u32 NvMap::PinHandle(NvMap::Handle::Id handle) {
183 191
184void NvMap::UnpinHandle(Handle::Id handle) { 192void NvMap::UnpinHandle(Handle::Id handle) {
185 auto handle_description{GetHandle(handle)}; 193 auto handle_description{GetHandle(handle)};
186 if (!handle_description) 194 if (!handle_description) {
187 return; 195 return;
196 }
188 197
189 std::scoped_lock lock(handle_description->mutex); 198 std::scoped_lock lock(handle_description->mutex);
190 if (--handle_description->pins < 0) { 199 if (--handle_description->pins < 0) {
@@ -226,12 +235,13 @@ std::optional<NvMap::FreeInfo> NvMap::FreeHandle(Handle::Id handle, bool interna
226 235
227 // Try to remove the shared ptr to the handle from the map, if nothing else is using the 236 // Try to remove the shared ptr to the handle from the map, if nothing else is using the
228 // handle then it will now be freed when `handle_description` goes out of scope 237 // handle then it will now be freed when `handle_description` goes out of scope
229 if (TryRemoveHandle(*handle_description)) 238 if (TryRemoveHandle(*handle_description)) {
230 LOG_DEBUG(Service_NVDRV, "Removed nvmap handle: {}", handle); 239 LOG_DEBUG(Service_NVDRV, "Removed nvmap handle: {}", handle);
231 else 240 } else {
232 LOG_DEBUG(Service_NVDRV, 241 LOG_DEBUG(Service_NVDRV,
233 "Tried to free nvmap handle: {} but didn't as it still has duplicates", 242 "Tried to free nvmap handle: {} but didn't as it still has duplicates",
234 handle); 243 handle);
244 }
235 245
236 freeInfo = { 246 freeInfo = {
237 .address = handle_description->address, 247 .address = handle_description->address,
diff --git a/src/core/hle/service/nvdrv/core/nvmap.h b/src/core/hle/service/nvdrv/core/nvmap.h
index 4f37dcf43..1082bb58d 100644
--- a/src/core/hle/service/nvdrv/core/nvmap.h
+++ b/src/core/hle/service/nvdrv/core/nvmap.h
@@ -5,6 +5,7 @@
5 5
6#pragma once 6#pragma once
7 7
8#include <atomic>
8#include <list> 9#include <list>
9#include <memory> 10#include <memory>
10#include <mutex> 11#include <mutex>
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
index d95a88393..d1beefba6 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -188,6 +188,7 @@ NvResult nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<
188 188
189 allocation_map[params.offset] = { 189 allocation_map[params.offset] = {
190 .size = size, 190 .size = size,
191 .mappings{},
191 .page_size = params.page_size, 192 .page_size = params.page_size,
192 .sparse = (params.flags & MappingFlags::Sparse) != MappingFlags::None, 193 .sparse = (params.flags & MappingFlags::Sparse) != MappingFlags::None,
193 .big_pages = params.page_size != VM::YUZU_PAGESIZE, 194 .big_pages = params.page_size != VM::YUZU_PAGESIZE,
@@ -474,11 +475,13 @@ void nvhost_as_gpu::GetVARegionsImpl(IoctlGetVaRegions& params) {
474 VaRegion{ 475 VaRegion{
475 .offset = vm.small_page_allocator->vaStart << VM::PAGE_SIZE_BITS, 476 .offset = vm.small_page_allocator->vaStart << VM::PAGE_SIZE_BITS,
476 .page_size = VM::YUZU_PAGESIZE, 477 .page_size = VM::YUZU_PAGESIZE,
478 ._pad0_{},
477 .pages = vm.small_page_allocator->vaLimit - vm.small_page_allocator->vaStart, 479 .pages = vm.small_page_allocator->vaLimit - vm.small_page_allocator->vaStart,
478 }, 480 },
479 VaRegion{ 481 VaRegion{
480 .offset = vm.big_page_allocator->vaStart << vm.big_page_size_bits, 482 .offset = vm.big_page_allocator->vaStart << vm.big_page_size_bits,
481 .page_size = vm.big_page_size, 483 .page_size = vm.big_page_size,
484 ._pad0_{},
482 .pages = vm.big_page_allocator->vaLimit - vm.big_page_allocator->vaStart, 485 .pages = vm.big_page_allocator->vaLimit - vm.big_page_allocator->vaStart,
483 }, 486 },
484 }; 487 };
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index a84e4d425..7fffb8e48 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -204,12 +204,12 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
204 204
205 event.wait_handle = 205 event.wait_handle =
206 host1x_syncpoint_manager.RegisterHostAction(fence_id, target_value, [this, slot]() { 206 host1x_syncpoint_manager.RegisterHostAction(fence_id, target_value, [this, slot]() {
207 auto& event = events[slot]; 207 auto& event_ = events[slot];
208 if (event.status.exchange(EventState::Signalling, std::memory_order_acq_rel) == 208 if (event_.status.exchange(EventState::Signalling, std::memory_order_acq_rel) ==
209 EventState::Waiting) { 209 EventState::Waiting) {
210 event.kevent->GetWritableEvent().Signal(); 210 event_.kevent->GetWritableEvent().Signal();
211 } 211 }
212 event.status.store(EventState::Signalled, std::memory_order_release); 212 event_.status.store(EventState::Signalled, std::memory_order_release);
213 }); 213 });
214 return NvResult::Timeout; 214 return NvResult::Timeout;
215} 215}
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
index 5e3820085..fed537039 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
@@ -12,8 +12,8 @@ namespace Service::Nvidia::Devices {
12 12
13u32 nvhost_nvdec::next_id{}; 13u32 nvhost_nvdec::next_id{};
14 14
15nvhost_nvdec::nvhost_nvdec(Core::System& system_, NvCore::Container& core) 15nvhost_nvdec::nvhost_nvdec(Core::System& system_, NvCore::Container& core_)
16 : nvhost_nvdec_common{system_, core, NvCore::ChannelType::NvDec} {} 16 : nvhost_nvdec_common{system_, core_, NvCore::ChannelType::NvDec} {}
17nvhost_nvdec::~nvhost_nvdec() = default; 17nvhost_nvdec::~nvhost_nvdec() = default;
18 18
19NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, 19NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index 490e399f4..2e4ff988c 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -11,8 +11,8 @@ namespace Service::Nvidia::Devices {
11 11
12u32 nvhost_vic::next_id{}; 12u32 nvhost_vic::next_id{};
13 13
14nvhost_vic::nvhost_vic(Core::System& system_, NvCore::Container& core) 14nvhost_vic::nvhost_vic(Core::System& system_, NvCore::Container& core_)
15 : nvhost_nvdec_common{system_, core, NvCore::ChannelType::VIC} {} 15 : nvhost_nvdec_common{system_, core_, NvCore::ChannelType::VIC} {}
16 16
17nvhost_vic::~nvhost_vic() = default; 17nvhost_vic::~nvhost_vic() = default;
18 18
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 992c117f1..f84fc8c37 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -269,7 +269,7 @@ NvResult nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) {
269 params.address = freeInfo->address; 269 params.address = freeInfo->address;
270 params.size = static_cast<u32>(freeInfo->size); 270 params.size = static_cast<u32>(freeInfo->size);
271 params.flags.raw = 0; 271 params.flags.raw = 0;
272 params.flags.map_uncached = freeInfo->was_uncached; 272 params.flags.map_uncached.Assign(freeInfo->was_uncached);
273 } else { 273 } else {
274 // This is possible when there's internel dups or other duplicates. 274 // This is possible when there's internel dups or other duplicates.
275 } 275 }
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 31c45236e..b26254753 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -6,6 +6,7 @@
6#pragma once 6#pragma once
7 7
8#include <functional> 8#include <functional>
9#include <list>
9#include <memory> 10#include <memory>
10#include <string> 11#include <string>
11#include <unordered_map> 12#include <unordered_map>
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index f083811ec..9c917cacf 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -58,6 +58,7 @@ static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
58class NativeWindow final { 58class NativeWindow final {
59public: 59public:
60 constexpr explicit NativeWindow(u32 id_) : id{id_} {} 60 constexpr explicit NativeWindow(u32 id_) : id{id_} {}
61 constexpr explicit NativeWindow(const NativeWindow& other) = default;
61 62
62private: 63private:
63 const u32 magic = 2; 64 const u32 magic = 2;