From fac2783a09dc15b45932d1ff55ee156a7515efd1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 3 Nov 2013 23:57:41 -0500 Subject: [PATCH] Optimize some struct sizes. This is the list of reduced sizes: file: dsound.c - struct dsound_t reduced from 56 bytes to 52 bytes. file: shader_parse.h - struct gfx_fbo_scale reduced from 32 bytes to 28 bytes. file: thread_wrapper.c - struct texture reduced from 28 bytes to 24 bytes. file: libretro.h - struct retro_hw_render_callback reduced from 40 bytes to 36 bytes. file: movie.c - struct bsv_movie reduced from 36 bytes to 32 bytes. file: netplay.c - struct delta_frame reduced from 16 bytes to 12 bytes. file: performance.h - struct rarch_perf_counter_t reduced from 40 bytes to 32 bytes. --- audio/dsound.c | 8 +++++--- gfx/shader_parse.h | 2 +- gfx/thread_wrapper.c | 4 ++-- libretro.h | 42 +++++++++++++++++++++++++++++++----------- movie.c | 7 ++++--- netplay.c | 3 ++- performance.h | 2 +- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/audio/dsound.c b/audio/dsound.c index a8c94959ee..95b4c55314 100644 --- a/audio/dsound.c +++ b/audio/dsound.c @@ -54,15 +54,17 @@ typedef struct dsound { LPDIRECTSOUND ds; LPDIRECTSOUNDBUFFER dsb; - HANDLE event; - bool nonblock; fifo_buffer_t *buffer; CRITICAL_SECTION crit; - volatile bool thread_alive; + HANDLE event; HANDLE thread; + unsigned buffer_size; + + bool nonblock; + volatile bool thread_alive; } dsound_t; static inline unsigned write_avail(unsigned read_ptr, unsigned write_ptr, unsigned buffer_size) diff --git a/gfx/shader_parse.h b/gfx/shader_parse.h index 0822dc7c41..0c6acccfa1 100644 --- a/gfx/shader_parse.h +++ b/gfx/shader_parse.h @@ -54,7 +54,6 @@ enum gfx_wrap_type struct gfx_fbo_scale { - bool valid; enum gfx_scale_type type_x; enum gfx_scale_type type_y; float scale_x; @@ -62,6 +61,7 @@ struct gfx_fbo_scale unsigned abs_x; unsigned abs_y; bool fp_fbo; + bool valid; }; struct gfx_shader_pass diff --git a/gfx/thread_wrapper.c b/gfx/thread_wrapper.c index 32583644f8..c6499429a7 100644 --- a/gfx/thread_wrapper.c +++ b/gfx/thread_wrapper.c @@ -74,11 +74,11 @@ typedef struct thread_video { void *frame; size_t frame_cap; - bool frame_updated; - bool rgb32; unsigned width; unsigned height; float alpha; + bool frame_updated; + bool rgb32; bool enable; bool full_screen; } texture; diff --git a/libretro.h b/libretro.h index e4a03028f2..97fdcfad2e 100755 --- a/libretro.h +++ b/libretro.h @@ -633,22 +633,42 @@ enum retro_hw_context_type struct retro_hw_render_callback { - enum retro_hw_context_type context_type; // Which API to use. Set by libretro core. - retro_hw_context_reset_t context_reset; // Called when a context has been created or when it has been reset. - retro_hw_get_current_framebuffer_t get_current_framebuffer; // Set by frontend. - retro_hw_get_proc_address_t get_proc_address; // Set by frontend. - bool depth; // Set if render buffers should have depth component attached. - bool stencil; // Set if stencil buffers should be attached. - // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored. - bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used. + // Which API to use. Set by libretro core. + enum retro_hw_context_type context_type; + + // Called when a context has been created or when it has been reset. + retro_hw_context_reset_t context_reset; + + // A callback to be called before the context is destroyed. + // Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification. + retro_hw_context_reset_t context_destroy; + + // Set by frontend + retro_hw_get_current_framebuffer_t get_current_framebuffer; + + // Set by frontend + retro_hw_get_proc_address_t get_proc_address; + unsigned version_major; // Major version number for core GL context. unsigned version_minor; // Minor version number for core GL context. - bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. + // Set if render buffers should have depth component attached. + bool depth; + + // Set if stencil buffers should be attached. + // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored. + bool stencil; + + // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used. + bool bottom_left_origin; + + // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. // The reset callback might still be called in extreme situations such as if the context is lost beyond recovery. // For optimal stability, set this to false, and allow context to be reset at any time. - retro_hw_context_reset_t context_destroy; // A callback to be called before the context is destroyed. Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification. - bool debug_context; // Creates a debug context. + bool cache_context; + + // Creates a debug context. + bool debug_context; }; // Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events. diff --git a/movie.c b/movie.c index 94fa6bc43a..1b5fc18ad5 100644 --- a/movie.c +++ b/movie.c @@ -24,16 +24,17 @@ struct bsv_movie { FILE *file; - uint8_t *state; - size_t state_size; size_t *frame_pos; // A ring buffer keeping track of positions in the file for each frame. size_t frame_mask; size_t frame_ptr; - bool playback; size_t min_file_pos; + size_t state_size; + uint8_t *state; + + bool playback; bool first_rewind; bool did_rewind; }; diff --git a/netplay.c b/netplay.c index 181579c3f8..8b9b557e61 100644 --- a/netplay.c +++ b/netplay.c @@ -49,8 +49,9 @@ struct delta_frame uint16_t real_input_state; uint16_t simulated_input_state; - bool is_simulated; uint16_t self_state; + + bool is_simulated; bool used_real; }; diff --git a/performance.h b/performance.h index 4515dc1c65..a9dffc54b0 100644 --- a/performance.h +++ b/performance.h @@ -32,11 +32,11 @@ typedef int64_t rarch_time_t; typedef struct rarch_perf_counter { - const char *ident; rarch_perf_tick_t start; rarch_perf_tick_t total; rarch_perf_tick_t call_cnt; + const char *ident; bool registered; } rarch_perf_counter_t;