Externals: Add glslang from Vulkan SDK v1.0.21.1

This commit is contained in:
Stenzek
2016-06-26 15:06:20 +10:00
parent 49e57df2b6
commit 951fc44d86
135 changed files with 74837 additions and 0 deletions

26
Externals/glslang/hlsl/CMakeLists.txt vendored Executable file
View File

@ -0,0 +1,26 @@
set(SOURCES
hlslParseHelper.cpp
hlslScanContext.cpp
hlslOpMap.cpp
hlslTokenStream.cpp
hlslGrammar.cpp
hlslParseables.cpp)
set(HEADERS
hlslParseHelper.h
hlslTokens.h
hlslScanContext.h
hlslOpMap.h
hlslTokenStream.h
hlslGrammar.h
hlslParseables.h)
add_library(HLSL STATIC ${SOURCES} ${HEADERS})
set_property(TARGET HLSL PROPERTY FOLDER hlsl)
if(WIN32)
source_group("Source" FILES ${SOURCES} ${HEADERS})
endif(WIN32)
install(TARGETS HLSL
ARCHIVE DESTINATION lib)

2482
Externals/glslang/hlsl/hlslGrammar.cpp vendored Executable file

File diff suppressed because it is too large Load Diff

114
Externals/glslang/hlsl/hlslGrammar.h vendored Executable file
View File

@ -0,0 +1,114 @@
//
//Copyright (C) 2016 Google, Inc.
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef HLSLGRAMMAR_H_
#define HLSLGRAMMAR_H_
#include "hlslParseHelper.h"
#include "hlslOpMap.h"
#include "hlslTokenStream.h"
namespace glslang {
// Should just be the grammar aspect of HLSL.
// Described in more detail in hlslGrammar.cpp.
class HlslGrammar : public HlslTokenStream {
public:
HlslGrammar(HlslScanContext& scanner, HlslParseContext& parseContext)
: HlslTokenStream(scanner), parseContext(parseContext), intermediate(parseContext.intermediate) { }
virtual ~HlslGrammar() { }
bool parse();
protected:
HlslGrammar();
HlslGrammar& operator=(const HlslGrammar&);
void expected(const char*);
void unimplemented(const char*);
bool acceptIdentifier(HlslToken&);
bool acceptCompilationUnit();
bool acceptDeclaration(TIntermNode*& node);
bool acceptControlDeclaration(TIntermNode*& node);
bool acceptSamplerDeclarationDX9(TType&);
bool acceptSamplerState();
bool acceptFullySpecifiedType(TType&);
void acceptQualifier(TQualifier&);
bool acceptType(TType&);
bool acceptTemplateType(TBasicType&);
bool acceptVectorTemplateType(TType&);
bool acceptMatrixTemplateType(TType&);
bool acceptSamplerType(TType&);
bool acceptTextureType(TType&);
bool acceptStruct(TType&);
bool acceptStructDeclarationList(TTypeList*&);
bool acceptFunctionParameters(TFunction&);
bool acceptParameterDeclaration(TFunction&);
bool acceptFunctionDefinition(TFunction&, TIntermNode*&);
bool acceptParenExpression(TIntermTyped*&);
bool acceptExpression(TIntermTyped*&);
bool acceptInitializer(TIntermTyped*&);
bool acceptAssignmentExpression(TIntermTyped*&);
bool acceptBinaryExpression(TIntermTyped*&, PrecedenceLevel);
bool acceptUnaryExpression(TIntermTyped*&);
bool acceptPostfixExpression(TIntermTyped*&);
bool acceptConstructor(TIntermTyped*&);
bool acceptFunctionCall(HlslToken, TIntermTyped*&, TIntermTyped* base = nullptr);
bool acceptArguments(TFunction*, TIntermTyped*&);
bool acceptLiteral(TIntermTyped*&);
bool acceptCompoundStatement(TIntermNode*&);
bool acceptStatement(TIntermNode*&);
bool acceptScopedStatement(TIntermNode*&);
bool acceptScopedCompoundStatement(TIntermNode*&);
bool acceptNestedStatement(TIntermNode*&);
void acceptAttributes();
bool acceptSelectionStatement(TIntermNode*&);
bool acceptSwitchStatement(TIntermNode*&);
bool acceptIterationStatement(TIntermNode*&);
bool acceptJumpStatement(TIntermNode*&);
bool acceptCaseLabel(TIntermNode*&);
bool acceptDefaultLabel(TIntermNode*&);
void acceptArraySpecifier(TArraySizes*&);
void acceptPostDecls(TType&);
HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate
TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST
};
} // end namespace glslang
#endif // HLSLGRAMMAR_H_

171
Externals/glslang/hlsl/hlslOpMap.cpp vendored Executable file
View File

@ -0,0 +1,171 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
// Map from physical token form (e.g. '-') to logical operator
// form (e.g., binary subtract or unary negate).
#include "hlslOpMap.h"
namespace glslang {
// Map parsing tokens that could be assignments into assignment operators.
TOperator HlslOpMap::assignment(EHlslTokenClass op)
{
switch (op) {
case EHTokAssign: return EOpAssign;
case EHTokMulAssign: return EOpMulAssign;
case EHTokDivAssign: return EOpDivAssign;
case EHTokAddAssign: return EOpAddAssign;
case EHTokModAssign: return EOpModAssign;
case EHTokLeftAssign: return EOpLeftShiftAssign;
case EHTokRightAssign: return EOpRightShiftAssign;
case EHTokAndAssign: return EOpAndAssign;
case EHTokXorAssign: return EOpExclusiveOrAssign;
case EHTokOrAssign: return EOpInclusiveOrAssign;
case EHTokSubAssign: return EOpSubAssign;
default:
return EOpNull;
}
}
// Map parsing tokens that could be binary operations into binary operators.
TOperator HlslOpMap::binary(EHlslTokenClass op)
{
switch (op) {
case EHTokPlus: return EOpAdd;
case EHTokDash: return EOpSub;
case EHTokStar: return EOpMul;
case EHTokSlash: return EOpDiv;
case EHTokPercent: return EOpMod;
case EHTokRightOp: return EOpRightShift;
case EHTokLeftOp: return EOpLeftShift;
case EHTokAmpersand: return EOpAnd;
case EHTokVerticalBar: return EOpInclusiveOr;
case EHTokCaret: return EOpExclusiveOr;
case EHTokEqOp: return EOpEqual;
case EHTokNeOp: return EOpNotEqual;
case EHTokLeftAngle: return EOpLessThan;
case EHTokRightAngle: return EOpGreaterThan;
case EHTokLeOp: return EOpLessThanEqual;
case EHTokGeOp: return EOpGreaterThanEqual;
case EHTokOrOp: return EOpLogicalOr;
case EHTokXorOp: return EOpLogicalXor;
case EHTokAndOp: return EOpLogicalAnd;
default:
return EOpNull;
}
}
// Map parsing tokens that could be unary operations into unary operators.
// These are just the ones that can appear in front of its operand.
TOperator HlslOpMap::preUnary(EHlslTokenClass op)
{
switch (op) {
case EHTokPlus: return EOpAdd; // means no-op, but still a unary op was present
case EHTokDash: return EOpNegative;
case EHTokBang: return EOpLogicalNot;
case EHTokTilde: return EOpBitwiseNot;
case EHTokIncOp: return EOpPreIncrement;
case EHTokDecOp: return EOpPreDecrement;
default: return EOpNull; // means not a pre-unary op
}
}
// Map parsing tokens that could be unary operations into unary operators.
// These are just the ones that can appear behind its operand.
TOperator HlslOpMap::postUnary(EHlslTokenClass op)
{
switch (op) {
case EHTokDot: return EOpIndexDirectStruct;
case EHTokLeftBracket: return EOpIndexIndirect;
case EHTokIncOp: return EOpPostIncrement;
case EHTokDecOp: return EOpPostDecrement;
default: return EOpNull; // means not a post-unary op
}
}
// Map operators into their level of precedence.
PrecedenceLevel HlslOpMap::precedenceLevel(TOperator op)
{
switch (op) {
case EOpLogicalOr:
return PlLogicalOr;
case EOpLogicalXor:
return PlLogicalXor;
case EOpLogicalAnd:
return PlLogicalAnd;
case EOpInclusiveOr:
return PlBitwiseOr;
case EOpExclusiveOr:
return PlBitwiseXor;
case EOpAnd:
return PlBitwiseAnd;
case EOpEqual:
case EOpNotEqual:
return PlEquality;
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
return PlRelational;
case EOpRightShift:
case EOpLeftShift:
return PlShift;
case EOpAdd:
case EOpSub:
return PlAdd;
case EOpMul:
case EOpDiv:
case EOpMod:
return PlMul;
default:
return PlBad;
}
}
} // end namespace glslang

69
Externals/glslang/hlsl/hlslOpMap.h vendored Executable file
View File

@ -0,0 +1,69 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef HLSLOPMAP_H_
#define HLSLOPMAP_H_
#include "hlslScanContext.h"
namespace glslang {
enum PrecedenceLevel {
PlBad,
PlLogicalOr,
PlLogicalXor,
PlLogicalAnd,
PlBitwiseOr,
PlBitwiseXor,
PlBitwiseAnd,
PlEquality,
PlRelational,
PlShift,
PlAdd,
PlMul
};
class HlslOpMap {
public:
static TOperator assignment(EHlslTokenClass op);
static TOperator binary(EHlslTokenClass op);
static TOperator preUnary(EHlslTokenClass op);
static TOperator postUnary(EHlslTokenClass op);
static PrecedenceLevel precedenceLevel(TOperator);
};
} // end namespace glslang
#endif // HLSLOPMAP_H_

4162
Externals/glslang/hlsl/hlslParseHelper.cpp vendored Executable file

File diff suppressed because it is too large Load Diff

235
Externals/glslang/hlsl/hlslParseHelper.h vendored Executable file
View File

