From 3f151c51114fd1e9c9ab0f379e0ff3045c400b75 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Wed, 8 Jan 2025 21:16:04 +1000 Subject: [PATCH] nvdrv: Add MSVC compatibility for packed structs Add conditional compilation directives to handle packed struct definitions differently between MSVC and other compilers. MSVC uses #pragma pack while GCC/Clang use __attribute__((packed)). This change affects: - ZBCColorEntry - ZBCDepthEntry - IoctlZbcSetTable The functionality remains the same, but ensures proper struct packing across different compiler environments. --- .../service/nvdrv/devices/nvhost_ctrl_gpu.h | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 2ad752c07..232b0e310 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -45,11 +45,19 @@ private: struct ZBCColorEntry { u32 color_ds[4]; +#ifdef _MSC_VER + }; +#else } __attribute__((packed)); +#endif struct ZBCDepthEntry { u32 depth[4]; +#ifdef _MSC_VER + }; +#else } __attribute__((packed)); +#endif std::array zbc_color_table{}; std::array zbc_depth_table{}; @@ -139,6 +147,7 @@ private: static_assert(sizeof(IoctlNvgpuGpuZcullGetInfoArgs) == 40, "IoctlNvgpuGpuZcullGetInfoArgs is incorrect size"); +#ifdef _MSC_VER #pragma pack(push, 1) struct IoctlZbcSetTable { u32 color_ds_table_index; @@ -147,8 +156,18 @@ private: u32 color_ds[4]; // 16 bytes u32 color_l2[4]; // 16 bytes u32 depth; // 4 bytes - } __attribute__((packed)); // Use GCC's packed attribute + }; #pragma pack(pop) +#else + struct IoctlZbcSetTable { + u32 color_ds_table_index; + u32 format; + u32 mode; + u32 color_ds[4]; // 16 bytes + u32 color_l2[4]; // 16 bytes + u32 depth; // 4 bytes + } __attribute__((packed)); +#endif static_assert(sizeof(IoctlZbcSetTable) == 48, "IoctlZbcSetTable is incorrect size");