diff options
author | Chris Robinson <[email protected]> | 2023-05-01 17:11:49 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-01 17:11:49 -0700 |
commit | bb08a416f1b0e31292b896f2f8845e365daee6b1 (patch) | |
tree | 065c1ec74167265451fd3396b7557be22f962c16 | |
parent | 89f67ad6f9878ecfb48b49ce0dd69b9ecb065d0b (diff) |
Put the debug filters into a group
-rw-r--r-- | al/debug.cpp | 26 | ||||
-rw-r--r-- | al/debug.h | 69 | ||||
-rw-r--r-- | al/error.cpp | 1 | ||||
-rw-r--r-- | alc/alc.cpp | 1 | ||||
-rw-r--r-- | alc/context.cpp | 10 | ||||
-rw-r--r-- | alc/context.h | 60 |
6 files changed, 98 insertions, 69 deletions
diff --git a/al/debug.cpp b/al/debug.cpp index 70c7c4db..fc893490 100644 --- a/al/debug.cpp +++ b/al/debug.cpp @@ -222,6 +222,7 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlSOFT(ALenum source, ALenum typ } std::lock_guard<std::mutex> _{context->mDebugCbLock}; + DebugGroup &debug = context->mDebugGroups.back(); if(count > 0) { const uint filterbase{(1u<<srcIndices[0]) | (1u<<typeIndices[0])}; @@ -230,24 +231,23 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlSOFT(ALenum source, ALenum typ { const uint64_t filter{filterbase | (uint64_t{id} << 32)}; - auto iter = std::lower_bound(context->mDebugIdFilters.cbegin(), - context->mDebugIdFilters.cend(), filter); - if(!enable && (iter == context->mDebugIdFilters.cend() || *iter != filter)) - context->mDebugIdFilters.insert(iter, filter); - else if(enable && iter != context->mDebugIdFilters.cend() && *iter == filter) - context->mDebugIdFilters.erase(iter); + auto iter = std::lower_bound(debug.mIdFilters.cbegin(), debug.mIdFilters.cend(), + filter); + if(!enable && (iter == debug.mIdFilters.cend() || *iter != filter)) + debug.mIdFilters.insert(iter, filter); + else if(enable && iter != debug.mIdFilters.cend() && *iter == filter) + debug.mIdFilters.erase(iter); } } else { - auto apply_filter = [enable,&context](const uint filter) + auto apply_filter = [enable,&debug](const uint filter) { - auto iter = std::lower_bound(context->mDebugFilters.cbegin(), - context->mDebugFilters.cend(), filter); - if(!enable && (iter == context->mDebugFilters.cend() || *iter != filter)) - context->mDebugFilters.insert(iter, filter); - else if(enable && iter != context->mDebugFilters.cend() && *iter == filter) - context->mDebugFilters.erase(iter); + auto iter = std::lower_bound(debug.mFilters.cbegin(), debug.mFilters.cend(), filter); + if(!enable && (iter == debug.mFilters.cend() || *iter != filter)) + debug.mFilters.insert(iter, filter); + else if(enable && iter != debug.mFilters.cend() && *iter == filter) + debug.mFilters.erase(iter); }; auto apply_severity = [apply_filter,svrIndices](const uint filter) { @@ -2,6 +2,10 @@ #define AL_DEBUG_H #include <stdint.h> +#include <string> +#include <vector> + +using uint = unsigned int; /* Somewhat arbitrary. Avoid letting it get out of control if the app enables @@ -10,4 +14,69 @@ constexpr uint8_t MaxDebugLoggedMessages{64}; constexpr uint16_t MaxDebugMessageLength{1024}; + +constexpr uint DebugSourceBase{0}; +enum class DebugSource : uint8_t { + API = 0, + System, + ThirdParty, + Application, + Other, +}; +constexpr uint DebugSourceCount{5}; + +constexpr uint DebugTypeBase{DebugSourceBase + DebugSourceCount}; +enum class DebugType : uint8_t { + Error = 0, + DeprecatedBehavior, + UndefinedBehavior, + Portability, + Performance, + Marker, + Other, +}; +constexpr uint DebugTypeCount{7}; + +constexpr uint DebugSeverityBase{DebugTypeBase + DebugTypeCount}; +enum class DebugSeverity : uint8_t { + High = 0, + Medium, + Low, + Notification, +}; +constexpr uint DebugSeverityCount{4}; + +struct DebugGroup { + const uint mId; + const DebugSource mSource; + std::string mMessage; + std::vector<uint> mFilters; + std::vector<uint64_t> mIdFilters; + + template<typename T> + DebugGroup(DebugSource source, uint id, T&& message) + : mId{id}, mSource{source}, mMessage{std::forward<T>(message)} + { } + DebugGroup(const DebugGroup&) = default; + DebugGroup(DebugGroup&&) = default; +}; + + +struct DebugLogEntry { + const DebugSource mSource; + const DebugType mType; + const DebugSeverity mSeverity; + const uint mId; + + std::string mMessage; + + template<typename T> + DebugLogEntry(DebugSource source, DebugType type, uint id, DebugSeverity severity, T&& message) + : mSource{source}, mType{type}, mSeverity{severity}, mId{id} + , mMessage{std::forward<T>(message)} + { } + DebugLogEntry(const DebugLogEntry&) = default; + DebugLogEntry(DebugLogEntry&&) = default; +}; + #endif /* AL_DEBUG_H */ diff --git a/al/error.cpp b/al/error.cpp index 70081a2e..39fd9f0a 100644 --- a/al/error.cpp +++ b/al/error.cpp @@ -35,6 +35,7 @@ #include "AL/al.h" #include "AL/alc.h" +#include "al/debug.h" #include "alc/context.h" #include "almalloc.h" #include "core/except.h" diff --git a/alc/alc.cpp b/alc/alc.cpp index 63654b1a..aa65222c 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -61,6 +61,7 @@ #include "al/auxeffectslot.h" #include "al/buffer.h" +#include "al/debug.h" #include "al/effect.h" #include "al/filter.h" #include "al/listener.h" diff --git a/alc/context.cpp b/alc/context.cpp index 7d10a91d..755a1e41 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -122,6 +122,7 @@ void ALCcontext::setThreadContext(ALCcontext *context) noexcept ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device) : ContextBase{device.get()}, mALDevice{std::move(device)} { + mDebugGroups.emplace_back(DebugSource::Other, 0, std::string{}); } ALCcontext::~ALCcontext() @@ -328,6 +329,7 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, } std::unique_lock<std::mutex> debuglock{mDebugCbLock}; + DebugGroup &debug = mDebugGroups.back(); if(!mDebugEnabled.load()) UNLIKELY return; @@ -372,15 +374,15 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, const uint64_t idfilter{(1_u64 << (DebugSourceBase+al::to_underlying(source))) | (1_u64 << (DebugTypeBase+al::to_underlying(type))) | (uint64_t{id} << 32)}; - auto iditer = std::lower_bound(mDebugIdFilters.cbegin(), mDebugIdFilters.cend(), idfilter); - if(iditer != mDebugIdFilters.cend() && *iditer == idfilter) + auto iditer = std::lower_bound(debug.mIdFilters.cbegin(), debug.mIdFilters.cend(), idfilter); + if(iditer != debug.mIdFilters.cend() && *iditer == idfilter) return; const uint filter{(1u << (DebugSourceBase+al::to_underlying(source))) | (1u << (DebugTypeBase+al::to_underlying(type))) | (1u << (DebugSeverityBase+al::to_underlying(severity)))}; - auto iter = std::lower_bound(mDebugFilters.cbegin(), mDebugFilters.cend(), filter); - if(iter != mDebugFilters.cend() && *iter == filter) + auto iter = std::lower_bound(debug.mFilters.cbegin(), debug.mFilters.cend(), filter); + if(iter != debug.mFilters.cend() && *iter == filter) return; if(mDebugCb) diff --git a/alc/context.h b/alc/context.h index b3f548c8..3e31c9b8 100644 --- a/alc/context.h +++ b/alc/context.h @@ -33,57 +33,14 @@ struct ALeffect; struct ALeffectslot; struct ALsource; +struct DebugGroup; +struct DebugLogEntry; -using uint = unsigned int; - +enum class DebugSource : uint8_t; +enum class DebugType : uint8_t; +enum class DebugSeverity : uint8_t; -constexpr uint DebugSourceBase{0}; -enum class DebugSource : uint8_t { - API = 0, - System, - ThirdParty, - Application, - Other, -}; -constexpr uint DebugSourceCount{5}; - -constexpr uint DebugTypeBase{DebugSourceBase + DebugSourceCount}; -enum class DebugType : uint8_t { - Error = 0, - DeprecatedBehavior, - UndefinedBehavior, - Portability, - Performance, - Marker, - Other, -}; -constexpr uint DebugTypeCount{7}; - -constexpr uint DebugSeverityBase{DebugTypeBase + DebugTypeCount}; -enum class DebugSeverity : uint8_t { - High = 0, - Medium, - Low, - Notification, -}; -constexpr uint DebugSeverityCount{4}; - -struct LogEntry { - const DebugSource mSource; - const DebugType mType; - const DebugSeverity mSeverity; - const uint mId; - - std::string mMessage; - - template<typename T> - LogEntry(DebugSource source, DebugType type, uint id, DebugSeverity severity, T&& message) - : mSource{source}, mType{type}, mSeverity{severity}, mId{id} - , mMessage{std::forward<T>(message)} - { } - LogEntry(const LogEntry&) = default; - LogEntry(LogEntry&&) = default; -}; +using uint = unsigned int; struct SourceSubList { @@ -145,9 +102,8 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase { std::mutex mDebugCbLock; ALDEBUGPROCSOFT mDebugCb{}; void *mDebugParam{nullptr}; - std::vector<uint> mDebugFilters; - std::vector<uint64_t> mDebugIdFilters; - std::deque<LogEntry> mDebugLog; + std::vector<DebugGroup> mDebugGroups; + std::deque<DebugLogEntry> mDebugLog; ALlistener mListener{}; |