summaryrefslogtreecommitdiff
path: root/source/slang/slang-lookup-glslstd450.cpp
blob: cd9172cf09180bac5f98b702d563ab0cb0e16c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Hash function for GLSLstd450
//
// This file was thoughtfully generated by a machine,
// don't even think about modifying it yourself!
//

#include "../core/slang-common.h"
#include "../core/slang-string.h"
#include "spirv/unified1/GLSL.std.450.h"


namespace Slang
{

static const unsigned tableSalt[81] ={
    1, 1, 1, 1, 4, 0, 1, 0, 10, 0, 3, 0, 0, 13, 4, 1,
    5, 1, 5, 4, 0, 0, 0, 1, 0, 9, 1, 0, 0, 1, 1, 8,
    2, 0, 0, 2, 0, 1, 0, 0, 2, 1, 1, 0, 0, 0, 0, 1,
    4, 3, 9, 0, 26, 0, 0, 2, 0, 2, 8, 0, 0, 17, 20, 5,
    0, 0, 0, 5, 4, 9, 4, 23, 0, 1, 7, 0, 24, 43, 10, 41,
    6
};

struct KV
{
    const char* name;
    GLSLstd450 value;
};

static const KV words[81] =
{
    {"FindSMsb", GLSLstd450FindSMsb},
    {"SClamp", GLSLstd450SClamp},
    {"UnpackHalf2x16", GLSLstd450UnpackHalf2x16},
    {"Normalize", GLSLstd450Normalize},
    {"Pow", GLSLstd450Pow},
    {"Ceil", GLSLstd450Ceil},
    {"PackUnorm4x8", GLSLstd450PackUnorm4x8},
    {"Cosh", GLSLstd450Cosh},
    {"Frexp", GLSLstd450Frexp},
    {"PackUnorm2x16", GLSLstd450PackUnorm2x16},
    {"Atan2", GLSLstd450Atan2},
    {"Exp", GLSLstd450Exp},
    {"Ldexp", GLSLstd450Ldexp},
    {"NClamp", GLSLstd450NClamp},
    {"PackHalf2x16", GLSLstd450PackHalf2x16},
    {"Trunc", GLSLstd450Trunc},
    {"UMin", GLSLstd450UMin},
    {"FClamp", GLSLstd450FClamp},
    {"SMin", GLSLstd450SMin},
    {"IMix", GLSLstd450IMix},
    {"FindUMsb", GLSLstd450FindUMsb},
    {"Cos", GLSLstd450Cos},
    {"UnpackUnorm4x8", GLSLstd450UnpackUnorm4x8},
    {"Fma", GLSLstd450Fma},
    {"RoundEven", GLSLstd450RoundEven},
    {"Log", GLSLstd450Log},
    {"Refract", GLSLstd450Refract},
    {"Distance", GLSLstd450Distance},
    {"UMax", GLSLstd450UMax},
    {"ModfStruct", GLSLstd450ModfStruct},
    {"PackSnorm4x8", GLSLstd450PackSnorm4x8},
    {"Determinant", GLSLstd450Determinant},
    {"SmoothStep", GLSLstd450SmoothStep},
    {"Reflect", GLSLstd450Reflect},
    {"Fract", GLSLstd450Fract},
    {"Asin", GLSLstd450Asin},
    {"Tanh", GLSLstd450Tanh},
    {"Degrees", GLSLstd450Degrees},
    {"Sqrt", GLSLstd450Sqrt},
    {"MatrixInverse", GLSLstd450MatrixInverse},
    {"Exp2", GLSLstd450Exp2},
    {"Cross", GLSLstd450Cross},
    {"FindILsb", GLSLstd450FindILsb},
    {"FMax", GLSLstd450FMax},
    {"NMin", GLSLstd450NMin},
    {"SMax", GLSLstd450SMax},
    {"InverseSqrt", GLSLstd450InverseSqrt},
    {"Length", GLSLstd450Length},
    {"SAbs", GLSLstd450SAbs},
    {"UClamp", GLSLstd450UClamp},
    {"FMix", GLSLstd450FMix},
    {"FaceForward", GLSLstd450FaceForward},
    {"Tan", GLSLstd450Tan},
    {"Modf", GLSLstd450Modf},
    {"PackSnorm2x16", GLSLstd450PackSnorm2x16},
    {"Round", GLSLstd450Round},
    {"UnpackUnorm2x16", GLSLstd450UnpackUnorm2x16},
    {"Atan", GLSLstd450Atan},
    {"FSign", GLSLstd450FSign},
    {"Sin", GLSLstd450Sin},
    {"UnpackSnorm2x16", GLSLstd450UnpackSnorm2x16},
    {"Radians", GLSLstd450Radians},
    {"PackDouble2x32", GLSLstd450PackDouble2x32},
    {"Sinh", GLSLstd450Sinh},
    {"UnpackSnorm4x8", GLSLstd450UnpackSnorm4x8},
    {"InterpolateAtCentroid", GLSLstd450InterpolateAtCentroid},
    {"NMax", GLSLstd450NMax},
    {"Acosh", GLSLstd450Acosh},
    {"Acos", GLSLstd450Acos},
    {"UnpackDouble2x32", GLSLstd450UnpackDouble2x32},
    {"FrexpStruct", GLSLstd450FrexpStruct},
    {"Atanh", GLSLstd450Atanh},
    {"Floor", GLSLstd450Floor},
    {"Asinh", GLSLstd450Asinh},
    {"InterpolateAtOffset", GLSLstd450InterpolateAtOffset},
    {"Step", GLSLstd450Step},
    {"FAbs", GLSLstd450FAbs},
    {"InterpolateAtSample", GLSLstd450InterpolateAtSample},
    {"Log2", GLSLstd450Log2},
    {"SSign", GLSLstd450SSign},
    {"FMin", GLSLstd450FMin},
};

static UInt32 hash(const UnownedStringSlice& str, UInt32 salt)
{
    UInt64 h = salt;
    for(const char c : str)
        h = ((h * 0x00000100000001B3) ^ c);
    return h % (sizeof(tableSalt)/sizeof(tableSalt[0]));
}

bool lookupGLSLstd450(const UnownedStringSlice& str, GLSLstd450& value)
{
    const auto i = hash(str, tableSalt[hash(str, 0)]);
    if(str == words[i].name)
    {
        value = words[i].value;
        return true;
    }
    else
    {
        return false;
    }
}

}