//POSSIBILITY OF SUCH DAMAGE.
//
-#include "Include/InfoSink.h"
+#include "../Include/InfoSink.h"
#include <string.h>
prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u";
-
+
postfixes[2] = "2";
postfixes[3] = "3";
postfixes[4] = "4";
s.append("bvec4 isinf(vec4 x);");
}
- if (profile == EEsProfile && version >= 300 ||
- profile != EEsProfile && version >= 330) {
+ if ((profile == EEsProfile && version >= 300) ||
+ (profile != EEsProfile && version >= 330)) {
s.append("int floatBitsToInt(float value);");
s.append("ivec2 floatBitsToInt(vec2 value);");
s.append("ivec3 floatBitsToInt(vec3 value);");
s.append("vec4 uintBitsToFloat(uvec4 value);");
}
- if (profile == EEsProfile && version >= 300 ||
- profile != EEsProfile && version >= 400) {
+ if ((profile == EEsProfile && version >= 300) ||
+ (profile != EEsProfile && version >= 400)) {
s.append( "highp uint packSnorm2x16 (vec2);");
s.append( "highp vec2 unpackSnorm2x16 (highp uint);");
s.append( "highp uint packUnorm2x16 (vec2);");
s.append("float determinant(mat2 m);");
s.append("float determinant(mat3 m);");
s.append("float determinant(mat4 m);");
-
+
s.append("mat2 inverse(mat2 m);");
s.append("mat3 inverse(mat3 m);");
s.append("mat4 inverse(mat4 m);");
// Original-style texture functions existing in both stages.
// (Per-stage functions below.)
//
- if (profile == EEsProfile && version == 100 ||
- profile == ECompatibilityProfile || version < FirstProfileVersion) {
+ if ((profile == EEsProfile && version == 100) ||
+ profile == ECompatibilityProfile ||
+ version < FirstProfileVersion) {
s.append("vec4 texture2D(sampler2D, vec2);");
s.append("vec4 texture2DProj(sampler2D, vec3);");
s.append("vec4 textureCube(samplerCube, vec3);");
}
- if (profile != EEsProfile &&
+ if (profile != EEsProfile &&
(profile == ECompatibilityProfile || version < FirstProfileVersion)) {
s.append("vec4 texture1D(sampler1D, float);");
-
+
s.append("vec4 texture1DProj(sampler1D, vec2);");
s.append("vec4 texture1DProj(sampler1D, vec4);");
-
+
s.append("vec4 texture3D(sampler3D, vec3);");
s.append("vec4 texture3DProj(sampler3D, vec4);");
// enumerate all the types
for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler
-
+
if (image > 0 && version < 420)
continue;
//
// Now, make all the function prototypes for the type we just built...
- //
+ //
TSampler sampler;
- sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
- shadow ? true : false,
+ sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
+ shadow ? true : false,
ms ? true : false);
if (image)
sampler.image = true;
TString typeName = sampler.getString();
addQueryFunctions(sampler, typeName, version, profile);
-
+
if (image)
addImageFunctions(sampler, typeName, version, profile);
- else
+ else
addSamplingFunctions(sampler, typeName, version, profile);
}
}
continue;
if (extraProj && (sampler.dim == Esd3D || sampler.shadow))
continue;
-
+
TString s;
// return type
else {
s.append(",");
TBasicType t = fetch ? EbtInt : EbtFloat;
- if (totalDims == 1)
+ if (totalDims == 1)
s.append(TType::getBasicString(t));
else {
s.append(prefixes[t]);
s.append("vec");
s.append(postfixes[totalDims]);
}
- }
+ }
if (bias && compare)
continue;
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
s.append(builtInConstant);
}
case EShLangCompute:
// TODO: desktop functionality: support new stages
break;
-
+
default:
assert(false && "Language not supported");
break;
symbolTable.relateToOperator("outerProduct", EOpOuterProduct);
symbolTable.relateToOperator("transpose", EOpTranspose);
if (version >= 150) {
- symbolTable.relateToOperator("determinant", EOpDeterminant);
+ symbolTable.relateToOperator("determinant", EOpDeterminant);
symbolTable.relateToOperator("inverse", EOpMatrixInverse);
}
}
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
break;
- default:
+ default:
assert(false && "Language not supported");
}
}
#ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_
-#include "Include/ResourceLimits.h"
+#include "../Include/ResourceLimits.h"
#include "../Include/Common.h"
#include "../Include/ShHandle.h"
#include "SymbolTable.h"
{
TIntermAggregate* aggNode = growAggregate(left, right);
if (aggNode)
- aggNode->setLoc(loc);
+ aggNode->setLoc(loc);
return aggNode;
}
numErrors += unit.numErrors;
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
- if (profile != EEsProfile && unit.profile == EEsProfile ||
- profile == EEsProfile && unit.profile != EEsProfile)
+ if ((profile != EEsProfile && unit.profile == EEsProfile) ||
+ (profile == EEsProfile && unit.profile != EEsProfile))
error(infoSink, "Cannot mix ES profile with non-ES profile shaders\n");
if (unit.treeRoot == 0)
void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects)
{
// Error check and merge the linker objects (duplicates should not be merged)
- unsigned int initialNumLinkerObjects = linkerObjects.size();
+ std::size_t initialNumLinkerObjects = linkerObjects.size();
for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) {
bool merge = true;
- for (unsigned int linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
+ for (std::size_t linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode();
TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
assert(symbol && unitSymbol);
case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign:
// Check for integer-only operands.
- if ( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint ||
- right->getBasicType() != EbtInt && right->getBasicType() != EbtUint)
+ if (( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint) ||
+ (right->getBasicType() != EbtInt && right->getBasicType() != EbtUint))
return false;
if (left->isMatrix() || right->isMatrix())
return false;
case EOpSubAssign:
case EOpDivAssign:
case EOpModAssign:
- if (left->isMatrix() && right->isVector() ||
- left->isVector() && right->isMatrix() ||
+ if ((left->isMatrix() && right->isVector()) ||
+ (left->isVector() && right->isMatrix()) ||
left->getBasicType() != right->getBasicType())
return false;
if (left->isMatrix() && right->isMatrix() && (left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows()))
//
// Returns true for successful acceptance of the shader, false if any errors.
//
-bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], int lengths[], int numStrings)
+bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], size_t lengths[], int numStrings)
{
// empty shaders are okay
if (! strings || numStrings == 0 || lengths[0] == 0)
ppContext.setShaderStrings(strings, lengths, numStrings);
// TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens
- int len = 0;
+ size_t len = 0;
while (strings[0][len] == ' ' ||
strings[0][len] == '\t' ||
strings[0][len] == '\n' ||
} else {
if (index->getQualifier().storage == EvqConst) {
int indexValue = index->getAsConstantUnion()->getConstArray()[0].getIConst();
- if (! base->isArray() && (base->isVector() && base->getType().getVectorSize() <= indexValue ||
- base->isMatrix() && base->getType().getMatrixCols() <= indexValue))
+ if (! base->isArray() && ((base->isVector() && base->getType().getVectorSize() <= indexValue) ||
+ (base->isMatrix() && base->getType().getMatrixCols() <= indexValue)))
error(loc, "", "[", "index out of range '%d'", index->getAsConstantUnion()->getConstArray()[0].getIConst());
if (base->isArray()) {
if (base->getType().getArraySize() == 0) {
if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) {
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
- if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
- language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
+ if ((language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat) ||
+ (language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat)) {
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
return;
// Storage qualification
if (dst.storage == EvqTemporary || dst.storage == EvqGlobal)
dst.storage = src.storage;
- else if (dst.storage == EvqIn && src.storage == EvqOut ||
- dst.storage == EvqOut && src.storage == EvqIn)
+ else if ((dst.storage == EvqIn && src.storage == EvqOut) ||
+ (dst.storage == EvqOut && src.storage == EvqIn))
dst.storage = EvqInOut;
- else if (dst.storage == EvqIn && src.storage == EvqConst ||
- dst.storage == EvqConst && src.storage == EvqIn)
+ else if ((dst.storage == EvqIn && src.storage == EvqConst) ||
+ (dst.storage == EvqConst && src.storage == EvqIn))
dst.storage = EvqConstReadOnly;
else if (src.storage != EvqTemporary)
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
// Precision qualifiers
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
- if (dst.precision == EpqNone || force && src.precision != EpqNone)
+ if (dst.precision == EpqNone || (force && src.precision != EpqNone))
dst.precision = src.precision;
// Layout qualifiers
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
{
- if (sizes1 && sizes2 ||
- sizes1 && sizes1->isArrayOfArrays() ||
- sizes2 && sizes2->isArrayOfArrays())
+ if ((sizes1 && sizes2) ||
+ (sizes1 && sizes1->isArrayOfArrays()) ||
+ (sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc);
}
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
{
- if (type && type->isArray() && sizes2 ||
- sizes2 && sizes2->isArrayOfArrays())
+ if ((type && type->isArray() && sizes2) ||
+ (sizes2 && sizes2->isArrayOfArrays()))
arrayDimError(loc);
}
// Potentially redeclaring a built-in variable...
- if (identifier == "gl_FragDepth" && version >= 420 ||
- identifier == "gl_PerVertex" && version >= 410 ||
- identifier == "gl_PerFragment" && version >= 410 ||
- identifier == "gl_FragCoord" && version >= 150 ||
- identifier == "gl_ClipDistance" && version >= 130 ||
- identifier == "gl_FrontColor" && version >= 130 ||
- identifier == "gl_BackColor" && version >= 130 ||
- identifier == "gl_FrontSecondaryColor" && version >= 130 ||
- identifier == "gl_BackSecondaryColor" && version >= 130 ||
- identifier == "gl_SecondaryColor" && version >= 130 ||
- identifier == "gl_Color" && version >= 130 && language == EShLangFragment ||
- identifier == "gl_TexCoord") {
+ if ((identifier == "gl_FragDepth" && version >= 420) ||
+ (identifier == "gl_PerVertex" && version >= 410) ||
+ (identifier == "gl_PerFragment" && version >= 410) ||
+ (identifier == "gl_FragCoord" && version >= 150) ||
+ (identifier == "gl_ClipDistance" && version >= 130) ||
+ (identifier == "gl_FrontColor" && version >= 130) ||
+ (identifier == "gl_BackColor" && version >= 130) ||
+ (identifier == "gl_FrontSecondaryColor" && version >= 130) ||
+ (identifier == "gl_BackSecondaryColor" && version >= 130) ||
+ (identifier == "gl_SecondaryColor" && version >= 130) ||
+ (identifier == "gl_Color" && version >= 130 && language == EShLangFragment) ||
+ identifier == "gl_TexCoord") {
// Find the existing symbol, if any.
bool builtIn;
TQualifier memberQualifier = typeList[member].type->getQualifier();
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockDefaults.storage)
error(loc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), "");
- if (currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation() || memberQualifier.isAuxiliary())
+ if ((currentBlockDefaults.storage == EvqUniform && memberQualifier.isInterpolation()) || memberQualifier.isAuxiliary())
error(loc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), "");
TBasicType basicType = typeList[member].type->getBasicType();
wrapupSwitchSubsequence(lastStatements, 0);
if (expression == 0 ||
- expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint ||
+ (expression->getBasicType() != EbtInt && expression->getBasicType() != EbtUint) ||
expression->getType().isArray() || expression->getType().isMatrix() || expression->getType().isVector())
error(loc, "condition must be a scalar integer expression", "switch", "");
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
public:
- bool parseShaderStrings(TPpContext&, char* strings[], int strLen[], int numStrings);
+ bool parseShaderStrings(TPpContext&, char* strings[], size_t strLen[], int numStrings);
void parserError(const char *s); // for bison's yyerror
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
#include "../Include/PoolAlloc.h"
#include "../Include/Common.h"
-#include "Include/InitializeGlobals.h"
+#include "../Include/InitializeGlobals.h"
#include "osinclude.h"
namespace glslang {
#include <string.h>
#include "Scan.h"
-#include "Include/Types.h"
+#include "../Include/Types.h"
#include "SymbolTable.h"
#include "glslang_tab.cpp.h"
#include "ParseHelper.h"
case SWITCH:
case DEFAULT:
- if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < 130)
+ if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < 130))
reservedWord();
return keyword;
case LAYOUT:
case SHARED:
- if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < 140)
+ if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < 140))
return identifierOrType();
return keyword;
case SAMPLER2DRECTSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile ||
- parseContext.profile != EEsProfile && parseContext.version < 140)
+ (parseContext.profile != EEsProfile && parseContext.version < 140))
reservedWord();
return keyword;
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version == 300)
reservedWord();
- else if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < 130)
+ else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType();
return keyword;
return es30ReservedFromGLSL(130);
case SMOOTH:
- if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < 130)
+ if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < 130))
return identifierOrType();
return keyword;
case PRECISE:
if (parseContext.profile == EEsProfile ||
- parseContext.profile != EEsProfile && parseContext.version < 400)
+ (parseContext.profile != EEsProfile && parseContext.version < 400))
return identifierOrType();
return keyword;
return keyword;
case PACKED:
- if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < 330)
+ if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < 330))
return reservedWord();
return identifierOrType();
case RESOURCE:
{
- bool reserved = parseContext.profile == EEsProfile && parseContext.version >= 300 ||
- parseContext.profile != EEsProfile && parseContext.version >= 420;
+ bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version >= 420);
return identifierOrReserved(reserved);
}
case SUPERP:
// but then got reserved by ES 3.0.
int TScanContext::es30ReservedFromGLSL(int version)
{
- if (parseContext.profile == EEsProfile && parseContext.version < 300 ||
- parseContext.profile != EEsProfile && parseContext.version < version) {
+ if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version < version)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
// showed up, both in an es version and a non-ES version.
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
{
- if (parseContext.profile == EEsProfile && parseContext.version < esVersion ||
- parseContext.profile != EEsProfile && parseContext.version < nonEsVersion) {
+ if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
+ (parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
if (parseContext.profile != EEsProfile && parseContext.version >= 420)
return keyword;
- if (parseContext.profile == EEsProfile && parseContext.version >= 300 ||
- parseContext.profile != EEsProfile && parseContext.version >= 130) {
+ if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
+ (parseContext.profile != EEsProfile && parseContext.version >= 130)) {
reservedWord();
return keyword;
#include "Versions.h"
namespace glslang {
-
+
//
// A character scanner that seamlessly, on read-only strings, reads across an
// array of strings without assuming null termination.
//
class TInputScanner {
public:
- TInputScanner(int n, const char* const i[], int L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { }
+ TInputScanner(int n, const char* const i[], size_t L[]) : numSources(n), sources(i), lengths(L), currentSource(0), currentChar(0) { }
// return of -1 means end of strings,
// anything else is the next character
void advance()
{
++currentChar;
- if (currentChar >= lengths[currentSource]) {
+ if (currentChar >= static_cast<int>(lengths[currentSource])) {
++currentSource;
currentChar = 0;
while (currentSource < numSources && lengths[currentSource] == 0)
protected:
int numSources; // number of strings in source
const char* const *sources; // array of strings
- const int *lengths; // length of each string
+ const size_t *lengths; // length of each string
int currentSource;
int currentChar;
};
symbolTable.push();
const char* builtInShaders[2];
- int builtInLengths[2];
+ size_t builtInLengths[2];
builtInShaders[0] = builtIns.c_str();
builtInLengths[0] = builtIns.size();
GetThreadPoolAllocator().push();
// move to length-based strings, rather than null-terminated strings
- int* lengths = new int[numStrings];
+ size_t* lengths = new size_t[numStrings];
for (int s = 0; s < numStrings; ++s) {
if (inputLengths == 0 || inputLengths[s] < 0)
lengths[s] = strlen(shaderStrings[s]);
FreeScanner();
}
-void TPpContext::setPreamble(const char* p, int l)
+void TPpContext::setPreamble(const char* p, size_t l)
{
if (p && l > 0) {
// preAmble could be a hard-coded string; make writable copy
}
}
-void TPpContext::setShaderStrings(char* s[], int l[], int n)
+void TPpContext::setShaderStrings(char* s[], size_t l[], int n)
{
strings = s;
lengths = l;
TPpContext(TParseContext&);
virtual ~TPpContext();
- void setPreamble(const char* preamble, int length);
- void setShaderStrings(char* strings[], int lengths[], int numStrings);
+ void setPreamble(const char* preamble, size_t length);
+ void setShaderStrings(char* strings[], size_t lengths[], int numStrings);
const char* tokenize(TPpToken* yylvalpp);
};
protected:
- char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
- int preambleLength;
- char** strings; // official strings of shader, starting a string 0 line 1
- int* lengths;
- int numStrings; // how many official strings there are
- int currentString; // which string we're currently parsing (-1 for preamble)
+ char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
+ int preambleLength;
+ char** strings; // official strings of shader, starting a string 0 line 1
+ size_t* lengths;
+ int numStrings; // how many official strings there are
+ int currentString; // which string we're currently parsing (-1 for preamble)
// Scanner data:
int mostRecentToken; // Most recent token seen by the scanner