mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Externals: Update glslang.
This updates glslang to commit 9bb8cfffb0eed010e07132282c41d73064a7a609 which is the current version listed in the known_good.json file for the version 1.3.212 of the Vulkan-ValidationLayers repo.
This commit is contained in:
64
Externals/glslang/hlsl/CMakeLists.txt
vendored
64
Externals/glslang/hlsl/CMakeLists.txt
vendored
@ -1,25 +1,43 @@
|
||||
set(SOURCES
|
||||
hlslAttributes.cpp
|
||||
hlslParseHelper.cpp
|
||||
hlslScanContext.cpp
|
||||
hlslOpMap.cpp
|
||||
hlslTokenStream.cpp
|
||||
hlslGrammar.cpp
|
||||
hlslParseables.cpp)
|
||||
# Copyright (C) 2020 The Khronos Group 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 The Khronos Group 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.
|
||||
|
||||
set(HEADERS
|
||||
hlslAttributes.h
|
||||
hlslParseHelper.h
|
||||
hlslTokens.h
|
||||
hlslScanContext.h
|
||||
hlslOpMap.h
|
||||
hlslTokenStream.h
|
||||
hlslGrammar.h
|
||||
hlslParseables.h)
|
||||
# The HLSL source is directly embedded into the glslang target when ENABLE_HLSL
|
||||
# is set.
|
||||
# This source now lives at: glslang/HLSL/
|
||||
# The HLSL target is now just a stub that exists for backwards compatibility for
|
||||
# projects that referenced this target.
|
||||
|
||||
glslang_pch(SOURCES pch.cpp)
|
||||
|
||||
add_library(HLSL ${LIB_TYPE} ${SOURCES} ${HEADERS})
|
||||
add_library(HLSL ${LIB_TYPE} "stub.cpp")
|
||||
set_property(TARGET HLSL PROPERTY FOLDER hlsl)
|
||||
set_property(TARGET HLSL PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@ -27,10 +45,6 @@ if(WIN32 AND BUILD_SHARED_LIBS)
|
||||
set_target_properties(HLSL PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
source_group("Source" FILES ${SOURCES} ${HEADERS})
|
||||
endif(WIN32)
|
||||
|
||||
if(ENABLE_GLSLANG_INSTALL)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS HLSL EXPORT HLSLTargets
|
||||
@ -42,4 +56,4 @@ if(ENABLE_GLSLANG_INSTALL)
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
install(EXPORT HLSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
|
||||
endif(ENABLE_GLSLANG_INSTALL)
|
||||
endif()
|
||||
|
149
Externals/glslang/hlsl/hlslAttributes.cpp
vendored
149
Externals/glslang/hlsl/hlslAttributes.cpp
vendored
@ -1,149 +0,0 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "hlslAttributes.h"
|
||||
#include "hlslParseHelper.h"
|
||||
|
||||
namespace glslang {
|
||||
// Map the given string to an attribute enum from TAttributeType,
|
||||
// or EatNone if invalid.
|
||||
TAttributeType HlslParseContext::attributeFromName(const TString& nameSpace, const TString& name) const
|
||||
{
|
||||
// handle names within a namespace
|
||||
|
||||
if (nameSpace == "vk") {
|
||||
if (name == "input_attachment_index")
|
||||
return EatInputAttachment;
|
||||
else if (name == "location")
|
||||
return EatLocation;
|
||||
else if (name == "binding")
|
||||
return EatBinding;
|
||||
else if (name == "global_cbuffer_binding")
|
||||
return EatGlobalBinding;
|
||||
else if (name == "builtin")
|
||||
return EatBuiltIn;
|
||||
else if (name == "constant_id")
|
||||
return EatConstantId;
|
||||
else if (name == "push_constant")
|
||||
return EatPushConstant;
|
||||
} else if (nameSpace == "spv") {
|
||||
if (name == "format_rgba32f") return EatFormatRgba32f;
|
||||
if (name == "format_rgba16f") return EatFormatRgba16f;
|
||||
if (name == "format_r32f") return EatFormatR32f;
|
||||
if (name == "format_rgba8") return EatFormatRgba8;
|
||||
if (name == "format_rgba8snorm") return EatFormatRgba8Snorm;
|
||||
if (name == "format_rg32f") return EatFormatRg32f;
|
||||
if (name == "format_rg16f") return EatFormatRg16f;
|
||||
if (name == "format_r11fg11fb10f") return EatFormatR11fG11fB10f;
|
||||
if (name == "format_r16f") return EatFormatR16f;
|
||||
if (name == "format_rgba16") return EatFormatRgba16;
|
||||
if (name == "format_rgb10a2") return EatFormatRgb10A2;
|
||||
if (name == "format_rg16") return EatFormatRg16;
|
||||
if (name == "format_rg8") return EatFormatRg8;
|
||||
if (name == "format_r16") return EatFormatR16;
|
||||
if (name == "format_r8") return EatFormatR8;
|
||||
if (name == "format_rgba16snorm") return EatFormatRgba16Snorm;
|
||||
if (name == "format_rg16snorm") return EatFormatRg16Snorm;
|
||||
if (name == "format_rg8snorm") return EatFormatRg8Snorm;
|
||||
if (name == "format_r16snorm") return EatFormatR16Snorm;
|
||||
if (name == "format_r8snorm") return EatFormatR8Snorm;
|
||||
if (name == "format_rgba32i") return EatFormatRgba32i;
|
||||
if (name == "format_rgba16i") return EatFormatRgba16i;
|
||||
if (name == "format_rgba8i") return EatFormatRgba8i;
|
||||
if (name == "format_r32i") return EatFormatR32i;
|
||||
if (name == "format_rg32i") return EatFormatRg32i;
|
||||
if (name == "format_rg16i") return EatFormatRg16i;
|
||||
if (name == "format_rg8i") return EatFormatRg8i;
|
||||
if (name == "format_r16i") return EatFormatR16i;
|
||||
if (name == "format_r8i") return EatFormatR8i;
|
||||
if (name == "format_rgba32ui") return EatFormatRgba32ui;
|
||||
if (name == "format_rgba16ui") return EatFormatRgba16ui;
|
||||
if (name == "format_rgba8ui") return EatFormatRgba8ui;
|
||||
if (name == "format_r32ui") return EatFormatR32ui;
|
||||
if (name == "format_rgb10a2ui") return EatFormatRgb10a2ui;
|
||||
if (name == "format_rg32ui") return EatFormatRg32ui;
|
||||
if (name == "format_rg16ui") return EatFormatRg16ui;
|
||||
if (name == "format_rg8ui") return EatFormatRg8ui;
|
||||
if (name == "format_r16ui") return EatFormatR16ui;
|
||||
if (name == "format_r8ui") return EatFormatR8ui;
|
||||
|
||||
if (name == "nonwritable") return EatNonWritable;
|
||||
if (name == "nonreadable") return EatNonReadable;
|
||||
} else if (nameSpace.size() > 0)
|
||||
return EatNone;
|
||||
|
||||
// handle names with no namespace
|
||||
|
||||
if (name == "allow_uav_condition")
|
||||
return EatAllow_uav_condition;
|
||||
else if (name == "branch")
|
||||
return EatBranch;
|
||||
else if (name == "call")
|
||||
return EatCall;
|
||||
else if (name == "domain")
|
||||
return EatDomain;
|
||||
else if (name == "earlydepthstencil")
|
||||
return EatEarlyDepthStencil;
|
||||
else if (name == "fastopt")
|
||||
return EatFastOpt;
|
||||
else if (name == "flatten")
|
||||
return EatFlatten;
|
||||
else if (name == "forcecase")
|
||||
return EatForceCase;
|
||||
else if (name == "instance")
|
||||
return EatInstance;
|
||||
else if (name == "maxtessfactor")
|
||||
return EatMaxTessFactor;
|
||||
else if (name == "maxvertexcount")
|
||||
return EatMaxVertexCount;
|
||||
else if (name == "numthreads")
|
||||
return EatNumThreads;
|
||||
else if (name == "outputcontrolpoints")
|
||||
return EatOutputControlPoints;
|
||||
else if (name == "outputtopology")
|
||||
return EatOutputTopology;
|
||||
else if (name == "partitioning")
|
||||
return EatPartitioning;
|
||||
else if (name == "patchconstantfunc")
|
||||
return EatPatchConstantFunc;
|
||||
else if (name == "unroll")
|
||||
return EatUnroll;
|
||||
else if (name == "loop")
|
||||
return EatLoop;
|
||||
else
|
||||
return EatNone;
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
59
Externals/glslang/hlsl/hlslAttributes.h
vendored
59
Externals/glslang/hlsl/hlslAttributes.h
vendored
@ -1,59 +0,0 @@
|
||||
//
|
||||
// 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 HLSLATTRIBUTES_H_
|
||||
#define HLSLATTRIBUTES_H_
|
||||
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
#include "../glslang/MachineIndependent/attribute.h"
|
||||
#include "../glslang/MachineIndependent/SymbolTable.h"
|
||||
#include "hlslScanContext.h"
|
||||
|
||||
namespace glslang {
|
||||
|
||||
class TFunctionDeclarator {
|
||||
public:
|
||||
TFunctionDeclarator() : function(nullptr), body(nullptr) { }
|
||||
TSourceLoc loc;
|
||||
TFunction* function;
|
||||
TAttributes attributes;
|
||||
TVector<HlslToken>* body;
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // HLSLATTRIBUTES_H_
|
4175
Externals/glslang/hlsl/hlslGrammar.cpp
vendored
4175
Externals/glslang/hlsl/hlslGrammar.cpp
vendored
File diff suppressed because it is too large
Load Diff
142
Externals/glslang/hlsl/hlslGrammar.h
vendored
142
Externals/glslang/hlsl/hlslGrammar.h
vendored
@ -1,142 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2016-2018 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 {
|
||||
|
||||
class TFunctionDeclarator;
|
||||
|
||||
// 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),
|
||||
typeIdentifiers(false), unitNode(nullptr) { }
|
||||
virtual ~HlslGrammar() { }
|
||||
|
||||
bool parse();
|
||||
|
||||
protected:
|
||||
HlslGrammar();
|
||||
HlslGrammar& operator=(const HlslGrammar&);
|
||||
|
||||
void expected(const char*);
|
||||
void unimplemented(const char*);
|
||||
bool acceptIdentifier(HlslToken&);
|
||||
bool acceptCompilationUnit();
|
||||
bool acceptDeclarationList(TIntermNode*&);
|
||||
bool acceptDeclaration(TIntermNode*&);
|
||||
bool acceptControlDeclaration(TIntermNode*& node);
|
||||
bool acceptSamplerDeclarationDX9(TType&);
|
||||
bool acceptSamplerState();
|
||||
bool acceptFullySpecifiedType(TType&, const TAttributes&);
|
||||
bool acceptFullySpecifiedType(TType&, TIntermNode*& nodeList, const TAttributes&, bool forbidDeclarators = false);
|
||||
bool acceptQualifier(TQualifier&);
|
||||
bool acceptLayoutQualifierList(TQualifier&);
|
||||
bool acceptType(TType&);
|
||||
bool acceptType(TType&, TIntermNode*& nodeList);
|
||||
bool acceptTemplateVecMatBasicType(TBasicType&);
|
||||
bool acceptVectorTemplateType(TType&);
|
||||
bool acceptMatrixTemplateType(TType&);
|
||||
bool acceptTessellationDeclType(TBuiltInVariable&);
|
||||
bool acceptTessellationPatchTemplateType(TType&);
|
||||
bool acceptStreamOutTemplateType(TType&, TLayoutGeometry&);
|
||||
bool acceptOutputPrimitiveGeometry(TLayoutGeometry&);
|
||||
bool acceptAnnotations(TQualifier&);
|
||||
bool acceptSamplerTypeDX9(TType &);
|
||||
bool acceptSamplerType(TType&);
|
||||
bool acceptTextureType(TType&);
|
||||
bool acceptSubpassInputType(TType&);
|
||||
bool acceptStructBufferType(TType&);
|
||||
bool acceptTextureBufferType(TType&);
|
||||
bool acceptConstantBufferType(TType&);
|
||||
bool acceptStruct(TType&, TIntermNode*& nodeList);
|
||||
bool acceptStructDeclarationList(TTypeList*&, TIntermNode*& nodeList, TVector<TFunctionDeclarator>&);
|
||||
bool acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType&, TString& memberName,
|
||||
TFunctionDeclarator&);
|
||||
bool acceptFunctionParameters(TFunction&);
|
||||
bool acceptParameterDeclaration(TFunction&);
|
||||
bool acceptFunctionDefinition(TFunctionDeclarator&, TIntermNode*& nodeList, TVector<HlslToken>* deferredTokens);
|
||||
bool acceptFunctionBody(TFunctionDeclarator& declarator, TIntermNode*& nodeList);
|
||||
bool acceptParenExpression(TIntermTyped*&);
|
||||
bool acceptExpression(TIntermTyped*&);
|
||||
bool acceptInitializer(TIntermTyped*&);
|
||||
bool acceptAssignmentExpression(TIntermTyped*&);
|
||||
bool acceptConditionalExpression(TIntermTyped*&);
|
||||
bool acceptBinaryExpression(TIntermTyped*&, PrecedenceLevel);
|
||||
bool acceptUnaryExpression(TIntermTyped*&);
|
||||
bool acceptPostfixExpression(TIntermTyped*&);
|
||||
bool acceptConstructor(TIntermTyped*&);
|
||||
bool acceptFunctionCall(const TSourceLoc&, TString& name, TIntermTyped*&, TIntermTyped* objectBase);
|
||||
bool acceptArguments(TFunction*, TIntermTyped*&);
|
||||
bool acceptLiteral(TIntermTyped*&);
|
||||
bool acceptSimpleStatement(TIntermNode*&);
|
||||
bool acceptCompoundStatement(TIntermNode*&);
|
||||
bool acceptScopedStatement(TIntermNode*&);
|
||||
bool acceptScopedCompoundStatement(TIntermNode*&);
|
||||
bool acceptStatement(TIntermNode*&);
|
||||
bool acceptNestedStatement(TIntermNode*&);
|
||||
void acceptAttributes(TAttributes&);
|
||||
bool acceptSelectionStatement(TIntermNode*&, const TAttributes&);
|
||||
bool acceptSwitchStatement(TIntermNode*&, const TAttributes&);
|
||||
bool acceptIterationStatement(TIntermNode*&, const TAttributes&);
|
||||
bool acceptJumpStatement(TIntermNode*&);
|
||||
bool acceptCaseLabel(TIntermNode*&);
|
||||
bool acceptDefaultLabel(TIntermNode*&);
|
||||
void acceptArraySpecifier(TArraySizes*&);
|
||||
bool acceptPostDecls(TQualifier&);
|
||||
bool acceptDefaultParameterDeclaration(const TType&, TIntermTyped*&);
|
||||
|
||||
bool captureBlockTokens(TVector<HlslToken>& tokens);
|
||||
const char* getTypeString(EHlslTokenClass tokenClass) const;
|
||||
|
||||
HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate
|
||||
TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST
|
||||
bool typeIdentifiers; // shader uses some types as identifiers
|
||||
TIntermNode* unitNode;
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // HLSLGRAMMAR_H_
|
173
Externals/glslang/hlsl/hlslOpMap.cpp
vendored
173
Externals/glslang/hlsl/hlslOpMap.cpp
vendored
@ -1,173 +0,0 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
case EHTokColonColon: return EOpScoping;
|
||||
|
||||
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
69
Externals/glslang/hlsl/hlslOpMap.h
vendored
@ -1,69 +0,0 @@
|
||||
//
|
||||
// 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_
|
10032
Externals/glslang/hlsl/hlslParseHelper.cpp
vendored
10032
Externals/glslang/hlsl/hlslParseHelper.cpp
vendored
File diff suppressed because it is too large
Load Diff
507
Externals/glslang/hlsl/hlslParseHelper.h
vendored
507
Externals/glslang/hlsl/hlslParseHelper.h
vendored
@ -1,507 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2016-2018 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"
|
||||
#include "../glslang/MachineIndependent/attribute.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace glslang {
|
||||
|
||||
class TFunctionDeclarator;
|
||||
|
||||
class HlslParseContext : public TParseContextBase {
|
||||
public:
|
||||
HlslParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins,
|
||||
int version, EProfile, const SpvVersion& spvVersion, EShLanguage, TInfoSink&,
|
||||
const TString sourceEntryPointName,
|
||||
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
||||
virtual ~HlslParseContext();
|
||||
void initializeExtensionBehavior() override;
|
||||
|
||||
void setLimits(const TBuiltInResource&) override;
|
||||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false) override;
|
||||
virtual const char* getGlobalUniformBlockName() const override { return "$Global"; }
|
||||
virtual void setUniformBlockDefaults(TType& block) const override
|
||||
{
|
||||
block.getQualifier().layoutPacking = ElpStd140;
|
||||
block.getQualifier().layoutMatrix = ElmRowMajor;
|
||||
}
|
||||
|
||||
void reservedPpErrorCheck(const TSourceLoc&, const char* /*name*/, const char* /*op*/) override { }
|
||||
bool lineContinuationCheck(const TSourceLoc&, bool /*endOfComment*/) override { return true; }
|
||||
bool lineDirectiveShouldSetNextLine() const override { return true; }
|
||||
bool builtInName(const TString&);
|
||||
|
||||
void handlePragma(const TSourceLoc&, const TVector<TString>&) override;
|
||||
TIntermTyped* handleVariable(const TSourceLoc&, const TString* string);
|
||||
TIntermTyped* handleBracketDereference(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
|
||||
TIntermTyped* handleBracketOperator(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
|
||||
|
||||
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);
|
||||
bool isBuiltInMethod(const TSourceLoc&, TIntermTyped* base, const TString& field);
|
||||
void assignToInterface(TVariable& variable);
|
||||
void handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
|
||||
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributes&, TIntermNode*& entryPointTree);
|
||||
TIntermNode* transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributes&);
|
||||
void handleEntryPointAttributes(const TSourceLoc&, const TAttributes&);
|
||||
void transferTypeAttributes(const TSourceLoc&, const TAttributes&, TType&, bool allowEntry = false);
|
||||
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
|
||||
void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
|
||||
void remapNonEntryPointIO(TFunction& function);
|
||||
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
|
||||
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
|
||||
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
|
||||
TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
|
||||
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*);
|
||||
TIntermAggregate* assignClipCullDistance(const TSourceLoc&, TOperator, int semanticId, TIntermTyped* left, TIntermTyped* right);
|
||||
TIntermTyped* assignPosition(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
|
||||
void decomposeIntrinsic(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
|
||||
void decomposeSampleMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
|
||||
void decomposeStructBufferMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
|
||||
void decomposeGeometryMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
|
||||
void pushFrontArguments(TIntermTyped* front, TIntermTyped*& arguments);
|
||||
void addInputArgumentConversions(const TFunction&, TIntermTyped*&);
|
||||
void expandArguments(const TSourceLoc&, const TFunction&, TIntermTyped*&);
|
||||
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermOperator&);
|
||||
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
|
||||
TFunction* makeConstructorCall(const TSourceLoc&, const TType&);
|
||||
void handleSemantic(TSourceLoc, TQualifier&, TBuiltInVariable, const TString& upperCase);
|
||||
void handlePackOffset(const TSourceLoc&, TQualifier&, const glslang::TString& location,
|
||||
const glslang::TString* component);
|
||||
void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc,
|
||||
int subComponent, const glslang::TString*);
|
||||
TIntermTyped* convertConditionalExpression(const TSourceLoc&, TIntermTyped*, bool mustBeScalar = true);
|
||||
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
|
||||
|
||||
bool parseMatrixSwizzleSelector(const TSourceLoc&, const TString&, int cols, int rows, TSwizzleSelectors<TMatrixSelector>&);
|
||||
int getMatrixComponentsColumn(int rows, const TSwizzleSelectors<TMatrixSelector>&);
|
||||
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&);
|
||||
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&);
|
||||
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
|
||||
void structArrayCheck(const TSourceLoc&, const TType& structure);
|
||||
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
|
||||
void globalQualifierFix(const TSourceLoc&, TQualifier&);
|
||||
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
|
||||
void mergeQualifiers(TQualifier& dst, const TQualifier& src);
|
||||
int computeSamplerTypeIndex(TSampler&);
|
||||
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&);
|
||||
void paramFix(TType& type);
|
||||
void specializationCheck(const TSourceLoc&, const TType&, const char* op);
|
||||
|
||||
void setLayoutQualifier(const TSourceLoc&, TQualifier&, TString&);
|
||||
void setLayoutQualifier(const TSourceLoc&, TQualifier&, TString&, const TIntermTyped*);
|
||||
void setSpecConstantId(const TSourceLoc&, TQualifier&, int value);
|
||||
void mergeObjectLayoutQualifiers(TQualifier& dest, const TQualifier& src, bool inheritOnly);
|
||||
void checkNoShaderLayouts(const TSourceLoc&, const TShaderQualifiers&);
|
||||
|
||||
const TFunction* findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn, int& thisDepth, TIntermTyped*& args);
|
||||
void addGenMulArgumentConversion(const TSourceLoc& loc, TFunction& call, TIntermTyped*& args);
|
||||
void declareTypedef(const TSourceLoc&, const TString& identifier, const TType&);
|
||||
void declareStruct(const TSourceLoc&, TString& structName, TType&);
|
||||
TSymbol* lookupUserType(const TString&, TType&);
|
||||
TIntermNode* declareVariable(const TSourceLoc&, const TString& identifier, TType&, TIntermTyped* initializer = 0);
|
||||
void lengthenList(const TSourceLoc&, TIntermSequence& list, int size, TIntermTyped* scalarInit);
|
||||
TIntermTyped* handleConstructor(const TSourceLoc&, TIntermTyped*, const TType&);
|
||||
TIntermTyped* addConstructor(const TSourceLoc&, TIntermTyped*, const TType&);
|
||||
TIntermTyped* convertArray(TIntermTyped*, const TType&);
|
||||
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
|
||||
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
|
||||
void declareBlock(const TSourceLoc&, TType&, const TString* instanceName = 0);
|
||||
void declareStructBufferCounter(const TSourceLoc& loc, const TType& bufferType, const TString& name);
|
||||
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
|
||||
void fixXfbOffsets(TQualifier&, TTypeList&);
|
||||
void fixBlockUniformOffsets(const 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, const TAttributes&);
|
||||
|
||||
void nestLooping() { ++loopNestingLevel; }
|
||||
void unnestLooping() { --loopNestingLevel; }
|
||||
void nestAnnotations() { ++annotationNestingLevel; }
|
||||
void unnestAnnotations() { --annotationNestingLevel; }
|
||||
int getAnnotationNestingLevel() { return annotationNestingLevel; }
|
||||
void pushScope() { symbolTable.push(); }
|
||||
void popScope() { symbolTable.pop(0); }
|
||||
|
||||
void pushThisScope(const TType&, const TVector<TFunctionDeclarator>&);
|
||||
void popThisScope() { symbolTable.pop(0); }
|
||||
|
||||
void pushImplicitThis(TVariable* thisParameter) { implicitThisStack.push_back(thisParameter); }
|
||||
void popImplicitThis() { implicitThisStack.pop_back(); }
|
||||
TVariable* getImplicitThis(int thisDepth) const { return implicitThisStack[implicitThisStack.size() - thisDepth]; }
|
||||
|
||||
void pushNamespace(const TString& name);
|
||||
void popNamespace();
|
||||
void getFullNamespaceName(TString*&) const;
|
||||
void addScopeMangler(TString&);
|
||||
|
||||
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
|
||||
void popSwitchSequence() { switchSequenceStack.pop_back(); }
|
||||
|
||||
virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName,
|
||||
TTypeList* typeList = nullptr) override;
|
||||
|
||||
// Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore.
|
||||
TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node);
|
||||
bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override;
|
||||
|
||||
TLayoutFormat getLayoutFromTxType(const TSourceLoc&, const TType&);
|
||||
|
||||
bool handleOutputGeometry(const TSourceLoc&, const TLayoutGeometry& geometry);
|
||||
bool handleInputGeometry(const TSourceLoc&, const TLayoutGeometry& geometry);
|
||||
|
||||
// Determine selection control from attributes
|
||||
void handleSelectionAttributes(const TSourceLoc& loc, TIntermSelection*, const TAttributes& attributes);
|
||||
void handleSwitchAttributes(const TSourceLoc& loc, TIntermSwitch*, const TAttributes& attributes);
|
||||
|
||||
// Determine loop control from attributes
|
||||
void handleLoopAttributes(const TSourceLoc& loc, TIntermLoop*, const TAttributes& attributes);
|
||||
|
||||
// Share struct buffer deep types
|
||||
void shareStructBufferType(TType&);
|
||||
|
||||
// Set texture return type of the given sampler. Returns success (not all types are valid).
|
||||
bool setTextureReturnType(TSampler& sampler, const TType& retType, const TSourceLoc& loc);
|
||||
|
||||
// Obtain the sampler return type of the given sampler in retType.
|
||||
void getTextureReturnType(const TSampler& sampler, TType& retType) const;
|
||||
|
||||
TAttributeType attributeFromName(const TString& nameSpace, const TString& name) const;
|
||||
|
||||
protected:
|
||||
struct TFlattenData {
|
||||
TFlattenData() : nextBinding(TQualifier::layoutBindingEnd),
|
||||
nextLocation(TQualifier::layoutLocationEnd) { }
|
||||
TFlattenData(int nb, int nl) : nextBinding(nb), nextLocation(nl) { }
|
||||
|
||||
TVector<TVariable*> members; // individual flattened variables
|
||||
TVector<int> offsets; // offset to next tree level
|
||||
unsigned int nextBinding; // next binding to use.
|
||||
unsigned int nextLocation; // next location to use
|
||||
};
|
||||
|
||||
void fixConstInit(const TSourceLoc&, const TString& identifier, TType& type, TIntermTyped*& initializer);
|
||||
void inheritGlobalDefaults(TQualifier& dst) const;
|
||||
TVariable* makeInternalVariable(const char* name, const TType&) const;
|
||||
TVariable* makeInternalVariable(const TString& name, const TType& type) const {
|
||||
return makeInternalVariable(name.c_str(), type);
|
||||
}
|
||||
TIntermSymbol* makeInternalVariableNode(const TSourceLoc&, const char* name, const TType&) const;
|
||||
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&, bool track);
|
||||
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&, bool track);
|
||||
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
|
||||
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
|
||||
bool isScalarConstructor(const TIntermNode*);
|
||||
TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);
|
||||
|
||||
// Return true if this node requires L-value conversion (e.g, to an imageStore).
|
||||
bool shouldConvertLValue(const TIntermNode*) const;
|
||||
|
||||
// Array and struct flattening
|
||||
TIntermTyped* flattenAccess(TIntermTyped* base, int member);
|
||||
TIntermTyped* flattenAccess(int uniqueId, int member, TStorageQualifier outerStorage, const TType&, int subset = -1);
|
||||
int findSubtreeOffset(const TIntermNode&) const;
|
||||
int findSubtreeOffset(const TType&, int subset, const TVector<int>& offsets) const;
|
||||
bool shouldFlatten(const TType&, TStorageQualifier, bool topLevel) const;
|
||||
bool wasFlattened(const TIntermTyped* node) const;
|
||||
bool wasFlattened(int id) const { return flattenMap.find(id) != flattenMap.end(); }
|
||||
int addFlattenedMember(const TVariable&, const TType&, TFlattenData&, const TString& name, bool linkage,
|
||||
const TQualifier& outerQualifier, const TArraySizes* builtInArraySizes);
|
||||
|
||||
// Structure splitting (splits interstage built-in types into its own struct)
|
||||
void split(const TVariable&);
|
||||
void splitBuiltIn(const TString& baseName, const TType& memberType, const TArraySizes*, const TQualifier&);
|
||||
const TType& split(const TType& type, const TString& name, const TQualifier&);
|
||||
bool wasSplit(const TIntermTyped* node) const;
|
||||
bool wasSplit(int id) const { return splitNonIoVars.find(id) != splitNonIoVars.end(); }
|
||||
TVariable* getSplitNonIoVar(int id) const;
|
||||
void addPatchConstantInvocation();
|
||||
void fixTextureShadowModes();
|
||||
void finalizeAppendMethods();
|
||||
TIntermTyped* makeIntegerIndex(TIntermTyped*);
|
||||
|
||||
void fixBuiltInIoType(TType&);
|
||||
|
||||
void flatten(const TVariable& variable, bool linkage);
|
||||
int flatten(const TVariable& variable, const TType&, TFlattenData&, TString name, bool linkage,
|
||||
const TQualifier& outerQualifier, const TArraySizes* builtInArraySizes);
|
||||
int flattenStruct(const TVariable& variable, const TType&, TFlattenData&, TString name, bool linkage,
|
||||
const TQualifier& outerQualifier, const TArraySizes* builtInArraySizes);
|
||||
int flattenArray(const TVariable& variable, const TType&, TFlattenData&, TString name, bool linkage,
|
||||
const TQualifier& outerQualifier);
|
||||
|
||||
bool hasUniform(const TQualifier& qualifier) const;
|
||||
void clearUniform(TQualifier& qualifier);
|
||||
bool isInputBuiltIn(const TQualifier& qualifier) const;
|
||||
bool hasInput(const TQualifier& qualifier) const;
|
||||
void correctOutput(TQualifier& qualifier);
|
||||
bool isOutputBuiltIn(const TQualifier& qualifier) const;
|
||||
bool hasOutput(const TQualifier& qualifier) const;
|
||||
void correctInput(TQualifier& qualifier);
|
||||
void correctUniform(TQualifier& qualifier);
|
||||
void clearUniformInputOutput(TQualifier& qualifier);
|
||||
|
||||
// Test method names
|
||||
bool isStructBufferMethod(const TString& name) const;
|
||||
void counterBufferType(const TSourceLoc& loc, TType& type);
|
||||
|
||||
// Return standard sample position array
|
||||
TIntermConstantUnion* getSamplePosArray(int count);
|
||||
|
||||
TType* getStructBufferContentType(const TType& type) const;
|
||||
bool isStructBufferType(const TType& type) const { return getStructBufferContentType(type) != nullptr; }
|
||||
TIntermTyped* indexStructBufferContent(const TSourceLoc& loc, TIntermTyped* buffer) const;
|
||||
TIntermTyped* getStructBufferCounter(const TSourceLoc& loc, TIntermTyped* buffer);
|
||||
TString getStructBuffCounterName(const TString&) const;
|
||||
void addStructBuffArguments(const TSourceLoc& loc, TIntermAggregate*&);
|
||||
void addStructBufferHiddenCounterParam(const TSourceLoc& loc, TParameter&, TIntermAggregate*&);
|
||||
|
||||
// Return true if this type is a reference. This is not currently a type method in case that's
|
||||
// a language specific answer.
|
||||
bool isReference(const TType& type) const { return isStructBufferType(type); }
|
||||
|
||||
// Return true if this a buffer type that has an associated counter buffer.
|
||||
bool hasStructBuffCounter(const TType&) const;
|
||||
|
||||
// Finalization step: remove unused buffer blocks from linkage (we don't know until the
|
||||
// shader is entirely compiled)
|
||||
void removeUnusedStructBufferCounters();
|
||||
|
||||
static bool isClipOrCullDistance(TBuiltInVariable);
|
||||
static bool isClipOrCullDistance(const TQualifier& qual) { return isClipOrCullDistance(qual.builtIn); }
|
||||
static bool isClipOrCullDistance(const TType& type) { return isClipOrCullDistance(type.getQualifier()); }
|
||||
|
||||
// Find the patch constant function (issues error, returns nullptr if not found)
|
||||
const TFunction* findPatchConstantFunction(const TSourceLoc& loc);
|
||||
|
||||
// Pass through to base class after remembering built-in mappings.
|
||||
using TParseContextBase::trackLinkage;
|
||||
void trackLinkage(TSymbol& variable) override;
|
||||
|
||||
void finish() override; // post-processing
|
||||
|
||||
// Linkage symbol helpers
|
||||
TIntermSymbol* findTessLinkageSymbol(TBuiltInVariable biType) const;
|
||||
|
||||
// Current state of parsing
|
||||
int annotationNestingLevel; // 0 if outside all annotations
|
||||
|
||||
HlslParseContext(HlslParseContext&);
|
||||
HlslParseContext& operator=(HlslParseContext&);
|
||||
|
||||
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex()
|
||||
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;
|
||||
|
||||
TMap<int, TFlattenData> flattenMap;
|
||||
|
||||
// IO-type map. Maps a pure symbol-table form of a structure-member list into
|
||||
// each of the (up to) three kinds of IO, as each as different allowed decorations,
|
||||
// but HLSL allows mixing all in the same structure.
|
||||
struct tIoKinds {
|
||||
TTypeList* input;
|
||||
TTypeList* output;
|
||||
TTypeList* uniform;
|
||||
};
|
||||
TMap<const TTypeList*, tIoKinds> ioTypeMap;
|
||||
|
||||
// Structure splitting data:
|
||||
TMap<int, TVariable*> splitNonIoVars; // variables with the built-in interstage IO removed, indexed by unique ID.
|
||||
|
||||
// Structuredbuffer shared types. Typically there are only a few.
|
||||
TVector<TType*> structBufferTypes;
|
||||
|
||||
// This tracks texture sample user structure return types. Only a limited number are supported, as
|
||||
// may fit in TSampler::structReturnIndex.
|
||||
TVector<TTypeList*> textureReturnStruct;
|
||||
|
||||
TMap<TString, bool> structBufferCounter; // true if counter buffer is in use
|
||||
|
||||
// The built-in interstage IO map considers e.g, EvqPosition on input and output separately, so that we
|
||||
// can build the linkage correctly if position appears on both sides. Otherwise, multiple positions
|
||||
// are considered identical.
|
||||
struct tInterstageIoData {
|
||||
tInterstageIoData(TBuiltInVariable bi, TStorageQualifier q) :
|
||||
builtIn(bi), storage(q) { }
|
||||
|
||||
TBuiltInVariable builtIn;
|
||||
TStorageQualifier storage;
|
||||
|
||||
// ordering for maps
|
||||
bool operator<(const tInterstageIoData d) const {
|
||||
return (builtIn != d.builtIn) ? (builtIn < d.builtIn) : (storage < d.storage);
|
||||
}
|
||||
};
|
||||
|
||||
TMap<tInterstageIoData, TVariable*> splitBuiltIns; // split built-ins, indexed by built-in type.
|
||||
TVariable* inputPatch; // input patch is special for PCF: it's the only non-builtin PCF input,
|
||||
// and is handled as a pseudo-builtin.
|
||||
|
||||
unsigned int nextInLocation;
|
||||
unsigned int nextOutLocation;
|
||||
|
||||
TFunction* entryPointFunction;
|
||||
TIntermNode* entryPointFunctionBody;
|
||||
|
||||
TString patchConstantFunctionName; // hull shader patch constant function name, from function level attribute.
|
||||
TMap<TBuiltInVariable, TSymbol*> builtInTessLinkageSymbols; // used for tessellation, finding declared built-ins
|
||||
|
||||
TVector<TString> currentTypePrefix; // current scoping prefix for nested structures
|
||||
TVector<TVariable*> implicitThisStack; // currently active 'this' variables for nested structures
|
||||
|
||||
TVariable* gsStreamOutput; // geometry shader stream outputs, for emit (Append method)
|
||||
|
||||
TVariable* clipDistanceOutput; // synthesized clip distance out variable (shader might have >1)
|
||||
TVariable* cullDistanceOutput; // synthesized cull distance out variable (shader might have >1)
|
||||
TVariable* clipDistanceInput; // synthesized clip distance in variable (shader might have >1)
|
||||
TVariable* cullDistanceInput; // synthesized cull distance in variable (shader might have >1)
|
||||
|
||||
static const int maxClipCullRegs = 2;
|
||||
std::array<int, maxClipCullRegs> clipSemanticNSizeIn; // vector, indexed by clip semantic ID
|
||||
std::array<int, maxClipCullRegs> cullSemanticNSizeIn; // vector, indexed by cull semantic ID
|
||||
std::array<int, maxClipCullRegs> clipSemanticNSizeOut; // vector, indexed by clip semantic ID
|
||||
std::array<int, maxClipCullRegs> cullSemanticNSizeOut; // vector, indexed by cull semantic ID
|
||||
|
||||
// This tracks the first (mip level) argument to the .mips[][] operator. Since this can be nested as
|
||||
// in tx.mips[tx.mips[0][1].x][2], we need a stack. We also track the TSourceLoc for error reporting
|
||||
// purposes.
|
||||
struct tMipsOperatorData {
|
||||
tMipsOperatorData(TSourceLoc l, TIntermTyped* m) : loc(l), mipLevel(m) { }
|
||||
TSourceLoc loc;
|
||||
TIntermTyped* mipLevel;
|
||||
};
|
||||
|
||||
TVector<tMipsOperatorData> mipsOperatorMipArg;
|
||||
|
||||
// The geometry output stream is not copied out from the entry point as a typical output variable
|
||||
// is. It's written via EmitVertex (hlsl=Append), which may happen in arbitrary control flow.
|
||||
// For this we need the real output symbol. Since it may not be known at the time and Append()
|
||||
// method is parsed, the sequence will be patched during finalization.
|
||||
struct tGsAppendData {
|
||||
TIntermAggregate* node;
|
||||
TSourceLoc loc;
|
||||
};
|
||||
|
||||
TVector<tGsAppendData> gsAppends;
|
||||
|
||||
// A texture object may be used with shadow and non-shadow samplers, but both may not be
|
||||
// alive post-DCE in the same shader. We do not know at compilation time which are alive: that's
|
||||
// only known post-DCE. If a texture is used both ways, we create two textures, and
|
||||
// leave the elimiation of one to the optimizer. This maps the shader variant to
|
||||
// the shadow variant.
|
||||
//
|
||||
// This can be removed if and when the texture shadow code in
|
||||
// HlslParseContext::handleSamplerTextureCombine is removed.
|
||||
struct tShadowTextureSymbols {
|
||||
tShadowTextureSymbols() { symId.fill(-1); }
|
||||
|
||||
void set(bool shadow, int id) { symId[int(shadow)] = id; }
|
||||
int get(bool shadow) const { return symId[int(shadow)]; }
|
||||
|
||||
// True if this texture has been seen with both shadow and non-shadow modes
|
||||
bool overloaded() const { return symId[0] != -1 && symId[1] != -1; }
|
||||
bool isShadowId(int id) const { return symId[1] == id; }
|
||||
|
||||
private:
|
||||
std::array<int, 2> symId;
|
||||
};
|
||||
|
||||
TMap<int, tShadowTextureSymbols*> textureShadowVariant;
|
||||
};
|
||||
|
||||
// This is the prefix we use for built-in methods to avoid namespace collisions with
|
||||
// global scope user functions.
|
||||
// TODO: this would be better as a nonparseable character, but that would
|
||||
// require changing the scanner.
|
||||
#define BUILTIN_PREFIX "__BI_"
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // HLSL_PARSE_INCLUDED_
|
1324
Externals/glslang/hlsl/hlslParseables.cpp
vendored
1324
Externals/glslang/hlsl/hlslParseables.cpp
vendored
File diff suppressed because it is too large
Load Diff
64
Externals/glslang/hlsl/hlslParseables.h
vendored
64
Externals/glslang/hlsl/hlslParseables.h
vendored
@ -1,64 +0,0 @@
|
||||
//
|
||||
// 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_
|
903
Externals/glslang/hlsl/hlslScanContext.cpp
vendored
903
Externals/glslang/hlsl/hlslScanContext.cpp
vendored
@ -1,903 +0,0 @@
|
||||
//
|
||||
// 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 <cstring>
|
||||
#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"
|
||||
|
||||
// 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;
|
||||
std::unordered_map<const char*, glslang::TBuiltInVariable, str_hash, str_eq>* SemanticMap = 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)["layout"] = EHTokLayout;
|
||||
(*KeywordMap)["globallycoherent"] = EHTokGloballyCoherent;
|
||||
(*KeywordMap)["inline"] = EHTokInline;
|
||||
|
||||
(*KeywordMap)["point"] = EHTokPoint;
|
||||
(*KeywordMap)["line"] = EHTokLine;
|
||||
(*KeywordMap)["triangle"] = EHTokTriangle;
|
||||
(*KeywordMap)["lineadj"] = EHTokLineAdj;
|
||||
(*KeywordMap)["triangleadj"] = EHTokTriangleAdj;
|
||||
|
||||
(*KeywordMap)["PointStream"] = EHTokPointStream;
|
||||
(*KeywordMap)["LineStream"] = EHTokLineStream;
|
||||
(*KeywordMap)["TriangleStream"] = EHTokTriangleStream;
|
||||
|
||||
(*KeywordMap)["InputPatch"] = EHTokInputPatch;
|
||||
(*KeywordMap)["OutputPatch"] = EHTokOutputPatch;
|
||||
|
||||
(*KeywordMap)["Buffer"] = EHTokBuffer;
|
||||
(*KeywordMap)["vector"] = EHTokVector;
|
||||
(*KeywordMap)["matrix"] = EHTokMatrix;
|
||||
|
||||
(*KeywordMap)["void"] = EHTokVoid;
|
||||
(*KeywordMap)["string"] = EHTokString;
|
||||
(*KeywordMap)["bool"] = EHTokBool;
|
||||
(*KeywordMap)["int"] = EHTokInt;
|
||||
(*KeywordMap)["uint"] = EHTokUint;
|
||||
(*KeywordMap)["uint64_t"] = EHTokUint64;
|
||||
(*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"] = EHTokMin16uint;
|
||||
|
||||
(*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)["half1"] = EHTokHalf1;
|
||||
(*KeywordMap)["half2"] = EHTokHalf2;
|
||||
(*KeywordMap)["half3"] = EHTokHalf3;
|
||||
(*KeywordMap)["half4"] = EHTokHalf4;
|
||||
(*KeywordMap)["min16float1"] = EHTokMin16float1;
|
||||
(*KeywordMap)["min16float2"] = EHTokMin16float2;
|
||||
(*KeywordMap)["min16float3"] = EHTokMin16float3;
|
||||
(*KeywordMap)["min16float4"] = EHTokMin16float4;
|
||||
(*KeywordMap)["min10float1"] = EHTokMin10float1;
|
||||
(*KeywordMap)["min10float2"] = EHTokMin10float2;
|
||||
(*KeywordMap)["min10float3"] = EHTokMin10float3;
|
||||
(*KeywordMap)["min10float4"] = EHTokMin10float4;
|
||||
(*KeywordMap)["min16int1"] = EHTokMin16int1;
|
||||
(*KeywordMap)["min16int2"] = EHTokMin16int2;
|
||||
(*KeywordMap)["min16int3"] = EHTokMin16int3;
|
||||
(*KeywordMap)["min16int4"] = EHTokMin16int4;
|
||||
(*KeywordMap)["min12int1"] = EHTokMin12int1;
|
||||
(*KeywordMap)["min12int2"] = EHTokMin12int2;
|
||||
(*KeywordMap)["min12int3"] = EHTokMin12int3;
|
||||
(*KeywordMap)["min12int4"] = EHTokMin12int4;
|
||||
(*KeywordMap)["min16uint1"] = EHTokMin16uint1;
|
||||
(*KeywordMap)["min16uint2"] = EHTokMin16uint2;
|
||||
(*KeywordMap)["min16uint3"] = EHTokMin16uint3;
|
||||
(*KeywordMap)["min16uint4"] = EHTokMin16uint4;
|
||||
|
||||
(*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)["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)["half1x1"] = EHTokHalf1x1;
|
||||
(*KeywordMap)["half1x2"] = EHTokHalf1x2;
|
||||
(*KeywordMap)["half1x3"] = EHTokHalf1x3;
|
||||
(*KeywordMap)["half1x4"] = EHTokHalf1x4;
|
||||
(*KeywordMap)["half2x1"] = EHTokHalf2x1;
|
||||
(*KeywordMap)["half2x2"] = EHTokHalf2x2;
|
||||
(*KeywordMap)["half2x3"] = EHTokHalf2x3;
|
||||
(*KeywordMap)["half2x4"] = EHTokHalf2x4;
|
||||
(*KeywordMap)["half3x1"] = EHTokHalf3x1;
|
||||
(*KeywordMap)["half3x2"] = EHTokHalf3x2;
|
||||
(*KeywordMap)["half3x3"] = EHTokHalf3x3;
|
||||
(*KeywordMap)["half3x4"] = EHTokHalf3x4;
|
||||
(*KeywordMap)["half4x1"] = EHTokHalf4x1;
|
||||
(*KeywordMap)["half4x2"] = EHTokHalf4x2;
|
||||
(*KeywordMap)["half4x3"] = EHTokHalf4x3;
|
||||
(*KeywordMap)["half4x4"] = EHTokHalf4x4;
|
||||
(*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)["RWTexture1D"] = EHTokRWTexture1d;
|
||||
(*KeywordMap)["RWTexture1DArray"] = EHTokRWTexture1darray;
|
||||
(*KeywordMap)["RWTexture2D"] = EHTokRWTexture2d;
|
||||
(*KeywordMap)["RWTexture2DArray"] = EHTokRWTexture2darray;
|
||||
(*KeywordMap)["RWTexture3D"] = EHTokRWTexture3d;
|
||||
(*KeywordMap)["RWBuffer"] = EHTokRWBuffer;
|
||||
(*KeywordMap)["SubpassInput"] = EHTokSubpassInput;
|
||||
(*KeywordMap)["SubpassInputMS"] = EHTokSubpassInputMS;
|
||||
|
||||
(*KeywordMap)["AppendStructuredBuffer"] = EHTokAppendStructuredBuffer;
|
||||
(*KeywordMap)["ByteAddressBuffer"] = EHTokByteAddressBuffer;
|
||||
(*KeywordMap)["ConsumeStructuredBuffer"] = EHTokConsumeStructuredBuffer;
|
||||
(*KeywordMap)["RWByteAddressBuffer"] = EHTokRWByteAddressBuffer;
|
||||
(*KeywordMap)["RWStructuredBuffer"] = EHTokRWStructuredBuffer;
|
||||
(*KeywordMap)["StructuredBuffer"] = EHTokStructuredBuffer;
|
||||
(*KeywordMap)["TextureBuffer"] = EHTokTextureBuffer;
|
||||
|
||||
(*KeywordMap)["class"] = EHTokClass;
|
||||
(*KeywordMap)["struct"] = EHTokStruct;
|
||||
(*KeywordMap)["cbuffer"] = EHTokCBuffer;
|
||||
(*KeywordMap)["ConstantBuffer"] = EHTokConstantBuffer;
|
||||
(*KeywordMap)["tbuffer"] = EHTokTBuffer;
|
||||
(*KeywordMap)["typedef"] = EHTokTypedef;
|
||||
(*KeywordMap)["this"] = EHTokThis;
|
||||
(*KeywordMap)["namespace"] = EHTokNamespace;
|
||||
|
||||
(*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("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("throw");
|
||||
ReservedSet->insert("try");
|
||||
ReservedSet->insert("typename");
|
||||
ReservedSet->insert("union");
|
||||
ReservedSet->insert("unsigned");
|
||||
ReservedSet->insert("using");
|
||||
ReservedSet->insert("virtual");
|
||||
|
||||
SemanticMap = new std::unordered_map<const char*, glslang::TBuiltInVariable, str_hash, str_eq>;
|
||||
|
||||
// in DX9, all outputs had to have a semantic associated with them, that was either consumed
|
||||
// by the system or was a specific register assignment
|
||||
// in DX10+, only semantics with the SV_ prefix have any meaning beyond decoration
|
||||
// Fxc will only accept DX9 style semantics in compat mode
|
||||
// Also, in DX10 if a SV value is present as the input of a stage, but isn't appropriate for that
|
||||
// stage, it would just be ignored as it is likely there as part of an output struct from one stage
|
||||
// to the next
|
||||
bool bParseDX9 = false;
|
||||
if (bParseDX9) {
|
||||
(*SemanticMap)["PSIZE"] = EbvPointSize;
|
||||
(*SemanticMap)["FOG"] = EbvFogFragCoord;
|
||||
(*SemanticMap)["DEPTH"] = EbvFragDepth;
|
||||
(*SemanticMap)["VFACE"] = EbvFace;
|
||||
(*SemanticMap)["VPOS"] = EbvFragCoord;
|
||||
}
|
||||
|
||||
(*SemanticMap)["SV_POSITION"] = EbvPosition;
|
||||
(*SemanticMap)["SV_VERTEXID"] = EbvVertexIndex;
|
||||
(*SemanticMap)["SV_VIEWPORTARRAYINDEX"] = EbvViewportIndex;
|
||||
(*SemanticMap)["SV_TESSFACTOR"] = EbvTessLevelOuter;
|
||||
(*SemanticMap)["SV_SAMPLEINDEX"] = EbvSampleId;
|
||||
(*SemanticMap)["SV_RENDERTARGETARRAYINDEX"] = EbvLayer;
|
||||
(*SemanticMap)["SV_PRIMITIVEID"] = EbvPrimitiveId;
|
||||
(*SemanticMap)["SV_OUTPUTCONTROLPOINTID"] = EbvInvocationId;
|
||||
(*SemanticMap)["SV_ISFRONTFACE"] = EbvFace;
|
||||
(*SemanticMap)["SV_INSTANCEID"] = EbvInstanceIndex;
|
||||
(*SemanticMap)["SV_INSIDETESSFACTOR"] = EbvTessLevelInner;
|
||||
(*SemanticMap)["SV_GSINSTANCEID"] = EbvInvocationId;
|
||||
(*SemanticMap)["SV_DISPATCHTHREADID"] = EbvGlobalInvocationId;
|
||||
(*SemanticMap)["SV_GROUPTHREADID"] = EbvLocalInvocationId;
|
||||
(*SemanticMap)["SV_GROUPINDEX"] = EbvLocalInvocationIndex;
|
||||
(*SemanticMap)["SV_GROUPID"] = EbvWorkGroupId;
|
||||
(*SemanticMap)["SV_DOMAINLOCATION"] = EbvTessCoord;
|
||||
(*SemanticMap)["SV_DEPTH"] = EbvFragDepth;
|
||||
(*SemanticMap)["SV_COVERAGE"] = EbvSampleMask;
|
||||
(*SemanticMap)["SV_DEPTHGREATEREQUAL"] = EbvFragDepthGreater;
|
||||
(*SemanticMap)["SV_DEPTHLESSEQUAL"] = EbvFragDepthLesser;
|
||||
(*SemanticMap)["SV_STENCILREF"] = EbvFragStencilRef;
|
||||
}
|
||||
|
||||
void HlslScanContext::deleteKeywordMap()
|
||||
{
|
||||
delete KeywordMap;
|
||||
KeywordMap = nullptr;
|
||||
delete ReservedSet;
|
||||
ReservedSet = nullptr;
|
||||
delete SemanticMap;
|
||||
SemanticMap = nullptr;
|
||||
}
|
||||
|
||||
// Wrapper for tokenizeClass() to get everything inside the token.
|
||||
void HlslScanContext::tokenize(HlslToken& token)
|
||||
{
|
||||
EHlslTokenClass tokenClass = tokenizeClass(token);
|
||||
token.tokenClass = tokenClass;
|
||||
}
|
||||
|
||||
glslang::TBuiltInVariable HlslScanContext::mapSemantic(const char* upperCase)
|
||||
{
|
||||
auto it = SemanticMap->find(upperCase);
|
||||
if (it != SemanticMap->end())
|
||||
return it->second;
|
||||
else
|
||||
return glslang::EbvNone;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
int token = ppContext.tokenize(ppToken);
|
||||
if (token == EndOfInput)
|
||||
return EHTokNone;
|
||||
|
||||
tokenText = ppToken.name;
|
||||
loc = ppToken.loc;
|
||||
parserToken->loc = loc;
|
||||
switch (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 PPAtomAddAssign: return EHTokAddAssign;
|
||||
case PPAtomSubAssign: return EHTokSubAssign;
|
||||
case PPAtomMulAssign: return EHTokMulAssign;
|
||||
case PPAtomDivAssign: return EHTokDivAssign;
|
||||
case PPAtomModAssign: 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 PpAtomColonColon: return EHTokColonColon;
|
||||
|
||||
case PpAtomConstInt: parserToken->i = ppToken.ival; return EHTokIntConstant;
|
||||
case PpAtomConstUint: parserToken->i = ppToken.ival; return EHTokUintConstant;
|
||||
case PpAtomConstFloat16: parserToken->d = ppToken.dval; return EHTokFloat16Constant;
|
||||
case PpAtomConstFloat: parserToken->d = ppToken.dval; return EHTokFloatConstant;
|
||||
case PpAtomConstDouble: parserToken->d = ppToken.dval; return EHTokDoubleConstant;
|
||||
case PpAtomIdentifier:
|
||||
{
|
||||
EHlslTokenClass token = tokenizeIdentifier();
|
||||
return token;
|
||||
}
|
||||
|
||||
case PpAtomConstString: {
|
||||
parserToken->string = NewPoolTString(tokenText);
|
||||
return EHTokStringConstant;
|
||||
}
|
||||
|
||||
case EndOfInput: return EHTokNone;
|
||||
|
||||
default:
|
||||
if (token < PpAtomMaxSingle) {
|
||||
char buf[2];
|
||||
buf[0] = (char)token;
|
||||
buf[1] = 0;
|
||||
parseContext.error(loc, "unexpected token", buf, "");
|
||||
} else if (tokenText[0] != 0)
|
||||
parseContext.error(loc, "unexpected token", tokenText, "");
|
||||
else
|
||||
parseContext.error(loc, "unexpected token", "", "");
|
||||
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:
|
||||
case EHTokPrecise:
|
||||
case EHTokLayout:
|
||||
case EHTokGloballyCoherent:
|
||||
case EHTokInline:
|
||||
return keyword;
|
||||
|
||||
// primitive types
|
||||
case EHTokPoint:
|
||||
case EHTokLine:
|
||||
case EHTokTriangle:
|
||||
case EHTokLineAdj:
|
||||
case EHTokTriangleAdj:
|
||||
return keyword;
|
||||
|
||||
// stream out types
|
||||
case EHTokPointStream:
|
||||
case EHTokLineStream:
|
||||
case EHTokTriangleStream:
|
||||
return keyword;
|
||||
|
||||
// Tessellation patches
|
||||
case EHTokInputPatch:
|
||||
case EHTokOutputPatch:
|
||||
return keyword;
|
||||
|
||||
case EHTokBuffer:
|
||||
case EHTokVector:
|
||||
case EHTokMatrix:
|
||||
return keyword;
|
||||
|
||||
// scalar types
|
||||
case EHTokVoid:
|
||||
case EHTokString:
|
||||
case EHTokBool:
|
||||
case EHTokInt:
|
||||
case EHTokUint:
|
||||
case EHTokUint64:
|
||||
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:
|
||||
case EHTokHalf1:
|
||||
case EHTokHalf2:
|
||||
case EHTokHalf3:
|
||||
case EHTokHalf4:
|
||||
case EHTokMin16float1:
|
||||
case EHTokMin16float2:
|
||||
case EHTokMin16float3:
|
||||
case EHTokMin16float4:
|
||||
case EHTokMin10float1:
|
||||
case EHTokMin10float2:
|
||||
case EHTokMin10float3:
|
||||
case EHTokMin10float4:
|
||||
case EHTokMin16int1:
|
||||
case EHTokMin16int2:
|
||||
case EHTokMin16int3:
|
||||
case EHTokMin16int4:
|
||||
case EHTokMin12int1:
|
||||
case EHTokMin12int2:
|
||||
case EHTokMin12int3:
|
||||
case EHTokMin12int4:
|
||||
case EHTokMin16uint1:
|
||||
case EHTokMin16uint2:
|
||||
case EHTokMin16uint3:
|
||||
case EHTokMin16uint4:
|
||||
|
||||
// matrix types
|
||||
case EHTokBool1x1:
|
||||
case EHTokBool1x2:
|
||||
case EHTokBool1x3:
|
||||
case EHTokBool1x4:
|
||||
case EHTokBool2x1:
|
||||
case EHTokBool2x2:
|
||||
case EHTokBool2x3:
|
||||
case EHTokBool2x4:
|
||||
case EHTokBool3x1:
|
||||
case EHTokBool3x2:
|
||||
case EHTokBool3x3:
|
||||
case EHTokBool3x4:
|
||||
case EHTokBool4x1:
|
||||
case EHTokBool4x2:
|
||||
case EHTokBool4x3:
|
||||
case EHTokBool4x4:
|
||||
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 EHTokUint1x1:
|
||||
case EHTokUint1x2:
|
||||
case EHTokUint1x3:
|
||||
case EHTokUint1x4:
|
||||
case EHTokUint2x1:
|
||||
case EHTokUint2x2:
|
||||
case EHTokUint2x3:
|
||||
case EHTokUint2x4:
|
||||
case EHTokUint3x1:
|
||||
case EHTokUint3x2:
|
||||
case EHTokUint3x3:
|
||||
case EHTokUint3x4:
|
||||
case EHTokUint4x1:
|
||||
case EHTokUint4x2:
|
||||
case EHTokUint4x3:
|
||||
case EHTokUint4x4:
|
||||
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 EHTokHalf1x1:
|
||||
case EHTokHalf1x2:
|
||||
case EHTokHalf1x3:
|
||||
case EHTokHalf1x4:
|
||||
case EHTokHalf2x1:
|
||||
case EHTokHalf2x2:
|
||||
case EHTokHalf2x3:
|
||||
case EHTokHalf2x4:
|
||||
case EHTokHalf3x1:
|
||||
case EHTokHalf3x2:
|
||||
case EHTokHalf3x3:
|
||||
case EHTokHalf3x4:
|
||||
case EHTokHalf4x1:
|
||||
case EHTokHalf4x2:
|
||||
case EHTokHalf4x3:
|
||||
case EHTokHalf4x4:
|
||||
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:
|
||||
case EHTokRWTexture1d:
|
||||
case EHTokRWTexture1darray:
|
||||
case EHTokRWTexture2d:
|
||||
case EHTokRWTexture2darray:
|
||||
case EHTokRWTexture3d:
|
||||
case EHTokRWBuffer:
|
||||
case EHTokAppendStructuredBuffer:
|
||||
case EHTokByteAddressBuffer:
|
||||
case EHTokConsumeStructuredBuffer:
|
||||
case EHTokRWByteAddressBuffer:
|
||||
case EHTokRWStructuredBuffer:
|
||||
case EHTokStructuredBuffer:
|
||||
case EHTokTextureBuffer:
|
||||
case EHTokSubpassInput:
|
||||
case EHTokSubpassInputMS:
|
||||
return keyword;
|
||||
|
||||
// variable, user type, ...
|
||||
case EHTokClass:
|
||||
case EHTokStruct:
|
||||
case EHTokTypedef:
|
||||
case EHTokCBuffer:
|
||||
case EHTokConstantBuffer:
|
||||
case EHTokTBuffer:
|
||||
case EHTokThis:
|
||||
case EHTokNamespace:
|
||||
return keyword;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
109
Externals/glslang/hlsl/hlslScanContext.h
vendored
109
Externals/glslang/hlsl/hlslScanContext.h
vendored
@ -1,109 +0,0 @@
|
||||
//
|
||||
// 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) { 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;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// 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&);
|
||||
glslang::TBuiltInVariable mapSemantic(const char*);
|
||||
|
||||
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_
|
150
Externals/glslang/hlsl/hlslTokenStream.cpp
vendored
150
Externals/glslang/hlsl/hlslTokenStream.cpp
vendored
@ -1,150 +0,0 @@
|
||||
//
|
||||
// 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 < tokenBufferSize);
|
||||
preTokenStack[preTokenStackSize++] = tok;
|
||||
}
|
||||
|
||||
HlslToken HlslTokenStream::popPreToken()
|
||||
{
|
||||
assert(preTokenStackSize > 0);
|
||||
|
||||
return preTokenStack[--preTokenStackSize];
|
||||
}
|
||||
|
||||
void HlslTokenStream::pushTokenBuffer(const HlslToken& tok)
|
||||
{
|
||||
tokenBuffer[tokenBufferPos] = tok;
|
||||
tokenBufferPos = (tokenBufferPos+1) % tokenBufferSize;
|
||||
}
|
||||
|
||||
HlslToken HlslTokenStream::popTokenBuffer()
|
||||
{
|
||||
// Back up
|
||||
tokenBufferPos = (tokenBufferPos+tokenBufferSize-1) % tokenBufferSize;
|
||||
|
||||
return tokenBuffer[tokenBufferPos];
|
||||
}
|
||||
|
||||
//
|
||||
// Make a new source of tokens, not from the source, but from an
|
||||
// already pre-processed token stream.
|
||||
//
|
||||
// This interrupts current token processing which must be restored
|
||||
// later. Some simplifying assumptions are made (and asserted).
|
||||
//
|
||||
void HlslTokenStream::pushTokenStream(const TVector<HlslToken>* tokens)
|
||||
{
|
||||
// not yet setup to interrupt a stream that has been receded
|
||||
// and not yet reconsumed
|
||||
assert(preTokenStackSize == 0);
|
||||
|
||||
// save current state
|
||||
currentTokenStack.push_back(token);
|
||||
|
||||
// set up new token stream
|
||||
tokenStreamStack.push_back(tokens);
|
||||
|
||||
// start position at first token:
|
||||
token = (*tokens)[0];
|
||||
tokenPosition.push_back(0);
|
||||
}
|
||||
|
||||
// Undo pushTokenStream(), see above
|
||||
void HlslTokenStream::popTokenStream()
|
||||
{
|
||||
tokenStreamStack.pop_back();
|
||||
tokenPosition.pop_back();
|
||||
token = currentTokenStack.back();
|
||||
currentTokenStack.pop_back();
|
||||
}
|
||||
|
||||
// Load 'token' with the next token in the stream of tokens.
|
||||
void HlslTokenStream::advanceToken()
|
||||
{
|
||||
pushTokenBuffer(token);
|
||||
if (preTokenStackSize > 0)
|
||||
token = popPreToken();
|
||||
else {
|
||||
if (tokenStreamStack.size() == 0)
|
||||
scanner.tokenize(token);
|
||||
else {
|
||||
++tokenPosition.back();
|
||||
if (tokenPosition.back() >= (int)tokenStreamStack.back()->size())
|
||||
token.tokenClass = EHTokNone;
|
||||
else
|
||||
token = (*tokenStreamStack.back())[tokenPosition.back()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
96
Externals/glslang/hlsl/hlslTokenStream.h
vendored
96
Externals/glslang/hlsl/hlslTokenStream.h
vendored
@ -1,96 +0,0 @@
|
||||
//
|
||||
// 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), tokenBufferPos(0) { }
|
||||
virtual ~HlslTokenStream() { }
|
||||
|
||||
public:
|
||||
void advanceToken();
|
||||
void recedeToken();
|
||||
bool acceptTokenClass(EHlslTokenClass);
|
||||
EHlslTokenClass peek() const;
|
||||
bool peekTokenClass(EHlslTokenClass) const;
|
||||
glslang::TBuiltInVariable mapSemantic(const char* upperCase) { return scanner.mapSemantic(upperCase); }
|
||||
|
||||
void pushTokenStream(const TVector<HlslToken>* tokens);
|
||||
void popTokenStream();
|
||||
|
||||
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 from source file
|
||||
TVector<const TVector<HlslToken>*> tokenStreamStack; // for getting the next token from an existing vector of tokens
|
||||
TVector<int> tokenPosition;
|
||||
TVector<HlslToken> currentTokenStack;
|
||||
|
||||
// This is the number of tokens we can recedeToken() over.
|
||||
static const int tokenBufferSize = 2;
|
||||
|
||||
// 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 2.
|
||||
HlslToken preTokenStack[tokenBufferSize];
|
||||
int preTokenStackSize;
|
||||
void pushPreToken(const HlslToken&);
|
||||
HlslToken popPreToken();
|
||||
|
||||
// Previously scanned tokens, not yet returned 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 2.
|
||||
HlslToken tokenBuffer[tokenBufferSize];
|
||||
int tokenBufferPos;
|
||||
void pushTokenBuffer(const HlslToken&);
|
||||
HlslToken popTokenBuffer();
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // HLSLTOKENSTREAM_H_
|
374
Externals/glslang/hlsl/hlslTokens.h
vendored
374
Externals/glslang/hlsl/hlslTokens.h
vendored
@ -1,374 +0,0 @@
|
||||
//
|
||||
// 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,
|
||||
EHTokLayout,
|
||||
EHTokGloballyCoherent,
|
||||
EHTokInline,
|
||||
|
||||
// primitive types
|
||||
EHTokPoint,
|
||||
EHTokLine,
|
||||
EHTokTriangle,
|
||||
EHTokLineAdj,
|
||||
EHTokTriangleAdj,
|
||||
|
||||
// stream out types
|
||||
EHTokPointStream,
|
||||
EHTokLineStream,
|
||||
EHTokTriangleStream,
|
||||
|
||||
// Tessellation patches
|
||||
EHTokInputPatch,
|
||||
EHTokOutputPatch,
|
||||
|
||||
// template types
|
||||
EHTokBuffer,
|
||||
EHTokVector,
|
||||
EHTokMatrix,
|
||||
|
||||
// scalar types
|
||||
EHTokVoid,
|
||||
EHTokString,
|
||||
EHTokBool,
|
||||
EHTokInt,
|
||||
EHTokUint,
|
||||
EHTokUint64,
|
||||
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,
|
||||
EHTokHalf1,
|
||||
EHTokHalf2,
|
||||
EHTokHalf3,
|
||||
EHTokHalf4,
|
||||
EHTokMin16float1,
|
||||
EHTokMin16float2,
|
||||
EHTokMin16float3,
|
||||
EHTokMin16float4,
|
||||
EHTokMin10float1,
|
||||
EHTokMin10float2,
|
||||
EHTokMin10float3,
|
||||
EHTokMin10float4,
|
||||
EHTokMin16int1,
|
||||
EHTokMin16int2,
|
||||
EHTokMin16int3,
|
||||
EHTokMin16int4,
|
||||
EHTokMin12int1,
|
||||
EHTokMin12int2,
|
||||
EHTokMin12int3,
|
||||
EHTokMin12int4,
|
||||
EHTokMin16uint1,
|
||||
EHTokMin16uint2,
|
||||
EHTokMin16uint3,
|
||||
EHTokMin16uint4,
|
||||
|
||||
// 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,
|
||||
EHTokHalf1x1,
|
||||
EHTokHalf1x2,
|
||||
EHTokHalf1x3,
|
||||
EHTokHalf1x4,
|
||||
EHTokHalf2x1,
|
||||
EHTokHalf2x2,
|
||||
EHTokHalf2x3,
|
||||
EHTokHalf2x4,
|
||||
EHTokHalf3x1,
|
||||
EHTokHalf3x2,
|
||||
EHTokHalf3x3,
|
||||
EHTokHalf3x4,
|
||||
EHTokHalf4x1,
|
||||
EHTokHalf4x2,
|
||||
EHTokHalf4x3,
|
||||
EHTokHalf4x4,
|
||||
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,
|
||||
EHTokRWTexture1d,
|
||||
EHTokRWTexture1darray,
|
||||
EHTokRWTexture2d,
|
||||
EHTokRWTexture2darray,
|
||||
EHTokRWTexture3d,
|
||||
EHTokRWBuffer,
|
||||
EHTokSubpassInput,
|
||||
EHTokSubpassInputMS,
|
||||
|
||||
// Structure buffer variants
|
||||
EHTokAppendStructuredBuffer,
|
||||
EHTokByteAddressBuffer,
|
||||
EHTokConsumeStructuredBuffer,
|
||||
EHTokRWByteAddressBuffer,
|
||||
EHTokRWStructuredBuffer,
|
||||
EHTokStructuredBuffer,
|
||||
EHTokTextureBuffer,
|
||||
|
||||
// variable, user type, ...
|
||||
EHTokIdentifier,
|
||||
EHTokClass,
|
||||
EHTokStruct,
|
||||
EHTokCBuffer,
|
||||
EHTokTBuffer,
|
||||
EHTokTypedef,
|
||||
EHTokThis,
|
||||
EHTokNamespace,
|
||||
EHTokConstantBuffer,
|
||||
|
||||
// constant
|
||||
EHTokFloat16Constant,
|
||||
EHTokFloatConstant,
|
||||
EHTokDoubleConstant,
|
||||
EHTokIntConstant,
|
||||
EHTokUintConstant,
|
||||
EHTokBoolConstant,
|
||||
EHTokStringConstant,
|
||||
|
||||
// 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,
|
||||
EHTokColonColon,
|
||||
EHTokSemicolon,
|
||||
EHTokBang,
|
||||
EHTokDash,
|
||||
EHTokTilde,
|
||||
EHTokPlus,
|
||||
EHTokStar,
|
||||
EHTokSlash,
|
||||
EHTokPercent,
|
||||
EHTokLeftAngle,
|
||||
EHTokRightAngle,
|
||||
EHTokVerticalBar,
|
||||
EHTokCaret,
|
||||
EHTokAmpersand,
|
||||
EHTokQuestion,
|
||||
};
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
#endif // EHLSLTOKENS_H_
|
54
Externals/glslang/hlsl/pch.h
vendored
54
Externals/glslang/hlsl/pch.h
vendored
@ -1,54 +0,0 @@
|
||||
#ifndef _PCH_H
|
||||
#define _PCH_H
|
||||
//
|
||||
// Copyright (C) 2018 The Khronos Group 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.
|
||||
//
|
||||
|
||||
#include "hlslParseHelper.h"
|
||||
#include "hlslScanContext.h"
|
||||
#include "hlslGrammar.h"
|
||||
#include "hlslAttributes.h"
|
||||
|
||||
#include "../glslang/MachineIndependent/Scan.h"
|
||||
#include "../glslang/MachineIndependent/preprocessor/PpContext.h"
|
||||
|
||||
#include "../glslang/OSDependent/osinclude.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cctype>
|
||||
#include <array>
|
||||
#include <set>
|
||||
|
||||
|
||||
#endif /* _PCH_H */
|
@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (C) 2018 The Khronos Group Inc.
|
||||
// Copyright (C) 2020 Google, Inc.
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +15,7 @@
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
//
|
||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
||||
// 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.
|
||||
//
|
||||
@ -32,4 +33,9 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
// The HLSL source is directly embedded into the glslang target when ENABLE_HLSL
|
||||
// is set.
|
||||
// This source now lives at: glslang/HLSL/
|
||||
// The HLSL target is now just a stub that exists for backwards compatibility
|
||||
// for projects that referenced this target. As a target requires at least one
|
||||
// source file to build, this file acts as that stub.
|
Reference in New Issue
Block a user