Coverage Report

Created: 2026-01-09 07:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/glslang/glslang/ResourceLimits/ResourceLimits.cpp
Line
Count
Source
1
//
2
// Copyright (C) 2016 Google, 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 Google Inc. 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
#include <cstdlib>
36
#include <cstring>
37
#include <sstream>
38
#include <cctype>
39
40
#include "glslang/Public/ResourceLimits.h"
41
42
static TBuiltInResource Resources;
43
44
static const TBuiltInResource DefaultTBuiltInResource = {
45
    /* .MaxLights = */ 32,
46
    /* .MaxClipPlanes = */ 6,
47
    /* .MaxTextureUnits = */ 32,
48
    /* .MaxTextureCoords = */ 32,
49
    /* .MaxVertexAttribs = */ 64,
50
    /* .MaxVertexUniformComponents = */ 4096,
51
    /* .MaxVaryingFloats = */ 64,
52
    /* .MaxVertexTextureImageUnits = */ 32,
53
    /* .MaxCombinedTextureImageUnits = */ 80,
54
    /* .MaxTextureImageUnits = */ 32,
55
    /* .MaxFragmentUniformComponents = */ 4096,
56
    /* .MaxDrawBuffers = */ 32,
57
    /* .MaxVertexUniformVectors = */ 128,
58
    /* .MaxVaryingVectors = */ 8,
59
    /* .MaxFragmentUniformVectors = */ 16,
60
    /* .MaxVertexOutputVectors = */ 16,
61
    /* .MaxFragmentInputVectors = */ 15,
62
    /* .MinProgramTexelOffset = */ -8,
63
    /* .MaxProgramTexelOffset = */ 7,
64
    /* .MaxClipDistances = */ 8,
65
    /* .MaxComputeWorkGroupCountX = */ 65535,
66
    /* .MaxComputeWorkGroupCountY = */ 65535,
67
    /* .MaxComputeWorkGroupCountZ = */ 65535,
68
    /* .MaxComputeWorkGroupSizeX = */ 1024,
69
    /* .MaxComputeWorkGroupSizeY = */ 1024,
70
    /* .MaxComputeWorkGroupSizeZ = */ 64,
71
    /* .MaxComputeUniformComponents = */ 1024,
72
    /* .MaxComputeTextureImageUnits = */ 16,
73
    /* .MaxComputeImageUniforms = */ 8,
74
    /* .MaxComputeAtomicCounters = */ 8,
75
    /* .MaxComputeAtomicCounterBuffers = */ 1,
76
    /* .MaxVaryingComponents = */ 60,
77
    /* .MaxVertexOutputComponents = */ 64,
78
    /* .MaxGeometryInputComponents = */ 64,
79
    /* .MaxGeometryOutputComponents = */ 128,
80
    /* .MaxFragmentInputComponents = */ 128,
81
    /* .MaxImageUnits = */ 8,
82
    /* .MaxCombinedImageUnitsAndFragmentOutputs = */ 8,
83
    /* .MaxCombinedShaderOutputResources = */ 8,
84
    /* .MaxImageSamples = */ 0,
85
    /* .MaxVertexImageUniforms = */ 0,
86
    /* .MaxTessControlImageUniforms = */ 0,
87
    /* .MaxTessEvaluationImageUniforms = */ 0,
88
    /* .MaxGeometryImageUniforms = */ 0,
89
    /* .MaxFragmentImageUniforms = */ 8,
90
    /* .MaxCombinedImageUniforms = */ 8,
91
    /* .MaxGeometryTextureImageUnits = */ 16,
92
    /* .MaxGeometryOutputVertices = */ 256,
93
    /* .MaxGeometryTotalOutputComponents = */ 1024,
94
    /* .MaxGeometryUniformComponents = */ 1024,
95
    /* .MaxGeometryVaryingComponents = */ 64,
96
    /* .MaxTessControlInputComponents = */ 128,
97
    /* .MaxTessControlOutputComponents = */ 128,
98
    /* .MaxTessControlTextureImageUnits = */ 16,
99
    /* .MaxTessControlUniformComponents = */ 1024,
100
    /* .MaxTessControlTotalOutputComponents = */ 4096,
101
    /* .MaxTessEvaluationInputComponents = */ 128,
102
    /* .MaxTessEvaluationOutputComponents = */ 128,
103
    /* .MaxTessEvaluationTextureImageUnits = */ 16,
104
    /* .MaxTessEvaluationUniformComponents = */ 1024,
105
    /* .MaxTessPatchComponents = */ 120,
106
    /* .MaxPatchVertices = */ 32,
107
    /* .MaxTessGenLevel = */ 64,
108
    /* .MaxViewports = */ 16,
109
    /* .MaxVertexAtomicCounters = */ 0,
110
    /* .MaxTessControlAtomicCounters = */ 0,
111
    /* .MaxTessEvaluationAtomicCounters = */ 0,
112
    /* .MaxGeometryAtomicCounters = */ 0,
113
    /* .MaxFragmentAtomicCounters = */ 8,
114
    /* .MaxCombinedAtomicCounters = */ 8,
115
    /* .MaxAtomicCounterBindings = */ 1,
116
    /* .MaxVertexAtomicCounterBuffers = */ 0,
117
    /* .MaxTessControlAtomicCounterBuffers = */ 0,
118
    /* .MaxTessEvaluationAtomicCounterBuffers = */ 0,
119
    /* .MaxGeometryAtomicCounterBuffers = */ 0,
120
    /* .MaxFragmentAtomicCounterBuffers = */ 1,
121
    /* .MaxCombinedAtomicCounterBuffers = */ 1,
122
    /* .MaxAtomicCounterBufferSize = */ 16384,
123
    /* .MaxTransformFeedbackBuffers = */ 4,
124
    /* .MaxTransformFeedbackInterleavedComponents = */ 64,
125
    /* .MaxCullDistances = */ 8,
126
    /* .MaxCombinedClipAndCullDistances = */ 8,
127
    /* .MaxSamples = */ 4,
128
    /* .maxMeshOutputVerticesNV = */ 256,
129
    /* .maxMeshOutputPrimitivesNV = */ 512,
130
    /* .maxMeshWorkGroupSizeX_NV = */ 32,
131
    /* .maxMeshWorkGroupSizeY_NV = */ 1,
132
    /* .maxMeshWorkGroupSizeZ_NV = */ 1,
133
    /* .maxTaskWorkGroupSizeX_NV = */ 32,
134
    /* .maxTaskWorkGroupSizeY_NV = */ 1,
135
    /* .maxTaskWorkGroupSizeZ_NV = */ 1,
136
    /* .maxMeshViewCountNV = */ 4,
137
    /* .maxMeshOutputVerticesEXT = */ 256,
138
    /* .maxMeshOutputPrimitivesEXT = */ 256,
139
    /* .maxMeshWorkGroupSizeX_EXT = */ 128,
140
    /* .maxMeshWorkGroupSizeY_EXT = */ 128,
141
    /* .maxMeshWorkGroupSizeZ_EXT = */ 128,
142
    /* .maxTaskWorkGroupSizeX_EXT = */ 128,
143
    /* .maxTaskWorkGroupSizeY_EXT = */ 128,
144
    /* .maxTaskWorkGroupSizeZ_EXT = */ 128,
145
    /* .maxMeshViewCountEXT = */ 4,
146
    /* .maxDualSourceDrawBuffersEXT = */ 1,
147
148
    /* .limits = */ {
149
        /* .nonInductiveForLoops = */ 1,
150
        /* .whileLoops = */ 1,
151
        /* .doWhileLoops = */ 1,
152
        /* .generalUniformIndexing = */ 1,
153
        /* .generalAttributeMatrixVectorIndexing = */ 1,
154
        /* .generalVaryingIndexing = */ 1,
155
        /* .generalSamplerIndexing = */ 1,
156
        /* .generalVariableIndexing = */ 1,
157
        /* .generalConstantMatrixVectorIndexing = */ 1,
158
    }};
