1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00

Reorder structs, alignment

This commit is contained in:
twinaphex 2020-08-15 19:43:17 +02:00
parent a5efd70db7
commit f09df7c6e3
10 changed files with 169 additions and 160 deletions

View File

@ -13,6 +13,7 @@ For POD-types, try to order structs as follows (first to last):
* ptrdiff_t (4 bytes [32bit], 8 bytes [64bit])
* ssize_t (4 bytes [32bit], 8 bytes [64bit])
* size_t (4 bytes [32bit], 8 bytes [64bit])
* jmp_buf (4 bytes)
* long (4 bytes [64bit Win], 8 bytes [64bit non-Win], 4 bytes [32bit])
* int32_t (4 bytes)
* float (4 bytes)

6
core.h
View File

@ -58,9 +58,9 @@ typedef struct rarch_memory_map
typedef struct rarch_system_info
{
struct retro_location_callback location_cb; /* ptr alignment */
disk_control_interface_t disk_control; /* ptr alignment */
struct retro_system_info info; /* ptr alignment */
rarch_memory_map_t mmaps; /* ptr alignment */
disk_control_interface_t disk_control; /* ptr alignment */
struct retro_system_info info; /* ptr alignment */
rarch_memory_map_t mmaps; /* ptr alignment */
const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
struct
{

View File

@ -55,6 +55,7 @@ const struct retro_controller_description *
struct retro_core_t
{
uint64_t serialization_quirks_v;
void (*retro_init)(void);
void (*retro_deinit)(void);
unsigned (*retro_api_version)(void);
@ -89,7 +90,6 @@ struct retro_core_t
bool input_polled;
bool has_set_subsystems;
bool has_set_input_descriptors;
uint64_t serialization_quirks_v;
};
bool libretro_get_shared_context(void);

View File

@ -95,16 +95,6 @@ typedef struct vulkan_context
slock_t *queue_lock;
retro_vulkan_destroy_device_t destroy_device; /* ptr alignment */
uint32_t graphics_queue_index;
uint32_t num_swapchain_images;
uint32_t current_swapchain_index;
uint32_t current_frame_index;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
unsigned num_recycled_acquire_semaphores;
VkInstance instance;
VkPhysicalDevice gpu;
VkDevice device;
@ -125,6 +115,16 @@ typedef struct vulkan_context
#ifdef VULKAN_DEBUG
VkDebugReportCallbackEXT debug_callback;
#endif
uint32_t graphics_queue_index;
uint32_t num_swapchain_images;
uint32_t current_swapchain_index;
uint32_t current_frame_index;
unsigned swapchain_width;
unsigned swapchain_height;
unsigned swap_interval;
unsigned num_recycled_acquire_semaphores;
bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool invalid_swapchain;
/* Used by screenshot to get blits with correct colorspace. */
@ -189,7 +189,7 @@ struct vk_vertex
{
float x, y;
float tex_x, tex_y;
struct vk_color color;
struct vk_color color; /* float alignment */
};
struct vk_image
@ -233,7 +233,7 @@ struct vk_buffer
struct vk_buffer_node
{
struct vk_buffer buffer;
struct vk_buffer buffer; /* uint64_t alignment */
struct vk_buffer_node *next;
};

View File

@ -40,21 +40,21 @@
typedef struct freetype_atlas_slot
{
struct font_glyph glyph;
struct freetype_atlas_slot* next; /* ptr alignment */
struct font_glyph glyph; /* unsigned alignment */
unsigned charcode;
unsigned last_used;
struct freetype_atlas_slot* next;
}freetype_atlas_slot_t;
typedef struct freetype_renderer
{
FT_Library lib;
FT_Face face;
struct font_atlas atlas;
freetype_atlas_slot_t atlas_slots[FT_ATLAS_SIZE];
freetype_atlas_slot_t* uc_map[0x100];
FT_Library lib; /* ptr alignment */
FT_Face face; /* ptr alignment */
struct font_atlas atlas; /* ptr alignment */
freetype_atlas_slot_t atlas_slots[FT_ATLAS_SIZE]; /* ptr alignment */
freetype_atlas_slot_t* uc_map[0x100]; /* ptr alignment */
unsigned usage_counter;
struct font_line_metrics line_metrics;
struct font_line_metrics line_metrics; /* float alignment */
} ft_font_renderer_t;
static struct font_atlas *font_renderer_ft_get_atlas(void *data)

View File

@ -36,9 +36,9 @@
typedef struct
{
struct font_line_metrics line_metrics;
struct font_atlas atlas;
struct font_glyph glyphs[256];
struct font_atlas atlas; /* ptr alignment */
struct font_glyph glyphs[256]; /* unsigned alignment */
struct font_line_metrics line_metrics; /* float alignment */
} stb_font_renderer_t;
static struct font_atlas *font_renderer_stb_get_atlas(void *data)

View File

@ -44,26 +44,24 @@
typedef struct stb_unicode_atlas_slot
{
struct font_glyph glyph;
struct stb_unicode_atlas_slot* next;
struct font_glyph glyph; /* unsigned alignment */
unsigned charcode;
unsigned last_used;
struct stb_unicode_atlas_slot* next;
}stb_unicode_atlas_slot_t;
typedef struct
{
uint8_t *font_data;
stbtt_fontinfo info;
struct font_atlas atlas; /* ptr alignment */
stb_unicode_atlas_slot_t* uc_map[0x100];
stb_unicode_atlas_slot_t atlas_slots[STB_UNICODE_ATLAS_SIZE];
stbtt_fontinfo info; /* ptr alignment */
int max_glyph_width;
int max_glyph_height;
float scale_factor;
struct font_line_metrics line_metrics;
struct font_atlas atlas;
stb_unicode_atlas_slot_t atlas_slots[STB_UNICODE_ATLAS_SIZE];
stb_unicode_atlas_slot_t* uc_map[0x100];
unsigned usage_counter;
float scale_factor;
struct font_line_metrics line_metrics; /* float alignment */
} stb_unicode_font_renderer_t;
static struct font_atlas *font_renderer_stb_unicode_get_atlas(void *data)

View File

@ -168,7 +168,7 @@ typedef struct menu_input_pointer
typedef struct menu_input
{
menu_input_pointer_t pointer; /* int64_t alignment */
menu_input_pointer_t pointer; /* retro_time_t alignment */
unsigned ptr;
bool select_inhibit;
bool cancel_inhibit;

View File

@ -1934,6 +1934,10 @@ struct rarch_state
retro_time_t libretro_core_runtime_usec;
retro_time_t video_driver_frame_time_samples[
MEASURE_FRAME_TIME_SAMPLES_COUNT];
struct global g_extern; /* retro_time_t alignment */
#ifdef HAVE_MENU
menu_input_t menu_input_state; /* retro_time_t alignment */
#endif
retro_usec_t runloop_frame_time_last;
@ -1946,11 +1950,22 @@ struct rarch_state
#ifdef HAVE_MENU
struct menu_state menu_driver_state; /* int64_t alignment */
#endif
#if defined(HAVE_COMMAND)
#ifdef HAVE_NETWORK_CMD
struct sockaddr_storage lastcmd_net_source; /* int64_t alignment */
#endif
#endif
#ifdef HAVE_GFX_WIDGETS
dispgfx_widget_t dispwidget_st; /* uint64_t alignment */
#endif
#ifdef HAVE_MENU
struct menu_bind_state menu_input_binds; /* uint64_t alignment */
#endif
struct retro_core_t current_core; /* uint64_t alignment */
#if defined(HAVE_RUNAHEAD)
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
struct retro_core_t secondary_core; /* uint64_t alignment */
#endif
#endif
uint64_t audio_driver_free_samples_count;
@ -2107,6 +2122,10 @@ struct rarch_state
const struct retro_keybind *libretro_input_binds[MAX_USERS];
struct retro_subsystem_rom_info
subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS]
[SUBSYSTEM_MAX_SUBSYSTEM_ROMS]; /* ptr alignment */
gfx_ctx_driver_t current_video_context; /* ptr alignment */
content_state_t content_st; /* ptr alignment */
midi_event_t midi_drv_input_event; /* ptr alignment */
midi_event_t midi_drv_output_event; /* ptr alignment */
@ -2132,70 +2151,29 @@ struct rarch_state
runahead_load_state_function
retro_unserialize_callback_original; /* ptr alignment */
#endif
/*************************************/
/* TODO/FIXME BEGIN - find alignment */
#ifdef HAVE_DYNAMIC
dylib_t lib_handle;
#endif
#ifdef HAVE_NETWORKING
struct netplay_room netplay_host_room;
#endif
struct retro_callbacks retro_ctx; /* ptr alignment */
#if defined(HAVE_RUNAHEAD)
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
dylib_t secondary_module;
struct retro_core_t secondary_core;
struct retro_callbacks secondary_callbacks;
struct retro_callbacks secondary_callbacks; /* ptr alignment */
#endif
#endif
#ifdef HAVE_MENU
menu_input_pointer_hw_state_t menu_input_pointer_hw_state;
menu_input_t menu_input_state;
#endif
gfx_ctx_driver_t current_video_context;
/**
* dynamic.c:dynamic_request_hw_context will try to set flag data when the context
* is in the middle of being rebuilt; in these cases we will save flag
* data and set this to true.
* When the context is reinit, it checks this, reads from
* deferred_flag_data and cleans it.
*
* TODO - Dirty hack, fix it better
*/
gfx_ctx_flags_t deferred_flag_data;
retro_bits_t has_set_libretro_device;
#ifdef HAVE_AUDIOMIXER
struct audio_mixer_stream
audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS];
/* ptr alignment */
#endif
struct retro_callbacks retro_ctx;
struct retro_core_t current_core;
struct global g_extern;
#if defined(HAVE_COMMAND)
#ifdef HAVE_NETWORK_CMD
struct sockaddr_storage lastcmd_net_source;
socklen_t lastcmd_net_source_len;
#ifdef HAVE_NETWORKING
struct netplay_room netplay_host_room; /* ptr alignment */
#endif
#ifdef HAVE_DYNAMIC
dylib_t lib_handle; /* ptr alignment */
#endif
#if defined(HAVE_RUNAHEAD)
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
dylib_t secondary_lib_handle; /* ptr alignment */
#endif
#endif
#ifdef HAVE_THREAD_STORAGE
sthread_tls_t rarch_tls;
#endif
jmp_buf error_sjlj_context;
struct retro_subsystem_rom_info
subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS]
[SUBSYSTEM_MAX_SUBSYSTEM_ROMS];
/* TODO/FIXME END - find alignment */
/*************************************/
/* Opaque handles to currently running window.
* Used by e.g. input drivers which bind to a window.
* Drivers are responsible for setting these if an input driver
@ -2225,6 +2203,9 @@ struct rarch_state
size_t runahead_save_state_size;
#endif
jmp_buf error_sjlj_context; /* 4-byte alignment,
put it right before long */
turbo_buttons_t input_driver_turbo_btns; /* int32_t alignment */
int osk_ptr;
#if defined(HAVE_COMMAND)
@ -2250,9 +2231,13 @@ struct rarch_state
int reannounce;
#endif
input_device_info_t input_device_info[MAX_INPUT_DEVICES]; /* unsigned alignment */
input_device_info_t input_device_info[MAX_INPUT_DEVICES];
/* unsigned alignment */
#ifdef HAVE_MENU
menu_dialog_t dialog_st; /* unsigned alignment */
menu_dialog_t dialog_st; /* unsigned alignment */
#endif
#ifdef HAVE_THREAD_STORAGE
sthread_tls_t rarch_tls; /* unsigned alignment */
#endif
unsigned runloop_pending_windowed_scale;
unsigned runloop_max_frames;
@ -2323,11 +2308,33 @@ struct rarch_state
#endif
#ifdef HAVE_MENU
unsigned char menu_keyboard_key_state[RETROK_LAST];
menu_input_pointer_hw_state_t menu_input_pointer_hw_state;
/* int16_t alignment */
#endif
#ifdef HAVE_MENU
unsigned char menu_keyboard_key_state[RETROK_LAST];
#endif
/**
* dynamic.c:dynamic_request_hw_context will try to set flag data when the context
* is in the middle of being rebuilt; in these cases we will save flag
* data and set this to true.
* When the context is reinit, it checks this, reads from
* deferred_flag_data and cleans it.
*
* TODO - Dirty hack, fix it better
*/
gfx_ctx_flags_t deferred_flag_data; /* uint32_t alignment */
#if defined(HAVE_COMMAND)
#ifdef HAVE_NETWORK_CMD
socklen_t lastcmd_net_source_len; /* uint32_t alignment */
#endif
#endif
retro_bits_t has_set_libretro_device; /* uint32_t alignment */
#ifdef HAVE_BSV_MOVIE
struct bsv_state bsv_movie_state; /* char alignment */
struct bsv_state bsv_movie_state; /* char alignment */
#endif
char cached_video_driver[32];
char video_driver_title_buf[64];
@ -20606,7 +20613,7 @@ static void strcat_alloc(char **dst, const char *s)
static void secondary_core_destroy(struct rarch_state *p_rarch)
{
if (!p_rarch || !p_rarch->secondary_module)
if (!p_rarch || !p_rarch->secondary_lib_handle)
return;
/* unload game from core */
@ -20619,8 +20626,8 @@ static void secondary_core_destroy(struct rarch_state *p_rarch)
p_rarch->secondary_core.retro_deinit();
memset(&p_rarch->secondary_core, 0, sizeof(struct retro_core_t));
dylib_close(p_rarch->secondary_module);
p_rarch->secondary_module = NULL;
dylib_close(p_rarch->secondary_lib_handle);
p_rarch->secondary_lib_handle = NULL;
filestream_delete(p_rarch->secondary_library_path);
if (p_rarch->secondary_library_path)
free(p_rarch->secondary_library_path);
@ -20629,7 +20636,7 @@ static void secondary_core_destroy(struct rarch_state *p_rarch)
static bool secondary_core_ensure_exists(struct rarch_state *p_rarch)
{
if (!p_rarch->secondary_module)
if (!p_rarch->secondary_lib_handle)
if (!secondary_core_create(p_rarch))
return false;
return true;
@ -20653,7 +20660,8 @@ static void remember_controller_port_device(
{
if (port >= 0 && port < MAX_USERS)
p_rarch->port_map[port] = (int)device;
if (p_rarch->secondary_module && p_rarch->secondary_core.retro_set_controller_port_device)
if ( p_rarch->secondary_lib_handle
&& p_rarch->secondary_core.retro_set_controller_port_device)
p_rarch->secondary_core.retro_set_controller_port_device((unsigned)port, (unsigned)device);
}
@ -20875,7 +20883,8 @@ static bool secondary_core_create(struct rarch_state *p_rarch)
/* Load Core */
if (!init_libretro_symbols_custom(p_rarch,
CORE_TYPE_PLAIN, &p_rarch->secondary_core,
p_rarch->secondary_library_path, &p_rarch->secondary_module))
p_rarch->secondary_library_path,
&p_rarch->secondary_lib_handle))
return false;
p_rarch->secondary_core.symbols_inited = true;
@ -38866,14 +38875,14 @@ static enum runloop_state runloop_check_state(
global->menu.noop_start_time = current_time;
global->menu.noop_press_time = 0;
if (global->menu.prev_action == old_action)
if (global->menu_prev_action == old_action)
global->menu.action_start_time = global->menu.prev_start_time;
else
global->menu.action_start_time = current_time;
}
else
{
if ( global->menu.prev_action == action &&
if ( global->menu_prev_action == action &&
global->menu.noop_press_time < 200000) /* 250ms */
{
global->menu.action_start_time = global->menu.prev_start_time;
@ -38882,7 +38891,7 @@ static enum runloop_state runloop_check_state(
else
{
global->menu.prev_start_time = current_time;
global->menu.prev_action = action;
global->menu_prev_action = action;
global->menu.action_press_time = 0;
}
}

View File

@ -226,61 +226,6 @@ typedef struct rarch_resolution
typedef struct global
{
bool launched_from_cli;
bool cli_load_menu_on_error;
struct
{
char savefile[8192];
char savestate[8192];
char cheatfile[8192];
char ups[8192];
char bps[8192];
char ips[8192];
char label[8192];
char *remapfile;
} name;
/* Recording. */
struct
{
bool use_output_dir;
char path[8192];
char config[8192];
char output_dir[8192];
char config_dir[8192];
unsigned width;
unsigned height;
size_t gpu_width;
size_t gpu_height;
} record;
/* Settings and/or global state that is specific to
* a console-style implementation. */
struct
{
bool flickerfilter_enable;
bool softfilter_enable;
struct
{
bool pal_enable;
bool pal60_enable;
unsigned char soft_filter_index;
unsigned gamma_correction;
unsigned int flicker_filter_index;
struct
{
bool check;
unsigned count;
uint32_t *list;
rarch_resolution_t current;
rarch_resolution_t initial;
} resolutions;
} screen;
} console;
/* Settings and/or global states specific to menus */
#ifdef HAVE_MENU
struct
{
@ -289,9 +234,65 @@ typedef struct global
retro_time_t noop_start_time;
retro_time_t action_start_time;
retro_time_t action_press_time;
enum menu_action prev_action;
} menu;
#endif
struct
{
char *remapfile;
char savefile[8192];
char savestate[8192];
char cheatfile[8192];
char ups[8192];
char bps[8192];
char ips[8192];
char label[8192];
} name;
/* Recording. */
struct
{
size_t gpu_width;
size_t gpu_height;
unsigned width;
unsigned height;
char path[8192];
char config[8192];
char output_dir[8192];
char config_dir[8192];
bool use_output_dir;
} record;
/* Settings and/or global state that is specific to
* a console-style implementation. */
struct
{
struct
{
struct
{
uint32_t *list;
unsigned count;
rarch_resolution_t current;
rarch_resolution_t initial;
bool check;
} resolutions;
unsigned gamma_correction;
unsigned int flicker_filter_index;
unsigned char soft_filter_index;
bool pal_enable;
bool pal60_enable;
} screen;
bool flickerfilter_enable;
bool softfilter_enable;
} console;
/* Settings and/or global states specific to menus */
#ifdef HAVE_MENU
enum menu_action menu_prev_action;
#endif
bool launched_from_cli;
bool cli_load_menu_on_error;
} global_t;
typedef struct content_state