@ -0,0 +1,235 @@
//
//Copyright (C) 2016 Google, Inc.
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 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.
//
#ifndef HLSL_PARSE_INCLUDED_
#define HLSL_PARSE_INCLUDED_
#include "../glslang/MachineIndependent/parseVersions.h"
#include "../glslang/MachineIndependent/ParseHelper.h"
namespace glslang {
class HlslParseContext : public TParseContextBase {
public:
HlslParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins,
int version, EProfile, const SpvVersion& spvVersion, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
virtual ~HlslParseContext();
void setLimits(const TBuiltInResource&);
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
void getPreamble(std::string&);
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void reservedPpErrorCheck(const TSourceLoc&, const char* /*name*/, const char* /*op*/) { }
bool lineContinuationCheck(const TSourceLoc&, bool /*endOfComment*/) { return true; }
bool lineDirectiveShouldSetNextLine() const { return true; }
bool builtInName(const TString&);
void handlePragma(const TSourceLoc&, const TVector<TString>&);
TIntermTyped* handleVariable(const TSourceLoc&, TSymbol* symbol, const TString* string);
TIntermTyped* handleBracketDereference(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
void checkIndex(const TSourceLoc&, const TType&, int& index);
void makeEditable(TSymbol*&);
TVariable* getEditableVariable(const char* name);
bool isIoResizeArray(const TType&) const;
void fixIoArraySize(const TSourceLoc&, TType&);
void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base);
void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false);
int getIoArrayImplicitSize() const;
void checkIoArrayConsistency(const TSourceLoc&, int requiredSize, const char* feature, TType&, const TString&);
TIntermTyped* handleBinaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleUnaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* childNode);
TIntermTyped* handleDotDereference(const TSourceLoc&, TIntermTyped* base, const TString& field);
TFunction* handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermNode*);
void decomposeIntrinsic(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
void decomposeSampleMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
void addInputArgumentConversions(const TFunction&, TIntermNode*&) const;
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
void handleSemantic(TType& type, const TString& semantic);
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
bool parseVectorFields(const TSourceLoc&, const TString&, int vecSize, TVectorFields&);
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
void unaryOpError(const TSourceLoc&, const char* op, TString operand);
void binaryOpError(const TSourceLoc&, const char* op, TString left, TString right);
void variableCheck(TIntermTyped*& nodePtr);
void constantValueCheck(TIntermTyped* node, const char* token);
void integerCheck(const TIntermTyped* node, const char* token);
void globalCheck(const TSourceLoc&, const char* token);
bool constructorError(const TSourceLoc&, TIntermNode*, TFunction&, TOperator, TType&);
bool constructorTextureSamplerError(const TSourceLoc&, const TFunction&);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&);
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
void structArrayCheck(const TSourceLoc&, const TType& structure);
void arrayDimMerge(TType& type, const TArraySizes* sizes);
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
void boolCheck(const TSourceLoc&, const TIntermTyped*);
void globalQualifierFix(const TSourceLoc&, TQualifier&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
void mergeQualifiers(const TSourceLoc&, TQualifier& dst, const TQualifier& src, bool force);
int computeSamplerTypeIndex(TSampler&);
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&, bool& newDeclaration);
void redeclareBuiltinBlock(const TSourceLoc&, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes);
void paramFix(TType& type);
void specializationCheck(const TSourceLoc&, const TType&, const char* op);
void setLayoutQualifier(const TSourceLoc&, TPublicType&, TString&);
void setLayoutQualifier(const TSourceLoc&, TPublicType&, TString&, const TIntermTyped*);
void mergeObjectLayoutQualifiers(TQualifier& dest, const TQualifier& src, bool inheritOnly);
void checkNoShaderLayouts(const TSourceLoc&, const TShaderQualifiers&);
const TFunction* findFunction(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
void declareTypedef(const TSourceLoc&, TString& identifier, const TType&, TArraySizes* typeArray = 0);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&, TOperator);
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
void declareBlock(const TSourceLoc&, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
void fixBlockXfbOffsets(TQualifier&, TTypeList&);
void fixBlockUniformOffsets(TQualifier&, TTypeList&);
void addQualifierToExisting(const TSourceLoc&, TQualifier, const TString& identifier);
void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&);
void updateStandaloneQualifierDefaults(const TSourceLoc&, const TPublicType&);
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body);
void updateImplicitArraySize(const TSourceLoc&, TIntermNode*, int index);
void nestLooping() { ++loopNestingLevel; }
void unnestLooping() { --loopNestingLevel; }
void pushScope() { symbolTable.push(); }
void popScope() { symbolTable.pop(0); }
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
void popSwitchSequence() { switchSequenceStack.pop_back(); }
protected:
void inheritGlobalDefaults(TQualifier& dst) const;
TVariable* makeInternalVariable(const char* name, const TType&) const;
TVariable* declareNonArray(const TSourceLoc&, TString& identifier, TType&, bool& newDeclaration);
void declareArray(const TSourceLoc&, TString& identifier, const TType&, TSymbol*&, bool& newDeclaration);
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
TOperator mapTypeToConstructorOp(const TType&) const;
TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);
void outputMessage(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, TPrefixType prefix,
va_list args);
// Current state of parsing
struct TPragma contextPragma;
int loopNestingLevel; // 0 if outside all loops
int structNestingLevel; // 0 if outside blocks and structures
int controlFlowNestingLevel; // 0 if outside all flow control
TList<TIntermSequence*> switchSequenceStack; // case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
bool inEntrypoint; // if inside a function, true if the function is the entry point
bool postMainReturn; // if inside a function, true if the function is the entry point and this is after a return statement
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
const TString* blockName;
TQualifier currentBlockQualifier;
TBuiltInResource resources;
TLimits& limits;
HlslParseContext(HlslParseContext&);
HlslParseContext& operator=(HlslParseContext&);
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex()
bool afterEOF;
TQualifier globalBufferDefaults;
TQualifier globalUniformDefaults;
TQualifier globalInputDefaults;
TQualifier globalOutputDefaults;
TString currentCaller; // name of last function body entered (not valid when at global scope)
TIdSetType inductiveLoopIds;
TVector<TIntermTyped*> needsIndexLimitationChecking;
//
// Geometry shader input arrays:
// - array sizing is based on input primitive and/or explicit size
//
// Tessellation control output arrays:
// - array sizing is based on output layout(vertices=...) and/or explicit size
//
// Both:
// - array sizing is retroactive
// - built-in block redeclarations interact with this
//
// Design:
// - use a per-context "resize-list", a list of symbols whose array sizes
// can be fixed
//
// - the resize-list starts empty at beginning of user-shader compilation, it does
// not have built-ins in it
//
// - on built-in array use: copyUp() symbol and add it to the resize-list
//
// - on user array declaration: add it to the resize-list
//
// - on block redeclaration: copyUp() symbol and add it to the resize-list
// * note, that appropriately gives an error if redeclaring a block that
// was already used and hence already copied-up
//
// - on seeing a layout declaration that sizes the array, fix everything in the
// resize-list, giving errors for mismatch
//
// - on seeing an array size declaration, give errors on mismatch between it and previous
// array-sizing declarations
//
TVector<TSymbol*> ioArraySymbolResizeList;
};
} // end namespace glslang
#endif // HLSL_PARSE_INCLUDED_

871
Externals/glslang/hlsl/hlslParseables.cpp vendored Executable file
View File

@ -0,0 +1,871 @@
//
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 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.
//
//
// Create strings that declare built-in definitions, add built-ins programmatically
// that cannot be expressed in the strings, and establish mappings between
// built-in functions and operators.
//
// Where to put a built-in:
// TBuiltInParseablesHlsl::initialize(version,profile) context-independent textual built-ins; add them to the right string
// TBuiltInParseablesHlsl::initialize(resources,...) context-dependent textual built-ins; add them to the right string
// TBuiltInParseablesHlsl::identifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table,
// including identifying what extensions are needed if a version does not allow a symbol
// TBuiltInParseablesHlsl::identifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the
// symbol table, including identifying what extensions are needed if a version does
// not allow a symbol
//
#include "hlslParseables.h"
#include <cctype>
#include <utility>
#include <algorithm>
namespace { // anonymous namespace functions
const bool UseHlslTypes = false;
const char* BaseTypeName(const char argOrder, const char* scalarName, const char* vecName, const char* matName)
{
switch (argOrder) {
case 'S': return scalarName;
case 'V': return vecName;
case 'M': return matName;
default: return "UNKNOWN_TYPE";
}
}
bool IsTextureType(const char argOrder) { return argOrder == '%' || argOrder == '@'; }
bool IsTextureArrayed(const char argOrder) { return argOrder == '@'; }
bool IsTextureMS(const char /*argOrder*/) { return false; } // TODO: ...
// Reject certain combinations that are illegal sample methods. For example,
// 3D arrays.
bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim0)
{
const bool isArrayed = IsTextureArrayed(*argOrder);
const bool isMS = IsTextureMS(*argOrder);
// there are no 3D arrayed textures, or 3D SampleCmp
if (dim0 == 3 && (isArrayed || name == "SampleCmp"))
return true;
const int numArgs = int(std::count(argOrder, argOrder + strlen(argOrder), ',')) + 1;
// Reject invalid offset arrayed forms with cubemaps
if (isArrayed && dim0 == 4) {
if ((name == "Sample" && numArgs >= 4) ||
(name == "SampleBias" && numArgs >= 5) ||
(name == "SampleCmp" && numArgs >= 5) ||
(name == "SampleCmpLevelZero" && numArgs >= 4) ||
(name == "SampleGrad" && numArgs >= 6) ||
(name == "SampleLevel" && numArgs >= 5))
return true;
}
// Reject invalid Loads
if (name == "Load") {
if ((numArgs >= 3 && !isMS) || // Load with sampleindex requires multisample
(dim0 == 4)) // Load does not support any cubemaps, arrayed or not.
return true;
}
return false;
}
// Create and return a type name. This is done in GLSL, not HLSL conventions, until such
// time as builtins are parsed using the HLSL parser.
//
// order: S = scalar, V = vector, M = matrix
// argType: F = float, D = double, I = int, U = uint, B = bool, S = sampler
// dim0 = vector dimension, or matrix 1st dimension
// dim1 = matrix 2nd dimension
glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, const char* argType, int dim0, int dim1)
{
const bool isTranspose = (argOrder[0] == '^');
const bool isMatMul = (argOrder[0] == '#');
const bool isTexture = IsTextureType(argOrder[0]);
const bool isArrayed = IsTextureArrayed(argOrder[0]);
//const bool isMS = IsTextureMS(argOrder[0]);
char order = *argOrder;
char type = *argType;
if (isTranspose) { // Take transpose of matrix dimensions
order = *++argOrder;
std::swap(dim0, dim1);
} else if (isMatMul) {
order = *++argOrder;
dim0 = dim1; // set vector dimension to mat col
} else if (isTexture) {
order = *++argOrder;
if (type == 'F') // map base type to texture of that type.
type = 'T'; // e.g, int -> itexture, uint -> utexture, etc.
else if (type == 'I')
type = 'i';
else if (type == 'U')
type = 'u';
}
if (UseHlslTypes) {
switch (type) {
case '-': s += "void"; break;
case 'F': s += "float"; break;
case 'D': s += "double"; break;
case 'I': s += "int"; break;
case 'U': s += "uint"; break;
case 'B': s += "bool"; break;
case 'S': s += "sampler"; break;
case 'T': s += "Texture"; break;
case 'i': s += "Texture <int4>"; break;
case 'u': s += "Texture <uint4>"; break;
default: s += "UNKNOWN_TYPE"; break;
}
} else {
switch (type) {
case '-': s += "void"; break;
case 'F': s += BaseTypeName(order, "float", "vec", "mat"); break;
case 'D': s += BaseTypeName(order, "double", "dvec", "dmat"); break;
case 'I': s += BaseTypeName(order, "int", "ivec", "imat"); break;
case 'U': s += BaseTypeName(order, "uint", "uvec", "umat"); break;
case 'B': s += BaseTypeName(order, "bool", "bvec", "bmat"); break;
case 'S': s += "sampler"; break;
case 'T': // fall through
case 'i': // ...
case 'u': // ...
if (type != 'T')
s += type;
s += "texture";
break;
default: s += "UNKNOWN_TYPE"; break;
}
}
// handle fixed vector sizes, such as float3, and only ever 3.
const int fixedVecSize = isdigit(argOrder[1]) ? (argOrder[1] - '0') : 0;
if (fixedVecSize != 0)
dim0 = dim1 = fixedVecSize;
// Add sampler dimensions
if (type == 'S' || isTexture) {
if (order == 'V') {
switch (dim0) {
case 1: s += "1D"; break;
case 2: s += "2D"; break;
case 3: s += "3D"; break;
case 4: s += "Cube"; break;
default: s += "UNKNOWN_SAMPLER"; break;
}
}
} else {
// Non-sampler type:
// verify dimensions
if (((order == 'V' || order == 'M') && (dim0 < 1 || dim0 > 4)) ||
(order == 'M' && (dim1 < 1 || dim1 > 4))) {
s += "UNKNOWN_DIMENSION";
return s;
}
switch (order) {
case '-': break; // no dimensions for voids
case 'S': break; // no dimensions on scalars
case 'V': s += ('0' + char(dim0)); break;
case 'M':
{
if (!UseHlslTypes) // GLSL has column first for mat types
std::swap(dim0, dim1);
s += ('0' + char(dim0));
s += 'x';
s += ('0' + char(dim1));
break;
}
}
}
// handle arrayed textures
if (isArrayed)
s += "Array";
return s;
}
// TODO: the GLSL parser is currently used to parse HLSL prototypes. However, many valid HLSL prototypes
// are not valid GLSL prototypes. This rejects the invalid ones. Thus, there is a single switch below
// to enable creation of the entire HLSL space.
inline bool IsValidGlsl(const char* cname, char retOrder, char retType, char argOrder, char argType,
int dim0, int dim1, int dim0Max, int dim1Max)
{
const bool isVec = dim0Max > 1 || argType == 'V';
const bool isMat = dim1Max > 1 || argType == 'M';
if (!IsTextureType(argOrder) &&
((isVec && dim0 == 1) || // avoid vec1
(isMat && dim0 == 1 && dim1 == 1))) // avoid mat1x1
return false;
const std::string name(cname); // for ease of comparison. slow, but temporary, until HLSL parser is online.
if (isMat && dim1 == 1) // TODO: avoid mat Nx1 until we find the right GLSL profile
return false;
if ((isMat && (argType == 'I' || argType == 'U' || argType == 'B')) ||
(retOrder == 'M' && (retType == 'I' || retType == 'U' || retType == 'B')))
return false;
if (name == "GetRenderTargetSamplePosition" ||
name == "tex1D" ||
name == "tex1Dgrad")
return false;
return true;
}
// Return true for the end of a single argument key, which can be the end of the string, or
// the comma separator.
inline bool IsEndOfArg(const char* arg)
{
return arg == nullptr || *arg == '\0' || *arg == ',';
}
// return position of end of argument specifier
inline const char* FindEndOfArg(const char* arg)
{
while (!IsEndOfArg(arg))
++arg;
return *arg == '\0' ? nullptr : arg;
}
// Return pointer to beginning of Nth argument specifier in the string.
inline const char* NthArg(const char* arg, int n)
{
for (int x=0; x<n && arg; ++x)
if ((arg = FindEndOfArg(arg)) != nullptr)
++arg; // skip arg separator
return arg;
}
inline void FindVectorMatrixBounds(const char* argOrder, int fixedVecSize, int& dim0Min, int& dim0Max, int& /*dim1Min*/, int& dim1Max)
{
for (int arg = 0; ; ++arg) {
const char* nthArgOrder(NthArg(argOrder, arg));
if (nthArgOrder == nullptr)
break;
else if (*nthArgOrder == 'V')
dim0Max = 4;
else if (*nthArgOrder == 'M')
dim0Max = dim1Max = 4;
}
if (fixedVecSize > 0) // handle fixed sized vectors
dim0Min = dim0Max = fixedVecSize;
}
} // end anonymous namespace
namespace glslang {
TBuiltInParseablesHlsl::TBuiltInParseablesHlsl()
{
}
//
// Handle creation of mat*mat specially, since it doesn't fall conveniently out of
// the generic prototype creation code below.
//
void TBuiltInParseablesHlsl::createMatTimesMat()
{
TString& s = commonBuiltins;
const int first = (UseHlslTypes ? 1 : 2);
for (int xRows = first; xRows <=4; xRows++) {
for (int xCols = first; xCols <=4; xCols++) {
const int yRows = xCols;
for (int yCols = first; yCols <=4; yCols++) {
const int retRows = xRows;
const int retCols = yCols;
AppendTypeName(s, "M", "F", retRows, retCols); // add return type
s.append(" "); // space between type and name
s.append("mul"); // intrinsic name
s.append("("); // open paren
AppendTypeName(s, "M", "F", xRows, xCols); // add X input
s.append(", ");
AppendTypeName(s, "M", "F", yRows, yCols); // add Y input
s.append(");\n"); // close paren
}
}
}
}
//
// Add all context-independent built-in functions and variables that are present
// for the given version and profile. Share common ones across stages, otherwise
// make stage-specific entries.
//
// Most built-ins variables can be added as simple text strings. Some need to
// be added programmatically, which is done later in IdentifyBuiltIns() below.
//
void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/)
{
static const EShLanguageMask EShLangAll = EShLanguageMask(EShLangCount - 1);
// This structure encodes the prototype information for each HLSL intrinsic.
// Because explicit enumeration would be cumbersome, it's procedurally generated.
// orderKey can be:
// S = scalar, V = vector, M = matrix, - = void
// typekey can be:
// D = double, F = float, U = uint, I = int, B = bool, S = sampler
// An empty order or type key repeats the first one. E.g: SVM,, means 3 args each of SVM.
// '>' as first letter of order creates an output parameter
// '<' as first letter of order creates an input parameter
// '^' as first letter of order takes transpose dimensions
// '#' as first letter of order sets rows=cols for mats
// '%' as first letter of order creates texture of given F/I/U type (texture, itexture, etc)
// '@' as first letter of order creates arrayed texture of given type
static const struct {
const char* name; // intrinsic name
const char* retOrder; // return type key: empty matches order of 1st argument
const char* retType; // return type key: empty matches type of 1st argument
const char* argOrder; // argument order key
const char* argType; // argument type key
unsigned int stage; // stage mask
} hlslIntrinsics[] = {
// name retOrd retType argOrder argType stage mask
// -----------------------------------------------------------------------------------------------
{ "abort", nullptr, nullptr, "-", "-", EShLangAll },
{ "abs", nullptr, nullptr, "SVM", "DFUI", EShLangAll },
{ "acos", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "all", "S", "B", "SVM", "BFI", EShLangAll },
{ "AllMemoryBarrier", nullptr, nullptr, "-", "-", EShLangComputeMask },
{ "AllMemoryBarrierWithGroupSync", nullptr, nullptr, "-", "-", EShLangComputeMask },
{ "any", "S", "B", "SVM", "BFI", EShLangAll },
{ "asdouble", "S", "D", "S,", "U,", EShLangAll },
{ "asdouble", "V2", "D", "V2,", "U,", EShLangAll },
{ "asfloat", nullptr, "F", "SVM", "BFIU", EShLangAll },
{ "asin", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "asint", nullptr, "I", "SVM", "FU", EShLangAll },
{ "asuint", nullptr, "U", "SVM", "FU", EShLangAll },
{ "atan", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "atan2", nullptr, nullptr, "SVM,", "F,", EShLangAll },
{ "ceil", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "CheckAccessFullyMapped", "S", "B" , "S", "U", EShLangFragmentMask | EShLangComputeMask },
{ "clamp", nullptr, nullptr, "SVM,,", "FUI,,", EShLangAll },
{ "clip", "-", "-", "SVM", "F", EShLangFragmentMask },
{ "cos", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "cosh", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "countbits", nullptr, nullptr, "SV", "U", EShLangAll },
{ "cross", nullptr, nullptr, "V3,", "F,", EShLangAll },
{ "D3DCOLORtoUBYTE4", "V4", "I", "V4", "F", EShLangAll },
{ "ddx", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "ddx_coarse", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "ddx_fine", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "ddy", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "ddy_coarse", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "ddy_fine", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "degrees", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "determinant", "S", "F", "M", "F", EShLangAll },
{ "DeviceMemoryBarrier", nullptr, nullptr, "-", "-", EShLangFragmentMask | EShLangComputeMask },
{ "DeviceMemoryBarrierWithGroupSync", nullptr, nullptr, "-", "-", EShLangComputeMask },
{ "distance", "S", "F", "V,", "F,", EShLangAll },
{ "dot", "S", nullptr, "V,", "FI,", EShLangAll },
{ "dst", nullptr, nullptr, "V4,V4", "F,", EShLangAll },
// { "errorf", "-", "-", "", "", EShLangAll }, TODO: varargs
{ "EvaluateAttributeAtCentroid", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "EvaluateAttributeAtSample", nullptr, nullptr, "SVM,S", "F,U", EShLangFragmentMask },
{ "EvaluateAttributeSnapped", nullptr, nullptr, "SVM,V2", "F,I", EShLangFragmentMask },
{ "exp", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "exp2", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "f16tof32", nullptr, "F", "SV", "U", EShLangAll },
{ "f32tof16", nullptr, "U", "SV", "F", EShLangAll },
{ "faceforward", nullptr, nullptr, "V,,", "F,,", EShLangAll },
{ "firstbithigh", nullptr, nullptr, "SV", "UI", EShLangAll },
{ "firstbitlow", nullptr, nullptr, "SV", "UI", EShLangAll },
{ "floor", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "fma", nullptr, nullptr, "SVM,,", "D,,", EShLangAll },
{ "fmod", nullptr, nullptr, "SVM,", "F,", EShLangAll },
{ "frac", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "frexp", nullptr, nullptr, "SVM,", "F,", EShLangAll },
{ "fwidth", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "GetRenderTargetSampleCount", "S", "U", "-", "-", EShLangAll },
{ "GetRenderTargetSamplePosition", "V2", "F", "V1", "I", EShLangAll },
{ "GroupMemoryBarrier", nullptr, nullptr, "-", "-", EShLangComputeMask },
{ "GroupMemoryBarrierWithGroupSync", nullptr, nullptr, "-", "-", EShLangComputeMask },
{ "InterlockedAdd", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedAdd", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedAnd", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedAnd", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedCompareExchange", "-", "-", "SVM,,,>", "UI,,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedCompareStore", "-", "-", "SVM,,", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedExchange", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedMax", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedMax", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedMin", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedMin", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedOr", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedOr", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedXor", "-", "-", "SVM,,>", "UI,,", EShLangFragmentMask | EShLangComputeMask },
{ "InterlockedXor", "-", "-", "SVM,", "UI,", EShLangFragmentMask | EShLangComputeMask },
{ "isfinite", nullptr, "B" , "SVM", "F", EShLangAll },
{ "isinf", nullptr, "B" , "SVM", "F", EShLangAll },
{ "isnan", nullptr, "B" , "SVM", "F", EShLangAll },
{ "ldexp", nullptr, nullptr, "SVM,", "F,", EShLangAll },
{ "length", "S", "F", "V", "F", EShLangAll },
{ "lerp", nullptr, nullptr, "SVM,,", "F,,", EShLangAll },
{ "lit", "V4", "F", "S,,", "F,,", EShLangAll },
{ "log", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "log10", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "log2", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "mad", nullptr, nullptr, "SVM,,", "DFUI,,", EShLangAll },
{ "max", nullptr, nullptr, "SVM,", "FI,", EShLangAll },
{ "min", nullptr, nullptr, "SVM,", "FI,", EShLangAll },
{ "modf", nullptr, nullptr, "SVM,>", "FI,", EShLangAll },
{ "msad4", "V4", "U", "S,V2,V4", "U,,", EShLangAll },
{ "mul", "S", nullptr, "S,S", "FI,", EShLangAll },
{ "mul", "V", nullptr, "S,V", "FI,", EShLangAll },
{ "mul", "M", nullptr, "S,M", "FI,", EShLangAll },
{ "mul", "V", nullptr, "V,S", "FI,", EShLangAll },
{ "mul", "S", nullptr, "V,V", "FI,", EShLangAll },
{ "mul", "#V", nullptr, "V,M", "FI,", EShLangAll },
{ "mul", "M", nullptr, "M,S", "FI,", EShLangAll },
{ "mul", "V", nullptr, "M,#V", "FI,", EShLangAll },
// mat*mat form of mul is handled in createMatTimesMat()
{ "noise", "S", "F", "V", "F", EShLangFragmentMask },
{ "normalize", nullptr, nullptr, "V", "F", EShLangAll },
{ "pow", nullptr, nullptr, "SVM,", "F,", EShLangAll },
// { "printf", "-", "-", "", "", EShLangAll }, TODO: varargs
{ "Process2DQuadTessFactorsAvg", "-", "-", "V4,V2,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "Process2DQuadTessFactorsMax", "-", "-", "V4,V2,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "Process2DQuadTessFactorsMin", "-", "-", "V4,V2,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "ProcessIsolineTessFactors", "-", "-", "S,,>,>", "F,,,", EShLangTessControlMask },
{ "ProcessQuadTessFactorsAvg", "-", "-", "V4,S,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "ProcessQuadTessFactorsMax", "-", "-", "V4,S,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "ProcessQuadTessFactorsMin", "-", "-", "V4,S,>V4,>V2,>V2", "F,,,,", EShLangTessControlMask },
{ "ProcessTriTessFactorsAvg", "-", "-", "V3,S,>V3,>S,>S", "F,,,,", EShLangTessControlMask },
{ "ProcessTriTessFactorsMax", "-", "-", "V3,S,>V3,>S,>S", "F,,,,", EShLangTessControlMask },
{ "ProcessTriTessFactorsMin", "-", "-", "V3,S,>V3,>S,>S", "F,,,,", EShLangTessControlMask },
{ "radians", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "rcp", nullptr, nullptr, "SVM", "FD", EShLangAll },
{ "reflect", nullptr, nullptr, "V,", "F,", EShLangAll },
{ "refract", nullptr, nullptr, "V,V,S", "F,,", EShLangAll },
{ "reversebits", nullptr, nullptr, "SV", "U", EShLangAll },
{ "round", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "rsqrt", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "saturate", nullptr, nullptr , "SVM", "F", EShLangAll },
{ "sign", nullptr, nullptr, "SVM", "FI", EShLangAll },
{ "sin", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "sincos", "-", "-", "SVM,>,>", "F,,", EShLangAll },
{ "sinh", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "smoothstep", nullptr, nullptr, "SVM,,", "F,,", EShLangAll },
{ "sqrt", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "step", nullptr, nullptr, "SVM,", "F,", EShLangAll },
{ "tan", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "tanh", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "tex1D", "V4", "F", "V1,S", "S,F", EShLangFragmentMask },
{ "tex1D", "V4", "F", "V1,S,V1,V1", "S,F,F,F",EShLangFragmentMask },
{ "tex1Dbias", "V4", "F", "V1,V4", "S,F", EShLangFragmentMask },
{ "tex1Dgrad", "V4", "F", "V1,V1,V1,V1","S,F,F,F",EShLangFragmentMask },
{ "tex1Dlod", "V4", "F", "V1,V4", "S,F", EShLangFragmentMask },
{ "tex1Dproj", "V4", "F", "V1,V4", "S,F", EShLangFragmentMask },
{ "tex2D", "V4", "F", "V2,V2", "S,F", EShLangFragmentMask },
{ "tex2D", "V4", "F", "V2,V2,V2,V2","S,F,F,F",EShLangFragmentMask },
{ "tex2Dbias", "V4", "F", "V2,V4", "S,F", EShLangFragmentMask },
{ "tex2Dgrad", "V4", "F", "V2,V2,V2,V2","S,F,F,F",EShLangFragmentMask },
{ "tex2Dlod", "V4", "F", "V2,V4", "S,F", EShLangFragmentMask },
{ "tex2Dproj", "V4", "F", "V2,V4", "S,F", EShLangFragmentMask },
{ "tex3D", "V4", "F", "V3,V3", "S,F", EShLangFragmentMask },
{ "tex3D", "V4", "F", "V3,V3,V3,V3","S,F,F,F",EShLangFragmentMask },
{ "tex3Dbias", "V4", "F", "V3,V4", "S,F", EShLangFragmentMask },
{ "tex3Dgrad", "V4", "F", "V3,V3,V3,V3","S,F,F,F",EShLangFragmentMask },
{ "tex3Dlod", "V4", "F", "V3,V4", "S,F", EShLangFragmentMask },
{ "tex3Dproj", "V4", "F", "V3,V4", "S,F", EShLangFragmentMask },
{ "texCUBE", "V4", "F", "V4,V3", "S,F", EShLangFragmentMask },
{ "texCUBE", "V4", "F", "V4,V3,V3,V3","S,F,F,F",EShLangFragmentMask },
{ "texCUBEbias", "V4", "F", "V4,V4", "S,F", EShLangFragmentMask },
{ "texCUBEgrad", "V4", "F", "V4,V3,V3,V3","S,F,F,F",EShLangFragmentMask },
{ "texCUBElod", "V4", "F", "V4,V4", "S,F", EShLangFragmentMask },
{ "texCUBEproj", "V4", "F", "V4,V4", "S,F", EShLangFragmentMask },
{ "transpose", "^M", nullptr, "M", "F", EShLangAll },
{ "trunc", nullptr, nullptr, "SVM", "F", EShLangAll },
// Texture object methods. Return type can be overridden by shader declaration.
// !O = no offset, O = offset, !A = no array, A = array
{ "Sample", /*!O !A*/ "V4", nullptr, "%V,S,V", "FIU,S,F", EShLangFragmentMask },
{ "Sample", /* O !A*/ "V4", nullptr, "%V,S,V,V", "FIU,S,F,I", EShLangFragmentMask },
{ "Sample", /*!O A*/ "V4", nullptr, "@V,S,V", "FIU,S,F", EShLangFragmentMask },
{ "Sample", /* O A*/ "V4", nullptr, "@V,S,V,V", "FIU,S,F,I", EShLangFragmentMask },
{ "SampleBias", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
{ "SampleBias", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
{ "SampleBias", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
{ "SampleBias", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
// { "SampleCmp", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
// { "SampleCmp", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
// { "SampleCmp", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
// { "SampleCmp", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
// { "SampleCmpLevelZero", /*!O !A*/ "V4", nullptr, "%V,S,V", "FIU,S,F", EShLangFragmentMask },
// { "SampleCmpLevelZero", /* O !A*/ "V4", nullptr, "%V,S,V,V", "FIU,S,F,I", EShLangFragmentMask },
// { "SampleCmpLevelZero", /*!O A*/ "V4", nullptr, "@V,S,V", "FIU,S,F", EShLangFragmentMask },
// { "SampleCmpLevelZero", /* O A*/ "V4", nullptr, "@V,S,V,V", "FIU,S,F,I", EShLangFragmentMask },
{ "SampleGrad", /*!O !A*/ "V4", nullptr, "%V,S,V,V,V", "FIU,S,F,F,F", EShLangAll },
{ "SampleGrad", /* O !A*/ "V4", nullptr, "%V,S,V,V,V,V", "FIU,S,F,F,F,I", EShLangAll },
{ "SampleGrad", /*!O A*/ "V4", nullptr, "@V,S,V,V,V", "FIU,S,F,F,F", EShLangAll },
{ "SampleGrad", /* O A*/ "V4", nullptr, "@V,S,V,V,V,V", "FIU,S,F,F,F,I", EShLangAll },
// { "SampleLevel", /*!O !A*/ "V4", nullptr, "%V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
// { "SampleLevel", /* O !A*/ "V4", nullptr, "%V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
// { "SampleLevel", /*!O A*/ "V4", nullptr, "@V,S,V,S", "FIU,S,F,F", EShLangFragmentMask },
// { "SampleLevel", /* O A*/ "V4", nullptr, "@V,S,V,S,V", "FIU,S,F,F,I", EShLangFragmentMask },
// TODO: ...
// { "Load", "V4", nullptr, "%V,V", "FIU,I", EShLangFragmentMask },
// { "Load", /* +sampleidex*/ "V4", nullptr, "%V,V,S", "FIU,I,I", EShLangFragmentMask },
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "%V,V,S,V", "FIU,I,I,I", EShLangFragmentMask },
// { "Load", "V4", nullptr, "@V,V", "FIU,I", EShLangFragmentMask },
// { "Load", /* +sampleidex*/ "V4", nullptr, "@V,V,S", "FIU,I,I", EShLangFragmentMask },
// { "Load", /* +samplindex, offset*/ "V4", nullptr, "@V,V,S,V", "FIU,I,I,I", EShLangFragmentMask },
// Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet.
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 },
};
// Set this to true to avoid generating prototypes that will be invalid for the GLSL parser.
// TODO: turn it off (and remove the code) when the HLSL parser can be used to parse builtins.
static const bool skipInvalidGlsl = true;
// Create prototypes for the intrinsics. TODO: Avoid ranged based for until all compilers can handle it.
for (int icount = 0; hlslIntrinsics[icount].name; ++icount) {
const auto& intrinsic = hlslIntrinsics[icount];
for (int stage = 0; stage < EShLangCount; ++stage) { // for each stage...
if ((intrinsic.stage & (1<<stage)) == 0) // skip inapplicable stages
continue;
// reference to either the common builtins, or stage specific builtins.
TString& s = (intrinsic.stage == EShLangAll) ? commonBuiltins : stageBuiltins[stage];
for (const char* argOrder = intrinsic.argOrder; !IsEndOfArg(argOrder); ++argOrder) { // for each order...
const bool isTexture = IsTextureType(*argOrder);
const bool isArrayed = IsTextureArrayed(*argOrder);
const int fixedVecSize = isdigit(argOrder[1]) ? (argOrder[1] - '0') : 0;
// calculate min and max vector and matrix dimensions
int dim0Min = 1;
int dim0Max = 1;
int dim1Min = 1;
int dim1Max = 1;
FindVectorMatrixBounds(argOrder, fixedVecSize, dim0Min, dim0Max, dim1Min, dim1Max);
for (const char* argType = intrinsic.argType; !IsEndOfArg(argType); ++argType) { // for each type...
for (int dim0 = dim0Min; dim0 <= dim0Max; ++dim0) { // for each dim 0...
for (int dim1 = dim1Min; dim1 <= dim1Max; ++dim1) { // for each dim 1...
const char* retOrder = intrinsic.retOrder ? intrinsic.retOrder : argOrder;
const char* retType = intrinsic.retType ? intrinsic.retType : argType;
if (skipInvalidGlsl && !IsValidGlsl(intrinsic.name, *retOrder, *retType, *argOrder, *argType,
dim0, dim1, dim0Max, dim1Max))
continue;
// Reject some forms of sample methods that don't exist.
if (isTexture && IsIllegalSample(intrinsic.name, argOrder, dim0))
continue;
AppendTypeName(s, retOrder, retType, dim0, dim1); // add return type
s.append(" "); // space between type and name
s.append(intrinsic.name); // intrinsic name
s.append("("); // open paren
// Append argument types, if any.
for (int arg = 0; ; ++arg) {
const char* nthArgOrder(NthArg(argOrder, arg));
const char* nthArgType(NthArg(argType, arg));
if (nthArgOrder == nullptr || nthArgType == nullptr)
break;
// cube textures use vec3 coordinates
int argDim0 = isTexture && arg > 0 ? std::min(dim0, 3) : dim0;
// arrayed textures have one extra coordinate dimension
if (isArrayed && arg == 2)
argDim0++;
// For textures, the 1D case isn't a 1-vector, but a scalar.
if (isTexture && argDim0 == 1 && arg > 0 && *nthArgOrder == 'V')
nthArgOrder = "S";
s.append(arg > 0 ? ", ": ""); // comma separator if needed
if (*nthArgOrder == '>') { // output params
++nthArgOrder;
s.append("out ");
} else if (*nthArgOrder == '<') { // input params
++nthArgOrder;
s.append("in ");
}
// Comma means use the 1st argument order and type.
if (*nthArgOrder == ',' || *nthArgOrder == '\0') nthArgOrder = argOrder;
if (*nthArgType == ',' || *nthArgType == '\0') nthArgType = argType;
AppendTypeName(s, nthArgOrder, nthArgType, argDim0, dim1); // Add arguments
}
s.append(");\n"); // close paren and trailing semicolon
}
}
}
if (fixedVecSize > 0 || isTexture) // skip over special characters
++argOrder;
}
if (intrinsic.stage == EShLangAll) // common builtins are only added once.
break;
}
}
createMatTimesMat(); // handle this case separately, for convenience
// printf("Common:\n%s\n", getCommonString().c_str());
// printf("Frag:\n%s\n", getStageString(EShLangFragment).c_str());
// printf("Vertex:\n%s\n", getStageString(EShLangVertex).c_str());
// printf("Geo:\n%s\n", getStageString(EShLangGeometry).c_str());
// printf("TessCtrl:\n%s\n", getStageString(EShLangTessControl).c_str());
// printf("TessEval:\n%s\n", getStageString(EShLangTessEvaluation).c_str());
// printf("Compute:\n%s\n", getStageString(EShLangCompute).c_str());
}
//
// Add context-dependent built-in functions and variables that are present
// for the given version and profile. All the results are put into just the
// commonBuiltins, because it is called for just a specific stage. So,
// add stage-specific entries to the commonBuiltins, and only if that stage
// was requested.
//
void TBuiltInParseablesHlsl::initialize(const TBuiltInResource& /*resources*/, int /*version*/, EProfile /*profile*/,
const SpvVersion& /*spvVersion*/, EShLanguage /*language*/)
{
}
//
// Finish adding/processing context-independent built-in symbols.
// 1) Programmatically add symbols that could not be added by simple text strings above.
// 2) Map built-in functions to operators, for those that will turn into an operation node
// instead of remaining a function call.
// 3) Tag extension-related symbols added to their base version with their extensions, so
// that if an early version has the extension turned off, there is an error reported on use.
//
void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/, EShLanguage /*language*/,
TSymbolTable& symbolTable)
{
// symbolTable.relateToOperator("abort", EOpAbort);
symbolTable.relateToOperator("abs", EOpAbs);
symbolTable.relateToOperator("acos", EOpAcos);
symbolTable.relateToOperator("all", EOpAll);
symbolTable.relateToOperator("AllMemoryBarrier", EOpMemoryBarrier);
symbolTable.relateToOperator("AllMemoryBarrierWithGroupSync", EOpAllMemoryBarrierWithGroupSync);
symbolTable.relateToOperator("any", EOpAny);
symbolTable.relateToOperator("asdouble", EOpAsDouble);
symbolTable.relateToOperator("asfloat", EOpIntBitsToFloat);
symbolTable.relateToOperator("asin", EOpAsin);
symbolTable.relateToOperator("asint", EOpFloatBitsToInt);
symbolTable.relateToOperator("asuint", EOpFloatBitsToUint);
symbolTable.relateToOperator("atan", EOpAtan);
symbolTable.relateToOperator("atan2", EOpAtan);
symbolTable.relateToOperator("ceil", EOpCeil);
// symbolTable.relateToOperator("CheckAccessFullyMapped");
symbolTable.relateToOperator("clamp", EOpClamp);
symbolTable.relateToOperator("clip", EOpClip);
symbolTable.relateToOperator("cos", EOpCos);
symbolTable.relateToOperator("cosh", EOpCosh);
symbolTable.relateToOperator("countbits", EOpBitCount);
symbolTable.relateToOperator("cross", EOpCross);
// symbolTable.relateToOperator("D3DCOLORtoUBYTE4", EOpD3DCOLORtoUBYTE4);
symbolTable.relateToOperator("ddx", EOpDPdx);
symbolTable.relateToOperator("ddx_coarse", EOpDPdxCoarse);
symbolTable.relateToOperator("ddx_fine", EOpDPdxFine);
symbolTable.relateToOperator("ddy", EOpDPdy);
symbolTable.relateToOperator("ddy_coarse", EOpDPdyCoarse);
symbolTable.relateToOperator("ddy_fine", EOpDPdyFine);
symbolTable.relateToOperator("degrees", EOpDegrees);
symbolTable.relateToOperator("determinant", EOpDeterminant);
symbolTable.relateToOperator("DeviceMemoryBarrier", EOpGroupMemoryBarrier);
symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync", EOpGroupMemoryBarrierWithGroupSync); // ...
symbolTable.relateToOperator("distance", EOpDistance);
symbolTable.relateToOperator("dot", EOpDot);
symbolTable.relateToOperator("dst", EOpDst);
// symbolTable.relateToOperator("errorf", EOpErrorf);
symbolTable.relateToOperator("EvaluateAttributeAtCentroid", EOpInterpolateAtCentroid);
symbolTable.relateToOperator("EvaluateAttributeAtSample", EOpInterpolateAtSample);
symbolTable.relateToOperator("EvaluateAttributeSnapped", EOpEvaluateAttributeSnapped);
symbolTable.relateToOperator("exp", EOpExp);
symbolTable.relateToOperator("exp2", EOpExp2);
symbolTable.relateToOperator("f16tof32", EOpF16tof32);
symbolTable.relateToOperator("f32tof16", EOpF32tof16);
symbolTable.relateToOperator("faceforward", EOpFaceForward);
symbolTable.relateToOperator("firstbithigh", EOpFindMSB);
symbolTable.relateToOperator("firstbitlow", EOpFindLSB);
symbolTable.relateToOperator("floor", EOpFloor);
symbolTable.relateToOperator("fma", EOpFma);
symbolTable.relateToOperator("fmod", EOpMod);
symbolTable.relateToOperator("frac", EOpFract);
symbolTable.relateToOperator("frexp", EOpFrexp);
symbolTable.relateToOperator("fwidth", EOpFwidth);
// symbolTable.relateToOperator("GetRenderTargetSampleCount");
// symbolTable.relateToOperator("GetRenderTargetSamplePosition");
symbolTable.relateToOperator("GroupMemoryBarrier", EOpWorkgroupMemoryBarrier);
symbolTable.relateToOperator("GroupMemoryBarrierWithGroupSync", EOpWorkgroupMemoryBarrierWithGroupSync);
symbolTable.relateToOperator("InterlockedAdd", EOpInterlockedAdd);
symbolTable.relateToOperator("InterlockedAnd", EOpInterlockedAnd);
symbolTable.relateToOperator("InterlockedCompareExchange", EOpInterlockedCompareExchange);
symbolTable.relateToOperator("InterlockedCompareStore", EOpInterlockedCompareStore);
symbolTable.relateToOperator("InterlockedExchange", EOpInterlockedExchange);
symbolTable.relateToOperator("InterlockedMax", EOpInterlockedMax);
symbolTable.relateToOperator("InterlockedMin", EOpInterlockedMin);
symbolTable.relateToOperator("InterlockedOr", EOpInterlockedOr);
symbolTable.relateToOperator("InterlockedXor", EOpInterlockedXor);
symbolTable.relateToOperator("isfinite", EOpIsFinite);
symbolTable.relateToOperator("isinf", EOpIsInf);
symbolTable.relateToOperator("isnan", EOpIsNan);
symbolTable.relateToOperator("ldexp", EOpLdexp);
symbolTable.relateToOperator("length", EOpLength);
symbolTable.relateToOperator("lerp", EOpMix);
symbolTable.relateToOperator("lit", EOpLit);
symbolTable.relateToOperator("log", EOpLog);
symbolTable.relateToOperator("log10", EOpLog10);
symbolTable.relateToOperator("log2", EOpLog2);
symbolTable.relateToOperator("mad", EOpFma);
symbolTable.relateToOperator("max", EOpMax);
symbolTable.relateToOperator("min", EOpMin);
symbolTable.relateToOperator("modf", EOpModf);
// symbolTable.relateToOperator("msad4", EOpMsad4);
symbolTable.relateToOperator("mul", EOpGenMul);
// symbolTable.relateToOperator("noise", EOpNoise); // TODO: check return type
symbolTable.relateToOperator("normalize", EOpNormalize);
symbolTable.relateToOperator("pow", EOpPow);
// symbolTable.relateToOperator("printf", EOpPrintf);
// symbolTable.relateToOperator("Process2DQuadTessFactorsAvg");
// symbolTable.relateToOperator("Process2DQuadTessFactorsMax");
// symbolTable.relateToOperator("Process2DQuadTessFactorsMin");
// symbolTable.relateToOperator("ProcessIsolineTessFactors");
// symbolTable.relateToOperator("ProcessQuadTessFactorsAvg");
// symbolTable.relateToOperator("ProcessQuadTessFactorsMax");
// symbolTable.relateToOperator("ProcessQuadTessFactorsMin");
// symbolTable.relateToOperator("ProcessTriTessFactorsAvg");
// symbolTable.relateToOperator("ProcessTriTessFactorsMax");
// symbolTable.relateToOperator("ProcessTriTessFactorsMin");
symbolTable.relateToOperator("radians", EOpRadians);
symbolTable.relateToOperator("rcp", EOpRcp);
symbolTable.relateToOperator("reflect", EOpReflect);
symbolTable.relateToOperator("refract", EOpRefract);
symbolTable.relateToOperator("reversebits", EOpBitFieldReverse);
symbolTable.relateToOperator("round", EOpRoundEven);
symbolTable.relateToOperator("rsqrt", EOpInverseSqrt);
symbolTable.relateToOperator("saturate", EOpSaturate);
symbolTable.relateToOperator("sign", EOpSign);
symbolTable.relateToOperator("sin", EOpSin);
symbolTable.relateToOperator("sincos", EOpSinCos);
symbolTable.relateToOperator("sinh", EOpSinh);
symbolTable.relateToOperator("smoothstep", EOpSmoothStep);
symbolTable.relateToOperator("sqrt", EOpSqrt);
symbolTable.relateToOperator("step", EOpStep);
symbolTable.relateToOperator("tan", EOpTan);
symbolTable.relateToOperator("tanh", EOpTanh);
symbolTable.relateToOperator("tex1D", EOpTexture);
symbolTable.relateToOperator("tex1Dbias", EOpTextureBias);
symbolTable.relateToOperator("tex1Dgrad", EOpTextureGrad);
symbolTable.relateToOperator("tex1Dlod", EOpTextureLod);
symbolTable.relateToOperator("tex1Dproj", EOpTextureProj);
symbolTable.relateToOperator("tex2D", EOpTexture);
symbolTable.relateToOperator("tex2Dbias", EOpTextureBias);
symbolTable.relateToOperator("tex2Dgrad", EOpTextureGrad);
symbolTable.relateToOperator("tex2Dlod", EOpTextureLod);
symbolTable.relateToOperator("tex2Dproj", EOpTextureProj);
symbolTable.relateToOperator("tex3D", EOpTexture);
symbolTable.relateToOperator("tex3Dbias", EOpTextureBias);
symbolTable.relateToOperator("tex3Dgrad", EOpTextureGrad);
symbolTable.relateToOperator("tex3Dlod", EOpTextureLod);
symbolTable.relateToOperator("tex3Dproj", EOpTextureProj);
symbolTable.relateToOperator("texCUBE", EOpTexture);
symbolTable.relateToOperator("texCUBEbias", EOpTextureBias);
symbolTable.relateToOperator("texCUBEgrad", EOpTextureGrad);
symbolTable.relateToOperator("texCUBElod", EOpTextureLod);
symbolTable.relateToOperator("texCUBEproj", EOpTextureProj);
symbolTable.relateToOperator("transpose", EOpTranspose);
symbolTable.relateToOperator("trunc", EOpTrunc);
// Texture methods
symbolTable.relateToOperator("Sample", EOpMethodSample);
symbolTable.relateToOperator("SampleBias", EOpMethodSampleBias);
// symbolTable.relateToOperator("SampleCmp", EOpMethodSampleCmp);
// symbolTable.relateToOperator("SampleCmpLevelZero", EOpMethodSampleCmpLevelZero);
symbolTable.relateToOperator("SampleGrad", EOpMethodSampleGrad);
// symbolTable.relateToOperator("SampleLevel", EOpMethodSampleLevel);
// symbolTable.relateToOperator("Load", EOpMethodLoad);
}
//
// Add context-dependent (resource-specific) built-ins not handled by the above. These
// would be ones that need to be programmatically added because they cannot
// be added by simple text strings. For these, also
// 1) Map built-in functions to operators, for those that will turn into an operation node
// instead of remaining a function call.
// 2) Tag extension-related symbols added to their base version with their extensions, so
// that if an early version has the extension turned off, there is an error reported on use.
//
void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profile*/, const SpvVersion& /*spvVersion*/, EShLanguage /*language*/,
TSymbolTable& /*symbolTable*/, const TBuiltInResource& /*resources*/)
{
}
} // end namespace glslang

64
Externals/glslang/hlsl/hlslParseables.h vendored Executable file
View File

@ -0,0 +1,64 @@
//
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 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.
//
#ifndef _HLSLPARSEABLES_INCLUDED_
#define _HLSLPARSEABLES_INCLUDED_
#include "../glslang/MachineIndependent/Initialize.h"
namespace glslang {
//
// This is an HLSL specific derivation of TBuiltInParseables. See comment
// above TBuiltInParseables for details.
//
class TBuiltInParseablesHlsl : public TBuiltInParseables {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TBuiltInParseablesHlsl();
void initialize(int version, EProfile, const SpvVersion& spvVersion);
void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
private:
void createMatTimesMat();
};
} // end namespace glslang
#endif // _HLSLPARSEABLES_INCLUDED_

648
Externals/glslang/hlsl/hlslScanContext.cpp vendored Executable file
View File

@ -0,0 +1,648 @@
//
//Copyright (C) 2016 Google, Inc.
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
//
// HLSL scanning, leveraging the scanning done by the preprocessor.
//
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include "../glslang/Include/Types.h"
#include "../glslang/MachineIndependent/SymbolTable.h"
#include "../glslang/MachineIndependent/ParseHelper.h"
#include "hlslScanContext.h"
#include "hlslTokens.h"
//#include "Scan.h"
// preprocessor includes
#include "../glslang/MachineIndependent/preprocessor/PpContext.h"
#include "../glslang/MachineIndependent/preprocessor/PpTokens.h"
namespace {
struct str_eq
{
bool operator()(const char* lhs, const char* rhs) const
{
return strcmp(lhs, rhs) == 0;
}
};
struct str_hash
{
size_t operator()(const char* str) const
{
// djb2
unsigned long hash = 5381;
int c;
while ((c = *str++) != 0)
hash = ((hash << 5) + hash) + c;
return hash;
}
};
// A single global usable by all threads, by all versions, by all languages.
// After a single process-level initialization, this is read only and thread safe
std::unordered_map<const char*, glslang::EHlslTokenClass, str_hash, str_eq>* KeywordMap = nullptr;
std::unordered_set<const char*, str_hash, str_eq>* ReservedSet = nullptr;
};
namespace glslang {
void HlslScanContext::fillInKeywordMap()
{
if (KeywordMap != nullptr) {
// this is really an error, as this should called only once per process
// but, the only risk is if two threads called simultaneously
return;
}
KeywordMap = new std::unordered_map<const char*, EHlslTokenClass, str_hash, str_eq>;
(*KeywordMap)["static"] = EHTokStatic;
(*KeywordMap)["const"] = EHTokConst;
(*KeywordMap)["unorm"] = EHTokUnorm;
(*KeywordMap)["snorm"] = EHTokSNorm;
(*KeywordMap)["extern"] = EHTokExtern;
(*KeywordMap)["uniform"] = EHTokUniform;
(*KeywordMap)["volatile"] = EHTokVolatile;
(*KeywordMap)["precise"] = EHTokPrecise;
(*KeywordMap)["shared"] = EHTokShared;
(*KeywordMap)["groupshared"] = EHTokGroupShared;
(*KeywordMap)["linear"] = EHTokLinear;
(*KeywordMap)["centroid"] = EHTokCentroid;
(*KeywordMap)["nointerpolation"] = EHTokNointerpolation;
(*KeywordMap)["noperspective"] = EHTokNoperspective;
(*KeywordMap)["sample"] = EHTokSample;
(*KeywordMap)["row_major"] = EHTokRowMajor;
(*KeywordMap)["column_major"] = EHTokColumnMajor;
(*KeywordMap)["packoffset"] = EHTokPackOffset;
(*KeywordMap)["in"] = EHTokIn;
(*KeywordMap)["out"] = EHTokOut;
(*KeywordMap)["inout"] = EHTokInOut;
(*KeywordMap)["Buffer"] = EHTokBuffer;
(*KeywordMap)["vector"] = EHTokVector;
(*KeywordMap)["matrix"] = EHTokMatrix;
(*KeywordMap)["void"] = EHTokVoid;
(*KeywordMap)["bool"] = EHTokBool;
(*KeywordMap)["int"] = EHTokInt;
(*KeywordMap)["uint"] = EHTokUint;
(*KeywordMap)["dword"] = EHTokDword;
(*KeywordMap)["half"] = EHTokHalf;
(*KeywordMap)["float"] = EHTokFloat;
(*KeywordMap)["double"] = EHTokDouble;
(*KeywordMap)["min16float"] = EHTokMin16float;
(*KeywordMap)["min10float"] = EHTokMin10float;
(*KeywordMap)["min16int"] = EHTokMin16int;
(*KeywordMap)["min12int"] = EHTokMin12int;
(*KeywordMap)["min16uint"] = EHTokMin16int;
(*KeywordMap)["bool1"] = EHTokBool1;
(*KeywordMap)["bool2"] = EHTokBool2;
(*KeywordMap)["bool3"] = EHTokBool3;
(*KeywordMap)["bool4"] = EHTokBool4;
(*KeywordMap)["float1"] = EHTokFloat1;
(*KeywordMap)["float2"] = EHTokFloat2;
(*KeywordMap)["float3"] = EHTokFloat3;
(*KeywordMap)["float4"] = EHTokFloat4;
(*KeywordMap)["int1"] = EHTokInt1;
(*KeywordMap)["int2"] = EHTokInt2;
(*KeywordMap)["int3"] = EHTokInt3;
(*KeywordMap)["int4"] = EHTokInt4;
(*KeywordMap)["double1"] = EHTokDouble1;
(*KeywordMap)["double2"] = EHTokDouble2;
(*KeywordMap)["double3"] = EHTokDouble3;
(*KeywordMap)["double4"] = EHTokDouble4;
(*KeywordMap)["uint1"] = EHTokUint1;
(*KeywordMap)["uint2"] = EHTokUint2;
(*KeywordMap)["uint3"] = EHTokUint3;
(*KeywordMap)["uint4"] = EHTokUint4;
(*KeywordMap)["int1x1"] = EHTokInt1x1;
(*KeywordMap)["int1x2"] = EHTokInt1x2;
(*KeywordMap)["int1x3"] = EHTokInt1x3;
(*KeywordMap)["int1x4"] = EHTokInt1x4;
(*KeywordMap)["int2x1"] = EHTokInt2x1;
(*KeywordMap)["int2x2"] = EHTokInt2x2;
(*KeywordMap)["int2x3"] = EHTokInt2x3;
(*KeywordMap)["int2x4"] = EHTokInt2x4;
(*KeywordMap)["int3x1"] = EHTokInt3x1;
(*KeywordMap)["int3x2"] = EHTokInt3x2;
(*KeywordMap)["int3x3"] = EHTokInt3x3;
(*KeywordMap)["int3x4"] = EHTokInt3x4;
(*KeywordMap)["int4x1"] = EHTokInt4x1;
(*KeywordMap)["int4x2"] = EHTokInt4x2;
(*KeywordMap)["int4x3"] = EHTokInt4x3;
(*KeywordMap)["int4x4"] = EHTokInt4x4;
(*KeywordMap)["uint1x1"] = EHTokUint1x1;
(*KeywordMap)["uint1x2"] = EHTokUint1x2;
(*KeywordMap)["uint1x3"] = EHTokUint1x3;
(*KeywordMap)["uint1x4"] = EHTokUint1x4;
(*KeywordMap)["uint2x1"] = EHTokUint2x1;
(*KeywordMap)["uint2x2"] = EHTokUint2x2;
(*KeywordMap)["uint2x3"] = EHTokUint2x3;
(*KeywordMap)["uint2x4"] = EHTokUint2x4;
(*KeywordMap)["uint3x1"] = EHTokUint3x1;
(*KeywordMap)["uint3x2"] = EHTokUint3x2;
(*KeywordMap)["uint3x3"] = EHTokUint3x3;
(*KeywordMap)["uint3x4"] = EHTokUint3x4;
(*KeywordMap)["uint4x1"] = EHTokUint4x1;
(*KeywordMap)["uint4x2"] = EHTokUint4x2;
(*KeywordMap)["uint4x3"] = EHTokUint4x3;
(*KeywordMap)["uint4x4"] = EHTokUint4x4;
(*KeywordMap)["bool1x1"] = EHTokBool1x1;
(*KeywordMap)["bool1x2"] = EHTokBool1x2;
(*KeywordMap)["bool1x3"] = EHTokBool1x3;
(*KeywordMap)["bool1x4"] = EHTokBool1x4;
(*KeywordMap)["bool2x1"] = EHTokBool2x1;
(*KeywordMap)["bool2x2"] = EHTokBool2x2;
(*KeywordMap)["bool2x3"] = EHTokBool2x3;
(*KeywordMap)["bool2x4"] = EHTokBool2x4;
(*KeywordMap)["bool3x1"] = EHTokBool3x1;
(*KeywordMap)["bool3x2"] = EHTokBool3x2;
(*KeywordMap)["bool3x3"] = EHTokBool3x3;
(*KeywordMap)["bool3x4"] = EHTokBool3x4;
(*KeywordMap)["bool4x1"] = EHTokBool4x1;
(*KeywordMap)["bool4x2"] = EHTokBool4x2;
(*KeywordMap)["bool4x3"] = EHTokBool4x3;
(*KeywordMap)["bool4x4"] = EHTokBool4x4;
(*KeywordMap)["float1x1"] = EHTokFloat1x1;
(*KeywordMap)["float1x2"] = EHTokFloat1x2;
(*KeywordMap)["float1x3"] = EHTokFloat1x3;
(*KeywordMap)["float1x4"] = EHTokFloat1x4;
(*KeywordMap)["float2x1"] = EHTokFloat2x1;
(*KeywordMap)["float2x2"] = EHTokFloat2x2;
(*KeywordMap)["float2x3"] = EHTokFloat2x3;
(*KeywordMap)["float2x4"] = EHTokFloat2x4;
(*KeywordMap)["float3x1"] = EHTokFloat3x1;
(*KeywordMap)["float3x2"] = EHTokFloat3x2;
(*KeywordMap)["float3x3"] = EHTokFloat3x3;
(*KeywordMap)["float3x4"] = EHTokFloat3x4;
(*KeywordMap)["float4x1"] = EHTokFloat4x1;
(*KeywordMap)["float4x2"] = EHTokFloat4x2;
(*KeywordMap)["float4x3"] = EHTokFloat4x3;
(*KeywordMap)["float4x4"] = EHTokFloat4x4;
(*KeywordMap)["double1x1"] = EHTokDouble1x1;
(*KeywordMap)["double1x2"] = EHTokDouble1x2;
(*KeywordMap)["double1x3"] = EHTokDouble1x3;
(*KeywordMap)["double1x4"] = EHTokDouble1x4;
(*KeywordMap)["double2x1"] = EHTokDouble2x1;
(*KeywordMap)["double2x2"] = EHTokDouble2x2;
(*KeywordMap)["double2x3"] = EHTokDouble2x3;
(*KeywordMap)["double2x4"] = EHTokDouble2x4;
(*KeywordMap)["double3x1"] = EHTokDouble3x1;
(*KeywordMap)["double3x2"] = EHTokDouble3x2;
(*KeywordMap)["double3x3"] = EHTokDouble3x3;
(*KeywordMap)["double3x4"] = EHTokDouble3x4;
(*KeywordMap)["double4x1"] = EHTokDouble4x1;
(*KeywordMap)["double4x2"] = EHTokDouble4x2;
(*KeywordMap)["double4x3"] = EHTokDouble4x3;
(*KeywordMap)["double4x4"] = EHTokDouble4x4;
(*KeywordMap)["sampler"] = EHTokSampler;
(*KeywordMap)["sampler1D"] = EHTokSampler1d;
(*KeywordMap)["sampler2D"] = EHTokSampler2d;
(*KeywordMap)["sampler3D"] = EHTokSampler3d;
(*KeywordMap)["samplerCube"] = EHTokSamplerCube;
(*KeywordMap)["sampler_state"] = EHTokSamplerState;
(*KeywordMap)["SamplerState"] = EHTokSamplerState;
(*KeywordMap)["SamplerComparisonState"] = EHTokSamplerComparisonState;
(*KeywordMap)["texture"] = EHTokTexture;
(*KeywordMap)["Texture1D"] = EHTokTexture1d;
(*KeywordMap)["Texture1DArray"] = EHTokTexture1darray;
(*KeywordMap)["Texture2D"] = EHTokTexture2d;
(*KeywordMap)["Texture2DArray"] = EHTokTexture2darray;
(*KeywordMap)["Texture3D"] = EHTokTexture3d;
(*KeywordMap)["TextureCube"] = EHTokTextureCube;
(*KeywordMap)["TextureCubeArray"] = EHTokTextureCubearray;
(*KeywordMap)["Texture2DMS"] = EHTokTexture2DMS;
(*KeywordMap)["Texture2DMSArray"] = EHTokTexture2DMSarray;
(*KeywordMap)["struct"] = EHTokStruct;
(*KeywordMap)["typedef"] = EHTokTypedef;
(*KeywordMap)["true"] = EHTokBoolConstant;
(*KeywordMap)["false"] = EHTokBoolConstant;
(*KeywordMap)["for"] = EHTokFor;
(*KeywordMap)["do"] = EHTokDo;
(*KeywordMap)["while"] = EHTokWhile;
(*KeywordMap)["break"] = EHTokBreak;
(*KeywordMap)["continue"] = EHTokContinue;
(*KeywordMap)["if"] = EHTokIf;
(*KeywordMap)["else"] = EHTokElse;
(*KeywordMap)["discard"] = EHTokDiscard;
(*KeywordMap)["return"] = EHTokReturn;
(*KeywordMap)["switch"] = EHTokSwitch;
(*KeywordMap)["case"] = EHTokCase;
(*KeywordMap)["default"] = EHTokDefault;
// TODO: get correct set here
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
ReservedSet->insert("auto");
ReservedSet->insert("catch");
ReservedSet->insert("char");
ReservedSet->insert("class");
ReservedSet->insert("const_cast");
ReservedSet->insert("enum");
ReservedSet->insert("explicit");
ReservedSet->insert("friend");
ReservedSet->insert("goto");
ReservedSet->insert("long");
ReservedSet->insert("mutable");
ReservedSet->insert("new");
ReservedSet->insert("operator");
ReservedSet->insert("private");
ReservedSet->insert("protected");
ReservedSet->insert("public");
ReservedSet->insert("reinterpret_cast");
ReservedSet->insert("short");
ReservedSet->insert("signed");
ReservedSet->insert("sizeof");
ReservedSet->insert("static_cast");
ReservedSet->insert("template");
ReservedSet->insert("this");
ReservedSet->insert("throw");
ReservedSet->insert("try");
ReservedSet->insert("typename");
ReservedSet->insert("union");
ReservedSet->insert("unsigned");
ReservedSet->insert("using");
ReservedSet->insert("virtual");
}
void HlslScanContext::deleteKeywordMap()
{
delete KeywordMap;
KeywordMap = nullptr;
delete ReservedSet;
ReservedSet = nullptr;
}
// Wrapper for tokenizeClass()"] = to get everything inside the token.
void HlslScanContext::tokenize(HlslToken& token)
{
EHlslTokenClass tokenClass = tokenizeClass(token);
token.tokenClass = tokenClass;
}
//
// Fill in token information for the next token, except for the token class.
// Returns the enum value of the token class of the next token found.
// Return 0 (EndOfTokens) on end of input.
//
EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token)
{
do {
parserToken = &token;
TPpToken ppToken;
tokenText = ppContext.tokenize(&ppToken);
if (tokenText == nullptr)
return EHTokNone;
loc = ppToken.loc;
parserToken->loc = loc;
switch (ppToken.token) {
case ';': return EHTokSemicolon;
case ',': return EHTokComma;
case ':': return EHTokColon;
case '=': return EHTokAssign;
case '(': return EHTokLeftParen;
case ')': return EHTokRightParen;
case '.': return EHTokDot;
case '!': return EHTokBang;
case '-': return EHTokDash;
case '~': return EHTokTilde;
case '+': return EHTokPlus;
case '*': return EHTokStar;
case '/': return EHTokSlash;
case '%': return EHTokPercent;
case '<': return EHTokLeftAngle;
case '>': return EHTokRightAngle;
case '|': return EHTokVerticalBar;
case '^': return EHTokCaret;
case '&': return EHTokAmpersand;
case '?': return EHTokQuestion;
case '[': return EHTokLeftBracket;
case ']': return EHTokRightBracket;
case '{': return EHTokLeftBrace;
case '}': return EHTokRightBrace;
case '\\':
parseContext.error(loc, "illegal use of escape character", "\\", "");
break;
case PpAtomAdd: return EHTokAddAssign;
case PpAtomSub: return EHTokSubAssign;
case PpAtomMul: return EHTokMulAssign;
case PpAtomDiv: return EHTokDivAssign;
case PpAtomMod: return EHTokModAssign;
case PpAtomRight: return EHTokRightOp;
case PpAtomLeft: return EHTokLeftOp;
case PpAtomRightAssign: return EHTokRightAssign;
case PpAtomLeftAssign: return EHTokLeftAssign;
case PpAtomAndAssign: return EHTokAndAssign;
case PpAtomOrAssign: return EHTokOrAssign;
case PpAtomXorAssign: return EHTokXorAssign;
case PpAtomAnd: return EHTokAndOp;
case PpAtomOr: return EHTokOrOp;
case PpAtomXor: return EHTokXorOp;
case PpAtomEQ: return EHTokEqOp;
case PpAtomGE: return EHTokGeOp;
case PpAtomNE: return EHTokNeOp;
case PpAtomLE: return EHTokLeOp;
case PpAtomDecrement: return EHTokDecOp;
case PpAtomIncrement: return EHTokIncOp;
case PpAtomConstInt: parserToken->i = ppToken.ival; return EHTokIntConstant;
case PpAtomConstUint: parserToken->i = ppToken.ival; return EHTokUintConstant;
case PpAtomConstFloat: parserToken->d = ppToken.dval; return EHTokFloatConstant;
case PpAtomConstDouble: parserToken->d = ppToken.dval; return EHTokDoubleConstant;
case PpAtomIdentifier:
{
EHlslTokenClass token = tokenizeIdentifier();
return token;
}
case EndOfInput: return EHTokNone;
default:
char buf[2];
buf[0] = (char)ppToken.token;
buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
break;
}
} while (true);
}
EHlslTokenClass HlslScanContext::tokenizeIdentifier()
{
if (ReservedSet->find(tokenText) != ReservedSet->end())
return reservedWord();
auto it = KeywordMap->find(tokenText);
if (it == KeywordMap->end()) {
// Should have an identifier of some sort
return identifierOrType();
}
keyword = it->second;
switch (keyword) {
// qualifiers
case EHTokStatic:
case EHTokConst:
case EHTokSNorm:
case EHTokUnorm:
case EHTokExtern:
case EHTokUniform:
case EHTokVolatile:
case EHTokShared:
case EHTokGroupShared:
case EHTokLinear:
case EHTokCentroid:
case EHTokNointerpolation:
case EHTokNoperspective:
case EHTokSample:
case EHTokRowMajor:
case EHTokColumnMajor:
case EHTokPackOffset:
case EHTokIn:
case EHTokOut:
case EHTokInOut:
return keyword;
// template types
case EHTokBuffer:
case EHTokVector:
case EHTokMatrix:
return keyword;
// scalar types
case EHTokVoid:
case EHTokBool:
case EHTokInt:
case EHTokUint:
case EHTokDword:
case EHTokHalf:
case EHTokFloat:
case EHTokDouble:
case EHTokMin16float:
case EHTokMin10float:
case EHTokMin16int:
case EHTokMin12int:
case EHTokMin16uint:
// vector types
case EHTokBool1:
case EHTokBool2:
case EHTokBool3:
case EHTokBool4:
case EHTokFloat1:
case EHTokFloat2:
case EHTokFloat3:
case EHTokFloat4:
case EHTokInt1:
case EHTokInt2:
case EHTokInt3:
case EHTokInt4:
case EHTokDouble1:
case EHTokDouble2:
case EHTokDouble3:
case EHTokDouble4:
case EHTokUint1:
case EHTokUint2:
case EHTokUint3:
case EHTokUint4:
// matrix types
case EHTokInt1x1:
case EHTokInt1x2:
case EHTokInt1x3:
case EHTokInt1x4:
case EHTokInt2x1:
case EHTokInt2x2:
case EHTokInt2x3:
case EHTokInt2x4:
case EHTokInt3x1:
case EHTokInt3x2:
case EHTokInt3x3:
case EHTokInt3x4:
case EHTokInt4x1:
case EHTokInt4x2:
case EHTokInt4x3:
case EHTokInt4x4:
case EHTokFloat1x1:
case EHTokFloat1x2:
case EHTokFloat1x3:
case EHTokFloat1x4:
case EHTokFloat2x1:
case EHTokFloat2x2:
case EHTokFloat2x3:
case EHTokFloat2x4:
case EHTokFloat3x1:
case EHTokFloat3x2:
case EHTokFloat3x3:
case EHTokFloat3x4:
case EHTokFloat4x1:
case EHTokFloat4x2:
case EHTokFloat4x3:
case EHTokFloat4x4:
case EHTokDouble1x1:
case EHTokDouble1x2:
case EHTokDouble1x3:
case EHTokDouble1x4:
case EHTokDouble2x1:
case EHTokDouble2x2:
case EHTokDouble2x3:
case EHTokDouble2x4:
case EHTokDouble3x1:
case EHTokDouble3x2:
case EHTokDouble3x3:
case EHTokDouble3x4:
case EHTokDouble4x1:
case EHTokDouble4x2:
case EHTokDouble4x3:
case EHTokDouble4x4:
return keyword;
// texturing types
case EHTokSampler:
case EHTokSampler1d:
case EHTokSampler2d:
case EHTokSampler3d:
case EHTokSamplerCube:
case EHTokSamplerState:
case EHTokSamplerComparisonState:
case EHTokTexture:
case EHTokTexture1d:
case EHTokTexture1darray:
case EHTokTexture2d:
case EHTokTexture2darray:
case EHTokTexture3d:
case EHTokTextureCube:
case EHTokTextureCubearray:
case EHTokTexture2DMS:
case EHTokTexture2DMSarray:
return keyword;
// variable, user type, ...
case EHTokStruct:
case EHTokTypedef:
case EHTokBoolConstant:
if (strcmp("true", tokenText) == 0)
parserToken->b = true;
else
parserToken->b = false;
return keyword;
// control flow
case EHTokFor:
case EHTokDo:
case EHTokWhile:
case EHTokBreak:
case EHTokContinue:
case EHTokIf:
case EHTokElse:
case EHTokDiscard:
case EHTokReturn:
case EHTokCase:
case EHTokSwitch:
case EHTokDefault:
return keyword;
default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return EHTokNone;
}
}
EHlslTokenClass HlslScanContext::identifierOrType()
{
parserToken->string = NewPoolTString(tokenText);
return EHTokIdentifier;
}
// Give an error for use of a reserved symbol.
// However, allow built-in declarations to use reserved words, to allow
// extension support before the extension is enabled.
EHlslTokenClass HlslScanContext::reservedWord()
{
if (! parseContext.symbolTable.atBuiltInLevel())
parseContext.error(loc, "Reserved word.", tokenText, "", "");
return EHTokNone;
}
EHlslTokenClass HlslScanContext::identifierOrReserved(bool reserved)
{
if (reserved) {
reservedWord();
return EHTokNone;
}
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future reserved keyword", tokenText, "");
return identifierOrType();
}
// For a keyword that was never reserved, until it suddenly
// showed up.
EHlslTokenClass HlslScanContext::nonreservedKeyword(int version)
{
if (parseContext.version < version)
return identifierOrType();
return keyword;
}
} // end namespace glslang

