Coverage Report

Created: 2025-07-04 07:23

/src/shaderc/third_party/glslang/glslang/HLSL/hlslParseables.cpp
Line
Count
Source (jump to first uncovered line)
1
//
2
// Copyright (C) 2016 LunarG, Inc.
3
//
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions
8
// are met:
9
//
10
//    Redistributions of source code must retain the above copyright
11
//    notice, this list of conditions and the following disclaimer.
12
//
13
//    Redistributions in binary form must reproduce the above
14
//    copyright notice, this list of conditions and the following
15
//    disclaimer in the documentation and/or other materials provided
16
//    with the distribution.
17
//
18
//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19
//    contributors may be used to endorse or promote products derived
20
//    from this software without specific prior written permission.
21
//
22
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
// POSSIBILITY OF SUCH DAMAGE.
34
//
35
36
//
37
// Create strings that declare built-in definitions, add built-ins programmatically
38
// that cannot be expressed in the strings, and establish mappings between
39
// built-in functions and operators.
40
//
41
// Where to put a built-in:
42
//   TBuiltInParseablesHlsl::initialize(version,profile) context-independent textual built-ins; add them to the right string
43
//   TBuiltInParseablesHlsl::initialize(resources,...)   context-dependent textual built-ins; add them to the right string
44
//   TBuiltInParseablesHlsl::identifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table,
45
//                                                including identifying what extensions are needed if a version does not allow a symbol
46
//   TBuiltInParseablesHlsl::identifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the
47
//                                                symbol table, including identifying what extensions are needed if a version does
48
//                                                not allow a symbol
49
//
50
51
#include "hlslParseables.h"
52
#include "hlslParseHelper.h"
53
#include <cctype>
54
#include <utility>
55
#include <algorithm>
56
57
namespace {  // anonymous namespace functions
58
59
// arg order queries
60
0
bool IsSamplerType(const char argType)     { return argType == 'S' || argType == 's'; }
61
0
bool IsArrayed(const char argOrder)        { return argOrder == '@' || argOrder == '&' || argOrder == '#'; }
62
0
bool IsTextureNonMS(const char argOrder)   { return argOrder == '%'; }
63
0
bool IsSubpassInput(const char argOrder)   { return argOrder == '[' || argOrder == ']'; }
64
0
bool IsArrayedTexture(const char argOrder) { return argOrder == '@'; }
65
0
bool IsTextureMS(const char argOrder)      { return argOrder == '$' || argOrder == '&'; }
66
0
bool IsMS(const char argOrder)             { return IsTextureMS(argOrder) || argOrder == ']'; }
67
0
bool IsBuffer(const char argOrder)         { return argOrder == '*' || argOrder == '~'; }
68
0
bool IsImage(const char argOrder)          { return argOrder == '!' || argOrder == '#' || argOrder == '~'; }
69
70
bool IsTextureType(const char argOrder)
71
0
{
72
0
    return IsTextureNonMS(argOrder) || IsArrayedTexture(argOrder) ||
73
0
           IsTextureMS(argOrder) || IsBuffer(argOrder) || IsImage(argOrder);
74
0
}
75
76
// Reject certain combinations that are illegal sample methods.  For example,
77
// 3D arrays.
78
bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim0)
79
0
{
80
0
    const bool isArrayed = IsArrayed(*argOrder);
81
0
    const bool isMS      = IsTextureMS(*argOrder);
82
0
    const bool isBuffer  = IsBuffer(*argOrder);
83
84
    // there are no 3D arrayed textures, or 3D SampleCmp(LevelZero)
85
0
    if (dim0 == 3 && (isArrayed || name == "SampleCmp" || name == "SampleCmpLevelZero"))
86
0
        return true;
87
88
0
    const int numArgs = int(std::count(argOrder, argOrder + strlen(argOrder), ',')) + 1;
89
90
    // Reject invalid offset forms with cubemaps
91
0
    if (dim0 == 4) {
92
0
        if ((name == "Sample"             && numArgs >= 4) ||
93
0
            (name == "SampleBias"         && numArgs >= 5) ||
94
0
            (name == "SampleCmp"          && numArgs >= 5) ||
95
0
            (name == "SampleCmpLevelZero" && numArgs >= 5) ||
96
0
            (name == "SampleGrad"         && numArgs >= 6) ||
97
0
            (name == "SampleLevel"        && numArgs >= 5))
98
0
            return true;
99
0
    }
100
101
0
    const bool isGather =
102
0
        (name == "Gather" ||
103
0
         name == "GatherRed" ||
104
0
         name == "GatherGreen" ||
105
0
         name == "GatherBlue"  ||
106
0
         name == "GatherAlpha");
107
108
0
    const bool isGatherCmp =
109
0
        (name == "GatherCmp"      ||
110
0
         name == "GatherCmpRed"   ||
111
0
         name == "GatherCmpGreen" ||
112
0
         name == "GatherCmpBlue"  ||
113
0
         name == "GatherCmpAlpha");
114
115
    // Reject invalid Gathers
116
0
    if (isGather || isGatherCmp) {
117
0
        if (dim0 == 1 || dim0 == 3)   // there are no 1D or 3D gathers
118
0
            return true;
119
120
        // no offset on cube or cube array gathers
121
0
        if (dim0 == 4) {
122
0
            if ((isGather && numArgs > 3) || (isGatherCmp && numArgs > 4))
123
0
                return true;
124
0
        }
125
0
    }
126
127
    // Reject invalid Loads
128
0
    if (name == "Load" && dim0 == 4)
129
0
        return true; // Load does not support any cubemaps, arrayed or not.
130
131
    // Multisample formats are only 2D and 2Darray
132
0
    if (isMS && dim0 != 2)
133
0
        return true;
134
135
    // Buffer are only 1D
136
0
    if (isBuffer && dim0 != 1)
137
0
        return true;
138
139
0
    return false;
140
0
}
141
142
// Return the number of the coordinate arg, if any
143
int CoordinateArgPos(const glslang::TString& name, bool isTexture)
144
0
{
145
0
    if (!isTexture || (name == "GetDimensions"))
146
0
        return -1;  // has none
147
0
    else if (name == "Load")
148
0
        return 1;
149
0
    else
150
0
        return 2;  // other texture methods are 2
151
0
}
152
153
// Some texture methods use an addition coordinate dimension for the mip
154
bool HasMipInCoord(const glslang::TString& name, bool isMS, bool isBuffer, bool isImage)
155
0
{
156
0
    return name == "Load" && !isMS && !isBuffer && !isImage;
157
0
}
158
159
// LOD calculations don't pass the array level in the coordinate.
160
bool NoArrayCoord(const glslang::TString& name)
161
0
{
162
0
    return name == "CalculateLevelOfDetail" || name == "CalculateLevelOfDetailUnclamped";
163
0
}
164
165
// Handle IO params marked with > or <
166
const char* IoParam(glslang::TString& s, const char* nthArgOrder)
167
0
{
168
0
    if (*nthArgOrder == '>') {           // output params
169
0
        ++nthArgOrder;
170
0
        s.append("out ");
171
0
    } else if (*nthArgOrder == '<') {    // input params
172
0
        ++nthArgOrder;
173
0
        s.append("in ");
174
0
    }
175
176
0
    return nthArgOrder;
177
0
}
178
179
// Handle repeated args
180
void HandleRepeatArg(const char*& arg, const char*& prev, const char* current)
181
0
{
182
0
    if (*arg == ',' || *arg == '\0')
183
0
        arg = prev;
184
0
    else
185
0
        prev = current;
186
0
}
187
188
// Return true for the end of a single argument key, which can be the end of the string, or
189
// the comma separator.
190
inline bool IsEndOfArg(const char* arg)
191
0
{
192
0
    return arg == nullptr || *arg == '\0' || *arg == ',';
193
0
}
194
195
// If this is a fixed vector size, such as V3, return the size.  Else return 0.
196
int FixedVecSize(const char* arg)
197
0
{
198
0
    while (!IsEndOfArg(arg)) {
199
0
        if (isdigit(*arg))
200
0
            return *arg - '0';
201
0
        ++arg;
202
0
    }
203
204
0
    return 0; // none found.
205
0
}
206
207
// Create and return a type name, using HLSL type conventions.
208
//
209
//    order:   S = scalar, V = vector, M = matrix
210
//    argType: F = float, D = double, I = int, U = uint, B = bool, S = sampler
211
//    dim0 = vector dimension, or matrix 1st dimension
212
//    dim1 = matrix 2nd dimension
213
glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, const char* argType, int dim0, int dim1)
214
0
{
215
0
    const bool isTranspose = (argOrder[0] == '^');
216
0
    const bool isTexture   = IsTextureType(argOrder[0]);
217
0
    const bool isArrayed   = IsArrayed(argOrder[0]);
218
0
    const bool isSampler   = IsSamplerType(argType[0]);
219
0
    const bool isMS        = IsMS(argOrder[0]);
220
0
    const bool isBuffer    = IsBuffer(argOrder[0]);
221
0
    const bool isImage     = IsImage(argOrder[0]);
222
0
    const bool isSubpass   = IsSubpassInput(argOrder[0]);
223
224
0
    char type  = *argType;
225
226
0
    if (isTranspose) {  // Take transpose of matrix dimensions
227
0
        std::swap(dim0, dim1);
228
0
    } else if (isTexture || isSubpass) {
229
0
        if (type == 'F')       // map base type to texture of that type.
230
0
            type = 'T';        // e.g, int -> itexture, uint -> utexture, etc.
231
0
        else if (type == 'I')
232
0
            type = 'i';
233
0
        else if (type == 'U')
234
0
            type = 'u';
235
0
    }
236
237
0
    if (isTranspose)
238
0
        ++argOrder;
239
240
0
    char order = *argOrder;
241
242
0
    switch (type) {
243
0
    case '-': s += "void";                                break;
244
0
    case 'F': s += "float";                               break;
245
0
    case 'D': s += "double";                              break;
246
0
    case 'I': s += "int";                                 break;
247
0
    case 'U': s += "uint";                                break;
248
0
    case 'L': s += "int64_t";                             break;
249
0
    case 'M': s += "uint64_t";                            break;
250
0
    case 'B': s += "bool";                                break;
251
0
    case 'S': s += "sampler";                             break;
252
0
    case 's': s += "SamplerComparisonState";              break;
253
0
    case 'T': s += ((isBuffer && isImage) ? "RWBuffer" :
254
0
                    isSubpass ? "SubpassInput" :
255
0
                    isBuffer ? "Buffer" :
256
0
                    isImage  ? "RWTexture" : "Texture");  break;
257
0
    case 'i': s += ((isBuffer && isImage) ? "RWBuffer" :
258
0
                    isSubpass ? "SubpassInput" :
259
0
                    isBuffer ? "Buffer" :
260
0
                    isImage ? "RWTexture" : "Texture");   break;
261
0
    case 'u': s += ((isBuffer && isImage) ? "RWBuffer" :
262
0
                    isSubpass ? "SubpassInput" :
263
0
                    isBuffer ? "Buffer" :
264
0
                    isImage ? "RWTexture" : "Texture");   break;
265
0
    default:  s += "UNKNOWN_TYPE";                        break;
266
0
    }
267
268
0
    if (isSubpass && isMS)
269
0
        s += "MS";
270
271
    // handle fixed vector sizes, such as float3, and only ever 3.
272
0
    const int fixedVecSize = FixedVecSize(argOrder);
273
0
    if (fixedVecSize != 0)
274
0
        dim0 = dim1 = fixedVecSize;
275
276
0
    const char dim0Char = ('0' + char(dim0));
277
0
    const char dim1Char = ('0' + char(dim1));
278
279
    // Add sampler dimensions
280
0
    if (isSampler || isTexture) {
281
0
        if ((order == 'V' || isTexture) && !isBuffer) {
282
0
            switch (dim0) {
283
0
            case 1: s += "1D";                   break;
284
0
            case 2: s += (isMS ? "2DMS" : "2D"); break;
285
0
            case 3: s += "3D";                   break;
286
0
            case 4: s += (type == 'S'? "CUBE" : "Cube"); break;
287
0
            default: s += "UNKNOWN_SAMPLER";     break;
288
0
            }
289
0
        }
290
0
    } else {
291
        // Non-sampler type:
292
        // verify dimensions
293
0
        if (((order == 'V' || order == 'M') && (dim0 < 1 || dim0 > 4)) ||
294
0
            (order == 'M' && (dim1 < 1 || dim1 > 4))) {
295
0
            s += "UNKNOWN_DIMENSION";
296
0
            return s;
297
0
        }
298
299
0
        switch (order) {
300
0
        case '-': break;  // no dimensions for voids
301
0
        case 'S': break;  // no dimensions on scalars
302
0
        case 'V':
303
0
            s += dim0Char;
304
0
            break;
305
0
        case 'M':
306
0
            s += dim0Char;
307
0
            s += 'x';
308
0
            s += dim1Char;
309
0
            break;
310
0
        default:
311
0
            break;
312
0
        }
313
0
    }
314
315
    // handle arrayed textures
316
0
    if (isArrayed)
317
0
        s += "Array";
318
319
0
    switch (type) {
320
0
    case 'i': s += "<int";   s += dim0Char; s += ">"; break;
321
0
    case 'u': s += "<uint";  s += dim0Char; s += ">"; break;
322
0
    case 'T': s += "<float"; s += dim0Char; s += ">"; break;
323
0
    default: break;
324
0
    }
325
326
0
    return s;
327
0
}
328
329
// This rejects prototypes not normally valid for GLSL and it's way of finding
330
// overloaded built-ins under implicit type conversion.
331
//
332
// It is possible that this is not needed, but that would require some tweaking
333
// of other rules to get the same results.
334
inline bool IsValid(const char* cname, char /* retOrder */, char /* retType */, char argOrder, char /* argType */, int dim0, int /* dim1 */)
335
0
{
336
0
    const bool isVec = (argOrder == 'V');
337
338
0
    const std::string name(cname);
339
340
    // these do not have vec1 versions
341
0
    if (dim0 == 1 && (name == "normalize" || name == "reflect" || name == "refract"))
342
0
        return false;
343
344
0
    if (!IsTextureType(argOrder) && (isVec && dim0 == 1)) // avoid vec1
345
0
        return false;
346
347
0
    return true;
348
0
}
349
350
// return position of end of argument specifier
351
inline const char* FindEndOfArg(const char* arg)
352
0
{
353
0
    while (!IsEndOfArg(arg))
354
0
        ++arg;
355
356
0
    return *arg == '\0' ? nullptr : arg;
357
0
}
358
359
// Return pointer to beginning of Nth argument specifier in the string.
360
inline const char* NthArg(const char* arg, int n)
361
0
{
362
0
    for (int x=0; x<n && arg; ++x)
363
0
        if ((arg = FindEndOfArg(arg)) != nullptr)
364
0
            ++arg;  // skip arg separator
365
366
0
    return arg;
367
0
}
368
369
inline void FindVectorMatrixBounds(const char* argOrder, int fixedVecSize, int& dim0Min, int& dim0Max, int& /*dim1Min*/, int& dim1Max)
370
0
{
371
0
    for (int arg = 0; ; ++arg) {
372
0
        const char* nthArgOrder(NthArg(argOrder, arg));
373
0
        if (nthArgOrder == nullptr)
374
0
            break;
375
0
        else if (*nthArgOrder == 'V' || IsSubpassInput(*nthArgOrder))
376
0
            dim0Max = 4;
377
0
        else if (*nthArgOrder == 'M')
378
0
            dim0Max = dim1Max = 4;
379
0
    }
380
381
0
    if (fixedVecSize > 0) // handle fixed sized vectors
382
0
        dim0Min = dim0Max = fixedVecSize;
383
0
}
384
385
} // end anonymous namespace
386
387
namespace glslang {
388
389
TBuiltInParseablesHlsl::TBuiltInParseablesHlsl()
390
0
{
391
0
}
392
393
//
394
// Handle creation of mat*mat specially, since it doesn't fall conveniently out of
395
// the generic prototype creation code below.
396
//
397
void TBuiltInParseablesHlsl::createMatTimesMat()
398
0
{
399
0
    TString& s = commonBuiltins;
400
401
0
    for (int xRows = 1; xRows <=4; xRows++) {
402
0
        for (int xCols = 1; xCols <=4; xCols++) {
403
0
            const int yRows = xCols;
404
0
            for (int yCols = 1; yCols <=4; yCols++) {
405
0
                const int retRows = xRows;
406
0
                const int retCols = yCols;
407
408
                // Create a mat * mat of the appropriate dimensions
409
0
                AppendTypeName(s, "M", "F", retRows, retCols);  // add return type
410
0
                s.append(" ");                                  // space between type and name
411
0
                s.append("mul");                                // intrinsic name
412
0
                s.append("(");                                  // open paren
413
414
0
                AppendTypeName(s, "M", "F", xRows, xCols);      // add X input
415
0
                s.append(", ");
416
0
                AppendTypeName(s, "M", "F", yRows, yCols);      // add Y input
417
418
0
                s.append(");\n");                               // close paren
419
0
            }
420
421
            // Create M*V
422
0
            AppendTypeName(s, "V", "F", xRows, 1);          // add return type
423
0
            s.append(" ");                                  // space between type and name
424
0
            s.append("mul");                                // intrinsic name
425
0
            s.append("(");                                  // open paren
426
427
0
            AppendTypeName(s, "M", "F", xRows, xCols);      // add X input
428
0
            s.append(", ");
429
0
            AppendTypeName(s, "V", "F", xCols, 1);          // add Y input
430
431
0
            s.append(");\n");                               // close paren
432
433
            // Create V*M
434
0
            AppendTypeName(s, "V", "F", xCols, 1);          // add return type
435
0
            s.append(" ");                                  // space between type and name
436
0
            s.append("mul");                                // intrinsic name
437
0
            s.append("(");                                  // open paren
438
439
0
            AppendTypeName(s, "V", "F", xRows, 1);          // add Y input
440
0
            s.append(", ");
441
0
            AppendTypeName(s, "M", "F", xRows, xCols);      // add X input
442
443
0
            s.append(");\n");                               // close paren
444
0
        }
445
0
    }
446
0
}
447
448
//
449
// Add all context-independent built-in functions and variables that are present
450
// for the given version and profile.  Share common ones across stages, otherwise
451
// make stage-specific entries.
452
//
453
// Most built-ins variables can be added as simple text strings.  Some need to
454
// be added programmatically, which is done later in IdentifyBuiltIns() below.
455
//
456
void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/)
457
0
{
458
0
    static const EShLanguageMask EShLangAll    = EShLanguageMask(EShLangCount - 1);
459
460
    // These are the actual stage masks defined in the documentation, in case they are
461
    // needed for future validation.  For now, they are commented out, and set below
462
    // to EShLangAll, to allow any intrinsic to be used in any shader, which is legal
463
    // if it is not called.
464
    //
465
    // static const EShLanguageMask EShLangPSCS   = EShLanguageMask(EShLangFragmentMask | EShLangComputeMask);
466
    // static const EShLanguageMask EShLangVSPSGS = EShLanguageMask(EShLangVertexMask | EShLangFragmentMask | EShLangGeometryMask);
467
    // static const EShLanguageMask EShLangCS     = EShLangComputeMask;
468
    // static const EShLanguageMask EShLangPS     = EShLangFragmentMask;
469
    // static const EShLanguageMask EShLangHS     = EShLangTessControlMask;
470
471
    // This set uses EShLangAll for everything.
472
0
    static const EShLanguageMask EShLangPSCS   = EShLangAll;
473
0
    static const EShLanguageMask EShLangVSPSGS = EShLangAll;
474
0
    static const EShLanguageMask EShLangCS     = EShLangAll;
475
0
    static const EShLanguageMask EShLangPS     = EShLangAll;
476
0
    static const EShLanguageMask EShLangHS     = EShLangAll;
477
0
    static const EShLanguageMask EShLangGS     = EShLangAll;
478
479
    // This structure encodes the prototype information for each HLSL intrinsic.
480
    // Because explicit enumeration would be cumbersome, it's procedurally generated.
481
    // orderKey can be:
482
    //   S = scalar, V = vector, M = matrix, - = void
483
    // typekey can be:
484
    //   D = double, F = float, U = uint, I = int, B = bool, S = sampler, s = shadowSampler, M = uint64_t, L = int64_t
485
    // An empty order or type key repeats the first one.  E.g: SVM,, means 3 args each of SVM.
486
    // '>' as first letter of order creates an output parameter
487
    // '<' as first letter of order creates an input parameter
488
    // '^' as first letter of order takes transpose dimensions
489
    // '%' as first letter of order creates texture of given F/I/U type (texture, itexture, etc)
490
    // '@' as first letter of order creates arrayed texture of given type
491
    // '$' / '&' as first letter of order creates 2DMS / 2DMSArray textures
492
    // '*' as first letter of order creates buffer object
493
    // '!' as first letter of order creates image object
494
    // '#' as first letter of order creates arrayed image object
495
    // '~' as first letter of order creates an image buffer object
496
    // '[' / ']' as first letter of order creates a SubpassInput/SubpassInputMS object
497
498
0
    static const struct {
499
0
        const char*   name;      // intrinsic name
500
0
        const char*   retOrder;  // return type key: empty matches order of 1st argument
501
0
        const char*   retType;   // return type key: empty matches type of 1st argument
502
0
        const char*   argOrder;  // argument order key
503
0
        const char*   argType;   // argument type key
504
0
        unsigned int  stage;     // stage mask
505
0
        bool          method;    // true if it's a method.
506
0
    } hlslIntrinsics[] = {
507
        // name                               retOrd   retType    argOrder          argType          stage mask     method
508
        // ----------------------------------------------------------------------------------------------------------------
509
0
        { "abort",                            nullptr, nullptr,   "-",              "-",             EShLangAll,    false },
510
0
        { "abs",                              nullptr, nullptr,   "SVM",            "DFUI",          EShLangAll,    false },
511
0
        { "acos",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
512
0
        { "all",                              "S",    "B",        "SVM",            "BFIU",          EShLangAll,    false },
513
0
        { "AllMemoryBarrier",                 nullptr, nullptr,   "-",              "-",             EShLangCS,     false },
514
0
        { "AllMemoryBarrierWithGroupSync",    nullptr, nullptr,   "-",              "-",             EShLangCS,     false },
515
0
        { "any",                              "S",     "B",       "SVM",            "BFIU",          EShLangAll,    false },
516
0
        { "asdouble",                         "S",     "D",       "S,",             "UI,",           EShLangAll,    false },
517
0
        { "asdouble",                         "V2",    "D",       "V2,",            "UI,",           EShLangAll,    false },
518
0
        { "asfloat",                          nullptr, "F",       "SVM",            "BFIU",          EShLangAll,    false },
519
0
        { "asin",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
520
0
        { "asint",                            nullptr, "I",       "SVM",            "FIU",           EShLangAll,    false },
521
0
        { "asuint",                           nullptr, "U",       "SVM",            "FIU",           EShLangAll,    false },
522
0
        { "atan",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
523
0
        { "atan2",                            nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
524
0
        { "ceil",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
525
0
        { "CheckAccessFullyMapped",           "S",     "B" ,      "S",              "U",             EShLangPSCS,   false },
526
0
        { "clamp",                            nullptr, nullptr,   "SVM,,",          "FUI,,",         EShLangAll,    false },
527
0
        { "clip",                             "-",     "-",       "SVM",            "FUI",           EShLangPS,     false },
528
0
        { "cos",                              nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
529
0
        { "cosh",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
530
0
        { "countbits",                        nullptr, nullptr,   "SV",             "UI",            EShLangAll,    false },
531
0
        { "cross",                            nullptr, nullptr,   "V3,",            "F,",            EShLangAll,    false },
532
0
        { "D3DCOLORtoUBYTE4",                 "V4",    "I",       "V4",             "F",             EShLangAll,    false },
533
0
        { "ddx",                              nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
534
0
        { "ddx_coarse",                       nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
535
0
        { "ddx_fine",                         nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
536
0
        { "ddy",                              nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
537
0
        { "ddy_coarse",                       nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
538
0
        { "ddy_fine",                         nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
539
0
        { "degrees",                          nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
540
0
        { "determinant",                      "S",     "F",       "M",              "F",             EShLangAll,    false },
541
0
        { "DeviceMemoryBarrier",              nullptr, nullptr,   "-",              "-",             EShLangPSCS,   false },
542
0
        { "DeviceMemoryBarrierWithGroupSync", nullptr, nullptr,   "-",              "-",             EShLangCS,     false },
543
0
        { "distance",                         "S",     "F",       "SV,",            "F,",            EShLangAll,    false },
544
0
        { "dot",                              "S",     nullptr,   "SV,",            "FI,",           EShLangAll,    false },
545
0
        { "dst",                              nullptr, nullptr,   "V4,",            "F,",            EShLangAll,    false },
546
        // { "errorf",                           "-",     "-",       "",             "",             EShLangAll,    false }, TODO: varargs
547
0
        { "EvaluateAttributeAtCentroid",      nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
548
0
        { "EvaluateAttributeAtSample",        nullptr, nullptr,   "SVM,S",          "F,U",           EShLangPS,     false },
549
0
        { "EvaluateAttributeSnapped",         nullptr, nullptr,   "SVM,V2",         "F,I",           EShLangPS,     false },
550
0
        { "exp",                              nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
551
0
        { "exp2",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
552
0
        { "f16tof32",                         nullptr, "F",       "SV",             "U",             EShLangAll,    false },
553
0
        { "f32tof16",                         nullptr, "U",       "SV",             "F",             EShLangAll,    false },
554
0
        { "faceforward",                      nullptr, nullptr,   "V,,",            "F,,",           EShLangAll,    false },
555
0
        { "firstbithigh",                     nullptr, nullptr,   "SV",             "UI",            EShLangAll,    false },
556
0
        { "firstbitlow",                      nullptr, nullptr,   "SV",             "UI",            EShLangAll,    false },
557
0
        { "floor",                            nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
558
0
        { "fma",                              nullptr, nullptr,   "SVM,,",          "D,,",           EShLangAll,    false },
559
0
        { "fmod",                             nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
560
0
        { "frac",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
561
0
        { "frexp",                            nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
562
0
        { "fwidth",                           nullptr, nullptr,   "SVM",            "F",             EShLangPS,     false },
563
0
        { "GetRenderTargetSampleCount",       "S",     "U",       "-",              "-",             EShLangAll,    false },
564
0
        { "GetRenderTargetSamplePosition",    "V2",    "F",       "V1",             "I",             EShLangAll,    false },
565
0
        { "GroupMemoryBarrier",               nullptr, nullptr,   "-",              "-",             EShLangCS,     false },
566
0
        { "GroupMemoryBarrierWithGroupSync",  nullptr, nullptr,   "-",              "-",             EShLangCS,     false },
567
0
        { "InterlockedAdd",                   "-",     "-",       "SVM,,>",         "FUI,,",          EShLangPSCS,   false },
568
0
        { "InterlockedAdd",                   "-",     "-",       "SVM,",           "FUI,",           EShLangPSCS,   false },
569
0
        { "InterlockedAnd",                   "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
570
0
        { "InterlockedAnd",                   "-",     "-",       "SVM,",           "UI,",           EShLangPSCS,   false },
571
0
        { "InterlockedCompareExchange",       "-",     "-",       "SVM,,,>",        "UI,,,",         EShLangPSCS,   false },
572
0
        { "InterlockedCompareStore",          "-",     "-",       "SVM,,",          "UI,,",          EShLangPSCS,   false },
573
0
        { "InterlockedExchange",              "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
574
0
        { "InterlockedMax",                   "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
575
0
        { "InterlockedMax",                   "-",     "-",       "SVM,",           "UI,",           EShLangPSCS,   false },
576
0
        { "InterlockedMin",                   "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
577
0
        { "InterlockedMin",                   "-",     "-",       "SVM,",           "UI,",           EShLangPSCS,   false },
578
0
        { "InterlockedOr",                    "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
579
0
        { "InterlockedOr",                    "-",     "-",       "SVM,",           "UI,",           EShLangPSCS,   false },
580
0
        { "InterlockedXor",                   "-",     "-",       "SVM,,>",         "UI,,",          EShLangPSCS,   false },
581
0
        { "InterlockedXor",                   "-",     "-",       "SVM,",           "UI,",           EShLangPSCS,   false },
582
0
        { "isfinite",                         nullptr, "B" ,      "SVM",            "F",             EShLangAll,    false },
583
0
        { "isinf",                            nullptr, "B" ,      "SVM",            "F",             EShLangAll,    false },
584
0
        { "isnan",                            nullptr, "B" ,      "SVM",            "F",             EShLangAll,    false },
585
0
        { "ldexp",                            nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
586
0
        { "length",                           "S",     "F",       "SV",             "F",             EShLangAll,    false },
587
0
        { "lerp",                             nullptr, nullptr,   "VM,,",           "F,,",           EShLangAll,    false },
588
0
        { "lerp",                             nullptr, nullptr,   "SVM,,S",         "F,,",           EShLangAll,    false },
589
0
        { "lit",                              "V4",    "F",       "S,,",            "F,,",           EShLangAll,    false },
590
0
        { "log",                              nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
591
0
        { "log10",                            nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
592
0
        { "log2",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
593
0
        { "mad",                              nullptr, nullptr,   "SVM,,",          "DFUI,,",        EShLangAll,    false },
594
0
        { "max",                              nullptr, nullptr,   "SVM,",           "FIU,",          EShLangAll,    false },
595
0
        { "min",                              nullptr, nullptr,   "SVM,",           "FIU,",          EShLangAll,    false },
596
0
        { "modf",                             nullptr, nullptr,   "SVM,>",          "FIU,",          EShLangAll,    false },
597
0
        { "msad4",                            "V4",    "U",       "S,V2,V4",        "U,,",           EShLangAll,    false },
598
0
        { "mul",                              "S",     nullptr,   "S,S",            "FI,",           EShLangAll,    false },
599
0
        { "mul",                              "V",     nullptr,   "S,V",            "FI,",           EShLangAll,    false },
600
0
        { "mul",                              "M",     nullptr,   "S,M",            "FI,",           EShLangAll,    false },
601
0
        { "mul",                              "V",     nullptr,   "V,S",            "FI,",           EShLangAll,    false },
602
0
        { "mul",                              "S",     nullptr,   "V,V",            "FI,",           EShLangAll,    false },
603
0
        { "mul",                              "M",     nullptr,   "M,S",            "FI,",           EShLangAll,    false },
604
        // mat*mat form of mul is handled in createMatTimesMat()
605
0
        { "noise",                            "S",     "F",       "V",              "F",             EShLangPS,     false },
606
0
        { "normalize",                        nullptr, nullptr,   "V",              "F",             EShLangAll,    false },
607
0
        { "pow",                              nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
608
0
        { "printf",                           nullptr, nullptr,   "-",              "-",             EShLangAll,    false },
609
0
        { "Process2DQuadTessFactorsAvg",      "-",     "-",       "V4,V2,>V4,>V2,", "F,,,,",         EShLangHS,     false },
610
0
        { "Process2DQuadTessFactorsMax",      "-",     "-",       "V4,V2,>V4,>V2,", "F,,,,",         EShLangHS,     false },
611
0
        { "Process2DQuadTessFactorsMin",      "-",     "-",       "V4,V2,>V4,>V2,", "F,,,,",         EShLangHS,     false },
612
0
        { "ProcessIsolineTessFactors",        "-",     "-",       "S,,>,>",         "F,,,",          EShLangHS,     false },
613
0
        { "ProcessQuadTessFactorsAvg",        "-",     "-",       "V4,S,>V4,>V2,",  "F,,,,",         EShLangHS,     false },
614
0
        { "ProcessQuadTessFactorsMax",        "-",     "-",       "V4,S,>V4,>V2,",  "F,,,,",         EShLangHS,     false },
615
0
        { "ProcessQuadTessFactorsMin",        "-",     "-",       "V4,S,>V4,>V2,",  "F,,,,",         EShLangHS,     false },
616
0
        { "ProcessTriTessFactorsAvg",         "-",     "-",       "V3,S,>V3,>S,",   "F,,,,",         EShLangHS,     false },
617
0
        { "ProcessTriTessFactorsMax",         "-",     "-",       "V3,S,>V3,>S,",   "F,,,,",         EShLangHS,     false },
618
0
        { "ProcessTriTessFactorsMin",         "-",     "-",       "V3,S,>V3,>S,",   "F,,,,",         EShLangHS,     false },
619
0
        { "radians",                          nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
620
0
        { "rcp",                              nullptr, nullptr,   "SVM",            "FD",            EShLangAll,    false },
621
0
        { "reflect",                          nullptr, nullptr,   "V,",             "F,",            EShLangAll,    false },
622
0
        { "refract",                          nullptr, nullptr,   "V,V,S",          "F,,",           EShLangAll,    false },
623
0
        { "reversebits",                      nullptr, nullptr,   "SV",             "UI",            EShLangAll,    false },
624
0
        { "round",                            nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
625
0
        { "rsqrt",                            nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
626
0
        { "saturate",                         nullptr, nullptr ,  "SVM",            "F",             EShLangAll,    false },
627
0
        { "sign",                             nullptr, nullptr,   "SVM",            "FI",            EShLangAll,    false },
628
0
        { "sin",                              nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
629
0
        { "sincos",                           "-",     "-",       "SVM,>,>",        "F,,",           EShLangAll,    false },
630
0
        { "sinh",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
631
0
        { "smoothstep",                       nullptr, nullptr,   "SVM,,",          "F,,",           EShLangAll,    false },
632
0
        { "sqrt",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
633
0
        { "step",                             nullptr, nullptr,   "SVM,",           "F,",            EShLangAll,    false },
634
0
        { "tan",                              nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
635
0
        { "tanh",                             nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
636
0
        { "tex1D",                            "V4",    "F",       "S,S",            "S,F",           EShLangPS,     false },
637
0
        { "tex1D",                            "V4",    "F",       "S,S,V1,",        "S,F,,",         EShLangPS,     false },
638
0
        { "tex1Dbias",                        "V4",    "F",       "S,V4",           "S,F",           EShLangPS,     false },
639
0
        { "tex1Dgrad",                        "V4",    "F",       "S,,,",           "S,F,,",         EShLangPS,     false },
640
0
        { "tex1Dlod",                         "V4",    "F",       "S,V4",           "S,F",           EShLangPS,     false },
641
0
        { "tex1Dproj",                        "V4",    "F",       "S,V4",           "S,F",           EShLangPS,     false },
642
0
        { "tex2D",                            "V4",    "F",       "V2,",            "S,F",           EShLangPS,     false },
643
0
        { "tex2D",                            "V4",    "F",       "V2,,,",          "S,F,,",         EShLangPS,     false },
644
0
        { "tex2Dbias",                        "V4",    "F",       "V2,V4",          "S,F",           EShLangPS,     false },
645
0
        { "tex2Dgrad",                        "V4",    "F",       "V2,,,",          "S,F,,",         EShLangPS,     false },
646
0
        { "tex2Dlod",                         "V4",    "F",       "V2,V4",          "S,F",           EShLangAll,    false },
647
0
        { "tex2Dproj",                        "V4",    "F",       "V2,V4",          "S,F",           EShLangPS,     false },
648
0
        { "tex3D",                            "V4",    "F",       "V3,",            "S,F",           EShLangPS,     false },
649
0
        { "tex3D",                            "V4",    "F",       "V3,,,",          "S,F,,",         EShLangPS,     false },
650
0
        { "tex3Dbias",                        "V4",    "F",       "V3,V4",          "S,F",           EShLangPS,     false },
651
0
        { "tex3Dgrad",                        "V4",    "F",       "V3,,,",          "S,F,,",         EShLangPS,     false },
652
0
        { "tex3Dlod",                         "V4",    "F",       "V3,V4",          "S,F",           EShLangPS,     false },
653
0
        { "tex3Dproj",                        "V4",    "F",       "V3,V4",          "S,F",           EShLangPS,     false },
654
0
        { "texCUBE",                          "V4",    "F",       "V4,V3",          "S,F",           EShLangPS,     false },
655
0
        { "texCUBE",                          "V4",    "F",       "V4,V3,,",        "S,F,,",         EShLangPS,     false },
656
0
        { "texCUBEbias",                      "V4",    "F",       "V4,",            "S,F",           EShLangPS,     false },
657
0
        { "texCUBEgrad",                      "V4",    "F",       "V4,V3,,",        "S,F,,",         EShLangPS,     false },
658
0
        { "texCUBElod",                       "V4",    "F",       "V4,",            "S,F",           EShLangPS,     false },
659
0
        { "texCUBEproj",                      "V4",    "F",       "V4,",            "S,F",           EShLangPS,     false },
660
0
        { "transpose",                        "^M",    nullptr,   "M",              "FUIB",          EShLangAll,    false },
661
0
        { "trunc",                            nullptr, nullptr,   "SVM",            "F",             EShLangAll,    false },
662
663
        // Texture object methods.  Return type can be overridden by shader declaration.
664
        // !O = no offset, O = offset
665
0
        { "Sample",             /*!O*/        "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangPS,    true },
666
0
        { "Sample",             /* O*/        "V4",    nullptr,   "%@,S,V,",        "FIU,S,F,I",      EShLangPS,    true },
667
668
0
        { "SampleBias",         /*!O*/        "V4",    nullptr,   "%@,S,V,S",       "FIU,S,F,F",      EShLangPS,    true },
669
0
        { "SampleBias",         /* O*/        "V4",    nullptr,   "%@,S,V,S,V",     "FIU,S,F,F,I",    EShLangPS,    true },
670
671
        // TODO: FXC accepts int/uint samplers here.  unclear what that means.
672
0
        { "SampleCmp",          /*!O*/        "S",     "F",       "%@,S,V,S",       "FIU,s,F,",       EShLangPS,    true },
673
0
        { "SampleCmp",          /* O*/        "S",     "F",       "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangPS,    true },
674
675
        // TODO: FXC accepts int/uint samplers here.  unclear what that means.
676
0
        { "SampleCmpLevelZero", /*!O*/        "S",     "F",       "%@,S,V,S",       "FIU,s,F,F",      EShLangPS,    true },
677
0
        { "SampleCmpLevelZero", /* O*/        "S",     "F",       "%@,S,V,S,V",     "FIU,s,F,F,I",    EShLangPS,    true },
678
679
0
        { "SampleGrad",         /*!O*/        "V4",    nullptr,   "%@,S,V,,",       "FIU,S,F,,",      EShLangAll,   true },
680
0
        { "SampleGrad",         /* O*/        "V4",    nullptr,   "%@,S,V,,,",      "FIU,S,F,,,I",    EShLangAll,   true },
681
682
0
        { "SampleLevel",        /*!O*/        "V4",    nullptr,   "%@,S,V,S",       "FIU,S,F,",       EShLangAll,   true },
683
0
        { "SampleLevel",        /* O*/        "V4",    nullptr,   "%@,S,V,S,V",     "FIU,S,F,,I",     EShLangAll,   true },
684
685
0
        { "Load",               /*!O*/        "V4",    nullptr,   "%@,V",           "FIU,I",          EShLangAll,   true },
686
0
        { "Load",               /* O*/        "V4",    nullptr,   "%@,V,V",         "FIU,I,I",        EShLangAll,   true },
687
0
        { "Load", /* +sampleidex*/            "V4",    nullptr,   "$&,V,S",         "FIU,I,I",        EShLangAll,   true },
688
0
        { "Load", /* +samplindex, offset*/    "V4",    nullptr,   "$&,V,S,V",       "FIU,I,I,I",      EShLangAll,   true },
689
690
        // RWTexture loads
691
0
        { "Load",                             "V4",    nullptr,   "!#,V",           "FIU,I",          EShLangAll,   true },
692
        // (RW)Buffer loads
693
0
        { "Load",                             "V4",    nullptr,   "~*1,V",          "FIU,I",          EShLangAll,   true },
694
695
0
        { "Gather",             /*!O*/        "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangAll,   true },
696
0
        { "Gather",             /* O*/        "V4",    nullptr,   "%@,S,V,V",       "FIU,S,F,I",      EShLangAll,   true },
697
698
0
        { "CalculateLevelOfDetail",           "S",     "F",       "%@,S,V",         "FUI,S,F",        EShLangPS,    true },
699
0
        { "CalculateLevelOfDetailUnclamped",  "S",     "F",       "%@,S,V",         "FUI,S,F",        EShLangPS,    true },
700
701
0
        { "GetSamplePosition",                "V2",    "F",       "$&2,S",          "FUI,I",          EShLangVSPSGS,true },
702
703
        //
704
        // UINT Width
705
        // UINT MipLevel, UINT Width, UINT NumberOfLevels
706
0
        { "GetDimensions",   /* 1D */         "-",     "-",       "%!~1,>S",        "FUI,U",          EShLangAll,   true },
707
0
        { "GetDimensions",   /* 1D */         "-",     "-",       "%!~1,>S",        "FUI,F",          EShLangAll,   true },
708
0
        { "GetDimensions",   /* 1D */         "-",     "-",       "%1,S,>S,",       "FUI,U,,",        EShLangAll,   true },
709
0
        { "GetDimensions",   /* 1D */         "-",     "-",       "%1,S,>S,",       "FUI,U,F,",       EShLangAll,   true },
710
711
        // UINT Width, UINT Elements
712
        // UINT MipLevel, UINT Width, UINT Elements, UINT NumberOfLevels
713
0
        { "GetDimensions",   /* 1DArray */    "-",     "-",       "@#1,>S,",        "FUI,U,",         EShLangAll,   true },
714
0
        { "GetDimensions",   /* 1DArray */    "-",     "-",       "@#1,>S,",        "FUI,F,",         EShLangAll,   true },
715
0
        { "GetDimensions",   /* 1DArray */    "-",     "-",       "@1,S,>S,,",      "FUI,U,,,",       EShLangAll,   true },
716
0
        { "GetDimensions",   /* 1DArray */    "-",     "-",       "@1,S,>S,,",      "FUI,U,F,,",      EShLangAll,   true },
717
718
        // UINT Width, UINT Height
719
        // UINT MipLevel, UINT Width, UINT Height, UINT NumberOfLevels
720
0
        { "GetDimensions",   /* 2D */         "-",     "-",       "%!2,>S,",        "FUI,U,",         EShLangAll,   true },
721
0
        { "GetDimensions",   /* 2D */         "-",     "-",       "%!2,>S,",        "FUI,F,",         EShLangAll,   true },
722
0
        { "GetDimensions",   /* 2D */         "-",     "-",       "%2,S,>S,,",      "FUI,U,,,",       EShLangAll,   true },
723
0
        { "GetDimensions",   /* 2D */         "-",     "-",       "%2,S,>S,,",      "FUI,U,F,,",      EShLangAll,   true },
724
725
        // UINT Width, UINT Height, UINT Elements
726
        // UINT MipLevel, UINT Width, UINT Height, UINT Elements, UINT NumberOfLevels
727
0
        { "GetDimensions",   /* 2DArray */    "-",     "-",       "@#2,>S,,",       "FUI,U,,",        EShLangAll,   true },
728
0
        { "GetDimensions",   /* 2DArray */    "-",     "-",       "@#2,>S,,",       "FUI,F,F,F",      EShLangAll,   true },
729
0
        { "GetDimensions",   /* 2DArray */    "-",     "-",       "@2,S,>S,,,",     "FUI,U,,,,",      EShLangAll,   true },
730
0
        { "GetDimensions",   /* 2DArray */    "-",     "-",       "@2,S,>S,,,",     "FUI,U,F,,,",     EShLangAll,   true },
731
732
        // UINT Width, UINT Height, UINT Depth
733
        // UINT MipLevel, UINT Width, UINT Height, UINT Depth, UINT NumberOfLevels
734
0
        { "GetDimensions",   /* 3D */         "-",     "-",       "%!3,>S,,",       "FUI,U,,",        EShLangAll,   true },
735
0
        { "GetDimensions",   /* 3D */         "-",     "-",       "%!3,>S,,",       "FUI,F,,",        EShLangAll,   true },
736
0
        { "GetDimensions",   /* 3D */         "-",     "-",       "%3,S,>S,,,",     "FUI,U,,,,",      EShLangAll,   true },
737
0
        { "GetDimensions",   /* 3D */         "-",     "-",       "%3,S,>S,,,",     "FUI,U,F,,,",     EShLangAll,   true },
738
739
        // UINT Width, UINT Height
740
        // UINT MipLevel, UINT Width, UINT Height, UINT NumberOfLevels
741
0
        { "GetDimensions",   /* Cube */       "-",     "-",       "%4,>S,",         "FUI,U,",         EShLangAll,   true },
742
0
        { "GetDimensions",   /* Cube */       "-",     "-",       "%4,>S,",         "FUI,F,",         EShLangAll,   true },
743
0
        { "GetDimensions",   /* Cube */       "-",     "-",       "%4,S,>S,,",      "FUI,U,,,",       EShLangAll,   true },
744
0
        { "GetDimensions",   /* Cube */       "-",     "-",       "%4,S,>S,,",      "FUI,U,F,,",      EShLangAll,   true },
745
746
        // UINT Width, UINT Height, UINT Elements
747
        // UINT MipLevel, UINT Width, UINT Height, UINT Elements, UINT NumberOfLevels
748
0
        { "GetDimensions",   /* CubeArray */  "-",     "-",       "@4,>S,,",        "FUI,U,,",        EShLangAll,   true },
749
0
        { "GetDimensions",   /* CubeArray */  "-",     "-",       "@4,>S,,",        "FUI,F,,",        EShLangAll,   true },
750
0
        { "GetDimensions",   /* CubeArray */  "-",     "-",       "@4,S,>S,,,",     "FUI,U,,,,",      EShLangAll,   true },
751
0
        { "GetDimensions",   /* CubeArray */  "-",     "-",       "@4,S,>S,,,",     "FUI,U,F,,,",     EShLangAll,   true },
752
753
        // UINT Width, UINT Height, UINT Samples
754
        // UINT Width, UINT Height, UINT Elements, UINT Samples
755
0
        { "GetDimensions",   /* 2DMS */       "-",     "-",       "$2,>S,,",        "FUI,U,,",        EShLangAll,   true },
756
0
        { "GetDimensions",   /* 2DMS */       "-",     "-",       "$2,>S,,",        "FUI,U,,",        EShLangAll,   true },
757
0
        { "GetDimensions",   /* 2DMSArray */  "-",     "-",       "&2,>S,,,",       "FUI,U,,,",       EShLangAll,   true },
758
0
        { "GetDimensions",   /* 2DMSArray */  "-",     "-",       "&2,>S,,,",       "FUI,U,,,",       EShLangAll,   true },
759
760
        // SM5 texture methods
761
0
        { "GatherRed",       /*!O*/           "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangAll,   true },
762
0
        { "GatherRed",       /* O*/           "V4",    nullptr,   "%@,S,V,",        "FIU,S,F,I",      EShLangAll,   true },
763
0
        { "GatherRed",       /* O, status*/   "V4",    nullptr,   "%@,S,V,,>S",     "FIU,S,F,I,U",    EShLangAll,   true },
764
0
        { "GatherRed",       /* O-4 */        "V4",    nullptr,   "%@,S,V,,,,",     "FIU,S,F,I,,,",   EShLangAll,   true },
765
0
        { "GatherRed",       /* O-4, status */"V4",    nullptr,   "%@,S,V,,,,,S",   "FIU,S,F,I,,,,U", EShLangAll,   true },
766
767
0
        { "GatherGreen",     /*!O*/           "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangAll,   true },
768
0
        { "GatherGreen",     /* O*/           "V4",    nullptr,   "%@,S,V,",        "FIU,S,F,I",      EShLangAll,   true },
769
0
        { "GatherGreen",     /* O, status*/   "V4",    nullptr,   "%@,S,V,,>S",     "FIU,S,F,I,U",    EShLangAll,   true },
770
0
        { "GatherGreen",     /* O-4 */        "V4",    nullptr,   "%@,S,V,,,,",     "FIU,S,F,I,,,",   EShLangAll,   true },
771
0
        { "GatherGreen",     /* O-4, status */"V4",    nullptr,   "%@,S,V,,,,,S",   "FIU,S,F,I,,,,U", EShLangAll,   true },
772
773
0
        { "GatherBlue",      /*!O*/           "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangAll,   true },
774
0
        { "GatherBlue",      /* O*/           "V4",    nullptr,   "%@,S,V,",        "FIU,S,F,I",      EShLangAll,   true },
775
0
        { "GatherBlue",      /* O, status*/   "V4",    nullptr,   "%@,S,V,,>S",     "FIU,S,F,I,U",    EShLangAll,   true },
776
0
        { "GatherBlue",      /* O-4 */        "V4",    nullptr,   "%@,S,V,,,,",     "FIU,S,F,I,,,",   EShLangAll,   true },
777
0
        { "GatherBlue",      /* O-4, status */"V4",    nullptr,   "%@,S,V,,,,,S",   "FIU,S,F,I,,,,U", EShLangAll,   true },
778
779
0
        { "GatherAlpha",     /*!O*/           "V4",    nullptr,   "%@,S,V",         "FIU,S,F",        EShLangAll,   true },
780
0
        { "GatherAlpha",     /* O*/           "V4",    nullptr,   "%@,S,V,",        "FIU,S,F,I",      EShLangAll,   true },
781
0
        { "GatherAlpha",     /* O, status*/   "V4",    nullptr,   "%@,S,V,,>S",     "FIU,S,F,I,U",    EShLangAll,   true },
782
0
        { "GatherAlpha",     /* O-4 */        "V4",    nullptr,   "%@,S,V,,,,",     "FIU,S,F,I,,,",   EShLangAll,   true },
783
0
        { "GatherAlpha",     /* O-4, status */"V4",    nullptr,   "%@,S,V,,,,,S",   "FIU,S,F,I,,,,U", EShLangAll,   true },
784
785
0
        { "GatherCmp",       /*!O*/           "V4",    nullptr,   "%@,S,V,S",       "FIU,s,F,",       EShLangAll,   true },
786
0
        { "GatherCmp",       /* O*/           "V4",    nullptr,   "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangAll,   true },
787
0
        { "GatherCmp",       /* O, status*/   "V4",    nullptr,   "%@,S,V,S,V,>S",  "FIU,s,F,,I,U",   EShLangAll,   true },
788
0
        { "GatherCmp",       /* O-4 */        "V4",    nullptr,   "%@,S,V,S,V,,,",  "FIU,s,F,,I,,,",  EShLangAll,   true },
789
0
        { "GatherCmp",       /* O-4, status */"V4",    nullptr,   "%@,S,V,S,V,,V,S","FIU,s,F,,I,,,,U",EShLangAll,   true },
790
791
0
        { "GatherCmpRed",    /*!O*/           "V4",    nullptr,   "%@,S,V,S",       "FIU,s,F,",       EShLangAll,   true },
792
0
        { "GatherCmpRed",    /* O*/           "V4",    nullptr,   "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangAll,   true },
793
0
        { "GatherCmpRed",    /* O, status*/   "V4",    nullptr,   "%@,S,V,S,V,>S",  "FIU,s,F,,I,U",   EShLangAll,   true },
794
0
        { "GatherCmpRed",    /* O-4 */        "V4",    nullptr,   "%@,S,V,S,V,,,",  "FIU,s,F,,I,,,",  EShLangAll,   true },
795
0
        { "GatherCmpRed",    /* O-4, status */"V4",    nullptr,   "%@,S,V,S,V,,V,S","FIU,s,F,,I,,,,U",EShLangAll,   true },
796
797
0
        { "GatherCmpGreen",  /*!O*/           "V4",    nullptr,   "%@,S,V,S",       "FIU,s,F,",       EShLangAll,   true },
798
0
        { "GatherCmpGreen",  /* O*/           "V4",    nullptr,   "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangAll,   true },
799
0
        { "GatherCmpGreen",  /* O, status*/   "V4",    nullptr,   "%@,S,V,S,V,>S",  "FIU,s,F,,I,U",   EShLangAll,   true },
800
0
        { "GatherCmpGreen",  /* O-4 */        "V4",    nullptr,   "%@,S,V,S,V,,,",  "FIU,s,F,,I,,,",  EShLangAll,   true },
801
0
        { "GatherCmpGreen",  /* O-4, status */"V4",    nullptr,   "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll,   true },
802
803
0
        { "GatherCmpBlue",   /*!O*/           "V4",    nullptr,   "%@,S,V,S",       "FIU,s,F,",       EShLangAll,   true },
804
0
        { "GatherCmpBlue",   /* O*/           "V4",    nullptr,   "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangAll,   true },
805
0
        { "GatherCmpBlue",   /* O, status*/   "V4",    nullptr,   "%@,S,V,S,V,>S",  "FIU,s,F,,I,U",   EShLangAll,   true },
806
0
        { "GatherCmpBlue",   /* O-4 */        "V4",    nullptr,   "%@,S,V,S,V,,,",  "FIU,s,F,,I,,,",  EShLangAll,   true },
807
0
        { "GatherCmpBlue",   /* O-4, status */"V4",    nullptr,   "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll,   true },
808
809
0
        { "GatherCmpAlpha",  /*!O*/           "V4",    nullptr,   "%@,S,V,S",       "FIU,s,F,",       EShLangAll,   true },
810
0
        { "GatherCmpAlpha",  /* O*/           "V4",    nullptr,   "%@,S,V,S,V",     "FIU,s,F,,I",     EShLangAll,   true },
811
0
        { "GatherCmpAlpha",  /* O, status*/   "V4",    nullptr,   "%@,S,V,S,V,>S",  "FIU,s,F,,I,U",   EShLangAll,   true },
812
0
        { "GatherCmpAlpha",  /* O-4 */        "V4",    nullptr,   "%@,S,V,S,V,,,",  "FIU,s,F,,I,,,",  EShLangAll,   true },
813
0
        { "GatherCmpAlpha",  /* O-4, status */"V4",    nullptr,   "%@,S,V,S,V,,,,S","FIU,s,F,,I,,,,U",EShLangAll,   true },
814
815
        // geometry methods
816
0
        { "Append",                           "-",     "-",       "-",              "-",              EShLangGS ,   true },
817
0
        { "RestartStrip",                     "-",     "-",       "-",              "-",              EShLangGS ,   true },
818
819
        // Methods for structurebuffers.  TODO: wildcard type matching.
820
0
        { "Load",                             nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
821
0
        { "Load2",                            nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
822
0
        { "Load3",                            nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
823
0
        { "Load4",                            nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
824
0
        { "Store",                            nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
825
0
        { "Store2",                           nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
826
0
        { "Store3",                           nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
827
0
        { "Store4",                           nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
828
0
        { "GetDimensions",                    nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
829
0
        { "InterlockedAdd",                   nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
830
0
        { "InterlockedAnd",                   nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
831
0
        { "InterlockedCompareExchange",       nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
832
0
        { "InterlockedCompareStore",          nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
833
0
        { "InterlockedExchange",              nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
834
0
        { "InterlockedMax",                   nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
835
0
        { "InterlockedMin",                   nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
836
0
        { "InterlockedOr",                    nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
837
0
        { "InterlockedXor",                   nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
838
0
        { "IncrementCounter",                 nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
839
0
        { "DecrementCounter",                 nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
840
0
        { "Consume",                          nullptr, nullptr,   "-",              "-",              EShLangAll,   true },
841
842
        // SM 6.0
843
844
0
        { "WaveIsFirstLane",                  "S",     "B",       "-",              "-",              EShLangPSCS,  false},
845
0
        { "WaveGetLaneCount",                 "S",     "U",       "-",              "-",              EShLangPSCS,  false},
846
0
        { "WaveGetLaneIndex",                 "S",     "U",       "-",              "-",              EShLangPSCS,  false},
847
0
        { "WaveActiveAnyTrue",                "S",     "B",       "S",              "B",              EShLangPSCS,  false},
848
0
        { "WaveActiveAllTrue",                "S",     "B",       "S",              "B",              EShLangPSCS,  false},
849
0
        { "WaveActiveBallot",                 "V4",    "U",       "S",              "B",              EShLangPSCS,  false},
850
0
        { "WaveReadLaneAt",                   nullptr, nullptr,   "SV,S",           "DFUI,U",         EShLangPSCS,  false},
851
0
        { "WaveReadLaneFirst",                nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
852
0
        { "WaveActiveAllEqual",               "S",     "B",       "SV",             "DFUI",           EShLangPSCS,  false},
853
0
        { "WaveActiveAllEqualBool",           "S",     "B",       "S",              "B",              EShLangPSCS,  false},
854
0
        { "WaveActiveCountBits",              "S",     "U",       "S",              "B",              EShLangPSCS,  false},
855
856
0
        { "WaveActiveSum",                    nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
857
0
        { "WaveActiveProduct",                nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
858
0
        { "WaveActiveBitAnd",                 nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
859
0
        { "WaveActiveBitOr",                  nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
860
0
        { "WaveActiveBitXor",                 nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
861
0
        { "WaveActiveMin",                    nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
862
0
        { "WaveActiveMax",                    nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
863
0
        { "WavePrefixSum",                    nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
864
0
        { "WavePrefixProduct",                nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
865
0
        { "WavePrefixCountBits",              "S",     "U",       "S",              "B",              EShLangPSCS,  false},
866
0
        { "QuadReadAcrossX",                  nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
867
0
        { "QuadReadAcrossY",                  nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
868
0
        { "QuadReadAcrossDiagonal",           nullptr, nullptr,   "SV",             "DFUI",           EShLangPSCS,  false},
869
0
        { "QuadReadLaneAt",                   nullptr, nullptr,   "SV,S",           "DFUI,U",         EShLangPSCS,  false},
870
871
        // Methods for subpass input objects
872
0
        { "SubpassLoad",                      "V4",    nullptr,   "[",              "FIU",            EShLangPS,    true },
873
0
        { "SubpassLoad",                      "V4",    nullptr,   "],S",            "FIU,I",          EShLangPS,    true },
874
875
        // Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet.
876
0
        { nullptr,                            nullptr, nullptr,   nullptr,      nullptr,  0, false },
877
0
    };
878
879
    // Create prototypes for the intrinsics.  TODO: Avoid ranged based for until all compilers can handle it.
880
0
    for (int icount = 0; hlslIntrinsics[icount].name; ++icount) {
881
0
        const auto& intrinsic = hlslIntrinsics[icount];
882
883
0
        for (int stage = 0; stage < EShLangCount; ++stage) {                                // for each stage...
884
0
            if ((intrinsic.stage & (1<<stage)) == 0) // skip inapplicable stages
885
0
                continue;
886
887
            // reference to either the common builtins, or stage specific builtins.
888
0
            TString& s = (intrinsic.stage == EShLangAll) ? commonBuiltins : stageBuiltins[stage];
889
890
0
            for (const char* argOrder = intrinsic.argOrder; !IsEndOfArg(argOrder); ++argOrder) { // for each order...
891
0
                const bool isTexture   = IsTextureType(*argOrder);
892
0
                const bool isArrayed   = IsArrayed(*argOrder);
893
0
                const bool isMS        = IsTextureMS(*argOrder);
894
0
                const bool isBuffer    = IsBuffer(*argOrder);
895
0
                const bool isImage     = IsImage(*argOrder);
896
0
                const bool mipInCoord  = HasMipInCoord(intrinsic.name, isMS, isBuffer, isImage);
897
0
                const int fixedVecSize = FixedVecSize(argOrder);
898
0
                const int coordArg     = CoordinateArgPos(intrinsic.name, isTexture);
899
900
                // calculate min and max vector and matrix dimensions
901
0
                int dim0Min = 1;
902
0
                int dim0Max = 1;
903
0
                int dim1Min = 1;
904
0
                int dim1Max = 1;
905
906
0
                FindVectorMatrixBounds(argOrder, fixedVecSize, dim0Min, dim0Max, dim1Min, dim1Max);
907
908
0
                for (const char* argType = intrinsic.argType; !IsEndOfArg(argType); ++argType) { // for each type...
909
0
                    for (int dim0 = dim0Min; dim0 <= dim0Max; ++dim0) {          // for each dim 0...
910
0
                        for (int dim1 = dim1Min; dim1 <= dim1Max; ++dim1) {      // for each dim 1...
911
0
                            const char* retOrder = intrinsic.retOrder ? intrinsic.retOrder : argOrder;
912
0
                            const char* retType  = intrinsic.retType  ? intrinsic.retType  : argType;
913
914
0
                            if (!IsValid(intrinsic.name, *retOrder, *retType, *argOrder, *argType, dim0, dim1))
915
0
                                continue;
916
917
                            // Reject some forms of sample methods that don't exist.
918
0
                            if (isTexture && IsIllegalSample(intrinsic.name, argOrder, dim0))
919
0
                                continue;
920
921
0
                            AppendTypeName(s, retOrder, retType, dim0, dim1);  // add return type
922
0
                            s.append(" ");                                     // space between type and name
923
924
                            // methods have a prefix.  TODO: it would be better as an invalid identifier character,
925
                            // but that requires a scanner change.
926
0
                            if (intrinsic.method)
927
0
                                s.append(BUILTIN_PREFIX);
928
929
0
                            s.append(intrinsic.name);                          // intrinsic name
930
0
                            s.append("(");                                     // open paren
931
932
0
                            const char* prevArgOrder = nullptr;
933
0
                            const char* prevArgType = nullptr;
934
935
                            // Append argument types, if any.
936
0
                            for (int arg = 0; ; ++arg) {
937
0
                                const char* nthArgOrder(NthArg(argOrder, arg));
938
0
                                const char* nthArgType(NthArg(argType, arg));
939
940
0
                                if (nthArgOrder == nullptr || nthArgType == nullptr)
941
0
                                    break;
942
943
                                // cube textures use vec3 coordinates
944
0
                                int argDim0 = isTexture && arg > 0 ? std::min(dim0, 3) : dim0;
945
946
0
                                s.append(arg > 0 ? ", ": "");  // comma separator if needed
947
948
0
                                const char* orderBegin = nthArgOrder;
949
0
                                nthArgOrder = IoParam(s, nthArgOrder);
950
951
                                // Comma means use the previous argument order and type.
952
0
                                HandleRepeatArg(nthArgOrder, prevArgOrder, orderBegin);
953
0
                                HandleRepeatArg(nthArgType,  prevArgType, nthArgType);
954
955
                                // In case the repeated arg has its own I/O marker
956
0
                                nthArgOrder = IoParam(s, nthArgOrder);
957
958
                                // arrayed textures have one extra coordinate dimension, except for
959
                                // the CalculateLevelOfDetail family.
960
0
                                if (isArrayed && arg == coordArg && !NoArrayCoord(intrinsic.name))
961
0
                                    argDim0++;
962
963
                                // Some texture methods use an addition arg dimension to hold mip
964
0
                                if (arg == coordArg && mipInCoord)
965
0
                                    argDim0++;
966
967
                                // For textures, the 1D case isn't a 1-vector, but a scalar.
968
0
                                if (isTexture && argDim0 == 1 && arg > 0 && *nthArgOrder == 'V')
969
0
                                    nthArgOrder = "S";
970
971
0
                                AppendTypeName(s, nthArgOrder, nthArgType, argDim0, dim1); // Add arguments
972
0
                            }
973
974
0
                            s.append(");\n");            // close paren and trailing semicolon
975
0
                        } // dim 1 loop
976
0
                    } // dim 0 loop
977
0
                } // arg type loop
978
979
                // skip over special characters
980
0
                if (isTexture && isalpha(argOrder[1]))
981
0
                    ++argOrder;
982
0
                if (isdigit(argOrder[1]))
983
0
                    ++argOrder;
984
0
            } // arg order loop
985
986
0
            if (intrinsic.stage == EShLangAll) // common builtins are only added once.
987
0
                break;
988
0
        }
989
0
    }
990
991
0
    createMatTimesMat(); // handle this case separately, for convenience
992
993
    // printf("Common:\n%s\n",   getCommonString().c_str());
994
    // printf("Frag:\n%s\n",     getStageString(EShLangFragment).c_str());
995
    // printf("Vertex:\n%s\n",   getStageString(EShLangVertex).c_str());
996
    // printf("Geo:\n%s\n",      getStageString(EShLangGeometry).c_str());
997
    // printf("TessCtrl:\n%s\n", getStageString(EShLangTessControl).c_str());
998
    // printf("TessEval:\n%s\n", getStageString(EShLangTessEvaluation).c_str());
999
    // printf("Compute:\n%s\n",  getStageString(EShLangCompute).c_str());
1000
0
}
1001
1002
//
1003
// Add context-dependent built-in functions and variables that are present
1004
// for the given version and profile.  All the results are put into just the
1005
// commonBuiltins, because it is called for just a specific stage.  So,
1006
// add stage-specific entries to the commonBuiltins, and only if that stage
1007
// was requested.
1008
//
1009
void TBuiltInParseablesHlsl::initialize(const TBuiltInResource& /*resources*/, int /*version*/, EProfile /*profile*/,
1010
                                        const SpvVersion& /*spvVersion*/, EShLanguage /*language*/)
1011
0
{
1012
0
}
1013
1014
//
1015
// Finish adding/processing context-independent built-in symbols.
1016
// 1) Programmatically add symbols that could not be added by simple text strings above.
1017
// 2) Map built-in functions to operators, for those that will turn into an operation node
1018
//    instead of remaining a function call.
1019
// 3) Tag extension-related symbols added to their base version with their extensions, so
1020
//    that if an early version has the extension turned off, there is an error reported on use.
1021
//
1022
void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/, EShLanguage /*language*/,
1023
                                              TSymbolTable& symbolTable)
1024
0
{
1025
    // symbolTable.relateToOperator("abort",                       EOpAbort);
1026
0
    symbolTable.relateToOperator("abs",                         EOpAbs);
1027
0
    symbolTable.relateToOperator("acos",                        EOpAcos);
1028
0
    symbolTable.relateToOperator("all",                         EOpAll);
1029
0
    symbolTable.relateToOperator("AllMemoryBarrier",            EOpMemoryBarrier);
1030
0
    symbolTable.relateToOperator("AllMemoryBarrierWithGroupSync", EOpAllMemoryBarrierWithGroupSync);
1031
0
    symbolTable.relateToOperator("any",                         EOpAny);
1032
0
    symbolTable.relateToOperator("asdouble",                    EOpAsDouble);
1033
0
    symbolTable.relateToOperator("asfloat",                     EOpIntBitsToFloat);
1034
0
    symbolTable.relateToOperator("asin",                        EOpAsin);
1035
0
    symbolTable.relateToOperator("asint",                       EOpFloatBitsToInt);
1036
0
    symbolTable.relateToOperator("asuint",                      EOpFloatBitsToUint);
1037
0
    symbolTable.relateToOperator("atan",                        EOpAtan);
1038
0
    symbolTable.relateToOperator("atan2",                       EOpAtan);
1039
0
    symbolTable.relateToOperator("ceil",                        EOpCeil);
1040
    // symbolTable.relateToOperator("CheckAccessFullyMapped");
1041
0
    symbolTable.relateToOperator("clamp",                       EOpClamp);
1042
0
    symbolTable.relateToOperator("clip",                        EOpClip);
1043
0
    symbolTable.relateToOperator("cos",                         EOpCos);
1044
0
    symbolTable.relateToOperator("cosh",                        EOpCosh);
1045
0
    symbolTable.relateToOperator("countbits",                   EOpBitCount);
1046
0
    symbolTable.relateToOperator("cross",                       EOpCross);
1047
0
    symbolTable.relateToOperator("D3DCOLORtoUBYTE4",            EOpD3DCOLORtoUBYTE4);
1048
0
    symbolTable.relateToOperator("ddx",                         EOpDPdx);
1049
0
    symbolTable.relateToOperator("ddx_coarse",                  EOpDPdxCoarse);
1050
0
    symbolTable.relateToOperator("ddx_fine",                    EOpDPdxFine);
1051
0
    symbolTable.relateToOperator("ddy",                         EOpDPdy);
1052
0
    symbolTable.relateToOperator("ddy_coarse",                  EOpDPdyCoarse);
1053
0
    symbolTable.relateToOperator("ddy_fine",                    EOpDPdyFine);
1054
0
    symbolTable.relateToOperator("degrees",                     EOpDegrees);
1055
0
    symbolTable.relateToOperator("determinant",                 EOpDeterminant);
1056
0
    symbolTable.relateToOperator("DeviceMemoryBarrier",         EOpDeviceMemoryBarrier);
1057
0
    symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync", EOpDeviceMemoryBarrierWithGroupSync);
1058
0
    symbolTable.relateToOperator("distance",                    EOpDistance);
1059
0
    symbolTable.relateToOperator("dot",                         EOpDot);
1060
0
    symbolTable.relateToOperator("dst",                         EOpDst);
1061
    // symbolTable.relateToOperator("errorf",                      EOpErrorf);
1062
0
    symbolTable.relateToOperator("EvaluateAttributeAtCentroid", EOpInterpolateAtCentroid);
1063
0
    symbolTable.relateToOperator("EvaluateAttributeAtSample",   EOpInterpolateAtSample);
1064
0
    symbolTable.relateToOperator("EvaluateAttributeSnapped",    EOpEvaluateAttributeSnapped);
1065
0
    symbolTable.relateToOperator("exp",                         EOpExp);
1066
0
    symbolTable.relateToOperator("exp2",                        EOpExp2);
1067
0
    symbolTable.relateToOperator("f16tof32",                    EOpF16tof32);
1068
0
    symbolTable.relateToOperator("f32tof16",                    EOpF32tof16);
1069
0
    symbolTable.relateToOperator("faceforward",                 EOpFaceForward);
1070
0
    symbolTable.relateToOperator("firstbithigh",                EOpFindMSB);
1071
0
    symbolTable.relateToOperator("firstbitlow",                 EOpFindLSB);
1072
0
    symbolTable.relateToOperator("floor",                       EOpFloor);
1073
0
    symbolTable.relateToOperator("fma",                         EOpFma);
1074
0
    symbolTable.relateToOperator("fmod",                        EOpMod);
1075
0
    symbolTable.relateToOperator("frac",                        EOpFract);
1076
0
    symbolTable.relateToOperator("frexp",                       EOpFrexp);
1077
0
    symbolTable.relateToOperator("fwidth",                      EOpFwidth);
1078
    // symbolTable.relateToOperator("GetRenderTargetSampleCount");
1079
    // symbolTable.relateToOperator("GetRenderTargetSamplePosition");
1080
0
    symbolTable.relateToOperator("GroupMemoryBarrier",          EOpWorkgroupMemoryBarrier);
1081
0
    symbolTable.relateToOperator("GroupMemoryBarrierWithGroupSync", EOpWorkgroupMemoryBarrierWithGroupSync);
1082
0
    symbolTable.relateToOperator("InterlockedAdd",              EOpInterlockedAdd);
1083
0
    symbolTable.relateToOperator("InterlockedAnd",              EOpInterlockedAnd);
1084
0
    symbolTable.relateToOperator("InterlockedCompareExchange",  EOpInterlockedCompareExchange);
1085
0
    symbolTable.relateToOperator("InterlockedCompareStore",     EOpInterlockedCompareStore);
1086
0
    symbolTable.relateToOperator("InterlockedExchange",         EOpInterlockedExchange);
1087
0
    symbolTable.relateToOperator("InterlockedMax",              EOpInterlockedMax);
1088
0
    symbolTable.relateToOperator("InterlockedMin",              EOpInterlockedMin);
1089
0
    symbolTable.relateToOperator("InterlockedOr",               EOpInterlockedOr);
1090
0
    symbolTable.relateToOperator("InterlockedXor",              EOpInterlockedXor);
1091
0
    symbolTable.relateToOperator("isfinite",                    EOpIsFinite);
1092
0
    symbolTable.relateToOperator("isinf",                       EOpIsInf);
1093
0
    symbolTable.relateToOperator("isnan",                       EOpIsNan);
1094
0
    symbolTable.relateToOperator("ldexp",                       EOpLdexp);
1095
0
    symbolTable.relateToOperator("length",                      EOpLength);
1096
0
    symbolTable.relateToOperator("lerp",                        EOpMix);
1097
0
    symbolTable.relateToOperator("lit",                         EOpLit);
1098
0
    symbolTable.relateToOperator("log",                         EOpLog);
1099
0
    symbolTable.relateToOperator("log10",                       EOpLog10);
1100
0
    symbolTable.relateToOperator("log2",                        EOpLog2);
1101
0
    symbolTable.relateToOperator("mad",                         EOpFma);
1102
0
    symbolTable.relateToOperator("max",                         EOpMax);
1103
0
    symbolTable.relateToOperator("min",                         EOpMin);
1104
0
    symbolTable.relateToOperator("modf",                        EOpModf);
1105
    // symbolTable.relateToOperator("msad4",                       EOpMsad4);
1106
0
    symbolTable.relateToOperator("mul",                         EOpGenMul);
1107
    // symbolTable.relateToOperator("noise",                    EOpNoise); // TODO: check return type
1108
0
    symbolTable.relateToOperator("normalize",                   EOpNormalize);
1109
0
    symbolTable.relateToOperator("pow",                         EOpPow);
1110
0
    symbolTable.relateToOperator("printf",                      EOpDebugPrintf);
1111
    // symbolTable.relateToOperator("Process2DQuadTessFactorsAvg");
1112
    // symbolTable.relateToOperator("Process2DQuadTessFactorsMax");
1113
    // symbolTable.relateToOperator("Process2DQuadTessFactorsMin");
1114
    // symbolTable.relateToOperator("ProcessIsolineTessFactors");
1115
    // symbolTable.relateToOperator("ProcessQuadTessFactorsAvg");
1116
    // symbolTable.relateToOperator("ProcessQuadTessFactorsMax");
1117
    // symbolTable.relateToOperator("ProcessQuadTessFactorsMin");
1118
    // symbolTable.relateToOperator("ProcessTriTessFactorsAvg");
1119
    // symbolTable.relateToOperator("ProcessTriTessFactorsMax");
1120
    // symbolTable.relateToOperator("ProcessTriTessFactorsMin");
1121
0
    symbolTable.relateToOperator("radians",                     EOpRadians);
1122
0
    symbolTable.relateToOperator("rcp",                         EOpRcp);
1123
0
    symbolTable.relateToOperator("reflect",                     EOpReflect);
1124
0
    symbolTable.relateToOperator("refract",                     EOpRefract);
1125
0
    symbolTable.relateToOperator("reversebits",                 EOpBitFieldReverse);
1126
0
    symbolTable.relateToOperator("round",                       EOpRound);
1127
0
    symbolTable.relateToOperator("rsqrt",                       EOpInverseSqrt);
1128
0
    symbolTable.relateToOperator("saturate",                    EOpSaturate);
1129
0
    symbolTable.relateToOperator("sign",                        EOpSign);
1130
0
    symbolTable.relateToOperator("sin",                         EOpSin);
1131
0
    symbolTable.relateToOperator("sincos",                      EOpSinCos);
1132
0
    symbolTable.relateToOperator("sinh",                        EOpSinh);
1133
0
    symbolTable.relateToOperator("smoothstep",                  EOpSmoothStep);
1134
0
    symbolTable.relateToOperator("sqrt",                        EOpSqrt);
1135
0
    symbolTable.relateToOperator("step",                        EOpStep);
1136
0
    symbolTable.relateToOperator("tan",                         EOpTan);
1137
0
    symbolTable.relateToOperator("tanh",                        EOpTanh);
1138
0
    symbolTable.relateToOperator("tex1D",                       EOpTexture);
1139
0
    symbolTable.relateToOperator("tex1Dbias",                   EOpTextureBias);
1140
0
    symbolTable.relateToOperator("tex1Dgrad",                   EOpTextureGrad);
1141
0
    symbolTable.relateToOperator("tex1Dlod",                    EOpTextureLod);
1142
0
    symbolTable.relateToOperator("tex1Dproj",                   EOpTextureProj);
1143
0
    symbolTable.relateToOperator("tex2D",                       EOpTexture);
1144
0
    symbolTable.relateToOperator("tex2Dbias",                   EOpTextureBias);
1145
0
    symbolTable.relateToOperator("tex2Dgrad",                   EOpTextureGrad);
1146
0
    symbolTable.relateToOperator("tex2Dlod",                    EOpTextureLod);
1147
0
    symbolTable.relateToOperator("tex2Dproj",                   EOpTextureProj);
1148
0
    symbolTable.relateToOperator("tex3D",                       EOpTexture);
1149
0
    symbolTable.relateToOperator("tex3Dbias",                   EOpTextureBias);
1150
0
    symbolTable.relateToOperator("tex3Dgrad",                   EOpTextureGrad);
1151
0
    symbolTable.relateToOperator("tex3Dlod",                    EOpTextureLod);
1152
0
    symbolTable.relateToOperator("tex3Dproj",                   EOpTextureProj);
1153
0
    symbolTable.relateToOperator("texCUBE",                     EOpTexture);
1154
0
    symbolTable.relateToOperator("texCUBEbias",                 EOpTextureBias);
1155
0
    symbolTable.relateToOperator("texCUBEgrad",                 EOpTextureGrad);
1156
0
    symbolTable.relateToOperator("texCUBElod",                  EOpTextureLod);
1157
0
    symbolTable.relateToOperator("texCUBEproj",                 EOpTextureProj);
1158
0
    symbolTable.relateToOperator("transpose",                   EOpTranspose);
1159
0
    symbolTable.relateToOperator("trunc",                       EOpTrunc);
1160
1161
    // Texture methods
1162
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Sample",                      EOpMethodSample);
1163
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SampleBias",                  EOpMethodSampleBias);
1164
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SampleCmp",                   EOpMethodSampleCmp);
1165
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SampleCmpLevelZero",          EOpMethodSampleCmpLevelZero);
1166
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SampleGrad",                  EOpMethodSampleGrad);
1167
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SampleLevel",                 EOpMethodSampleLevel);
1168
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Load",                        EOpMethodLoad);
1169
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GetDimensions",               EOpMethodGetDimensions);
1170
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GetSamplePosition",           EOpMethodGetSamplePosition);
1171
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Gather",                      EOpMethodGather);
1172
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "CalculateLevelOfDetail",      EOpMethodCalculateLevelOfDetail);
1173
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "CalculateLevelOfDetailUnclamped", EOpMethodCalculateLevelOfDetailUnclamped);
1174
1175
    // Structure buffer methods (excluding associations already made above for texture methods w/ same name)
1176
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Load2",                       EOpMethodLoad2);
1177
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Load3",                       EOpMethodLoad3);
1178
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Load4",                       EOpMethodLoad4);
1179
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Store",                       EOpMethodStore);
1180
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Store2",                      EOpMethodStore2);
1181
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Store3",                      EOpMethodStore3);
1182
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Store4",                      EOpMethodStore4);
1183
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "IncrementCounter",            EOpMethodIncrementCounter);
1184
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "DecrementCounter",            EOpMethodDecrementCounter);
1185
    // Append is also a GS method: we don't add it twice
1186
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Consume",                     EOpMethodConsume);
1187
1188
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedAdd",              EOpInterlockedAdd);
1189
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedAnd",              EOpInterlockedAnd);
1190
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedCompareExchange",  EOpInterlockedCompareExchange);
1191
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedCompareStore",     EOpInterlockedCompareStore);
1192
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedExchange",         EOpInterlockedExchange);
1193
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedMax",              EOpInterlockedMax);
1194
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedMin",              EOpInterlockedMin);
1195
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedOr",               EOpInterlockedOr);
1196
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "InterlockedXor",              EOpInterlockedXor);
1197
1198
    // SM5 Texture methods
1199
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherRed",                   EOpMethodGatherRed);
1200
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherGreen",                 EOpMethodGatherGreen);
1201
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherBlue",                  EOpMethodGatherBlue);
1202
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherAlpha",                 EOpMethodGatherAlpha);
1203
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherCmp",                   EOpMethodGatherCmpRed); // alias
1204
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherCmpRed",                EOpMethodGatherCmpRed);
1205
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherCmpGreen",              EOpMethodGatherCmpGreen);
1206
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherCmpBlue",               EOpMethodGatherCmpBlue);
1207
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "GatherCmpAlpha",              EOpMethodGatherCmpAlpha);
1208
1209
    // GS methods
1210
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "Append",                      EOpMethodAppend);
1211
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "RestartStrip",                EOpMethodRestartStrip);
1212
1213
    // Wave ops
1214
0
    symbolTable.relateToOperator("WaveIsFirstLane",                            EOpSubgroupElect);
1215
0
    symbolTable.relateToOperator("WaveGetLaneCount",                           EOpWaveGetLaneCount);
1216
0
    symbolTable.relateToOperator("WaveGetLaneIndex",                           EOpWaveGetLaneIndex);
1217
0
    symbolTable.relateToOperator("WaveActiveAnyTrue",                          EOpSubgroupAny);
1218
0
    symbolTable.relateToOperator("WaveActiveAllTrue",                          EOpSubgroupAll);
1219
0
    symbolTable.relateToOperator("WaveActiveBallot",                           EOpSubgroupBallot);
1220
0
    symbolTable.relateToOperator("WaveReadLaneFirst",                          EOpSubgroupBroadcastFirst);
1221
0
    symbolTable.relateToOperator("WaveReadLaneAt",                             EOpSubgroupShuffle);
1222
0
    symbolTable.relateToOperator("WaveActiveAllEqual",                         EOpSubgroupAllEqual);
1223
0
    symbolTable.relateToOperator("WaveActiveAllEqualBool",                     EOpSubgroupAllEqual);
1224
0
    symbolTable.relateToOperator("WaveActiveCountBits",                        EOpWaveActiveCountBits);
1225
0
    symbolTable.relateToOperator("WaveActiveSum",                              EOpSubgroupAdd);
1226
0
    symbolTable.relateToOperator("WaveActiveProduct",                          EOpSubgroupMul);
1227
0
    symbolTable.relateToOperator("WaveActiveBitAnd",                           EOpSubgroupAnd);
1228
0
    symbolTable.relateToOperator("WaveActiveBitOr",                            EOpSubgroupOr);
1229
0
    symbolTable.relateToOperator("WaveActiveBitXor",                           EOpSubgroupXor);
1230
0
    symbolTable.relateToOperator("WaveActiveMin",                              EOpSubgroupMin);
1231
0
    symbolTable.relateToOperator("WaveActiveMax",                              EOpSubgroupMax);
1232
0
    symbolTable.relateToOperator("WavePrefixSum",                              EOpSubgroupInclusiveAdd);
1233
0
    symbolTable.relateToOperator("WavePrefixProduct",                          EOpSubgroupInclusiveMul);
1234
0
    symbolTable.relateToOperator("WavePrefixCountBits",                        EOpWavePrefixCountBits);
1235
0
    symbolTable.relateToOperator("QuadReadAcrossX",                            EOpSubgroupQuadSwapHorizontal);
1236
0
    symbolTable.relateToOperator("QuadReadAcrossY",                            EOpSubgroupQuadSwapVertical);
1237
0
    symbolTable.relateToOperator("QuadReadAcrossDiagonal",                     EOpSubgroupQuadSwapDiagonal);
1238
0
    symbolTable.relateToOperator("QuadReadLaneAt",                             EOpSubgroupQuadBroadcast);
1239
1240
    // Subpass input methods
1241
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SubpassLoad",                 EOpSubpassLoad);
1242
0
    symbolTable.relateToOperator(BUILTIN_PREFIX "SubpassLoadMS",               EOpSubpassLoadMS);
1243
0
}
1244
1245
//
1246
// Add context-dependent (resource-specific) built-ins not handled by the above.  These
1247
// would be ones that need to be programmatically added because they cannot
1248
// be added by simple text strings.  For these, also
1249
// 1) Map built-in functions to operators, for those that will turn into an operation node
1250
//    instead of remaining a function call.
1251
// 2) Tag extension-related symbols added to their base version with their extensions, so
1252
//    that if an early version has the extension turned off, there is an error reported on use.
1253
//
1254
void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/, EShLanguage /*language*/,
1255
                                              TSymbolTable& /*symbolTable*/, const TBuiltInResource& /*resources*/)
1256
0
{
1257
0
}
1258
1259
} // end namespace glslang