From f49820dd6b376ccc477dc77e11cf157d006299a5 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 16 Jun 2020 11:54:34 +0100 Subject: [PATCH] Move hlsl/ source to glslang/HLSL/ Now that the HLSL source files are part of the `glslang` target (#2271), it makes sense for these to sit in the `glslang` directory. Changed the case of the directory from `hlsl` to `HLSL` to better match the sibling directories. --- Android.mk | 16 +-- BUILD.bazel | 8 +- BUILD.gn | 30 +++--- glslang/CMakeLists.txt | 30 +++--- {hlsl => glslang/HLSL}/hlslAttributes.cpp | 0 {hlsl => glslang/HLSL}/hlslAttributes.h | 4 +- {hlsl => glslang/HLSL}/hlslGrammar.cpp | 0 {hlsl => glslang/HLSL}/hlslGrammar.h | 0 {hlsl => glslang/HLSL}/hlslOpMap.cpp | 0 {hlsl => glslang/HLSL}/hlslOpMap.h | 0 {hlsl => glslang/HLSL}/hlslParseHelper.cpp | 110 ++++++++++----------- {hlsl => glslang/HLSL}/hlslParseHelper.h | 12 +-- {hlsl => glslang/HLSL}/hlslParseables.cpp | 0 {hlsl => glslang/HLSL}/hlslParseables.h | 2 +- {hlsl => glslang/HLSL}/hlslScanContext.cpp | 10 +- {hlsl => glslang/HLSL}/hlslScanContext.h | 2 +- {hlsl => glslang/HLSL}/hlslTokenStream.cpp | 0 {hlsl => glslang/HLSL}/hlslTokenStream.h | 0 {hlsl => glslang/HLSL}/hlslTokens.h | 0 {hlsl => glslang/HLSL}/pch.cpp | 0 {hlsl => glslang/HLSL}/pch.h | 15 ++- glslang/MachineIndependent/ShaderLang.cpp | 6 +- hlsl/CMakeLists.txt | 1 + hlsl/stub.cpp | 1 + 24 files changed, 124 insertions(+), 123 deletions(-) rename {hlsl => glslang/HLSL}/hlslAttributes.cpp (100%) rename {hlsl => glslang/HLSL}/hlslAttributes.h (94%) rename {hlsl => glslang/HLSL}/hlslGrammar.cpp (100%) rename {hlsl => glslang/HLSL}/hlslGrammar.h (100%) rename {hlsl => glslang/HLSL}/hlslOpMap.cpp (100%) rename {hlsl => glslang/HLSL}/hlslOpMap.h (100%) rename {hlsl => glslang/HLSL}/hlslParseHelper.cpp (99%) rename {hlsl => glslang/HLSL}/hlslParseHelper.h (99%) rename {hlsl => glslang/HLSL}/hlslParseables.cpp (100%) rename {hlsl => glslang/HLSL}/hlslParseables.h (97%) rename {hlsl => glslang/HLSL}/hlslScanContext.cpp (99%) rename {hlsl => glslang/HLSL}/hlslScanContext.h (98%) rename {hlsl => glslang/HLSL}/hlslTokenStream.cpp (100%) rename {hlsl => glslang/HLSL}/hlslTokenStream.h (100%) rename {hlsl => glslang/HLSL}/hlslTokens.h (100%) rename {hlsl => glslang/HLSL}/pch.cpp (100%) rename {hlsl => glslang/HLSL}/pch.h (92%) diff --git a/Android.mk b/Android.mk index fda81a7c..524afe8c 100644 --- a/Android.mk +++ b/Android.mk @@ -27,15 +27,15 @@ include $(CLEAR_VARS) LOCAL_MODULE:=HLSL LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES) LOCAL_SRC_FILES:= \ - hlsl/hlslAttributes.cpp \ - hlsl/hlslGrammar.cpp \ - hlsl/hlslOpMap.cpp \ - hlsl/hlslParseables.cpp \ - hlsl/hlslParseHelper.cpp \ - hlsl/hlslScanContext.cpp \ - hlsl/hlslTokenStream.cpp + glslang/HLSL/hlslAttributes.cpp \ + glslang/HLSL/hlslGrammar.cpp \ + glslang/HLSL/hlslOpMap.cpp \ + glslang/HLSL/hlslParseables.cpp \ + glslang/HLSL/hlslParseHelper.cpp \ + glslang/HLSL/hlslScanContext.cpp \ + glslang/HLSL/hlslTokenStream.cpp LOCAL_C_INCLUDES:=$(LOCAL_PATH) \ - $(LOCAL_PATH)/hlsl + $(LOCAL_PATH)/glslang/HLSL include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) diff --git a/BUILD.bazel b/BUILD.bazel index 5930608a..442a94c2 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -34,15 +34,15 @@ cc_library( srcs = glob( [ "glslang/GenericCodeGen/*.cpp", + "glslang/HLSL/*.cpp", "glslang/MachineIndependent/*.cpp", "glslang/MachineIndependent/preprocessor/*.cpp", - "hlsl/*.cpp", ], exclude = [ + "glslang/HLSL/pch.cpp", + "glslang/HLSL/pch.h", "glslang/MachineIndependent/pch.cpp", "glslang/MachineIndependent/pch.h", - "hlsl/pch.cpp", - "hlsl/pch.h", ], ) + [ "OGLCompilersDLL/InitializeDll.cpp", @@ -53,10 +53,10 @@ cc_library( ["glslang/OSDependent/Unix/ossource.cpp"], }), hdrs = glob([ + "glslang/HLSL/*.h", "glslang/Include/*.h", "glslang/MachineIndependent/*.h", "glslang/MachineIndependent/preprocessor/*.h", - "hlsl/*.h", ]) + [ "OGLCompilersDLL/InitializeDll.h", "StandAlone/DirStackFileIncluder.h", diff --git a/BUILD.gn b/BUILD.gn index 49b4b0a3..cb44707c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -88,6 +88,21 @@ source_set("glslang_sources") { "SPIRV/spvIR.h", "glslang/GenericCodeGen/CodeGen.cpp", "glslang/GenericCodeGen/Link.cpp", + "glslang/HLSL/hlslAttributes.cpp", + "glslang/HLSL/hlslAttributes.h", + "glslang/HLSL/hlslGrammar.cpp", + "glslang/HLSL/hlslGrammar.h", + "glslang/HLSL/hlslOpMap.cpp", + "glslang/HLSL/hlslOpMap.h", + "glslang/HLSL/hlslParseables.cpp", + "glslang/HLSL/hlslParseables.h", + "glslang/HLSL/hlslParseHelper.cpp", + "glslang/HLSL/hlslParseHelper.h", + "glslang/HLSL/hlslScanContext.cpp", + "glslang/HLSL/hlslScanContext.h", + "glslang/HLSL/hlslTokens.h", + "glslang/HLSL/hlslTokenStream.cpp", + "glslang/HLSL/hlslTokenStream.h", "glslang/Include/BaseTypes.h", "glslang/Include/Common.h", "glslang/Include/ConstantUnion.h", @@ -147,21 +162,6 @@ source_set("glslang_sources") { "glslang/MachineIndependent/reflection.h", "glslang/OSDependent/osinclude.h", "glslang/Public/ShaderLang.h", - "hlsl/hlslAttributes.cpp", - "hlsl/hlslAttributes.h", - "hlsl/hlslGrammar.cpp", - "hlsl/hlslGrammar.h", - "hlsl/hlslOpMap.cpp", - "hlsl/hlslOpMap.h", - "hlsl/hlslParseHelper.cpp", - "hlsl/hlslParseHelper.h", - "hlsl/hlslParseables.cpp", - "hlsl/hlslParseables.h", - "hlsl/hlslScanContext.cpp", - "hlsl/hlslScanContext.h", - "hlsl/hlslTokenStream.cpp", - "hlsl/hlslTokenStream.h", - "hlsl/hlslTokens.h", ] defines = [ "ENABLE_OPT=1" ] diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index 606bbdcb..c59c9741 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -84,23 +84,23 @@ glslang_pch(SOURCES MachineIndependent/pch.cpp) if(ENABLE_HLSL) list(APPEND SOURCES - ../hlsl/hlslAttributes.cpp - ../hlsl/hlslParseHelper.cpp - ../hlsl/hlslScanContext.cpp - ../hlsl/hlslOpMap.cpp - ../hlsl/hlslTokenStream.cpp - ../hlsl/hlslGrammar.cpp - ../hlsl/hlslParseables.cpp) + HLSL/hlslAttributes.cpp + HLSL/hlslParseHelper.cpp + HLSL/hlslScanContext.cpp + HLSL/hlslOpMap.cpp + HLSL/hlslTokenStream.cpp + HLSL/hlslGrammar.cpp + HLSL/hlslParseables.cpp) list(APPEND HEADERS - ../hlsl/hlslAttributes.h - ../hlsl/hlslParseHelper.h - ../hlsl/hlslTokens.h - ../hlsl/hlslScanContext.h - ../hlsl/hlslOpMap.h - ../hlsl/hlslTokenStream.h - ../hlsl/hlslGrammar.h - ../hlsl/hlslParseables.h) + HLSL/hlslAttributes.h + HLSL/hlslParseHelper.h + HLSL/hlslTokens.h + HLSL/hlslScanContext.h + HLSL/hlslOpMap.h + HLSL/hlslTokenStream.h + HLSL/hlslGrammar.h + HLSL/hlslParseables.h) endif(ENABLE_HLSL) add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS}) diff --git a/hlsl/hlslAttributes.cpp b/glslang/HLSL/hlslAttributes.cpp similarity index 100% rename from hlsl/hlslAttributes.cpp rename to glslang/HLSL/hlslAttributes.cpp diff --git a/hlsl/hlslAttributes.h b/glslang/HLSL/hlslAttributes.h similarity index 94% rename from hlsl/hlslAttributes.h rename to glslang/HLSL/hlslAttributes.h index b1cc0372..62faa5b8 100644 --- a/hlsl/hlslAttributes.h +++ b/glslang/HLSL/hlslAttributes.h @@ -39,8 +39,8 @@ #include #include -#include "../glslang/MachineIndependent/attribute.h" -#include "../glslang/MachineIndependent/SymbolTable.h" +#include "../MachineIndependent/attribute.h" +#include "../MachineIndependent/SymbolTable.h" #include "hlslScanContext.h" namespace glslang { diff --git a/hlsl/hlslGrammar.cpp b/glslang/HLSL/hlslGrammar.cpp similarity index 100% rename from hlsl/hlslGrammar.cpp rename to glslang/HLSL/hlslGrammar.cpp diff --git a/hlsl/hlslGrammar.h b/glslang/HLSL/hlslGrammar.h similarity index 100% rename from hlsl/hlslGrammar.h rename to glslang/HLSL/hlslGrammar.h diff --git a/hlsl/hlslOpMap.cpp b/glslang/HLSL/hlslOpMap.cpp similarity index 100% rename from hlsl/hlslOpMap.cpp rename to glslang/HLSL/hlslOpMap.cpp diff --git a/hlsl/hlslOpMap.h b/glslang/HLSL/hlslOpMap.h similarity index 100% rename from hlsl/hlslOpMap.h rename to glslang/HLSL/hlslOpMap.h diff --git a/hlsl/hlslParseHelper.cpp b/glslang/HLSL/hlslParseHelper.cpp similarity index 99% rename from hlsl/hlslParseHelper.cpp rename to glslang/HLSL/hlslParseHelper.cpp index 18ee4c46..dff32648 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/glslang/HLSL/hlslParseHelper.cpp @@ -39,11 +39,11 @@ #include "hlslGrammar.h" #include "hlslAttributes.h" -#include "../glslang/Include/Common.h" -#include "../glslang/MachineIndependent/Scan.h" -#include "../glslang/MachineIndependent/preprocessor/PpContext.h" +#include "../Include/Common.h" +#include "../MachineIndependent/Scan.h" +#include "../MachineIndependent/preprocessor/PpContext.h" -#include "../glslang/OSDependent/osinclude.h" +#include "../OSDependent/osinclude.h" #include #include @@ -814,7 +814,7 @@ TIntermTyped* HlslParseContext::handleBracketDereference(const TSourceLoc& loc, base->getAsSymbolNode()->getName().c_str(), ""); else error(loc, " left of '[' is not of type array, matrix, or vector ", "expression", ""); - } else if (base->getType().getQualifier().isFrontEndConstant() && + } else if (base->getType().getQualifier().isFrontEndConstant() && index->getQualifier().isFrontEndConstant()) { // both base and index are front-end constants checkIndex(loc, base->getType(), indexValue); @@ -1848,7 +1848,7 @@ void HlslParseContext::handleEntryPointAttributes(const TSourceLoc& loc, const T error(loc, "invalid partitioning", "", ""); } else { TVertexSpacing partitioning = EvsNone; - + if (partitionStr == "integer") { partitioning = EvsEqual; } else if (partitionStr == "fractional_even") { @@ -2484,7 +2484,7 @@ TIntermTyped* HlslParseContext::assignPosition(const TSourceLoc& loc, TOperator TIntermTyped* rhsElement = intermediate.addIndex(EOpIndexDirect, tempSymR, index, loc); const TType derefType(right->getType(), 0); - + lhsElement->setType(derefType); rhsElement->setType(derefType); @@ -2504,7 +2504,7 @@ TIntermTyped* HlslParseContext::assignPosition(const TSourceLoc& loc, TOperator return assignList; } - + // Clip and cull distance require special handling due to a semantic mismatch. In HLSL, // these can be float scalar, float vector, or arrays of float scalar or float vector. // In SPIR-V, they are arrays of scalar floats in all cases. We must copy individual components @@ -2573,7 +2573,7 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc vecItems += (*semanticNSize)[x]; arrayLoc += (*semanticNSize)[x]; } - + // It can have up to 2 array dimensions (in the case of geometry shader inputs) const TArraySizes* const internalArraySizes = internalNode->getType().getArraySizes(); @@ -2594,7 +2594,7 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc // into a float array, or vice versa. Here, we make the array the right size and type, // which depends on the incoming data, which has several potential dimensions: // * Semantic ID - // * vector size + // * vector size // * array size // Of those, semantic ID and array size cannot appear simultaneously. // @@ -2655,7 +2655,7 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc // Holds individual component assignments as we make them. TIntermTyped* clipCullAssign = nullptr; - // If the types are homomorphic, use a simple assign. No need to mess about with + // If the types are homomorphic, use a simple assign. No need to mess about with // individual components. if (clipCullSym->getType().isArray() == internalNode->getType().isArray() && clipCullInnerArraySize == internalInnerArraySize && @@ -2766,7 +2766,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op if (binaryNode == nullptr) return false; - return (binaryNode->getOp() == EOpIndexDirect || binaryNode->getOp() == EOpIndexIndirect) && + return (binaryNode->getOp() == EOpIndexDirect || binaryNode->getOp() == EOpIndexIndirect) && wasSplit(binaryNode->getLeft()); }; @@ -2798,7 +2798,7 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op const bool isFlattenLeft = wasFlattened(leftSymbol); const bool isFlattenRight = wasFlattened(rightSymbol); - // OK to do a single assign if neither side is split or flattened. Otherwise, + // OK to do a single assign if neither side is split or flattened. Otherwise, // fall through to a member-wise copy. if (!isFlattenLeft && !isFlattenRight && !isSplitLeft && !isSplitRight) { // Clip and cull distance requires more processing. See comment above assignClipCullDistance. @@ -3430,9 +3430,9 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte // Byte address buffers index in bytes (only multiples of 4 permitted... not so much a byte address // buffer then, but that's what it calls itself. - const bool isByteAddressBuffer = (builtInType == EbvByteAddressBuffer || + const bool isByteAddressBuffer = (builtInType == EbvByteAddressBuffer || builtInType == EbvRWByteAddressBuffer); - + if (isByteAddressBuffer) argIndex = intermediate.addBinaryNode(EOpRightShift, argIndex, @@ -3447,7 +3447,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte const TType derefType(argArray->getType(), 0); node->setType(derefType); } - + break; case EOpMethodLoad2: @@ -3573,8 +3573,8 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte const TType indexType(argValue->getType(), 0); rValue->setType(indexType); } - - TIntermTyped* assign = intermediate.addAssign(EOpAssign, lValue, rValue, loc); + + TIntermTyped* assign = intermediate.addAssign(EOpAssign, lValue, rValue, loc); body = intermediate.growAggregate(body, assign); } @@ -3751,7 +3751,7 @@ TIntermConstantUnion* HlslParseContext::getSamplePosArray(int count) } TConstUnionArray* values = new TConstUnionArray(numSamples*2); - + for (int pos=0; possetType(TType(node->getType().getBasicType(), EvqTemporary, node->getVectorSize())); TIntermTyped* convertedResult = nullptr; - + TType retType; getTextureReturnType(sampler, retType); @@ -3811,7 +3811,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType for (unsigned m = 0; m < unsigned(retType.getStruct()->size()); ++m) { const TType memberType(retType, m); // dereferenced type of the member we're about to assign. - + // Check for bad struct members. This should have been caught upstream. Complain, because // wwe don't know what to do with it. This algorithm could be generalized to handle // other things, e.g, sub-structures, but HLSL doesn't allow them. @@ -3819,7 +3819,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType error(loc, "expected: scalar or vector type in texture structure", "", ""); return nullptr; } - + // Index into the struct variable to find the member to assign. TIntermTyped* structMember = intermediate.addIndex(EOpIndexDirectStruct, intermediate.addSymbol(*structVar, loc), @@ -3841,14 +3841,14 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType TIntermTyped* structVecComponent = intermediate.addIndex(EOpIndexDirect, structMember, intermediate.addConstantUnion(component, loc), loc); - + memberAssign = intermediate.addAssign(EOpAssign, structVecComponent, vec4Member, loc); } else { // Scalar member: we can assign to it directly. memberAssign = intermediate.addAssign(EOpAssign, structMember, vec4Member, loc); } - + conversionAggregate->getSequence().push_back(memberAssign); } } @@ -3887,7 +3887,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType if (arguments->getAsTyped()->getBasicType() != EbtSampler) return; } else { - if (argAggregate->getSequence().size() == 0 || + if (argAggregate->getSequence().size() == 0 || argAggregate->getSequence()[0] == nullptr || argAggregate->getSequence()[0]->getAsTyped()->getBasicType() != EbtSampler) return; @@ -4584,13 +4584,13 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType int count = 0; for (int val = 2; val <= 16; val *= 2) idxtest[count++] = - intermediate.addBinaryNode(EOpEqual, + intermediate.addBinaryNode(EOpEqual, intermediate.addSymbol(*outSampleCount, loc), intermediate.addConstantUnion(val, loc), loc, TType(EbtBool)); const TOperator idxOp = (argSampIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect : EOpIndexIndirect; - + // Create index ops into position arrays given sample index. // TODO: should it be clamped? TIntermTyped* index[4]; @@ -4605,13 +4605,13 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType // (sampleCount == 4) ? pos4[idx] : // (sampleCount == 8) ? pos8[idx] : // (sampleCount == 16) ? pos16[idx] : float2(0,0); - TIntermTyped* test = - intermediate.addSelection(idxtest[0], index[0], - intermediate.addSelection(idxtest[1], index[1], + TIntermTyped* test = + intermediate.addSelection(idxtest[0], index[0], + intermediate.addSelection(idxtest[1], index[1], intermediate.addSelection(idxtest[2], index[2], - intermediate.addSelection(idxtest[3], index[3], + intermediate.addSelection(idxtest[3], index[3], getSamplePosArray(1), loc), loc), loc), loc); - + compoundStatement = intermediate.growAggregate(compoundStatement, test); compoundStatement->setOperator(EOpSequence); compoundStatement->setLoc(loc); @@ -4624,7 +4624,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType case EOpSubpassLoad: { - const TIntermTyped* argSubpass = + const TIntermTyped* argSubpass = argAggregate ? argAggregate->getSequence()[0]->getAsTyped() : arguments->getAsTyped(); @@ -4639,7 +4639,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType break; } - + default: break; // most pass through unchanged @@ -5159,7 +5159,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& for (int idx = 0; idx < vecSize; ++idx) { TIntermTyped* idxConst = intermediate.addConstantUnion(idx, loc, true); - TIntermTyped* component = argValue->getType().isVector() ? + TIntermTyped* component = argValue->getType().isVector() ? intermediate.addIndex(EOpIndexDirect, argValue, idxConst, loc) : argValue; if (component != argValue) @@ -5171,7 +5171,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& unpackOp->setLoc(loc); TIntermTyped* lowOrder = intermediate.addIndex(EOpIndexDirect, unpackOp, zero, loc); - + if (result != nullptr) { result->getSequence().push_back(lowOrder); node = result; @@ -5179,7 +5179,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& node = lowOrder; } } - + break; } @@ -5210,7 +5210,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& for (int idx = 0; idx < vecSize; ++idx) { TIntermTyped* idxConst = intermediate.addConstantUnion(idx, loc, true); - TIntermTyped* component = argValue->getType().isVector() ? + TIntermTyped* component = argValue->getType().isVector() ? intermediate.addIndex(EOpIndexDirect, argValue, idxConst, loc) : argValue; if (component != argValue) @@ -5221,7 +5221,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& vec2ComponentAndZero->getSequence().push_back(zero); vec2ComponentAndZero->setType(TType(EbtFloat, EvqTemporary, 2)); vec2ComponentAndZero->setLoc(loc); - + TIntermTyped* packOp = new TIntermUnary(EOpPackHalf2x16); packOp->getAsUnaryNode()->setOperand(vec2ComponentAndZero); packOp->setLoc(loc); @@ -5294,7 +5294,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& TIntermTyped* notinf = handleUnaryMath(loc, "!", EOpLogicalNot, isinf); notinf->setType(boolType); - + TIntermTyped* andNode = handleBinaryMath(loc, "and", EOpLogicalAnd, notnan, notinf); andNode->setType(boolType); @@ -5678,7 +5678,7 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI // means take 'arguments' itself as the one argument. TIntermTyped* arg = function.getParamCount() == 1 ? arguments->getAsTyped() - : (aggregate ? + : (aggregate ? aggregate->getSequence()[param]->getAsTyped() : arguments->getAsTyped()); if (*function[param].type != arg->getType()) { @@ -5749,7 +5749,7 @@ void HlslParseContext::expandArguments(const TSourceLoc& loc, const TFunction& f else if (args.size() > 1) { if (function.getParamCount() + functionParamNumberOffset == 1) { arguments = intermediate.makeAggregate(args.front()); - std::for_each(args.begin() + 1, args.end(), + std::for_each(args.begin() + 1, args.end(), [&](TIntermTyped* arg) { arguments = intermediate.growAggregate(arguments, arg); }); @@ -5768,7 +5768,7 @@ void HlslParseContext::expandArguments(const TSourceLoc& loc, const TFunction& f // means take 'arguments' itself as the one argument. TIntermTyped* arg = function.getParamCount() == 1 ? arguments->getAsTyped() - : (aggregate ? + : (aggregate ? aggregate->getSequence()[param + functionParamNumberOffset]->getAsTyped() : arguments->getAsTyped()); @@ -8568,7 +8568,7 @@ TIntermTyped* HlslParseContext::convertArray(TIntermTyped* node, const TType& ty // bump up to the next component to consume const auto getNextComponent = [&]() { TIntermTyped* component; - component = handleBracketDereference(node->getLoc(), constructee, + component = handleBracketDereference(node->getLoc(), constructee, intermediate.addConstantUnion(constructeeElement, node->getLoc())); if (component->isVector()) component = handleBracketDereference(node->getLoc(), component, @@ -9640,7 +9640,7 @@ bool HlslParseContext::setTextureReturnType(TSampler& sampler, const TType& retT // Insert it in the vector that tracks struct return types. sampler.structReturnIndex = unsigned(textureReturnStruct.size()); textureReturnStruct.push_back(members); - + // Success! return true; } @@ -9688,7 +9688,7 @@ const TFunction* HlslParseContext::findPatchConstantFunction(const TSourceLoc& l TVector candidateList; bool builtIn; symbolTable.findFunctionNameList(mangledName, candidateList, builtIn); - + // We have to have one and only one, or we don't know which to pick: the patchconstantfunc does not // allow any disambiguation of overloads. if (candidateList.empty()) { @@ -9759,26 +9759,26 @@ void HlslParseContext::addPatchConstantInvocation() return type.isSizedArray() && biType == EbvOutputPatch; }; - + // We will perform these steps. Each is in a scoped block for separation: they could // become separate functions to make addPatchConstantInvocation shorter. - // + // // 1. Union the interfaces, and create built-ins for anything present in the PCF and // declared as a built-in variable that isn't present in the entry point's signature. // // 2. Synthesizes a call to the patchconstfunction using built-in variables from either main, // or the ones we created. Matching is based on built-in type. We may use synthesized // variables from (1) above. - // + // // 2B: Synthesize per control point invocations of wrapped entry point if the PCF requires them. // // 3. Create a return sequence: copy the return value (if any) from the PCF to a // (non-sanitized) output variable. In case this may involve multiple copies, such as for // an arrayed variable, a temporary copy of the PCF output is created to avoid multiple // indirections into a complex R-value coming from the call to the PCF. - // + // // 4. Create a barrier. - // + // // 5/5B. Call the PCF inside an if test for (invocation id == 0). TFunction* patchConstantFunctionPtr = const_cast(findPatchConstantFunction(loc)); @@ -9885,7 +9885,7 @@ void HlslParseContext::addPatchConstantInvocation() } else { // find which built-in it is const TBuiltInVariable biType = patchConstantFunction[p].getDeclaredBuiltIn(); - + if (biType == EbvInputPatch && inputPatch == nullptr) { error(loc, "unimplemented: PCF input patch without entry point input patch parameter", "", ""); return; @@ -9992,7 +9992,7 @@ void HlslParseContext::addPatchConstantInvocation() element->setType(derefType); element->setLoc(loc); - pcfCallSequence = intermediate.growAggregate(pcfCallSequence, + pcfCallSequence = intermediate.growAggregate(pcfCallSequence, handleAssign(loc, EOpAssign, element, callReturn)); } } @@ -10041,7 +10041,7 @@ void HlslParseContext::addPatchConstantInvocation() pcfCallSequence = intermediate.growAggregate(pcfCallSequence, pcfCall); } - // ================ Step 4: Barrier ================ + // ================ Step 4: Barrier ================ TIntermTyped* barrier = new TIntermAggregate(EOpBarrier); barrier->setLoc(loc); barrier->setType(TType(EbtVoid)); @@ -10113,7 +10113,7 @@ void HlslParseContext::finalizeAppendMethods() // Patch append sequences, now that we know the stream output symbol. for (auto append = gsAppends.begin(); append != gsAppends.end(); ++append) { - append->node->getSequence()[0] = + append->node->getSequence()[0] = handleAssign(append->loc, EOpAssign, intermediate.addSymbol(*gsStreamOutput, append->loc), append->node->getSequence()[0]->getAsTyped()); diff --git a/hlsl/hlslParseHelper.h b/glslang/HLSL/hlslParseHelper.h similarity index 99% rename from hlsl/hlslParseHelper.h rename to glslang/HLSL/hlslParseHelper.h index 3ca21c6c..3ae1db1e 100644 --- a/hlsl/hlslParseHelper.h +++ b/glslang/HLSL/hlslParseHelper.h @@ -36,9 +36,9 @@ #ifndef HLSL_PARSE_INCLUDED_ #define HLSL_PARSE_INCLUDED_ -#include "../glslang/MachineIndependent/parseVersions.h" -#include "../glslang/MachineIndependent/ParseHelper.h" -#include "../glslang/MachineIndependent/attribute.h" +#include "../MachineIndependent/parseVersions.h" +#include "../MachineIndependent/ParseHelper.h" +#include "../MachineIndependent/attribute.h" #include @@ -320,7 +320,7 @@ protected: // 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()); } @@ -407,7 +407,7 @@ protected: // This tracks texture sample user structure return types. Only a limited number are supported, as // may fit in TSampler::structReturnIndex. TVector textureReturnStruct; - + TMap 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 @@ -456,7 +456,7 @@ protected: std::array 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 + // 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) { } diff --git a/hlsl/hlslParseables.cpp b/glslang/HLSL/hlslParseables.cpp similarity index 100% rename from hlsl/hlslParseables.cpp rename to glslang/HLSL/hlslParseables.cpp diff --git a/hlsl/hlslParseables.h b/glslang/HLSL/hlslParseables.h similarity index 97% rename from hlsl/hlslParseables.h rename to glslang/HLSL/hlslParseables.h index 28f424b3..a4aef6c3 100644 --- a/hlsl/hlslParseables.h +++ b/glslang/HLSL/hlslParseables.h @@ -36,7 +36,7 @@ #ifndef _HLSLPARSEABLES_INCLUDED_ #define _HLSLPARSEABLES_INCLUDED_ -#include "../glslang/MachineIndependent/Initialize.h" +#include "../MachineIndependent/Initialize.h" namespace glslang { diff --git a/hlsl/hlslScanContext.cpp b/glslang/HLSL/hlslScanContext.cpp similarity index 99% rename from hlsl/hlslScanContext.cpp rename to glslang/HLSL/hlslScanContext.cpp index 5af321fa..fc62672f 100644 --- a/hlsl/hlslScanContext.cpp +++ b/glslang/HLSL/hlslScanContext.cpp @@ -42,15 +42,15 @@ #include #include -#include "../glslang/Include/Types.h" -#include "../glslang/MachineIndependent/SymbolTable.h" -#include "../glslang/MachineIndependent/ParseHelper.h" +#include "../Include/Types.h" +#include "../MachineIndependent/SymbolTable.h" +#include "../MachineIndependent/ParseHelper.h" #include "hlslScanContext.h" #include "hlslTokens.h" // preprocessor includes -#include "../glslang/MachineIndependent/preprocessor/PpContext.h" -#include "../glslang/MachineIndependent/preprocessor/PpTokens.h" +#include "../MachineIndependent/preprocessor/PpContext.h" +#include "../MachineIndependent/preprocessor/PpTokens.h" namespace { diff --git a/hlsl/hlslScanContext.h b/glslang/HLSL/hlslScanContext.h similarity index 98% rename from hlsl/hlslScanContext.h rename to glslang/HLSL/hlslScanContext.h index 9d30a12e..3b191e48 100644 --- a/hlsl/hlslScanContext.h +++ b/glslang/HLSL/hlslScanContext.h @@ -41,7 +41,7 @@ #ifndef HLSLSCANCONTEXT_H_ #define HLSLSCANCONTEXT_H_ -#include "../glslang/MachineIndependent/ParseHelper.h" +#include "../MachineIndependent/ParseHelper.h" #include "hlslTokens.h" namespace glslang { diff --git a/hlsl/hlslTokenStream.cpp b/glslang/HLSL/hlslTokenStream.cpp similarity index 100% rename from hlsl/hlslTokenStream.cpp rename to glslang/HLSL/hlslTokenStream.cpp diff --git a/hlsl/hlslTokenStream.h b/glslang/HLSL/hlslTokenStream.h similarity index 100% rename from hlsl/hlslTokenStream.h rename to glslang/HLSL/hlslTokenStream.h diff --git a/hlsl/hlslTokens.h b/glslang/HLSL/hlslTokens.h similarity index 100% rename from hlsl/hlslTokens.h rename to glslang/HLSL/hlslTokens.h diff --git a/hlsl/pch.cpp b/glslang/HLSL/pch.cpp similarity index 100% rename from hlsl/pch.cpp rename to glslang/HLSL/pch.cpp diff --git a/hlsl/pch.h b/glslang/HLSL/pch.h similarity index 92% rename from hlsl/pch.h rename to glslang/HLSL/pch.h index e0bc4917..465e7c14 100644 --- a/hlsl/pch.h +++ b/glslang/HLSL/pch.h @@ -34,21 +34,20 @@ // POSSIBILITY OF SUCH DAMAGE. // +#include "hlslAttributes.h" +#include "hlslGrammar.h" #include "hlslParseHelper.h" #include "hlslScanContext.h" -#include "hlslGrammar.h" -#include "hlslAttributes.h" -#include "../glslang/MachineIndependent/Scan.h" -#include "../glslang/MachineIndependent/preprocessor/PpContext.h" +#include "../MachineIndependent/Scan.h" +#include "../MachineIndependent/preprocessor/PpContext.h" -#include "../glslang/OSDependent/osinclude.h" +#include "../OSDependent/osinclude.h" #include -#include -#include #include +#include +#include #include - #endif /* _PCH_H */ diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index a1392dbd..476d1798 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -51,9 +51,9 @@ #include "ScanContext.h" #ifdef ENABLE_HLSL -#include "../../hlsl/hlslParseHelper.h" -#include "../../hlsl/hlslParseables.h" -#include "../../hlsl/hlslScanContext.h" +#include "../HLSL/hlslParseHelper.h" +#include "../HLSL/hlslParseables.h" +#include "../HLSL/hlslScanContext.h" #endif #include "../Include/ShHandle.h" diff --git a/hlsl/CMakeLists.txt b/hlsl/CMakeLists.txt index d0866312..0e5d901c 100644 --- a/hlsl/CMakeLists.txt +++ b/hlsl/CMakeLists.txt @@ -1,6 +1,7 @@ # 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. diff --git a/hlsl/stub.cpp b/hlsl/stub.cpp index c53b9395..f1d39c15 100644 --- a/hlsl/stub.cpp +++ b/hlsl/stub.cpp @@ -35,6 +35,7 @@ // 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.