emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.82k stars 3.31k forks source link

alext.h does not define macros for absent extensions #22649

Open sergeyext opened 1 month ago

sergeyext commented 1 month ago

OpenAL does not require all extensions to work and provides alIsExtensionPresent to check if an extension works. My codebase (and I suppose many others) handles this situation like

if (alIsExtensionPresent("AL_SOFT_direct_channels")) {
    alSourcei(id, AL_DIRECT_CHANNELS_SOFT, AL_TRUE);
}

This code fails to compile with emscripten after cf8a0d0 and requires additional macros to fix. On the other hand, if you unconditionlessly call alSourcei(id, AL_DIRECT_CHANNELS_SOFT, AL_TRUE);, it will raise an AL_INVALID_ENUM error on a platform with no such extension, which is expected behavior.

I would like to suggest adding macros of unsupported extensions for compatibility with native code.

sbc100 commented 1 month ago

@gabeklavans would you be able to take a look?

sbc100 commented 1 month ago

To be clear the problem here is that we do not define AL_DIRECT_CHANNELS_SOFT after cf8a0d0?

gabeklavans commented 1 month ago

Sounds like a good point. I didn't consider that all macros would still need to be present in order to check if the extension is enabled on the system.

The total of possible extensions is a moving target, so it may not be feasible to get all of them in and keep them up to date, but I can definitely just throw a bunch in there, including the one you're missing.

I'd hope that openal will correctly report that the extensions that haven't been implemented in emscripten are in fact not present, but I admit I'm not aware of the internals of openal to know if this is the case. I hope adding these macros for unsupported extension names doesn't break things in that way!

sergeyext commented 1 month ago

To be clear the problem here is that we do not define AL_DIRECT_CHANNELS_SOFT after cf8a0d0?

Yes, that's correct. Also, here's the extension list with many more definitions.