109
Externals/glslang/hlsl/hlslScanContext.h vendored Executable file
View File

@ -0,0 +1,109 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
//
// This holds context specific to the HLSL scanner, which
// sits between the preprocessor scanner and HLSL parser.
//
#ifndef HLSLSCANCONTEXT_H_
#define HLSLSCANCONTEXT_H_
#include "../glslang/MachineIndependent/ParseHelper.h"
#include "hlslTokens.h"
namespace glslang {
class TPpContext;
class TPpToken;
//
// Everything needed to fully describe a token.
//
struct HlslToken {
HlslToken() : string(nullptr), symbol(nullptr) { loc.init(); }
TSourceLoc loc; // location of token in the source
EHlslTokenClass tokenClass; // what kind of token it is
union { // what data the token holds
glslang::TString *string; // for identifiers
int i; // for literals
unsigned int u;
bool b;
double d;
};
glslang::TSymbol* symbol; // if a symbol-table lookup was done already, this is the result
};
//
// The state of scanning and translating raw tokens to slightly richer
// semantics, like knowing if an identifier is an existing symbol, or
// user-defined type.
//
class HlslScanContext {
public:
HlslScanContext(TParseContextBase& parseContext, TPpContext& ppContext)
: parseContext(parseContext), ppContext(ppContext) { }
virtual ~HlslScanContext() { }
static void fillInKeywordMap();
static void deleteKeywordMap();
void tokenize(HlslToken&);
protected:
HlslScanContext(HlslScanContext&);
HlslScanContext& operator=(HlslScanContext&);
EHlslTokenClass tokenizeClass(HlslToken&);
EHlslTokenClass tokenizeIdentifier();
EHlslTokenClass identifierOrType();
EHlslTokenClass reservedWord();
EHlslTokenClass identifierOrReserved(bool reserved);
EHlslTokenClass nonreservedKeyword(int version);
TParseContextBase& parseContext;
TPpContext& ppContext;
TSourceLoc loc;
TPpToken* ppToken;
HlslToken* parserToken;
const char* tokenText;
EHlslTokenClass keyword;
};
} // end namespace glslang
#endif // HLSLSCANCONTEXT_H_

