Open phr34k opened 11 months ago
This sounds more like a GLSL spec question, perhaps something that can be added via a GLSL extension and thus perhaps it is something best discussed in the GLSL repository. If you would like, I can transfer this issue there for discussion of an extension spec, which would be needed before any glslang implementation could be accepted.
This could be solved with things such as :
layout(my_entry_point, local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(entry_point=my_entry_point, local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
That would not break most current implementation: If its not specified, local_size are uniform to all entry point, the same it is currently. If specified, we can override specific entry point.
That could also be propagated to every layout qualifier to add specific layout parameters to specific entry points. That would allow having multiple shader stage in a single file aswell. This way, we can have a closer control for every entry point than the one we have with current HLSL.
@arcady-lunarg I think you're right that it's intertwined with glsl specification, however to my knowledge alternative entrypoints is also a non-standard glslang specific (compiler-)feature, so I'm not sure if it should only be left to specification level to rectify the problem. I'd be quite okay with the solution @antaalt coins, at least to me it seems like a non-invasive solution that could likely be adapted to other scenarios where global state interferes with entry points feature.
To my understanding glslang presently supports for selecting an alternative entrypoints. While working with multiple compute shaders, I wondered what the correct way is to specifcy the workgroup size when their parameters differ for the respective entrypoints.
Consider the following example:
This would roughly be mapped like this, but also illustrates the problem. Most glsl snippets the local size is uniformly specified in global scope disassociated from the effective entrypoint so this causes double declaration problem.
One of the question I have is what is the official approach to this behavior without invoking/relying on preprocessor directives. After some quick tests I noticed this declaration statement can be inside the function body scope, that behavior seems conform the documented grammer outlined in "Ch 9. Shading Language Grammer" of "OpenGL Shading Language, Version 4.60.8".
In specific the "layout_qualifier" is reachable from the "function_definition" however lack of clear documented cases makes me question if it's actually a case of valid or undefined behavior, and/or if I can rely on traditional compiler optimisations e.g. function call elimination to negate the potentional double declaration.
Related to: