mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-14 13:51:04 +00:00
5ca85ad9de
HLSL allows type keywords to also be identifiers, so a sequence such as "float half = 3" is valid, or more bizzarely, something like "float.float = int.uint + bool;" There are places this is not supported. E.g, it's permitted for struct members, but not struct names or functions. Also, vector or matrix types such as "float3" are not permitted as identifiers. This PR adds that support, as well as support for the "half" type. In production shaders, this was seen with variables named "half". The PR attempts to support this without breaking useful grammar errors such as "; expected" at the end of unterminated statements, so it errs on that side at the possible expense of failing to accept valid constructs containing a type keyword identifier. If others are discovered, they can be added. Also, half is now accepted as a valid type, alongside the min*float types.
29 lines
516 B
GLSL
29 lines
516 B
GLSL
|
|
struct foo_t {
|
|
float float;
|
|
};
|
|
|
|
float fn(float float) { return float; }
|
|
|
|
float4 main() : SV_Target0
|
|
{
|
|
float float = 7;
|
|
bool bool[2] = { float, float };
|
|
int int = bool[1];
|
|
uint uint = float + int;
|
|
min16float min16float = uint;
|
|
min10float min10float = min16float;
|
|
half half = 0.5;
|
|
|
|
{
|
|
foo_t float;
|
|
float.float = 42;
|
|
}
|
|
|
|
bool[0] = bool[1];
|
|
|
|
float = float + int + uint + min16float + min10float + (bool[0] ? int : float) + fn(float);
|
|
|
|
return float;
|
|
}
|