Darkyenus / glsl4idea

A GLSL language plugin for IntelliJ IDEA
GNU Lesser General Public License v3.0
101 stars 31 forks source link

Support for GLSL loop/branch attributes #137

Closed skalarproduktraum closed 2 years ago

skalarproduktraum commented 6 years ago

Hi there,

first, thanks for a great plugin, it's really helpful :+1:

Now to the issue: For about a year now, glslang, Khronos' reference GLSL compiler, supports loop/branch attributes like [[unroll]], [[flatten]], etc. At the moment, these are not recognised by glsl4idea, and cause it to emit errors.

Is there a chance you'd include support for such attributes, or alternatively, what would be a good place to dig in your existent code to contribute support for these? (I already had a look at your parser code, but probably looked in the wrong places, so a hint would be awesome :+1: )

Thanks!

Darkyenus commented 6 years ago

It shouldn't be that hard to add, but before any such extension is added, its formal specification must be known. I couldn't find anything about it in GLSL 4.60 spec, is this a feature specific to that compiler?

skalarproduktraum commented 6 years ago

The unroll/flatten etc. attributes are part of the SPIR-V spec (https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html#_a_id_loop_control_a_loop_control), and glslang supports those when compiling to SPIR-V. Considering glslang is the reference compiler, it'd be awesome to have it at least as an optional feature.

Darkyenus commented 6 years ago

That is a SPIR-V binary documentation. I agree that it would be nice to have this feature, but formal grammar (syntax) specification is needed first. I.e. how can the tag look, where can it appear, what are valid values and where, should we check for invalid tag values or are they valid, etc.