summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-01-08 21:16:04 +1000
committerZephyron <zephyron@citron-emu.org>2025-01-08 21:16:04 +1000
commit3f151c51114fd1e9c9ab0f379e0ff3045c400b75 (patch)
tree6fad5f034e3bc6b9f12c1452129ccc5516da02cc /src
parentc65c8ac45e1e795549942cde6d455a0437635f31 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h21
1 files changed, 20 insertions, 1 deletions
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<ZBCColorEntry, MaxZBCTableSize> zbc_color_table{};
std::array<ZBCDepthEntry, MaxZBCTableSize> 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");