Open chergert opened 2 years ago
@nolanderc wanna take a stab at this?
I have been running into this myself after I added support for #include
: I have split some common functionality into separate files, but seeing as they can be used in both compute, vertex and fragment shaders, I decided to give them the extension .glsl
. However, as this is not a recognized extension, the language server crashes. As I see it, we have two options:
Unfortunately, it does not seem as if glslang provides an enum variant for such a "generic" shader language. Maybe we could just assume a compute shader, or similar, as they should be closest to a superset of all others?
How about a warning + sane default as you suggested?
I'm also interested in this. Recently I started going over some playlists at https://www.youtube.com/@TheCherno. He has stuff on OpenGL, Game Engines, C++ in general etc.
I think it was in one of his videos from the OpenGL playlist (possibly this one: https://youtu.be/2pv0Fbo-7ms but I'm not sure) where he explains that one of the systems he wants to build is to have one file for multiple shader types. We can probably take a look at how they handle code recognition in that project through some file splitting method. I assume something like this can be done for an LSP as well, but I'm not even an amateur with LSPs so I can't say more.
If there is interest in automatically handling concatenated files, that would certainly be nice. GTK does this, which is what I would want to use this for when working on GTK's GL renderer.
$ cat blend.glsl
// VERTEX_SHADER:
// blend.glsl
...
// FRAGMENT_SHADER:
// blend.glsl
...
Currently glslls just crashes if it can't discover the extension, which can create a lot of core dumps over time. Might be nice to just send an error back to the client.