glslang portability: Fixed a slew of OSX compilation warnings (but not all).

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31469 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-06-10 23:23:12 +00:00
parent 79eaa91e6f
commit fae38ee277
12 changed files with 83 additions and 75 deletions

View File

@ -370,7 +370,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
if (glslangIntermediate->getXfbMode())
builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb);
spv::ExecutionMode mode;
unsigned int mode;
switch (glslangIntermediate->getStage()) {
case EShLangVertex:
break;
@ -384,10 +384,10 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgQuads: mode = spv::ExecutionModeInputQuads; break;
case glslang::ElgIsolines: mode = spv::ExecutionModeInputIsolines; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
default: mode = spv::BadValue; break;
}
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
// TODO
//builder.addExecutionMode(spv::VertexSpacingMdName, glslangIntermediate->getVertexSpacing());
@ -402,20 +402,20 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
case glslang::ElgLinesAdjacency: mode = spv::ExecutionModeInputLinesAdjacency; break;
case glslang::ElgTriangles: mode = spv::ExecutionModeInputTriangles; break;
case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionModeInputTrianglesAdjacency; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
default: mode = spv::BadValue; break;
}
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeInvocations, glslangIntermediate->getInvocations());
switch (glslangIntermediate->getOutputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break;
case glslang::ElgLineStrip: mode = spv::ExecutionModeOutputLineStrip; break;
case glslang::ElgTriangleStrip: mode = spv::ExecutionModeOutputTriangleStrip; break;
default: mode = (spv::ExecutionMode)spv::BadValue; break;
default: mode = spv::BadValue; break;
}
if (mode != spv::BadValue)
builder.addExecutionMode(shaderEntry, mode);
builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
break;
@ -1239,10 +1239,7 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
if (glslang::IsAnonymous(name))
name = "";
if (storageClass == spv::BadValue)
return builder.createVariable(spv::StorageClassFunction, spvType, name);
else
return builder.createVariable(storageClass, spvType, name);
return builder.createVariable(storageClass, spvType, name);
}
// Return type Id of the sampled type.

View File

