-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Host buffers extension initial #1012
base: master
Are you sure you want to change the base?
Conversation
I don't think I like splitting the buffer pool like this, all the extra complexity and it doesn't handle the underlying issue of it not working between different drivers through the router, and leaves no way to know whether two devices or contexts can recognize each others' buffers aside from trying it. Two devices could have the extension, but not be able to share buffers if they're on two different drivers that support the extension independently. A better option may be to just make the buffer (and effect and filter) lists global, and a function to query if two given contexts or devices share them (this could increase lock contention, but if it's desired functionality, it may be worth the drawback). Or have some kind of share functionality, along the lines of |
Hi, @kcat , thanks for quick response!
This is not intended to work, in case if application uses 2 different openal implementations. Target use-case is application that uses only openal-soft and need to decouple buffer management from context management.
GLES-like share functionality does not really addressing issues that this extension is intended to solve. In Vulkan there are
OpenAL also cannot quite reuse those extensions as-is since buffers are opaque types and application doesn't know how-much memory to
If that OK, I'm fine with this. In that case |
Right but my point is, OpenAL Soft could just make the buffers global and implicitly sharable between its own devices, but the app would have no way to know whether two given devices can use the same buffers aside from just trying and see if it errors.
I'm not sure what GLES-like share functionality is like, but with GLX and WGL, it is a method of allowing multiple contexts to recognize each others' sharable objects (which don't rely on context-specific state). So you could create an OpenGL context, create another OpenGL context from the same driver and share with the previous context, then creating textures and stuff on one context will let them be accessible to the other. Similarly, you could create an OpenAL context, create another OpenAL context from the same driver and share it with the previous context, then creating buffers (and filters and effect objects) on one context will let them be accessible to the other context.
OpenAL Soft 1.23.1 supports
It's preferable over the split pool, but not really ideal since it leaves no way to know which contexts can share buffers. |
Thanks for response! I'll need to take a look into AL_EXT_STATIC_BUFFER first and see if it's good fit for the job and will be back! |
488e735
to
3e41047
Compare
After examining AL_EXT_STATIC_BUFFER: while static buffer can be used to achieve the goal, it has development and abstraction cost: game-engine would have to maintain something like a
I've pushed new changes for single-pool based solution: no new api-entries, but
Havent address this yet. So far can propose interface such as: |
Small bump to review: just want to sync on a direction of how extension is evolving |
Unfortunately it isn't, it will break ABI and cause potential problems for existing compiled code that's calling the function without expecting it to have a return value. I don't know the actual effect it'll have, but I'd expect different systems to have different behaviors, making it a potential danger even if it appears to work. I'm also not a fan of allowing With recent commits,
A buffer ID wouldn't be necessary, if two contexts can share buffers any valid buffer with one context would work with the other. Though I still prefer the idea of the app having to make a call to actively share resources, either with a function call just after context creation or a new context creation function, in case an implementation would need to do it on explicit request instead of implicitly sharing everywhere it can. |
Depend on calling convention. In source code I've found: #ifdef _WIN32
#define AL_APIENTRY __cdecl
#else
#define AL_APIENTRY
#endif For
It's difficult to express in api:
One more slightly tangent point to bring, for me would be EAX. |
I am not confident that this will work context-less. A context or device handle is needed to "talk" to a driver, and even though it could work in some situations, it wouldn't be reliable depending on how OpenAL is accessed.
That wouldn't happen. The "link" would be created during context creation (or immediately after, before any buffers are made). Essentially the In practice, the shared state would likely include filters and effects too, not just buffers.
Any context that is or will be shared with other contexts.
The buffer list can be shared as much as desired, as long as it doesn't overflow the reference counter (4 billion for a 32-bit counter).
The EAX memory is just a dummy counter, to pacify apps that think they're using audio hardware memory. It doesn't actually do anything as far as OpenAL Soft is concerned, all memory is the same, it's just pretending to do what apps expect when using it. There might need to be a bit of a think to ensure the counter doesn't break (maybe include it in the shared state?), but EAX is only for old apps and old apps wouldn't use a new extension for sharing resources, so an app wouldn't be using both EAX and sharing at the same time. |
In current implementation
Unfortunately this is not valid solution. If sharing api is so complex, game-engine can instead fallback on full-software emulation via This maintaining different non-compatible buffer-ID's defeats the purpose. Declaring buffers upfront also defeat the purpose.
Maybe I'm losing what is driver here. There are, AFAIK, no 'real' openal drivers anymore. And from application standpoint, ther eis little reason to support and link two different openal implementations sanctimoniously. If there is demand from other developers, we may provide extension only conditionally (only for PC+Mobile).
Good point. For now, reason why I'm focusing on buffer is lack of use-case for effects/filters to test. However they might be introduced afterward, as another extension or newer version of the same one. |
I mean conceptually. I don't think a method for this can be made to work without a context that would be satisfactory.
It wouldn't be complex. It would be using an alternative function for
The problem is OpenAL needs a device or context to know what to do with a call. If you want to decouple sound loading from sound devices, it will need to be loaded and managed separately from OpenAL. Perhaps using a combination of context sharing and Load sounds into your own memory buffer, along with it's format and any other info you want, and a buffer ID (which is 0 by default). When you create the first context, create it normally and then create buffers for any already-loaded sounds using In this way, the buffer ID would also act as a flag indicating if the sound buffer is in use by an OpenAL buffer, which would need to be deleted using any existing context before it can be explicitly freed.
Generic Software and Creative's hardware drivers still get used. Rapture3D is still around, AFAIK. But even with just OpenAL Soft, if it's used through the router for whatever reason, an OpenAL call won't get to OpenAL Soft without a context or device handle. |
Can you please clarify here: is my understanding correct, that openal uses |
Hi, following discussion in #1006, decide to create an extension prototype here. Do not have a experience with proposing api extensions, but need to start somewhere :)
Name
AL_SOFT_host_buffers
Overview
This extension allows application to allocate, deallocate and manipulate sound buffers without any active openal context.
Id's of those buffers are valid across openal-soft contexts, allowing seamless switching between different output devices.
Already tested this new api for gen/delete/data is my game-project - this enables to make sound code much more simple and provide well defined behavior when sound is uses across devices (builtin sound + headsets).
New Procedures and Functions
Those functions generally follow syntax of vanilla openal buffer-functions, for gen/delete/modify, with only change in return of error code. Returning an error-code is necessary, due to
alGetError
is bound toALCcontext
.For now keeping thins simple, one alloc/free/upload and basic get/set functions are implemented.
New Tokens
None.
Other information
Addressed by using upper bit if buffer-id, to signify that it belong to host-buffers. For applications that do not use this extension no extra locking should happen on primary path. Only exception now is
alSourceQueueBuffers
(see implementation details).I'm not really knowledgeable on how EAX should work, By looking in source code EXA seen to be device-depended. Solution for now to set
eax_x_ram_mode = EaxStorage::Accessible
, assuming that it software emulated EAX.Calling
EAXSetBufferMode
on host buffer generate a errorAL_INVALID_VALUE
alObjectLabelDirectEXT
Should not interact, as buffer name stored in device, generates
AL_INVALID_NAME
error