aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-03 10:42:32 -0700
committerChris Robinson <[email protected]>2023-05-03 12:18:42 -0700
commitce588ea5a3c3ee6c7fce64ec501a03ebaca373d4 (patch)
tree56bdc75dc41cc4d59b88f086c974bd7a648dbc2a
parent90b0840d62a123e946e81f514bbe331897da8838 (diff)
Implement a context debug flag
Setting the debug flag at context creation enables more debug messages for the created context, and enables debug messages by default.
-rw-r--r--al/debug.cpp15
-rw-r--r--al/state.cpp23
-rw-r--r--alc/alc.cpp41
-rw-r--r--alc/context.cpp7
-rw-r--r--alc/context.h9
-rw-r--r--alc/inprogext.h11
6 files changed, 76 insertions, 30 deletions
diff --git a/al/debug.cpp b/al/debug.cpp
index fa16ff73..786fcd1f 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -248,6 +248,9 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageInsertEXT(ALenum source, ALenum type,
ContextRef context{GetContextRef()};
if(!context) UNLIKELY return;
+ if(!context->mContextFlags.test(ContextFlags::DebugBit))
+ return;
+
if(!message)
return context->setError(AL_INVALID_VALUE, "Null message pointer");
@@ -416,9 +419,10 @@ FORCE_ALIGN void AL_APIENTRY alPushDebugGroupEXT(ALenum source, ALuint id, ALsiz
newback.mFilters = oldback.mFilters;
newback.mIdFilters = oldback.mIdFilters;
- context->sendDebugMessage(debuglock, newback.mSource, DebugType::PushGroup, newback.mId,
- DebugSeverity::Notification, static_cast<ALsizei>(newback.mMessage.size()),
- newback.mMessage.data());
+ if(context->mContextFlags.test(ContextFlags::DebugBit))
+ context->sendDebugMessage(debuglock, newback.mSource, DebugType::PushGroup, newback.mId,
+ DebugSeverity::Notification, static_cast<ALsizei>(newback.mMessage.size()),
+ newback.mMessage.data());
}
FORCE_ALIGN void AL_APIENTRY alPopDebugGroupEXT(void) noexcept
@@ -440,8 +444,9 @@ FORCE_ALIGN void AL_APIENTRY alPopDebugGroupEXT(void) noexcept
std::string message{std::move(debug.mMessage)};
context->mDebugGroups.pop_back();
- context->sendDebugMessage(debuglock, source, DebugType::PopGroup, id,
- DebugSeverity::Notification, static_cast<ALsizei>(message.size()), message.data());
+ if(context->mContextFlags.test(ContextFlags::DebugBit))
+ context->sendDebugMessage(debuglock, source, DebugType::PopGroup, id,
+ DebugSeverity::Notification, static_cast<ALsizei>(message.size()), message.data());
}
diff --git a/al/state.cpp b/al/state.cpp
index 71c9b703..efc6398d 100644
--- a/al/state.cpp
+++ b/al/state.cpp
@@ -150,6 +150,7 @@ enum PropertyValue : ALenum {
MaxDebugMessageLength = AL_MAX_DEBUG_MESSAGE_LENGTH_EXT,
MaxDebugLoggedMessages = AL_MAX_DEBUG_LOGGED_MESSAGES_EXT,
MaxDebugGroupDepth = AL_MAX_DEBUG_GROUP_STACK_DEPTH_EXT,
+ ContextFlags = AL_CONTEXT_FLAGS_EXT,
#ifdef ALSOFT_EAX
EaxRamSize = AL_EAX_RAM_SIZE,
EaxRamFree = AL_EAX_RAM_FREE,
@@ -183,10 +184,11 @@ void GetValue(ALCcontext *context, ALenum pname, T *values)
return;
case AL_DOPPLER_VELOCITY:
- context->debugMessage(DebugSource::API, DebugType::DeprecatedBehavior, 0,
- DebugSeverity::Medium, -1,
- "AL_DOPPLER_VELOCITY is deprecated in AL 1.1, use AL_SPEED_OF_SOUND; "
- "AL_DOPPLER_VELOCITY -> AL_SPEED_OF_SOUND / 343.3f");
+ if(context->mContextFlags.test(ContextFlags::DebugBit)) UNLIKELY
+ context->debugMessage(DebugSource::API, DebugType::DeprecatedBehavior, 0,
+ DebugSeverity::Medium, -1,
+ "AL_DOPPLER_VELOCITY is deprecated in AL 1.1, use AL_SPEED_OF_SOUND; "
+ "AL_DOPPLER_VELOCITY -> AL_SPEED_OF_SOUND / 343.3f");
*values = cast_value(context->mDopplerVelocity);
return;
@@ -241,6 +243,10 @@ void GetValue(ALCcontext *context, ALenum pname, T *values)
*values = cast_value(MaxDebugGroupDepth);
return;
+ case AL_CONTEXT_FLAGS_EXT:
+ *values = cast_value(context->mContextFlags.to_ulong());
+ return;
+
#ifdef ALSOFT_EAX
#define EAX_ERROR "[alGetInteger] EAX not enabled."
@@ -618,10 +624,11 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if(!context) UNLIKELY return;
- context->debugMessage(DebugSource::API, DebugType::DeprecatedBehavior, 0,
- DebugSeverity::Medium, -1,
- "alDopplerVelocity is deprecated in AL 1.1, use alSpeedOfSound; "
- "alDopplerVelocity(x) -> alSpeedOfSound(343.3f * x)");
+ if(context->mContextFlags.test(ContextFlags::DebugBit)) UNLIKELY
+ context->debugMessage(DebugSource::API, DebugType::DeprecatedBehavior, 0,
+ DebugSeverity::Medium, -1,
+ "alDopplerVelocity is deprecated in AL 1.1, use alSpeedOfSound; "
+ "alDopplerVelocity(x) -> alSpeedOfSound(343.3f * x)");
if(!(value >= 0.0f && std::isfinite(value)))
context->setError(AL_INVALID_VALUE, "Doppler velocity %f out of range", value);
diff --git a/alc/alc.cpp b/alc/alc.cpp
index de5bc232..8932a084 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -573,6 +573,9 @@ constexpr struct {
DECL(ALC_INVALID_VALUE),
DECL(ALC_OUT_OF_MEMORY),
+ DECL(ALC_CONTEXT_FLAGS_EXT),
+ DECL(ALC_CONTEXT_DEBUG_BIT_EXT),
+
DECL(AL_INVALID),
DECL(AL_NONE),
@@ -1021,6 +1024,7 @@ constexpr ALCchar alcExtensionList[] =
"ALC_ENUMERATE_ALL_EXT "
"ALC_ENUMERATION_EXT "
"ALC_EXT_CAPTURE "
+ "ALC_EXTX_debug "
"ALC_EXT_DEDICATED "
"ALC_EXT_disconnect "
"ALC_EXT_EFX "
@@ -2619,11 +2623,12 @@ START_API_FUNC
return;
}
- ctx->debugMessage(DebugSource::API, DebugType::Portability, 0, DebugSeverity::Medium, -1,
- "alcSuspendContext behavior is not portable -- some implementations suspend all "
- "rendering, some only defer property changes, and some are completely no-op; consider "
- "using alcDevicePauseSOFT to suspend all rendering, or alDeferUpdatesSOFT to only defer "
- "property changes");
+ if(context->mContextFlags.test(ContextFlags::DebugBit)) UNLIKELY
+ ctx->debugMessage(DebugSource::API, DebugType::Portability, 0, DebugSeverity::Medium, -1,
+ "alcSuspendContext behavior is not portable -- some implementations suspend all "
+ "rendering, some only defer property changes, and some are completely no-op; consider "
+ "using alcDevicePauseSOFT to suspend all rendering, or alDeferUpdatesSOFT to only "
+ "defer property changes");
if(SuspendDefers)
{
@@ -2643,11 +2648,12 @@ START_API_FUNC
return;
}
- ctx->debugMessage(DebugSource::API, DebugType::Portability, 0, DebugSeverity::Medium, -1,
- "alcProcessContext behavior is not portable -- some implementations resume rendering, "
- "some apply deferred property changes, and some are completely no-op; consider using "
- "alcDeviceResumeSOFT to resume rendering, or alProcessUpdatesSOFT to apply deferred "
- "property changes");
+ if(context->mContextFlags.test(ContextFlags::DebugBit)) UNLIKELY
+ ctx->debugMessage(DebugSource::API, DebugType::Portability, 0, DebugSeverity::Medium, -1,
+ "alcProcessContext behavior is not portable -- some implementations resume rendering, "
+ "some apply deferred property changes, and some are completely no-op; consider using "
+ "alcDeviceResumeSOFT to resume rendering, or alProcessUpdatesSOFT to apply deferred "
+ "property changes");
if(SuspendDefers)
{
@@ -3366,7 +3372,20 @@ START_API_FUNC
return nullptr;
}
- ContextRef context{new ALCcontext{dev}};
+ ContextFlagBitset ctxflags{0};
+ if(attrList)
+ {
+ for(size_t i{0};attrList[i];i+=2)
+ {
+ if(attrList[i] == ALC_CONTEXT_FLAGS_EXT)
+ {
+ ctxflags = static_cast<ALuint>(attrList[i+1]);
+ break;
+ }
+ }
+ }
+
+ ContextRef context{new ALCcontext{dev, ctxflags}};
context->init();
if(auto volopt = dev->configValue<float>(nullptr, "volume-adjust"))
diff --git a/alc/context.cpp b/alc/context.cpp
index 6a2f57ca..2fbf67af 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -51,7 +51,7 @@ using voidp = void*;
constexpr ALchar alExtList[] =
"AL_EXT_ALAW "
"AL_EXT_BFORMAT "
- "AL_EXTX_DEBUG "
+ "AL_EXTX_debug "
"AL_EXT_DOUBLE "
"AL_EXT_EXPONENT_DISTANCE "
"AL_EXT_FLOAT32 "
@@ -119,10 +119,11 @@ void ALCcontext::setThreadContext(ALCcontext *context) noexcept
{ sThreadContext.set(context); }
#endif
-ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device)
- : ContextBase{device.get()}, mALDevice{std::move(device)}
+ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device, ContextFlagBitset flags)
+ : ContextBase{device.get()}, mALDevice{std::move(device)}, mContextFlags{flags}
{
mDebugGroups.emplace_back(DebugSource::Other, 0, std::string{});
+ mDebugEnabled.store(mContextFlags.test(ContextFlags::DebugBit), std::memory_order_relaxed);
}
ALCcontext::~ALCcontext()
diff --git a/alc/context.h b/alc/context.h
index 9381db04..402794eb 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -43,6 +43,12 @@ enum class DebugSeverity : uint8_t;
using uint = unsigned int;
+enum ContextFlags {
+ DebugBit = 0, /* ALC_CONTEXT_DEBUG_BIT_EXT */
+};
+using ContextFlagBitset = std::bitset<sizeof(ALuint)*8>;
+
+
struct DebugLogEntry {
const DebugSource mSource;
const DebugType mType;
@@ -103,6 +109,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
std::atomic<ALenum> mLastError{AL_NO_ERROR};
+ const ContextFlagBitset mContextFlags;
std::atomic<bool> mDebugEnabled{false};
DistanceModel mDistanceModel{DistanceModel::Default};
@@ -141,7 +148,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
std::string mExtensionListOverride{};
- ALCcontext(al::intrusive_ptr<ALCdevice> device);
+ ALCcontext(al::intrusive_ptr<ALCdevice> device, ContextFlagBitset flags);
ALCcontext(const ALCcontext&) = delete;
ALCcontext& operator=(const ALCcontext&) = delete;
~ALCcontext();
diff --git a/alc/inprogext.h b/alc/inprogext.h
index 9db3b65b..b39eaa58 100644
--- a/alc/inprogext.h
+++ b/alc/inprogext.h
@@ -54,8 +54,14 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotStopvSOFT(ALsizei n, const ALuint *
#define AL_STOP_SOURCES_ON_DISCONNECT_SOFT 0x19AB
#endif
-#ifndef AL_EXT_DEBUG
-#define AL_EXT_DEBUG
+#ifndef ALC_EXT_debug
+#define ALC_EXT_debug
+#define ALC_CONTEXT_FLAGS_EXT 0x19CE
+#define ALC_CONTEXT_DEBUG_BIT_EXT 0x0001
+#endif
+
+#ifndef AL_EXT_debug
+#define AL_EXT_debug
#define AL_DONT_CARE_EXT 0x0002
#define AL_DEBUG_OUTPUT_EXT 0x19B2
#define AL_DEBUG_CALLBACK_FUNCTION_EXT 0x19B3
@@ -85,6 +91,7 @@ AL_API void AL_APIENTRY alAuxiliaryEffectSlotStopvSOFT(ALsizei n, const ALuint *
#define AL_MAX_DEBUG_GROUP_STACK_DEPTH_EXT 0x19CB
#define AL_STACK_OVERFLOW_EXT 0x19CC
#define AL_STACK_UNDERFLOW_EXT 0x19CD
+#define AL_CONTEXT_FLAGS_EXT 0x19CE
typedef void (AL_APIENTRY*ALDEBUGPROCEXT)(ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message, void *userParam);
typedef void (AL_APIENTRY*LPALDEBUGMESSAGECALLBACKEXT)(ALDEBUGPROCEXT callback, void *userParam);