aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-01 17:11:49 -0700
committerChris Robinson <[email protected]>2023-05-01 17:11:49 -0700
commitbb08a416f1b0e31292b896f2f8845e365daee6b1 (patch)
tree065c1ec74167265451fd3396b7557be22f962c16 /al
parent89f67ad6f9878ecfb48b49ce0dd69b9ecb065d0b (diff)
Put the debug filters into a group
Diffstat (limited to 'al')
-rw-r--r--al/debug.cpp26
-rw-r--r--al/debug.h69
-rw-r--r--al/error.cpp1
3 files changed, 83 insertions, 13 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)
{
diff --git a/al/debug.h b/al/debug.h
index 23b0ca1b..c2147cf4 100644
--- a/al/debug.h
+++ b/al/debug.h
@@ -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"