summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------externals/dynarmic0
-rw-r--r--src/core/hle/kernel/kernel.cpp2
-rw-r--r--src/core/hle/service/friend/friend.cpp23
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp11
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp5
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdevice.h20
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp11
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp11
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp9
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp11
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp11
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.h12
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp10
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp2
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.cpp8
27 files changed, 192 insertions, 98 deletions
diff --git a/externals/dynarmic b/externals/dynarmic
Subproject 646fd0592091c5c1e5899fa715bd7b7fcc977a3 Subproject c28f13af9797c0319d9a38b5b5c8470ff906e2c
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 780008b08..5b6c7792e 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -68,9 +68,9 @@ struct KernelCore::Impl {
68 InitializePhysicalCores(); 68 InitializePhysicalCores();
69 InitializeSystemResourceLimit(kernel, system); 69 InitializeSystemResourceLimit(kernel, system);
70 InitializeMemoryLayout(); 70 InitializeMemoryLayout();
71 InitializePreemption(kernel);
72 InitializeSchedulers(); 71 InitializeSchedulers();
73 InitializeSuspendThreads(); 72 InitializeSuspendThreads();
73 InitializePreemption(kernel);
74 } 74 }
75 75
76 void InitializeCores() { 76 void InitializeCores() {
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp
index 72a877d68..0a6621ef2 100644
--- a/src/core/hle/service/friend/friend.cpp
+++ b/src/core/hle/service/friend/friend.cpp
@@ -133,7 +133,7 @@ private:
133 void GetBlockedUserListIds(Kernel::HLERequestContext& ctx) { 133 void GetBlockedUserListIds(Kernel::HLERequestContext& ctx) {
134 // This is safe to stub, as there should be no adverse consequences from reporting no 134 // This is safe to stub, as there should be no adverse consequences from reporting no
135 // blocked users. 135 // blocked users.
136 LOG_WARNING(Service_ACC, "(STUBBED) called"); 136 LOG_WARNING(Service_Friend, "(STUBBED) called");
137 IPC::ResponseBuilder rb{ctx, 3}; 137 IPC::ResponseBuilder rb{ctx, 3};
138 rb.Push(RESULT_SUCCESS); 138 rb.Push(RESULT_SUCCESS);
139 rb.Push<u32>(0); // Indicates there are no blocked users 139 rb.Push<u32>(0); // Indicates there are no blocked users
@@ -141,14 +141,14 @@ private:
141 141
142 void DeclareCloseOnlinePlaySession(Kernel::HLERequestContext& ctx) { 142 void DeclareCloseOnlinePlaySession(Kernel::HLERequestContext& ctx) {
143 // Stub used by Splatoon 2 143 // Stub used by Splatoon 2
144 LOG_WARNING(Service_ACC, "(STUBBED) called"); 144 LOG_WARNING(Service_Friend, "(STUBBED) called");
145 IPC::ResponseBuilder rb{ctx, 2}; 145 IPC::ResponseBuilder rb{ctx, 2};
146 rb.Push(RESULT_SUCCESS); 146 rb.Push(RESULT_SUCCESS);
147 } 147 }
148 148
149 void UpdateUserPresence(Kernel::HLERequestContext& ctx) { 149 void UpdateUserPresence(Kernel::HLERequestContext& ctx) {
150 // Stub used by Retro City Rampage 150 // Stub used by Retro City Rampage
151 LOG_WARNING(Service_ACC, "(STUBBED) called"); 151 LOG_WARNING(Service_Friend, "(STUBBED) called");
152 IPC::ResponseBuilder rb{ctx, 2}; 152 IPC::ResponseBuilder rb{ctx, 2};
153 rb.Push(RESULT_SUCCESS); 153 rb.Push(RESULT_SUCCESS);
154 } 154 }
@@ -159,7 +159,7 @@ private:
159 const auto uuid = rp.PopRaw<Common::UUID>(); 159 const auto uuid = rp.PopRaw<Common::UUID>();
160 [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>(); 160 [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
161 const auto pid = rp.Pop<u64>(); 161 const auto pid = rp.Pop<u64>();
162 LOG_WARNING(Service_ACC, "(STUBBED) called, offset={}, uuid={}, pid={}", friend_offset, 162 LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid={}, pid={}", friend_offset,
163 uuid.Format(), pid); 163 uuid.Format(), pid);
164 164
165 IPC::ResponseBuilder rb{ctx, 3}; 165 IPC::ResponseBuilder rb{ctx, 3};
@@ -191,7 +191,7 @@ public:
191 191
192private: 192private:
193 void GetEvent(Kernel::HLERequestContext& ctx) { 193 void GetEvent(Kernel::HLERequestContext& ctx) {
194 LOG_DEBUG(Service_ACC, "called"); 194 LOG_DEBUG(Service_Friend, "called");
195 195
196 IPC::ResponseBuilder rb{ctx, 2, 1}; 196 IPC::ResponseBuilder rb{ctx, 2, 1};
197 rb.Push(RESULT_SUCCESS); 197 rb.Push(RESULT_SUCCESS);
@@ -199,7 +199,7 @@ private:
199 } 199 }
200 200
201 void Clear(Kernel::HLERequestContext& ctx) { 201 void Clear(Kernel::HLERequestContext& ctx) {
202 LOG_DEBUG(Service_ACC, "called"); 202 LOG_DEBUG(Service_Friend, "called");
203 while (!notifications.empty()) { 203 while (!notifications.empty()) {
204 notifications.pop(); 204 notifications.pop();
205 } 205 }
@@ -210,10 +210,10 @@ private:
210 } 210 }
211 211
212 void Pop(Kernel::HLERequestContext& ctx) { 212 void Pop(Kernel::HLERequestContext& ctx) {
213 LOG_DEBUG(Service_ACC, "called"); 213 LOG_DEBUG(Service_Friend, "called");
214 214
215 if (notifications.empty()) { 215 if (notifications.empty()) {
216 LOG_ERROR(Service_ACC, "No notifications in queue!"); 216 LOG_ERROR(Service_Friend, "No notifications in queue!");
217 IPC::ResponseBuilder rb{ctx, 2}; 217 IPC::ResponseBuilder rb{ctx, 2};
218 rb.Push(ERR_NO_NOTIFICATIONS); 218 rb.Push(ERR_NO_NOTIFICATIONS);
219 return; 219 return;
@@ -231,7 +231,8 @@ private:
231 break; 231 break;
232 default: 232 default:
233 // HOS seems not have an error case for an unknown notification 233 // HOS seems not have an error case for an unknown notification
234 LOG_WARNING(Service_ACC, "Unknown notification {:08X}", notification.notification_type); 234 LOG_WARNING(Service_Friend, "Unknown notification {:08X}",
235 notification.notification_type);
235 break; 236 break;
236 } 237 }
237 238
@@ -269,14 +270,14 @@ void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) {
269 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 270 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
270 rb.Push(RESULT_SUCCESS); 271 rb.Push(RESULT_SUCCESS);
271 rb.PushIpcInterface<IFriendService>(system); 272 rb.PushIpcInterface<IFriendService>(system);
272 LOG_DEBUG(Service_ACC, "called"); 273 LOG_DEBUG(Service_Friend, "called");
273} 274}
274 275
275void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) { 276void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) {
276 IPC::RequestParser rp{ctx}; 277 IPC::RequestParser rp{ctx};
277 auto uuid = rp.PopRaw<Common::UUID>(); 278 auto uuid = rp.PopRaw<Common::UUID>();
278 279
279 LOG_DEBUG(Service_ACC, "called, uuid={}", uuid.Format()); 280 LOG_DEBUG(Service_Friend, "called, uuid={}", uuid.Format());
280 281
281 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 282 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
282 rb.Push(RESULT_SUCCESS); 283 rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index e7063f8ef..93c43a203 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -4,6 +4,7 @@
4 4
5#include <cstring> 5#include <cstring>
6#include "common/common_types.h" 6#include "common/common_types.h"
7#include "common/logging/log.h"
7#include "core/core_timing.h" 8#include "core/core_timing.h"
8#include "core/frontend/emu_window.h" 9#include "core/frontend/emu_window.h"
9#include "core/hle/service/hid/controllers/gesture.h" 10#include "core/hle/service/hid/controllers/gesture.h"
@@ -19,9 +20,9 @@ Controller_Gesture::~Controller_Gesture() = default;
19 20
20void Controller_Gesture::OnInit() { 21void Controller_Gesture::OnInit() {
21 for (std::size_t id = 0; id < MAX_FINGERS; ++id) { 22 for (std::size_t id = 0; id < MAX_FINGERS; ++id) {
22 mouse_finger_id[id] = MAX_FINGERS; 23 mouse_finger_id[id] = MAX_POINTS;
23 keyboard_finger_id[id] = MAX_FINGERS; 24 keyboard_finger_id[id] = MAX_POINTS;
24 udp_finger_id[id] = MAX_FINGERS; 25 udp_finger_id[id] = MAX_POINTS;
25 } 26 }
26} 27}
27 28
@@ -142,6 +143,10 @@ std::optional<std::size_t> Controller_Gesture::GetUnusedFingerID() const {
142std::size_t Controller_Gesture::UpdateTouchInputEvent( 143std::size_t Controller_Gesture::UpdateTouchInputEvent(
143 const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { 144 const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) {
144 const auto& [x, y, pressed] = touch_input; 145 const auto& [x, y, pressed] = touch_input;
146 if (finger_id > MAX_POINTS) {
147 LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id);
148 return MAX_POINTS;
149 }
145 if (pressed) { 150 if (pressed) {
146 if (finger_id == MAX_POINTS) { 151 if (finger_id == MAX_POINTS) {
147 const auto first_free_id = GetUnusedFingerID(); 152 const auto first_free_id = GetUnusedFingerID();
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 5219f2dad..be60492a4 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -5,6 +5,7 @@
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h"
8#include "core/core_timing.h" 9#include "core/core_timing.h"
9#include "core/frontend/emu_window.h" 10#include "core/frontend/emu_window.h"
10#include "core/frontend/input.h" 11#include "core/frontend/input.h"
@@ -118,6 +119,10 @@ std::optional<std::size_t> Controller_Touchscreen::GetUnusedFingerID() const {
118std::size_t Controller_Touchscreen::UpdateTouchInputEvent( 119std::size_t Controller_Touchscreen::UpdateTouchInputEvent(
119 const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { 120 const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) {
120 const auto& [x, y, pressed] = touch_input; 121 const auto& [x, y, pressed] = touch_input;
122 if (finger_id > MAX_FINGERS) {
123 LOG_ERROR(Service_HID, "Invalid finger id {}", finger_id);
124 return MAX_FINGERS;
125 }
121 if (pressed) { 126 if (pressed) {
122 Attributes attribute{}; 127 Attributes attribute{};
123 if (finger_id == MAX_FINGERS) { 128 if (finger_id == MAX_FINGERS) {
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h
index 5681599ba..b37f023df 100644
--- a/src/core/hle/service/nvdrv/devices/nvdevice.h
+++ b/src/core/hle/service/nvdrv/devices/nvdevice.h
@@ -31,7 +31,7 @@ public:
31 * @param output A buffer where the output data will be written to. 31 * @param output A buffer where the output data will be written to.
32 * @returns The result code of the ioctl. 32 * @returns The result code of the ioctl.
33 */ 33 */
34 virtual NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, 34 virtual NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
35 std::vector<u8>& output) = 0; 35 std::vector<u8>& output) = 0;
36 36
37 /** 37 /**
@@ -42,7 +42,7 @@ public:
42 * @param output A buffer where the output data will be written to. 42 * @param output A buffer where the output data will be written to.
43 * @returns The result code of the ioctl. 43 * @returns The result code of the ioctl.
44 */ 44 */
45 virtual NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 45 virtual NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
46 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0; 46 const std::vector<u8>& inline_input, std::vector<u8>& output) = 0;
47 47
48 /** 48 /**
@@ -53,8 +53,20 @@ public:
53 * @param inline_output A buffer where the inlined output data will be written to. 53 * @param inline_output A buffer where the inlined output data will be written to.
54 * @returns The result code of the ioctl. 54 * @returns The result code of the ioctl.
55 */ 55 */
56 virtual NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 56 virtual NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
57 std::vector<u8>& inline_output) = 0; 57 std::vector<u8>& output, std::vector<u8>& inline_output) = 0;
58
59 /**
60 * Called once a device is openned
61 * @param fd The device fd
62 */
63 virtual void OnOpen(DeviceFD fd) = 0;
64
65 /**
66 * Called once a device is closed
67 * @param fd The device fd
68 */
69 virtual void OnClose(DeviceFD fd) = 0;
58 70
59protected: 71protected:
60 Core::System& system; 72 Core::System& system;
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index ce615c758..5ab7e39b0 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -18,24 +18,27 @@ nvdisp_disp0::nvdisp_disp0(Core::System& system, std::shared_ptr<nvmap> nvmap_de
18 : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} 18 : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {}
19nvdisp_disp0 ::~nvdisp_disp0() = default; 19nvdisp_disp0 ::~nvdisp_disp0() = default;
20 20
21NvResult nvdisp_disp0::Ioctl1(Ioctl command, const std::vector<u8>& input, 21NvResult nvdisp_disp0::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
22 std::vector<u8>& output) { 22 std::vector<u8>& output) {
23 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 23 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
24 return NvResult::NotImplemented; 24 return NvResult::NotImplemented;
25} 25}
26 26
27NvResult nvdisp_disp0::Ioctl2(Ioctl command, const std::vector<u8>& input, 27NvResult nvdisp_disp0::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
28 const std::vector<u8>& inline_input, std::vector<u8>& output) { 28 const std::vector<u8>& inline_input, std::vector<u8>& output) {
29 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 29 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
30 return NvResult::NotImplemented; 30 return NvResult::NotImplemented;
31} 31}
32 32
33NvResult nvdisp_disp0::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 33NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
34 std::vector<u8>& inline_output) { 34 std::vector<u8>& output, std::vector<u8>& inline_output) {
35 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 35 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
36 return NvResult::NotImplemented; 36 return NvResult::NotImplemented;
37} 37}
38 38
39void nvdisp_disp0::OnOpen(DeviceFD fd) {}
40void nvdisp_disp0::OnClose(DeviceFD fd) {}
41
39void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, 42void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height,
40 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform, 43 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform,
41 const Common::Rectangle<int>& crop_rect) { 44 const Common::Rectangle<int>& crop_rect) {
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
index 55a33b7e4..59c9b6101 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
@@ -20,11 +20,15 @@ public:
20 explicit nvdisp_disp0(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); 20 explicit nvdisp_disp0(Core::System& system, std::shared_ptr<nvmap> nvmap_dev);
21 ~nvdisp_disp0() override; 21 ~nvdisp_disp0() override;
22 22
23 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 23 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
24 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 24 std::vector<u8>& output) override;
25 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
25 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 26 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
26 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 27 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
27 std::vector<u8>& inline_output) override; 28 std::vector<u8>& output, std::vector<u8>& inline_output) override;
29
30 void OnOpen(DeviceFD fd) override;
31 void OnClose(DeviceFD fd) override;
28 32
29 /// Performs a screen flip, drawing the buffer pointed to by the handle. 33 /// Performs a screen flip, drawing the buffer pointed to by the handle.
30 void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride, 34 void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride,
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 485ac5f50..f7b3dc317 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp
@@ -21,7 +21,7 @@ nvhost_as_gpu::nvhost_as_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_
21 : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} 21 : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {}
22nvhost_as_gpu::~nvhost_as_gpu() = default; 22nvhost_as_gpu::~nvhost_as_gpu() = default;
23 23
24NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, 24NvResult nvhost_as_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
25 std::vector<u8>& output) { 25 std::vector<u8>& output) {
26 switch (command.group) { 26 switch (command.group) {
27 case 'A': 27 case 'A':
@@ -54,14 +54,14 @@ NvResult nvhost_as_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input,
54 return NvResult::NotImplemented; 54 return NvResult::NotImplemented;
55} 55}
56 56
57NvResult nvhost_as_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, 57NvResult nvhost_as_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
58 const std::vector<u8>& inline_input, std::vector<u8>& output) { 58 const std::vector<u8>& inline_input, std::vector<u8>& output) {
59 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 59 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
60 return NvResult::NotImplemented; 60 return NvResult::NotImplemented;
61} 61}
62 62
63NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 63NvResult nvhost_as_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
64 std::vector<u8>& inline_output) { 64 std::vector<u8>& output, std::vector<u8>& inline_output) {
65 switch (command.group) { 65 switch (command.group) {
66 case 'A': 66 case 'A':
67 switch (command.cmd) { 67 switch (command.cmd) {
@@ -78,6 +78,9 @@ NvResult nvhost_as_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std:
78 return NvResult::NotImplemented; 78 return NvResult::NotImplemented;
79} 79}
80 80
81void nvhost_as_gpu::OnOpen(DeviceFD fd) {}
82void nvhost_as_gpu::OnClose(DeviceFD fd) {}
83
81NvResult nvhost_as_gpu::AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output) { 84NvResult nvhost_as_gpu::AllocAsEx(const std::vector<u8>& input, std::vector<u8>& output) {
82 IoctlAllocAsEx params{}; 85 IoctlAllocAsEx params{};
83 std::memcpy(&params, input.data(), input.size()); 86 std::memcpy(&params, input.data(), input.size());
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
index 9ee60e060..d86a9cab6 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
@@ -33,11 +33,15 @@ public:
33 explicit nvhost_as_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_dev); 33 explicit nvhost_as_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_dev);
34 ~nvhost_as_gpu() override; 34 ~nvhost_as_gpu() override;
35 35
36 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 36 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
37 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 37 std::vector<u8>& output) override;
38 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
38 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 39 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
39 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 40 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
40 std::vector<u8>& inline_output) override; 41 std::vector<u8>& output, std::vector<u8>& inline_output) override;
42
43 void OnOpen(DeviceFD fd) override;
44 void OnClose(DeviceFD fd) override;
41 45
42private: 46private:
43 class BufferMap final { 47 class BufferMap final {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index f6129ef10..9f00d5cb0 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -20,7 +20,8 @@ nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface,
20 : nvdevice(system), events_interface{events_interface}, syncpoint_manager{syncpoint_manager} {} 20 : nvdevice(system), events_interface{events_interface}, syncpoint_manager{syncpoint_manager} {}
21nvhost_ctrl::~nvhost_ctrl() = default; 21nvhost_ctrl::~nvhost_ctrl() = default;
22 22
23NvResult nvhost_ctrl::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 23NvResult nvhost_ctrl::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
24 std::vector<u8>& output) {
24 switch (command.group) { 25 switch (command.group) {
25 case 0x0: 26 case 0x0:
26 switch (command.cmd) { 27 switch (command.cmd) {
@@ -46,18 +47,21 @@ NvResult nvhost_ctrl::Ioctl1(Ioctl command, const std::vector<u8>& input, std::v
46 return NvResult::NotImplemented; 47 return NvResult::NotImplemented;
47} 48}
48 49
49NvResult nvhost_ctrl::Ioctl2(Ioctl command, const std::vector<u8>& input, 50NvResult nvhost_ctrl::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
50 const std::vector<u8>& inline_input, std::vector<u8>& output) { 51 const std::vector<u8>& inline_input, std::vector<u8>& output) {
51 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 52 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
52 return NvResult::NotImplemented; 53 return NvResult::NotImplemented;
53} 54}
54 55
55NvResult nvhost_ctrl::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 56NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
56 std::vector<u8>& inline_outpu) { 57 std::vector<u8>& output, std::vector<u8>& inline_outpu) {
57 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 58 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
58 return NvResult::NotImplemented; 59 return NvResult::NotImplemented;
59} 60}
60 61
62void nvhost_ctrl::OnOpen(DeviceFD fd) {}
63void nvhost_ctrl::OnClose(DeviceFD fd) {}
64
61NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { 65NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) {
62 IocGetConfigParams params{}; 66 IocGetConfigParams params{};
63 std::memcpy(&params, input.data(), sizeof(params)); 67 std::memcpy(&params, input.data(), sizeof(params));
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
index c5aa1362a..9178789c3 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
@@ -18,11 +18,15 @@ public:
18 SyncpointManager& syncpoint_manager); 18 SyncpointManager& syncpoint_manager);
19 ~nvhost_ctrl() override; 19 ~nvhost_ctrl() override;
20 20
21 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 21 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
22 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 22 std::vector<u8>& output) override;
23 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
23 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 24 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
24 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 25 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
25 std::vector<u8>& inline_output) override; 26 std::vector<u8>& output, std::vector<u8>& inline_output) override;
27
28 void OnOpen(DeviceFD fd) override;
29 void OnClose(DeviceFD fd) override;
26 30
27private: 31private:
28 struct IocSyncptReadParams { 32 struct IocSyncptReadParams {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
index 0320d3ae2..933d42f3f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -15,7 +15,7 @@ namespace Service::Nvidia::Devices {
15nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {} 15nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {}
16nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; 16nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default;
17 17
18NvResult nvhost_ctrl_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, 18NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
19 std::vector<u8>& output) { 19 std::vector<u8>& output) {
20 switch (command.group) { 20 switch (command.group) {
21 case 'G': 21 case 'G':
@@ -47,13 +47,13 @@ NvResult nvhost_ctrl_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input,
47 return NvResult::NotImplemented; 47 return NvResult::NotImplemented;
48} 48}
49 49
50NvResult nvhost_ctrl_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, 50NvResult nvhost_ctrl_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
51 const std::vector<u8>& inline_input, std::vector<u8>& output) { 51 const std::vector<u8>& inline_input, std::vector<u8>& output) {
52 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 52 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
53 return NvResult::NotImplemented; 53 return NvResult::NotImplemented;
54} 54}
55 55
56NvResult nvhost_ctrl_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, 56NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
57 std::vector<u8>& output, std::vector<u8>& inline_output) { 57 std::vector<u8>& output, std::vector<u8>& inline_output) {
58 switch (command.group) { 58 switch (command.group) {
59 case 'G': 59 case 'G':
@@ -73,6 +73,9 @@ NvResult nvhost_ctrl_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input,
73 return NvResult::NotImplemented; 73 return NvResult::NotImplemented;
74} 74}
75 75
76void nvhost_ctrl_gpu::OnOpen(DeviceFD fd) {}
77void nvhost_ctrl_gpu::OnClose(DeviceFD fd) {}
78
76NvResult nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, 79NvResult nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input,
77 std::vector<u8>& output) { 80 std::vector<u8>& output) {
78 LOG_DEBUG(Service_NVDRV, "called"); 81 LOG_DEBUG(Service_NVDRV, "called");
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
index 137b88238..f98aa841a 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
@@ -16,11 +16,15 @@ public:
16 explicit nvhost_ctrl_gpu(Core::System& system); 16 explicit nvhost_ctrl_gpu(Core::System& system);
17 ~nvhost_ctrl_gpu() override; 17 ~nvhost_ctrl_gpu() override;
18 18
19 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 19 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
20 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 20 std::vector<u8>& output) override;
21 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
21 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 22 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
22 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 23 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
23 std::vector<u8>& inline_output) override; 24 std::vector<u8>& output, std::vector<u8>& inline_output) override;
25
26 void OnOpen(DeviceFD fd) override;
27 void OnClose(DeviceFD fd) override;
24 28
25private: 29private:
26 struct IoctlGpuCharacteristics { 30 struct IoctlGpuCharacteristics {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index af8b3d9f1..e83aaa798 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -23,7 +23,8 @@ nvhost_gpu::nvhost_gpu(Core::System& system, std::shared_ptr<nvmap> nvmap_dev,
23 23
24nvhost_gpu::~nvhost_gpu() = default; 24nvhost_gpu::~nvhost_gpu() = default;
25 25
26NvResult nvhost_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 26NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
27 std::vector<u8>& output) {
27 switch (command.group) { 28 switch (command.group) {
28 case 0x0: 29 case 0x0:
29 switch (command.cmd) { 30 switch (command.cmd) {
@@ -74,7 +75,7 @@ NvResult nvhost_gpu::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve
74 return NvResult::NotImplemented; 75 return NvResult::NotImplemented;
75}; 76};
76 77
77NvResult nvhost_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input, 78NvResult nvhost_gpu::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
78 const std::vector<u8>& inline_input, std::vector<u8>& output) { 79 const std::vector<u8>& inline_input, std::vector<u8>& output) {
79 switch (command.group) { 80 switch (command.group) {
80 case 'H': 81 case 'H':
@@ -88,12 +89,15 @@ NvResult nvhost_gpu::Ioctl2(Ioctl command, const std::vector<u8>& input,
88 return NvResult::NotImplemented; 89 return NvResult::NotImplemented;
89} 90}
90 91
91NvResult nvhost_gpu::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 92NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
92 std::vector<u8>& inline_output) { 93 std::vector<u8>& output, std::vector<u8>& inline_output) {
93 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 94 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
94 return NvResult::NotImplemented; 95 return NvResult::NotImplemented;
95} 96}
96 97
98void nvhost_gpu::OnOpen(DeviceFD fd) {}
99void nvhost_gpu::OnClose(DeviceFD fd) {}
100
97NvResult nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) { 101NvResult nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) {
98 IoctlSetNvmapFD params{}; 102 IoctlSetNvmapFD params{};
99 std::memcpy(&params, input.data(), input.size()); 103 std::memcpy(&params, input.data(), input.size());
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
index e0298b4fe..12a1a1133 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
@@ -26,11 +26,15 @@ public:
26 SyncpointManager& syncpoint_manager); 26 SyncpointManager& syncpoint_manager);
27 ~nvhost_gpu() override; 27 ~nvhost_gpu() override;
28 28
29 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 29 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
30 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 30 std::vector<u8>& output) override;
31 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
31 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 32 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
32 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 33 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
33 std::vector<u8>& inline_output) override; 34 std::vector<u8>& output, std::vector<u8>& inline_output) override;
35
36 void OnOpen(DeviceFD fd) override;
37 void OnClose(DeviceFD fd) override;
34 38
35private: 39private:
36 enum class CtxObjects : u32_le { 40 enum class CtxObjects : u32_le {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
index ecba1dba1..c8031970b 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
@@ -16,7 +16,7 @@ nvhost_nvdec::nvhost_nvdec(Core::System& system, std::shared_ptr<nvmap> nvmap_de
16 : nvhost_nvdec_common(system, std::move(nvmap_dev), syncpoint_manager) {} 16 : nvhost_nvdec_common(system, std::move(nvmap_dev), syncpoint_manager) {}
17nvhost_nvdec::~nvhost_nvdec() = default; 17nvhost_nvdec::~nvhost_nvdec() = default;
18 18
19NvResult nvhost_nvdec::Ioctl1(Ioctl command, const std::vector<u8>& input, 19NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
20 std::vector<u8>& output) { 20 std::vector<u8>& output) {
21 switch (command.group) { 21 switch (command.group) {
22 case 0x0: 22 case 0x0:
@@ -57,16 +57,19 @@ NvResult nvhost_nvdec::Ioctl1(Ioctl command, const std::vector<u8>& input,
57 return NvResult::NotImplemented; 57 return NvResult::NotImplemented;
58} 58}
59 59
60NvResult nvhost_nvdec::Ioctl2(Ioctl command, const std::vector<u8>& input, 60NvResult nvhost_nvdec::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
61 const std::vector<u8>& inline_input, std::vector<u8>& output) { 61 const std::vector<u8>& inline_input, std::vector<u8>& output) {
62 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 62 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
63 return NvResult::NotImplemented; 63 return NvResult::NotImplemented;
64} 64}
65 65
66NvResult nvhost_nvdec::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 66NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
67 std::vector<u8>& inline_output) { 67 std::vector<u8>& output, std::vector<u8>& inline_output) {
68 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 68 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
69 return NvResult::NotImplemented; 69 return NvResult::NotImplemented;
70} 70}
71 71
72void nvhost_nvdec::OnOpen(DeviceFD fd) {}
73void nvhost_nvdec::OnClose(DeviceFD fd) {}
74
72} // namespace Service::Nvidia::Devices 75} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
index 77ef53cdd..6c38a8c24 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
@@ -15,11 +15,15 @@ public:
15 SyncpointManager& syncpoint_manager); 15 SyncpointManager& syncpoint_manager);
16 ~nvhost_nvdec() override; 16 ~nvhost_nvdec() override;
17 17
18 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 18 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
19 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 19 std::vector<u8>& output) override;
20 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
20 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 21 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
21 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 22 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
22 std::vector<u8>& inline_output) override; 23 std::vector<u8>& output, std::vector<u8>& inline_output) override;
24
25 void OnOpen(DeviceFD fd) override;
26 void OnClose(DeviceFD fd) override;
23}; 27};
24 28
25} // namespace Service::Nvidia::Devices 29} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
index 2d06955c0..0a9c35c01 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
@@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices {
13nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {} 13nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {}
14nvhost_nvjpg::~nvhost_nvjpg() = default; 14nvhost_nvjpg::~nvhost_nvjpg() = default;
15 15
16NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input, 16NvResult nvhost_nvjpg::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
17 std::vector<u8>& output) { 17 std::vector<u8>& output) {
18 switch (command.group) { 18 switch (command.group) {
19 case 'H': 19 case 'H':
@@ -32,18 +32,21 @@ NvResult nvhost_nvjpg::Ioctl1(Ioctl command, const std::vector<u8>& input,
32 return NvResult::NotImplemented; 32 return NvResult::NotImplemented;
33} 33}
34 34
35NvResult nvhost_nvjpg::Ioctl2(Ioctl command, const std::vector<u8>& input, 35NvResult nvhost_nvjpg::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
36 const std::vector<u8>& inline_input, std::vector<u8>& output) { 36 const std::vector<u8>& inline_input, std::vector<u8>& output) {
37 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 37 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
38 return NvResult::NotImplemented; 38 return NvResult::NotImplemented;
39} 39}
40 40
41NvResult nvhost_nvjpg::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 41NvResult nvhost_nvjpg::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
42 std::vector<u8>& inline_output) { 42 std::vector<u8>& output, std::vector<u8>& inline_output) {
43 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 43 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
44 return NvResult::NotImplemented; 44 return NvResult::NotImplemented;
45} 45}
46 46
47void nvhost_nvjpg::OnOpen(DeviceFD fd) {}
48void nvhost_nvjpg::OnClose(DeviceFD fd) {}
49
47NvResult nvhost_nvjpg::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) { 50NvResult nvhost_nvjpg::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) {
48 IoctlSetNvmapFD params{}; 51 IoctlSetNvmapFD params{};
49 std::memcpy(&params, input.data(), input.size()); 52 std::memcpy(&params, input.data(), input.size());
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
index 43948d18d..1f97b642f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
@@ -16,11 +16,15 @@ public:
16 explicit nvhost_nvjpg(Core::System& system); 16 explicit nvhost_nvjpg(Core::System& system);
17 ~nvhost_nvjpg() override; 17 ~nvhost_nvjpg() override;
18 18
19 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 19 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
20 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 20 std::vector<u8>& output) override;
21 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
21 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 22 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
22 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 23 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
23 std::vector<u8>& inline_output) override; 24 std::vector<u8>& output, std::vector<u8>& inline_output) override;
25
26 void OnOpen(DeviceFD fd) override;
27 void OnClose(DeviceFD fd) override;
24 28
25private: 29private:
26 struct IoctlSetNvmapFD { 30 struct IoctlSetNvmapFD {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index 70849a9bd..0421fb956 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -16,7 +16,8 @@ nvhost_vic::nvhost_vic(Core::System& system, std::shared_ptr<nvmap> nvmap_dev,
16 16
17nvhost_vic::~nvhost_vic() = default; 17nvhost_vic::~nvhost_vic() = default;
18 18
19NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 19NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
20 std::vector<u8>& output) {
20 switch (command.group) { 21 switch (command.group) {
21 case 0x0: 22 case 0x0:
22 switch (command.cmd) { 23 switch (command.cmd) {
@@ -55,16 +56,19 @@ NvResult nvhost_vic::Ioctl1(Ioctl command, const std::vector<u8>& input, std::ve
55 return NvResult::NotImplemented; 56 return NvResult::NotImplemented;
56} 57}
57 58
58NvResult nvhost_vic::Ioctl2(Ioctl command, const std::vector<u8>& input, 59NvResult nvhost_vic::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
59 const std::vector<u8>& inline_input, std::vector<u8>& output) { 60 const std::vector<u8>& inline_input, std::vector<u8>& output) {
60 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 61 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
61 return NvResult::NotImplemented; 62 return NvResult::NotImplemented;
62} 63}
63 64
64NvResult nvhost_vic::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 65NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
65 std::vector<u8>& inline_output) { 66 std::vector<u8>& output, std::vector<u8>& inline_output) {
66 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 67 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
67 return NvResult::NotImplemented; 68 return NvResult::NotImplemented;
68} 69}
69 70
71void nvhost_vic::OnOpen(DeviceFD fd) {}
72void nvhost_vic::OnClose(DeviceFD fd) {}
73
70} // namespace Service::Nvidia::Devices 74} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.h b/src/core/hle/service/nvdrv/devices/nvhost_vic.h
index f401c61fa..cebefad71 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.h
@@ -14,10 +14,14 @@ public:
14 SyncpointManager& syncpoint_manager); 14 SyncpointManager& syncpoint_manager);
15 ~nvhost_vic(); 15 ~nvhost_vic();
16 16
17 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 17 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
18 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 18 std::vector<u8>& output) override;
19 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
19 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 20 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
20 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 21 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
21 std::vector<u8>& inline_output) override; 22 std::vector<u8>& output, std::vector<u8>& inline_output) override;
23
24 void OnOpen(DeviceFD fd) override;
25 void OnClose(DeviceFD fd) override;
22}; 26};
23} // namespace Service::Nvidia::Devices 27} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 4015a2740..dd1355522 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -19,7 +19,8 @@ nvmap::nvmap(Core::System& system) : nvdevice(system) {
19 19
20nvmap::~nvmap() = default; 20nvmap::~nvmap() = default;
21 21
22NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) { 22NvResult nvmap::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
23 std::vector<u8>& output) {
23 switch (command.group) { 24 switch (command.group) {
24 case 0x1: 25 case 0x1:
25 switch (command.cmd) { 26 switch (command.cmd) {
@@ -47,18 +48,21 @@ NvResult nvmap::Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<
47 return NvResult::NotImplemented; 48 return NvResult::NotImplemented;
48} 49}
49 50
50NvResult nvmap::Ioctl2(Ioctl command, const std::vector<u8>& input, 51NvResult nvmap::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
51 const std::vector<u8>& inline_input, std::vector<u8>& output) { 52 const std::vector<u8>& inline_input, std::vector<u8>& output) {
52 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 53 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
53 return NvResult::NotImplemented; 54 return NvResult::NotImplemented;
54} 55}
55 56
56NvResult nvmap::Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 57NvResult nvmap::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
57 std::vector<u8>& inline_output) { 58 std::vector<u8>& output, std::vector<u8>& inline_output) {
58 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw); 59 UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
59 return NvResult::NotImplemented; 60 return NvResult::NotImplemented;
60} 61}
61 62
63void nvmap::OnOpen(DeviceFD fd) {}
64void nvmap::OnClose(DeviceFD fd) {}
65
62VAddr nvmap::GetObjectAddress(u32 handle) const { 66VAddr nvmap::GetObjectAddress(u32 handle) const {
63 auto object = GetObject(handle); 67 auto object = GetObject(handle);
64 ASSERT(object); 68 ASSERT(object);
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h
index 4484bd79f..208875845 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.h
+++ b/src/core/hle/service/nvdrv/devices/nvmap.h
@@ -19,11 +19,15 @@ public:
19 explicit nvmap(Core::System& system); 19 explicit nvmap(Core::System& system);
20 ~nvmap() override; 20 ~nvmap() override;
21 21
22 NvResult Ioctl1(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override; 22 NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
23 NvResult Ioctl2(Ioctl command, const std::vector<u8>& input, 23 std::vector<u8>& output) override;
24 NvResult Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
24 const std::vector<u8>& inline_input, std::vector<u8>& output) override; 25 const std::vector<u8>& inline_input, std::vector<u8>& output) override;
25 NvResult Ioctl3(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 26 NvResult Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
26 std::vector<u8>& inline_output) override; 27 std::vector<u8>& output, std::vector<u8>& inline_output) override;
28
29 void OnOpen(DeviceFD fd) override;
30 void OnClose(DeviceFD fd) override;
27 31
28 /// Returns the allocated address of an nvmap object given its handle. 32 /// Returns the allocated address of an nvmap object given its handle.
29 VAddr GetObjectAddress(u32 handle) const; 33 VAddr GetObjectAddress(u32 handle) const;
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index abba80112..ede77858a 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -89,6 +89,8 @@ DeviceFD Module::Open(const std::string& device_name) {
89 auto device = devices[device_name]; 89 auto device = devices[device_name];
90 const DeviceFD fd = next_fd++; 90 const DeviceFD fd = next_fd++;
91 91
92 device->OnOpen(fd);
93
92 open_files[fd] = std::move(device); 94 open_files[fd] = std::move(device);
93 95
94 return fd; 96 return fd;
@@ -108,7 +110,7 @@ NvResult Module::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input
108 return NvResult::NotImplemented; 110 return NvResult::NotImplemented;
109 } 111 }
110 112
111 return itr->second->Ioctl1(command, input, output); 113 return itr->second->Ioctl1(fd, command, input, output);
112} 114}
113 115
114NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input, 116NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
@@ -125,7 +127,7 @@ NvResult Module::Ioctl2(DeviceFD fd, Ioctl command, const std::vector<u8>& input
125 return NvResult::NotImplemented; 127 return NvResult::NotImplemented;
126 } 128 }
127 129
128 return itr->second->Ioctl2(command, input, inline_input, output); 130 return itr->second->Ioctl2(fd, command, input, inline_input, output);
129} 131}
130 132
131NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input, 133NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
@@ -142,7 +144,7 @@ NvResult Module::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input
142 return NvResult::NotImplemented; 144 return NvResult::NotImplemented;
143 } 145 }
144 146
145 return itr->second->Ioctl3(command, input, output, inline_output); 147 return itr->second->Ioctl3(fd, command, input, output, inline_output);
146} 148}
147 149
148NvResult Module::Close(DeviceFD fd) { 150NvResult Module::Close(DeviceFD fd) {
@@ -158,6 +160,8 @@ NvResult Module::Close(DeviceFD fd) {
158 return NvResult::NotImplemented; 160 return NvResult::NotImplemented;
159 } 161 }
160 162
163 itr->second->OnClose(fd);
164
161 open_files.erase(itr); 165 open_files.erase(itr);
162 166
163 return NvResult::Success; 167 return NvResult::Success;
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 34d396434..697cb16b9 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -51,7 +51,7 @@ constexpr std::array REQUIRED_EXTENSIONS{
51#ifdef _WIN32 51#ifdef _WIN32
52 VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, 52 VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
53#endif 53#endif
54#ifdef __linux__ 54#ifdef __unix__
55 VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, 55 VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
56#endif 56#endif
57}; 57};
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
index 2a8b7a907..fa37aa79a 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
@@ -62,7 +62,7 @@ public:
62 : memory{std::move(memory_)}, allocation_size{allocation_size_}, property_flags{properties}, 62 : memory{std::move(memory_)}, allocation_size{allocation_size_}, property_flags{properties},
63 shifted_memory_type{1U << type} {} 63 shifted_memory_type{1U << type} {}
64 64
65#if defined(_WIN32) || defined(__linux__) 65#if defined(_WIN32) || defined(__unix__)
66 ~MemoryAllocation() { 66 ~MemoryAllocation() {
67 if (owning_opengl_handle != 0) { 67 if (owning_opengl_handle != 0) {
68 glDeleteMemoryObjectsEXT(1, &owning_opengl_handle); 68 glDeleteMemoryObjectsEXT(1, &owning_opengl_handle);
@@ -114,7 +114,7 @@ public:
114 } 114 }
115 return owning_opengl_handle; 115 return owning_opengl_handle;
116 } 116 }
117#elif __linux__ 117#elif __unix__
118 [[nodiscard]] u32 ExportOpenGLHandle() { 118 [[nodiscard]] u32 ExportOpenGLHandle() {
119 if (!owning_opengl_handle) { 119 if (!owning_opengl_handle) {
120 glCreateMemoryObjectsEXT(1, &owning_opengl_handle); 120 glCreateMemoryObjectsEXT(1, &owning_opengl_handle);
@@ -165,7 +165,7 @@ private:
165 const u32 shifted_memory_type; ///< Shifted Vulkan memory type. 165 const u32 shifted_memory_type; ///< Shifted Vulkan memory type.
166 std::vector<Range> commits; ///< All commit ranges done from this allocation. 166 std::vector<Range> commits; ///< All commit ranges done from this allocation.
167 std::span<u8> memory_mapped_span; ///< Memory mapped span. Empty if not queried before. 167 std::span<u8> memory_mapped_span; ///< Memory mapped span. Empty if not queried before.
168#if defined(_WIN32) || defined(__linux__) 168#if defined(_WIN32) || defined(__unix__)
169 u32 owning_opengl_handle{}; ///< Owning OpenGL memory object handle. 169 u32 owning_opengl_handle{}; ///< Owning OpenGL memory object handle.
170#endif 170#endif
171}; 171};
@@ -249,7 +249,7 @@ void MemoryAllocator::AllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, u6
249 .pNext = nullptr, 249 .pNext = nullptr,
250#ifdef _WIN32 250#ifdef _WIN32
251 .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, 251 .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT,
252#elif __linux__ 252#elif __unix__
253 .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, 253 .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
254#else 254#else
255 .handleTypes = 0, 255 .handleTypes = 0,