-
-
Couldn't load subscription status.
- Fork 441
Add TryGetExtension methods to AL & ALContext #598
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
Add TryGetExtension methods to AL & ALContext #598
Conversation
|
The ALContext TryGetExtension method I’d expect to mirror the ones in Vk and XR i.e. it’s basically the same method but with an extra parameter. All extension-related methods bar IsExtensionPresent itself should use ExtensionAttribute. Hope this helps! |
|
Thanks, that helped a bit. I did some research about the codebase and also looked into documentation to better understand what is going on. And now I agree that Anyway, I noticed that You mentioned an extra parameter. There is no separate I'll make a commit so that you could check if the method is correct. Then I'll add XML documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As requested, an initial lookover (not a full review)
Some comments:
- If you wanted to add
[Obsolete("This method has been deprecated and will be removed in Silk.NET 3.0. Please use TryGetExtension instead.")]toGetExtensionon both classes, that'd be much appreciated. - If you'd like to add
[Obsolete("This class is deprecated and will be removed in Silk.NET 3.0. Please use the TryGetExtension method on ALContext.")]toALExtensionLoaderagain would be much appreciated
| public bool TryGetExtension<T> | ||
| (out T ext) where T : NativeExtension<ALContext> => | ||
| !((ext = IsExtensionPresent(ExtensionAttribute.GetExtensionAttribute(typeof(T)).Name) | ||
| ? (T) Activator.CreateInstance(typeof(T), Context) | ||
| : null) is null); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should have a Device* parameter which you feed in as the first parameter of IsExtensionPresent. It's awful we weren't using that in GetExtension - we really should have been!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should XML documentation contain a remark This function doesn't check that the extension is enabled - you will get an error later on if you attempt to call an extension function from an extension that isn't loaded.? If I understand correctly, ALContext.TryGetExtension also doesn't check if it is enabled.
If yes, I think I should update the AL.TryGetExtension XML too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenAL doesn't have a concept of enabling extensions like Vulkan does - with Vulkan if you try to get the address to a function in an extension which is not enabled, you will get a symbol loading exception whereas OpenAL allows it and automatically grants access to all extensions available on that implementation. There is alEnable which enables the extension's functionality in some cases, but that's different to enabling the extension itself. So I would say leave that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much! Once again, your code is superb it's just missing a few stylistic choices we make in our codebase which could do with being implemented. All one click changes so no need to open the IDE :)
Co-authored-by: Dylan Perks <11160611+Perksey@users.noreply.github.com>
Summary of the PR
This PR adds
TryGetExtensionmethods toALandALContextclasses inSilk.NET.OpenALRelated issues, Discord discussions, or proposals
#574
Further Comments
TryGetExtensionmethod inALis nearly the same as in OpenGL bindings. It was trivial to copy-paste and then compare toGetExtensionto verify. The XML documentation was also taken fromGLand modified.However,
GetExtensionmethod inALContextis different and also it doesn't useExtensionAttribute. Also it requires a pointer to aDeviceto operate. So I am not sure if "copy-paste" approach would work. Should I convertALContext.GetExtensiontoTryGetExtension?Or maybe I am wrong, and it will be enough to copy existing method and import
Silk.NET.Core.Attributesnamespace?Just want to be sure.