diff options
Diffstat (limited to 'chromium/third_party/glslang')
67 files changed, 1648 insertions, 541 deletions
diff --git a/chromium/third_party/glslang/src/Android.mk b/chromium/third_party/glslang/src/Android.mk index fda81a7cf25..524afe8cbad 100644 --- a/chromium/third_party/glslang/src/Android.mk +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/BUILD.bazel b/chromium/third_party/glslang/src/BUILD.bazel index 5930608a890..442a94c2a92 100644 --- a/chromium/third_party/glslang/src/BUILD.bazel +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/BUILD.gn b/chromium/third_party/glslang/src/BUILD.gn index 49b4b0a33aa..cb44707c704 100644 --- a/chromium/third_party/glslang/src/BUILD.gn +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/CMakeLists.txt b/chromium/third_party/glslang/src/CMakeLists.txt index cd9baf84424..bb5205ea773 100644 --- a/chromium/third_party/glslang/src/CMakeLists.txt +++ b/chromium/third_party/glslang/src/CMakeLists.txt @@ -57,6 +57,7 @@ CMAKE_DEPENDENT_OPTION(ENABLE_HLSL OFF) option(ENABLE_RTTI "Enables RTTI" OFF) +option(ENABLE_EXCEPTIONS "Enables Exceptions" OFF) option(ENABLE_OPT "Enables spirv-opt capability if present" ON) option(ENABLE_PCH "Enables Precompiled header" ON) option(ENABLE_CTEST "Enables testing" ON) @@ -121,6 +122,9 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") if(NOT ENABLE_RTTI) add_compile_options(-fno-rtti) endif() + if(NOT ENABLE_EXCEPTIONS) + add_compile_options(-fno-exceptions) + endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0") add_compile_options(-Werror=deprecated-copy) endif() @@ -131,9 +135,20 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) if(NOT ENABLE_RTTI) add_compile_options(-fno-rtti) endif() + if(NOT ENABLE_EXCEPTIONS) + add_compile_options(-fno-exceptions) + endif() elseif(MSVC) if(NOT ENABLE_RTTI) - add_compile_options(/GR-) # Disable RTTI + string(FIND "${CMAKE_CXX_FLAGS}" "/GR" MSVC_HAS_GR) + if(MSVC_HAS_GR) + string(REGEX REPLACE /GR /GR- CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + else() + add_compile_options(/GR-) # Disable RTTI + endif() + endif() + if(ENABLE_EXCEPTIONS) + add_compile_options(/EHsc) # Enable Exceptions endif() endif() @@ -141,7 +156,7 @@ if(ENABLE_GLSLANG_JS) if(MSVC) add_compile_options(/Os /GR-) else() - add_compile_options(-Os -fno-exceptions) + add_compile_options(-Os -fno-rtti -fno-exceptions) if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-unused-variable -Wno-unused-const-variable) @@ -205,7 +220,7 @@ if(ENABLE_CTEST) add_subdirectory(gtests) endif() -if(BUILD_TESTING) +if(ENABLE_CTEST AND BUILD_TESTING) # glslang-testsuite runs a bash script on Windows. # Make sure to use '-o igncr' flag to ignore carriage returns (\r). set(IGNORE_CR_FLAG "") @@ -226,4 +241,4 @@ if(BUILD_TESTING) add_test(NAME glslang-testsuite COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/) -endif(BUILD_TESTING) +endif() diff --git a/chromium/third_party/glslang/src/README.md b/chromium/third_party/glslang/src/README.md index ff844c02803..756e857c878 100755 --- a/chromium/third_party/glslang/src/README.md +++ b/chromium/third_party/glslang/src/README.md @@ -1,18 +1,24 @@ # News -[](https://travis-ci.org/KhronosGroup/glslang) -[](https://ci.appveyor.com/project/Khronoswebmaster/glslang/branch/master) +1. The versioning scheme is being improved, and you might notice some differences. This is currently WIP, but will be coming soon. See, for example, PR #2277. -## Planned Deprecations/Removals +2. If you get a new **compilation error due to a missing header**, it might be caused by this planned removal: -1. **SPIRV Folder, 1-May, 2020.** Glslang, when installed through CMake, +**SPIRV Folder, 1-May, 2020.** Glslang, when installed through CMake, will install a `SPIRV` folder into `${CMAKE_INSTALL_INCLUDEDIR}`. This `SPIRV` folder is being moved to `glslang/SPIRV`. During the transition the `SPIRV` folder will be installed into both locations. The old install of `SPIRV/` will be removed as a CMake install target no sooner than May 1, 2020. See issue #1964. -2. **Visual Studio 2013, 20-July, 2020.** Keeping code compiling for MS Visual Studio 2013 will no longer be +If people are only using this location to get spirv.hpp, I recommend they get that from [SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers) instead. + +[](https://travis-ci.org/KhronosGroup/glslang) +[](https://ci.appveyor.com/project/Khronoswebmaster/glslang/branch/master) + +## Planned Deprecations/Removals + +1. **Visual Studio 2013, 20-July, 2020.** Keeping code compiling for MS Visual Studio 2013 will no longer be a goal as of July 20, 2020, the fifth anniversary of the release of Visual Studio 2015. # Glslang Components and Status diff --git a/chromium/third_party/glslang/src/SPIRV/CInterface/spirv_c_interface.cpp b/chromium/third_party/glslang/src/SPIRV/CInterface/spirv_c_interface.cpp new file mode 100644 index 00000000000..c88b8085803 --- /dev/null +++ b/chromium/third_party/glslang/src/SPIRV/CInterface/spirv_c_interface.cpp @@ -0,0 +1,110 @@ +/** + This code is based on the glslang_c_interface implementation by Viktor Latypov +**/ + +/** +BSD 2-Clause License + +Copyright (c) 2019, Viktor Latypov +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. 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. + +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 HOLDER 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 "glslang/Include/glslang_c_interface.h" + +#include "SPIRV/GlslangToSpv.h" +#include "SPIRV/Logger.h" +#include "SPIRV/SpvTools.h" + +typedef struct glslang_program_s { + glslang::TProgram* program; + std::vector<unsigned int> spirv; + std::string loggerMessages; +} glslang_program_t; + +static EShLanguage c_shader_stage(glslang_stage_t stage) +{ + switch (stage) { + case GLSLANG_STAGE_VERTEX: + return EShLangVertex; + case GLSLANG_STAGE_TESSCONTROL: + return EShLangTessControl; + case GLSLANG_STAGE_TESSEVALUATION: + return EShLangTessEvaluation; + case GLSLANG_STAGE_GEOMETRY: + return EShLangGeometry; + case GLSLANG_STAGE_FRAGMENT: + return EShLangFragment; + case GLSLANG_STAGE_COMPUTE: + return EShLangCompute; + case GLSLANG_STAGE_RAYGEN_NV: + return EShLangRayGen; + case GLSLANG_STAGE_INTERSECT_NV: + return EShLangIntersect; + case GLSLANG_STAGE_ANYHIT_NV: + return EShLangAnyHit; + case GLSLANG_STAGE_CLOSESTHIT_NV: + return EShLangClosestHit; + case GLSLANG_STAGE_MISS_NV: + return EShLangMiss; + case GLSLANG_STAGE_CALLABLE_NV: + return EShLangCallable; + case GLSLANG_STAGE_TASK_NV: + return EShLangTaskNV; + case GLSLANG_STAGE_MESH_NV: + return EShLangMeshNV; + default: + break; + } + return EShLangCount; +} + +void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage) +{ + spv::SpvBuildLogger logger; + glslang::SpvOptions spvOptions; + spvOptions.validate = true; + + const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage)); + + glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions); + + program->loggerMessages = logger.getAllMessages(); +} + +size_t glslang_program_SPIRV_get_size(glslang_program_t* program) { return program->spirv.size(); } + +void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int* out) +{ + memcpy(out, program->spirv.data(), program->spirv.size() * sizeof(unsigned int)); +} + +unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program) +{ + return program->spirv.data(); +} + +const char* glslang_program_SPIRV_get_messages(glslang_program_t* program) +{ + return program->loggerMessages.empty() ? nullptr : program->loggerMessages.c_str(); +} diff --git a/chromium/third_party/glslang/src/SPIRV/CMakeLists.txt b/chromium/third_party/glslang/src/SPIRV/CMakeLists.txt index 90406099a05..5e90086dae2 100644 --- a/chromium/third_party/glslang/src/SPIRV/CMakeLists.txt +++ b/chromium/third_party/glslang/src/SPIRV/CMakeLists.txt @@ -6,7 +6,8 @@ set(SOURCES SpvPostProcess.cpp doc.cpp SpvTools.cpp - disassemble.cpp) + disassemble.cpp + CInterface/spirv_c_interface.cpp) set(SPVREMAP_SOURCES SPVRemapper.cpp @@ -98,6 +99,5 @@ if(ENABLE_GLSLANG_INSTALL) install(EXPORT SPIRVTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) - install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SPIRV/) install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/SPIRV/) endif(ENABLE_GLSLANG_INSTALL) diff --git a/chromium/third_party/glslang/src/SPIRV/GlslangToSpv.cpp b/chromium/third_party/glslang/src/SPIRV/GlslangToSpv.cpp index 3bed67835f3..b63d901ca97 100644 --- a/chromium/third_party/glslang/src/SPIRV/GlslangToSpv.cpp +++ b/chromium/third_party/glslang/src/SPIRV/GlslangToSpv.cpp @@ -1292,7 +1292,8 @@ bool IsDescriptorResource(const glslang::TType& type) // basically samplerXXX/subpass/sampler/texture are all included // if they are the global-scope-class, not the function parameter // (or local, if they ever exist) class. - if (type.getBasicType() == glslang::EbtSampler) + if (type.getBasicType() == glslang::EbtSampler || + type.getBasicType() == glslang::EbtAccStruct) return type.getQualifier().isUniformOrBuffer(); // None of the above. @@ -1448,7 +1449,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb); } - if (sourceExtensions.find("GL_EXT_ray_flags_primitive_culling") != sourceExtensions.end()) { + if (glslangIntermediate->getLayoutPrimitiveCulling()) { builder.addCapability(spv::CapabilityRayTraversalPrimitiveCullingProvisionalKHR); } @@ -1710,16 +1711,19 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol) spv::Id id = getSymbolId(symbol); if (builder.isPointer(id)) { - // Include all "static use" and "linkage only" interface variables on the OpEntryPoint instruction - // Consider adding to the OpEntryPoint interface list. - // Only looking at structures if they have at least one member. - if (!symbol->getType().isStruct() || symbol->getType().getStruct()->size() > 0) { - spv::StorageClass sc = builder.getStorageClass(id); - // Before SPIR-V 1.4, we only want to include Input and Output. - // Starting with SPIR-V 1.4, we want all globals. - if ((glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4 && sc != spv::StorageClassFunction) || - (sc == spv::StorageClassInput || sc == spv::StorageClassOutput)) { - iOSet.insert(id); + if (!symbol->getType().getQualifier().isParamInput() && + !symbol->getType().getQualifier().isParamOutput()) { + // Include all "static use" and "linkage only" interface variables on the OpEntryPoint instruction + // Consider adding to the OpEntryPoint interface list. + // Only looking at structures if they have at least one member. + if (!symbol->getType().isStruct() || symbol->getType().getStruct()->size() > 0) { + spv::StorageClass sc = builder.getStorageClass(id); + // Before SPIR-V 1.4, we only want to include Input and Output. + // Starting with SPIR-V 1.4, we want all globals. + if ((glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4 && sc != spv::StorageClassFunction) || + (sc == spv::StorageClassInput || sc == spv::StorageClassOutput)) { + iOSet.insert(id); + } } } @@ -3524,7 +3528,18 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol* if (glslang::IsAnonymous(name)) name = ""; - return builder.createVariable(storageClass, spvType, name); + spv::Id initializer = spv::NoResult; + + if (node->getType().getQualifier().storage == glslang::EvqUniform && + !node->getConstArray().empty()) { + int nextConst = 0; + initializer = createSpvConstantFromConstUnionArray(node->getType(), + node->getConstArray(), + nextConst, + false /* specConst */); + } + + return builder.createVariable(storageClass, spvType, name, initializer); } // Return type Id of the sampled type. @@ -4388,8 +4403,10 @@ bool TGlslangToSpvTraverser::writableParam(glslang::TStorageQualifier qualifier) assert(qualifier == glslang::EvqIn || qualifier == glslang::EvqOut || qualifier == glslang::EvqInOut || + qualifier == glslang::EvqUniform || qualifier == glslang::EvqConstReadOnly); - return qualifier != glslang::EvqConstReadOnly; + return qualifier != glslang::EvqConstReadOnly && + qualifier != glslang::EvqUniform; } // Is parameter pass-by-original? @@ -5599,7 +5616,7 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, OpD case glslang::EOpNotEqual: case glslang::EOpVectorNotEqual: if (isFloat) - binOp = spv::OpFOrdNotEqual; + binOp = spv::OpFUnordNotEqual; else if (isBool) binOp = spv::OpLogicalNotEqual; else @@ -6297,7 +6314,7 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecora case glslang::EOpConvFloatToBool: zero = builder.makeFloatConstant(0.0F); zero = makeSmearedConstant(zero, vectorSize); - return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero); + return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero); case glslang::EOpConvBoolToFloat: convOp = spv::OpSelect; zero = builder.makeFloatConstant(0.0F); @@ -6446,11 +6463,11 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecora case glslang::EOpConvDoubleToBool: zero = builder.makeDoubleConstant(0.0); zero = makeSmearedConstant(zero, vectorSize); - return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero); + return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero); case glslang::EOpConvFloat16ToBool: zero = builder.makeFloat16Constant(0.0F); zero = makeSmearedConstant(zero, vectorSize); - return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero); + return builder.createBinOp(spv::OpFUnordNotEqual, destType, operand, zero); case glslang::EOpConvBoolToDouble: convOp = spv::OpSelect; zero = builder.makeDoubleConstant(0.0); @@ -8270,6 +8287,18 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n // We now know we have a specialization constant to build + // Extra capabilities may be needed. + if (node.getType().contains8BitInt()) + builder.addCapability(spv::CapabilityInt8); + if (node.getType().contains16BitFloat()) + builder.addCapability(spv::CapabilityFloat16); + if (node.getType().contains16BitInt()) + builder.addCapability(spv::CapabilityInt16); + if (node.getType().contains64BitInt()) + builder.addCapability(spv::CapabilityInt64); + if (node.getType().containsDouble()) + builder.addCapability(spv::CapabilityFloat64); + // gl_WorkGroupSize is a special case until the front-end handles hierarchical specialization constants, // even then, it's specialization ids are handled by special case syntax in GLSL: layout(local_size_x = ... if (node.getType().getQualifier().builtIn == glslang::EbvWorkGroupSize) { @@ -8625,7 +8654,9 @@ int GetSpirvGeneratorVersion() // return 6; // revert version 5 change, which makes a different (new) kind of incorrect code, // versions 4 and 6 each generate OpArrayLength as it has long been done // return 7; // GLSL volatile keyword maps to both SPIR-V decorations Volatile and Coherent - return 8; // switch to new dead block eliminator; use OpUnreachable + // return 8; // switch to new dead block eliminator; use OpUnreachable + // return 9; // don't include opaque function parameters in OpEntryPoint global's operand list + return 10; // Generate OpFUnordNotEqual for != comparisons } // Write SPIR-V out to a binary file @@ -8708,10 +8739,14 @@ void GlslangToSpv(const TIntermediate& intermediate, std::vector<unsigned int>& // If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan // eg. forward and remove memory writes of opaque types. bool prelegalization = intermediate.getSource() == EShSourceHlsl; - if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer) { - SpirvToolsLegalize(intermediate, spirv, logger, options); + if ((prelegalization || options->optimizeSize) && !options->disableOptimizer) { + SpirvToolsTransform(intermediate, spirv, logger, options); prelegalization = false; } + else if (options->stripDebugInfo) { + // Strip debug info even if optimization is disabled. + SpirvToolsStripDebugInfo(intermediate, spirv, logger); + } if (options->validate) SpirvToolsValidate(intermediate, spirv, logger, prelegalization); diff --git a/chromium/third_party/glslang/src/SPIRV/SpvBuilder.cpp b/chromium/third_party/glslang/src/SPIRV/SpvBuilder.cpp index 6cf70a12d12..62b7d0ebbc1 100644 --- a/chromium/third_party/glslang/src/SPIRV/SpvBuilder.cpp +++ b/chromium/third_party/glslang/src/SPIRV/SpvBuilder.cpp @@ -2166,7 +2166,7 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b Op op; switch (getMostBasicTypeClass(valueType)) { case OpTypeFloat: - op = equal ? OpFOrdEqual : OpFOrdNotEqual; + op = equal ? OpFOrdEqual : OpFUnordNotEqual; break; case OpTypeInt: default: diff --git a/chromium/third_party/glslang/src/SPIRV/SpvTools.cpp b/chromium/third_party/glslang/src/SPIRV/SpvTools.cpp index 1e968ba5423..6d4d9ef2d34 100644 --- a/chromium/third_party/glslang/src/SPIRV/SpvTools.cpp +++ b/chromium/third_party/glslang/src/SPIRV/SpvTools.cpp @@ -80,6 +80,39 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog return spv_target_env::SPV_ENV_UNIVERSAL_1_0; } +// Callback passed to spvtools::Optimizer::SetMessageConsumer +void OptimizerMesssageConsumer(spv_message_level_t level, const char *source, + const spv_position_t &position, const char *message) +{ + auto &out = std::cerr; + switch (level) + { + case SPV_MSG_FATAL: + case SPV_MSG_INTERNAL_ERROR: + case SPV_MSG_ERROR: + out << "error: "; + break; + case SPV_MSG_WARNING: + out << "warning: "; + break; + case SPV_MSG_INFO: + case SPV_MSG_DEBUG: + out << "info: "; + break; + default: + break; + } + if (source) + { + out << source << ":"; + } + out << position.line << ":" << position.column << ":" << position.index << ":"; + if (message) + { + out << " " << message; + } + out << std::endl; +} // Use the SPIRV-Tools disassembler to print SPIR-V. void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& spirv) @@ -128,45 +161,14 @@ void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector< spvContextDestroy(context); } -// Apply the SPIRV-Tools optimizer to generated SPIR-V, for the purpose of -// legalizing HLSL SPIR-V. -void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, - spv::SpvBuildLogger* logger, const SpvOptions* options) +// Apply the SPIRV-Tools optimizer to generated SPIR-V. HLSL SPIR-V is legalized in the process. +void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, + spv::SpvBuildLogger* logger, const SpvOptions* options) { spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2; spvtools::Optimizer optimizer(target_env); - optimizer.SetMessageConsumer( - [](spv_message_level_t level, const char *source, const spv_position_t &position, const char *message) { - auto &out = std::cerr; - switch (level) - { - case SPV_MSG_FATAL: - case SPV_MSG_INTERNAL_ERROR: - case SPV_MSG_ERROR: - out << "error: "; - break; - case SPV_MSG_WARNING: - out << "warning: "; - break; - case SPV_MSG_INFO: - case SPV_MSG_DEBUG: - out << "info: "; - break; - default: - break; - } - if (source) - { - out << source << ":"; - } - out << position.line << ":" << position.column << ":" << position.index << ":"; - if (message) - { - out << " " << message; - } - out << std::endl; - }); + optimizer.SetMessageConsumer(OptimizerMesssageConsumer); // If debug (specifically source line info) is being generated, propagate // line information into all SPIR-V instructions. This avoids loss of @@ -175,6 +177,9 @@ void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector< if (options->generateDebugInfo) { optimizer.RegisterPass(spvtools::CreatePropagateLineInfoPass()); } + else if (options->stripDebugInfo) { + optimizer.RegisterPass(spvtools::CreateStripDebugInfoPass()); + } optimizer.RegisterPass(spvtools::CreateWrapOpKillPass()); optimizer.RegisterPass(spvtools::CreateDeadBranchElimPass()); optimizer.RegisterPass(spvtools::CreateMergeReturnPass()); @@ -212,6 +217,25 @@ void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector< optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions); } +// Apply the SPIRV-Tools optimizer to strip debug info from SPIR-V. This is implicitly done by +// SpirvToolsTransform if spvOptions->stripDebugInfo is set, but can be called separately if +// optimization is disabled. +void SpirvToolsStripDebugInfo(const glslang::TIntermediate& intermediate, + std::vector<unsigned int>& spirv, spv::SpvBuildLogger* logger) +{ + spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2; + + spvtools::Optimizer optimizer(target_env); + optimizer.SetMessageConsumer(OptimizerMesssageConsumer); + + optimizer.RegisterPass(spvtools::CreateStripDebugInfoPass()); + + spvtools::OptimizerOptions spvOptOptions; + optimizer.SetTargetEnv(MapToSpirvToolsEnv(intermediate.getSpv(), logger)); + spvOptOptions.set_run_validator(false); // The validator may run as a separate step later on + optimizer.Run(spirv.data(), spirv.size(), &spirv, spvOptOptions); +} + }; // end namespace glslang #endif diff --git a/chromium/third_party/glslang/src/SPIRV/SpvTools.h b/chromium/third_party/glslang/src/SPIRV/SpvTools.h index 59c914da0b7..7779dfa779f 100644 --- a/chromium/third_party/glslang/src/SPIRV/SpvTools.h +++ b/chromium/third_party/glslang/src/SPIRV/SpvTools.h @@ -52,9 +52,10 @@ namespace glslang { struct SpvOptions { - SpvOptions() : generateDebugInfo(false), disableOptimizer(true), + SpvOptions() : generateDebugInfo(false), stripDebugInfo(false), disableOptimizer(true), optimizeSize(false), disassemble(false), validate(false) { } bool generateDebugInfo; + bool stripDebugInfo; bool disableOptimizer; bool optimizeSize; bool disassemble; @@ -70,10 +71,15 @@ void SpirvToolsDisassemble(std::ostream& out, const std::vector<unsigned int>& s void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, spv::SpvBuildLogger*, bool prelegalization); -// Apply the SPIRV-Tools optimizer to generated SPIR-V, for the purpose of -// legalizing HLSL SPIR-V. -void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, - spv::SpvBuildLogger*, const SpvOptions*); +// Apply the SPIRV-Tools optimizer to generated SPIR-V. HLSL SPIR-V is legalized in the process. +void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, + spv::SpvBuildLogger*, const SpvOptions*); + +// Apply the SPIRV-Tools optimizer to strip debug info from SPIR-V. This is implicitly done by +// SpirvToolsTransform if spvOptions->stripDebugInfo is set, but can be called separately if +// optimization is disabled. +void SpirvToolsStripDebugInfo(const glslang::TIntermediate& intermediate, + std::vector<unsigned int>& spirv, spv::SpvBuildLogger*); #endif diff --git a/chromium/third_party/glslang/src/StandAlone/StandAlone.cpp b/chromium/third_party/glslang/src/StandAlone/StandAlone.cpp index a7ce53d4fbd..5e17affefc3 100644 --- a/chromium/third_party/glslang/src/StandAlone/StandAlone.cpp +++ b/chromium/third_party/glslang/src/StandAlone/StandAlone.cpp @@ -106,6 +106,7 @@ bool targetHlslFunctionality1 = false; bool SpvToolsDisassembler = false; bool SpvToolsValidate = false; bool NaNClamp = false; +bool stripDebugInfo = false; // // Return codes from main/exit(). @@ -555,6 +556,12 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem ReflectOptions |= EShReflectionAllBlockVariables; } else if (lowerword == "reflect-unwrap-io-blocks") { ReflectOptions |= EShReflectionUnwrapIOBlocks; + } else if (lowerword == "reflect-all-io-variables") { + ReflectOptions |= EShReflectionAllIOVariables; + } else if (lowerword == "reflect-shared-std140-ubo") { + ReflectOptions |= EShReflectionSharedStd140UBO; + } else if (lowerword == "reflect-shared-std140-ssbo") { + ReflectOptions |= EShReflectionSharedStd140SSBO; } else if (lowerword == "resource-set-bindings" || // synonyms lowerword == "resource-set-binding" || lowerword == "rsb") { @@ -744,7 +751,13 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem Error("-f: expected hlsl_functionality1"); break; case 'g': - Options |= EOptionDebug; + // Override previous -g or -g0 argument + stripDebugInfo = false; + Options &= ~EOptionDebug; + if (argv[0][2] == '0') + stripDebugInfo = true; + else + Options |= EOptionDebug; break; case 'h': usage(); @@ -1144,6 +1157,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits) glslang::SpvOptions spvOptions; if (Options & EOptionDebug) spvOptions.generateDebugInfo = true; + else if (stripDebugInfo) + spvOptions.stripDebugInfo = true; spvOptions.disableOptimizer = (Options & EOptionOptimizeDisable) != 0; spvOptions.optimizeSize = (Options & EOptionOptimizeSize) != 0; spvOptions.disassemble = SpvToolsDisassembler; @@ -1562,6 +1577,7 @@ void usage() " 'hlsl_functionality1' enables use of the\n" " SPV_GOOGLE_hlsl_functionality1 extension\n" " -g generate debug information\n" + " -g0 strip debug information\n" " -h print this usage message\n" " -i intermediate tree (glslang AST) is printed out\n" " -l link all input files together to form a single module\n" @@ -1593,7 +1609,8 @@ void usage() " --hlsl-iomap perform IO mapping in HLSL register space\n" " --hlsl-enable-16bit-types allow 16-bit types in SPIR-V for HLSL\n" " --hlsl-dx9-compatible interprets sampler declarations as a\n" - " texture/sampler combo like DirectX9 would.\n" + " texture/sampler combo like DirectX9 would,\n" + " and recognizes DirectX9-specific semantics\n" " --invert-y | --iy invert position.Y output in vertex shader\n" " --keep-uncalled | --ku don't eliminate uncalled functions\n" " --nan-clamp favor non-NaN operand in min, max, and clamp\n" diff --git a/chromium/third_party/glslang/src/glslang/CInterface/glslang_c_interface.cpp b/chromium/third_party/glslang/src/glslang/CInterface/glslang_c_interface.cpp index c4c24a9e4bf..54283e6f28a 100644 --- a/chromium/third_party/glslang/src/glslang/CInterface/glslang_c_interface.cpp +++ b/chromium/third_party/glslang/src/glslang/CInterface/glslang_c_interface.cpp @@ -32,9 +32,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "glslang/Include/glslang_c_interface.h" -#include "SPIRV/GlslangToSpv.h" -#include "SPIRV/Logger.h" -#include "SPIRV/SpvTools.h" #include "StandAlone/DirStackFileIncluder.h" #include "StandAlone/ResourceLimits.h" #include "glslang/Include/ShHandle.h" @@ -401,36 +398,6 @@ glslang_program_t* glslang_program_create() return p; } -void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage) -{ - spv::SpvBuildLogger logger; - glslang::SpvOptions spvOptions; - spvOptions.validate = true; - - const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage)); - - glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions); - - program->loggerMessages = logger.getAllMessages(); -} - -size_t glslang_program_SPIRV_get_size(glslang_program_t* program) { return program->spirv.size(); } - -void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int* out) -{ - memcpy(out, program->spirv.data(), program->spirv.size() * sizeof(unsigned int)); -} - -unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program) -{ - return program->spirv.data(); -} - -const char* glslang_program_SPIRV_get_messages(glslang_program_t* program) -{ - return program->loggerMessages.empty() ? nullptr : program->loggerMessages.c_str(); -} - void glslang_program_delete(glslang_program_t* program) { if (!program) diff --git a/chromium/third_party/glslang/src/glslang/CMakeLists.txt b/chromium/third_party/glslang/src/glslang/CMakeLists.txt index a0259a3deff..e37b9e13750 100644 --- a/chromium/third_party/glslang/src/glslang/CMakeLists.txt +++ b/chromium/third_party/glslang/src/glslang/CMakeLists.txt @@ -82,11 +82,32 @@ set(HEADERS 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) + + 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) +endif(ENABLE_HLSL) + add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS}) set_property(TARGET glslang PROPERTY FOLDER glslang) set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON) target_link_libraries(glslang OGLCompiler OSDependent) -target_include_directories(glslang PUBLIC +target_include_directories(glslang PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) @@ -94,16 +115,14 @@ if(WIN32 AND BUILD_SHARED_LIBS) set_target_properties(glslang PROPERTIES PREFIX "") endif() -if(ENABLE_HLSL) - target_link_libraries(glslang HLSL) -endif() - if(WIN32) source_group("Public" REGULAR_EXPRESSION "Public/*") source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*") source_group("Include" REGULAR_EXPRESSION "Include/[^/]*") source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*") source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*") + source_group("HLSL" REGULAR_EXPRESSION "HLSL/*") + source_group("CInterface" REGULAR_EXPRESSION "CInterface/*") endif(WIN32) if(ENABLE_GLSLANG_INSTALL) diff --git a/chromium/third_party/glslang/src/hlsl/hlslAttributes.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslAttributes.cpp index 0cc0d3f4fcb..0cc0d3f4fcb 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslAttributes.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslAttributes.cpp diff --git a/chromium/third_party/glslang/src/hlsl/hlslAttributes.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslAttributes.h index b1cc0372e5e..62faa5b8894 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslAttributes.h +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslAttributes.h @@ -39,8 +39,8 @@ #include <unordered_map> #include <functional> -#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/chromium/third_party/glslang/src/hlsl/hlslGrammar.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslGrammar.cpp index 47ced29c020..5bfc53fe5c7 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslGrammar.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslGrammar.cpp @@ -382,6 +382,16 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) if (forbidDeclarators) return true; + // Check if there are invalid in/out qualifiers + switch (declaredType.getQualifier().storage) { + case EvqIn: + case EvqOut: + case EvqInOut: + parseContext.error(token.loc, "in/out qualifiers are only valid on parameters", token.string->c_str(), ""); + default: + break; + } + // declarator_list // : declarator // : identifier @@ -697,7 +707,9 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier) qualifier.noContraction = true; break; case EHTokIn: - qualifier.storage = (qualifier.storage == EvqOut) ? EvqInOut : EvqIn; + if (qualifier.storage != EvqUniform) { + qualifier.storage = (qualifier.storage == EvqOut) ? EvqInOut : EvqIn; + } break; case EHTokOut: qualifier.storage = (qualifier.storage == EvqIn) ? EvqInOut : EvqOut; diff --git a/chromium/third_party/glslang/src/hlsl/hlslGrammar.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslGrammar.h index 27706b2b9b6..27706b2b9b6 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslGrammar.h +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslGrammar.h diff --git a/chromium/third_party/glslang/src/hlsl/hlslOpMap.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslOpMap.cpp index ebe6fbd96cf..ebe6fbd96cf 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslOpMap.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslOpMap.cpp diff --git a/chromium/third_party/glslang/src/hlsl/hlslOpMap.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslOpMap.h index 4e783f3f0c4..4e783f3f0c4 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslOpMap.h +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslOpMap.h diff --git a/chromium/third_party/glslang/src/hlsl/hlslParseHelper.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslParseHelper.cpp index 2dc173fcad4..dff32648e41 100755 --- a/chromium/third_party/glslang/src/hlsl/hlslParseHelper.cpp +++ b/chromium/third_party/glslang/src/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 <algorithm> #include <functional> @@ -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); @@ -1169,7 +1169,7 @@ bool HlslParseContext::shouldFlatten(const TType& type, TStorageQualifier qualif } // Top level variable flattening: construct data -void HlslParseContext::flatten(const TVariable& variable, bool linkage) +void HlslParseContext::flatten(const TVariable& variable, bool linkage, bool arrayed) { const TType& type = variable.getType(); @@ -1181,8 +1181,15 @@ void HlslParseContext::flatten(const TVariable& variable, bool linkage) TFlattenData(type.getQualifier().layoutBinding, type.getQualifier().layoutLocation))); - // the item is a map pair, so first->second is the TFlattenData itself. - flatten(variable, type, entry.first->second, variable.getName(), linkage, type.getQualifier(), nullptr); + // if flattening arrayed io struct, array each member of dereferenced type + if (arrayed) { + const TType dereferencedType(type, 0); + flatten(variable, dereferencedType, entry.first->second, variable.getName(), linkage, + type.getQualifier(), type.getArraySizes()); + } else { + flatten(variable, type, entry.first->second, variable.getName(), linkage, + type.getQualifier(), nullptr); + } } // Recursively flatten the given variable at the provided type, building the flattenData as we go. @@ -1256,6 +1263,10 @@ int HlslParseContext::addFlattenedMember(const TVariable& variable, const TType& } } + // Only propagate arraysizes here for arrayed io + if (variable.getType().getQualifier().isArrayedIo(language) && builtInArraySizes != nullptr) + memberVariable->getWritableType().copyArraySizes(*builtInArraySizes); + flattenData.offsets.push_back(static_cast<int>(flattenData.members.size())); flattenData.members.push_back(memberVariable); @@ -1837,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") { @@ -2068,11 +2079,8 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct // Further this return/in/out transform by flattening, splitting, and assigning locations const auto makeVariableInOut = [&](TVariable& variable) { if (variable.getType().isStruct()) { - if (variable.getType().getQualifier().isArrayedIo(language)) { - if (variable.getType().containsBuiltIn()) - split(variable); - } else if (shouldFlatten(variable.getType(), EvqVaryingIn /* not assigned yet, but close enough */, true)) - flatten(variable, false /* don't track linkage here, it will be tracked in assignToInterface() */); + bool arrayed = variable.getType().getQualifier().isArrayedIo(language); + flatten(variable, false /* don't track linkage here, it will be tracked in assignToInterface() */, arrayed); } // TODO: flatten arrays too // TODO: flatten everything in I/O @@ -2103,6 +2111,23 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct makeVariableInOut(*(*it)); } + // Add uniform parameters to the $Global uniform block. + TVector<TVariable*> opaque_uniforms; + for (int i = 0; i < userFunction.getParamCount(); i++) { + TType& paramType = *userFunction[i].type; + TString& paramName = *userFunction[i].name; + if (paramType.getQualifier().storage == EvqUniform) { + if (!paramType.containsOpaque()) { + // Add it to the global uniform block. + growGlobalUniformBlock(loc, paramType, paramName); + } else { + // Declare it as a separate variable. + TVariable *var = makeInternalVariable(paramName.c_str(), paramType); + opaque_uniforms.push_back(var); + } + } + } + // Synthesize the call pushScope(); // matches the one in handleFunctionBody() @@ -2123,6 +2148,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct TVector<TVariable*> argVars; TIntermAggregate* synthBody = new TIntermAggregate(); auto inputIt = inputs.begin(); + auto opaqueUniformIt = opaque_uniforms.begin(); TIntermTyped* callingArgs = nullptr; for (int i = 0; i < userFunction.getParamCount(); i++) { @@ -2141,6 +2167,17 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct intermediate.addSymbol(**inputIt))); inputIt++; } + if (param.type->getQualifier().storage == EvqUniform) { + if (!param.type->containsOpaque()) { + // Look it up in the $Global uniform block. + intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg, + handleVariable(loc, param.name))); + } else { + intermediate.growAggregate(synthBody, handleAssign(loc, EOpAssign, arg, + intermediate.addSymbol(**opaqueUniformIt))); + ++opaqueUniformIt; + } + } } // Call @@ -2447,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); @@ -2467,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 @@ -2536,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(); @@ -2557,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. // @@ -2618,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 && @@ -2729,23 +2766,39 @@ 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()); }; + // Return symbol if node is symbol or index ref + const auto getSymbol = [](const TIntermTyped* node) -> const TIntermSymbol* { + const TIntermSymbol* symbolNode = node->getAsSymbolNode(); + if (symbolNode != nullptr) + return symbolNode; + + const TIntermBinary* binaryNode = node->getAsBinaryNode(); + if (binaryNode != nullptr && (binaryNode->getOp() == EOpIndexDirect || binaryNode->getOp() == EOpIndexIndirect)) + return binaryNode->getLeft()->getAsSymbolNode(); + + return nullptr; + }; + // Return true if this stage assigns clip position with potentially inverted Y const auto assignsClipPos = [this](const TIntermTyped* node) -> bool { return node->getType().getQualifier().builtIn == EbvPosition && (language == EShLangVertex || language == EShLangGeometry || language == EShLangTessEvaluation); }; + const TIntermSymbol* leftSymbol = getSymbol(left); + const TIntermSymbol* rightSymbol = getSymbol(right); + const bool isSplitLeft = wasSplit(left) || indexesSplit(left); const bool isSplitRight = wasSplit(right) || indexesSplit(right); - const bool isFlattenLeft = wasFlattened(left); - const bool isFlattenRight = wasFlattened(right); + 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. @@ -2791,10 +2844,10 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op memberCount = left->getType().getCumulativeArraySize(); if (isFlattenLeft) - leftVariables = &flattenMap.find(left->getAsSymbolNode()->getId())->second.members; + leftVariables = &flattenMap.find(leftSymbol->getId())->second.members; if (isFlattenRight) { - rightVariables = &flattenMap.find(right->getAsSymbolNode()->getId())->second.members; + rightVariables = &flattenMap.find(rightSymbol->getId())->second.members; } else { // The RHS is not flattened. There are several cases: // 1. 1 item to copy: Use the RHS directly. @@ -2828,8 +2881,10 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op TStorageQualifier leftStorage = left->getType().getQualifier().storage; TStorageQualifier rightStorage = right->getType().getQualifier().storage; - int leftOffset = findSubtreeOffset(*left); - int rightOffset = findSubtreeOffset(*right); + int leftOffsetStart = findSubtreeOffset(*left); + int rightOffsetStart = findSubtreeOffset(*right); + int leftOffset = leftOffsetStart; + int rightOffset = rightOffsetStart; const auto getMember = [&](bool isLeft, const TType& type, int member, TIntermTyped* splitNode, int splitMember, bool flattened) @@ -2869,10 +2924,35 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op } } } else if (flattened && !shouldFlatten(derefType, isLeft ? leftStorage : rightStorage, false)) { - if (isLeft) + if (isLeft) { + // offset will cycle through variables for arrayed io + if (leftOffset >= static_cast<int>(leftVariables->size())) + leftOffset = leftOffsetStart; subTree = intermediate.addSymbol(*(*leftVariables)[leftOffset++]); - else + } else { + // offset will cycle through variables for arrayed io + if (rightOffset >= static_cast<int>(rightVariables->size())) + rightOffset = rightOffsetStart; subTree = intermediate.addSymbol(*(*rightVariables)[rightOffset++]); + } + + // arrayed io + if (subTree->getType().isArray()) { + if (!arrayElement.empty()) { + const TType derefType(subTree->getType(), arrayElement.front()); + subTree = intermediate.addIndex(EOpIndexDirect, subTree, + intermediate.addConstantUnion(arrayElement.front(), loc), loc); + subTree->setType(derefType); + } else { + // There's an index operation we should transfer to the output builtin. + assert(splitNode->getAsOperator() != nullptr && + splitNode->getAsOperator()->getOp() == EOpIndexIndirect); + const TType splitDerefType(subTree->getType(), 0); + subTree = intermediate.addIndex(splitNode->getAsOperator()->getOp(), subTree, + splitNode->getAsBinaryNode()->getRight(), loc); + subTree->setType(splitDerefType); + } + } } else { // Index operator if it's an aggregate, else EOpNull const TOperator accessOp = type.isArray() ? EOpIndexDirect @@ -3350,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, @@ -3367,7 +3447,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte const TType derefType(argArray->getType(), 0); node->setType(derefType); } - + break; case EOpMethodLoad2: @@ -3493,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); } @@ -3671,7 +3751,7 @@ TIntermConstantUnion* HlslParseContext::getSamplePosArray(int count) } TConstUnionArray* values = new TConstUnionArray(numSamples*2); - + for (int pos=0; pos<count; ++pos) { TConstUnion x, y; x.setDConst(sampleLoc[pos].x); @@ -3705,7 +3785,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType result->setType(TType(node->getType().getBasicType(), EvqTemporary, node->getVectorSize())); TIntermTyped* convertedResult = nullptr; - + TType retType; getTextureReturnType(sampler, retType); @@ -3731,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. @@ -3739,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), @@ -3761,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); } } @@ -3807,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; @@ -4504,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]; @@ -4525,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); @@ -4544,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(); @@ -4559,7 +4639,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType break; } - + default: break; // most pass through unchanged @@ -5079,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) @@ -5091,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; @@ -5099,7 +5179,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*& node = lowOrder; } } - + break; } @@ -5130,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) @@ -5141,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); @@ -5214,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); @@ -5598,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()) { @@ -5669,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); }); @@ -5688,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()); @@ -6049,6 +6129,32 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu return semanticNum; }; + if (builtIn == EbvNone && hlslDX9Compatible()) { + if (language == EShLangVertex) { + if (qualifier.isParamOutput()) { + if (upperCase == "POSITION") { + builtIn = EbvPosition; + } + if (upperCase == "PSIZE") { + builtIn = EbvPointSize; + } + } + } else if (language == EShLangFragment) { + if (qualifier.isParamInput() && upperCase == "VPOS") { + builtIn = EbvFragCoord; + } + if (qualifier.isParamOutput()) { + if (upperCase.compare(0, 5, "COLOR") == 0) { + qualifier.layoutLocation = getSemanticNumber(upperCase, 0, nullptr); + nextOutLocation = std::max(nextOutLocation, qualifier.layoutLocation + 1u); + } + if (upperCase == "DEPTH") { + builtIn = EbvFragDepth; + } + } + } + } + switch(builtIn) { case EbvNone: // Get location numbers from fragment outputs, instead of @@ -6863,7 +6969,6 @@ void HlslParseContext::paramFix(TType& type) type.getQualifier().storage = EvqConstReadOnly; break; case EvqGlobal: - case EvqUniform: case EvqTemporary: type.getQualifier().storage = EvqIn; break; @@ -8463,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, @@ -9535,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; } @@ -9583,7 +9688,7 @@ const TFunction* HlslParseContext::findPatchConstantFunction(const TSourceLoc& l TVector<const TFunction*> 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()) { @@ -9654,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<TFunction*>(findPatchConstantFunction(loc)); @@ -9740,6 +9845,8 @@ void HlslParseContext::addPatchConstantInvocation() } else { // Use the original declaration type for the linkage paramType->getQualifier().builtIn = biType; + if (biType == EbvTessLevelInner || biType == EbvTessLevelInner) + paramType->getQualifier().patch = true; if (notInEntryPoint.count(tInterstageIoData(biType, storage)) == 1) addToLinkage(*paramType, patchConstantFunction[p].name, nullptr); @@ -9778,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; @@ -9885,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)); } } @@ -9911,8 +10018,8 @@ void HlslParseContext::addPatchConstantInvocation() TVariable* pcfOutput = makeInternalVariable("@patchConstantOutput", outType); pcfOutput->getWritableType().getQualifier().storage = EvqVaryingOut; - if (pcfOutput->getType().containsBuiltIn()) - split(*pcfOutput); + if (pcfOutput->getType().isStruct()) + flatten(*pcfOutput, false); assignToInterface(*pcfOutput); @@ -9934,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)); @@ -10006,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/chromium/third_party/glslang/src/hlsl/hlslParseHelper.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslParseHelper.h index 6f4166103d2..3ae1db1e473 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslParseHelper.h +++ b/chromium/third_party/glslang/src/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 <array> @@ -276,7 +276,7 @@ protected: void fixBuiltInIoType(TType&); - void flatten(const TVariable& variable, bool linkage); + void flatten(const TVariable& variable, bool linkage, bool arrayed = false); 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, @@ -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<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 @@ -456,7 +456,7 @@ protected: 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 + // 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/chromium/third_party/glslang/src/hlsl/hlslParseables.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslParseables.cpp index a63ecb60526..ccc865e3393 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslParseables.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslParseables.cpp @@ -56,18 +56,6 @@ namespace { // anonymous namespace functions -const bool UseHlslTypes = true; - -const char* BaseTypeName(const char argOrder, const char* scalarName, const char* vecName, const char* matName) -{ - switch (argOrder) { - case 'S': return scalarName; - case 'V': return vecName; - case 'M': return matName; - default: return "UNKNOWN_TYPE"; - } -} - // arg order queries bool IsSamplerType(const char argType) { return argType == 'S' || argType == 's'; } bool IsArrayed(const char argOrder) { return argOrder == '@' || argOrder == '&' || argOrder == '#'; } @@ -216,8 +204,7 @@ int FixedVecSize(const char* arg) return 0; // none found. } -// Create and return a type name. This is done in GLSL, not HLSL conventions, until such -// time as builtins are parsed using the HLSL parser. +// Create and return a type name, using HLSL type conventions. // // order: S = scalar, V = vector, M = matrix // argType: F = float, D = double, I = int, U = uint, B = bool, S = sampler @@ -252,63 +239,35 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons char order = *argOrder; - if (UseHlslTypes) { - switch (type) { - case '-': s += "void"; break; - case 'F': s += "float"; break; - case 'D': s += "double"; break; - case 'I': s += "int"; break; - case 'U': s += "uint"; break; - case 'L': s += "int64_t"; break; - case 'M': s += "uint64_t"; break; - case 'B': s += "bool"; break; - case 'S': s += "sampler"; break; - case 's': s += "SamplerComparisonState"; break; - case 'T': s += ((isBuffer && isImage) ? "RWBuffer" : - isSubpass ? "SubpassInput" : - isBuffer ? "Buffer" : - isImage ? "RWTexture" : "Texture"); break; - case 'i': s += ((isBuffer && isImage) ? "RWBuffer" : - isSubpass ? "SubpassInput" : - isBuffer ? "Buffer" : - isImage ? "RWTexture" : "Texture"); break; - case 'u': s += ((isBuffer && isImage) ? "RWBuffer" : - isSubpass ? "SubpassInput" : - isBuffer ? "Buffer" : - isImage ? "RWTexture" : "Texture"); break; - default: s += "UNKNOWN_TYPE"; break; - } - - if (isSubpass && isMS) - s += "MS"; - - } else { - switch (type) { - case '-': s += "void"; break; - case 'F': s += BaseTypeName(order, "float", "vec", "mat"); break; - case 'D': s += BaseTypeName(order, "double", "dvec", "dmat"); break; - case 'I': s += BaseTypeName(order, "int", "ivec", "imat"); break; - case 'U': s += BaseTypeName(order, "uint", "uvec", "umat"); break; - case 'B': s += BaseTypeName(order, "bool", "bvec", "bmat"); break; - case 'S': s += "sampler"; break; - case 's': s += "samplerShadow"; break; - case 'T': // fall through - case 'i': // ... - case 'u': // ... - if (type != 'T') // create itexture, utexture, etc - s += type; - - s += ((isImage && isBuffer) ? "imageBuffer" : - isSubpass ? "subpassInput" : - isImage ? "image" : - isBuffer ? "samplerBuffer" : - "texture"); - break; - - default: s += "UNKNOWN_TYPE"; break; - } + switch (type) { + case '-': s += "void"; break; + case 'F': s += "float"; break; + case 'D': s += "double"; break; + case 'I': s += "int"; break; + case 'U': s += "uint"; break; + case 'L': s += "int64_t"; break; + case 'M': s += "uint64_t"; break; + case 'B': s += "bool"; break; + case 'S': s += "sampler"; break; + case 's': s += "SamplerComparisonState"; break; + case 'T': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : + isBuffer ? "Buffer" : + isImage ? "RWTexture" : "Texture"); break; + case 'i': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : + isBuffer ? "Buffer" : + isImage ? "RWTexture" : "Texture"); break; + case 'u': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : + isBuffer ? "Buffer" : + isImage ? "RWTexture" : "Texture"); break; + default: s += "UNKNOWN_TYPE"; break; } + if (isSubpass && isMS) + s += "MS"; + // handle fixed vector sizes, such as float3, and only ever 3. const int fixedVecSize = FixedVecSize(argOrder); if (fixedVecSize != 0) @@ -324,7 +283,7 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons case 1: s += "1D"; break; case 2: s += (isMS ? "2DMS" : "2D"); break; case 3: s += "3D"; break; - case 4: s += "Cube"; break; + case 4: s += (type == 'S'? "CUBE" : "Cube"); break; default: s += "UNKNOWN_SAMPLER"; break; } } @@ -357,26 +316,24 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons if (isArrayed) s += "Array"; - // For HLSL, append return type for texture types - if (UseHlslTypes) { - switch (type) { - case 'i': s += "<int"; s += dim0Char; s += ">"; break; - case 'u': s += "<uint"; s += dim0Char; s += ">"; break; - case 'T': s += "<float"; s += dim0Char; s += ">"; break; - default: break; - } + switch (type) { + case 'i': s += "<int"; s += dim0Char; s += ">"; break; + case 'u': s += "<uint"; s += dim0Char; s += ">"; break; + case 'T': s += "<float"; s += dim0Char; s += ">"; break; + default: break; } return s; } -// The GLSL parser can be used to parse a subset of HLSL prototypes. However, many valid HLSL prototypes -// are not valid GLSL prototypes. This rejects the invalid ones. Thus, there is a single switch below -// to enable creation of the entire HLSL space. +// This rejects prototypes not normally valid for GLSL and it's way of finding +// overloaded built-ins under implicit type conversion. +// +// It is possible that this is not needed, but that would require some tweaking +// of other rules to get the same results. inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1) { const bool isVec = (argOrder == 'V'); - const bool isMat = (argOrder == 'M'); const std::string name(cname); @@ -387,26 +344,6 @@ inline bool IsValid(const char* cname, char retOrder, char retType, char argOrde if (!IsTextureType(argOrder) && (isVec && dim0 == 1)) // avoid vec1 return false; - if (UseHlslTypes) { - // NO further restrictions for HLSL - } else { - // GLSL parser restrictions - if ((isMat && (argType == 'I' || argType == 'U' || argType == 'B')) || - (retOrder == 'M' && (retType == 'I' || retType == 'U' || retType == 'B'))) - return false; - - if (isMat && dim0 == 1 && dim1 == 1) // avoid mat1x1 - return false; - - if (isMat && dim1 == 1) // TODO: avoid mat Nx1 until we find the right GLSL profile - return false; - - if (name == "GetRenderTargetSamplePosition" || - name == "tex1D" || - name == "tex1Dgrad") - return false; - } - return true; } @@ -461,12 +398,10 @@ void TBuiltInParseablesHlsl::createMatTimesMat() { TString& s = commonBuiltins; - const int first = (UseHlslTypes ? 1 : 2); - - for (int xRows = first; xRows <=4; xRows++) { - for (int xCols = first; xCols <=4; xCols++) { + for (int xRows = 1; xRows <=4; xRows++) { + for (int xCols = 1; xCols <=4; xCols++) { const int yRows = xCols; - for (int yCols = first; yCols <=4; yCols++) { + for (int yCols = 1; yCols <=4; yCols++) { const int retRows = xRows; const int retCols = yCols; @@ -917,7 +852,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c { "WaveActiveAllEqual", "S", "B", "SV", "DFUI", EShLangPSCS, false}, { "WaveActiveAllEqualBool", "S", "B", "S", "B", EShLangPSCS, false}, { "WaveActiveCountBits", "S", "U", "S", "B", EShLangPSCS, false}, - + { "WaveActiveSum", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false}, { "WaveActiveProduct", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false}, { "WaveActiveBitAnd", nullptr, nullptr, "SV", "DFUI", EShLangPSCS, false}, diff --git a/chromium/third_party/glslang/src/hlsl/hlslParseables.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslParseables.h index 28f424b3172..a4aef6c3e61 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslParseables.h +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/hlsl/hlslScanContext.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslScanContext.cpp index 28a66bb47d2..fc62672f4ef 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslScanContext.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslScanContext.cpp @@ -42,15 +42,15 @@ #include <unordered_map> #include <unordered_set> -#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 { @@ -317,7 +317,7 @@ void HlslScanContext::fillInKeywordMap() (*KeywordMap)["sampler1D"] = EHTokSampler1d; (*KeywordMap)["sampler2D"] = EHTokSampler2d; (*KeywordMap)["sampler3D"] = EHTokSampler3d; - (*KeywordMap)["samplerCube"] = EHTokSamplerCube; + (*KeywordMap)["samplerCUBE"] = EHTokSamplerCube; (*KeywordMap)["sampler_state"] = EHTokSamplerState; (*KeywordMap)["SamplerState"] = EHTokSamplerState; (*KeywordMap)["SamplerComparisonState"] = EHTokSamplerComparisonState; diff --git a/chromium/third_party/glslang/src/hlsl/hlslScanContext.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslScanContext.h index 9d30a12e1e5..3b191e489f5 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslScanContext.h +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/hlsl/hlslTokenStream.cpp b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokenStream.cpp index 5d9311cfd7a..5d9311cfd7a 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslTokenStream.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokenStream.cpp diff --git a/chromium/third_party/glslang/src/hlsl/hlslTokenStream.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokenStream.h index cb6c9e7234f..cb6c9e7234f 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslTokenStream.h +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokenStream.h diff --git a/chromium/third_party/glslang/src/hlsl/hlslTokens.h b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokens.h index 4426bccecb5..4426bccecb5 100644 --- a/chromium/third_party/glslang/src/hlsl/hlslTokens.h +++ b/chromium/third_party/glslang/src/glslang/HLSL/hlslTokens.h diff --git a/chromium/third_party/glslang/src/hlsl/pch.cpp b/chromium/third_party/glslang/src/glslang/HLSL/pch.cpp index b7a08654a54..b7a08654a54 100644 --- a/chromium/third_party/glslang/src/hlsl/pch.cpp +++ b/chromium/third_party/glslang/src/glslang/HLSL/pch.cpp diff --git a/chromium/third_party/glslang/src/hlsl/pch.h b/chromium/third_party/glslang/src/glslang/HLSL/pch.h index e0bc4917812..465e7c14f82 100644 --- a/chromium/third_party/glslang/src/hlsl/pch.h +++ b/chromium/third_party/glslang/src/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 <algorithm> -#include <functional> -#include <cctype> #include <array> +#include <cctype> +#include <functional> #include <set> - #endif /* _PCH_H */ diff --git a/chromium/third_party/glslang/src/glslang/Include/Types.h b/chromium/third_party/glslang/src/glslang/Include/Types.h index b2c416d1055..235ea3f1d5e 100644 --- a/chromium/third_party/glslang/src/glslang/Include/Types.h +++ b/chromium/third_party/glslang/src/glslang/Include/Types.h @@ -1235,6 +1235,7 @@ struct TShaderQualifiers { bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV set bool layoutDerivativeGroupLinear; // true if layout derivative_group_linearNV set int primitives; // mesh shader "max_primitives"DerivativeGroupLinear; // true if layout derivative_group_linearNV set + bool layoutPrimitiveCulling; // true if layout primitive_culling set TLayoutDepth getDepth() const { return layoutDepth; } #else TLayoutDepth getDepth() const { return EldNone; } @@ -1268,6 +1269,7 @@ struct TShaderQualifiers { layoutOverrideCoverage = false; layoutDerivativeGroupQuads = false; layoutDerivativeGroupLinear = false; + layoutPrimitiveCulling = false; primitives = TQualifier::layoutNotSet; interlockOrdering = EioNone; #endif @@ -1331,6 +1333,8 @@ struct TShaderQualifiers { primitives = src.primitives; if (src.interlockOrdering != EioNone) interlockOrdering = src.interlockOrdering; + if (src.layoutPrimitiveCulling) + layoutPrimitiveCulling = src.layoutPrimitiveCulling; #endif } }; diff --git a/chromium/third_party/glslang/src/glslang/Include/glslang_c_shader_types.h b/chromium/third_party/glslang/src/glslang/Include/glslang_c_shader_types.h index 769f4c4a8cc..d01a115f696 100644 --- a/chromium/third_party/glslang/src/glslang/Include/glslang_c_shader_types.h +++ b/chromium/third_party/glslang/src/glslang/Include/glslang_c_shader_types.h @@ -164,6 +164,9 @@ typedef enum { GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3), GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4), GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5), + GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6), + GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7), + GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8), LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT), } glslang_reflection_options_t; diff --git a/chromium/third_party/glslang/src/glslang/Include/revision.h b/chromium/third_party/glslang/src/glslang/Include/revision.h index 744c2fb4256..a99244be39f 100644 --- a/chromium/third_party/glslang/src/glslang/Include/revision.h +++ b/chromium/third_party/glslang/src/glslang/Include/revision.h @@ -1,3 +1,3 @@ // This header is generated by the make-revision script. -#define GLSLANG_PATCH_LEVEL 3743 +#define GLSLANG_PATCH_LEVEL 3802 diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/Intermediate.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/Intermediate.cpp index d7049d8d5cf..52ec6115f82 100755 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/Intermediate.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/Intermediate.cpp @@ -1733,12 +1733,14 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat case EbtUint64: case EbtFloat: case EbtDouble: - return true; + return version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64); case EbtInt16: case EbtUint16: - return extensionRequested(E_GL_AMD_gpu_shader_int16); + return (version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64)) && + extensionRequested(E_GL_AMD_gpu_shader_int16); case EbtFloat16: - return extensionRequested(E_GL_AMD_gpu_shader_half_float); + return (version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64)) && + extensionRequested(E_GL_AMD_gpu_shader_half_float); default: return false; } diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.cpp index 117c1644986..69800658151 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.cpp @@ -5173,6 +5173,12 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi } } } + + if (id == "primitive_culling") { + requireExtensions(loc, 1, &E_GL_EXT_ray_flags_primitive_culling, "primitive culling"); + publicType.shaderQualifiers.layoutPrimitiveCulling = true; + return; + } #endif error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), ""); @@ -5770,6 +5776,8 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type) int repeated = intermediate.addXfbBufferOffset(type); if (repeated >= 0) error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer); + if (type.isUnsizedArray()) + error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer); // "The offset must be a multiple of the size of the first component of the first // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate @@ -6104,6 +6112,8 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua error(loc, message, "num_views", ""); if (shaderQualifiers.interlockOrdering != EioNone) error(loc, message, TQualifier::getInterlockOrderingString(shaderQualifiers.interlockOrdering), ""); + if (shaderQualifiers.layoutPrimitiveCulling) + error(loc, "can only be applied as standalone", "primitive_culling", ""); #endif } @@ -7453,8 +7463,8 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con arraySizesCheck(memberLoc, currentBlockQualifier, memberType.getArraySizes(), nullptr, member == typeList.size() - 1); if (memberQualifier.hasOffset()) { if (spvVersion.spv == 0) { - requireProfile(memberLoc, ~EEsProfile, "offset on block member"); - profileRequires(memberLoc, ~EEsProfile, 440, E_GL_ARB_enhanced_layouts, "offset on block member"); + profileRequires(memberLoc, ~EEsProfile, 440, E_GL_ARB_enhanced_layouts, "\"offset\" on block member"); + profileRequires(memberLoc, EEsProfile, 300, E_GL_ARB_enhanced_layouts, "\"offset\" on block member"); } } @@ -7593,6 +7603,8 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con fixBlockLocations(loc, currentBlockQualifier, typeList, memberWithLocation, memberWithoutLocation); fixXfbOffsets(currentBlockQualifier, typeList); fixBlockUniformOffsets(currentBlockQualifier, typeList); + fixBlockUniformLayoutMatrix(currentBlockQualifier, &typeList, nullptr); + fixBlockUniformLayoutPacking(currentBlockQualifier, &typeList, nullptr); for (unsigned int member = 0; member < typeList.size(); ++member) layoutTypeCheck(typeList[member].loc, *typeList[member].type); @@ -7963,6 +7975,101 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ } } +// +// Spread LayoutMatrix to uniform block member, if a uniform block member is a struct, +// we need spread LayoutMatrix to this struct member too. and keep this rule for recursive. +// +void TParseContext::fixBlockUniformLayoutMatrix(TQualifier& qualifier, TTypeList* originTypeList, + TTypeList* tmpTypeList) +{ + assert(tmpTypeList == nullptr || originTypeList->size() == tmpTypeList->size()); + for (unsigned int member = 0; member < originTypeList->size(); ++member) { + if (qualifier.layoutPacking != ElpNone) { + if (tmpTypeList == nullptr) { + if (((*originTypeList)[member].type->isMatrix() || + (*originTypeList)[member].type->getBasicType() == EbtStruct) && + (*originTypeList)[member].type->getQualifier().layoutMatrix == ElmNone) { + (*originTypeList)[member].type->getQualifier().layoutMatrix = qualifier.layoutMatrix; + } + } else { + if (((*tmpTypeList)[member].type->isMatrix() || + (*tmpTypeList)[member].type->getBasicType() == EbtStruct) && + (*tmpTypeList)[member].type->getQualifier().layoutMatrix == ElmNone) { + (*tmpTypeList)[member].type->getQualifier().layoutMatrix = qualifier.layoutMatrix; + } + } + } + + if ((*originTypeList)[member].type->getBasicType() == EbtStruct) { + TQualifier* memberQualifier = nullptr; + // block member can be declare a matrix style, so it should be update to the member's style + if ((*originTypeList)[member].type->getQualifier().layoutMatrix == ElmNone) { + memberQualifier = &qualifier; + } else { + memberQualifier = &((*originTypeList)[member].type->getQualifier()); + } + + const TType* tmpType = tmpTypeList == nullptr ? + (*originTypeList)[member].type->clone() : (*tmpTypeList)[member].type; + + fixBlockUniformLayoutMatrix(*memberQualifier, (*originTypeList)[member].type->getWritableStruct(), + tmpType->getWritableStruct()); + + const TTypeList* structure = recordStructCopy(matrixFixRecord, (*originTypeList)[member].type, tmpType); + + if (tmpTypeList == nullptr) { + (*originTypeList)[member].type->setStruct(const_cast<TTypeList*>(structure)); + } + if (tmpTypeList != nullptr) { + (*tmpTypeList)[member].type->setStruct(const_cast<TTypeList*>(structure)); + } + } + } +} + +// +// Spread LayoutPacking to block member, if a block member is a struct, we need spread LayoutPacking to +// this struct member too. and keep this rule for recursive. +// +void TParseContext::fixBlockUniformLayoutPacking(TQualifier& qualifier, TTypeList* originTypeList, + TTypeList* tmpTypeList) +{ + assert(tmpTypeList == nullptr || originTypeList->size() == tmpTypeList->size()); + for (unsigned int member = 0; member < originTypeList->size(); ++member) { + if (qualifier.layoutPacking != ElpNone) { + if (tmpTypeList == nullptr) { + if ((*originTypeList)[member].type->getQualifier().layoutPacking == ElpNone) { + (*originTypeList)[member].type->getQualifier().layoutPacking = qualifier.layoutPacking; + } + } else { + if ((*tmpTypeList)[member].type->getQualifier().layoutPacking == ElpNone) { + (*tmpTypeList)[member].type->getQualifier().layoutPacking = qualifier.layoutPacking; + } + } + } + + if ((*originTypeList)[member].type->getBasicType() == EbtStruct) { + // Deep copy the type in pool. + // Because, struct use in different block may have different layout qualifier. + // We have to new a object to distinguish between them. + const TType* tmpType = tmpTypeList == nullptr ? + (*originTypeList)[member].type->clone() : (*tmpTypeList)[member].type; + + fixBlockUniformLayoutPacking(qualifier, (*originTypeList)[member].type->getWritableStruct(), + tmpType->getWritableStruct()); + + const TTypeList* structure = recordStructCopy(packingFixRecord, (*originTypeList)[member].type, tmpType); + + if (tmpTypeList == nullptr) { + (*originTypeList)[member].type->setStruct(const_cast<TTypeList*>(structure)); + } + if (tmpTypeList != nullptr) { + (*tmpTypeList)[member].type->setStruct(const_cast<TTypeList*>(structure)); + } + } + } +} + // For an identifier that is already declared, add more qualification to it. void TParseContext::addQualifierToExisting(const TSourceLoc& loc, TQualifier qualifier, const TString& identifier) { @@ -8271,6 +8378,16 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con { checkIoArraysConsistency(loc); } + + if (publicType.shaderQualifiers.layoutPrimitiveCulling) { + if (publicType.qualifier.storage != EvqTemporary) + error(loc, "layout qualifier can not have storage qualifiers", "primitive_culling","", ""); + else { + intermediate.setLayoutPrimitiveCulling(); + } + // Exit early as further checks are not valid + return; + } #endif const TQualifier& qualifier = publicType.qualifier; @@ -8421,5 +8538,43 @@ TIntermNode* TParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expre return switchNode; } +// +// When a struct used in block, and has it's own layout packing, layout matrix, +// record the origin structure of a struct to map, and Record the structure copy to the copy table, +// +const TTypeList* TParseContext::recordStructCopy(TStructRecord& record, const TType* originType, const TType* tmpType) +{ + size_t memberCount = tmpType->getStruct()->size(); + size_t originHash = 0, tmpHash = 0; + std::hash<size_t> hasher; + for (size_t i = 0; i < memberCount; i++) { + size_t originMemberHash = hasher(originType->getStruct()->at(i).type->getQualifier().layoutPacking + + originType->getStruct()->at(i).type->getQualifier().layoutMatrix); + size_t tmpMemberHash = hasher(tmpType->getStruct()->at(i).type->getQualifier().layoutPacking + + tmpType->getStruct()->at(i).type->getQualifier().layoutMatrix); + originHash = hasher((originHash ^ originMemberHash) << 1); + tmpHash = hasher((tmpHash ^ tmpMemberHash) << 1); + } + const TTypeList* originStruct = originType->getStruct(); + const TTypeList* tmpStruct = tmpType->getStruct(); + if (originHash != tmpHash) { + auto fixRecords = record.find(originStruct); + if (fixRecords != record.end()) { + auto fixRecord = fixRecords->second.find(tmpHash); + if (fixRecord != fixRecords->second.end()) { + return fixRecord->second; + } else { + record[originStruct][tmpHash] = tmpStruct; + return tmpStruct; + } + } else { + record[originStruct] = std::map<size_t, const TTypeList*>(); + record[originStruct][tmpHash] = tmpStruct; + return tmpStruct; + } + } + return originStruct; +} + } // end namespace glslang diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.h b/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.h index 9c5fdc7857b..8b262c94631 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.h +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/ParseHelper.h @@ -68,6 +68,7 @@ class TScanContext; class TPpContext; typedef std::set<int> TIdSetType; +typedef std::map<const TTypeList*, std::map<size_t, const TTypeList*>> TStructRecord; // // Sharable code (as well as what's in TParseVersions) across @@ -418,12 +419,15 @@ public: void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation); void fixXfbOffsets(TQualifier&, TTypeList&); void fixBlockUniformOffsets(TQualifier&, TTypeList&); + void fixBlockUniformLayoutMatrix(TQualifier&, TTypeList*, TTypeList*); + void fixBlockUniformLayoutPacking(TQualifier&, TTypeList*, TTypeList*); void addQualifierToExisting(const TSourceLoc&, TQualifier, const TString& identifier); void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&); void invariantCheck(const TSourceLoc&, const TQualifier&); void updateStandaloneQualifierDefaults(const TSourceLoc&, const TPublicType&); void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode); TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body); + const TTypeList* recordStructCopy(TStructRecord&, const TType*, const TType*); #ifndef GLSLANG_WEB TAttributeType attributeFromName(const TString& name) const; @@ -484,6 +488,8 @@ protected: bool anyIndexLimits; TIdSetType inductiveLoopIds; TVector<TIntermTyped*> needsIndexLimitationChecking; + TStructRecord matrixFixRecord; + TStructRecord packingFixRecord; // // Geometry shader input arrays: diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/ShaderLang.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/ShaderLang.cpp index a1392dbdeba..476d179840c 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/ShaderLang.cpp +++ b/chromium/third_party/glslang/src/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/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.cpp index 143f2516dc8..3bf140cce5b 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.cpp @@ -64,6 +64,7 @@ // checkDeprecated() // requireNotRemoved() // requireExtensions() +// extensionRequires() // // Typically, only the first two calls are needed. They go into a code path that // implements Feature F, and will log the proper error/warning messages. Parsing @@ -78,9 +79,11 @@ // const char* const XXX_extension_X = "XXX_extension_X"; // // 2) Add extension initialization to TParseVersions::initializeExtensionBehavior(), -// the first function below: +// the first function below and optionally a entry to extensionData for additional +// error checks: // // extensionBehavior[XXX_extension_X] = EBhDisable; +// (Optional) exts[] = {XXX_extension_X, EShTargetSpv_1_4} // // 3) Add any preprocessor directives etc. in the next function, TParseVersions::getPreamble(): // @@ -140,6 +143,8 @@ // set of extensions that both enable them and are necessary, given the version of the symbol // table. (There is a different symbol table for each version.) // +// 7) If the extension has additional requirements like minimum SPIR-V version required, add them +// to extensionRequires() #include "parseVersions.h" #include "localintermediate.h" @@ -155,6 +160,20 @@ namespace glslang { // void TParseVersions::initializeExtensionBehavior() { + typedef struct { + const char *const extensionName; + EShTargetLanguageVersion minSpvVersion; + } extensionData; + + const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4} }; + + for (size_t ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) { + // Add only extensions which require > spv1.0 to save space in map + if (exts[ii].minSpvVersion > EShTargetSpv_1_0) { + extensionMinSpv[E_GL_EXT_ray_tracing] = exts[ii].minSpvVersion; + } + } + extensionBehavior[E_GL_OES_texture_3D] = EBhDisable; extensionBehavior[E_GL_OES_standard_derivatives] = EBhDisable; extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable; @@ -329,6 +348,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int64] = EBhDisable; extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_float16] = EBhDisable; } + #endif // GLSLANG_WEB // Get code that is not part of a shared symbol table, is specific to this shader, @@ -828,6 +848,9 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co // check if extension is used with correct shader stage checkExtensionStage(getCurrentLoc(), extension); + // check if extension has additional requirements + extensionRequires(getCurrentLoc(), extension ,behaviorString); + // update the requested extension updateExtensionBehavior(extension, behavior); @@ -944,6 +967,24 @@ void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * con } } +// Check if extension has additional requirements +void TParseVersions::extensionRequires(const TSourceLoc &loc, const char * const extension, const char *behaviorString) +{ + bool isEnabled = false; + if (!strcmp("require", behaviorString)) + isEnabled = true; + else if (!strcmp("enable", behaviorString)) + isEnabled = true; + + if (isEnabled) { + unsigned int minSpvVersion = 0; + auto iter = extensionMinSpv.find(TString(extension)); + if (iter != extensionMinSpv.end()) + minSpvVersion = iter->second; + requireSpv(loc, extension, minSpvVersion); + } +} + // Call for any operation needing full GLSL integer data-type support. void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op) { @@ -1201,5 +1242,12 @@ void TParseVersions::requireSpv(const TSourceLoc& loc, const char* op) error(loc, "only allowed when generating SPIR-V", op, ""); #endif } +void TParseVersions::requireSpv(const TSourceLoc& loc, const char *op, unsigned int version) +{ +#ifndef GLSLANG_WEB + if (spvVersion.spv < version) + error(loc, "not supported for current targeted SPIR-V version", op, ""); +#endif +} } // end namespace glslang diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.h b/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.h index c128d4642d6..c90db966d56 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.h +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/Versions.h @@ -36,6 +36,7 @@ // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // + #ifndef _VERSIONS_INCLUDED_ #define _VERSIONS_INCLUDED_ diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.cpp index 9dc1da2c9e0..fadcb1bf986 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.cpp @@ -309,26 +309,43 @@ struct TSymbolValidater TIntermSymbol* base = ent1.symbol; const TType& type = ent1.symbol->getType(); const TString& name = entKey.first; - TString mangleName1, mangleName2; - type.appendMangledName(mangleName1); EShLanguage stage = ent1.stage; + TString mangleName1, mangleName2; if (currentStage != stage) { preStage = currentStage; currentStage = stage; nextStage = EShLangCount; for (int i = currentStage + 1; i < EShLangCount; i++) { - if (inVarMaps[i] != nullptr) + if (inVarMaps[i] != nullptr) { nextStage = static_cast<EShLanguage>(i); + break; + } } } + + if (type.getQualifier().isArrayedIo(stage)) { + TType subType(type, 0); + subType.appendMangledName(mangleName1); + } else { + type.appendMangledName(mangleName1); + } + if (base->getQualifier().storage == EvqVaryingIn) { // validate stage in; if (preStage == EShLangCount) return; + if (name == "gl_PerVertex") + return; if (outVarMaps[preStage] != nullptr) { auto ent2 = outVarMaps[preStage]->find(name); if (ent2 != outVarMaps[preStage]->end()) { - ent2->second.symbol->getType().appendMangledName(mangleName2); + if (ent2->second.symbol->getType().getQualifier().isArrayedIo(preStage)) { + TType subType(ent2->second.symbol->getType(), 0); + subType.appendMangledName(mangleName2); + } + else { + ent2->second.symbol->getType().appendMangledName(mangleName2); + } if (mangleName1 == mangleName2) return; else { @@ -343,10 +360,18 @@ struct TSymbolValidater // validate stage out; if (nextStage == EShLangCount) return; + if (name == "gl_PerVertex") + return; if (outVarMaps[nextStage] != nullptr) { auto ent2 = inVarMaps[nextStage]->find(name); if (ent2 != inVarMaps[nextStage]->end()) { - ent2->second.symbol->getType().appendMangledName(mangleName2); + if (ent2->second.symbol->getType().getQualifier().isArrayedIo(nextStage)) { + TType subType(ent2->second.symbol->getType(), 0); + subType.appendMangledName(mangleName2); + } + else { + ent2->second.symbol->getType().appendMangledName(mangleName2); + } if (mangleName1 == mangleName2) return; else { @@ -579,10 +604,7 @@ TDefaultGlslIoResolver::TDefaultGlslIoResolver(const TIntermediate& intermediate int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) { const TType& type = ent.symbol->getType(); - const TString& name = IsAnonymous(ent.symbol->getName()) ? - ent.symbol->getType().getTypeName() - : - ent.symbol->getName(); + const TString& name = getAccessName(ent.symbol); if (currentStage != stage) { preStage = currentStage; currentStage = stage; @@ -630,7 +652,7 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf TVarSlotMap::iterator iter = storageSlotMap[resourceKey].find(name); if (iter != storageSlotMap[resourceKey].end()) { // If interface resource be found, set it has location and this symbol's new location - // equal the symbol's explicit location declarated in pre or next stage. + // equal the symbol's explicit location declaration in pre or next stage. // // vs: out vec4 a; // fs: layout(..., location = 3,...) in vec4 a; @@ -666,10 +688,7 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) { const TType& type = ent.symbol->getType(); - const TString& name = IsAnonymous(ent.symbol->getName()) ? - ent.symbol->getType().getTypeName() - : - ent.symbol->getName(); + const TString& name = getAccessName(ent.symbol); // kick out of not doing this if (! doAutoLocationMapping()) { return ent.newLocation = -1; @@ -712,7 +731,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn TVarSlotMap::iterator iter = slotMap.find(name); if (iter != slotMap.end()) { // If uniform resource be found, set it has location and this symbol's new location - // equal the uniform's explicit location declarated in other stage. + // equal the uniform's explicit location declaration in other stage. // // vs: uniform vec4 a; // fs: layout(..., location = 3,...) uniform vec4 a; @@ -720,7 +739,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn location = iter->second; } if (! hasLocation) { - // No explicit location declaraten in other stage. + // No explicit location declaration in other stage. // So we should find a new slot for this uniform. // // vs: uniform vec4 a; @@ -729,7 +748,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn storageSlotMap[resourceKey][name] = location; } } else { - // the first uniform declarated in a program. + // the first uniform declaration in a program. TVarSlotMap varSlotMap; location = getFreeSlot(resourceKey, 0, size); varSlotMap[name] = location; @@ -740,11 +759,8 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn int TDefaultGlslIoResolver::resolveBinding(EShLanguage /*stage*/, TVarEntryInfo& ent) { const TType& type = ent.symbol->getType(); - const TString& name = IsAnonymous(ent.symbol->getName()) ? - ent.symbol->getType().getTypeName() - : - ent.symbol->getName(); - // On OpenGL arrays of opaque types take a seperate binding for each element + const TString& name = getAccessName(ent.symbol); + // On OpenGL arrays of opaque types take a separate binding for each element int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1; TResourceType resource = getResourceType(type); // don't need to handle uniform symbol, it will be handled in resolveUniformLocation @@ -818,10 +834,7 @@ void TDefaultGlslIoResolver::endCollect(EShLanguage /*stage*/) { void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) { const TType& type = ent.symbol->getType(); - const TString& name = IsAnonymous(ent.symbol->getName()) ? - ent.symbol->getType().getTypeName() - : - ent.symbol->getName(); + const TString& name = getAccessName(ent.symbol); TStorageQualifier storage = type.getQualifier().storage; EShLanguage stage(EShLangCount); switch (storage) { @@ -881,10 +894,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) { const TType& type = ent.symbol->getType(); - const TString& name = IsAnonymous(ent.symbol->getName()) ? - ent.symbol->getType().getTypeName() - : - ent.symbol->getName(); + const TString& name = getAccessName(ent.symbol); int resource = getResourceType(type); if (type.getQualifier().hasBinding()) { TVarSlotMap& varSlotMap = resourceSlotMap[resource]; @@ -907,6 +917,13 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& } } +const TString& TDefaultGlslIoResolver::getAccessName(const TIntermSymbol* symbol) +{ + return symbol->getBasicType() == EbtBlock ? + symbol->getType().getTypeName() : + symbol->getName(); +} + //TDefaultGlslIoResolver end /* diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.h b/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.h index a6f2480cab0..7ca18b8a599 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.h +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/iomapper.h @@ -203,6 +203,7 @@ public: void endCollect(EShLanguage) override; void reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override; void reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override; + const TString& getAccessName(const TIntermSymbol*); // in/out symbol and uniform symbol are stored in the same resourceSlotMap, the storage key is used to identify each type of symbol. // We use stage and storage qualifier to construct a storage key. it can help us identify the same storage resource used in different stage. // if a resource is a program resource and we don't need know it usage stage, we can use same stage to build storage key. diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/linkValidate.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/linkValidate.cpp index dcb1cc8cba9..f0bede53a39 100755 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/linkValidate.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/linkValidate.cpp @@ -153,7 +153,7 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit) if (vertices == TQualifier::layoutNotSet) vertices = unit.vertices; - else if (vertices != unit.vertices) { + else if (unit.vertices != TQualifier::layoutNotSet && vertices != unit.vertices) { if (language == EShLangGeometry || language == EShLangMeshNV) error(infoSink, "Contradictory layout max_vertices values"); else if (language == EShLangTessControl) @@ -172,12 +172,12 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit) if (inputPrimitive == ElgNone) inputPrimitive = unit.inputPrimitive; - else if (inputPrimitive != unit.inputPrimitive) + else if (unit.inputPrimitive != ElgNone && inputPrimitive != unit.inputPrimitive) error(infoSink, "Contradictory input layout primitives"); if (outputPrimitive == ElgNone) outputPrimitive = unit.outputPrimitive; - else if (outputPrimitive != unit.outputPrimitive) + else if (unit.outputPrimitive != ElgNone && outputPrimitive != unit.outputPrimitive) error(infoSink, "Contradictory output layout primitives"); if (originUpperLeft != unit.originUpperLeft || pixelCenterInteger != unit.pixelCenterInteger) @@ -1362,9 +1362,9 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains // that component's size. Aggregate types are flattened down to the component // level to get this sequence of components." - if (type.isArray()) { + if (type.isSizedArray()) { // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness - assert(type.isSizedArray()); + // Unsized array use to xfb should be a compile error. TType elementType(type, 0); return type.getOuterArraySize() * computeTypeXfbSize(elementType, contains64BitType, contains16BitType, contains16BitType); } @@ -1550,7 +1550,9 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, T RoundToPow2(size, alignment); stride = size; // uses full matrix size for stride of an array of matrices (not quite what rule 6/8, but what's expected) // uses the assumption for rule 10 in the comment above - size = stride * type.getOuterArraySize(); + // use one element to represent the last member of SSBO which is unsized array + int arraySize = (type.isUnsizedArray() && (type.getOuterArraySize() == 0)) ? 1 : type.getOuterArraySize(); + size = stride * arraySize; return alignment; } diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/localintermediate.h b/chromium/third_party/glslang/src/glslang/MachineIndependent/localintermediate.h index 996e347fb2f..a3ff88683b5 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/localintermediate.h +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/localintermediate.h @@ -265,6 +265,7 @@ public: computeDerivativeMode(LayoutDerivativeNone), primitives(TQualifier::layoutNotSet), numTaskNVBlocks(0), + layoutPrimitiveCulling(false), autoMapBindings(false), autoMapLocations(false), flattenUniformArrays(false), @@ -399,7 +400,7 @@ public: void setSource(EShSource s) { source = s; } EShSource getSource() const { return source; } #else - void setSource(EShSource s) { assert(s == EShSourceGlsl); } + void setSource(EShSource s) { assert(s == EShSourceGlsl); (void)s; } EShSource getSource() const { return EShSourceGlsl; } #endif @@ -742,6 +743,8 @@ public: void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; } bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; } ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; } + void setLayoutPrimitiveCulling() { layoutPrimitiveCulling = true; } + bool getLayoutPrimitiveCulling() const { return layoutPrimitiveCulling; } bool setPrimitives(int m) { if (primitives != TQualifier::layoutNotSet) @@ -974,6 +977,7 @@ protected: ComputeDerivativeMode computeDerivativeMode; int primitives; int numTaskNVBlocks; + bool layoutPrimitiveCulling; // Base shift values std::array<unsigned int, EResCount> shiftBinding; diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/parseVersions.h b/chromium/third_party/glslang/src/glslang/MachineIndependent/parseVersions.h index aa1964fc2e5..0d006a716e5 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/parseVersions.h +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/parseVersions.h @@ -101,6 +101,7 @@ public: void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { } void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { } void checkExtensionStage(const TSourceLoc&, const char* const extension) { } + void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior) { } void fullIntegerCheck(const TSourceLoc&, const char* op) { } void doubleCheck(const TSourceLoc&, const char* op) { } bool float16Arithmetic() { return false; } @@ -139,6 +140,7 @@ public: virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[], const char* featureDesc); virtual void checkExtensionStage(const TSourceLoc&, const char* const extension); + virtual void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior); virtual void fullIntegerCheck(const TSourceLoc&, const char* op); virtual void unimplemented(const TSourceLoc&, const char* featureDesc); @@ -170,6 +172,7 @@ public: virtual void vulkanRemoved(const TSourceLoc&, const char* op); virtual void requireVulkan(const TSourceLoc&, const char* op); virtual void requireSpv(const TSourceLoc&, const char* op); + virtual void requireSpv(const TSourceLoc&, const char *op, unsigned int version); #if defined(GLSLANG_WEB) && !defined(GLSLANG_WEB_DEVEL) @@ -222,6 +225,7 @@ public: protected: TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to + TMap<TString, unsigned int> extensionMinSpv; // for each extension string, store minimum spirv required EShMessages messages; // errors/warnings/rule-sets int numErrors; // number of compile-time errors encountered TInputScanner* currentScanner; diff --git a/chromium/third_party/glslang/src/glslang/MachineIndependent/reflection.cpp b/chromium/third_party/glslang/src/glslang/MachineIndependent/reflection.cpp index 28769332340..03d6fe14572 100644 --- a/chromium/third_party/glslang/src/glslang/MachineIndependent/reflection.cpp +++ b/chromium/third_party/glslang/src/glslang/MachineIndependent/reflection.cpp @@ -77,10 +77,10 @@ namespace glslang { // This is in the glslang namespace directly so it can be a friend of TReflection. // -class TReflectionTraverser : public TLiveTraverser { +class TReflectionTraverser : public TIntermTraverser { public: TReflectionTraverser(const TIntermediate& i, TReflection& r) : - TLiveTraverser(i), reflection(r) { } + TIntermTraverser(), intermediate(i), reflection(r), updateStageMasks(true) { } virtual bool visitBinary(TVisit, TIntermBinary* node); virtual void visitSymbol(TIntermSymbol* base); @@ -92,11 +92,28 @@ public: if (processedDerefs.find(&base) == processedDerefs.end()) { processedDerefs.insert(&base); + int blockIndex = -1; + int offset = -1; + TList<TIntermBinary*> derefs; + TString baseName = base.getName(); + + if (base.getType().getBasicType() == EbtBlock) { + offset = 0; + bool anonymous = IsAnonymous(baseName); + const TString& blockName = base.getType().getTypeName(); + + if (!anonymous) + baseName = blockName; + else + baseName = ""; + + blockIndex = addBlockName(blockName, base.getType(), intermediate.getBlockSize(base.getType())); + } + // Use a degenerate (empty) set of dereferences to immediately put as at the end of // the dereference change expected by blowUpActiveAggregate. - TList<TIntermBinary*> derefs; - blowUpActiveAggregate(base.getType(), base.getName(), derefs, derefs.end(), -1, -1, 0, 0, - base.getQualifier().storage, true); + blowUpActiveAggregate(base.getType(), baseName, derefs, derefs.end(), offset, blockIndex, 0, -1, 0, + base.getQualifier().storage, updateStageMasks); } } @@ -155,9 +172,9 @@ public: void getOffsets(const TType& type, TVector<int>& offsets) { const TTypeList& memberList = *type.getStruct(); - int memberSize = 0; int offset = 0; + for (size_t m = 0; m < offsets.size(); ++m) { // if the user supplied an offset, snap to it now if (memberList[m].type->getQualifier().hasOffset()) @@ -233,7 +250,7 @@ public: // A value of 0 for arraySize will mean to use the full array's size. void blowUpActiveAggregate(const TType& baseType, const TString& baseName, const TList<TIntermBinary*>& derefs, TList<TIntermBinary*>::const_iterator deref, int offset, int blockIndex, int arraySize, - int topLevelArrayStride, TStorageQualifier baseStorage, bool active) + int topLevelArraySize, int topLevelArrayStride, TStorageQualifier baseStorage, bool active) { // when strictArraySuffix is enabled, we closely follow the rules from ARB_program_interface_query. // Broadly: @@ -262,14 +279,15 @@ public: // Visit all the indices of this array, and for each one add on the remaining dereferencing for (int i = 0; i < std::max(visitNode->getLeft()->getType().getOuterArraySize(), 1); ++i) { TString newBaseName = name; - if (strictArraySuffix && blockParent) + if (terminalType->getBasicType() == EbtBlock) {} + else if (strictArraySuffix && blockParent) newBaseName.append(TString("[0]")); else if (strictArraySuffix || baseType.getBasicType() != EbtBlock) newBaseName.append(TString("[") + String(i) + "]"); TList<TIntermBinary*>::const_iterator nextDeref = deref; ++nextDeref; blowUpActiveAggregate(*terminalType, newBaseName, derefs, nextDeref, offset, blockIndex, arraySize, - topLevelArrayStride, baseStorage, active); + topLevelArraySize, topLevelArrayStride, baseStorage, active); if (offset >= 0) offset += stride; @@ -282,9 +300,10 @@ public: int stride = getArrayStride(baseType, visitNode->getLeft()->getType()); index = visitNode->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst(); - if (strictArraySuffix && blockParent) { + if (terminalType->getBasicType() == EbtBlock) {} + else if (strictArraySuffix && blockParent) name.append(TString("[0]")); - } else if (strictArraySuffix || baseType.getBasicType() != EbtBlock) { + else if (strictArraySuffix || baseType.getBasicType() != EbtBlock) { name.append(TString("[") + String(index) + "]"); if (offset >= 0) @@ -294,7 +313,10 @@ public: if (topLevelArrayStride == 0) topLevelArrayStride = stride; - blockParent = false; + // expand top-level arrays in blocks with [0] suffix + if (topLevelArrayStride != 0 && visitNode->getLeft()->getType().isArray()) { + blockParent = false; + } break; } case EOpIndexDirectStruct: @@ -304,6 +326,12 @@ public: if (name.size() > 0) name.append("."); name.append((*visitNode->getLeft()->getType().getStruct())[index].type->getFieldName()); + + // expand non top-level arrays with [x] suffix + if (visitNode->getLeft()->getType().getBasicType() != EbtBlock && terminalType->isArray()) + { + blockParent = false; + } break; default: break; @@ -323,24 +351,27 @@ public: if (offset >= 0) stride = getArrayStride(baseType, *terminalType); - if (topLevelArrayStride == 0) - topLevelArrayStride = stride; - int arrayIterateSize = std::max(terminalType->getOuterArraySize(), 1); // for top-level arrays in blocks, only expand [0] to avoid explosion of items - if (strictArraySuffix && blockParent) + if ((strictArraySuffix && blockParent) || + ((topLevelArraySize == arrayIterateSize) && (topLevelArrayStride == 0))) { arrayIterateSize = 1; + } + + if (topLevelArrayStride == 0) + topLevelArrayStride = stride; for (int i = 0; i < arrayIterateSize; ++i) { TString newBaseName = name; - newBaseName.append(TString("[") + String(i) + "]"); + if (terminalType->getBasicType() != EbtBlock) + newBaseName.append(TString("[") + String(i) + "]"); TType derefType(*terminalType, 0); if (offset >= 0) offset = baseOffset + stride * i; blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0, - topLevelArrayStride, baseStorage, active); + topLevelArraySize, topLevelArrayStride, baseStorage, active); } } else { // Visit all members of this aggregate, and for each one, @@ -369,8 +400,31 @@ public: arrayStride = getArrayStride(baseType, derefType); } - blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0, - arrayStride, baseStorage, active); + if (topLevelArraySize == -1 && arrayStride == 0 && blockParent) + topLevelArraySize = 1; + + if (strictArraySuffix && blockParent) { + // if this member is an array, store the top-level array stride but start the explosion from + // the inner struct type. + if (derefType.isArray() && derefType.isStruct()) { + newBaseName.append("[0]"); + auto dimSize = derefType.isUnsizedArray() ? 0 : derefType.getArraySizes()->getDimSize(0); + blowUpActiveAggregate(TType(derefType, 0), newBaseName, derefs, derefs.end(), memberOffsets[i], + blockIndex, 0, dimSize, arrayStride, terminalType->getQualifier().storage, false); + } + else if (derefType.isArray()) { + auto dimSize = derefType.isUnsizedArray() ? 0 : derefType.getArraySizes()->getDimSize(0); + blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), memberOffsets[i], blockIndex, + 0, dimSize, 0, terminalType->getQualifier().storage, false); + } + else { + blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), memberOffsets[i], blockIndex, + 0, 1, 0, terminalType->getQualifier().storage, false); + } + } else { + blowUpActiveAggregate(derefType, newBaseName, derefs, derefs.end(), offset, blockIndex, 0, + topLevelArraySize, arrayStride, baseStorage, active); + } } } @@ -406,6 +460,7 @@ public: if ((reflection.options & EShReflectionSeparateBuffers) && terminalType->isAtomic()) reflection.atomicCounterUniformIndices.push_back(uniformIndex); + variables.back().topLevelArraySize = topLevelArraySize; variables.back().topLevelArrayStride = topLevelArrayStride; if ((reflection.options & EShReflectionAllBlockVariables) && active) { @@ -537,65 +592,17 @@ public: if (! anonymous) baseName = blockName; - if (base->getType().isArray()) { - TType derefType(base->getType(), 0); - - assert(! anonymous); - for (int e = 0; e < base->getType().getCumulativeArraySize(); ++e) - blockIndex = addBlockName(blockName + "[" + String(e) + "]", derefType, - intermediate.getBlockSize(base->getType())); - baseName.append(TString("[0]")); - } else - blockIndex = addBlockName(blockName, base->getType(), intermediate.getBlockSize(base->getType())); + blockIndex = addBlockName(blockName, base->getType(), intermediate.getBlockSize(base->getType())); if (reflection.options & EShReflectionAllBlockVariables) { // Use a degenerate (empty) set of dereferences to immediately put as at the end of // the dereference change expected by blowUpActiveAggregate. TList<TIntermBinary*> derefs; - // because we don't have any derefs, the first thing blowUpActiveAggregate will do is iterate over each - // member in the struct definition. This will lose any information about whether the parent was a buffer - // block. So if we're using strict array rules which don't expand the first child of a buffer block we - // instead iterate over the children here. - const bool strictArraySuffix = (reflection.options & EShReflectionStrictArraySuffix); - bool blockParent = (base->getType().getBasicType() == EbtBlock && base->getQualifier().storage == EvqBuffer); - - if (strictArraySuffix && blockParent) { - TType structDerefType(base->getType(), 0); - - const TType &structType = base->getType().isArray() ? structDerefType : base->getType(); - const TTypeList& typeList = *structType.getStruct(); - - TVector<int> memberOffsets; - - memberOffsets.resize(typeList.size()); - getOffsets(structType, memberOffsets); - - for (int i = 0; i < (int)typeList.size(); ++i) { - TType derefType(structType, i); - TString name = baseName; - if (name.size() > 0) - name.append("."); - name.append(typeList[i].type->getFieldName()); - - // if this member is an array, store the top-level array stride but start the explosion from - // the inner struct type. - if (derefType.isArray() && derefType.isStruct()) { - name.append("[0]"); - blowUpActiveAggregate(TType(derefType, 0), name, derefs, derefs.end(), memberOffsets[i], - blockIndex, 0, getArrayStride(structType, derefType), - base->getQualifier().storage, false); - } else { - blowUpActiveAggregate(derefType, name, derefs, derefs.end(), memberOffsets[i], blockIndex, - 0, 0, base->getQualifier().storage, false); - } - } - } else { - // otherwise - if we're not using strict array suffix rules, or this isn't a block so we are - // expanding root arrays anyway, just start the iteration from the base block type. - blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.end(), 0, blockIndex, 0, 0, + // otherwise - if we're not using strict array suffix rules, or this isn't a block so we are + // expanding root arrays anyway, just start the iteration from the base block type. + blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.end(), 0, blockIndex, 0, -1, 0, base->getQualifier().storage, false); - } } } @@ -626,30 +633,40 @@ public: else baseName = base->getName(); } - blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize, 0, + blowUpActiveAggregate(base->getType(), baseName, derefs, derefs.begin(), offset, blockIndex, arraySize, -1, 0, base->getQualifier().storage, true); } int addBlockName(const TString& name, const TType& type, int size) { - TReflection::TMapIndexToReflection& blocks = reflection.GetBlockMapForStorage(type.getQualifier().storage); - int blockIndex; - TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str()); - if (reflection.nameToIndex.find(name.c_str()) == reflection.nameToIndex.end()) { - blockIndex = (int)blocks.size(); - reflection.nameToIndex[name.c_str()] = blockIndex; - blocks.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, -1)); + if (type.isArray()) { + TType derefType(type, 0); + for (int e = 0; e < type.getOuterArraySize(); ++e) { + int memberBlockIndex = addBlockName(name + "[" + String(e) + "]", derefType, size); + if (e == 0) + blockIndex = memberBlockIndex; + } + } else { + TReflection::TMapIndexToReflection& blocks = reflection.GetBlockMapForStorage(type.getQualifier().storage); - blocks.back().numMembers = countAggregateMembers(type); + TReflection::TNameToIndex::const_iterator it = reflection.nameToIndex.find(name.c_str()); + if (reflection.nameToIndex.find(name.c_str()) == reflection.nameToIndex.end()) { + blockIndex = (int)blocks.size(); + reflection.nameToIndex[name.c_str()] = blockIndex; + blocks.push_back(TObjectReflection(name.c_str(), type, -1, -1, size, blockIndex)); - EShLanguageMask& stages = blocks.back().stages; - stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage()); - } else { - blockIndex = it->second; + blocks.back().numMembers = countAggregateMembers(type); - EShLanguageMask& stages = blocks[blockIndex].stages; - stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage()); + EShLanguageMask& stages = blocks.back().stages; + stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage()); + } + else { + blockIndex = it->second; + + EShLanguageMask& stages = blocks[blockIndex].stages; + stages = static_cast<EShLanguageMask>(stages | 1 << intermediate.getStage()); + } } return blockIndex; @@ -995,8 +1012,10 @@ public: return type.isArray() ? type.getOuterArraySize() : 1; } + const TIntermediate& intermediate; TReflection& reflection; std::set<const TIntermNode*> processedDerefs; + bool updateStageMasks; protected: TReflectionTraverser(TReflectionTraverser&); @@ -1029,7 +1048,21 @@ bool TReflectionTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node) // To reflect non-dereferenced objects. void TReflectionTraverser::visitSymbol(TIntermSymbol* base) { - if (base->getQualifier().storage == EvqUniform) + if (base->getQualifier().storage == EvqUniform) { + if (base->getBasicType() == EbtBlock) { + if (reflection.options & EShReflectionSharedStd140UBO) { + addUniform(*base); + } + } else { + addUniform(*base); + } + } + + // #TODO add std140/layout active rules for ssbo, same with ubo. + // Storage buffer blocks will be collected and expanding in this part. + if((reflection.options & EShReflectionSharedStd140SSBO) && + (base->getQualifier().storage == EvqBuffer && base->getBasicType() == EbtBlock && + (base->getQualifier().layoutPacking == ElpStd140 || base->getQualifier().layoutPacking == ElpShared))) addUniform(*base); if ((intermediate.getStage() == reflection.firstStage && base->getQualifier().isPipeInput()) || @@ -1135,15 +1168,47 @@ bool TReflection::addStage(EShLanguage stage, const TIntermediate& intermediate) TReflectionTraverser it(intermediate, *this); - // put the entry point on the list of functions to process - it.pushFunction(intermediate.getEntryPointMangledName().c_str()); - - // process all the functions - while (! it.functions.empty()) { - TIntermNode* function = it.functions.back(); - it.functions.pop_back(); - function->traverse(&it); + for (auto& sequnence : intermediate.getTreeRoot()->getAsAggregate()->getSequence()) { + if (sequnence->getAsAggregate() != nullptr) { + if (sequnence->getAsAggregate()->getOp() == glslang::EOpLinkerObjects) { + it.updateStageMasks = false; + TIntermAggregate* linkerObjects = sequnence->getAsAggregate(); + for (auto& sequnence : linkerObjects->getSequence()) { + auto pNode = sequnence->getAsSymbolNode(); + if (pNode != nullptr) { + if ((pNode->getQualifier().storage == EvqUniform && + (options & EShReflectionSharedStd140UBO)) || + (pNode->getQualifier().storage == EvqBuffer && + (options & EShReflectionSharedStd140SSBO))) { + // collect std140 and shared uniform block form AST + if ((pNode->getBasicType() == EbtBlock) && + ((pNode->getQualifier().layoutPacking == ElpStd140) || + (pNode->getQualifier().layoutPacking == ElpShared))) { + pNode->traverse(&it); + } + } + else if ((options & EShReflectionAllIOVariables) && + (pNode->getQualifier().isPipeInput() || pNode->getQualifier().isPipeOutput())) + { + pNode->traverse(&it); + } + } + } + } else { + // This traverser will travers all function in AST. + // If we want reflect uncalled function, we need set linke message EShMsgKeepUncalled. + // When EShMsgKeepUncalled been set to true, all function will be keep in AST, even it is a uncalled function. + // This will keep some uniform variables in reflection, if those uniform variables is used in these uncalled function. + // + // If we just want reflect only live node, we can use a default link message or set EShMsgKeepUncalled false. + // When linke message not been set EShMsgKeepUncalled, linker won't keep uncalled function in AST. + // So, travers all function node can equivalent to travers live function. + it.updateStageMasks = true; + sequnence->getAsAggregate()->traverse(&it); + } + } } + it.updateStageMasks = true; buildCounterIndices(intermediate); buildUniformStageMask(intermediate); diff --git a/chromium/third_party/glslang/src/glslang/Public/ShaderLang.h b/chromium/third_party/glslang/src/glslang/Public/ShaderLang.h index ad984944ab8..d51749b3e8d 100755..100644 --- a/chromium/third_party/glslang/src/glslang/Public/ShaderLang.h +++ b/chromium/third_party/glslang/src/glslang/Public/ShaderLang.h @@ -68,7 +68,7 @@ // This should always increase, as some paths to do not consume // a more major number. // It should increment by one when new functionality is added. -#define GLSLANG_MINOR_VERSION 13 +#define GLSLANG_MINOR_VERSION 15 // // Call before doing any other compiler/linker operations. @@ -255,7 +255,7 @@ enum EShMessages : unsigned { EShMsgDebugInfo = (1 << 10), // save debug information EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages - EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers) + EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics) EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table LAST_ELEMENT_MARKER(EShMsgCount), }; @@ -264,13 +264,16 @@ enum EShMessages : unsigned { // Options for building reflection // typedef enum { - EShReflectionDefault = 0, // default is original behaviour before options were added - EShReflectionStrictArraySuffix = (1 << 0), // reflection will follow stricter rules for array-of-structs suffixes - EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection - EShReflectionIntermediateIO = (1 << 2), // reflect inputs and outputs to program, even with no vertex shader - EShReflectionSeparateBuffers = (1 << 3), // buffer variables and buffer blocks are reflected separately - EShReflectionAllBlockVariables = (1 << 4), // reflect all variables in blocks, even if they are inactive - EShReflectionUnwrapIOBlocks = (1 << 5), // unwrap input/output blocks the same as with uniform blocks + EShReflectionDefault = 0, // default is original behaviour before options were added + EShReflectionStrictArraySuffix = (1 << 0), // reflection will follow stricter rules for array-of-structs suffixes + EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection + EShReflectionIntermediateIO = (1 << 2), // reflect inputs and outputs to program, even with no vertex shader + EShReflectionSeparateBuffers = (1 << 3), // buffer variables and buffer blocks are reflected separately + EShReflectionAllBlockVariables = (1 << 4), // reflect all variables in blocks, even if they are inactive + EShReflectionUnwrapIOBlocks = (1 << 5), // unwrap input/output blocks the same as with uniform blocks + EShReflectionAllIOVariables = (1 << 6), // reflect all input/output variables, even if they are inactive + EShReflectionSharedStd140SSBO = (1 << 7), // Apply std140/shared rules for ubo to ssbo + EShReflectionSharedStd140UBO = (1 << 8), // Apply std140/shared rules for ubo to ssbo LAST_ELEMENT_MARKER(EShReflectionCount), } EShReflectionOptions; @@ -412,6 +415,7 @@ enum TResourceType { EResCount }; + // Make one TShader per shader that you will link into a program. Then // - provide the shader through setStrings() or setStringsWithLengths() // - optionally call setEnv*(), see below for more detail @@ -694,6 +698,7 @@ public: int counterIndex; int numMembers; int arrayStride; // stride of an array variable + int topLevelArraySize; // size of the top-level variable in a storage buffer member int topLevelArrayStride; // stride of the top-level variable in a storage buffer member EShLanguageMask stages; diff --git a/chromium/third_party/glslang/src/gtests/AST.FromFile.cpp b/chromium/third_party/glslang/src/gtests/AST.FromFile.cpp index 50046719b48..762713782c5 100644 --- a/chromium/third_party/glslang/src/gtests/AST.FromFile.cpp +++ b/chromium/third_party/glslang/src/gtests/AST.FromFile.cpp @@ -234,6 +234,9 @@ INSTANTIATE_TEST_CASE_P( "maxClipDistances.vert", "findFunction.frag", "constantUnaryConversion.comp", + "xfbUnsizedArray.error.vert", + "glsl.140.layoutOffset.error.vert", + "glsl.430.layoutOffset.error.vert", "glsl.450.subgroup.frag", "glsl.450.subgroup.geom", "glsl.450.subgroup.tesc", @@ -258,6 +261,7 @@ INSTANTIATE_TEST_CASE_P( "glsl.460.subgroup.rgen", "glsl.460.subgroup.rint", "glsl.460.subgroup.rmiss", + "glsl.es300.layoutOffset.error.vert", "glsl.es320.subgroup.frag", "glsl.es320.subgroup.geom", "glsl.es320.subgroup.tesc", @@ -285,6 +289,7 @@ INSTANTIATE_TEST_CASE_P( })), FileNameAsCustomTestSuffix ); + // clang-format on } // anonymous namespace diff --git a/chromium/third_party/glslang/src/gtests/Hlsl.FromFile.cpp b/chromium/third_party/glslang/src/gtests/Hlsl.FromFile.cpp index f4835364408..c5e6d9f54f7 100755 --- a/chromium/third_party/glslang/src/gtests/Hlsl.FromFile.cpp +++ b/chromium/third_party/glslang/src/gtests/Hlsl.FromFile.cpp @@ -227,6 +227,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.hull.3.tesc", "main"}, {"hlsl.hull.4.tesc", "main"}, {"hlsl.hull.5.tesc", "main"}, + {"hlsl.hull.6.tesc", "main"}, {"hlsl.hull.void.tesc", "main"}, {"hlsl.hull.ctrlpt-1.tesc", "main"}, {"hlsl.hull.ctrlpt-2.tesc", "main"}, @@ -238,6 +239,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.implicitBool.frag", "main"}, {"hlsl.inf.vert", "main"}, {"hlsl.inoutquals.frag", "main"}, + {"hlsl.inoutquals.negative.frag", "main"}, {"hlsl.init.frag", "ShaderFunction"}, {"hlsl.init2.frag", "main"}, {"hlsl.isfinite.frag", "main"}, diff --git a/chromium/third_party/glslang/src/gtests/Link.FromFile.cpp b/chromium/third_party/glslang/src/gtests/Link.FromFile.cpp index dc9bb765cc4..3e1620719e7 100755 --- a/chromium/third_party/glslang/src/gtests/Link.FromFile.cpp +++ b/chromium/third_party/glslang/src/gtests/Link.FromFile.cpp @@ -99,6 +99,7 @@ INSTANTIATE_TEST_CASE_P( {"empty.frag", "empty2.frag", "empty3.frag"}, {"150.tesc", "150.tese", "400.tesc", "400.tese", "410.tesc", "420.tesc", "420.tese"}, {"max_vertices_0.geom"}, + {"contradict_0.geom", "contradict_1.geom"}, {"es-link1.frag", "es-link2.frag"}, {"missingBodies.vert"}, {"link.multiAnonBlocksInvalid.0.0.vert", "link.multiAnonBlocksInvalid.0.1.vert"}, diff --git a/chromium/third_party/glslang/src/gtests/Spv.FromFile.cpp b/chromium/third_party/glslang/src/gtests/Spv.FromFile.cpp index 1d061fb364b..e1d973529f7 100644 --- a/chromium/third_party/glslang/src/gtests/Spv.FromFile.cpp +++ b/chromium/third_party/glslang/src/gtests/Spv.FromFile.cpp @@ -329,20 +329,6 @@ INSTANTIATE_TEST_CASE_P( "spv.earlyReturnDiscard.frag", "spv.extPostDepthCoverage.frag", "spv.extPostDepthCoverage_Error.frag", - "spv.ext.AnyHitShader.rahit", - "spv.ext.AnyHitShader_Errors.rahit", - "spv.ext.ClosestHitShader.rchit", - "spv.ext.ClosestHitShader_Errors.rchit", - "spv.ext.IntersectShader.rint", - "spv.ext.IntersectShader_Errors.rint", - "spv.ext.MissShader.rmiss", - "spv.ext.MissShader_Errors.rmiss", - "spv.ext.RayCallable.rcall", - "spv.ext.RayCallable_Errors.rcall", - "spv.ext.RayConstants.rgen", - "spv.ext.RayGenShader.rgen", - "spv.ext.RayGenShader11.rgen", - "spv.ext.RayGenShaderArray.rgen", "spv.float16convertonlyarith.comp", "spv.float16convertonlystorage.comp", "spv.flowControl.frag", @@ -440,6 +426,9 @@ INSTANTIATE_TEST_CASE_P( "spv.specConstant.comp", "spv.specConstantComposite.vert", "spv.specConstantOperations.vert", + "spv.specConstant.float16.comp", + "spv.specConstant.int16.comp", + "spv.specConstant.int8.comp", "spv.storageBuffer.vert", "spv.precise.tese", "spv.precise.tesc", @@ -545,6 +534,7 @@ INSTANTIATE_TEST_CASE_P( "spv.1.4.LoopControl.frag", "spv.1.4.NonWritable.frag", "spv.1.4.OpEntryPoint.frag", + "spv.1.4.OpEntryPoint.opaqueParams.vert", "spv.1.4.OpSelect.frag", "spv.1.4.OpCopyLogical.comp", "spv.1.4.OpCopyLogicalBool.comp", @@ -553,6 +543,21 @@ INSTANTIATE_TEST_CASE_P( "spv.1.4.sparseTexture.frag", "spv.1.4.texture.frag", "spv.1.4.constructComposite.comp", + "spv.ext.AnyHitShader.rahit", + "spv.ext.AnyHitShader_Errors.rahit", + "spv.ext.ClosestHitShader.rchit", + "spv.ext.ClosestHitShader_Errors.rchit", + "spv.ext.IntersectShader.rint", + "spv.ext.IntersectShader_Errors.rint", + "spv.ext.MissShader.rmiss", + "spv.ext.MissShader_Errors.rmiss", + "spv.ext.RayPrimCull_Errors.rgen", + "spv.ext.RayCallable.rcall", + "spv.ext.RayCallable_Errors.rcall", + "spv.ext.RayConstants.rgen", + "spv.ext.RayGenShader.rgen", + "spv.ext.RayGenShader11.rgen", + "spv.ext.RayGenShaderArray.rgen", })), FileNameAsCustomTestSuffix ); @@ -600,6 +605,9 @@ INSTANTIATE_TEST_CASE_P( "spv.specConst.vert", "spv.specTexture.frag", "spv.OVR_multiview.vert", + "spv.uniformInitializer.frag", + "spv.uniformInitializerSpecConstant.frag", + "spv.uniformInitializerStruct.frag", "spv.xfbOffsetOnBlockMembersAssignment.vert", "spv.xfbOffsetOnStructMembersAssignment.vert", "spv.xfbOverlapOffsetCheckWithBlockAndMember.vert", diff --git a/chromium/third_party/glslang/src/hlsl/CMakeLists.txt b/chromium/third_party/glslang/src/hlsl/CMakeLists.txt index ae0d4d4eb74..0e5d901c245 100644 --- a/chromium/third_party/glslang/src/hlsl/CMakeLists.txt +++ b/chromium/third_party/glslang/src/hlsl/CMakeLists.txt @@ -1,25 +1,11 @@ -set(SOURCES - hlslAttributes.cpp - hlslParseHelper.cpp - hlslScanContext.cpp - hlslOpMap.cpp - hlslTokenStream.cpp - hlslGrammar.cpp - hlslParseables.cpp) -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 +13,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 diff --git a/chromium/third_party/glslang/src/hlsl/stub.cpp b/chromium/third_party/glslang/src/hlsl/stub.cpp new file mode 100644 index 00000000000..f1d39c1517b --- /dev/null +++ b/chromium/third_party/glslang/src/hlsl/stub.cpp @@ -0,0 +1,41 @@ +// +// Copyright (C) 2020 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. +// + +// 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. diff --git a/chromium/third_party/glslang/src/known_good.json b/chromium/third_party/glslang/src/known_good.json index 09042525ef3..9846b115655 100644 --- a/chromium/third_party/glslang/src/known_good.json +++ b/chromium/third_party/glslang/src/known_good.json @@ -5,14 +5,14 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit" : "bd0a2da946c3fb4c641acc4a0d53ee67653e200a" + "commit" : "e128ab0d624ce7beb08eb9656bb260c597a46d0a" }, { "name" : "spirv-tools/external/spirv-headers", "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Headers", "subdir" : "External/spirv-tools/external/spirv-headers", - "commit" : "f8bf11a0253a32375c32cad92c841237b96696c0" + "commit" : "ac638f1815425403e946d0ab78bac71d2bdbf3be" } ] } diff --git a/chromium/third_party/glslang/src/kokoro/android-ndk-build/build-docker.sh b/chromium/third_party/glslang/src/kokoro/android-ndk-build/build-docker.sh new file mode 100755 index 00000000000..2b23b27a758 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/android-ndk-build/build-docker.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # Display commands being run. + +using ndk-r21d + +export NDK_PROJECT_PATH="${ROOT_DIR}/ndk_test" +export APP_BUILD_SCRIPT="${ROOT_DIR}/ndk_test/Android.mk" + +echo "Building..." +ndk-build -j diff --git a/chromium/third_party/glslang/src/kokoro/android-ndk-build/build.sh b/chromium/third_party/glslang/src/kokoro/android-ndk-build/build.sh new file mode 100755 index 00000000000..5924f334c2b --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/android-ndk-build/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/chromium/third_party/glslang/src/kokoro/android-ndk-build/continuous.cfg b/chromium/third_party/glslang/src/kokoro/android-ndk-build/continuous.cfg new file mode 100644 index 00000000000..ee0c4fb98b0 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/android-ndk-build/continuous.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Continuous build configuration. +build_file: "glslang/kokoro/android-ndk-build/build.sh" diff --git a/chromium/third_party/glslang/src/kokoro/android-ndk-build/presubmit.cfg b/chromium/third_party/glslang/src/kokoro/android-ndk-build/presubmit.cfg new file mode 100644 index 00000000000..16f4fb7ee90 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/android-ndk-build/presubmit.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Presubmit build configuration. +build_file: "glslang/kokoro/android-ndk-build/build.sh" diff --git a/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build-docker.sh b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build-docker.sh new file mode 100755 index 00000000000..97c2a9e6dd9 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build-docker.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # Display commands being run. + +using cmake-3.17.2 +using clang-10.0.0 +using ninja-1.10.0 + +echo "Building..." +mkdir /build && cd /build + +cmake "$ROOT_DIR" -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$(pwd)/install" +ninja install diff --git a/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build.sh b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build.sh new file mode 100755 index 00000000000..6e9d98004b8 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}:ro" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/continuous.cfg b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/continuous.cfg new file mode 100644 index 00000000000..b3bb053f7d6 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/continuous.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Continuous build configuration. +build_file: "glslang/kokoro/linux-clang-cmake/build.sh" diff --git a/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/presubmit.cfg b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/presubmit.cfg new file mode 100644 index 00000000000..6bbcfe03d24 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-clang-cmake/presubmit.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Presubmit build configuration. +build_file: "glslang/kokoro/linux-clang-cmake/build.sh" diff --git a/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build-docker.sh b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build-docker.sh new file mode 100755 index 00000000000..119c5d9da56 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build-docker.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # Display commands being run. + +using cmake-3.17.2 +using gcc-9 +using ninja-1.10.0 + +echo "Building..." +mkdir /build && cd /build + +cmake "$ROOT_DIR" -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$(pwd)/install" +ninja install diff --git a/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build.sh b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build.sh new file mode 100755 index 00000000000..6e9d98004b8 --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (C) 2020 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. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}:ro" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/continuous.cfg b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/continuous.cfg new file mode 100644 index 00000000000..716e35376da --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/continuous.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Continuous build configuration. +build_file: "glslang/kokoro/linux-gcc-cmake/build.sh" diff --git a/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/presubmit.cfg b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/presubmit.cfg new file mode 100644 index 00000000000..0670f9d224f --- /dev/null +++ b/chromium/third_party/glslang/src/kokoro/linux-gcc-cmake/presubmit.cfg @@ -0,0 +1,35 @@ +# Copyright (C) 2020 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. + +# Presubmit build configuration. +build_file: "glslang/kokoro/linux-gcc-cmake/build.sh" diff --git a/chromium/third_party/glslang/src/ndk_test/jni/Application.mk b/chromium/third_party/glslang/src/ndk_test/jni/Application.mk index d7ccd349add..4e664659319 100644 --- a/chromium/third_party/glslang/src/ndk_test/jni/Application.mk +++ b/chromium/third_party/glslang/src/ndk_test/jni/Application.mk @@ -1,5 +1,5 @@ APP_ABI := all APP_BUILD_SCRIPT := Android.mk -APP_STL := gnustl_static +APP_STL := c++_static APP_PLATFORM := android-9 NDK_TOOLCHAIN_VERSION := 4.9 |