yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

common_func: Use std::array for INSERT_PADDING_* macros.

- Zero initialization here is useful for determinism.
This commit is contained in:
bunnei 2019-11-03 18:54:03 -05:00
parent ae6eb61892
commit 1bdae0fe29
14 changed files with 166 additions and 158 deletions

View File

@ -36,6 +36,13 @@
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/swap.h" #include "common/swap.h"
// Inlining
#ifdef _WIN32
#define FORCE_INLINE __forceinline
#else
#define FORCE_INLINE inline __attribute__((always_inline))
#endif
/* /*
* Abstract bitfield class * Abstract bitfield class
* *

View File

@ -1,10 +1,11 @@
// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project // Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <array>
#include <string> #include <string>
#if !defined(ARCHITECTURE_x86_64) #if !defined(ARCHITECTURE_x86_64)
@ -16,18 +17,15 @@
#define CONCAT2(x, y) DO_CONCAT2(x, y) #define CONCAT2(x, y) DO_CONCAT2(x, y)
#define DO_CONCAT2(x, y) x##y #define DO_CONCAT2(x, y) x##y
// helper macro to properly align structure members. /// Helper macros to insert unused bytes or words to properly align structs. These values will be
// Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", /// zero-initialized.
// depending on the current source line to make sure variable names are unique. #define INSERT_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__){};
#define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)] #define INSERT_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__){};
#define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)]
// Inlining /// These are similar to the INSERT_PADDING_* macros, but are needed for padding unions. This is
#ifdef _WIN32 /// because unions can only be initialized by one member.
#define FORCE_INLINE __forceinline #define INSERT_UNION_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__);
#else #define INSERT_UNION_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__);
#define FORCE_INLINE inline __attribute__((always_inline))
#endif
#ifndef _MSC_VER #ifndef _MSC_VER

View File

@ -32,11 +32,28 @@ enum class NCASectionFilesystemType : u8 {
ROMFS = 0x3, ROMFS = 0x3,
}; };
struct IVFCLevel {
u64_le offset;
u64_le size;
u32_le block_size;
u32_le reserved;
};
static_assert(sizeof(IVFCLevel) == 0x18, "IVFCLevel has incorrect size.");
struct IVFCHeader {
u32_le magic;
u32_le magic_number;
INSERT_UNION_PADDING_BYTES(8);
std::array<IVFCLevel, 6> levels;
INSERT_UNION_PADDING_BYTES(64);
};
static_assert(sizeof(IVFCHeader) == 0xE0, "IVFCHeader has incorrect size.");
struct NCASectionHeaderBlock { struct NCASectionHeaderBlock {
INSERT_PADDING_BYTES(3); INSERT_UNION_PADDING_BYTES(3);
NCASectionFilesystemType filesystem_type; NCASectionFilesystemType filesystem_type;
NCASectionCryptoType crypto_type; NCASectionCryptoType crypto_type;
INSERT_PADDING_BYTES(3); INSERT_UNION_PADDING_BYTES(3);
}; };
static_assert(sizeof(NCASectionHeaderBlock) == 0x8, "NCASectionHeaderBlock has incorrect size."); static_assert(sizeof(NCASectionHeaderBlock) == 0x8, "NCASectionHeaderBlock has incorrect size.");
@ -44,7 +61,7 @@ struct NCASectionRaw {
NCASectionHeaderBlock header; NCASectionHeaderBlock header;
std::array<u8, 0x138> block_data; std::array<u8, 0x138> block_data;
std::array<u8, 0x8> section_ctr; std::array<u8, 0x8> section_ctr;
INSERT_PADDING_BYTES(0xB8); INSERT_UNION_PADDING_BYTES(0xB8);
}; };
static_assert(sizeof(NCASectionRaw) == 0x200, "NCASectionRaw has incorrect size."); static_assert(sizeof(NCASectionRaw) == 0x200, "NCASectionRaw has incorrect size.");
@ -52,19 +69,19 @@ struct PFS0Superblock {
NCASectionHeaderBlock header_block; NCASectionHeaderBlock header_block;
std::array<u8, 0x20> hash; std::array<u8, 0x20> hash;
u32_le size; u32_le size;
INSERT_PADDING_BYTES(4); INSERT_UNION_PADDING_BYTES(4);
u64_le hash_table_offset; u64_le hash_table_offset;
u64_le hash_table_size; u64_le hash_table_size;
u64_le pfs0_header_offset; u64_le pfs0_header_offset;
u64_le pfs0_size; u64_le pfs0_size;
INSERT_PADDING_BYTES(0x1B0); INSERT_UNION_PADDING_BYTES(0x1B0);
}; };
static_assert(sizeof(PFS0Superblock) == 0x200, "PFS0Superblock has incorrect size."); static_assert(sizeof(PFS0Superblock) == 0x200, "PFS0Superblock has incorrect size.");
struct RomFSSuperblock { struct RomFSSuperblock {
NCASectionHeaderBlock header_block; NCASectionHeaderBlock header_block;
IVFCHeader ivfc; IVFCHeader ivfc;
INSERT_PADDING_BYTES(0x118); INSERT_UNION_PADDING_BYTES(0x118);
}; };
static_assert(sizeof(RomFSSuperblock) == 0x200, "RomFSSuperblock has incorrect size."); static_assert(sizeof(RomFSSuperblock) == 0x200, "RomFSSuperblock has incorrect size.");
@ -72,24 +89,24 @@ struct BKTRHeader {
u64_le offset; u64_le offset;
u64_le size; u64_le size;
u32_le magic; u32_le magic;
INSERT_PADDING_BYTES(0x4); INSERT_UNION_PADDING_BYTES(0x4);
u32_le number_entries; u32_le number_entries;
INSERT_PADDING_BYTES(0x4); INSERT_UNION_PADDING_BYTES(0x4);
}; };
static_assert(sizeof(BKTRHeader) == 0x20, "BKTRHeader has incorrect size."); static_assert(sizeof(BKTRHeader) == 0x20, "BKTRHeader has incorrect size.");
struct BKTRSuperblock { struct BKTRSuperblock {
NCASectionHeaderBlock header_block; NCASectionHeaderBlock header_block;
IVFCHeader ivfc; IVFCHeader ivfc;
INSERT_PADDING_BYTES(0x18); INSERT_UNION_PADDING_BYTES(0x18);
BKTRHeader relocation; BKTRHeader relocation;
BKTRHeader subsection; BKTRHeader subsection;
INSERT_PADDING_BYTES(0xC0); INSERT_UNION_PADDING_BYTES(0xC0);
}; };
static_assert(sizeof(BKTRSuperblock) == 0x200, "BKTRSuperblock has incorrect size."); static_assert(sizeof(BKTRSuperblock) == 0x200, "BKTRSuperblock has incorrect size.");
union NCASectionHeader { union NCASectionHeader {
NCASectionRaw raw; NCASectionRaw raw{};
PFS0Superblock pfs0; PFS0Superblock pfs0;
RomFSSuperblock romfs; RomFSSuperblock romfs;
BKTRSuperblock bktr; BKTRSuperblock bktr;

View File

@ -13,25 +13,6 @@
namespace FileSys { namespace FileSys {
struct RomFSHeader;
struct IVFCLevel {
u64_le offset;
u64_le size;
u32_le block_size;
u32_le reserved;
};
static_assert(sizeof(IVFCLevel) == 0x18, "IVFCLevel has incorrect size.");
struct IVFCHeader {
u32_le magic;
u32_le magic_number;
INSERT_PADDING_BYTES(8);
std::array<IVFCLevel, 6> levels;
INSERT_PADDING_BYTES(64);
};
static_assert(sizeof(IVFCHeader) == 0xE0, "IVFCHeader has incorrect size.");
enum class RomFSExtractionType { enum class RomFSExtractionType {
Full, // Includes data directory Full, // Includes data directory
Truncated, // Traverses into data directory Truncated, // Traverses into data directory

View File

@ -160,7 +160,7 @@ struct DomainMessageHeader {
// Used when responding to an IPC request, Server -> Client. // Used when responding to an IPC request, Server -> Client.
struct { struct {
u32_le num_objects; u32_le num_objects;
INSERT_PADDING_WORDS(3); INSERT_UNION_PADDING_WORDS(3);
}; };
// Used when performing an IPC request, Client -> Server. // Used when performing an IPC request, Client -> Server.
@ -171,8 +171,10 @@ struct DomainMessageHeader {
BitField<16, 16, u32> size; BitField<16, 16, u32> size;
}; };
u32_le object_id; u32_le object_id;
INSERT_PADDING_WORDS(2); INSERT_UNION_PADDING_WORDS(2);
}; };
std::array<u32, 4> raw{};
}; };
}; };
static_assert(sizeof(DomainMessageHeader) == 16, "DomainMessageHeader size is incorrect"); static_assert(sizeof(DomainMessageHeader) == 16, "DomainMessageHeader size is incorrect");

View File

@ -20,9 +20,9 @@ namespace Service::AM::Applets {
struct ShowError { struct ShowError {
u8 mode; u8 mode;
bool jump; bool jump;
INSERT_PADDING_BYTES(4); INSERT_UNION_PADDING_BYTES(4);
bool use_64bit_error_code; bool use_64bit_error_code;
INSERT_PADDING_BYTES(1); INSERT_UNION_PADDING_BYTES(1);
u64 error_code_64; u64 error_code_64;
u32 error_code_32; u32 error_code_32;
}; };
@ -32,7 +32,7 @@ static_assert(sizeof(ShowError) == 0x14, "ShowError has incorrect size.");
struct ShowErrorRecord { struct ShowErrorRecord {
u8 mode; u8 mode;
bool jump; bool jump;
INSERT_PADDING_BYTES(6); INSERT_UNION_PADDING_BYTES(6);
u64 error_code_64; u64 error_code_64;
u64 posix_time; u64 posix_time;
}; };
@ -41,7 +41,7 @@ static_assert(sizeof(ShowErrorRecord) == 0x18, "ShowErrorRecord has incorrect si
struct SystemErrorArg { struct SystemErrorArg {
u8 mode; u8 mode;
bool jump; bool jump;
INSERT_PADDING_BYTES(6); INSERT_UNION_PADDING_BYTES(6);
u64 error_code_64; u64 error_code_64;
std::array<char, 8> language_code; std::array<char, 8> language_code;
std::array<char, 0x800> main_text; std::array<char, 0x800> main_text;
@ -52,7 +52,7 @@ static_assert(sizeof(SystemErrorArg) == 0x1018, "SystemErrorArg has incorrect si
struct ApplicationErrorArg { struct ApplicationErrorArg {
u8 mode; u8 mode;
bool jump; bool jump;
INSERT_PADDING_BYTES(6); INSERT_UNION_PADDING_BYTES(6);
u32 error_code; u32 error_code;
std::array<char, 8> language_code; std::array<char, 8> language_code;
std::array<char, 0x800> main_text; std::array<char, 0x800> main_text;
@ -65,6 +65,7 @@ union Error::ErrorArguments {
ShowErrorRecord error_record; ShowErrorRecord error_record;
SystemErrorArg system_error; SystemErrorArg system_error;
ApplicationErrorArg application_error; ApplicationErrorArg application_error;
std::array<u8, 0x1018> raw{};
}; };
namespace { namespace {

View File

@ -45,7 +45,7 @@ struct DisplayInfo {
/// Whether or not the display has a limited number of layers. /// Whether or not the display has a limited number of layers.
u8 has_limited_layers{1}; u8 has_limited_layers{1};
INSERT_PADDING_BYTES(7){}; INSERT_PADDING_BYTES(7);
/// Indicates the total amount of layers supported by the display. /// Indicates the total amount of layers supported by the display.
/// @note This is only valid if has_limited_layers is set. /// @note This is only valid if has_limited_layers is set.

View File

@ -99,19 +99,19 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0x80); INSERT_UNION_PADDING_WORDS(0x80);
Surface dst; Surface dst;
INSERT_PADDING_WORDS(2); INSERT_UNION_PADDING_WORDS(2);
Surface src; Surface src;
INSERT_PADDING_WORDS(0x15); INSERT_UNION_PADDING_WORDS(0x15);
Operation operation; Operation operation;
INSERT_PADDING_WORDS(0x177); INSERT_UNION_PADDING_WORDS(0x177);
union { union {
u32 raw; u32 raw;
@ -119,7 +119,7 @@ public:
BitField<4, 1, Filter> filter; BitField<4, 1, Filter> filter;
} blit_control; } blit_control;
INSERT_PADDING_WORDS(0x8); INSERT_UNION_PADDING_WORDS(0x8);
u32 blit_dst_x; u32 blit_dst_x;
u32 blit_dst_y; u32 blit_dst_y;
@ -130,7 +130,7 @@ public:
u64 blit_src_x; u64 blit_src_x;
u64 blit_src_y; u64 blit_src_y;
INSERT_PADDING_WORDS(0x21); INSERT_UNION_PADDING_WORDS(0x21);
}; };
std::array<u32, NUM_REGS> reg_array; std::array<u32, NUM_REGS> reg_array;
}; };

View File

@ -51,7 +51,7 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0x60); INSERT_UNION_PADDING_WORDS(0x60);
Upload::Registers upload; Upload::Registers upload;
@ -63,7 +63,7 @@ public:
u32 data_upload; u32 data_upload;
INSERT_PADDING_WORDS(0x3F); INSERT_UNION_PADDING_WORDS(0x3F);
struct { struct {
u32 address; u32 address;
@ -72,11 +72,11 @@ public:
} }
} launch_desc_loc; } launch_desc_loc;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
u32 launch; u32 launch;
INSERT_PADDING_WORDS(0x4A7); INSERT_UNION_PADDING_WORDS(0x4A7);
struct { struct {
u32 address_high; u32 address_high;
@ -88,7 +88,7 @@ public:
} }
} tsc; } tsc;
INSERT_PADDING_WORDS(0x3); INSERT_UNION_PADDING_WORDS(0x3);
struct { struct {
u32 address_high; u32 address_high;
@ -100,7 +100,7 @@ public:
} }
} tic; } tic;
INSERT_PADDING_WORDS(0x22); INSERT_UNION_PADDING_WORDS(0x22);
struct { struct {
u32 address_high; u32 address_high;
@ -111,11 +111,11 @@ public:
} }
} code_loc; } code_loc;
INSERT_PADDING_WORDS(0x3FE); INSERT_UNION_PADDING_WORDS(0x3FE);
u32 tex_cb_index; u32 tex_cb_index;
INSERT_PADDING_WORDS(0x374); INSERT_UNION_PADDING_WORDS(0x374);
}; };
std::array<u32, NUM_REGS> reg_array; std::array<u32, NUM_REGS> reg_array;
}; };
@ -179,7 +179,7 @@ public:
}; };
INSERT_PADDING_WORDS(0x11); INSERT_PADDING_WORDS(0x11);
} launch_description; } launch_description{};
struct { struct {
u32 write_offset = 0; u32 write_offset = 0;

View File

@ -45,7 +45,7 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0x60); INSERT_UNION_PADDING_WORDS(0x60);
Upload::Registers upload; Upload::Registers upload;
@ -57,7 +57,7 @@ public:
u32 data; u32 data;
INSERT_PADDING_WORDS(0x11); INSERT_UNION_PADDING_WORDS(0x11);
}; };
std::array<u32, NUM_REGS> reg_array; std::array<u32, NUM_REGS> reg_array;
}; };

View File

@ -496,7 +496,7 @@ public:
Equation equation_a; Equation equation_a;
Factor factor_source_a; Factor factor_source_a;
Factor factor_dest_a; Factor factor_dest_a;
INSERT_PADDING_WORDS(1); INSERT_UNION_PADDING_WORDS(1);
}; };
struct RenderTargetConfig { struct RenderTargetConfig {
@ -517,7 +517,7 @@ public:
}; };
u32 layer_stride; u32 layer_stride;
u32 base_layer; u32 base_layer;
INSERT_PADDING_WORDS(7); INSERT_UNION_PADDING_WORDS(7);
GPUVAddr Address() const { GPUVAddr Address() const {
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
@ -542,7 +542,7 @@ public:
f32 translate_x; f32 translate_x;
f32 translate_y; f32 translate_y;
f32 translate_z; f32 translate_z;
INSERT_PADDING_WORDS(2); INSERT_UNION_PADDING_WORDS(2);
Common::Rectangle<s32> GetRect() const { Common::Rectangle<s32> GetRect() const {
return { return {
@ -606,7 +606,7 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0x45); INSERT_UNION_PADDING_WORDS(0x45);
struct { struct {
u32 upload_address; u32 upload_address;
@ -615,7 +615,7 @@ public:
u32 bind; u32 bind;
} macros; } macros;
INSERT_PADDING_WORDS(0x17); INSERT_UNION_PADDING_WORDS(0x17);
Upload::Registers upload; Upload::Registers upload;
struct { struct {
@ -626,7 +626,7 @@ public:
u32 data_upload; u32 data_upload;
INSERT_PADDING_WORDS(0x44); INSERT_UNION_PADDING_WORDS(0x44);
struct { struct {
union { union {
@ -636,11 +636,11 @@ public:
}; };
} sync_info; } sync_info;
INSERT_PADDING_WORDS(0x11E); INSERT_UNION_PADDING_WORDS(0x11E);
u32 tfb_enabled; u32 tfb_enabled;
INSERT_PADDING_WORDS(0x2E); INSERT_UNION_PADDING_WORDS(0x2E);
std::array<RenderTargetConfig, NumRenderTargets> rt; std::array<RenderTargetConfig, NumRenderTargets> rt;
@ -648,49 +648,49 @@ public:
std::array<ViewPort, NumViewports> viewports; std::array<ViewPort, NumViewports> viewports;
INSERT_PADDING_WORDS(0x1D); INSERT_UNION_PADDING_WORDS(0x1D);
struct { struct {
u32 first; u32 first;
u32 count; u32 count;
} vertex_buffer; } vertex_buffer;
INSERT_PADDING_WORDS(1); INSERT_UNION_PADDING_WORDS(1);
float clear_color[4]; float clear_color[4];
float clear_depth; float clear_depth;
INSERT_PADDING_WORDS(0x3); INSERT_UNION_PADDING_WORDS(0x3);
s32 clear_stencil; s32 clear_stencil;
INSERT_PADDING_WORDS(0x7); INSERT_UNION_PADDING_WORDS(0x7);
u32 polygon_offset_point_enable; u32 polygon_offset_point_enable;
u32 polygon_offset_line_enable; u32 polygon_offset_line_enable;
u32 polygon_offset_fill_enable; u32 polygon_offset_fill_enable;
INSERT_PADDING_WORDS(0xD); INSERT_UNION_PADDING_WORDS(0xD);
std::array<ScissorTest, NumViewports> scissor_test; std::array<ScissorTest, NumViewports> scissor_test;
INSERT_PADDING_WORDS(0x15); INSERT_UNION_PADDING_WORDS(0x15);
s32 stencil_back_func_ref; s32 stencil_back_func_ref;
u32 stencil_back_mask; u32 stencil_back_mask;
u32 stencil_back_func_mask; u32 stencil_back_func_mask;
INSERT_PADDING_WORDS(0xC); INSERT_UNION_PADDING_WORDS(0xC);
u32 color_mask_common; u32 color_mask_common;
INSERT_PADDING_WORDS(0x6); INSERT_UNION_PADDING_WORDS(0x6);
u32 rt_separate_frag_data; u32 rt_separate_frag_data;
f32 depth_bounds[2]; f32 depth_bounds[2];
INSERT_PADDING_WORDS(0xA); INSERT_UNION_PADDING_WORDS(0xA);
struct { struct {
u32 address_high; u32 address_high;
@ -710,7 +710,7 @@ public:
} }
} zeta; } zeta;
INSERT_PADDING_WORDS(0x41); INSERT_UNION_PADDING_WORDS(0x41);
union { union {
BitField<0, 4, u32> stencil; BitField<0, 4, u32> stencil;
@ -719,11 +719,11 @@ public:
BitField<12, 4, u32> viewport; BitField<12, 4, u32> viewport;
} clear_flags; } clear_flags;
INSERT_PADDING_WORDS(0x19); INSERT_UNION_PADDING_WORDS(0x19);
std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format; std::array<VertexAttribute, NumVertexAttributes> vertex_attrib_format;
INSERT_PADDING_WORDS(0xF); INSERT_UNION_PADDING_WORDS(0xF);
struct { struct {
union { union {
@ -746,16 +746,16 @@ public:
} }
} rt_control; } rt_control;
INSERT_PADDING_WORDS(0x2); INSERT_UNION_PADDING_WORDS(0x2);
u32 zeta_width; u32 zeta_width;
u32 zeta_height; u32 zeta_height;
INSERT_PADDING_WORDS(0x27); INSERT_UNION_PADDING_WORDS(0x27);
u32 depth_test_enable; u32 depth_test_enable;
INSERT_PADDING_WORDS(0x5); INSERT_UNION_PADDING_WORDS(0x5);
u32 independent_blend_enable; u32 independent_blend_enable;
@ -763,7 +763,7 @@ public:
u32 alpha_test_enabled; u32 alpha_test_enabled;
INSERT_PADDING_WORDS(0x6); INSERT_UNION_PADDING_WORDS(0x6);
u32 d3d_cull_mode; u32 d3d_cull_mode;
@ -777,7 +777,7 @@ public:
float b; float b;
float a; float a;
} blend_color; } blend_color;
INSERT_PADDING_WORDS(0x4); INSERT_UNION_PADDING_WORDS(0x4);
struct { struct {
u32 separate_alpha; u32 separate_alpha;
@ -786,7 +786,7 @@ public:
Blend::Factor factor_dest_rgb; Blend::Factor factor_dest_rgb;
Blend::Equation equation_a; Blend::Equation equation_a;
Blend::Factor factor_source_a; Blend::Factor factor_source_a;
INSERT_PADDING_WORDS(1); INSERT_UNION_PADDING_WORDS(1);
Blend::Factor factor_dest_a; Blend::Factor factor_dest_a;
u32 enable_common; u32 enable_common;
@ -802,7 +802,7 @@ public:
u32 stencil_front_func_mask; u32 stencil_front_func_mask;
u32 stencil_front_mask; u32 stencil_front_mask;
INSERT_PADDING_WORDS(0x2); INSERT_UNION_PADDING_WORDS(0x2);
u32 frag_color_clamp; u32 frag_color_clamp;
@ -811,12 +811,12 @@ public:
BitField<4, 1, u32> triangle_rast_flip; BitField<4, 1, u32> triangle_rast_flip;
} screen_y_control; } screen_y_control;
INSERT_PADDING_WORDS(0x21); INSERT_UNION_PADDING_WORDS(0x21);
u32 vb_element_base; u32 vb_element_base;
u32 vb_base_instance; u32 vb_base_instance;
INSERT_PADDING_WORDS(0x35); INSERT_UNION_PADDING_WORDS(0x35);
union { union {
BitField<0, 1, u32> c0; BitField<0, 1, u32> c0;
@ -829,11 +829,11 @@ public:
BitField<7, 1, u32> c7; BitField<7, 1, u32> c7;
} clip_distance_enabled; } clip_distance_enabled;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
float point_size; float point_size;
INSERT_PADDING_WORDS(0x7); INSERT_UNION_PADDING_WORDS(0x7);
u32 zeta_enable; u32 zeta_enable;
@ -842,7 +842,7 @@ public:
BitField<4, 1, u32> alpha_to_one; BitField<4, 1, u32> alpha_to_one;
} multisample_control; } multisample_control;
INSERT_PADDING_WORDS(0x4); INSERT_UNION_PADDING_WORDS(0x4);
struct { struct {
u32 address_high; u32 address_high;
@ -866,11 +866,11 @@ public:
} }
} tsc; } tsc;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
float polygon_offset_factor; float polygon_offset_factor;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
struct { struct {
u32 tic_address_high; u32 tic_address_high;
@ -883,7 +883,7 @@ public:
} }
} tic; } tic;
INSERT_PADDING_WORDS(0x5); INSERT_UNION_PADDING_WORDS(0x5);
u32 stencil_two_side_enable; u32 stencil_two_side_enable;
StencilOp stencil_back_op_fail; StencilOp stencil_back_op_fail;
@ -891,13 +891,13 @@ public:
StencilOp stencil_back_op_zpass; StencilOp stencil_back_op_zpass;
ComparisonOp stencil_back_func_func; ComparisonOp stencil_back_func_func;
INSERT_PADDING_WORDS(0x4); INSERT_UNION_PADDING_WORDS(0x4);
u32 framebuffer_srgb; u32 framebuffer_srgb;
float polygon_offset_units; float polygon_offset_units;
INSERT_PADDING_WORDS(0x11); INSERT_UNION_PADDING_WORDS(0x11);
union { union {
BitField<2, 1, u32> coord_origin; BitField<2, 1, u32> coord_origin;
@ -913,7 +913,7 @@ public:
(static_cast<GPUVAddr>(code_address_high) << 32) | code_address_low); (static_cast<GPUVAddr>(code_address_high) << 32) | code_address_low);
} }
} code_address; } code_address;
INSERT_PADDING_WORDS(1); INSERT_UNION_PADDING_WORDS(1);
struct { struct {
u32 vertex_end_gl; u32 vertex_end_gl;
@ -925,14 +925,14 @@ public:
}; };
} draw; } draw;
INSERT_PADDING_WORDS(0xA); INSERT_UNION_PADDING_WORDS(0xA);
struct { struct {
u32 enabled; u32 enabled;
u32 index; u32 index;
} primitive_restart; } primitive_restart;
INSERT_PADDING_WORDS(0x5F); INSERT_UNION_PADDING_WORDS(0x5F);
struct { struct {
u32 start_addr_high; u32 start_addr_high;
@ -973,9 +973,9 @@ public:
} }
} index_array; } index_array;
INSERT_PADDING_WORDS(0x7); INSERT_UNION_PADDING_WORDS(0x7);
INSERT_PADDING_WORDS(0x1F); INSERT_UNION_PADDING_WORDS(0x1F);
float polygon_offset_clamp; float polygon_offset_clamp;
@ -989,17 +989,17 @@ public:
} }
} instanced_arrays; } instanced_arrays;
INSERT_PADDING_WORDS(0x6); INSERT_UNION_PADDING_WORDS(0x6);
Cull cull; Cull cull;
u32 pixel_center_integer; u32 pixel_center_integer;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
u32 viewport_transform_enabled; u32 viewport_transform_enabled;
INSERT_PADDING_WORDS(0x3); INSERT_UNION_PADDING_WORDS(0x3);
union { union {
BitField<0, 1, u32> depth_range_0_1; BitField<0, 1, u32> depth_range_0_1;
@ -1007,13 +1007,13 @@ public:
BitField<4, 1, u32> depth_clamp_far; BitField<4, 1, u32> depth_clamp_far;
} view_volume_clip_control; } view_volume_clip_control;
INSERT_PADDING_WORDS(0x21); INSERT_UNION_PADDING_WORDS(0x21);
struct { struct {
u32 enable; u32 enable;
LogicOperation operation; LogicOperation operation;
} logic_op; } logic_op;
INSERT_PADDING_WORDS(0x1); INSERT_UNION_PADDING_WORDS(0x1);
union { union {
u32 raw; u32 raw;
@ -1026,9 +1026,9 @@ public:
BitField<6, 4, u32> RT; BitField<6, 4, u32> RT;
BitField<10, 11, u32> layer; BitField<10, 11, u32> layer;
} clear_buffers; } clear_buffers;
INSERT_PADDING_WORDS(0xB); INSERT_UNION_PADDING_WORDS(0xB);
std::array<ColorMask, NumRenderTargets> color_mask; std::array<ColorMask, NumRenderTargets> color_mask;
INSERT_PADDING_WORDS(0x38); INSERT_UNION_PADDING_WORDS(0x38);
struct { struct {
u32 query_address_high; u32 query_address_high;
@ -1050,7 +1050,7 @@ public:
} }
} query; } query;
INSERT_PADDING_WORDS(0x3C); INSERT_UNION_PADDING_WORDS(0x3C);
struct { struct {
union { union {
@ -1090,10 +1090,10 @@ public:
BitField<4, 4, ShaderProgram> program; BitField<4, 4, ShaderProgram> program;
}; };
u32 offset; u32 offset;
INSERT_PADDING_WORDS(14); INSERT_UNION_PADDING_WORDS(14);
} shader_config[MaxShaderProgram]; } shader_config[MaxShaderProgram];
INSERT_PADDING_WORDS(0x60); INSERT_UNION_PADDING_WORDS(0x60);
u32 firmware[0x20]; u32 firmware[0x20];
@ -1110,7 +1110,7 @@ public:
} }
} const_buffer; } const_buffer;
INSERT_PADDING_WORDS(0x10); INSERT_UNION_PADDING_WORDS(0x10);
struct { struct {
union { union {
@ -1118,14 +1118,14 @@ public:
BitField<0, 1, u32> valid; BitField<0, 1, u32> valid;
BitField<4, 5, u32> index; BitField<4, 5, u32> index;
}; };
INSERT_PADDING_WORDS(7); INSERT_UNION_PADDING_WORDS(7);
} cb_bind[MaxShaderStage]; } cb_bind[MaxShaderStage];
INSERT_PADDING_WORDS(0x56); INSERT_UNION_PADDING_WORDS(0x56);
u32 tex_cb_index; u32 tex_cb_index;
INSERT_PADDING_WORDS(0x395); INSERT_UNION_PADDING_WORDS(0x395);
struct { struct {
/// Compressed address of a buffer that holds information about bound SSBOs. /// Compressed address of a buffer that holds information about bound SSBOs.
@ -1137,14 +1137,14 @@ public:
} }
} ssbo_info; } ssbo_info;
INSERT_PADDING_WORDS(0x11); INSERT_UNION_PADDING_WORDS(0x11);
struct { struct {
u32 address[MaxShaderStage]; u32 address[MaxShaderStage];
u32 size[MaxShaderStage]; u32 size[MaxShaderStage];
} tex_info_buffers; } tex_info_buffers;
INSERT_PADDING_WORDS(0xCC); INSERT_UNION_PADDING_WORDS(0xCC);
}; };
std::array<u32, NUM_REGS> reg_array; std::array<u32, NUM_REGS> reg_array;
}; };

View File

@ -94,7 +94,7 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0xC0); INSERT_UNION_PADDING_WORDS(0xC0);
struct { struct {
union { union {
@ -112,7 +112,7 @@ public:
}; };
} exec; } exec;
INSERT_PADDING_WORDS(0x3F); INSERT_UNION_PADDING_WORDS(0x3F);
struct { struct {
u32 address_high; u32 address_high;
@ -139,7 +139,7 @@ public:
u32 x_count; u32 x_count;
u32 y_count; u32 y_count;
INSERT_PADDING_WORDS(0xB8); INSERT_UNION_PADDING_WORDS(0xB8);
u32 const0; u32 const0;
u32 const1; u32 const1;
@ -162,11 +162,11 @@ public:
Parameters dst_params; Parameters dst_params;
INSERT_PADDING_WORDS(1); INSERT_UNION_PADDING_WORDS(1);
Parameters src_params; Parameters src_params;
INSERT_PADDING_WORDS(0x13); INSERT_UNION_PADDING_WORDS(0x13);
}; };
std::array<u32, NUM_REGS> reg_array; std::array<u32, NUM_REGS> reg_array;
}; };

View File

@ -38,37 +38,37 @@ struct Header {
BitField<26, 1, u32> does_load_or_store; BitField<26, 1, u32> does_load_or_store;
BitField<27, 1, u32> does_fp64; BitField<27, 1, u32> does_fp64;
BitField<28, 4, u32> stream_out_mask; BitField<28, 4, u32> stream_out_mask;
} common0; } common0{};
union { union {
BitField<0, 24, u32> shader_local_memory_low_size; BitField<0, 24, u32> shader_local_memory_low_size;
BitField<24, 8, u32> per_patch_attribute_count; BitField<24, 8, u32> per_patch_attribute_count;
} common1; } common1{};
union { union {
BitField<0, 24, u32> shader_local_memory_high_size; BitField<0, 24, u32> shader_local_memory_high_size;
BitField<24, 8, u32> threads_per_input_primitive; BitField<24, 8, u32> threads_per_input_primitive;
} common2; } common2{};
union { union {
BitField<0, 24, u32> shader_local_memory_crs_size; BitField<0, 24, u32> shader_local_memory_crs_size;
BitField<24, 4, OutputTopology> output_topology; BitField<24, 4, OutputTopology> output_topology;
BitField<28, 4, u32> reserved; BitField<28, 4, u32> reserved;
} common3; } common3{};
union { union {
BitField<0, 12, u32> max_output_vertices; BitField<0, 12, u32> max_output_vertices;
BitField<12, 8, u32> store_req_start; // NOTE: not used by geometry shaders. BitField<12, 8, u32> store_req_start; // NOTE: not used by geometry shaders.
BitField<24, 4, u32> reserved; BitField<24, 4, u32> reserved;
BitField<12, 8, u32> store_req_end; // NOTE: not used by geometry shaders. BitField<12, 8, u32> store_req_end; // NOTE: not used by geometry shaders.
} common4; } common4{};
union { union {
struct { struct {
INSERT_PADDING_BYTES(3); // ImapSystemValuesA INSERT_UNION_PADDING_BYTES(3); // ImapSystemValuesA
INSERT_PADDING_BYTES(1); // ImapSystemValuesB INSERT_UNION_PADDING_BYTES(1); // ImapSystemValuesB
INSERT_PADDING_BYTES(16); // ImapGenericVector[32] INSERT_UNION_PADDING_BYTES(16); // ImapGenericVector[32]
INSERT_PADDING_BYTES(2); // ImapColor INSERT_UNION_PADDING_BYTES(2); // ImapColor
union { union {
BitField<0, 8, u16> clip_distances; BitField<0, 8, u16> clip_distances;
BitField<8, 1, u16> point_sprite_s; BitField<8, 1, u16> point_sprite_s;
@ -79,20 +79,20 @@ struct Header {
BitField<14, 1, u16> instance_id; BitField<14, 1, u16> instance_id;
BitField<15, 1, u16> vertex_id; BitField<15, 1, u16> vertex_id;
}; };
INSERT_PADDING_BYTES(5); // ImapFixedFncTexture[10] INSERT_UNION_PADDING_BYTES(5); // ImapFixedFncTexture[10]
INSERT_PADDING_BYTES(1); // ImapReserved INSERT_UNION_PADDING_BYTES(1); // ImapReserved
INSERT_PADDING_BYTES(3); // OmapSystemValuesA INSERT_UNION_PADDING_BYTES(3); // OmapSystemValuesA
INSERT_PADDING_BYTES(1); // OmapSystemValuesB INSERT_UNION_PADDING_BYTES(1); // OmapSystemValuesB
INSERT_PADDING_BYTES(16); // OmapGenericVector[32] INSERT_UNION_PADDING_BYTES(16); // OmapGenericVector[32]
INSERT_PADDING_BYTES(2); // OmapColor INSERT_UNION_PADDING_BYTES(2); // OmapColor
INSERT_PADDING_BYTES(2); // OmapSystemValuesC INSERT_UNION_PADDING_BYTES(2); // OmapSystemValuesC
INSERT_PADDING_BYTES(5); // OmapFixedFncTexture[10] INSERT_UNION_PADDING_BYTES(5); // OmapFixedFncTexture[10]
INSERT_PADDING_BYTES(1); // OmapReserved INSERT_UNION_PADDING_BYTES(1); // OmapReserved
} vtg; } vtg;
struct { struct {
INSERT_PADDING_BYTES(3); // ImapSystemValuesA INSERT_UNION_PADDING_BYTES(3); // ImapSystemValuesA
INSERT_PADDING_BYTES(1); // ImapSystemValuesB INSERT_UNION_PADDING_BYTES(1); // ImapSystemValuesB
union { union {
BitField<0, 2, AttributeUse> x; BitField<0, 2, AttributeUse> x;
BitField<2, 2, AttributeUse> y; BitField<2, 2, AttributeUse> y;
@ -100,10 +100,10 @@ struct Header {
BitField<6, 2, AttributeUse> z; BitField<6, 2, AttributeUse> z;
u8 raw; u8 raw;
} imap_generic_vector[32]; } imap_generic_vector[32];
INSERT_PADDING_BYTES(2); // ImapColor INSERT_UNION_PADDING_BYTES(2); // ImapColor
INSERT_PADDING_BYTES(2); // ImapSystemValuesC INSERT_UNION_PADDING_BYTES(2); // ImapSystemValuesC
INSERT_PADDING_BYTES(10); // ImapFixedFncTexture[10] INSERT_UNION_PADDING_BYTES(10); // ImapFixedFncTexture[10]
INSERT_PADDING_BYTES(2); // ImapReserved INSERT_UNION_PADDING_BYTES(2); // ImapReserved
struct { struct {
u32 target; u32 target;
union { union {
@ -139,6 +139,8 @@ struct Header {
return result; return result;
} }
} ps; } ps;
std::array<u32, 0xF> raw{};
}; };
u64 GetLocalMemorySize() const { u64 GetLocalMemorySize() const {

View File

@ -207,7 +207,7 @@ public:
union { union {
struct { struct {
INSERT_PADDING_WORDS(0x4); INSERT_UNION_PADDING_WORDS(0x4);
struct { struct {
u32 address_high; u32 address_high;
u32 address_low; u32 address_low;
@ -220,12 +220,12 @@ public:
u32 semaphore_sequence; u32 semaphore_sequence;
u32 semaphore_trigger; u32 semaphore_trigger;
INSERT_PADDING_WORDS(0xC); INSERT_UNION_PADDING_WORDS(0xC);
// The puser and the puller share the reference counter, the pusher only has read // The puser and the puller share the reference counter, the pusher only has read
// access // access
u32 reference_count; u32 reference_count;
INSERT_PADDING_WORDS(0x5); INSERT_UNION_PADDING_WORDS(0x5);
u32 semaphore_acquire; u32 semaphore_acquire;
u32 semaphore_release; u32 semaphore_release;
@ -234,7 +234,7 @@ public:
BitField<4, 4, u32> operation; BitField<4, 4, u32> operation;
BitField<8, 8, u32> id; BitField<8, 8, u32> id;
} fence_action; } fence_action;
INSERT_PADDING_WORDS(0xE2); INSERT_UNION_PADDING_WORDS(0xE2);
// Puller state // Puller state
u32 acquire_mode; u32 acquire_mode;