diff options
author | Chris Robinson <[email protected]> | 2022-07-13 05:09:42 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-07-13 05:19:51 -0700 |
commit | c843efd3225e53317d955dfe3550d2669f11639e (patch) | |
tree | e55b74e0d9e3aa8193b446115a4ac3e2965775fb /al | |
parent | 86094e87a575ef621d5d2550ed807ffeb6e5036d (diff) |
Don't track dirty flags per EAX version
Only the current version's flags are used, and they're all reset when changing
versions, making it unnecessary to track non-current version flags.
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 68 | ||||
-rw-r--r-- | al/auxeffectslot.h | 14 |
2 files changed, 35 insertions, 47 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 8a5915a6..04e7720d 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -1198,7 +1198,6 @@ void ALeffectslot::eax4_fx_slot_set_defaults(Eax4Props& props) void ALeffectslot::eax4_fx_slot_set_defaults() { eax4_fx_slot_set_defaults(eax4_.i); - eax4_.df = ~EaxDirtyFlags{}; } void ALeffectslot::eax5_fx_slot_set_defaults(Eax5Props& props) @@ -1211,7 +1210,6 @@ void ALeffectslot::eax5_fx_slot_set_defaults(Eax5Props& props) void ALeffectslot::eax5_fx_slot_set_defaults() { eax5_fx_slot_set_defaults(eax5_.i); - eax5_.df = ~EaxDirtyFlags{}; } void ALeffectslot::eax_fx_slot_set_defaults() @@ -1220,6 +1218,7 @@ void ALeffectslot::eax_fx_slot_set_defaults() eax5_fx_slot_set_defaults(); eax123_ = eax5_; eax_ = eax5_.i; + eax_df_ = ~EaxDirtyFlags{}; } void ALeffectslot::eax4_fx_slot_get(const EaxCall& call, const Eax4Props& props) const @@ -1338,11 +1337,10 @@ void ALeffectslot::eax4_fx_slot_set_all(const EaxCall& call) const auto& src = call.get_value<Exception, const EAX40FXSLOTPROPERTIES>(); Eax4AllValidator{}(src); auto& dst = eax4_.i; - auto& df = eax4_.df; - df |= eax_load_effect_dirty_bit; // Always reset the effect. - df |= (dst.lVolume != src.lVolume ? eax_volume_dirty_bit : EaxDirtyFlags{}); - df |= (dst.lLock != src.lLock ? eax_lock_dirty_bit : EaxDirtyFlags{}); - df |= (dst.ulFlags != src.ulFlags ? eax_flags_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= eax_load_effect_dirty_bit; // Always reset the effect. + eax_df_ |= (dst.lVolume != src.lVolume ? eax_volume_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.lLock != src.lLock ? eax_lock_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.ulFlags != src.ulFlags ? eax_flags_dirty_bit : EaxDirtyFlags{}); dst = src; } @@ -1351,20 +1349,18 @@ void ALeffectslot::eax5_fx_slot_set_all(const EaxCall& call) const auto& src = call.get_value<Exception, const EAX50FXSLOTPROPERTIES>(); Eax5AllValidator{}(src); auto& dst = eax5_.i; - auto& df = eax5_.df; - df |= eax_load_effect_dirty_bit; // Always reset the effect. - df |= (dst.lVolume != src.lVolume ? eax_volume_dirty_bit : EaxDirtyFlags{}); - df |= (dst.lLock != src.lLock ? eax_lock_dirty_bit : EaxDirtyFlags{}); - df |= (dst.ulFlags != src.ulFlags ? eax_flags_dirty_bit : EaxDirtyFlags{}); - df |= (dst.lOcclusion != src.lOcclusion ? eax_flags_dirty_bit : EaxDirtyFlags{}); - df |= (dst.flOcclusionLFRatio != src.flOcclusionLFRatio ? eax_flags_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= eax_load_effect_dirty_bit; // Always reset the effect. + eax_df_ |= (dst.lVolume != src.lVolume ? eax_volume_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.lLock != src.lLock ? eax_lock_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.ulFlags != src.ulFlags ? eax_flags_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.lOcclusion != src.lOcclusion ? eax_flags_dirty_bit : EaxDirtyFlags{}); + eax_df_ |= (dst.flOcclusionLFRatio != src.flOcclusionLFRatio ? eax_flags_dirty_bit : EaxDirtyFlags{}); dst = src; } // Returns `true` if all sources should be updated, or `false` otherwise. bool ALeffectslot::eax4_fx_slot_set(const EaxCall& call) { - auto& df = eax4_.df; auto& dst = eax4_.i; switch(call.get_property_id()) @@ -1376,29 +1372,28 @@ bool ALeffectslot::eax4_fx_slot_set(const EaxCall& call) break; case EAXFXSLOT_LOADEFFECT: eax4_fx_slot_ensure_unlocked(); - eax_fx_slot_set_dirty<Eax4GuidLoadEffectValidator, eax_load_effect_dirty_bit>(call, dst.guidLoadEffect, df); + eax_fx_slot_set_dirty<Eax4GuidLoadEffectValidator, eax_load_effect_dirty_bit>(call, dst.guidLoadEffect, eax_df_); break; case EAXFXSLOT_VOLUME: - eax_fx_slot_set<Eax4VolumeValidator, eax_volume_dirty_bit>(call, dst.lVolume, df); + eax_fx_slot_set<Eax4VolumeValidator, eax_volume_dirty_bit>(call, dst.lVolume, eax_df_); break; case EAXFXSLOT_LOCK: eax4_fx_slot_ensure_unlocked(); - eax_fx_slot_set<Eax4LockValidator, eax_lock_dirty_bit>(call, dst.lLock, df); + eax_fx_slot_set<Eax4LockValidator, eax_lock_dirty_bit>(call, dst.lLock, eax_df_); break; case EAXFXSLOT_FLAGS: - eax_fx_slot_set<Eax4FlagsValidator, eax_flags_dirty_bit>(call, dst.ulFlags, df); + eax_fx_slot_set<Eax4FlagsValidator, eax_flags_dirty_bit>(call, dst.ulFlags, eax_df_); break; default: eax_fail_unknown_property_id(); } - return (df & (eax_occlusion_dirty_bit | eax_occlusion_lf_ratio_dirty_bit)) != EaxDirtyFlags{}; + return (eax_df_ & (eax_occlusion_dirty_bit | eax_occlusion_lf_ratio_dirty_bit)) != EaxDirtyFlags{}; } // Returns `true` if all sources should be updated, or `false` otherwise. bool ALeffectslot::eax5_fx_slot_set(const EaxCall& call) { - auto& df = eax5_.df; auto& dst = eax5_.i; switch(call.get_property_id()) @@ -1409,28 +1404,28 @@ bool ALeffectslot::eax5_fx_slot_set(const EaxCall& call) eax5_fx_slot_set_all(call); break; case EAXFXSLOT_LOADEFFECT: - eax_fx_slot_set_dirty<Eax4GuidLoadEffectValidator, eax_load_effect_dirty_bit>(call, dst.guidLoadEffect, df); + eax_fx_slot_set_dirty<Eax4GuidLoadEffectValidator, eax_load_effect_dirty_bit>(call, dst.guidLoadEffect, eax_df_); break; case EAXFXSLOT_VOLUME: - eax_fx_slot_set<Eax4VolumeValidator, eax_volume_dirty_bit>(call, dst.lVolume, df); + eax_fx_slot_set<Eax4VolumeValidator, eax_volume_dirty_bit>(call, dst.lVolume, eax_df_); break; case EAXFXSLOT_LOCK: - eax_fx_slot_set<Eax4LockValidator, eax_lock_dirty_bit>(call, dst.lLock, df); + eax_fx_slot_set<Eax4LockValidator, eax_lock_dirty_bit>(call, dst.lLock, eax_df_); break; case EAXFXSLOT_FLAGS: - eax_fx_slot_set<Eax4FlagsValidator, eax_flags_dirty_bit>(call, dst.ulFlags, df); + eax_fx_slot_set<Eax4FlagsValidator, eax_flags_dirty_bit>(call, dst.ulFlags, eax_df_); break; case EAXFXSLOT_OCCLUSION: - eax_fx_slot_set<Eax5OcclusionValidator, eax_occlusion_dirty_bit>(call, dst.lOcclusion, df); + eax_fx_slot_set<Eax5OcclusionValidator, eax_occlusion_dirty_bit>(call, dst.lOcclusion, eax_df_); break; case EAXFXSLOT_OCCLUSIONLFRATIO: - eax_fx_slot_set<Eax5OcclusionLfRatioValidator, eax_occlusion_lf_ratio_dirty_bit>(call, dst.flOcclusionLFRatio, df); + eax_fx_slot_set<Eax5OcclusionLfRatioValidator, eax_occlusion_lf_ratio_dirty_bit>(call, dst.flOcclusionLFRatio, eax_df_); break; default: eax_fail_unknown_property_id(); } - return (df & (eax_occlusion_dirty_bit | eax_occlusion_lf_ratio_dirty_bit)) != EaxDirtyFlags{}; + return (eax_df_ & (eax_occlusion_dirty_bit | eax_occlusion_lf_ratio_dirty_bit)) != EaxDirtyFlags{}; } // Returns `true` if all sources should be updated, or `false` otherwise. @@ -1449,13 +1444,8 @@ bool ALeffectslot::eax_set(const EaxCall& call) { const auto version = call.get_version(); - if(eax_version_ != version) { - constexpr auto all_bits = ~EaxDirtyFlags{}; - eax123_.df = all_bits; - eax4_.df = all_bits; - eax5_.df = all_bits; - } - + if(eax_version_ != version) + eax_df_ = ~EaxDirtyFlags{}; eax_version_ = version; switch(call.get_property_set_id()) @@ -1468,7 +1458,7 @@ bool ALeffectslot::eax_set(const EaxCall& call) void ALeffectslot::eax4_fx_slot_commit(EaxDirtyFlags& dst_df) { - if(eax4_.df == EaxDirtyFlags{}) + if(eax_df_ == EaxDirtyFlags{}) return; eax_fx_slot_commit_property<eax_load_effect_dirty_bit>(eax4_, dst_df, &EAX40FXSLOTPROPERTIES::guidLoadEffect); @@ -1488,12 +1478,12 @@ void ALeffectslot::eax4_fx_slot_commit(EaxDirtyFlags& dst_df) dst_i.flOcclusionLFRatio = EAXFXSLOT_DEFAULTOCCLUSIONLFRATIO; } - eax4_.df = EaxDirtyFlags{}; + eax_df_ = EaxDirtyFlags{}; } void ALeffectslot::eax5_fx_slot_commit(Eax5State& state, EaxDirtyFlags& dst_df) { - if(state.df == EaxDirtyFlags{}) + if(eax_df_ == EaxDirtyFlags{}) return; eax_fx_slot_commit_property<eax_load_effect_dirty_bit>(state, dst_df, &EAX50FXSLOTPROPERTIES::guidLoadEffect); @@ -1502,7 +1492,7 @@ void ALeffectslot::eax5_fx_slot_commit(Eax5State& state, EaxDirtyFlags& dst_df) eax_fx_slot_commit_property<eax_flags_dirty_bit>(state, dst_df, &EAX50FXSLOTPROPERTIES::ulFlags); eax_fx_slot_commit_property<eax_occlusion_dirty_bit>(state, dst_df, &EAX50FXSLOTPROPERTIES::lOcclusion); eax_fx_slot_commit_property<eax_occlusion_lf_ratio_dirty_bit>(state, dst_df, &EAX50FXSLOTPROPERTIES::flOcclusionLFRatio); - state.df = EaxDirtyFlags{}; + eax_df_ = EaxDirtyFlags{}; } void ALeffectslot::eax_dispatch_effect(const EaxCall& call) diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index fb6a2e1e..8d8b187e 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -109,14 +109,12 @@ private: struct Eax4State { Eax4Props i; // Immediate. - EaxDirtyFlags df; // Dirty flags. }; using Eax5Props = EAX50FXSLOTPROPERTIES; struct Eax5State { Eax5Props i; // Immediate. - EaxDirtyFlags df; // Dirty flags. }; struct EaxRangeValidator { @@ -241,6 +239,7 @@ private: ALCcontext* eax_al_context_{}; EaxFxSlotIndexValue eax_fx_slot_index_{}; int eax_version_{}; // Current EAX version. + EaxDirtyFlags eax_df_{}; // Dirty flags for the current EAX version. EaxEffectUPtr eax_effect_{}; Eax5State eax123_{}; // EAX1/EAX2/EAX3 state. Eax4State eax4_{}; // EAX4 state. @@ -270,7 +269,8 @@ private: // sets a dirty flag without comparing the values, // and assigns the new value. template<typename TValidator, EaxDirtyFlags TDirtyBit, typename TProperties> - void eax_fx_slot_set_dirty(const EaxCall& call, TProperties& dst, EaxDirtyFlags& dirty_flags) + static void eax_fx_slot_set_dirty(const EaxCall& call, TProperties& dst, + EaxDirtyFlags& dirty_flags) { const auto& src = call.get_value<Exception, const TProperties>(); TValidator{}(src); @@ -321,16 +321,14 @@ private: typename TMemberResult, typename TProps, typename TState> - void eax_fx_slot_commit_property( - TState& state, - EaxDirtyFlags& dst_df, + void eax_fx_slot_commit_property(TState& state, EaxDirtyFlags& dst_df, TMemberResult TProps::*member) noexcept { auto& src_i = state.i; - auto& src_df = state.df; auto& dst_i = eax_; - if ((src_df & TDirtyBit) != EaxDirtyFlags{}) { + if((eax_df_ & TDirtyBit) != EaxDirtyFlags{}) + { dst_df |= TDirtyBit; dst_i.*member = src_i.*member; } |