From 9e95b2eb6fb3dc5a1c8659c0a90cdeb52ea6b051 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Wed, 10 May 2017 23:19:26 +0200 Subject: [PATCH] Various: Don't use boolean bitfields Using bitfields causes less optimized code generation and the memory savings are minimal as none of the objects are instantiated enough times to be worth it. See https://blogs.msdn.microsoft.com/oldnewthing/20081126-00/?p=20073 --- libobs/audio-monitoring/win32/wasapi-output.c | 4 +-- libobs/obs-hotkey.c | 8 ++--- libobs/obs-internal.h | 28 +++++++-------- plugins/obs-filters/scale-filter.c | 8 ++--- plugins/win-capture/game-capture.c | 36 +++++++++---------- .../graphics-hook/d3d10-capture.cpp | 6 ++-- .../graphics-hook/d3d11-capture.cpp | 6 ++-- .../graphics-hook/d3d12-capture.cpp | 8 ++--- .../graphics-hook/d3d9-capture.cpp | 4 +-- .../win-capture/graphics-hook/gl-capture.c | 6 ++-- 10 files changed, 57 insertions(+), 57 deletions(-) diff --git a/libobs/audio-monitoring/win32/wasapi-output.c b/libobs/audio-monitoring/win32/wasapi-output.c index 1d6d6d14e..750f9b58a 100644 --- a/libobs/audio-monitoring/win32/wasapi-output.c +++ b/libobs/audio-monitoring/win32/wasapi-output.c @@ -35,8 +35,8 @@ struct audio_monitor { audio_resampler_t *resampler; uint32_t sample_rate; uint32_t channels; - bool source_has_video : 1; - bool ignore : 1; + bool source_has_video; + bool ignore; int64_t lowest_audio_offset; struct circlebuf delay_buffer; diff --git a/libobs/obs-hotkey.c b/libobs/obs-hotkey.c index fdf9e7548..8ccc50c1d 100644 --- a/libobs/obs-hotkey.c +++ b/libobs/obs-hotkey.c @@ -1197,8 +1197,8 @@ reset: struct obs_hotkey_internal_inject { obs_key_combination_t hotkey; - bool pressed : 1; - bool strict_modifiers : 1; + bool pressed; + bool strict_modifiers; }; static inline bool inject_hotkey(void *data, @@ -1251,8 +1251,8 @@ void obs_hotkey_enable_strict_modifiers(bool enable) struct obs_query_hotkeys_helper { uint32_t modifiers; - bool no_press : 1; - bool strict_modifiers : 1; + bool no_press; + bool strict_modifiers; }; static inline bool query_hotkey(void *data, diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 230392e6e..0efeed12a 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -140,8 +140,8 @@ struct obs_hotkey_pair { obs_hotkey_pair_id pair_id; obs_hotkey_id id[2]; obs_hotkey_active_func func[2]; - bool pressed0 : 1; - bool pressed1 : 1; + bool pressed0; + bool pressed1; void *data[2]; }; @@ -166,8 +166,8 @@ void obs_hotkeys_free(void); struct obs_hotkey_binding { obs_key_combination_t key; - bool pressed : 1; - bool modifiers_match : 1; + bool pressed; + bool modifiers_match; obs_hotkey_id hotkey_id; obs_hotkey_t *hotkey; @@ -336,9 +336,9 @@ struct obs_core_hotkeys { pthread_t hotkey_thread; bool hotkey_thread_initialized; os_event_t *stop_event; - bool thread_disable_press : 1; - bool strict_modifiers : 1; - bool reroute_hotkeys : 1; + bool thread_disable_press; + bool strict_modifiers; + bool reroute_hotkeys; DARRAY(obs_hotkey_binding_t) bindings; obs_hotkey_callback_router_func router_func; @@ -643,12 +643,12 @@ struct obs_source { obs_hotkey_pair_id mute_unmute_key; obs_hotkey_id push_to_mute_key; obs_hotkey_id push_to_talk_key; - bool push_to_mute_enabled : 1; - bool push_to_mute_pressed : 1; - bool user_push_to_mute_pressed : 1; - bool push_to_talk_enabled : 1; - bool push_to_talk_pressed : 1; - bool user_push_to_talk_pressed : 1; + bool push_to_mute_enabled; + bool push_to_mute_pressed; + bool user_push_to_mute_pressed; + bool push_to_talk_enabled; + bool push_to_talk_pressed; + bool user_push_to_talk_pressed; uint64_t push_to_mute_delay; uint64_t push_to_mute_stop_time; uint64_t push_to_talk_delay; @@ -670,7 +670,7 @@ struct obs_source { uint32_t transition_cx; uint32_t transition_cy; uint32_t transition_fixed_duration; - bool transition_use_fixed_duration : 1; + bool transition_use_fixed_duration; enum obs_transition_mode transition_mode; enum obs_transition_scale_type transition_scale_type; struct matrix4 transition_matrices[2]; diff --git a/plugins/obs-filters/scale-filter.c b/plugins/obs-filters/scale-filter.c index 29e42c46d..3a1cfef7d 100644 --- a/plugins/obs-filters/scale-filter.c +++ b/plugins/obs-filters/scale-filter.c @@ -38,10 +38,10 @@ struct scale_filter_data { int cy_out; enum obs_scale_type sampling; gs_samplerstate_t *point_sampler; - bool aspect_ratio_only : 1; - bool target_valid : 1; - bool valid : 1; - bool undistort : 1; + bool aspect_ratio_only; + bool target_valid; + bool valid; + bool undistort; }; static const char *scale_filter_name(void *unused) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index be87b40b4..8c202f31c 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -87,13 +87,13 @@ struct game_capture_config { enum capture_mode mode; uint32_t scale_cx; uint32_t scale_cy; - bool cursor : 1; - bool force_shmem : 1; - bool force_scaling : 1; - bool allow_transparency : 1; - bool limit_framerate : 1; - bool capture_overlays : 1; - bool anticheat_hook : 1; + bool cursor; + bool force_shmem; + bool force_scaling; + bool allow_transparency; + bool limit_framerate; + bool capture_overlays; + bool anticheat_hook; }; struct game_capture { @@ -119,17 +119,17 @@ struct game_capture { volatile long hotkey_window; volatile bool deactivate_hook; volatile bool activate_hook_now; - bool wait_for_target_startup : 1; - bool showing : 1; - bool active : 1; - bool capturing : 1; - bool activate_hook : 1; - bool process_is_64bit : 1; - bool error_acquiring : 1; - bool dwm_capture : 1; - bool initial_config : 1; - bool convert_16bit : 1; - bool is_app : 1; + bool wait_for_target_startup; + bool showing; + bool active; + bool capturing; + bool activate_hook; + bool process_is_64bit; + bool error_acquiring; + bool dwm_capture; + bool initial_config; + bool convert_16bit; + bool is_app; bool cursor_hidden; struct game_capture_config config; diff --git a/plugins/win-capture/graphics-hook/d3d10-capture.cpp b/plugins/win-capture/graphics-hook/d3d10-capture.cpp index 9f62ff9e1..e7d958a67 100644 --- a/plugins/win-capture/graphics-hook/d3d10-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d10-capture.cpp @@ -12,9 +12,9 @@ struct d3d10_data { uint32_t cx; uint32_t cy; DXGI_FORMAT format; - bool using_shtex : 1; - bool using_scale : 1; - bool multisampled : 1; + bool using_shtex; + bool using_scale; + bool multisampled; ID3D10Texture2D *scale_tex; ID3D10ShaderResourceView *scale_resource; diff --git a/plugins/win-capture/graphics-hook/d3d11-capture.cpp b/plugins/win-capture/graphics-hook/d3d11-capture.cpp index ee0d7e162..a11e81b31 100644 --- a/plugins/win-capture/graphics-hook/d3d11-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d11-capture.cpp @@ -13,9 +13,9 @@ struct d3d11_data { uint32_t cx; uint32_t cy; DXGI_FORMAT format; - bool using_shtex : 1; - bool using_scale : 1; - bool multisampled : 1; + bool using_shtex; + bool using_scale; + bool multisampled; ID3D11Texture2D *scale_tex; ID3D11ShaderResourceView *scale_resource; diff --git a/plugins/win-capture/graphics-hook/d3d12-capture.cpp b/plugins/win-capture/graphics-hook/d3d12-capture.cpp index 36b9866c9..a237b3ba9 100644 --- a/plugins/win-capture/graphics-hook/d3d12-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d12-capture.cpp @@ -19,10 +19,10 @@ struct d3d12_data { uint32_t cx; uint32_t cy; DXGI_FORMAT format; - bool using_shtex : 1; - bool using_scale : 1; - bool multisampled : 1; - bool dxgi_1_4 : 1; + bool using_shtex; + bool using_scale; + bool multisampled; + bool dxgi_1_4; ID3D11Device *device11; ID3D11DeviceContext *context11; diff --git a/plugins/win-capture/graphics-hook/d3d9-capture.cpp b/plugins/win-capture/graphics-hook/d3d9-capture.cpp index d40f932d2..591c26075 100644 --- a/plugins/win-capture/graphics-hook/d3d9-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d9-capture.cpp @@ -32,8 +32,8 @@ struct d3d9_data { uint32_t cy; D3DFORMAT d3d9_format; DXGI_FORMAT dxgi_format; - bool using_shtex : 1; - bool using_scale : 1; + bool using_shtex; + bool using_scale; /* shared texture */ IDirect3DSurface9 *d3d9_copytex; diff --git a/plugins/win-capture/graphics-hook/gl-capture.c b/plugins/win-capture/graphics-hook/gl-capture.c index f46842f69..595655004 100644 --- a/plugins/win-capture/graphics-hook/gl-capture.c +++ b/plugins/win-capture/graphics-hook/gl-capture.c @@ -35,9 +35,9 @@ struct gl_data { uint32_t cy; DXGI_FORMAT format; GLuint fbo; - bool using_shtex : 1; - bool using_scale : 1; - bool shmem_fallback : 1; + bool using_shtex; + bool using_scale; + bool shmem_fallback; union { /* shared texture */