159
160
std::string GetDefaultTBuiltInResourceString()
161
0
{
162
0
    std::ostringstream ostream;
163
164
0
    ostream << "MaxLights "                                 << DefaultTBuiltInResource.maxLights << "\n"
165
0
            << "MaxClipPlanes "                             << DefaultTBuiltInResource.maxClipPlanes << "\n"
166
0
            << "MaxTextureUnits "                           << DefaultTBuiltInResource.maxTextureUnits << "\n"
167
0
            << "MaxTextureCoords "                          << DefaultTBuiltInResource.maxTextureCoords << "\n"
168
0
            << "MaxVertexAttribs "                          << DefaultTBuiltInResource.maxVertexAttribs << "\n"
169
0
            << "MaxVertexUniformComponents "                << DefaultTBuiltInResource.maxVertexUniformComponents << "\n"
170
0
            << "MaxVaryingFloats "                          << DefaultTBuiltInResource.maxVaryingFloats << "\n"
171
0
            << "MaxVertexTextureImageUnits "                << DefaultTBuiltInResource.maxVertexTextureImageUnits << "\n"
172
0
            << "MaxCombinedTextureImageUnits "              << DefaultTBuiltInResource.maxCombinedTextureImageUnits << "\n"
173
0
            << "MaxTextureImageUnits "                      << DefaultTBuiltInResource.maxTextureImageUnits << "\n"
174
0
            << "MaxFragmentUniformComponents "              << DefaultTBuiltInResource.maxFragmentUniformComponents << "\n"
175
0
            << "MaxDrawBuffers "                            << DefaultTBuiltInResource.maxDrawBuffers << "\n"
176
0
            << "MaxVertexUniformVectors "                   << DefaultTBuiltInResource.maxVertexUniformVectors << "\n"
177
0
            << "MaxVaryingVectors "                         << DefaultTBuiltInResource.maxVaryingVectors << "\n"
178
0
            << "MaxFragmentUniformVectors "                 << DefaultTBuiltInResource.maxFragmentUniformVectors << "\n"
179
0
            << "MaxVertexOutputVectors "                    << DefaultTBuiltInResource.maxVertexOutputVectors << "\n"
180
0
            << "MaxFragmentInputVectors "                   << DefaultTBuiltInResource.maxFragmentInputVectors << "\n"
181
0
            << "MinProgramTexelOffset "                     << DefaultTBuiltInResource.minProgramTexelOffset << "\n"
182
0
            << "MaxProgramTexelOffset "                     << DefaultTBuiltInResource.maxProgramTexelOffset << "\n"
183
0
            << "MaxClipDistances "                          << DefaultTBuiltInResource.maxClipDistances << "\n"
184
0
            << "MaxComputeWorkGroupCountX "                 << DefaultTBuiltInResource.maxComputeWorkGroupCountX << "\n"
185
0
            << "MaxComputeWorkGroupCountY "                 << DefaultTBuiltInResource.maxComputeWorkGroupCountY << "\n"
186
0
            << "MaxComputeWorkGroupCountZ "                 << DefaultTBuiltInResource.maxComputeWorkGroupCountZ << "\n"
187
0
            << "MaxComputeWorkGroupSizeX "                  << DefaultTBuiltInResource.maxComputeWorkGroupSizeX << "\n"
188
0
            << "MaxComputeWorkGroupSizeY "                  << DefaultTBuiltInResource.maxComputeWorkGroupSizeY << "\n"
189
0
            << "MaxComputeWorkGroupSizeZ "                  << DefaultTBuiltInResource.maxComputeWorkGroupSizeZ << "\n"
190
0
            << "MaxComputeUniformComponents "               << DefaultTBuiltInResource.maxComputeUniformComponents << "\n"
191
0
            << "MaxComputeTextureImageUnits "               << DefaultTBuiltInResource.maxComputeTextureImageUnits << "\n"
192
0
            << "MaxComputeImageUniforms "                   << DefaultTBuiltInResource.maxComputeImageUniforms << "\n"
193
0
            << "MaxComputeAtomicCounters "                  << DefaultTBuiltInResource.maxComputeAtomicCounters << "\n"
194
0
            << "MaxComputeAtomicCounterBuffers "            << DefaultTBuiltInResource.maxComputeAtomicCounterBuffers << "\n"
195
0
            << "MaxVaryingComponents "                      << DefaultTBuiltInResource.maxVaryingComponents << "\n"
196
0
            << "MaxVertexOutputComponents "                 << DefaultTBuiltInResource.maxVertexOutputComponents << "\n"
197
0
            << "MaxGeometryInputComponents "                << DefaultTBuiltInResource.maxGeometryInputComponents << "\n"
198
0
            << "MaxGeometryOutputComponents "               << DefaultTBuiltInResource.maxGeometryOutputComponents << "\n"
199
0
            << "MaxFragmentInputComponents "                << DefaultTBuiltInResource.maxFragmentInputComponents << "\n"
200
0
            << "MaxImageUnits "                             << DefaultTBuiltInResource.maxImageUnits << "\n"
201
0
            << "MaxCombinedImageUnitsAndFragmentOutputs "   << DefaultTBuiltInResource.maxCombinedImageUnitsAndFragmentOutputs << "\n"
202
0
            << "MaxCombinedShaderOutputResources "          << DefaultTBuiltInResource.maxCombinedShaderOutputResources << "\n"
203
0
            << "MaxImageSamples "                           << DefaultTBuiltInResource.maxImageSamples << "\n"
204
0
            << "MaxVertexImageUniforms "                    << DefaultTBuiltInResource.maxVertexImageUniforms << "\n"
205
0
            << "MaxTessControlImageUniforms "               << DefaultTBuiltInResource.maxTessControlImageUniforms << "\n"
206
0
            << "MaxTessEvaluationImageUniforms "            << DefaultTBuiltInResource.maxTessEvaluationImageUniforms << "\n"
207
0
            << "MaxGeometryImageUniforms "                  << DefaultTBuiltInResource.maxGeometryImageUniforms << "\n"
208
0
            << "MaxFragmentImageUniforms "                  << DefaultTBuiltInResource.maxFragmentImageUniforms << "\n"
209
0
            << "MaxCombinedImageUniforms "                  << DefaultTBuiltInResource.maxCombinedImageUniforms << "\n"
210
0
            << "MaxGeometryTextureImageUnits "              << DefaultTBuiltInResource.maxGeometryTextureImageUnits << "\n"
211
0
            << "MaxGeometryOutputVertices "                 << DefaultTBuiltInResource.maxGeometryOutputVertices << "\n"
212
0
            << "MaxGeometryTotalOutputComponents "          << DefaultTBuiltInResource.maxGeometryTotalOutputComponents << "\n"
213
0
            << "MaxGeometryUniformComponents "              << DefaultTBuiltInResource.maxGeometryUniformComponents << "\n"
214
0
            << "MaxGeometryVaryingComponents "              << DefaultTBuiltInResource.maxGeometryVaryingComponents << "\n"
215
0
            << "MaxTessControlInputComponents "             << DefaultTBuiltInResource.maxTessControlInputComponents << "\n"
216
0
            << "MaxTessControlOutputComponents "            << DefaultTBuiltInResource.maxTessControlOutputComponents << "\n"
217
0
            << "MaxTessControlTextureImageUnits "           << DefaultTBuiltInResource.maxTessControlTextureImageUnits << "\n"
218
0
            << "MaxTessControlUniformComponents "           << DefaultTBuiltInResource.maxTessControlUniformComponents << "\n"
219
0
            << "MaxTessControlTotalOutputComponents "       << DefaultTBuiltInResource.maxTessControlTotalOutputComponents << "\n"
220
0
            << "MaxTessEvaluationInputComponents "          << DefaultTBuiltInResource.maxTessEvaluationInputComponents << "\n"
221
0
            << "MaxTessEvaluationOutputComponents "         << DefaultTBuiltInResource.maxTessEvaluationOutputComponents << "\n"
222
0
            << "MaxTessEvaluationTextureImageUnits "        << DefaultTBuiltInResource.maxTessEvaluationTextureImageUnits << "\n"
223
0
            << "MaxTessEvaluationUniformComponents "        << DefaultTBuiltInResource.maxTessEvaluationUniformComponents << "\n"
224
0
            << "MaxTessPatchComponents "                    << DefaultTBuiltInResource.maxTessPatchComponents << "\n"
225
0
            << "MaxPatchVertices "                          << DefaultTBuiltInResource.maxPatchVertices << "\n"
226
0
            << "MaxTessGenLevel "                           << DefaultTBuiltInResource.maxTessGenLevel << "\n"
227
0
            << "MaxViewports "                              << DefaultTBuiltInResource.maxViewports << "\n"
228
0
            << "MaxVertexAtomicCounters "                   << DefaultTBuiltInResource.maxVertexAtomicCounters << "\n"
229
0
            << "MaxTessControlAtomicCounters "              << DefaultTBuiltInResource.maxTessControlAtomicCounters << "\n"
230
0
            << "MaxTessEvaluationAtomicCounters "           << DefaultTBuiltInResource.maxTessEvaluationAtomicCounters << "\n"
231
0
            << "MaxGeometryAtomicCounters "                 << DefaultTBuiltInResource.maxGeometryAtomicCounters << "\n"
232
0
            << "MaxFragmentAtomicCounters "                 << DefaultTBuiltInResource.maxFragmentAtomicCounters << "\n"
233
0
            << "MaxCombinedAtomicCounters "                 << DefaultTBuiltInResource.maxCombinedAtomicCounters << "\n"
234
0
            << "MaxAtomicCounterBindings "                  << DefaultTBuiltInResource.maxAtomicCounterBindings << "\n"
235
0
            << "MaxVertexAtomicCounterBuffers "             << DefaultTBuiltInResource.maxVertexAtomicCounterBuffers << "\n"
236
0
            << "MaxTessControlAtomicCounterBuffers "        << DefaultTBuiltInResource.maxTessControlAtomicCounterBuffers << "\n"
237
0
            << "MaxTessEvaluationAtomicCounterBuffers "     << DefaultTBuiltInResource.maxTessEvaluationAtomicCounterBuffers << "\n"
238
0
            << "MaxGeometryAtomicCounterBuffers "           << DefaultTBuiltInResource.maxGeometryAtomicCounterBuffers << "\n"
239
0
            << "MaxFragmentAtomicCounterBuffers "           << DefaultTBuiltInResource.maxFragmentAtomicCounterBuffers << "\n"
240
0
            << "MaxCombinedAtomicCounterBuffers "           << DefaultTBuiltInResource.maxCombinedAtomicCounterBuffers << "\n"
241
0
            << "MaxAtomicCounterBufferSize "                << DefaultTBuiltInResource.maxAtomicCounterBufferSize << "\n"
242
0
            << "MaxTransformFeedbackBuffers "               << DefaultTBuiltInResource.maxTransformFeedbackBuffers << "\n"
243
0
            << "MaxTransformFeedbackInterleavedComponents " << DefaultTBuiltInResource.maxTransformFeedbackInterleavedComponents << "\n"
244
0
            << "MaxCullDistances "                          << DefaultTBuiltInResource.maxCullDistances << "\n"
245
0
            << "MaxCombinedClipAndCullDistances "           << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n"
246
0
            << "MaxSamples "                                << DefaultTBuiltInResource.maxSamples << "\n"
247
0
            << "MaxMeshOutputVerticesNV "                   << DefaultTBuiltInResource.maxMeshOutputVerticesNV << "\n"
248
0
            << "MaxMeshOutputPrimitivesNV "                 << DefaultTBuiltInResource.maxMeshOutputPrimitivesNV << "\n"
249
0
            << "MaxMeshWorkGroupSizeX_NV "                  << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_NV << "\n"
250
0
            << "MaxMeshWorkGroupSizeY_NV "                  << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_NV << "\n"
251
0
            << "MaxMeshWorkGroupSizeZ_NV "                  << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_NV << "\n"
252
0
            << "MaxTaskWorkGroupSizeX_NV "                  << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_NV << "\n"
253
0
            << "MaxTaskWorkGroupSizeY_NV "                  << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n"
254
0
            << "MaxTaskWorkGroupSizeZ_NV "                  << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n"
255
0
            << "MaxMeshViewCountNV "                        << DefaultTBuiltInResource.maxMeshViewCountNV << "\n"
256
0
            << "MaxMeshOutputVerticesEXT "                  << DefaultTBuiltInResource.maxMeshOutputVerticesEXT << "\n"
257
0
            << "MaxMeshOutputPrimitivesEXT "                << DefaultTBuiltInResource.maxMeshOutputPrimitivesEXT << "\n"
258
0
            << "MaxMeshWorkGroupSizeX_EXT "                 << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_EXT << "\n"
259
0
            << "MaxMeshWorkGroupSizeY_EXT "                 << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_EXT << "\n"
260
0
            << "MaxMeshWorkGroupSizeZ_EXT "                 << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_EXT << "\n"
261
0
            << "MaxTaskWorkGroupSizeX_EXT "                 << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_EXT << "\n"
262
0
            << "MaxTaskWorkGroupSizeY_EXT "                 << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_EXT << "\n"
263
0
            << "MaxTaskWorkGroupSizeZ_EXT "                 << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_EXT << "\n"
264
0
            << "MaxMeshViewCountEXT "                       << DefaultTBuiltInResource.maxMeshViewCountEXT << "\n"
265
0
            << "MaxDualSourceDrawBuffersEXT "               << DefaultTBuiltInResource.maxDualSourceDrawBuffersEXT << "\n"
266
0
            << "nonInductiveForLoops "                      << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n"
267
0
            << "whileLoops "                                << DefaultTBuiltInResource.limits.whileLoops << "\n"
268
0
            << "doWhileLoops "                              << DefaultTBuiltInResource.limits.doWhileLoops << "\n"
269
0
            << "generalUniformIndexing "                    << DefaultTBuiltInResource.limits.generalUniformIndexing << "\n"
270
0
            << "generalAttributeMatrixVectorIndexing "      << DefaultTBuiltInResource.limits.generalAttributeMatrixVectorIndexing << "\n"
271
0
            << "generalVaryingIndexing "                    << DefaultTBuiltInResource.limits.generalVaryingIndexing << "\n"
272
0
            << "generalSamplerIndexing "                    << DefaultTBuiltInResource.limits.generalSamplerIndexing << "\n"
273
0
            << "generalVariableIndexing "                   << DefaultTBuiltInResource.limits.generalVariableIndexing << "\n"
274
0
            << "generalConstantMatrixVectorIndexing "       << DefaultTBuiltInResource.limits.generalConstantMatrixVectorIndexing << "\n"
275
0
      ;
276
277
0
    return ostream.str();
278
0
}
279
280
void DecodeResourceLimits(TBuiltInResource* resources, char* config)
281
0
{
282
0
    static const char* delims = " \t\n\r";
283
284
0
    size_t pos     = 0;
285
0
    std::string configStr(config);
286
287
0
    while ((pos = configStr.find_first_not_of(delims, pos)) != std::string::npos) {
288
0
        const size_t token_s = pos;
289
0
        const size_t token_e = configStr.find_first_of(delims, token_s);
290
0
        const size_t value_s = configStr.find_first_not_of(delims, token_e);
291
0
        const size_t value_e = configStr.find_first_of(delims, value_s);
292
0
        pos = value_e;
293
294
        // Faster to use compare(), but prefering readability.
295
0
        const std::string tokenStr = configStr.substr(token_s, token_e-token_s);
296
0
        const std::string valueStr = configStr.substr(value_s, value_e-value_s);
297
298
0
        if (value_s == std::string::npos || ! (valueStr[0] == '-' || isdigit(valueStr[0]))) {
299
0
            printf("Error: '%s' bad .conf file.  Each name must be followed by one number.\n",
300
0
                   valueStr.c_str());
301
0
            return;
302
0
        }
303
304
0
        const int value = std::atoi(valueStr.c_str());
305
306
0
        if (tokenStr == "MaxLights")
307
0
            resources->maxLights = value;
308
0
        else if (tokenStr == "MaxClipPlanes")
309
0
            resources->maxClipPlanes = value;
310
0
        else if (tokenStr == "MaxTextureUnits")
311
0
            resources->maxTextureUnits = value;
312
0
        else if (tokenStr == "MaxTextureCoords")
313
0
            resources->maxTextureCoords = value;
314
0
        else if (tokenStr == "MaxVertexAttribs")
315
0
            resources->maxVertexAttribs = value;
316
0
        else if (tokenStr == "MaxVertexUniformComponents")
317
0
            resources->maxVertexUniformComponents = value;
318
0
        else if (tokenStr == "MaxVaryingFloats")
319
0
            resources->maxVaryingFloats = value;
320
0
        else if (tokenStr == "MaxVertexTextureImageUnits")
321
0
            resources->maxVertexTextureImageUnits = value;
322
0
        else if (tokenStr == "MaxCombinedTextureImageUnits")
323
0
            resources->maxCombinedTextureImageUnits = value;
324
0
        else if (tokenStr == "MaxTextureImageUnits")
325
0
            resources->maxTextureImageUnits = value;
326
0
        else if (tokenStr == "MaxFragmentUniformComponents")
327
0
            resources->maxFragmentUniformComponents = value;
328
0
        else if (tokenStr == "MaxDrawBuffers")
329
0
            resources->maxDrawBuffers = value;
330
0
        else if (tokenStr == "MaxVertexUniformVectors")
331
0
            resources->maxVertexUniformVectors = value;
332
0
        else if (tokenStr == "MaxVaryingVectors")
333
0
            resources->maxVaryingVectors = value;
334
0
        else if (tokenStr == "MaxFragmentUniformVectors")
335
0
            resources->maxFragmentUniformVectors = value;
336
0
        else if (tokenStr == "MaxVertexOutputVectors")
337
0
            resources->maxVertexOutputVectors = value;
338
0
        else if (tokenStr == "MaxFragmentInputVectors")
339
0
            resources->maxFragmentInputVectors = value;
340
0
        else if (tokenStr == "MinProgramTexelOffset")
341
0
            resources->minProgramTexelOffset = value;
342
0
        else if (tokenStr == "MaxProgramTexelOffset")
343
0
            resources->maxProgramTexelOffset = value;
344
0
        else if (tokenStr == "MaxClipDistances")
345
0
            resources->maxClipDistances = value;
346
0
        else if (tokenStr == "MaxComputeWorkGroupCountX")
347
0
            resources->maxComputeWorkGroupCountX = value;
348
0
        else if (tokenStr == "MaxComputeWorkGroupCountY")
349
0
            resources->maxComputeWorkGroupCountY = value;
350
0
        else if (tokenStr == "MaxComputeWorkGroupCountZ")
351
0
            resources->maxComputeWorkGroupCountZ = value;
352
0
        else if (tokenStr == "MaxComputeWorkGroupSizeX")
353
0
            resources->maxComputeWorkGroupSizeX = value;
354
0
        else if (tokenStr == "MaxComputeWorkGroupSizeY")
355
0
            resources->maxComputeWorkGroupSizeY = value;
356
0
        else if (tokenStr == "MaxComputeWorkGroupSizeZ")
357
0
            resources->maxComputeWorkGroupSizeZ = value;
358
0
        else if (tokenStr == "MaxComputeUniformComponents")
359
0
            resources->maxComputeUniformComponents = value;
360
0
        else if (tokenStr == "MaxComputeTextureImageUnits")
361
0
            resources->maxComputeTextureImageUnits = value;
362
0
        else if (tokenStr == "MaxComputeImageUniforms")
363
0
            resources->maxComputeImageUniforms = value;
364
0
        else if (tokenStr == "MaxComputeAtomicCounters")
365
0
            resources->maxComputeAtomicCounters = value;
366
0
        else if (tokenStr == "MaxComputeAtomicCounterBuffers")
367
0
            resources->maxComputeAtomicCounterBuffers = value;
368
0
        else if (tokenStr == "MaxVaryingComponents")
369
0
            resources->maxVaryingComponents = value;
370
0
        else if (tokenStr == "MaxVertexOutputComponents")
371
0
            resources->maxVertexOutputComponents = value;
372
0
        else if (tokenStr == "MaxGeometryInputComponents")
373
0
            resources->maxGeometryInputComponents = value;
374
0
        else if (tokenStr == "MaxGeometryOutputComponents")
375
0
            resources->maxGeometryOutputComponents = value;
376
0
        else if (tokenStr == "MaxFragmentInputComponents")
377
0
            resources->maxFragmentInputComponents = value;
378
0
        else if (tokenStr == "MaxImageUnits")
379
0
            resources->maxImageUnits = value;
380
0
        else if (tokenStr == "MaxCombinedImageUnitsAndFragmentOutputs")
381
0
            resources->maxCombinedImageUnitsAndFragmentOutputs = value;
382
0
        else if (tokenStr == "MaxCombinedShaderOutputResources")
383
0
            resources->maxCombinedShaderOutputResources = value;
384
0
        else if (tokenStr == "MaxImageSamples")
385
0
            resources->maxImageSamples = value;
386
0
        else if (tokenStr == "MaxVertexImageUniforms")
387
0
            resources->maxVertexImageUniforms = value;
388
0
        else if (tokenStr == "MaxTessControlImageUniforms")
389
0
            resources->maxTessControlImageUniforms = value;
390
0
        else if (tokenStr == "MaxTessEvaluationImageUniforms")
391
0
            resources->maxTessEvaluationImageUniforms = value;
392
0
        else if (tokenStr == "MaxGeometryImageUniforms")
393
0
            resources->maxGeometryImageUniforms = value;
394
0
        else if (tokenStr == "MaxFragmentImageUniforms")
395
0
            resources->maxFragmentImageUniforms = value;
396
0
        else if (tokenStr == "MaxCombinedImageUniforms")
397
0
            resources->maxCombinedImageUniforms = value;
398
0
        else if (tokenStr == "MaxGeometryTextureImageUnits")
399
0
            resources->maxGeometryTextureImageUnits = value;
400
0
        else if (tokenStr == "MaxGeometryOutputVertices")
401
0
            resources->maxGeometryOutputVertices = value;
402
0
        else if (tokenStr == "MaxGeometryTotalOutputComponents")
403
0
            resources->maxGeometryTotalOutputComponents = value;
404
0
        else if (tokenStr == "MaxGeometryUniformComponents")
405
0
            resources->maxGeometryUniformComponents = value;
406
0
        else if (tokenStr == "MaxGeometryVaryingComponents")
407
0
            resources->maxGeometryVaryingComponents = value;
408
0
        else if (tokenStr == "MaxTessControlInputComponents")
409
0
            resources->maxTessControlInputComponents = value;
410
0
        else if (tokenStr == "MaxTessControlOutputComponents")
411
0
            resources->maxTessControlOutputComponents = value;
412
0
        else if (tokenStr == "MaxTessControlTextureImageUnits")
413
0
            resources->maxTessControlTextureImageUnits = value;
414
0
        else if (tokenStr == "MaxTessControlUniformComponents")
415
0
            resources->maxTessControlUniformComponents = value;
416
0
        else if (tokenStr == "MaxTessControlTotalOutputComponents")
417
0
            resources->maxTessControlTotalOutputComponents = value;
418
0
        else if (tokenStr == "MaxTessEvaluationInputComponents")
419
0
            resources->maxTessEvaluationInputComponents = value;
420
0
        else if (tokenStr == "MaxTessEvaluationOutputComponents")
421
0
            resources->maxTessEvaluationOutputComponents = value;
422
0
        else if (tokenStr == "MaxTessEvaluationTextureImageUnits")
423
0
            resources->maxTessEvaluationTextureImageUnits = value;
424
0
        else if (tokenStr == "MaxTessEvaluationUniformComponents")
425
0
            resources->maxTessEvaluationUniformComponents = value;
426
0
        else if (tokenStr == "MaxTessPatchComponents")
427
0
            resources->maxTessPatchComponents = value;
428
0
        else if (tokenStr == "MaxPatchVertices")
429
0
            resources->maxPatchVertices = value;
430
0
        else if (tokenStr == "MaxTessGenLevel")
431
0
            resources->maxTessGenLevel = value;
432
0
        else if (tokenStr == "MaxViewports")
433
0
            resources->maxViewports = value;
434
0
        else if (tokenStr == "MaxVertexAtomicCounters")
435
0
            resources->maxVertexAtomicCounters = value;
436
0
        else if (tokenStr == "MaxTessControlAtomicCounters")
437
0
            resources->maxTessControlAtomicCounters = value;
438
0
        else if (tokenStr == "MaxTessEvaluationAtomicCounters")
439
0
            resources->maxTessEvaluationAtomicCounters = value;
440
0
        else if (tokenStr == "MaxGeometryAtomicCounters")
441
0
            resources->maxGeometryAtomicCounters = value;
442
0
        else if (tokenStr == "MaxFragmentAtomicCounters")
443
0
            resources->maxFragmentAtomicCounters = value;
444
0
        else if (tokenStr == "MaxCombinedAtomicCounters")
445
0
            resources->maxCombinedAtomicCounters = value;
446
0
        else if (tokenStr == "MaxAtomicCounterBindings")
447
0
            resources->maxAtomicCounterBindings = value;
448
0
        else if (tokenStr == "MaxVertexAtomicCounterBuffers")
449
0
            resources->maxVertexAtomicCounterBuffers = value;
450
0
        else if (tokenStr == "MaxTessControlAtomicCounterBuffers")
451
0
            resources->maxTessControlAtomicCounterBuffers = value;
452
0
        else if (tokenStr == "MaxTessEvaluationAtomicCounterBuffers")
453
0
            resources->maxTessEvaluationAtomicCounterBuffers = value;
454
0
        else if (tokenStr == "MaxGeometryAtomicCounterBuffers")
455
0
            resources->maxGeometryAtomicCounterBuffers = value;
456
0
        else if (tokenStr == "MaxFragmentAtomicCounterBuffers")
457
0
            resources->maxFragmentAtomicCounterBuffers = value;
458
0
        else if (tokenStr == "MaxCombinedAtomicCounterBuffers")
459
0
            resources->maxCombinedAtomicCounterBuffers = value;
460
0
        else if (tokenStr == "MaxAtomicCounterBufferSize")
461
0
            resources->maxAtomicCounterBufferSize = value;
462
0
        else if (tokenStr == "MaxTransformFeedbackBuffers")
463
0
            resources->maxTransformFeedbackBuffers = value;
464
0
        else if (tokenStr == "MaxTransformFeedbackInterleavedComponents")
465
0
            resources->maxTransformFeedbackInterleavedComponents = value;
466
0
        else if (tokenStr == "MaxCullDistances")
467
0
            resources->maxCullDistances = value;
468
0
        else if (tokenStr == "MaxCombinedClipAndCullDistances")
469
0
            resources->maxCombinedClipAndCullDistances = value;
470
0
        else if (tokenStr == "MaxSamples")
471
0
            resources->maxSamples = value;
472
0
        else if (tokenStr == "MaxMeshOutputVerticesNV")
473
0
            resources->maxMeshOutputVerticesNV = value;
474
0
        else if (tokenStr == "MaxMeshOutputPrimitivesNV")
475
0
            resources->maxMeshOutputPrimitivesNV = value;
476
0
        else if (tokenStr == "MaxMeshWorkGroupSizeX_NV")
477
0
            resources->maxMeshWorkGroupSizeX_NV = value;
478
0
        else if (tokenStr == "MaxMeshWorkGroupSizeY_NV")
479
0
            resources->maxMeshWorkGroupSizeY_NV = value;
480
0
        else if (tokenStr == "MaxMeshWorkGroupSizeZ_NV")
481
0
            resources->maxMeshWorkGroupSizeZ_NV = value;
482
0
        else if (tokenStr == "MaxTaskWorkGroupSizeX_NV")
483
0
            resources->maxTaskWorkGroupSizeX_NV = value;
484
0
        else if (tokenStr == "MaxTaskWorkGroupSizeY_NV")
485
0
            resources->maxTaskWorkGroupSizeY_NV = value;
486
0
        else if (tokenStr == "MaxTaskWorkGroupSizeZ_NV")
487
0
            resources->maxTaskWorkGroupSizeZ_NV = value;
488
0
        else if (tokenStr == "MaxMeshViewCountNV")
489
0
            resources->maxMeshViewCountNV = value;
490
0
        else if (tokenStr == "MaxMeshOutputVerticesEXT")
491
0
            resources->maxMeshOutputVerticesEXT = value;
492
0
        else if (tokenStr == "MaxMeshOutputPrimitivesEXT")
493
0
            resources->maxMeshOutputPrimitivesEXT = value;
494
0
        else if (tokenStr == "MaxMeshWorkGroupSizeX_EXT")
495
0
            resources->maxMeshWorkGroupSizeX_EXT = value;
496
0
        else if (tokenStr == "MaxMeshWorkGroupSizeY_EXT")
497
0
            resources->maxMeshWorkGroupSizeY_EXT = value;
498
0
        else if (tokenStr == "MaxMeshWorkGroupSizeZ_EXT")
499
0
            resources->maxMeshWorkGroupSizeZ_EXT = value;
500
0
        else if (tokenStr == "MaxTaskWorkGroupSizeX_EXT")
501
0
            resources->maxTaskWorkGroupSizeX_EXT = value;
502
0
        else if (tokenStr == "MaxTaskWorkGroupSizeY_EXT")
503
0
            resources->maxTaskWorkGroupSizeY_EXT = value;
504
0
        else if (tokenStr == "MaxTaskWorkGroupSizeZ_EXT")
505
0
            resources->maxTaskWorkGroupSizeZ_EXT = value;
506
0
        else if (tokenStr == "MaxMeshViewCountEXT")
507
0
            resources->maxMeshViewCountEXT = value;
508
0
        else if (tokenStr == "MaxDualSourceDrawBuffersEXT")
509
0
            resources->maxDualSourceDrawBuffersEXT = value;
510
0
        else if (tokenStr == "nonInductiveForLoops")
511
0
            resources->limits.nonInductiveForLoops = (value != 0);
512
0
        else if (tokenStr == "whileLoops")
513
0
            resources->limits.whileLoops = (value != 0);
514
0
        else if (tokenStr == "doWhileLoops")
515
0
            resources->limits.doWhileLoops = (value != 0);
516
0
        else if (tokenStr == "generalUniformIndexing")
517
0
            resources->limits.generalUniformIndexing = (value != 0);
518
0
        else if (tokenStr == "generalAttributeMatrixVectorIndexing")
519
0
            resources->limits.generalAttributeMatrixVectorIndexing = (value != 0);
520
0
        else if (tokenStr == "generalVaryingIndexing")
521
0
            resources->limits.generalVaryingIndexing = (value != 0);
522
0
        else if (tokenStr == "generalSamplerIndexing")
523
0
            resources->limits.generalSamplerIndexing = (value != 0);
524
0
        else if (tokenStr == "generalVariableIndexing")
525
0
            resources->limits.generalVariableIndexing = (value != 0);
526
0
        else if (tokenStr == "generalConstantMatrixVectorIndexing")
527
0
            resources->limits.generalConstantMatrixVectorIndexing = (value != 0);
528
0
        else
529
0
            printf("Warning: unrecognized limit (%s) in configuration file.\n", tokenStr.c_str());
530
531
0
    }
532
0
}
533
534
TBuiltInResource* GetResources()
535
0
{
536
0
   return &Resources;
537
0
}
538
539
const TBuiltInResource* GetDefaultResources()
540
92
{
541
92
    return &DefaultTBuiltInResource;
542
92
}