106
Externals/glslang/hlsl/hlslTokenStream.cpp vendored Executable file
View File

@ -0,0 +1,106 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#include "hlslTokenStream.h"
namespace glslang {
void HlslTokenStream::pushPreToken(const HlslToken& tok)
{
assert(preTokenStackSize == 0);
preTokenStack = tok;
++preTokenStackSize;
}
HlslToken HlslTokenStream::popPreToken()
{
assert(preTokenStackSize == 1);
--preTokenStackSize;
return preTokenStack;
}
void HlslTokenStream::pushTokenBuffer(const HlslToken& tok)
{
tokenBuffer = tok;
}
HlslToken HlslTokenStream::popTokenBuffer()
{
return tokenBuffer;
}
// Load 'token' with the next token in the stream of tokens.
void HlslTokenStream::advanceToken()
{
pushTokenBuffer(token);
if (preTokenStackSize > 0)
token = popPreToken();
else
scanner.tokenize(token);
}
void HlslTokenStream::recedeToken()
{
pushPreToken(token);
token = popTokenBuffer();
}
// Return the current token class.
EHlslTokenClass HlslTokenStream::peek() const
{
return token.tokenClass;
}
// Return true, without advancing to the next token, if the current token is
// the expected (passed in) token class.
bool HlslTokenStream::peekTokenClass(EHlslTokenClass tokenClass) const
{
return peek() == tokenClass;
}
// Return true and advance to the next token if the current token is the
// expected (passed in) token class.
bool HlslTokenStream::acceptTokenClass(EHlslTokenClass tokenClass)
{
if (peekTokenClass(tokenClass)) {
advanceToken();
return true;
}
return false;
}
} // end namespace glslang