@ -2053,8 +2053,8 @@ void Builder::simplifyAccessChainSwizzle()
void Builder::mergeAccessChainSwizzle()
{
// is there even a chance of doing something? Need a single-component swizzle
if (accessChain.swizzle.size() > 1 ||
accessChain.swizzle.size() == 0 && accessChain.component == 0)
if ((accessChain.swizzle.size() > 1) ||
(accessChain.swizzle.size() == 0 && accessChain.component == 0))
return;
// TODO: optimization: remove this, but for now confine this to non-dynamic accesses

View File

@ -368,8 +368,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
disassembleIds(numOperands);
return;
case OperandVariableLiterals:
if (opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn ||
opCode == OpMemberDecorate && stream[word - 1] == DecorationBuiltIn) {
if ((opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn) ||
(opCode == OpMemberDecorate && stream[word - 1] == DecorationBuiltIn)) {
out << BuiltInString(stream[word++]);
--numOperands;
++op;

View File

@ -980,6 +980,8 @@ void FreeFileData(char** data)
void InfoLogMsg(const char* msg, const char* name, const int num)
{
printf(num >= 0 ? "#### %s %s %d INFO LOG ####\n" :
"#### %s %s INFO LOG ####\n", msg, name, num);
if (num >= 0 )
printf("#### %s %s %d INFO LOG ####\n", msg, name, num);
else
printf("#### %s %s INFO LOG ####\n", msg, name);
}

View File

@ -447,7 +447,8 @@ struct TIntermNodePair {
//
class TIntermTyped : public TIntermNode {
public:
TIntermTyped(const TType& t) { type.shallowCopy(t); }
TIntermTyped(const TType& t) { type.shallowCopy(t); }
TIntermTyped(TBasicType basicType) { TType bt(basicType); type.shallowCopy(bt); }
virtual TIntermTyped* getAsTyped() { return this; }
virtual const TIntermTyped* getAsTyped() const { return this; }
virtual void setType(const TType& t) { type.shallowCopy(t); }
@ -535,9 +536,9 @@ protected:
//
class TIntermSymbol : public TIntermTyped {
public:
// if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. If sym comes from
// per process threadPoolAllocator, then it causes increased memory usage per compile
// it is essential to use "symbol = sym" to assign to symbol
// if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. If sym comes from
// per process threadPoolAllocator, then it causes increased memory usage per compile
// it is essential to use "symbol = sym" to assign to symbol
TIntermSymbol(int i, const TString& n, const TType& t) :
TIntermTyped(t), id(i) { name = n;}
virtual int getId() const { return id; }
@ -582,8 +583,8 @@ public:
bool isConstructor() const;
virtual bool promote() { return true; }
protected:
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
TIntermOperator(TOperator o) : TIntermTyped(EbtFloat), op(o) {}
TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
TOperator op;
};
@ -634,35 +635,35 @@ class TIntermAggregate : public TIntermOperator {
public:
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
~TIntermAggregate() { delete pragmaTable; }
~TIntermAggregate() { delete pragmaTable; }
virtual TIntermAggregate* getAsAggregate() { return this; }
virtual const TIntermAggregate* getAsAggregate() const { return this; }
virtual void setOperator(TOperator o) { op = o; }
virtual TIntermSequence& getSequence() { return sequence; }
virtual const TIntermSequence& getSequence() const { return sequence; }
virtual void setName(const TString& n) { name = n; }
virtual void setName(const TString& n) { name = n; }
virtual const TString& getName() const { return name; }
virtual void traverse(TIntermTraverser*);
virtual void setUserDefined() { userDefined = true; }
virtual bool isUserDefined() { return userDefined; }
virtual TQualifierList& getQualifierList() { return qualifier; }
virtual const TQualifierList& getQualifierList() const { return qualifier; }
void setOptimize(bool o) { optimize = o; }
void setDebug(bool d) { debug = d; }
bool getOptimize() { return optimize; }
bool getDebug() { return debug; }
void addToPragmaTable(const TPragmaTable& pTable);
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
void setOptimize(bool o) { optimize = o; }
void setDebug(bool d) { debug = d; }
bool getOptimize() { return optimize; }
bool getDebug() { return debug; }
void addToPragmaTable(const TPragmaTable& pTable);
const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
protected:
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermSequence sequence;
TQualifierList qualifier;
TString name;
TString name;
bool userDefined; // used for user defined function names
bool optimize;
bool debug;
TPragmaTable* pragmaTable;
bool optimize;
bool debug;
TPragmaTable* pragmaTable;
};
//
@ -671,7 +672,7 @@ protected:
class TIntermSelection : public TIntermTyped {
public:
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
TIntermTyped(EbtVoid), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
virtual void traverse(TIntermTraverser*);

View File

@ -132,6 +132,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* const
}
TConstUnionArray newConstArray(newComps);
TType constBool(EbtBool, EvqConst);
switch(op) {
case EOpAdd:
@ -265,27 +266,27 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* const
case EOpLessThan:
newConstArray[0].setBConst(unionArray[0] < rightUnionArray[0]);
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
case EOpGreaterThan:
newConstArray[0].setBConst(unionArray[0] > rightUnionArray[0]);
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
case EOpLessThanEqual:
newConstArray[0].setBConst(! (unionArray[0] > rightUnionArray[0]));
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
case EOpGreaterThanEqual:
newConstArray[0].setBConst(! (unionArray[0] < rightUnionArray[0]));
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
case EOpEqual:
newConstArray[0].setBConst(node->getConstArray() == unionArray);
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
case EOpNotEqual:
newConstArray[0].setBConst(node->getConstArray() != unionArray);
returnType.shallowCopy(TType(EbtBool, EvqConst));
returnType.shallowCopy(constBool);
break;
default:

View File

@ -416,8 +416,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
"\n");
}
if (profile == EEsProfile && version >= 310 ||
profile != EEsProfile && version >= 430) {
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 430)) {
commonBuiltins.append(
"uint atomicAdd(coherent volatile inout uint, uint);"
" int atomicAdd(coherent volatile inout int, int);"
@ -446,8 +446,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
"\n");
}
if (profile == EEsProfile && version >= 310 ||
profile != EEsProfile && version >= 450) {
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 450)) {
commonBuiltins.append(
"int mix(int x, int y, bool a);"
"ivec2 mix(ivec2 x, ivec2 y, bvec2 a);"
@ -1330,8 +1330,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
//
//============================================================================
if (profile != EEsProfile && version >= 430 ||
profile == EEsProfile && version >= 310) {
if ((profile != EEsProfile && version >= 430) ||
(profile == EEsProfile && version >= 310)) {
stageBuiltins[EShLangCompute].append(
"in uvec3 gl_NumWorkGroups;"
"const uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
@ -2491,7 +2491,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
}
// images (some in compute below)
if (profile == EEsProfile && version >= 310 || profile != EEsProfile && version >= 130) {
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 130)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedShaderOutputResources = %d;", resources.maxCombinedShaderOutputResources);
@ -2505,7 +2506,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
}
// atomic counters (some in compute below)
if (profile == EEsProfile && version >= 310 || profile != EEsProfile && version >= 420) {
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 420)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources. maxFragmentAtomicCounters);

View File

@ -2192,7 +2192,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
// Ordering
if (! force && ((profile != EEsProfile && version < 420) ||
profile == EEsProfile && version < 310)
(profile == EEsProfile && version < 310))
&& ! extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)) {
// non-function parameters
if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
@ -4854,7 +4854,7 @@ void TParseContext::invariantCheck(TSourceLoc loc, const TQualifier& qualifier)
bool pipeOut = qualifier.isPipeOutput();
bool pipeIn = qualifier.isPipeInput();
if (version >= 300 || profile != EEsProfile && version >= 420) {
if (version >= 300 || (profile != EEsProfile && version >= 420)) {
if (! pipeOut)
error(loc, "can only apply to an output", "invariant", "");
} else {

View File

@ -1131,7 +1131,9 @@ int TScanContext::secondGenerationImage()
return keyword;
}
if (parseContext.symbolTable.atBuiltInLevel() || parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store)))
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile &&
(parseContext.version >= 420 || parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))))
return keyword;
if (parseContext.forwardCompatible)

