VERY experimental Nintendo Switch 2 emulator
C++
[nvdrv] Unstub Allocate Object Context (#104)
SDK-Chan46ddbea71c6b
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cppindex efc9cca1cc..63725e4055 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later@@ -192,11 +195,27 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params, DeviceFD fd) {}NvResult nvhost_gpu::AllocateObjectContext(IoctlAllocObjCtx& params) {- LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num={:X}, flags={:X}", params.class_num,- params.flags);+ LOG_DEBUG(Service_NVDRV, "called, class_num={:X}, flags={:X}, obj_id={:X}", params.class_num,+ params.flags, params.obj_id);- params.obj_id = 0x0;- return NvResult::Success;+ if (!channel_state->initialized) {+ LOG_CRITICAL(Service_NVDRV, "No address space bound to allocate a object context!");+ return NvResult::NotInitialized;+ }++ switch (static_cast<CtxClasses>(params.class_num)) {+ case CtxClasses::Ctx2D:+ case CtxClasses::Ctx3D:+ case CtxClasses::CtxCompute:+ case CtxClasses::CtxKepler:+ case CtxClasses::CtxDMA:+ case CtxClasses::CtxChannelGPFIFO:+ ctxObj_params.push_back(params);+ return NvResult::Success;+ default:+ LOG_ERROR(Service_NVDRV, "Invalid class number for object context: {:X}", params.class_num);+ return NvResult::BadParameter;+ }}static boost::container::small_vector<Tegra::CommandHeader, 512> BuildWaitCommandList(diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.hindex e0aeef9536..040de78734 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later@@ -54,7 +57,7 @@ public:private:friend class nvhost_as_gpu;- enum class CtxObjects : u32_le {+ enum class CtxClasses : u32_le {Ctx2D = 0x902D,Ctx3D = 0xB197,CtxCompute = 0xB1C0,@@ -183,6 +186,7 @@ private:s32_le nvmap_fd{};u64_le user_data{};IoctlZCullBind zcull_params{};+ std::vector<IoctlAllocObjCtx> ctxObj_params{};u32_le channel_priority{};u32_le channel_timeslice{};