1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "syntaxhighlighterdata.h"
5
6static constexpr QByteArrayView shader_arg_names[] {
7 { "gl_Position" },
8 { "qt_MultiTexCoord0" },
9 { "qt_Vertex" },
10 { "qt_Matrix" },
11 { "qt_Opacity" },
12 { "vertCoord" },
13 { "fragCoord" },
14 { "texCoord" },
15 { "fragColor" },
16 { "iMouse" },
17 { "iResolution" },
18 { "iTime" },
19 { "iFrame" },
20 { "iSource" },
21 { "iSourceBlur1" },
22 { "iSourceBlur2" },
23 { "iSourceBlur3" },
24 { "iSourceBlur4" },
25 { "iSourceBlur5" },
26 { "iSourceBlur6" }
27};
28
29static constexpr QByteArrayView shader_tag_names[] {
30 { "@main" },
31 { "@nodes" },
32 { "@mesh" },
33 { "@blursources" },
34 { "@requires" }
35};
36
37// From https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.40.pdf
38// Not including functions only available with compatibility profile
39static constexpr QByteArrayView shader_function_names[] {
40 { "radians()" },
41 { "degrees()" },
42 { "sin()" },
43 { "cos()" },
44 { "tan()" },
45 { "asin()" },
46 { "acos()" },
47 { "atan()" },
48 { "sinh()" },
49 { "cosh()" },
50 { "tanh()" },
51 { "asinh()" },
52 { "acosh()" },
53 { "atanh()" },
54 { "pow()" },
55 { "exp()" },
56 { "log()" },
57 { "exp2()" },
58 { "log2()" },
59 { "sqrt()" },
60 { "inversesqrt()" },
61 { "abs()" },
62 { "sign()" },
63 { "floor()" },
64 { "trunc()" },
65 { "round()" },
66 { "roundEven()" },
67 { "ceil()" },
68 { "fract()" },
69 { "mod()" },
70 { "modf()" },
71 { "min()" },
72 { "max()" },
73 { "clamp()" },
74 { "mix()" },
75 { "step()" },
76 { "smoothstep()" },
77 { "isnan()" },
78 { "isinf()" },
79 { "floatBitsToInt()" },
80 { "intBitsToFloat()" },
81 { "fma()" },
82 { "frexp()" },
83 { "ldexp()" },
84 { "packUnorm2x16()" },
85 { "packSnorm2x16()" },
86 { "packUnorm4x8()" },
87 { "packSnorm4x8()" },
88 { "unpackUnorm2x16()" },
89 { "unpackSnorm2x16()" },
90 { "unpackUnorm4x8()" },
91 { "unpackSnorm4x8()" },
92 //{ "packDouble2x32()" }, // Not supported in HLSL
93 //{ "unpackDouble2x32()" },
94 { "packHalf2x16()" },
95 { "unpackHalf2x16()" },
96 { "length()" },
97 { "distance()" },
98 { "dot()" },
99 { "cross()" },
100 { "normalize()" },
101 { "faceforward()" },
102 { "reflect()" },
103 { "refract()" },
104 { "matrixCompMult()" },
105 { "outerProduct()" },
106 { "transpose()" },
107 { "determinant()" },
108 { "inverse()" },
109 { "lessThan()" },
110 { "lessThanEqual()" },
111 { "greaterThan()" },
112 { "greaterThanEqual()" },
113 { "equal()" },
114 { "notEqual()" },
115 { "any()" },
116 { "all()" },
117 { "not()" },
118 //{ "uaddCarry()" }, // Extended arithmetic is only available from ESSL 310
119 //{ "usubBorrow()" },
120 //{ "umulExtended()" },
121 //{ "imulExtended()" },
122 { "bitfieldExtract()" },
123 { "bitfieldInsert()" },
124 { "bitfieldReverse()" },
125 { "bitCount()" },
126 { "findLSB()" },
127 { "findMSB()" },
128 { "textureSize()" },
129 //{ "textureQueryLod()" }, // ImageQueryLod is only supported on MSL 2.2 and up.
130 //{ "textureQueryLevels()" }, // textureQueryLevels not supported in ES profile.
131 { "texture()" },
132 { "textureProj()" },
133 { "textureLod()" },
134 { "textureOffset()" },
135 { "texelFetch()" },
136 { "texelFetchOffset()" },
137 { "textureProjOffset()" },
138 { "textureLodOffset()" },
139 { "textureProjLod()" },
140 { "textureProjLodOffset()" },
141 { "textureGrad()" },
142 { "textureGradOffset()" },
143 { "textureProjGrad()" },
144 { "textureProjGradOffset()" },
145 //{ "textureGather()" }, // textureGather requires ESSL 310.
146 //{ "textureGatherOffset()" },
147 //{ "textureGatherOffsets()" },
148 //{ "atomicCounterIncrement()" }, // 'atomic counter types' : not allowed when using GLSL for Vulkan
149 //{ "atomicCounterDecrement()" },
150 //{ "atomicCounter()" },
151 //{ "atomicAdd()" }, // HLSL: interlocked targets must be groupshared or UAV elements
152 //{ "atomicMin()" },
153 //{ "atomicMax()" },
154 //{ "atomicAnd()" },
155 //{ "atomicOr()" },
156 //{ "atomicXor()" },
157 //{ "atomicExchange()" },
158 //{ "atomicCompSwap()" },
159 { "dFdx()" },
160 { "dFdy()" },
161 { "fwidth()" }
162 //{ "interpolateAtCentroid()" }, // Pull-model interpolation requires MSL 2.3.
163 //{ "interpolateAtSample()" },
164 //{ "interpolateAtOffset()" }
165};
166
167SyntaxHighlighterData::SyntaxHighlighterData()
168{
169}
170
171
172QList<QByteArrayView> SyntaxHighlighterData::reservedArgumentNames()
173{
174 return { std::begin(arr: shader_arg_names), std::end(arr: shader_arg_names) };
175}
176
177QList<QByteArrayView> SyntaxHighlighterData::reservedTagNames()
178{
179 return { std::begin(arr: shader_tag_names), std::end(arr: shader_tag_names) };
180}
181
182QList<QByteArrayView> SyntaxHighlighterData::reservedFunctionNames()
183{
184 return { std::begin(arr: shader_function_names), std::end(arr: shader_function_names) };
185}
186

source code of qtquickeffectmaker/tools/qqem/syntaxhighlighterdata.cpp