| 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 "ResourceLimits.h" |
| 41 |
|
| 42 |
namespace glslang { |
| 43 |
|
| 44 |
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 |
/* .maxDualSourceDrawBuffersEXT = */ 1, |
| 138 |
|
| 139 |
/* .limits = */ { |
| 140 |
/* .nonInductiveForLoops = */ 1, |
| 141 |
/* .whileLoops = */ 1, |
| 142 |
/* .doWhileLoops = */ 1, |
| 143 |
/* .generalUniformIndexing = */ 1, |
| 144 |
/* .generalAttributeMatrixVectorIndexing = */ 1, |
| 145 |
/* .generalVaryingIndexing = */ 1, |
| 146 |
/* .generalSamplerIndexing = */ 1, |
| 147 |
/* .generalVariableIndexing = */ 1, |
| 148 |
/* .generalConstantMatrixVectorIndexing = */ 1, |
| 149 |
}}; |
| 150 |
|
| 151 |
std::string GetDefaultTBuiltInResourceString() |
| 152 |
{ |
| 153 |
std::ostringstream ostream; |
| 154 |
|
| 155 |
ostream << "MaxLights " << DefaultTBuiltInResource.maxLights << "\n" |
| 156 |
<< "MaxClipPlanes " << DefaultTBuiltInResource.maxClipPlanes << "\n" |
| 157 |
<< "MaxTextureUnits " << DefaultTBuiltInResource.maxTextureUnits << "\n" |
| 158 |
<< "MaxTextureCoords " << DefaultTBuiltInResource.maxTextureCoords << "\n" |
| 159 |
<< "MaxVertexAttribs " << DefaultTBuiltInResource.maxVertexAttribs << "\n" |
| 160 |
<< "MaxVertexUniformComponents " << DefaultTBuiltInResource.maxVertexUniformComponents << "\n" |
| 161 |
<< "MaxVaryingFloats " << DefaultTBuiltInResource.maxVaryingFloats << "\n" |
| 162 |
<< "MaxVertexTextureImageUnits " << DefaultTBuiltInResource.maxVertexTextureImageUnits << "\n" |
| 163 |
<< "MaxCombinedTextureImageUnits " << DefaultTBuiltInResource.maxCombinedTextureImageUnits << "\n" |
| 164 |
<< "MaxTextureImageUnits " << DefaultTBuiltInResource.maxTextureImageUnits << "\n" |
| 165 |
<< "MaxFragmentUniformComponents " << DefaultTBuiltInResource.maxFragmentUniformComponents << "\n" |
| 166 |
<< "MaxDrawBuffers " << DefaultTBuiltInResource.maxDrawBuffers << "\n" |
| 167 |
<< "MaxVertexUniformVectors " << DefaultTBuiltInResource.maxVertexUniformVectors << "\n" |
| 168 |
<< "MaxVaryingVectors " << DefaultTBuiltInResource.maxVaryingVectors << "\n" |
| 169 |
<< "MaxFragmentUniformVectors " << DefaultTBuiltInResource.maxFragmentUniformVectors << "\n" |
| 170 |
<< "MaxVertexOutputVectors " << DefaultTBuiltInResource.maxVertexOutputVectors << "\n" |
| 171 |
<< "MaxFragmentInputVectors " << DefaultTBuiltInResource.maxFragmentInputVectors << "\n" |
| 172 |
<< "MinProgramTexelOffset " << DefaultTBuiltInResource.minProgramTexelOffset << "\n" |
| 173 |
<< "MaxProgramTexelOffset " << DefaultTBuiltInResource.maxProgramTexelOffset << "\n" |
| 174 |
<< "MaxClipDistances " << DefaultTBuiltInResource.maxClipDistances << "\n" |
| 175 |
<< "MaxComputeWorkGroupCountX " << DefaultTBuiltInResource.maxComputeWorkGroupCountX << "\n" |
| 176 |
<< "MaxComputeWorkGroupCountY " << DefaultTBuiltInResource.maxComputeWorkGroupCountY << "\n" |
| 177 |
<< "MaxComputeWorkGroupCountZ " << DefaultTBuiltInResource.maxComputeWorkGroupCountZ << "\n" |
| 178 |
<< "MaxComputeWorkGroupSizeX " << DefaultTBuiltInResource.maxComputeWorkGroupSizeX << "\n" |
| 179 |
<< "MaxComputeWorkGroupSizeY " << DefaultTBuiltInResource.maxComputeWorkGroupSizeY << "\n" |
| 180 |
<< "MaxComputeWorkGroupSizeZ " << DefaultTBuiltInResource.maxComputeWorkGroupSizeZ << "\n" |
| 181 |
<< "MaxComputeUniformComponents " << DefaultTBuiltInResource.maxComputeUniformComponents << "\n" |
| 182 |
<< "MaxComputeTextureImageUnits " << DefaultTBuiltInResource.maxComputeTextureImageUnits << "\n" |
| 183 |
<< "MaxComputeImageUniforms " << DefaultTBuiltInResource.maxComputeImageUniforms << "\n" |
| 184 |
<< "MaxComputeAtomicCounters " << DefaultTBuiltInResource.maxComputeAtomicCounters << "\n" |
| 185 |
<< "MaxComputeAtomicCounterBuffers " << DefaultTBuiltInResource.maxComputeAtomicCounterBuffers << "\n" |
| 186 |
<< "MaxVaryingComponents " << DefaultTBuiltInResource.maxVaryingComponents << "\n" |
| 187 |
<< "MaxVertexOutputComponents " << DefaultTBuiltInResource.maxVertexOutputComponents << "\n" |
| 188 |
<< "MaxGeometryInputComponents " << DefaultTBuiltInResource.maxGeometryInputComponents << "\n" |
| 189 |
<< "MaxGeometryOutputComponents " << DefaultTBuiltInResource.maxGeometryOutputComponents << "\n" |
| 190 |
<< "MaxFragmentInputComponents " << DefaultTBuiltInResource.maxFragmentInputComponents << "\n" |
| 191 |
<< "MaxImageUnits " << DefaultTBuiltInResource.maxImageUnits << "\n" |
| 192 |
<< "MaxCombinedImageUnitsAndFragmentOutputs " << DefaultTBuiltInResource.maxCombinedImageUnitsAndFragmentOutputs << "\n" |
| 193 |
<< "MaxCombinedShaderOutputResources " << DefaultTBuiltInResource.maxCombinedShaderOutputResources << "\n" |
| 194 |
<< "MaxImageSamples " << DefaultTBuiltInResource.maxImageSamples << "\n" |
| 195 |
<< "MaxVertexImageUniforms " << DefaultTBuiltInResource.maxVertexImageUniforms << "\n" |
| 196 |
<< "MaxTessControlImageUniforms " << DefaultTBuiltInResource.maxTessControlImageUniforms << "\n" |
| 197 |
<< "MaxTessEvaluationImageUniforms " << DefaultTBuiltInResource.maxTessEvaluationImageUniforms << "\n" |
| 198 |
<< "MaxGeometryImageUniforms " << DefaultTBuiltInResource.maxGeometryImageUniforms << "\n" |
| 199 |
<< "MaxFragmentImageUniforms " << DefaultTBuiltInResource.maxFragmentImageUniforms << "\n" |
| 200 |
<< "MaxCombinedImageUniforms " << DefaultTBuiltInResource.maxCombinedImageUniforms << "\n" |
| 201 |
<< "MaxGeometryTextureImageUnits " << DefaultTBuiltInResource.maxGeometryTextureImageUnits << "\n" |
| 202 |
<< "MaxGeometryOutputVertices " << DefaultTBuiltInResource.maxGeometryOutputVertices << "\n" |
| 203 |
<< "MaxGeometryTotalOutputComponents " << DefaultTBuiltInResource.maxGeometryTotalOutputComponents << "\n" |
| 204 |
<< "MaxGeometryUniformComponents " << DefaultTBuiltInResource.maxGeometryUniformComponents << "\n" |
| 205 |
<< "MaxGeometryVaryingComponents " << DefaultTBuiltInResource.maxGeometryVaryingComponents << "\n" |
| 206 |
<< "MaxTessControlInputComponents " << DefaultTBuiltInResource.maxTessControlInputComponents << "\n" |
| 207 |
<< "MaxTessControlOutputComponents " << DefaultTBuiltInResource.maxTessControlOutputComponents << "\n" |
| 208 |
<< "MaxTessControlTextureImageUnits " << DefaultTBuiltInResource.maxTessControlTextureImageUnits << "\n" |
| 209 |
<< "MaxTessControlUniformComponents " << DefaultTBuiltInResource.maxTessControlUniformComponents << "\n" |
| 210 |
<< "MaxTessControlTotalOutputComponents " << DefaultTBuiltInResource.maxTessControlTotalOutputComponents << "\n" |
| 211 |
<< "MaxTessEvaluationInputComponents " << DefaultTBuiltInResource.maxTessEvaluationInputComponents << "\n" |
| 212 |
<< "MaxTessEvaluationOutputComponents " << DefaultTBuiltInResource.maxTessEvaluationOutputComponents << "\n" |
| 213 |
<< "MaxTessEvaluationTextureImageUnits " << DefaultTBuiltInResource.maxTessEvaluationTextureImageUnits << "\n" |
| 214 |
<< "MaxTessEvaluationUniformComponents " << DefaultTBuiltInResource.maxTessEvaluationUniformComponents << "\n" |
| 215 |
<< "MaxTessPatchComponents " << DefaultTBuiltInResource.maxTessPatchComponents << "\n" |
| 216 |
<< "MaxPatchVertices " << DefaultTBuiltInResource.maxPatchVertices << "\n" |
| 217 |
<< "MaxTessGenLevel " << DefaultTBuiltInResource.maxTessGenLevel << "\n" |
| 218 |
<< "MaxViewports " << DefaultTBuiltInResource.maxViewports << "\n" |
| 219 |
<< "MaxVertexAtomicCounters " << DefaultTBuiltInResource.maxVertexAtomicCounters << "\n" |
| 220 |
<< "MaxTessControlAtomicCounters " << DefaultTBuiltInResource.maxTessControlAtomicCounters << "\n" |
| 221 |
<< "MaxTessEvaluationAtomicCounters " << DefaultTBuiltInResource.maxTessEvaluationAtomicCounters << "\n" |
| 222 |
<< "MaxGeometryAtomicCounters " << DefaultTBuiltInResource.maxGeometryAtomicCounters << "\n" |
| 223 |
<< "MaxFragmentAtomicCounters " << DefaultTBuiltInResource.maxFragmentAtomicCounters << "\n" |
| 224 |
<< "MaxCombinedAtomicCounters " << DefaultTBuiltInResource.maxCombinedAtomicCounters << "\n" |
| 225 |
<< "MaxAtomicCounterBindings " << DefaultTBuiltInResource.maxAtomicCounterBindings << "\n" |
| 226 |
<< "MaxVertexAtomicCounterBuffers " << DefaultTBuiltInResource.maxVertexAtomicCounterBuffers << "\n" |
| 227 |
<< "MaxTessControlAtomicCounterBuffers " << DefaultTBuiltInResource.maxTessControlAtomicCounterBuffers << "\n" |
| 228 |
<< "MaxTessEvaluationAtomicCounterBuffers " << DefaultTBuiltInResource.maxTessEvaluationAtomicCounterBuffers << "\n" |
| 229 |
<< "MaxGeometryAtomicCounterBuffers " << DefaultTBuiltInResource.maxGeometryAtomicCounterBuffers << "\n" |
| 230 |
<< "MaxFragmentAtomicCounterBuffers " << DefaultTBuiltInResource.maxFragmentAtomicCounterBuffers << "\n" |
| 231 |
<< "MaxCombinedAtomicCounterBuffers " << DefaultTBuiltInResource.maxCombinedAtomicCounterBuffers << "\n" |
| 232 |
<< "MaxAtomicCounterBufferSize " << DefaultTBuiltInResource.maxAtomicCounterBufferSize << "\n" |
| 233 |
<< "MaxTransformFeedbackBuffers " << DefaultTBuiltInResource.maxTransformFeedbackBuffers << "\n" |
| 234 |
<< "MaxTransformFeedbackInterleavedComponents " << DefaultTBuiltInResource.maxTransformFeedbackInterleavedComponents << "\n" |
| 235 |
<< "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n" |
| 236 |
<< "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n" |
| 237 |
<< "MaxSamples " << DefaultTBuiltInResource.maxSamples << "\n" |
| 238 |
<< "MaxMeshOutputVerticesNV " << DefaultTBuiltInResource.maxMeshOutputVerticesNV << "\n" |
| 239 |
<< "MaxMeshOutputPrimitivesNV " << DefaultTBuiltInResource.maxMeshOutputPrimitivesNV << "\n" |
| 240 |
<< "MaxMeshWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_NV << "\n" |
| 241 |
<< "MaxMeshWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_NV << "\n" |
| 242 |
<< "MaxMeshWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_NV << "\n" |
| 243 |
<< "MaxTaskWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_NV << "\n" |
| 244 |
<< "MaxTaskWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n" |
| 245 |
<< "MaxTaskWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n" |
| 246 |
<< "MaxMeshViewCountNV " << DefaultTBuiltInResource.maxMeshViewCountNV << "\n" |
| 247 |
<< "MaxDualSourceDrawBuffersEXT " << DefaultTBuiltInResource.maxDualSourceDrawBuffersEXT << "\n" |
| 248 |
<< "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n" |
| 249 |
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n" |
| 250 |
<< "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n" |
| 251 |
<< "generalUniformIndexing " << DefaultTBuiltInResource.limits.generalUniformIndexing << "\n" |
| 252 |
<< "generalAttributeMatrixVectorIndexing " << DefaultTBuiltInResource.limits.generalAttributeMatrixVectorIndexing << "\n" |
| 253 |
<< "generalVaryingIndexing " << DefaultTBuiltInResource.limits.generalVaryingIndexing << "\n" |
| 254 |
<< "generalSamplerIndexing " << DefaultTBuiltInResource.limits.generalSamplerIndexing << "\n" |
| 255 |
<< "generalVariableIndexing " << DefaultTBuiltInResource.limits.generalVariableIndexing << "\n" |
| 256 |
<< "generalConstantMatrixVectorIndexing " << DefaultTBuiltInResource.limits.generalConstantMatrixVectorIndexing << "\n" |
| 257 |
; |
| 258 |
|
| 259 |
return ostream.str(); |
| 260 |
} |
| 261 |
|
| 262 |
void DecodeResourceLimits(TBuiltInResource* resources, char* config) |
| 263 |
{ |
| 264 |
static const char* delims = " \t\n\r"; |
| 265 |
|
| 266 |
size_t pos = 0; |
| 267 |
std::string configStr(config); |
| 268 |
|
| 269 |
while ((pos = configStr.find_first_not_of(delims, pos)) != std::string::npos) { |
| 270 |
const size_t token_s = pos; |
| 271 |
const size_t token_e = configStr.find_first_of(delims, token_s); |
| 272 |
const size_t value_s = configStr.find_first_not_of(delims, token_e); |
| 273 |
const size_t value_e = configStr.find_first_of(delims, value_s); |
| 274 |
pos = value_e; |
| 275 |
|
| 276 |
// Faster to use compare(), but prefering readability. |
| 277 |
const std::string tokenStr = configStr.substr(token_s, token_e-token_s); |
| 278 |
const std::string valueStr = configStr.substr(value_s, value_e-value_s); |
| 279 |
|
| 280 |
if (value_s == std::string::npos || ! (valueStr[0] == '-' || isdigit(valueStr[0]))) { |
| 281 |
printf("Error: '%s' bad .conf file. Each name must be followed by one number.\n", |
| 282 |
valueStr.c_str()); |
| 283 |
return; |
| 284 |
} |
| 285 |
|
| 286 |
const int value = std::atoi(valueStr.c_str()); |
| 287 |
|
| 288 |
if (tokenStr == "MaxLights") |
| 289 |
resources->maxLights = value; |
| 290 |
else if (tokenStr == "MaxClipPlanes") |
| 291 |
resources->maxClipPlanes = value; |
| 292 |
else if (tokenStr == "MaxTextureUnits") |
| 293 |
resources->maxTextureUnits = value; |
| 294 |
else if (tokenStr == "MaxTextureCoords") |
| 295 |
resources->maxTextureCoords = value; |
| 296 |
else if (tokenStr == "MaxVertexAttribs") |
| 297 |
resources->maxVertexAttribs = value; |
| 298 |
else if (tokenStr == "MaxVertexUniformComponents") |
| 299 |
resources->maxVertexUniformComponents = value; |
| 300 |
else if (tokenStr == "MaxVaryingFloats") |
| 301 |
resources->maxVaryingFloats = value; |
| 302 |
else if (tokenStr == "MaxVertexTextureImageUnits") |
| 303 |
resources->maxVertexTextureImageUnits = value; |
| 304 |
else if (tokenStr == "MaxCombinedTextureImageUnits") |
| 305 |
resources->maxCombinedTextureImageUnits = value; |
| 306 |
else if (tokenStr == "MaxTextureImageUnits") |
| 307 |
resources->maxTextureImageUnits = value; |
| 308 |
else if (tokenStr == "MaxFragmentUniformComponents") |
| 309 |
resources->maxFragmentUniformComponents = value; |
| 310 |
else if (tokenStr == "MaxDrawBuffers") |
| 311 |
resources->maxDrawBuffers = value; |
| 312 |
else if (tokenStr == "MaxVertexUniformVectors") |
| 313 |
resources->maxVertexUniformVectors = value; |
| 314 |
else if (tokenStr == "MaxVaryingVectors") |
| 315 |
resources->maxVaryingVectors = value; |
| 316 |
else if (tokenStr == "MaxFragmentUniformVectors") |
| 317 |
resources->maxFragmentUniformVectors = value; |
| 318 |
else if (tokenStr == "MaxVertexOutputVectors") |
| 319 |
resources->maxVertexOutputVectors = value; |
| 320 |
else if (tokenStr == "MaxFragmentInputVectors") |
| 321 |
resources->maxFragmentInputVectors = value; |
| 322 |
else if (tokenStr == "MinProgramTexelOffset") |
| 323 |
resources->minProgramTexelOffset = value; |
| 324 |
else if (tokenStr == "MaxProgramTexelOffset") |
| 325 |
resources->maxProgramTexelOffset = value; |
| 326 |
else if (tokenStr == "MaxClipDistances") |
| 327 |
resources->maxClipDistances = value; |
| 328 |
else if (tokenStr == "MaxComputeWorkGroupCountX") |
| 329 |
resources->maxComputeWorkGroupCountX = value; |
| 330 |
else if (tokenStr == "MaxComputeWorkGroupCountY") |
| 331 |
resources->maxComputeWorkGroupCountY = value; |
| 332 |
else if (tokenStr == "MaxComputeWorkGroupCountZ") |
| 333 |
resources->maxComputeWorkGroupCountZ = value; |
| 334 |
else if (tokenStr == "MaxComputeWorkGroupSizeX") |
| 335 |
resources->maxComputeWorkGroupSizeX = value; |
| 336 |
else if (tokenStr == "MaxComputeWorkGroupSizeY") |
| 337 |
resources->maxComputeWorkGroupSizeY = value; |
| 338 |
else if (tokenStr == "MaxComputeWorkGroupSizeZ") |
| 339 |
resources->maxComputeWorkGroupSizeZ = value; |
| 340 |
else if (tokenStr == "MaxComputeUniformComponents") |
| 341 |
resources->maxComputeUniformComponents = value; |
| 342 |
else if (tokenStr == "MaxComputeTextureImageUnits") |
| 343 |
resources->maxComputeTextureImageUnits = value; |
| 344 |
else if (tokenStr == "MaxComputeImageUniforms") |
| 345 |
resources->maxComputeImageUniforms = value; |
| 346 |
else if (tokenStr == "MaxComputeAtomicCounters") |
| 347 |
resources->maxComputeAtomicCounters = value; |
| 348 |
else if (tokenStr == "MaxComputeAtomicCounterBuffers") |
| 349 |
resources->maxComputeAtomicCounterBuffers = value; |
| 350 |
else if (tokenStr == "MaxVaryingComponents") |
| 351 |
resources->maxVaryingComponents = value; |
| 352 |
else if (tokenStr == "MaxVertexOutputComponents") |
| 353 |
resources->maxVertexOutputComponents = value; |
| 354 |
else if (tokenStr == "MaxGeometryInputComponents") |
| 355 |
resources->maxGeometryInputComponents = value; |
| 356 |
else if (tokenStr == "MaxGeometryOutputComponents") |
| 357 |
resources->maxGeometryOutputComponents = value; |
| 358 |
else if (tokenStr == "MaxFragmentInputComponents") |
| 359 |
resources->maxFragmentInputComponents = value; |
| 360 |
else if (tokenStr == "MaxImageUnits") |
| 361 |
resources->maxImageUnits = value; |
| 362 |
else if (tokenStr == "MaxCombinedImageUnitsAndFragmentOutputs") |
| 363 |
resources->maxCombinedImageUnitsAndFragmentOutputs = value; |
| 364 |
else if (tokenStr == "MaxCombinedShaderOutputResources") |
| 365 |
resources->maxCombinedShaderOutputResources = value; |
| 366 |
else if (tokenStr == "MaxImageSamples") |
| 367 |
resources->maxImageSamples = value; |
| 368 |
else if (tokenStr == "MaxVertexImageUniforms") |
| 369 |
resources->maxVertexImageUniforms = value; |
| 370 |
else if (tokenStr == "MaxTessControlImageUniforms") |
| 371 |
resources->maxTessControlImageUniforms = value; |
| 372 |
else if (tokenStr == "MaxTessEvaluationImageUniforms") |
| 373 |
resources->maxTessEvaluationImageUniforms = value; |
| 374 |
else if (tokenStr == "MaxGeometryImageUniforms") |
| 375 |
resources->maxGeometryImageUniforms = value; |
| 376 |
else if (tokenStr == "MaxFragmentImageUniforms") |
| 377 |
resources->maxFragmentImageUniforms = value; |
| 378 |
else if (tokenStr == "MaxCombinedImageUniforms") |
| 379 |
resources->maxCombinedImageUniforms = value; |
| 380 |
else if (tokenStr == "MaxGeometryTextureImageUnits") |
| 381 |
resources->maxGeometryTextureImageUnits = value; |
| 382 |
else if (tokenStr == "MaxGeometryOutputVertices") |
| 383 |
resources->maxGeometryOutputVertices = value; |
| 384 |
else if (tokenStr == "MaxGeometryTotalOutputComponents") |
| 385 |
resources->maxGeometryTotalOutputComponents = value; |
| 386 |
else if (tokenStr == "MaxGeometryUniformComponents") |
| 387 |
resources->maxGeometryUniformComponents = value; |
| 388 |
else if (tokenStr == "MaxGeometryVaryingComponents") |
| 389 |
resources->maxGeometryVaryingComponents = value; |
| 390 |
else if (tokenStr == "MaxTessControlInputComponents") |
| 391 |
resources->maxTessControlInputComponents = value; |
| 392 |
else if (tokenStr == "MaxTessControlOutputComponents") |
| 393 |
resources->maxTessControlOutputComponents = value; |
| 394 |
else if (tokenStr == "MaxTessControlTextureImageUnits") |
| 395 |
resources->maxTessControlTextureImageUnits = value; |
| 396 |
else if (tokenStr == "MaxTessControlUniformComponents") |
| 397 |
resources->maxTessControlUniformComponents = value; |
| 398 |
else if (tokenStr == "MaxTessControlTotalOutputComponents") |
| 399 |
resources->maxTessControlTotalOutputComponents = value; |
| 400 |
else if (tokenStr == "MaxTessEvaluationInputComponents") |
| 401 |
resources->maxTessEvaluationInputComponents = value; |
| 402 |
else if (tokenStr == "MaxTessEvaluationOutputComponents") |
| 403 |
resources->maxTessEvaluationOutputComponents = value; |
| 404 |
else if (tokenStr == "MaxTessEvaluationTextureImageUnits") |
| 405 |
resources->maxTessEvaluationTextureImageUnits = value; |
| 406 |
else if (tokenStr == "MaxTessEvaluationUniformComponents") |
| 407 |
resources->maxTessEvaluationUniformComponents = value; |
| 408 |
else if (tokenStr == "MaxTessPatchComponents") |
| 409 |
resources->maxTessPatchComponents = value; |
| 410 |
else if (tokenStr == "MaxPatchVertices") |
| 411 |
resources->maxPatchVertices = value; |
| 412 |
else if (tokenStr == "MaxTessGenLevel") |
| 413 |
resources->maxTessGenLevel = value; |
| 414 |
else if (tokenStr == "MaxViewports") |
| 415 |
resources->maxViewports = value; |
| 416 |
else if (tokenStr == "MaxVertexAtomicCounters") |
| 417 |
resources->maxVertexAtomicCounters = value; |
| 418 |
else if (tokenStr == "MaxTessControlAtomicCounters") |
| 419 |
resources->maxTessControlAtomicCounters = value; |
| 420 |
else if (tokenStr == "MaxTessEvaluationAtomicCounters") |
| 421 |
resources->maxTessEvaluationAtomicCounters = value; |
| 422 |
else if (tokenStr == "MaxGeometryAtomicCounters") |
| 423 |
resources->maxGeometryAtomicCounters = value; |
| 424 |
else if (tokenStr == "MaxFragmentAtomicCounters") |
| 425 |
resources->maxFragmentAtomicCounters = value; |
| 426 |
else if (tokenStr == "MaxCombinedAtomicCounters") |
| 427 |
resources->maxCombinedAtomicCounters = value; |
| 428 |
else if (tokenStr == "MaxAtomicCounterBindings") |
| 429 |
resources->maxAtomicCounterBindings = value; |
| 430 |
else if (tokenStr == "MaxVertexAtomicCounterBuffers") |
| 431 |
resources->maxVertexAtomicCounterBuffers = value; |
| 432 |
else if (tokenStr == "MaxTessControlAtomicCounterBuffers") |
| 433 |
resources->maxTessControlAtomicCounterBuffers = value; |
| 434 |
else if (tokenStr == "MaxTessEvaluationAtomicCounterBuffers") |
| 435 |
resources->maxTessEvaluationAtomicCounterBuffers = value; |
| 436 |
else if (tokenStr == "MaxGeometryAtomicCounterBuffers") |
| 437 |
resources->maxGeometryAtomicCounterBuffers = value; |
| 438 |
else if (tokenStr == "MaxFragmentAtomicCounterBuffers") |
| 439 |
resources->maxFragmentAtomicCounterBuffers = value; |
| 440 |
else if (tokenStr == "MaxCombinedAtomicCounterBuffers") |
| 441 |
resources->maxCombinedAtomicCounterBuffers = value; |
| 442 |
else if (tokenStr == "MaxAtomicCounterBufferSize") |
| 443 |
resources->maxAtomicCounterBufferSize = value; |
| 444 |
else if (tokenStr == "MaxTransformFeedbackBuffers") |
| 445 |
resources->maxTransformFeedbackBuffers = value; |
| 446 |
else if (tokenStr == "MaxTransformFeedbackInterleavedComponents") |
| 447 |
resources->maxTransformFeedbackInterleavedComponents = value; |
| 448 |
else if (tokenStr == "MaxCullDistances") |
| 449 |
resources->maxCullDistances = value; |
| 450 |
else if (tokenStr == "MaxCombinedClipAndCullDistances") |
| 451 |
resources->maxCombinedClipAndCullDistances = value; |
| 452 |
else if (tokenStr == "MaxSamples") |
| 453 |
resources->maxSamples = value; |
| 454 |
else if (tokenStr == "MaxMeshOutputVerticesNV") |
| 455 |
resources->maxMeshOutputVerticesNV = value; |
| 456 |
else if (tokenStr == "MaxMeshOutputPrimitivesNV") |
| 457 |
resources->maxMeshOutputPrimitivesNV = value; |
| 458 |
else if (tokenStr == "MaxMeshWorkGroupSizeX_NV") |
| 459 |
resources->maxMeshWorkGroupSizeX_NV = value; |
| 460 |
else if (tokenStr == "MaxMeshWorkGroupSizeY_NV") |
| 461 |
resources->maxMeshWorkGroupSizeY_NV = value; |
| 462 |
else if (tokenStr == "MaxMeshWorkGroupSizeZ_NV") |
| 463 |
resources->maxMeshWorkGroupSizeZ_NV = value; |
| 464 |
else if (tokenStr == "MaxTaskWorkGroupSizeX_NV") |
| 465 |
resources->maxTaskWorkGroupSizeX_NV = value; |
| 466 |
else if (tokenStr == "MaxTaskWorkGroupSizeY_NV") |
| 467 |
resources->maxTaskWorkGroupSizeY_NV = value; |
| 468 |
else if (tokenStr == "MaxTaskWorkGroupSizeZ_NV") |
| 469 |
resources->maxTaskWorkGroupSizeZ_NV = value; |
| 470 |
else if (tokenStr == "MaxMeshViewCountNV") |
| 471 |
resources->maxMeshViewCountNV = value; |
| 472 |
else if (tokenStr == "nonInductiveForLoops") |
| 473 |
resources->limits.nonInductiveForLoops = (value != 0); |
| 474 |
else if (tokenStr == "whileLoops") |
| 475 |
resources->limits.whileLoops = (value != 0); |
| 476 |
else if (tokenStr == "doWhileLoops") |
| 477 |
resources->limits.doWhileLoops = (value != 0); |
| 478 |
else if (tokenStr == "generalUniformIndexing") |
| 479 |
resources->limits.generalUniformIndexing = (value != 0); |
| 480 |
else if (tokenStr == "generalAttributeMatrixVectorIndexing") |
| 481 |
resources->limits.generalAttributeMatrixVectorIndexing = (value != 0); |
| 482 |
else if (tokenStr == "generalVaryingIndexing") |
| 483 |
resources->limits.generalVaryingIndexing = (value != 0); |
| 484 |
else if (tokenStr == "generalSamplerIndexing") |
| 485 |
resources->limits.generalSamplerIndexing = (value != 0); |
| 486 |
else if (tokenStr == "generalVariableIndexing") |
| 487 |
resources->limits.generalVariableIndexing = (value != 0); |
| 488 |
else if (tokenStr == "generalConstantMatrixVectorIndexing") |
| 489 |
resources->limits.generalConstantMatrixVectorIndexing = (value != 0); |
| 490 |
else |
| 491 |
printf("Warning: unrecognized limit (%s) in configuration file.\n", tokenStr.c_str()); |
| 492 |
|
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
} // end namespace glslang |