diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 65358ebf..bb72e31f 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -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. diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index fe10b2d2..35270b08 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -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 diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 8fcc5692..bc8ca880 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -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; diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 389315bf..0c97af54 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -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); } diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index e488d7d4..b999dd90 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -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*); diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp index 6590ee36..26572734 100644 --- a/glslang/MachineIndependent/Constant.cpp +++ b/glslang/MachineIndependent/Constant.cpp @@ -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: diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index f72de8ac..e666d7f7 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -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); diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 77698f86..69a13633 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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 { diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 6c56c1c4..f7f4d60c 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -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) diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index f630b875..97336e94 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -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. diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp index 80f2c854..849a6025 100644 --- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -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", "", ""); } diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index 641c1066..a5347911 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -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; }