Test compiling shaders with given resource limits using GTest.
This commit is contained in:
parent
8a9b1ee3b4
commit
1b141728a6
@ -32,6 +32,7 @@
|
|||||||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "ResourceLimits.h"
|
#include "ResourceLimits.h"
|
||||||
@ -236,4 +237,207 @@ std::string GetDefaultTBuiltInResourceString()
|
|||||||
return ostream.str();
|
return ostream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DecodeResourceLimits(TBuiltInResource* resources, char* config) {
|
||||||
|
const char* delims = " \t\n\r";
|
||||||
|
const char* token = strtok(config, delims);
|
||||||
|
while (token) {
|
||||||
|
const char* valueStr = strtok(0, delims);
|
||||||
|
if (valueStr == 0 || ! (valueStr[0] == '-' || (valueStr[0] >= '0' && valueStr[0] <= '9'))) {
|
||||||
|
printf("Error: '%s' bad .conf file. Each name must be followed by one number.\n", valueStr ? valueStr : "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int value = atoi(valueStr);
|
||||||
|
|
||||||
|
if (strcmp(token, "MaxLights") == 0)
|
||||||
|
resources->maxLights = value;
|
||||||
|
else if (strcmp(token, "MaxClipPlanes") == 0)
|
||||||
|
resources->maxClipPlanes = value;
|
||||||
|
else if (strcmp(token, "MaxTextureUnits") == 0)
|
||||||
|
resources->maxTextureUnits = value;
|
||||||
|
else if (strcmp(token, "MaxTextureCoords") == 0)
|
||||||
|
resources->maxTextureCoords = value;
|
||||||
|
else if (strcmp(token, "MaxVertexAttribs") == 0)
|
||||||
|
resources->maxVertexAttribs = value;
|
||||||
|
else if (strcmp(token, "MaxVertexUniformComponents") == 0)
|
||||||
|
resources->maxVertexUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxVaryingFloats") == 0)
|
||||||
|
resources->maxVaryingFloats = value;
|
||||||
|
else if (strcmp(token, "MaxVertexTextureImageUnits") == 0)
|
||||||
|
resources->maxVertexTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedTextureImageUnits") == 0)
|
||||||
|
resources->maxCombinedTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxTextureImageUnits") == 0)
|
||||||
|
resources->maxTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentUniformComponents") == 0)
|
||||||
|
resources->maxFragmentUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxDrawBuffers") == 0)
|
||||||
|
resources->maxDrawBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxVertexUniformVectors") == 0)
|
||||||
|
resources->maxVertexUniformVectors = value;
|
||||||
|
else if (strcmp(token, "MaxVaryingVectors") == 0)
|
||||||
|
resources->maxVaryingVectors = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentUniformVectors") == 0)
|
||||||
|
resources->maxFragmentUniformVectors = value;
|
||||||
|
else if (strcmp(token, "MaxVertexOutputVectors") == 0)
|
||||||
|
resources->maxVertexOutputVectors = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentInputVectors") == 0)
|
||||||
|
resources->maxFragmentInputVectors = value;
|
||||||
|
else if (strcmp(token, "MinProgramTexelOffset") == 0)
|
||||||
|
resources->minProgramTexelOffset = value;
|
||||||
|
else if (strcmp(token, "MaxProgramTexelOffset") == 0)
|
||||||
|
resources->maxProgramTexelOffset = value;
|
||||||
|
else if (strcmp(token, "MaxClipDistances") == 0)
|
||||||
|
resources->maxClipDistances = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupCountX") == 0)
|
||||||
|
resources->maxComputeWorkGroupCountX = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupCountY") == 0)
|
||||||
|
resources->maxComputeWorkGroupCountY = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupCountZ") == 0)
|
||||||
|
resources->maxComputeWorkGroupCountZ = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupSizeX") == 0)
|
||||||
|
resources->maxComputeWorkGroupSizeX = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupSizeY") == 0)
|
||||||
|
resources->maxComputeWorkGroupSizeY = value;
|
||||||
|
else if (strcmp(token, "MaxComputeWorkGroupSizeZ") == 0)
|
||||||
|
resources->maxComputeWorkGroupSizeZ = value;
|
||||||
|
else if (strcmp(token, "MaxComputeUniformComponents") == 0)
|
||||||
|
resources->maxComputeUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxComputeTextureImageUnits") == 0)
|
||||||
|
resources->maxComputeTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxComputeImageUniforms") == 0)
|
||||||
|
resources->maxComputeImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxComputeAtomicCounters") == 0)
|
||||||
|
resources->maxComputeAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxComputeAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxComputeAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxVaryingComponents") == 0)
|
||||||
|
resources->maxVaryingComponents = value;
|
||||||
|
else if (strcmp(token, "MaxVertexOutputComponents") == 0)
|
||||||
|
resources->maxVertexOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryInputComponents") == 0)
|
||||||
|
resources->maxGeometryInputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryOutputComponents") == 0)
|
||||||
|
resources->maxGeometryOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentInputComponents") == 0)
|
||||||
|
resources->maxFragmentInputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxImageUnits") == 0)
|
||||||
|
resources->maxImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedImageUnitsAndFragmentOutputs") == 0)
|
||||||
|
resources->maxCombinedImageUnitsAndFragmentOutputs = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedShaderOutputResources") == 0)
|
||||||
|
resources->maxCombinedShaderOutputResources = value;
|
||||||
|
else if (strcmp(token, "MaxImageSamples") == 0)
|
||||||
|
resources->maxImageSamples = value;
|
||||||
|
else if (strcmp(token, "MaxVertexImageUniforms") == 0)
|
||||||
|
resources->maxVertexImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlImageUniforms") == 0)
|
||||||
|
resources->maxTessControlImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationImageUniforms") == 0)
|
||||||
|
resources->maxTessEvaluationImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryImageUniforms") == 0)
|
||||||
|
resources->maxGeometryImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentImageUniforms") == 0)
|
||||||
|
resources->maxFragmentImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedImageUniforms") == 0)
|
||||||
|
resources->maxCombinedImageUniforms = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryTextureImageUnits") == 0)
|
||||||
|
resources->maxGeometryTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryOutputVertices") == 0)
|
||||||
|
resources->maxGeometryOutputVertices = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryTotalOutputComponents") == 0)
|
||||||
|
resources->maxGeometryTotalOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryUniformComponents") == 0)
|
||||||
|
resources->maxGeometryUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryVaryingComponents") == 0)
|
||||||
|
resources->maxGeometryVaryingComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlInputComponents") == 0)
|
||||||
|
resources->maxTessControlInputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlOutputComponents") == 0)
|
||||||
|
resources->maxTessControlOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlTextureImageUnits") == 0)
|
||||||
|
resources->maxTessControlTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlUniformComponents") == 0)
|
||||||
|
resources->maxTessControlUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlTotalOutputComponents") == 0)
|
||||||
|
resources->maxTessControlTotalOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationInputComponents") == 0)
|
||||||
|
resources->maxTessEvaluationInputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationOutputComponents") == 0)
|
||||||
|
resources->maxTessEvaluationOutputComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationTextureImageUnits") == 0)
|
||||||
|
resources->maxTessEvaluationTextureImageUnits = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationUniformComponents") == 0)
|
||||||
|
resources->maxTessEvaluationUniformComponents = value;
|
||||||
|
else if (strcmp(token, "MaxTessPatchComponents") == 0)
|
||||||
|
resources->maxTessPatchComponents = value;
|
||||||
|
else if (strcmp(token, "MaxPatchVertices") == 0)
|
||||||
|
resources->maxPatchVertices = value;
|
||||||
|
else if (strcmp(token, "MaxTessGenLevel") == 0)
|
||||||
|
resources->maxTessGenLevel = value;
|
||||||
|
else if (strcmp(token, "MaxViewports") == 0)
|
||||||
|
resources->maxViewports = value;
|
||||||
|
else if (strcmp(token, "MaxVertexAtomicCounters") == 0)
|
||||||
|
resources->maxVertexAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlAtomicCounters") == 0)
|
||||||
|
resources->maxTessControlAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationAtomicCounters") == 0)
|
||||||
|
resources->maxTessEvaluationAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryAtomicCounters") == 0)
|
||||||
|
resources->maxGeometryAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentAtomicCounters") == 0)
|
||||||
|
resources->maxFragmentAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedAtomicCounters") == 0)
|
||||||
|
resources->maxCombinedAtomicCounters = value;
|
||||||
|
else if (strcmp(token, "MaxAtomicCounterBindings") == 0)
|
||||||
|
resources->maxAtomicCounterBindings = value;
|
||||||
|
else if (strcmp(token, "MaxVertexAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxVertexAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxTessControlAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxTessControlAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxTessEvaluationAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxTessEvaluationAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxGeometryAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxGeometryAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxFragmentAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxFragmentAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedAtomicCounterBuffers") == 0)
|
||||||
|
resources->maxCombinedAtomicCounterBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxAtomicCounterBufferSize") == 0)
|
||||||
|
resources->maxAtomicCounterBufferSize = value;
|
||||||
|
else if (strcmp(token, "MaxTransformFeedbackBuffers") == 0)
|
||||||
|
resources->maxTransformFeedbackBuffers = value;
|
||||||
|
else if (strcmp(token, "MaxTransformFeedbackInterleavedComponents") == 0)
|
||||||
|
resources->maxTransformFeedbackInterleavedComponents = value;
|
||||||
|
else if (strcmp(token, "MaxCullDistances") == 0)
|
||||||
|
resources->maxCullDistances = value;
|
||||||
|
else if (strcmp(token, "MaxCombinedClipAndCullDistances") == 0)
|
||||||
|
resources->maxCombinedClipAndCullDistances = value;
|
||||||
|
else if (strcmp(token, "MaxSamples") == 0)
|
||||||
|
resources->maxSamples = value;
|
||||||
|
|
||||||
|
else if (strcmp(token, "nonInductiveForLoops") == 0)
|
||||||
|
resources->limits.nonInductiveForLoops = (value != 0);
|
||||||
|
else if (strcmp(token, "whileLoops") == 0)
|
||||||
|
resources->limits.whileLoops = (value != 0);
|
||||||
|
else if (strcmp(token, "doWhileLoops") == 0)
|
||||||
|
resources->limits.doWhileLoops = (value != 0);
|
||||||
|
else if (strcmp(token, "generalUniformIndexing") == 0)
|
||||||
|
resources->limits.generalUniformIndexing = (value != 0);
|
||||||
|
else if (strcmp(token, "generalAttributeMatrixVectorIndexing") == 0)
|
||||||
|
resources->limits.generalAttributeMatrixVectorIndexing = (value != 0);
|
||||||
|
else if (strcmp(token, "generalVaryingIndexing") == 0)
|
||||||
|
resources->limits.generalVaryingIndexing = (value != 0);
|
||||||
|
else if (strcmp(token, "generalSamplerIndexing") == 0)
|
||||||
|
resources->limits.generalSamplerIndexing = (value != 0);
|
||||||
|
else if (strcmp(token, "generalVariableIndexing") == 0)
|
||||||
|
resources->limits.generalVariableIndexing = (value != 0);
|
||||||
|
else if (strcmp(token, "generalConstantMatrixVectorIndexing") == 0)
|
||||||
|
resources->limits.generalConstantMatrixVectorIndexing = (value != 0);
|
||||||
|
else
|
||||||
|
printf("Warning: unrecognized limit (%s) in configuration file.\n", token);
|
||||||
|
|
||||||
|
token = strtok(0, delims);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace glslang
|
} // end namespace glslang
|
||||||
|
@ -49,6 +49,9 @@ extern const TBuiltInResource DefaultTBuiltInResource;
|
|||||||
// Returns the DefaultTBuiltInResource as a human-readable string.
|
// Returns the DefaultTBuiltInResource as a human-readable string.
|
||||||
std::string GetDefaultTBuiltInResourceString();
|
std::string GetDefaultTBuiltInResourceString();
|
||||||
|
|
||||||
|
// Decodes the resource limits from |config| to |resources|.
|
||||||
|
void DecodeResourceLimits(TBuiltInResource* resources, char* config);
|
||||||
|
|
||||||
} // end namespace glslang
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
|
#endif // _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
|
||||||
|
@ -134,206 +134,8 @@ void ProcessConfigFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* delims = " \t\n\r";
|
glslang::DecodeResourceLimits(&Resources, config);
|
||||||
const char* token = strtok(config, delims);
|
|
||||||
while (token) {
|
|
||||||
const char* valueStr = strtok(0, delims);
|
|
||||||
if (valueStr == 0 || ! (valueStr[0] == '-' || (valueStr[0] >= '0' && valueStr[0] <= '9'))) {
|
|
||||||
printf("Error: '%s' bad .conf file. Each name must be followed by one number.\n", valueStr ? valueStr : "");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int value = atoi(valueStr);
|
|
||||||
|
|
||||||
if (strcmp(token, "MaxLights") == 0)
|
|
||||||
Resources.maxLights = value;
|
|
||||||
else if (strcmp(token, "MaxClipPlanes") == 0)
|
|
||||||
Resources.maxClipPlanes = value;
|
|
||||||
else if (strcmp(token, "MaxTextureUnits") == 0)
|
|
||||||
Resources.maxTextureUnits = value;
|
|
||||||
else if (strcmp(token, "MaxTextureCoords") == 0)
|
|
||||||
Resources.maxTextureCoords = value;
|
|
||||||
else if (strcmp(token, "MaxVertexAttribs") == 0)
|
|
||||||
Resources.maxVertexAttribs = value;
|
|
||||||
else if (strcmp(token, "MaxVertexUniformComponents") == 0)
|
|
||||||
Resources.maxVertexUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxVaryingFloats") == 0)
|
|
||||||
Resources.maxVaryingFloats = value;
|
|
||||||
else if (strcmp(token, "MaxVertexTextureImageUnits") == 0)
|
|
||||||
Resources.maxVertexTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedTextureImageUnits") == 0)
|
|
||||||
Resources.maxCombinedTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxTextureImageUnits") == 0)
|
|
||||||
Resources.maxTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentUniformComponents") == 0)
|
|
||||||
Resources.maxFragmentUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxDrawBuffers") == 0)
|
|
||||||
Resources.maxDrawBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxVertexUniformVectors") == 0)
|
|
||||||
Resources.maxVertexUniformVectors = value;
|
|
||||||
else if (strcmp(token, "MaxVaryingVectors") == 0)
|
|
||||||
Resources.maxVaryingVectors = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentUniformVectors") == 0)
|
|
||||||
Resources.maxFragmentUniformVectors = value;
|
|
||||||
else if (strcmp(token, "MaxVertexOutputVectors") == 0)
|
|
||||||
Resources.maxVertexOutputVectors = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentInputVectors") == 0)
|
|
||||||
Resources.maxFragmentInputVectors = value;
|
|
||||||
else if (strcmp(token, "MinProgramTexelOffset") == 0)
|
|
||||||
Resources.minProgramTexelOffset = value;
|
|
||||||
else if (strcmp(token, "MaxProgramTexelOffset") == 0)
|
|
||||||
Resources.maxProgramTexelOffset = value;
|
|
||||||
else if (strcmp(token, "MaxClipDistances") == 0)
|
|
||||||
Resources.maxClipDistances = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupCountX") == 0)
|
|
||||||
Resources.maxComputeWorkGroupCountX = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupCountY") == 0)
|
|
||||||
Resources.maxComputeWorkGroupCountY = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupCountZ") == 0)
|
|
||||||
Resources.maxComputeWorkGroupCountZ = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupSizeX") == 0)
|
|
||||||
Resources.maxComputeWorkGroupSizeX = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupSizeY") == 0)
|
|
||||||
Resources.maxComputeWorkGroupSizeY = value;
|
|
||||||
else if (strcmp(token, "MaxComputeWorkGroupSizeZ") == 0)
|
|
||||||
Resources.maxComputeWorkGroupSizeZ = value;
|
|
||||||
else if (strcmp(token, "MaxComputeUniformComponents") == 0)
|
|
||||||
Resources.maxComputeUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxComputeTextureImageUnits") == 0)
|
|
||||||
Resources.maxComputeTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxComputeImageUniforms") == 0)
|
|
||||||
Resources.maxComputeImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxComputeAtomicCounters") == 0)
|
|
||||||
Resources.maxComputeAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxComputeAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxComputeAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxVaryingComponents") == 0)
|
|
||||||
Resources.maxVaryingComponents = value;
|
|
||||||
else if (strcmp(token, "MaxVertexOutputComponents") == 0)
|
|
||||||
Resources.maxVertexOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryInputComponents") == 0)
|
|
||||||
Resources.maxGeometryInputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryOutputComponents") == 0)
|
|
||||||
Resources.maxGeometryOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentInputComponents") == 0)
|
|
||||||
Resources.maxFragmentInputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxImageUnits") == 0)
|
|
||||||
Resources.maxImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedImageUnitsAndFragmentOutputs") == 0)
|
|
||||||
Resources.maxCombinedImageUnitsAndFragmentOutputs = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedShaderOutputResources") == 0)
|
|
||||||
Resources.maxCombinedShaderOutputResources = value;
|
|
||||||
else if (strcmp(token, "MaxImageSamples") == 0)
|
|
||||||
Resources.maxImageSamples = value;
|
|
||||||
else if (strcmp(token, "MaxVertexImageUniforms") == 0)
|
|
||||||
Resources.maxVertexImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlImageUniforms") == 0)
|
|
||||||
Resources.maxTessControlImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationImageUniforms") == 0)
|
|
||||||
Resources.maxTessEvaluationImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryImageUniforms") == 0)
|
|
||||||
Resources.maxGeometryImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentImageUniforms") == 0)
|
|
||||||
Resources.maxFragmentImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedImageUniforms") == 0)
|
|
||||||
Resources.maxCombinedImageUniforms = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryTextureImageUnits") == 0)
|
|
||||||
Resources.maxGeometryTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryOutputVertices") == 0)
|
|
||||||
Resources.maxGeometryOutputVertices = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryTotalOutputComponents") == 0)
|
|
||||||
Resources.maxGeometryTotalOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryUniformComponents") == 0)
|
|
||||||
Resources.maxGeometryUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryVaryingComponents") == 0)
|
|
||||||
Resources.maxGeometryVaryingComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlInputComponents") == 0)
|
|
||||||
Resources.maxTessControlInputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlOutputComponents") == 0)
|
|
||||||
Resources.maxTessControlOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlTextureImageUnits") == 0)
|
|
||||||
Resources.maxTessControlTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlUniformComponents") == 0)
|
|
||||||
Resources.maxTessControlUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlTotalOutputComponents") == 0)
|
|
||||||
Resources.maxTessControlTotalOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationInputComponents") == 0)
|
|
||||||
Resources.maxTessEvaluationInputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationOutputComponents") == 0)
|
|
||||||
Resources.maxTessEvaluationOutputComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationTextureImageUnits") == 0)
|
|
||||||
Resources.maxTessEvaluationTextureImageUnits = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationUniformComponents") == 0)
|
|
||||||
Resources.maxTessEvaluationUniformComponents = value;
|
|
||||||
else if (strcmp(token, "MaxTessPatchComponents") == 0)
|
|
||||||
Resources.maxTessPatchComponents = value;
|
|
||||||
else if (strcmp(token, "MaxPatchVertices") == 0)
|
|
||||||
Resources.maxPatchVertices = value;
|
|
||||||
else if (strcmp(token, "MaxTessGenLevel") == 0)
|
|
||||||
Resources.maxTessGenLevel = value;
|
|
||||||
else if (strcmp(token, "MaxViewports") == 0)
|
|
||||||
Resources.maxViewports = value;
|
|
||||||
else if (strcmp(token, "MaxVertexAtomicCounters") == 0)
|
|
||||||
Resources.maxVertexAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlAtomicCounters") == 0)
|
|
||||||
Resources.maxTessControlAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationAtomicCounters") == 0)
|
|
||||||
Resources.maxTessEvaluationAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryAtomicCounters") == 0)
|
|
||||||
Resources.maxGeometryAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentAtomicCounters") == 0)
|
|
||||||
Resources.maxFragmentAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedAtomicCounters") == 0)
|
|
||||||
Resources.maxCombinedAtomicCounters = value;
|
|
||||||
else if (strcmp(token, "MaxAtomicCounterBindings") == 0)
|
|
||||||
Resources.maxAtomicCounterBindings = value;
|
|
||||||
else if (strcmp(token, "MaxVertexAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxVertexAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxTessControlAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxTessControlAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxTessEvaluationAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxTessEvaluationAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxGeometryAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxGeometryAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxFragmentAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxFragmentAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedAtomicCounterBuffers") == 0)
|
|
||||||
Resources.maxCombinedAtomicCounterBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxAtomicCounterBufferSize") == 0)
|
|
||||||
Resources.maxAtomicCounterBufferSize = value;
|
|
||||||
else if (strcmp(token, "MaxTransformFeedbackBuffers") == 0)
|
|
||||||
Resources.maxTransformFeedbackBuffers = value;
|
|
||||||
else if (strcmp(token, "MaxTransformFeedbackInterleavedComponents") == 0)
|
|
||||||
Resources.maxTransformFeedbackInterleavedComponents = value;
|
|
||||||
else if (strcmp(token, "MaxCullDistances") == 0)
|
|
||||||
Resources.maxCullDistances = value;
|
|
||||||
else if (strcmp(token, "MaxCombinedClipAndCullDistances") == 0)
|
|
||||||
Resources.maxCombinedClipAndCullDistances = value;
|
|
||||||
else if (strcmp(token, "MaxSamples") == 0)
|
|
||||||
Resources.maxSamples = value;
|
|
||||||
|
|
||||||
else if (strcmp(token, "nonInductiveForLoops") == 0)
|
|
||||||
Resources.limits.nonInductiveForLoops = (value != 0);
|
|
||||||
else if (strcmp(token, "whileLoops") == 0)
|
|
||||||
Resources.limits.whileLoops = (value != 0);
|
|
||||||
else if (strcmp(token, "doWhileLoops") == 0)
|
|
||||||
Resources.limits.doWhileLoops = (value != 0);
|
|
||||||
else if (strcmp(token, "generalUniformIndexing") == 0)
|
|
||||||
Resources.limits.generalUniformIndexing = (value != 0);
|
|
||||||
else if (strcmp(token, "generalAttributeMatrixVectorIndexing") == 0)
|
|
||||||
Resources.limits.generalAttributeMatrixVectorIndexing = (value != 0);
|
|
||||||
else if (strcmp(token, "generalVaryingIndexing") == 0)
|
|
||||||
Resources.limits.generalVaryingIndexing = (value != 0);
|
|
||||||
else if (strcmp(token, "generalSamplerIndexing") == 0)
|
|
||||||
Resources.limits.generalSamplerIndexing = (value != 0);
|
|
||||||
else if (strcmp(token, "generalVariableIndexing") == 0)
|
|
||||||
Resources.limits.generalVariableIndexing = (value != 0);
|
|
||||||
else if (strcmp(token, "generalConstantMatrixVectorIndexing") == 0)
|
|
||||||
Resources.limits.generalConstantMatrixVectorIndexing = (value != 0);
|
|
||||||
else
|
|
||||||
printf("Warning: unrecognized limit (%s) in configuration file.\n", token);
|
|
||||||
|
|
||||||
token = strtok(0, delims);
|
|
||||||
}
|
|
||||||
if (configStrings)
|
if (configStrings)
|
||||||
FreeFileData(configStrings);
|
FreeFileData(configStrings);
|
||||||
else
|
else
|
||||||
|
@ -22,3 +22,7 @@ ERROR: 0:65: 'limitations' : Non-constant-index-expression
|
|||||||
ERROR: 20 compilation errors. No code generated.
|
ERROR: 20 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Linked vertex stage:
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ $EXE -c > $TARGETDIR/test.conf
|
|||||||
diff -b $BASEDIR/test.conf $TARGETDIR/test.conf || HASERROR=1
|
diff -b $BASEDIR/test.conf $TARGETDIR/test.conf || HASERROR=1
|
||||||
$EXE -i -l $TARGETDIR/test.conf specExamples.vert > $TARGETDIR/specExamples.vert.out
|
$EXE -i -l $TARGETDIR/test.conf specExamples.vert > $TARGETDIR/specExamples.vert.out
|
||||||
diff -b $BASEDIR/specExamples.vert.out $TARGETDIR || HASERROR=1
|
diff -b $BASEDIR/specExamples.vert.out $TARGETDIR || HASERROR=1
|
||||||
$EXE 100Limits.vert 100.conf > $TARGETDIR/100LimitsConf.vert.out
|
$EXE -l 100Limits.vert 100.conf > $TARGETDIR/100LimitsConf.vert.out
|
||||||
diff -b $BASEDIR/100LimitsConf.vert.out $TARGETDIR/100LimitsConf.vert.out || HASERROR=1
|
diff -b $BASEDIR/100LimitsConf.vert.out $TARGETDIR/100LimitsConf.vert.out || HASERROR=1
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -13,6 +13,7 @@ if (TARGET gmock)
|
|||||||
# Test related source files
|
# Test related source files
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
|
||||||
|
107
gtests/Config.FromFile.cpp
Normal file
107
gtests/Config.FromFile.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
//
|
||||||
|
// Copyright (C) 2016 Google, Inc.
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions
|
||||||
|
// are met:
|
||||||
|
//
|
||||||
|
// Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following
|
||||||
|
// disclaimer in the documentation and/or other materials provided
|
||||||
|
// with the distribution.
|
||||||
|
//
|
||||||
|
// Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "StandAlone/ResourceLimits.h"
|
||||||
|
#include "TestFixture.h"
|
||||||
|
|
||||||
|
namespace glslangtest {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct TestCaseSpec {
|
||||||
|
std::string input;
|
||||||
|
std::string config;
|
||||||
|
std::string output;
|
||||||
|
EShMessages controls;
|
||||||
|
};
|
||||||
|
|
||||||
|
using ConfigTest = GlslangTest<::testing::TestWithParam<TestCaseSpec>>;
|
||||||
|
|
||||||
|
TEST_P(ConfigTest, FromFile)
|
||||||
|
{
|
||||||
|
TestCaseSpec testCase = GetParam();
|
||||||
|
GlslangResult result;
|
||||||
|
|
||||||
|
// Get the contents for input shader and limit configurations.
|
||||||
|
std::string shaderContents, configContents;
|
||||||
|
tryLoadFile(GLSLANG_TEST_DIRECTORY "/" + testCase.input, "input", &shaderContents);
|
||||||
|
tryLoadFile(GLSLANG_TEST_DIRECTORY "/" + testCase.config, "limits config", &configContents);
|
||||||
|
|
||||||
|
// Decode limit configurations.
|
||||||
|
TBuiltInResource resources = {};
|
||||||
|
{
|
||||||
|
const size_t len = configContents.size();
|
||||||
|
char* configChars = new char[len + 1];
|
||||||
|
memcpy(configChars, configContents.data(), len);
|
||||||
|
configChars[len] = 0;
|
||||||
|
glslang::DecodeResourceLimits(&resources, configChars);
|
||||||
|
delete[] configChars;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compile the shader.
|
||||||
|
glslang::TShader shader(GetShaderStage(GetSuffix(testCase.input)));
|
||||||
|
compile(&shader, shaderContents, "", testCase.controls, &resources);
|
||||||
|
result.shaderResults.push_back(
|
||||||
|
{testCase.input, shader.getInfoLog(), shader.getInfoDebugLog()});
|
||||||
|
|
||||||
|
// Link the shader.
|
||||||
|
glslang::TProgram program;
|
||||||
|
program.addShader(&shader);
|
||||||
|
program.link(testCase.controls);
|
||||||
|
result.linkingOutput = program.getInfoLog();
|
||||||
|
result.linkingError = program.getInfoDebugLog();
|
||||||
|
|
||||||
|
std::ostringstream stream;
|
||||||
|
outputResultToStream(&stream, result, testCase.controls);
|
||||||
|
|
||||||
|
// Check with expected results.
|
||||||
|
const std::string expectedOutputFname =
|
||||||
|
GLSLANG_TEST_DIRECTORY "/baseResults/" + testCase.output;
|
||||||
|
std::string expectedOutput;
|
||||||
|
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||||
|
|
||||||
|
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
INSTANTIATE_TEST_CASE_P(
|
||||||
|
Glsl, ConfigTest,
|
||||||
|
::testing::ValuesIn(std::vector<TestCaseSpec>({
|
||||||
|
{"specExamples.vert", "baseResults/test.conf", "specExamples.vert.out", EShMsgAST},
|
||||||
|
{"100Limits.vert", "100.conf", "100LimitsConf.vert.out", EShMsgDefault},
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
} // namespace glslangtest
|
@ -171,7 +171,8 @@ public:
|
|||||||
// the target under the semantics conveyed via |controls|. Returns true
|
// the target under the semantics conveyed via |controls|. Returns true
|
||||||
// and modifies |shader| on success.
|
// and modifies |shader| on success.
|
||||||
bool compile(glslang::TShader* shader, const std::string& code,
|
bool compile(glslang::TShader* shader, const std::string& code,
|
||||||
const std::string& entryPointName, EShMessages controls)
|
const std::string& entryPointName, EShMessages controls,
|
||||||
|
const TBuiltInResource* resources=nullptr)
|
||||||
{
|
{
|
||||||
const char* shaderStrings = code.data();
|
const char* shaderStrings = code.data();
|
||||||
const int shaderLengths = static_cast<int>(code.size());
|
const int shaderLengths = static_cast<int>(code.size());
|
||||||
@ -181,8 +182,9 @@ public:
|
|||||||
// Reinitialize glslang if the semantics change.
|
// Reinitialize glslang if the semantics change.
|
||||||
GlslangInitializer::InitializationToken token =
|
GlslangInitializer::InitializationToken token =
|
||||||
GlobalTestSettings.initializer->acquire(controls);
|
GlobalTestSettings.initializer->acquire(controls);
|
||||||
return shader->parse(&glslang::DefaultTBuiltInResource, defaultVersion,
|
return shader->parse(
|
||||||
isForwardCompatible, controls);
|
(resources ? resources : &glslang::DefaultTBuiltInResource),
|
||||||
|
defaultVersion, isForwardCompatible, controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiles and links the given source |code| of the given shader
|
// Compiles and links the given source |code| of the given shader
|
||||||
|
Loading…
x
Reference in New Issue
Block a user