View File

@ -432,6 +432,9 @@ void TIntermediate::finalCheck(TInfoSink& infoSink)
break;
case EShLangCompute:
break;
default:
error(infoSink, "Unknown Stage.");
break;
}
// Process the tree for any node-specific work.

View File

@ -285,9 +285,9 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ch = pp->getChar();
}
} while ((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= '0' && ch <= '9') ||
ch == '_');
(ch >= 'A' && ch <= 'Z') ||
(ch >= '0' && ch <= '9') ||
ch == '_');
// line continuation with no token before or after makes len == 0, and need to start over skipping white space, etc.
if (len == 0)
@ -333,8 +333,8 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
}
ch = pp->getChar();
} while ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'));
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'));
} else {
pp->parseContext.error(ppToken->loc, "bad digit in hexidecimal literal", "", "");
}

View File

@ -381,16 +381,16 @@ public:
// a sampler...
switch (sampler.type) {
case EbtFloat:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
switch (sampler.shadow) {
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY : GL_SAMPLER_1D;
case true: return sampler.arrayed ? GL_SAMPLER_1D_ARRAY_SHADOW : GL_SAMPLER_1D_SHADOW;
}
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false:
switch (sampler.shadow) {
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY : GL_SAMPLER_2D;
case true: return sampler.arrayed ? GL_SAMPLER_2D_ARRAY_SHADOW : GL_SAMPLER_2D_SHADOW;
}
@ -399,7 +399,7 @@ public:
case Esd3D:
return GL_SAMPLER_3D;
case EsdCube:
switch (sampler.shadow) {
switch ((int)sampler.shadow) {
case false: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY : GL_SAMPLER_CUBE;
case true: return sampler.arrayed ? GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW : GL_SAMPLER_CUBE_SHADOW;
}
@ -409,11 +409,11 @@ public:
return GL_SAMPLER_BUFFER;
}
case EbtInt:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_INT_SAMPLER_1D_ARRAY : GL_INT_SAMPLER_1D;
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_INT_SAMPLER_2D_ARRAY : GL_INT_SAMPLER_2D;
case true: return sampler.arrayed ? GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_INT_SAMPLER_2D_MULTISAMPLE;
}
@ -427,11 +427,11 @@ public:
return GL_INT_SAMPLER_BUFFER;
}
case EbtUint:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : GL_UNSIGNED_INT_SAMPLER_1D;
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D;
case true: return sampler.arrayed ? GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
}
@ -451,11 +451,11 @@ public:
// an image...
switch (sampler.type) {
case EbtFloat:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_IMAGE_1D_ARRAY : GL_IMAGE_1D;
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_IMAGE_2D_ARRAY : GL_IMAGE_2D;
case true: return sampler.arrayed ? GL_IMAGE_2D_MULTISAMPLE_ARRAY : GL_IMAGE_2D_MULTISAMPLE;
}
@ -469,11 +469,11 @@ public:
return GL_IMAGE_BUFFER;
}
case EbtInt:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_INT_IMAGE_1D_ARRAY : GL_INT_IMAGE_1D;
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_INT_IMAGE_2D_ARRAY : GL_INT_IMAGE_2D;
case true: return sampler.arrayed ? GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_INT_IMAGE_2D_MULTISAMPLE;
}
@ -487,11 +487,11 @@ public:
return GL_INT_IMAGE_BUFFER;
}
case EbtUint:
switch (sampler.dim) {
switch ((int)sampler.dim) {
case Esd1D:
return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_1D_ARRAY : GL_UNSIGNED_INT_IMAGE_1D;
case Esd2D:
switch (sampler.ms) {
switch ((int)sampler.ms) {
case false: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_ARRAY : GL_UNSIGNED_INT_IMAGE_2D;
case true: return sampler.arrayed ? GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY : GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE;
}