From c0d2bbdcd52d5cb3971af7af96c9e77f7559cfb8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 19 Jul 2025 08:48:15 +0100 Subject: [PATCH] [nvdrv] ZBC table implement stubs --- .../service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 48 +++++++++++++++++++ .../service/nvdrv/devices/nvhost_ctrl_gpu.h | 12 +++++ 2 files changed, 60 insertions(+) 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 1b8f575586..6c7b8c8e62 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -231,12 +231,60 @@ NvResult nvhost_ctrl_gpu::ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params) { NvResult nvhost_ctrl_gpu::ZBCSetTable(IoctlZbcSetTable& params) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); + ZbcEntry entry = {}; + std::memset(&entry, 0, sizeof(entry)); // TODO(ogniK): What does this even actually do? + // TODO(myself): This thing I guess + if (params.type == 1) { + for (auto i = 0; i < 4; ++i) { + entry.color_ds[i] = params.color_ds[i]; + entry.color_l2[i] = params.color_l2[i]; + } + ASSERT(this->max_color_entries < 16); + this->color_entries[this->max_color_entries] = entry; + ++this->max_color_entries; + } else if (params.type == 2) { + entry.depth = params.depth; + ASSERT(this->max_depth_entries < 16); + this->depth_entries[this->max_depth_entries] = entry; + ++this->max_depth_entries; + } return NvResult::Success; } NvResult nvhost_ctrl_gpu::ZBCQueryTable(IoctlZbcQueryTable& params) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); + struct ZbcQueryParams { + u32_le color_ds[4]; + u32_le color_l2[4]; + u32_le depth; + u32_le ref_cnt; + u32_le format; + u32_le type; + u32_le index_size; + } entry = {}; + std::memset(&entry, 0, sizeof(entry)); + auto const index = param.index_size; + if (params.type == 0) { //no + entry.index_size = 15; + } else if (param.type == 1) { //color + ASSERT(index < 16); + for (auto i = 0; i < 4; ++i) { + params.color_ds[i] = this->color_entries[index].color_ds[i]; + params.color_l2[i] = this->color_entries[index].color_l2[i]; + } + // TODO: Only if no error thrown (otherwise dont modify) + params.format = this->color_entries[index].format; + params.ref_cnt = this->color_entries[index].ref_cnt; + } else if (param.type == 2) { //depth + ASSERT(index < 16); + params.depth = this->depth_entries[index].depth; + // TODO: Only if no error thrown (otherwise dont modify) + params.format = this->depth_entries[index].format; + params.ref_cnt = this->depth_entries[index].ref_cnt; + } else { + UNREACHABLE(); + } return NvResult::Success; } 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 d2ab05b214..199350fb38 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -171,6 +171,18 @@ private: // Events Kernel::KEvent* error_notifier_event; Kernel::KEvent* unknown_event; + + struct ZbcEntry { + u32_le color_ds[4]; + u32_le color_l2[4]; + u32_le depth; + u32_le type; + u32_le format; + }; + std::array color_entries; + std::array depth_entries; + u8 max_color_entries; + u8 max_depth_entries; }; } // namespace Service::Nvidia::Devices