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
This commit is contained in:
Zephyron 2025-01-04 18:57:12 +10:00
parent e11c6c03ec
commit 9be4bf9aa5
No known key found for this signature in database
GPG key ID: 8DA271B6A74353F1
2 changed files with 44 additions and 2 deletions

View file

@ -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;
}

View file

@ -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)