85
Externals/glslang/hlsl/hlslTokenStream.h vendored Executable file
View File

@ -0,0 +1,85 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef HLSLTOKENSTREAM_H_
#define HLSLTOKENSTREAM_H_
#include "hlslScanContext.h"
namespace glslang {
class HlslTokenStream {
public:
explicit HlslTokenStream(HlslScanContext& scanner)
: scanner(scanner), preTokenStackSize(0) { }
virtual ~HlslTokenStream() { }
public:
void advanceToken();
void recedeToken();
bool acceptTokenClass(EHlslTokenClass);
EHlslTokenClass peek() const;
bool peekTokenClass(EHlslTokenClass) const;
protected:
HlslToken token; // the token we are currently looking at, but have not yet accepted
private:
HlslTokenStream();
HlslTokenStream& operator=(const HlslTokenStream&);
HlslScanContext& scanner; // lexical scanner, to get next token
// Previously scanned tokens, returned for future advances,
// so logically in front of the token stream.
// Is logically a stack; needs last in last out semantics.
// Currently implemented as a stack of size 1.
HlslToken preTokenStack;
int preTokenStackSize;
void pushPreToken(const HlslToken&);
HlslToken popPreToken();
// Previously scanned tokens, not yet return for future advances,
// but available for that.
// Is logically a fifo for normal advances, and a stack for recession.
// Currently implemented with an intrinsic size of 1.
HlslToken tokenBuffer;
void pushTokenBuffer(const HlslToken&);
HlslToken popTokenBuffer();
};
} // end namespace glslang
#endif // HLSLTOKENSTREAM_H_

