Open mosra opened 2 years ago
I'm not sure how do-able this would be, but would also be great if there was an easy way to just completely replace ex. the main()
function in the shaders.
I merged #576 yesterday, which resolves the major blockers here (see the updated list above). So this is getting closer to being doable ;)
Cool! Hoping https://github.com/mosra/magnum/issues/506 can be picked up as well once you free up.
Discussed on Gitter a while ago, putting it here to avoid forgetting the details.
The main idea is that vertex (fragment, geometry...) shaders would contain various extension placeholders using macros. At the very least one for defining extra uniforms / inputs / outputs, and one inside the main function, with actual code.
Then, the user would have an option to subclass the shader and supply an additonal file to the base class, which defines a subset of these macros, such as:
This file would be inserted as the very first (after the
#version
directive), to allow also enabling various extension in it:Similar approach is taken in Babylon.js: https://github.com/BabylonJS/Babylon.js/blob/35eb617f377d67383e70e263e8a19596d80b5069/packages/dev/core/src/Shaders/default.fragment.fx
What's left to figure out:
ShaderConfiguration
class supplied, like apps orVk
APIs do -- c5abcf51406ad675873bebcc01b903e8e47eab28Could this configuration be shared between GL and Vulkan to avoid code duplication?Probably not, at the very least the flags are different (Flag::UniformBuffers
are implicit on Vulkan).Can be done by overrridingNoCreate
and then*this = BaseShader{actualConstructorParameters};
in the constructor could work, but is kinda nasty.compile()
from #534 instead.Make extension points impossible there?Could be doable by overridingcompile()
from #534 and callingsubmitLink()
again after setting up the attributes.GlslangShaderConverter
with an ability to do "implicit includes" similarly to GCC's-include
option, doing all this via a-DVERTEX_SHADER_INTERFACE_EXTENSION=...
passed tomagnum-shaderconverter
would be PAINFUL.#ifdef MACRO #include MACRO
? Does that work in glslang?