2012-12-12 21:15:54 +00:00
|
|
|
//
|
|
|
|
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
2013-02-17 06:01:50 +00:00
|
|
|
//Copyright (C) 2013 LunarG, Inc.
|
|
|
|
//
|
2012-12-12 21:15:54 +00:00
|
|
|
//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 3Dlabs Inc. Ltd. 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.
|
|
|
|
//
|
2013-09-17 19:26:08 +00:00
|
|
|
|
|
|
|
// this only applies to the standalone wrapper, not the front end in general
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
#include "Worklist.h"
|
2012-12-12 21:15:54 +00:00
|
|
|
#include "./../glslang/Include/ShHandle.h"
|
|
|
|
#include "./../glslang/Public/ShaderLang.h"
|
|
|
|
#include <string.h>
|
2013-03-08 23:14:42 +00:00
|
|
|
#include <stdlib.h>
|
2012-12-12 21:15:54 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
#include "osinclude.h"
|
2012-12-12 21:15:54 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
SH_IMPORT_EXPORT void ShOutputHtml();
|
|
|
|
}
|
|
|
|
|
2013-08-31 02:41:30 +00:00
|
|
|
// Command-line options
|
|
|
|
enum TOptions {
|
|
|
|
EOptionNone = 0x000,
|
|
|
|
EOptionIntermediate = 0x001,
|
|
|
|
EOptionSuppressInfolog = 0x002,
|
|
|
|
EOptionMemoryLeakMode = 0x004,
|
|
|
|
EOptionRelaxedErrors = 0x008,
|
|
|
|
EOptionGiveWarnings = 0x010,
|
|
|
|
EOptionsLinkProgram = 0x020,
|
2013-09-06 19:52:57 +00:00
|
|
|
EOptionMultiThreaded = 0x040,
|
2013-09-17 19:26:08 +00:00
|
|
|
EOptionDumpConfig = 0x080,
|
2013-11-07 01:06:34 +00:00
|
|
|
EOptionDumpReflection = 0x100,
|
2013-11-07 17:44:20 +00:00
|
|
|
EOptionSuppressWarnings = 0x200,
|
2013-12-04 04:43:40 +00:00
|
|
|
EOptionDumpVersions = 0x400,
|
2013-08-31 02:41:30 +00:00
|
|
|
};
|
|
|
|
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
|
|
|
// Return codes from main.
|
|
|
|
//
|
|
|
|
enum TFailCode {
|
|
|
|
ESuccess = 0,
|
|
|
|
EFailUsage,
|
|
|
|
EFailCompile,
|
|
|
|
EFailLink,
|
|
|
|
EFailCompilerCreate,
|
2013-07-31 18:44:13 +00:00
|
|
|
EFailThreadCreate,
|
2012-12-12 21:15:54 +00:00
|
|
|
EFailLinkerCreate
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Just placeholders for testing purposes. The stand-alone environment
|
|
|
|
// can't actually do a full link without something specifying real
|
|
|
|
// attribute bindings.
|
|
|
|
//
|
|
|
|
ShBinding FixedAttributeBindings[] = {
|
|
|
|
{ "gl_Vertex", 15 },
|
|
|
|
{ "gl_Color", 10 },
|
|
|
|
{ "gl_Normal", 7 },
|
|
|
|
};
|
|
|
|
|
|
|
|
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
|
|
|
|
|
2013-08-29 00:39:25 +00:00
|
|
|
EShLanguage FindLanguage(const std::string& name);
|
2013-11-07 23:33:24 +00:00
|
|
|
void CompileFile(const char *fileName, ShHandle);
|
2012-12-12 21:15:54 +00:00
|
|
|
void usage();
|
2013-10-28 18:12:06 +00:00
|
|
|
void FreeFileData(char** data);
|
|
|
|
char** ReadFileData(const char* fileName);
|
2013-02-11 22:36:01 +00:00
|
|
|
void InfoLogMsg(const char* msg, const char* name, const int num);
|
2013-06-25 18:10:05 +00:00
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
// Globally track if any compile or link failure.
|
|
|
|
bool CompileFailed = false;
|
|
|
|
bool LinkFailed = false;
|
|
|
|
|
2013-09-17 19:26:08 +00:00
|
|
|
// Use to test breaking up a single shader file into multiple strings.
|
2013-10-28 18:12:06 +00:00
|
|
|
int NumShaderStrings;
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-09-17 19:26:08 +00:00
|
|
|
TBuiltInResource Resources;
|
|
|
|
std::string ConfigFile;
|
|
|
|
|
|
|
|
//
|
|
|
|
// These are the default resources for TBuiltInResources, used for both
|
|
|
|
// - parsing this string for the case where the user didn't supply one
|
|
|
|
// - dumping out a template for user construction of a config file
|
|
|
|
//
|
2013-10-22 01:50:39 +00:00
|
|
|
const char* DefaultConfig =
|
|
|
|
"MaxLights 32\n"
|
|
|
|
"MaxClipPlanes 6\n"
|
|
|
|
"MaxTextureUnits 32\n"
|
|
|
|
"MaxTextureCoords 32\n"
|
|
|
|
"MaxVertexAttribs 64\n"
|
|
|
|
"MaxVertexUniformComponents 4096\n"
|
|
|
|
"MaxVaryingFloats 64\n"
|
|
|
|
"MaxVertexTextureImageUnits 32\n"
|
|
|
|
"MaxCombinedTextureImageUnits 32\n"
|
|
|
|
"MaxTextureImageUnits 32\n"
|
|
|
|
"MaxFragmentUniformComponents 4096\n"
|
|
|
|
"MaxDrawBuffers 32\n"
|
|
|
|
"MaxVertexUniformVectors 128\n"
|
|
|
|
"MaxVaryingVectors 8\n"
|
|
|
|
"MaxFragmentUniformVectors 16\n"
|
|
|
|
"MaxVertexOutputVectors 16\n"
|
|
|
|
"MaxFragmentInputVectors 15\n"
|
|
|
|
"MinProgramTexelOffset -8\n"
|
|
|
|
"MaxProgramTexelOffset 7\n"
|
|
|
|
"MaxClipDistances 8\n"
|
|
|
|
"MaxComputeWorkGroupCountX 65535\n"
|
|
|
|
"MaxComputeWorkGroupCountY 65535\n"
|
|
|
|
"MaxComputeWorkGroupCountZ 65535\n"
|
|
|
|
"MaxComputeWorkGroupSizeX 1024\n"
|
|
|
|
"MaxComputeWorkGroupSizeX 1024\n"
|
|
|
|
"MaxComputeWorkGroupSizeZ 64\n"
|
|
|
|
"MaxComputeUniformComponents 1024\n"
|
|
|
|
"MaxComputeTextureImageUnits 16\n"
|
|
|
|
"MaxComputeImageUniforms 8\n"
|
|
|
|
"MaxComputeAtomicCounters 8\n"
|
|
|
|
"MaxComputeAtomicCounterBuffers 1\n"
|
|
|
|
"MaxVaryingComponents 60\n"
|
|
|
|
"MaxVertexOutputComponents 64\n"
|
|
|
|
"MaxGeometryInputComponents 64\n"
|
|
|
|
"MaxGeometryOutputComponents 128\n"
|
|
|
|
"MaxFragmentInputComponents 128\n"
|
|
|
|
"MaxImageUnits 8\n"
|
|
|
|
"MaxCombinedImageUnitsAndFragmentOutputs 8\n"
|
|
|
|
"MaxImageSamples 0\n"
|
|
|
|
"MaxVertexImageUniforms 0\n"
|
|
|
|
"MaxTessControlImageUniforms 0\n"
|
|
|
|
"MaxTessEvaluationImageUniforms 0\n"
|
|
|
|
"MaxGeometryImageUniforms 0\n"
|
|
|
|
"MaxFragmentImageUniforms 8\n"
|
|
|
|
"MaxCombinedImageUniforms 8\n"
|
|
|
|
"MaxGeometryTextureImageUnits 16\n"
|
|
|
|
"MaxGeometryOutputVertices 256\n"
|
|
|
|
"MaxGeometryTotalOutputComponents 1024\n"
|
|
|
|
"MaxGeometryUniformComponents 1024\n"
|
|
|
|
"MaxGeometryVaryingComponents 64\n"
|
|
|
|
"MaxTessControlInputComponents 128\n"
|
|
|
|
"MaxTessControlOutputComponents 128\n"
|
|
|
|
"MaxTessControlTextureImageUnits 16\n"
|
|
|
|
"MaxTessControlUniformComponents 1024\n"
|
|
|
|
"MaxTessControlTotalOutputComponents 4096\n"
|
|
|
|
"MaxTessEvaluationInputComponents 128\n"
|
|
|
|
"MaxTessEvaluationOutputComponents 128\n"
|
|
|
|
"MaxTessEvaluationTextureImageUnits 16\n"
|
|
|
|
"MaxTessEvaluationUniformComponents 1024\n"
|
|
|
|
"MaxTessPatchComponents 120\n"
|
|
|
|
"MaxPatchVertices 32\n"
|
|
|
|
"MaxTessGenLevel 64\n"
|
|
|
|
"MaxViewports 16\n"
|
|
|
|
"MaxVertexAtomicCounters 0\n"
|
|
|
|
"MaxTessControlAtomicCounters 0\n"
|
|
|
|
"MaxTessEvaluationAtomicCounters 0\n"
|
|
|
|
"MaxGeometryAtomicCounters 0\n"
|
|
|
|
"MaxFragmentAtomicCounters 8\n"
|
|
|
|
"MaxCombinedAtomicCounters 8\n"
|
|
|
|
"MaxAtomicCounterBindings 1\n"
|
|
|
|
"MaxVertexAtomicCounterBuffers 0\n"
|
|
|
|
"MaxTessControlAtomicCounterBuffers 0\n"
|
|
|
|
"MaxTessEvaluationAtomicCounterBuffers 0\n"
|
|
|
|
"MaxGeometryAtomicCounterBuffers 0\n"
|
|
|
|
"MaxFragmentAtomicCounterBuffers 1\n"
|
|
|
|
"MaxCombinedAtomicCounterBuffers 1\n"
|
|
|
|
"MaxAtomicCounterBufferSize 16384\n"
|
|
|
|
|
|
|
|
"nonInductiveForLoops 1\n"
|
|
|
|
"whileLoops 1\n"
|
|
|
|
"doWhileLoops 1\n"
|
|
|
|
"generalUniformIndexing 1\n"
|
|
|
|
"generalAttributeMatrixVectorIndexing 1\n"
|
|
|
|
"generalVaryingIndexing 1\n"
|
|
|
|
"generalSamplerIndexing 1\n"
|
|
|
|
"generalVariableIndexing 1\n"
|
|
|
|
"generalConstantMatrixVectorIndexing 1\n"
|
|
|
|
;
|
2013-09-17 19:26:08 +00:00
|
|
|
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
2013-09-17 19:26:08 +00:00
|
|
|
// Parse either a .conf file provided by the user or the default string above.
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
2013-09-17 19:26:08 +00:00
|
|
|
void ProcessConfigFile()
|
2013-04-11 16:31:09 +00:00
|
|
|
{
|
2013-09-17 19:26:08 +00:00
|
|
|
char** configStrings = 0;
|
|
|
|
char *config = 0;
|
|
|
|
if (ConfigFile.size() > 0) {
|
2013-10-28 18:12:06 +00:00
|
|
|
configStrings = ReadFileData(ConfigFile.c_str());
|
2013-09-17 19:26:08 +00:00
|
|
|
if (configStrings)
|
|
|
|
config = *configStrings;
|
|
|
|
else {
|
|
|
|
printf("Error opening configuration file; will instead use the default configuration\n");
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config == 0) {
|
|
|
|
config = new char[strlen(DefaultConfig)];
|
|
|
|
strcpy(config, DefaultConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2013-10-16 22:28:35 +00:00
|
|
|
else if (strcmp(token, "MaxClipDistances") == 0)
|
|
|
|
Resources.maxClipDistances = value;
|
2013-10-22 01:50:39 +00:00
|
|
|
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, "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;
|
|
|
|
|
2013-10-02 05:10:48 +00:00
|
|
|
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);
|
2013-09-17 19:26:08 +00:00
|
|
|
else
|
|
|
|
printf("Warning: unrecognized limit (%s) in configuration file.\n", token);
|
|
|
|
|
|
|
|
token = strtok(0, delims);
|
|
|
|
}
|
|
|
|
if (configStrings)
|
|
|
|
FreeFileData(configStrings);
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 19:52:57 +00:00
|
|
|
// thread-safe list of shaders to asynchronously grab and compile
|
2013-07-31 18:44:13 +00:00
|
|
|
glslang::TWorklist Worklist;
|
2013-09-06 19:52:57 +00:00
|
|
|
|
|
|
|
// array of unique places to leave the shader names and infologs for the asynchronous compiles
|
|
|
|
glslang::TWorkItem **Work = 0;
|
|
|
|
int NumWorkItems = 0;
|
|
|
|
|
2013-08-31 02:41:30 +00:00
|
|
|
int Options = 0;
|
2013-07-31 18:44:13 +00:00
|
|
|
bool Delay = false;
|
2013-09-06 19:52:57 +00:00
|
|
|
const char* ExecutableName;
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-09-17 19:26:08 +00:00
|
|
|
//
|
|
|
|
// *.conf => this is a config file that can set limits/resources
|
|
|
|
//
|
|
|
|
bool SetConfigFile(const std::string& name)
|
|
|
|
{
|
|
|
|
if (name.size() < 5)
|
|
|
|
return false;
|
|
|
|
|
2013-10-11 16:28:43 +00:00
|
|
|
if (name.compare(name.size() - 5, 5, ".conf") == 0) {
|
2013-09-17 19:26:08 +00:00
|
|
|
ConfigFile = name;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
bool ProcessArguments(int argc, char* argv[])
|
|
|
|
{
|
2013-09-06 19:52:57 +00:00
|
|
|
ExecutableName = argv[0];
|
|
|
|
NumWorkItems = argc; // will include some empties where the '-' options were, but it doesn't matter, they'll be 0
|
|
|
|
Work = new glslang::TWorkItem*[NumWorkItems];
|
|
|
|
Work[0] = 0;
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
for (; argc >= 1; argc--, argv++) {
|
2013-09-17 19:26:08 +00:00
|
|
|
Work[argc] = 0;
|
2013-07-31 18:44:13 +00:00
|
|
|
if (argv[0][0] == '-') {
|
|
|
|
switch (argv[0][1]) {
|
2013-09-17 19:26:08 +00:00
|
|
|
case 'c':
|
|
|
|
Options |= EOptionDumpConfig;
|
|
|
|
break;
|
2013-07-31 18:44:13 +00:00
|
|
|
case 'd':
|
|
|
|
Delay = true;
|
|
|
|
break;
|
2013-09-17 19:26:08 +00:00
|
|
|
case 'i':
|
2013-08-31 02:41:30 +00:00
|
|
|
Options |= EOptionIntermediate;
|
2013-07-31 18:44:13 +00:00
|
|
|
break;
|
|
|
|
case 'l':
|
2013-08-31 02:41:30 +00:00
|
|
|
Options |= EOptionsLinkProgram;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
Options |= EOptionMemoryLeakMode;
|
2013-07-31 18:44:13 +00:00
|
|
|
break;
|
2013-11-07 01:06:34 +00:00
|
|
|
case 'q':
|
|
|
|
Options |= EOptionDumpReflection;
|
|
|
|
break;
|
2013-07-31 18:44:13 +00:00
|
|
|
case 'r':
|
2013-08-31 02:41:30 +00:00
|
|
|
Options |= EOptionRelaxedErrors;
|
2013-07-31 18:44:13 +00:00
|
|
|
break;
|
|
|
|
case 's':
|
2013-08-31 02:41:30 +00:00
|
|
|
Options |= EOptionSuppressInfolog;
|
2013-07-31 18:44:13 +00:00
|
|
|
break;
|
2013-09-06 19:52:57 +00:00
|
|
|
case 't':
|
|
|
|
#ifdef _WIN32
|
2013-11-07 17:44:20 +00:00
|
|
|
Options |= EOptionMultiThreaded;
|
2013-09-06 19:52:57 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2013-12-04 04:43:40 +00:00
|
|
|
case 'v':
|
|
|
|
Options |= EOptionDumpVersions;
|
|
|
|
break;
|
2013-11-07 17:44:20 +00:00
|
|
|
case 'w':
|
|
|
|
Options |= EOptionSuppressWarnings;
|
|
|
|
break;
|
2013-07-31 18:44:13 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
2013-09-06 19:52:57 +00:00
|
|
|
} else {
|
2013-09-17 19:26:08 +00:00
|
|
|
std::string name(argv[0]);
|
|
|
|
if (! SetConfigFile(name)) {
|
|
|
|
Work[argc] = new glslang::TWorkItem(name);
|
|
|
|
Worklist.add(Work[argc]);
|
|
|
|
}
|
2013-09-06 19:52:57 +00:00
|
|
|
}
|
2013-07-31 18:44:13 +00:00
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-11-07 17:44:20 +00:00
|
|
|
void SetMessageOptions(EShMessages& messages)
|
|
|
|
{
|
|
|
|
if (Options & EOptionRelaxedErrors)
|
|
|
|
messages = (EShMessages)(messages | EShMsgRelaxedErrors);
|
|
|
|
if (Options & EOptionIntermediate)
|
|
|
|
messages = (EShMessages)(messages | EShMsgAST);
|
|
|
|
if (Options & EOptionSuppressWarnings)
|
|
|
|
messages = (EShMessages)(messages | EShMsgSuppressWarnings);
|
|
|
|
}
|
|
|
|
|
2013-09-04 21:19:27 +00:00
|
|
|
// Thread entry point, for non-linking asynchronous mode.
|
2013-11-07 23:33:24 +00:00
|
|
|
//
|
|
|
|
// Return 0 for failure, 1 for success.
|
|
|
|
//
|
2013-07-31 23:19:17 +00:00
|
|
|
unsigned int
|
|
|
|
#ifdef _WIN32
|
|
|
|
__stdcall
|
|
|
|
#endif
|
2013-08-31 02:41:30 +00:00
|
|
|
CompileShaders(void*)
|
2013-07-31 18:44:13 +00:00
|
|
|
{
|
2013-09-06 19:52:57 +00:00
|
|
|
glslang::TWorkItem* workItem;
|
|
|
|
while (Worklist.remove(workItem)) {
|
|
|
|
ShHandle compiler = ShConstructCompiler(FindLanguage(workItem->name), Options);
|
2013-07-31 18:44:13 +00:00
|
|
|
if (compiler == 0)
|
2013-11-07 23:33:24 +00:00
|
|
|
return 0;
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-11-07 17:44:20 +00:00
|
|
|
CompileFile(workItem->name.c_str(), compiler);
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-08-31 02:41:30 +00:00
|
|
|
if (! (Options & EOptionSuppressInfolog))
|
2013-09-06 19:52:57 +00:00
|
|
|
workItem->results = ShGetInfoLog(compiler);
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
ShDestruct(compiler);
|
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-09-04 21:19:27 +00:00
|
|
|
//
|
|
|
|
// For linking mode: Will independently parse each item in the worklist, but then put them
|
|
|
|
// in the same program and link them together.
|
|
|
|
//
|
|
|
|
// Uses the new C++ interface instead of the old handle-based interface.
|
|
|
|
//
|
|
|
|
void CompileAndLinkShaders()
|
|
|
|
{
|
|
|
|
// keep track of what to free
|
|
|
|
std::list<glslang::TShader*> shaders;
|
2013-11-14 00:16:43 +00:00
|
|
|
|
2013-09-04 21:19:27 +00:00
|
|
|
EShMessages messages = EShMsgDefault;
|
2013-11-07 17:44:20 +00:00
|
|
|
SetMessageOptions(messages);
|
2013-09-04 21:19:27 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Per-shader processing...
|
|
|
|
//
|
|
|
|
|
2013-11-01 03:08:40 +00:00
|
|
|
glslang::TProgram& program = *new glslang::TProgram;
|
2013-09-06 19:52:57 +00:00
|
|
|
glslang::TWorkItem* workItem;
|
|
|
|
while (Worklist.remove(workItem)) {
|
|
|
|
EShLanguage stage = FindLanguage(workItem->name);
|
2013-09-04 21:19:27 +00:00
|
|
|
glslang::TShader* shader = new glslang::TShader(stage);
|
|
|
|
shaders.push_back(shader);
|
|
|
|
|
2013-09-06 19:52:57 +00:00
|
|
|
char** shaderStrings = ReadFileData(workItem->name.c_str());
|
2013-09-04 21:19:27 +00:00
|
|
|
if (! shaderStrings) {
|
|
|
|
usage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shader->setStrings(shaderStrings, 1);
|
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
if (! shader->parse(&Resources, 100, false, messages))
|
|
|
|
CompileFailed = true;
|
2013-09-04 21:19:27 +00:00
|
|
|
|
|
|
|
program.addShader(shader);
|
|
|
|
|
|
|
|
if (! (Options & EOptionSuppressInfolog)) {
|
2013-09-06 19:52:57 +00:00
|
|
|
puts(workItem->name.c_str());
|
2013-09-04 21:19:27 +00:00
|
|
|
puts(shader->getInfoLog());
|
|
|
|
puts(shader->getInfoDebugLog());
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeFileData(shaderStrings);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Program-level processing...
|
|
|
|
//
|
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
if (! program.link(messages))
|
|
|
|
LinkFailed = true;
|
|
|
|
|
2013-09-04 21:19:27 +00:00
|
|
|
if (! (Options & EOptionSuppressInfolog)) {
|
|
|
|
puts(program.getInfoLog());
|
|
|
|
puts(program.getInfoDebugLog());
|
|
|
|
}
|
|
|
|
|
2013-11-07 01:06:34 +00:00
|
|
|
if (Options & EOptionDumpReflection) {
|
|
|
|
program.buildReflection();
|
|
|
|
program.dumpReflection();
|
|
|
|
}
|
|
|
|
|
2013-11-01 03:08:40 +00:00
|
|
|
// Free everything up, program has to go before the shaders
|
|
|
|
// because it might have merged stuff from the shaders, and
|
|
|
|
// the stuff from the shaders has to have its destructors called
|
|
|
|
// before the pools holding the memory in the shaders is freed.
|
|
|
|
delete &program;
|
2013-09-04 21:19:27 +00:00
|
|
|
while (shaders.size() > 0) {
|
|
|
|
delete shaders.back();
|
|
|
|
shaders.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
int C_DECL main(int argc, char* argv[])
|
|
|
|
{
|
2013-08-03 00:04:10 +00:00
|
|
|
if (! ProcessArguments(argc, argv)) {
|
|
|
|
usage();
|
2013-07-31 18:44:13 +00:00
|
|
|
return EFailUsage;
|
2013-08-03 00:04:10 +00:00
|
|
|
}
|
2013-07-31 18:44:13 +00:00
|
|
|
|
2013-09-17 19:26:08 +00:00
|
|
|
if (Options & EOptionDumpConfig) {
|
|
|
|
printf("%s", DefaultConfig);
|
|
|
|
if (Worklist.empty())
|
|
|
|
return ESuccess;
|
|
|
|
}
|
|
|
|
|
2013-12-04 04:43:40 +00:00
|
|
|
if (Options & EOptionDumpVersions) {
|
|
|
|
printf("ESSL Version: %s\n", glslang::GetEsslVersionString());
|
|
|
|
printf("GLSL Version: %s\n", glslang::GetGlslVersionString());
|
|
|
|
if (Worklist.empty())
|
|
|
|
return ESuccess;
|
|
|
|
}
|
|
|
|
|
2013-09-17 19:26:08 +00:00
|
|
|
if (Worklist.empty()) {
|
|
|
|
usage();
|
|
|
|
return EFailUsage;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessConfigFile();
|
|
|
|
|
2013-09-04 21:19:27 +00:00
|
|
|
//
|
|
|
|
// Two modes:
|
2013-09-06 19:52:57 +00:00
|
|
|
// 1) linking all arguments together, single-threaded, new C++ interface
|
|
|
|
// 2) independent arguments, can be tackled by multiple asynchronous threads, for testing thread safety, using the old handle interface
|
2013-09-04 21:19:27 +00:00
|
|
|
//
|
2013-11-01 17:41:52 +00:00
|
|
|
if (Options & EOptionsLinkProgram) {
|
|
|
|
glslang::InitializeProcess();
|
2013-09-06 19:52:57 +00:00
|
|
|
CompileAndLinkShaders();
|
2013-11-01 17:41:52 +00:00
|
|
|
glslang::FinalizeProcess();
|
|
|
|
} else {
|
|
|
|
ShInitialize();
|
|
|
|
|
2013-09-06 19:52:57 +00:00
|
|
|
bool printShaderNames = Worklist.size() > 1;
|
|
|
|
|
|
|
|
if (Options & EOptionMultiThreaded) {
|
|
|
|
const int NumThreads = 16;
|
|
|
|
void* threads[NumThreads];
|
|
|
|
for (int t = 0; t < NumThreads; ++t) {
|
|
|
|
threads[t] = glslang::OS_CreateThread(&CompileShaders);
|
|
|
|
if (! threads[t]) {
|
|
|
|
printf("Failed to create thread\n");
|
|
|
|
return EFailThreadCreate;
|
|
|
|
}
|
2013-07-31 18:44:13 +00:00
|
|
|
}
|
2013-09-06 19:52:57 +00:00
|
|
|
glslang::OS_WaitForAllThreads(threads, NumThreads);
|
2013-11-07 23:33:24 +00:00
|
|
|
} else
|
|
|
|
CompileShaders(0);
|
2013-09-06 19:52:57 +00:00
|
|
|
|
|
|
|
// Print out all the resulting infologs
|
|
|
|
for (int w = 0; w < NumWorkItems; ++w) {
|
|
|
|
if (Work[w]) {
|
|
|
|
if (printShaderNames)
|
|
|
|
puts(Work[w]->name.c_str());
|
|
|
|
puts(Work[w]->results.c_str());
|
|
|
|
delete Work[w];
|
|
|
|
}
|
|
|
|
}
|
2013-11-01 17:41:52 +00:00
|
|
|
|
|
|
|
ShFinalize();
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
2013-07-31 18:44:13 +00:00
|
|
|
|
|
|
|
if (Delay)
|
|
|
|
glslang::OS_Sleep(1000000);
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
if (CompileFailed)
|
2012-12-12 21:15:54 +00:00
|
|
|
return EFailCompile;
|
2013-11-07 23:33:24 +00:00
|
|
|
if (LinkFailed)
|
2012-12-12 21:15:54 +00:00
|
|
|
return EFailLink;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Deduce the language from the filename. Files must end in one of the
|
|
|
|
// following extensions:
|
|
|
|
//
|
2013-07-31 18:44:13 +00:00
|
|
|
// .vert = vertex
|
|
|
|
// .tesc = tessellation control
|
|
|
|
// .tese = tessellation evaluation
|
|
|
|
// .geom = geometry
|
|
|
|
// .frag = fragment
|
2013-08-31 02:41:30 +00:00
|
|
|
// .comp = compute
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
2013-08-29 00:39:25 +00:00
|
|
|
EShLanguage FindLanguage(const std::string& name)
|
2012-12-12 21:15:54 +00:00
|
|
|
{
|
2013-07-31 18:44:13 +00:00
|
|
|
size_t ext = name.rfind('.');
|
|
|
|
if (ext == std::string::npos) {
|
|
|
|
usage();
|
2012-12-12 21:34:14 +00:00
|
|
|
return EShLangVertex;
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 18:44:13 +00:00
|
|
|
std::string suffix = name.substr(ext + 1, std::string::npos);
|
|
|
|
if (suffix == "vert")
|
|
|
|
return EShLangVertex;
|
|
|
|
else if (suffix == "tesc")
|
|
|
|
return EShLangTessControl;
|
|
|
|
else if (suffix == "tese")
|
|
|
|
return EShLangTessEvaluation;
|
|
|
|
else if (suffix == "geom")
|
|
|
|
return EShLangGeometry;
|
|
|
|
else if (suffix == "frag")
|
|
|
|
return EShLangFragment;
|
Put in infrastructure for tessellation, geometry, and compute stages, and partially flesh out with built-in functions.
Added the built-in functions EmitVertex(), EndPrimitive(), barrier(), memoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), memoryBarrierImage(), memoryBarrierShared(), and groupMemoryBarrier().
Have not added any new built-in variables.
Also changed the linear performance relateToOperator() to a high-performance version.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22659 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2013-08-09 17:14:49 +00:00
|
|
|
else if (suffix == "comp")
|
|
|
|
return EShLangCompute;
|
2013-07-31 18:44:13 +00:00
|
|
|
|
|
|
|
usage();
|
2012-12-12 21:34:14 +00:00
|
|
|
return EShLangVertex;
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-09-04 21:19:27 +00:00
|
|
|
// Read a file's data into a string, and compile it using the old interface ShCompile,
|
|
|
|
// for non-linkable results.
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
2013-11-07 23:33:24 +00:00
|
|
|
void CompileFile(const char *fileName, ShHandle compiler)
|
2012-12-12 21:15:54 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2013-06-25 18:10:05 +00:00
|
|
|
char** shaderStrings = ReadFileData(fileName);
|
2013-06-26 22:42:55 +00:00
|
|
|
if (! shaderStrings) {
|
|
|
|
usage();
|
2013-11-07 23:33:24 +00:00
|
|
|
CompileFailed = true;
|
|
|
|
return;
|
2013-06-26 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 18:10:05 +00:00
|
|
|
int* lengths = new int[NumShaderStrings];
|
|
|
|
|
|
|
|
// move to length-based strings, rather than null-terminated strings
|
|
|
|
for (int s = 0; s < NumShaderStrings; ++s)
|
|
|
|
lengths[s] = strlen(shaderStrings[s]);
|
2013-04-17 19:34:23 +00:00
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
if (! shaderStrings) {
|
|
|
|
CompileFailed = true;
|
|
|
|
return;
|
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-05-05 23:46:22 +00:00
|
|
|
EShMessages messages = EShMsgDefault;
|
2013-11-07 17:44:20 +00:00
|
|
|
SetMessageOptions(messages);
|
2013-09-04 21:19:27 +00:00
|
|
|
|
2013-08-31 02:41:30 +00:00
|
|
|
for (int i = 0; i < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++i) {
|
|
|
|
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j) {
|
2013-09-17 19:26:08 +00:00
|
|
|
//ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, &Resources, Options, 100, false, messages);
|
|
|
|
ret = ShCompile(compiler, shaderStrings, NumShaderStrings, 0, EShOptNone, &Resources, Options, 100, false, messages);
|
2013-10-28 18:12:06 +00:00
|
|
|
//const char* multi[12] = { "# ve", "rsion", " 300 e", "s", "\n#err",
|
|
|
|
// "or should be l", "ine 1", "string 5\n", "float glo", "bal",
|
|
|
|
// ";\n#error should be line 2\n void main() {", "global = 2.3;}" };
|
2013-06-25 18:10:05 +00:00
|
|
|
//const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
|
2013-10-28 18:12:06 +00:00
|
|
|
//ret = ShCompile(compiler, multi, 7, 0, EShOptNone, &Resources, Options, 100, false, messages);
|
2013-06-25 18:10:05 +00:00
|
|
|
}
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-08-31 02:41:30 +00:00
|
|
|
if (Options & EOptionMemoryLeakMode)
|
2013-07-31 18:44:13 +00:00
|
|
|
glslang::OS_DumpMemoryCounters();
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 18:10:05 +00:00
|
|
|
delete [] lengths;
|
|
|
|
FreeFileData(shaderStrings);
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-11-07 23:33:24 +00:00
|
|
|
if (ret == 0)
|
|
|
|
CompileFailed = true;
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// print usage to stdout
|
|
|
|
//
|
|
|
|
void usage()
|
|
|
|
{
|
2013-12-04 04:43:40 +00:00
|
|
|
printf("Usage: glslangValidator [option]... [file]...\n"
|
|
|
|
"\n"
|
|
|
|
"Where: each 'file' ends in\n"
|
|
|
|
" .conf to provide an optional config file that replaces the default configuration\n"
|
2013-09-17 19:26:08 +00:00
|
|
|
" (see -c option below for generating a template)\n"
|
Put in infrastructure for tessellation, geometry, and compute stages, and partially flesh out with built-in functions.
Added the built-in functions EmitVertex(), EndPrimitive(), barrier(), memoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), memoryBarrierImage(), memoryBarrierShared(), and groupMemoryBarrier().
Have not added any new built-in variables.
Also changed the linear performance relateToOperator() to a high-performance version.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22659 e7fa87d3-cd2b-0410-9028-fcbf551c1848
2013-08-09 17:14:49 +00:00
|
|
|
" .vert for a vertex shader\n"
|
|
|
|
" .tesc for a tessellation control shader\n"
|
|
|
|
" .tese for a tessellation evaluation shader\n"
|
|
|
|
" .geom for a geometry shader\n"
|
|
|
|
" .frag for a fragment shader\n"
|
2013-12-04 04:43:40 +00:00
|
|
|
" .comp for a compute shader\n"
|
|
|
|
"\n"
|
2013-08-05 15:52:03 +00:00
|
|
|
"Compilation warnings and errors will be printed to stdout.\n"
|
2013-12-04 04:43:40 +00:00
|
|
|
"\n"
|
2013-08-05 15:52:03 +00:00
|
|
|
"To get other information, use one of the following options:\n"
|
2013-12-04 04:43:40 +00:00
|
|
|
"(Each option must be specified separately, but can go anywhere in the command line.)\n"
|
|
|
|
" -c configuration dump; use to create default configuration file (redirect to a .conf file)\n"
|
|
|
|
" -i intermediate tree (glslang AST) is printed out\n"
|
|
|
|
" -l link validation of all input files\n"
|
|
|
|
" -m memory leak mode\n"
|
|
|
|
" -q dump reflection query database\n"
|
|
|
|
" -r relaxed semantic error-checking mode\n"
|
|
|
|
" -s silent mode\n"
|
|
|
|
" -t multi-threaded mode\n"
|
|
|
|
" -v print version strings\n"
|
|
|
|
" -w suppress warnings (except as required by #extension : warn)\n"
|
2013-11-07 17:44:20 +00:00
|
|
|
);
|
2012-12-12 21:15:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-08 23:14:42 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
int fopen_s(
|
|
|
|
FILE** pFile,
|
|
|
|
const char *filename,
|
|
|
|
const char *mode
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (!pFile || !filename || !mode) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE* f = fopen(filename, mode);
|
|
|
|
if (! f) {
|
|
|
|
if (errno != 0) {
|
|
|
|
return errno;
|
|
|
|
} else {
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*pFile = f;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-12-12 21:15:54 +00:00
|
|
|
//
|
|
|
|
// Malloc a string of sufficient size and read a string into it.
|
|
|
|
//
|
2013-02-11 22:36:01 +00:00
|
|
|
char** ReadFileData(const char *fileName)
|
2012-12-12 21:15:54 +00:00
|
|
|
{
|
2012-12-12 21:21:23 +00:00
|
|
|
FILE *in;
|
|
|
|
int errorCode = fopen_s(&in, fileName, "r");
|
2012-12-12 21:15:54 +00:00
|
|
|
char *fdata;
|
|
|
|
int count = 0;
|
2013-03-08 23:14:42 +00:00
|
|
|
const int maxSourceStrings = 5;
|
|
|
|
char** return_data = (char**)malloc(maxSourceStrings+1);
|
2012-12-12 21:15:54 +00:00
|
|
|
|
|
|
|
//return_data[MAX_SOURCE_STRINGS]=NULL;
|
2012-12-12 21:21:23 +00:00
|
|
|
if (errorCode) {
|
2012-12-12 21:15:54 +00:00
|
|
|
printf("Error: unable to open input file: %s\n", fileName);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgetc(in) != EOF)
|
|
|
|
count++;
|
|
|
|
|
|
|
|
fseek(in, 0, SEEK_SET);
|
|
|
|
|
|
|
|
|
|
|
|
if (!(fdata = (char *)malloc(count+2))) {
|
|
|
|
printf("Error allocating memory\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (fread(fdata,1,count, in)!=count) {
|
|
|
|
printf("Error reading input file: %s\n", fileName);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fdata[count] = '\0';
|
|
|
|
fclose(in);
|
2013-10-28 18:12:06 +00:00
|
|
|
if (count == 0) {
|
2012-12-12 21:15:54 +00:00
|
|
|
return_data[0]=(char*)malloc(count+2);
|
|
|
|
return_data[0][0]='\0';
|
2013-10-28 18:12:06 +00:00
|
|
|
NumShaderStrings = 0;
|
2012-12-12 21:15:54 +00:00
|
|
|
return return_data;
|
2013-10-28 18:12:06 +00:00
|
|
|
} else
|
|
|
|
NumShaderStrings = 1;
|
2012-12-12 21:15:54 +00:00
|
|
|
|
2013-06-25 18:10:05 +00:00
|
|
|
int len = (int)(ceil)((float)count/(float)NumShaderStrings);
|
2012-12-12 21:15:54 +00:00
|
|
|
int ptr_len=0,i=0;
|
|
|
|
while(count>0){
|
|
|
|
return_data[i]=(char*)malloc(len+2);
|
|
|
|
memcpy(return_data[i],fdata+ptr_len,len);
|
|
|
|
return_data[i][len]='\0';
|
|
|
|
count-=(len);
|
|
|
|
ptr_len+=(len);
|
|
|
|
if(count<len){
|
|
|
|
if(count==0){
|
2013-06-25 18:10:05 +00:00
|
|
|
NumShaderStrings=(i+1);
|
2012-12-12 21:15:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
len = count;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
return return_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeFileData(char **data)
|
|
|
|
{
|
2013-06-25 18:10:05 +00:00
|
|
|
for(int i=0;i<NumShaderStrings;i++)
|
2012-12-12 21:15:54 +00:00
|
|
|
free(data[i]);
|
|
|
|
}
|
|
|
|
|
2013-02-11 22:36:01 +00:00
|
|
|
void InfoLogMsg(const char* msg, const char* name, const int num)
|
2012-12-12 21:15:54 +00:00
|
|
|
{
|
|
|
|
printf(num >= 0 ? "#### %s %s %d INFO LOG ####\n" :
|
|
|
|
"#### %s %s INFO LOG ####\n", msg, name, num);
|
|
|
|
}
|