288
Externals/glslang/hlsl/hlslTokens.h vendored Executable file
View File

@ -0,0 +1,288 @@
//
//Copyright (C) 2016 Google, Inc.
//Copyright (C) 2016 LunarG, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google, Inc., nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef EHLSLTOKENS_H_
#define EHLSLTOKENS_H_
namespace glslang {
enum EHlslTokenClass {
EHTokNone = 0,
// qualifiers
EHTokStatic,
EHTokConst,
EHTokSNorm,
EHTokUnorm,
EHTokExtern,
EHTokUniform,
EHTokVolatile,
EHTokPrecise,
EHTokShared,
EHTokGroupShared,
EHTokLinear,
EHTokCentroid,
EHTokNointerpolation,
EHTokNoperspective,
EHTokSample,
EHTokRowMajor,
EHTokColumnMajor,
EHTokPackOffset,
EHTokIn,
EHTokOut,
EHTokInOut,
// template types
EHTokBuffer,
EHTokVector,
EHTokMatrix,
// scalar types
EHTokVoid,
EHTokBool,
EHTokInt,
EHTokUint,
EHTokDword,
EHTokHalf,
EHTokFloat,
EHTokDouble,
EHTokMin16float,
EHTokMin10float,
EHTokMin16int,
EHTokMin12int,
EHTokMin16uint,
// vector types
EHTokBool1,
EHTokBool2,
EHTokBool3,
EHTokBool4,
EHTokFloat1,
EHTokFloat2,
EHTokFloat3,
EHTokFloat4,
EHTokInt1,
EHTokInt2,
EHTokInt3,
EHTokInt4,
EHTokDouble1,
EHTokDouble2,
EHTokDouble3,
EHTokDouble4,
EHTokUint1,
EHTokUint2,
EHTokUint3,
EHTokUint4,
// matrix types
EHTokInt1x1,
EHTokInt1x2,
EHTokInt1x3,
EHTokInt1x4,
EHTokInt2x1,
EHTokInt2x2,
EHTokInt2x3,
EHTokInt2x4,
EHTokInt3x1,
EHTokInt3x2,
EHTokInt3x3,
EHTokInt3x4,
EHTokInt4x1,
EHTokInt4x2,
EHTokInt4x3,
EHTokInt4x4,
EHTokUint1x1,
EHTokUint1x2,
EHTokUint1x3,
EHTokUint1x4,
EHTokUint2x1,
EHTokUint2x2,
EHTokUint2x3,
EHTokUint2x4,
EHTokUint3x1,
EHTokUint3x2,
EHTokUint3x3,
EHTokUint3x4,
EHTokUint4x1,
EHTokUint4x2,
EHTokUint4x3,
EHTokUint4x4,
EHTokBool1x1,
EHTokBool1x2,
EHTokBool1x3,
EHTokBool1x4,
EHTokBool2x1,
EHTokBool2x2,
EHTokBool2x3,
EHTokBool2x4,
EHTokBool3x1,
EHTokBool3x2,
EHTokBool3x3,
EHTokBool3x4,
EHTokBool4x1,
EHTokBool4x2,
EHTokBool4x3,
EHTokBool4x4,
EHTokFloat1x1,
EHTokFloat1x2,
EHTokFloat1x3,
EHTokFloat1x4,
EHTokFloat2x1,
EHTokFloat2x2,
EHTokFloat2x3,
EHTokFloat2x4,
EHTokFloat3x1,
EHTokFloat3x2,
EHTokFloat3x3,
EHTokFloat3x4,
EHTokFloat4x1,
EHTokFloat4x2,
EHTokFloat4x3,
EHTokFloat4x4,
EHTokDouble1x1,
EHTokDouble1x2,
EHTokDouble1x3,
EHTokDouble1x4,
EHTokDouble2x1,
EHTokDouble2x2,
EHTokDouble2x3,
EHTokDouble2x4,
EHTokDouble3x1,
EHTokDouble3x2,
EHTokDouble3x3,
EHTokDouble3x4,
EHTokDouble4x1,
EHTokDouble4x2,
EHTokDouble4x3,
EHTokDouble4x4,
// texturing types
EHTokSampler,
EHTokSampler1d,
EHTokSampler2d,
EHTokSampler3d,
EHTokSamplerCube,
EHTokSamplerState,
EHTokSamplerComparisonState,
EHTokTexture,
EHTokTexture1d,
EHTokTexture1darray,
EHTokTexture2d,
EHTokTexture2darray,
EHTokTexture3d,
EHTokTextureCube,
EHTokTextureCubearray,
EHTokTexture2DMS,
EHTokTexture2DMSarray,
// variable, user type, ...
EHTokIdentifier,
EHTokTypeName,
EHTokStruct,
EHTokTypedef,
// constant
EHTokFloatConstant,
EHTokDoubleConstant,
EHTokIntConstant,
EHTokUintConstant,
EHTokBoolConstant,
// control flow
EHTokFor,
EHTokDo,
EHTokWhile,
EHTokBreak,
EHTokContinue,
EHTokIf,
EHTokElse,
EHTokDiscard,
EHTokReturn,
EHTokSwitch,
EHTokCase,
EHTokDefault,
// expressions
EHTokLeftOp,
EHTokRightOp,
EHTokIncOp,
EHTokDecOp,
EHTokLeOp,
EHTokGeOp,
EHTokEqOp,
EHTokNeOp,
EHTokAndOp,
EHTokOrOp,
EHTokXorOp,
EHTokAssign,
EHTokMulAssign,
EHTokDivAssign,
EHTokAddAssign,
EHTokModAssign,
EHTokLeftAssign,
EHTokRightAssign,
EHTokAndAssign,
EHTokXorAssign,
EHTokOrAssign,
EHTokSubAssign,
EHTokLeftParen,
EHTokRightParen,
EHTokLeftBracket,
EHTokRightBracket,
EHTokLeftBrace,
EHTokRightBrace,
EHTokDot,
EHTokComma,
EHTokColon,
EHTokSemicolon,
EHTokBang,
EHTokDash,
EHTokTilde,
EHTokPlus,
EHTokStar,
EHTokSlash,
EHTokPercent,
EHTokLeftAngle,
EHTokRightAngle,
EHTokVerticalBar,
EHTokCaret,
EHTokAmpersand,
EHTokQuestion,
};
} // end namespace glslang
#endif // EHLSLTOKENS_H_