aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-01 01:22:29 -0700
committerChris Robinson <[email protected]>2023-05-01 01:22:29 -0700
commit931e261fe0944c1876a95a373996351f3424f399 (patch)
treee5114b184ccaa96a091c2ac51d6cf0db1a955556
parent343b2ce1b3395a672608552d5fe2b1a312c100b1 (diff)
Implement debug message filtering for IDs
-rw-r--r--al/debug.cpp71
-rw-r--r--alc/context.cpp11
-rw-r--r--alc/context.h2
3 files changed, 62 insertions, 22 deletions
diff --git a/al/debug.cpp b/al/debug.cpp
index 702f165a..26a69aff 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -183,9 +183,6 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlSOFT(ALenum source, ALenum typ
if(severity != AL_DONT_CARE_SOFT)
return context->setError(AL_INVALID_OPERATION,
"Debug severity must be AL_DONT_CARE_SOFT with IDs");
-
- return context->setError(AL_INVALID_VALUE, "Debug ID filtering not supported");
- return;
}
if(enable != AL_TRUE && enable != AL_FALSE)
@@ -222,27 +219,57 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageControlSOFT(ALenum source, ALenum typ
}
std::lock_guard<std::mutex> _{context->mDebugCbLock};
- auto apply_filter = [enable,&context](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 apply_severity = [apply_filter,svrIndices](const uint filter)
+ if(count > 0)
{
- std::for_each(svrIndices.cbegin(), svrIndices.cend(),
- [apply_filter,filter](const uint idx){ apply_filter(filter | (1<<idx)); });
- };
- auto apply_type = [apply_severity,typeIndices](const uint filter)
+ const uint filter{(1u<<srcIndices[0]) | (1u<<typeIndices[0])};
+
+ for(const uint id : al::as_span(ids, static_cast<uint>(count)))
+ {
+ if(!enable)
+ {
+ auto &idfilters = context->mDebugIdFilters[id];
+ auto iter = std::lower_bound(idfilters.cbegin(), idfilters.cend(), filter);
+ if(iter == idfilters.cend() || *iter != filter)
+ idfilters.insert(iter, filter);
+ continue;
+ }
+
+ auto iditer = context->mDebugIdFilters.find(id);
+ if(iditer == context->mDebugIdFilters.end())
+ continue;
+ auto iter = std::lower_bound(iditer->second.cbegin(), iditer->second.cend(), filter);
+ if(iter != iditer->second.cend() && *iter == filter)
+ {
+ iditer->second.erase(iter);
+ if(iditer->second.empty())
+ context->mDebugIdFilters.erase(iditer);
+ }
+ }
+ }
+ else
{
- std::for_each(typeIndices.cbegin(), typeIndices.cend(),
- [apply_severity,filter](const uint idx){ apply_severity(filter | (1<<idx)); });
- };
- std::for_each(srcIndices.cbegin(), srcIndices.cend(),
- [apply_type](const uint idx){ apply_type(1<<idx); });
+ auto apply_filter = [enable,&context](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 apply_severity = [apply_filter,svrIndices](const uint filter)
+ {
+ std::for_each(svrIndices.cbegin(), svrIndices.cend(),
+ [apply_filter,filter](const uint idx){ apply_filter(filter | (1<<idx)); });
+ };
+ auto apply_type = [apply_severity,typeIndices](const uint filter)
+ {
+ std::for_each(typeIndices.cbegin(), typeIndices.cend(),
+ [apply_severity,filter](const uint idx){ apply_severity(filter | (1<<idx)); });
+ };
+ std::for_each(srcIndices.cbegin(), srcIndices.cend(),
+ [apply_type](const uint idx){ apply_type(1<<idx); });
+ }
}
diff --git a/alc/context.cpp b/alc/context.cpp
index 66de19d6..d4019bc9 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -366,6 +366,17 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id,
throw std::runtime_error{"Unexpected debug severity value "+std::to_string(al::to_underlying(severity))};
};
+ auto iditer = mDebugIdFilters.find(id);
+ if(iditer != mDebugIdFilters.end())
+ {
+ const uint filter{(1u<<(DebugSourceBase+al::to_underlying(source)))
+ | (1u<<(DebugTypeBase+al::to_underlying(type)))};
+
+ auto iter = std::lower_bound(iditer->second.cbegin(), iditer->second.cend(), filter);
+ if(iter != iditer->second.cend() && *iter == filter)
+ return;
+ }
+
const uint filter{(1u<<(DebugSourceBase+al::to_underlying(source)))
| (1u<<(DebugTypeBase+al::to_underlying(type)))
| (1u<<(DebugSeverityBase+al::to_underlying(severity)))};
diff --git a/alc/context.h b/alc/context.h
index 031e061e..c626160b 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -6,6 +6,7 @@
#include <memory>
#include <mutex>
#include <stdint.h>
+#include <unordered_map>
#include <utility>
#include "AL/al.h"
@@ -145,6 +146,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
ALDEBUGPROCSOFT mDebugCb{};
void *mDebugParam{nullptr};
std::vector<uint> mDebugFilters;
+ std::unordered_map<uint,std::vector<uint>> mDebugIdFilters;
std::deque<LogEntry> mDebugLog;
ALlistener mListener{};