summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-01-04 18:57:12 +1000
committerMike Lothian <mike@fireburn.co.uk>2025-05-11 12:17:03 +0100
commitde5f95c477e8c1108ebf092c28e60f71bd009e53 (patch)
treec70862c72fe31c8d19322e13226e827d0d8e9f21 /src
parent57fee6e5706913cd3b0f412919a683b95d27058e (diff)
nvdrv: Implement ZBCSetTable functionality
Implements basic Zero Bandwidth Clear (ZBC) table support in nvhost_ctrl_gpu. This adds storage and validation for both color and depth clear values, replacing the previous stub implementation. ZBC is a hardware optimization technique used by NVIDIA GPUs to efficiently handle buffer clearing operations. Changes include: - Added ZBC table storage structures - Implemented parameter validation - Added separate handling for color and depth modes - Improved debug logging - Added documentation explaining ZBC functionality
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp26
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h20
2 files changed, 44 insertions, 2 deletions
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 ddd85678b..f842570d7 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -223,8 +223,30 @@ NvResult nvhost_ctrl_gpu::ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params) {
}
NvResult nvhost_ctrl_gpu::ZBCSetTable(IoctlZbcSetTable& params) {
- LOG_WARNING(Service_NVDRV, "(STUBBED) called");
- // TODO(ogniK): What does this even actually do?
+ LOG_DEBUG(Service_NVDRV, "called with index={}, format={}, mode={}",
+ params.color_ds_table_index, params.format, params.mode);
+
+ // Validate parameters
+ if (params.color_ds_table_index >= MaxZBCTableSize || params.format >= MaxZBCFormats) {
+ return NvResult::InvalidArgument;
+ }
+
+ // Store the color/depth values
+ switch (params.mode) {
+ case ZBCTableMode::COLOR:
+ // Store color values
+ std::memcpy(zbc_color_table[params.color_ds_table_index].color_ds,
+ params.color_ds, sizeof(params.color_ds));
+ break;
+ case ZBCTableMode::DEPTH:
+ // Store depth values
+ std::memcpy(zbc_depth_table[params.color_ds_table_index].depth,
+ params.depth, sizeof(params.depth));
+ break;
+ default:
+ return NvResult::InvalidArgument;
+ }
+
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 d2ab05b21..3d14121ed 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
@@ -4,6 +4,7 @@
#pragma once
#include <vector>
+#include <array>
#include "common/common_funcs.h"
#include "common/common_types.h"
@@ -34,6 +35,25 @@ public:
Kernel::KEvent* QueryEvent(u32 event_id) override;
private:
+ static constexpr std::size_t MaxZBCTableSize = 16;
+ static constexpr std::size_t MaxZBCFormats = 32;
+
+ enum class ZBCTableMode : u32 {
+ COLOR = 0,
+ DEPTH = 1,
+ };
+
+ struct ZBCColorEntry {
+ u32 color_ds[4];
+ };
+
+ struct ZBCDepthEntry {
+ u32 depth[4];
+ };
+
+ std::array<ZBCColorEntry, MaxZBCTableSize> zbc_color_table{};
+ std::array<ZBCDepthEntry, MaxZBCTableSize> zbc_depth_table{};
+
struct IoctlGpuCharacteristics {
u32_le arch; // 0x120 (NVGPU_GPU_ARCH_GM200)
u32_le impl; // 0xB (NVGPU_GPU_IMPL_GM20B)