From 9abcb6ea24dbc7184c3a2ad9f4458f63f8901928 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 18 Aug 2020 13:42:46 -0400 Subject: Support for float atomics on RWByteAddressBuffer (#1502) * Fix premake5.lua so it uses the new path needed for OpenCLDebugInfo100.h * Keep including the includes directory. * Added the spirv-tools-generated files. * We don't need to include the spirv/unified1 path because the files needed are actually in the spirv-tools-generated folder. * Put the build_info.h glslang generated files in external/glslang-generated. Alter premake5.lua to pick up that header. * First pass at documenting how to build glslang and spirv-tools. * Improved glsl/spir-v tools README.md * Added revision.h * Change how gResources is calculated. Update about revision.h * Update docs a little. * Split out spirv-tools into a separate project for building glslang. This was not necessary on linux, but *is* necessary on windows, because there is a file disassemble.cpp in spirv-tools and in glslang, and this leads to VS choosing only one. With the separate library, the problem is resolved. * Fix direct-spirv-emit output. * Update to latest version of spirv headers and spirv-tools. * Upgrade submodule version of glslang in external. * Add fPIC to build options of slang-spirv-tools * WIP adding support for InterlockedAddFp32 * Upgrade slang-binaries to have new glslang. * Fix issues with Windows slang-glslang binaries, via update of slang-binaries used. * WIP - atomicAdd. This solution can't work as we can't do (float*) in glsl. * WIP on atomic float ops. * Added checking for multiple decls that takes into account __target_intrinsic and __specialized_for_target. First pass impl of atomic add on float for glsl. * Split __atomicAdd so extensions are applied appropriately. * Made Dxc/Fxc support includes. Use HLSL prelude to pass the path to nvapi Added -nv-api-path * Refactor around IncludeHandler and impl of IncludeSystem * slang-include-handler -> slang-include-system Have IncludeHandler/Impl defined in slang-preprocessor * Small comment improvements. * Document atomic float add addition in target-compatibility.md. * CUDA float atomic support on RWByteAddressBuffer. * Add atomic-float-byte-address-buffer-cross.slang * Removed inappropriate-once.slang - the test is no longer valid when a file is loaded and has a unique identity by default. A test could be made, but would require an API call to create the file (so no unique id). Improved handling of loadFile - uses uniqueId if has one. * Work around for testing target overlaps - to avoid exceptions on adding targets. Simplify PathInfo setup. Modify single-target-intrinsic.slang - it no longer failed because there were no longer multiple definitions for the same target. Co-authored-by: Tim Foley --- source/slang/slang.cpp | 115 ++++++------------------------------------------- 1 file changed, 12 insertions(+), 103 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 8523a445d..aed38547d 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -329,96 +329,6 @@ DownstreamCompiler* Session::getDefaultDownstreamCompiler(SourceLanguage sourceL return getOrLoadDownstreamCompiler(m_defaultDownstreamCompilers[int(sourceLanguage)], nullptr); } -ISlangFileSystemExt* IncludeHandlerImpl::_getFileSystemExt() -{ - return linkage->getFileSystemExt(); -} - -SlangResult IncludeHandlerImpl::_findFile(SlangPathType fromPathType, const String& fromPath, const String& path, PathInfo& pathInfoOut) -{ - ISlangFileSystemExt* fileSystemExt = _getFileSystemExt(); - - // Get relative path - ComPtr combinedPathBlob; - SLANG_RETURN_ON_FAIL(fileSystemExt->calcCombinedPath(fromPathType, fromPath.begin(), path.begin(), combinedPathBlob.writeRef())); - String combinedPath(StringUtil::getString(combinedPathBlob)); - if (combinedPath.getLength() <= 0) - { - return SLANG_FAIL; - } - - SlangPathType pathType; - SLANG_RETURN_ON_FAIL(fileSystemExt->getPathType(combinedPath.begin(), &pathType)); - if (pathType != SLANG_PATH_TYPE_FILE) - { - return SLANG_E_NOT_FOUND; - } - - // Get the uniqueIdentity - ComPtr uniqueIdentityBlob; - SLANG_RETURN_ON_FAIL(fileSystemExt->getFileUniqueIdentity(combinedPath.begin(), uniqueIdentityBlob.writeRef())); - - // If the rel path exists -> a uniqueIdentity MUST exists too - String uniqueIdentity(StringUtil::getString(uniqueIdentityBlob)); - if (uniqueIdentity.getLength() <= 0) - { - // Unique identity can't be empty - return SLANG_FAIL; - } - - pathInfoOut.type = PathInfo::Type::Normal; - pathInfoOut.foundPath = combinedPath; - pathInfoOut.uniqueIdentity = uniqueIdentity; - return SLANG_OK; -} - -SlangResult IncludeHandlerImpl::findFile( - String const& pathToInclude, - String const& pathIncludedFrom, - PathInfo& pathInfoOut) -{ - pathInfoOut.type = PathInfo::Type::Unknown; - - // Try just relative to current path - { - SlangResult res = _findFile(SLANG_PATH_TYPE_FILE, pathIncludedFrom, pathToInclude, pathInfoOut); - // It either succeeded or wasn't found, anything else is a failure passed back - if (SLANG_SUCCEEDED(res) || res != SLANG_E_NOT_FOUND) - { - return res; - } - } - - // Search all the searchDirectories - for(auto sd = searchDirectories; sd; sd = sd->parent) - { - for(auto& dir : sd->searchDirectories) - { - SlangResult res = _findFile(SLANG_PATH_TYPE_DIRECTORY, dir.path, pathToInclude, pathInfoOut); - if (SLANG_SUCCEEDED(res) || res != SLANG_E_NOT_FOUND) - { - return res; - } - } - } - - return SLANG_E_NOT_FOUND; -} - -String IncludeHandlerImpl::simplifyPath(const String& path) -{ - ISlangFileSystemExt* fileSystemExt = _getFileSystemExt(); - ComPtr simplifiedPath; - if (SLANG_FAILED(fileSystemExt->getSimplifiedPath(path.getBuffer(), simplifiedPath.writeRef()))) - { - return path; - } - return StringUtil::getString(simplifiedPath); -} - -// - - Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target) { auto entryPointProfile = entryPoint->getProfile(); @@ -866,12 +776,16 @@ SlangResult Linkage::loadFile(String const& path, PathInfo& outPathInfo, ISlangB ComPtr uniqueIdentity; // Get the unique identity - SLANG_RETURN_ON_FAIL(m_fileSystemExt->getFileUniqueIdentity(path.getBuffer(), uniqueIdentity.writeRef())); - - outPathInfo.foundPath = path; - outPathInfo.type = PathInfo::Type::FoundPath; - outPathInfo.uniqueIdentity = StringUtil::getString(uniqueIdentity); - + if (SLANG_FAILED(m_fileSystemExt->getFileUniqueIdentity(path.getBuffer(), uniqueIdentity.writeRef()))) + { + // We didn't get a unique identity, so go with just a found path + outPathInfo.type = PathInfo::Type::FoundPath; + outPathInfo.foundPath = path; + } + else + { + outPathInfo = PathInfo::makeNormal(path, StringUtil::getString(uniqueIdentity)); + } return SLANG_OK; } @@ -975,8 +889,6 @@ FrontEndCompileRequest::FrontEndCompileRequest( void FrontEndCompileRequest::parseTranslationUnit( TranslationUnitRequest* translationUnit) { - IncludeHandlerImpl includeHandler; - auto linkage = getLinkage(); // TODO(JS): NOTE! Here we are using the searchDirectories on the linkage. This is because @@ -986,8 +898,7 @@ void FrontEndCompileRequest::parseTranslationUnit( // If searchDirectories.parent pointed to the one in the Linkage would mean linkage paths // would be checked too (after those on the FrontEndCompileRequest). - includeHandler.linkage = linkage; - includeHandler.searchDirectories = &linkage->searchDirectories; + IncludeHandlerImpl includeHandler(&linkage->searchDirectories, linkage->getFileSystemExt()); RefPtr languageScope; switch (translationUnit->sourceLanguage) @@ -1740,9 +1651,7 @@ RefPtr Linkage::findOrImportModule( // Next, try to find the file of the given name, // using our ordinary include-handling logic. - IncludeHandlerImpl includeHandler; - includeHandler.linkage = this; - includeHandler.searchDirectories = &searchDirectories; + IncludeHandlerImpl includeHandler(&searchDirectories, getFileSystemExt()); // Get the original path info PathInfo pathIncludedFromInfo = getSourceManager()->getPathInfo(loc, SourceLocType::Actual); -- cgit v1.2.3