From 680384f7b831189bc55715373086fa5f0f060af1 Mon Sep 17 00:00:00 2001 From: SDK Chan Date: Sat, 15 Nov 2025 14:49:43 +0100 Subject: [PATCH] [gpu/NVDRV] Unstub SetChannelPriority and adjust ChannelSetTimeSlice (#3017) Games usually rely on either 1 of this services or both. The last call adjusts channel_timeslice. This behavior closely resembles Ryujinx accurate behavior for setting the channel_timeslice accordingly to the situation. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3017 Reviewed-by: Caio Oliveira Reviewed-by: crueter Co-authored-by: SDK Chan Co-committed-by: SDK Chan --- src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 14 +++++++++++++- src/core/hle/service/nvdrv/devices/nvhost_gpu.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 5f754650d9..fcc7f9d392 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -168,7 +168,15 @@ NvResult nvhost_gpu::SetErrorNotifier(IoctlSetErrorNotifier& params) { NvResult nvhost_gpu::SetChannelPriority(IoctlChannelSetPriority& params) { channel_priority = params.priority; - LOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority={:X}", channel_priority); + LOG_INFO(Service_NVDRV, "called, priority={:X}", channel_priority); + + switch (static_cast(channel_priority)) { + case ChannelPriority::Low: channel_timeslice = 1300; break; + case ChannelPriority::Medium: channel_timeslice = 2600; break; + case ChannelPriority::High: channel_timeslice = 5200; break; + default : return NvResult::BadParameter; + } + return NvResult::Success; } @@ -402,6 +410,10 @@ NvResult nvhost_gpu::ChannelSetTimeout(IoctlChannelSetTimeout& params) { NvResult nvhost_gpu::ChannelSetTimeslice(IoctlSetTimeslice& params) { LOG_INFO(Service_NVDRV, "called, timeslice={:#X}", params.timeslice); + if (params.timeslice < 1000 || params.timeslice > 5000) { + return NvResult::BadParameter; + } + channel_timeslice = params.timeslice; return NvResult::Success; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index fb0a5be959..b8854aab95 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h @@ -66,6 +66,12 @@ private: CtxChannelGPFIFO = 0xB06F, }; + enum class ChannelPriority : u32 { + Low = 0x32, + Medium = 0x64, + High = 0x96, + }; + struct IoctlSetNvmapFD { s32_le nvmap_fd{}; };