diff options
| author | Anders Leino <aleino@nvidia.com> | 2024-10-07 20:16:19 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-07 10:16:19 -0700 |
| commit | 509409ef11e3b1abd1d7e1bfb540bc172aa1a817 (patch) | |
| tree | a72725310c63b5224e76a79a4cb9b8ab9984cbc5 /source/slang | |
| parent | ff51c21ba217fe18bf22fec7bf822cde779b265d (diff) | |
Add WGSL support for slang-test (#5174)
* Use the assembly description as target when disassembling
I believe this is a bugfix.
It seems to have worked before because up until the WGSL case, the disassembler has been
the same executable as the one producing the binary to be disassembled.
* Add Tint as a downstream compiler
This closes issue #5104.
* Add downstream compiler for Tint.
* Tint is wrapped in a shared library, 'slang-tint' available from [1].
* The header file for slang-tint.dll is added in external/slang-tint-headers.
* Add some boilerplate for WGSL targets.
* Add an entry point test for WGSL.
[1] https://github.com/shader-slang/dawn/releases/tag/slang-tint-0
* Add WGSL_SPIRV as supported target for Glslang
* Add WebGPU support to slang-test
This helps to address issue #5051.
* Disable lots of crashing compute tests for 'wgpu'
This closes issue #5051.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-artifact-output-util.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang-compiler.cpp | 15 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.h | 3 | ||||
| -rw-r--r-- | source/slang/slang-emit.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 3 | ||||
| -rw-r--r-- | source/slang/slang-type-layout.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 3 |
7 files changed, 30 insertions, 4 deletions
diff --git a/source/slang/slang-artifact-output-util.cpp b/source/slang/slang-artifact-output-util.cpp index 3cb0e6c93..dcd6eb84e 100644 --- a/source/slang/slang-artifact-output-util.cpp +++ b/source/slang/slang-artifact-output-util.cpp @@ -33,12 +33,12 @@ namespace Slang } return SLANG_FAIL; } - // Get the downstream compiler that can be used for this target + // Get the downstream disassembler that can be used for this target // TODO(JS): // This could perhaps be performed in some other manner if there was more than one way to produce // disassembly from a binary. - const CodeGenTarget target = (CodeGenTarget)ArtifactDescUtil::getCompileTargetFromDesc(desc); + const CodeGenTarget target = (CodeGenTarget)ArtifactDescUtil::getCompileTargetFromDesc(assemblyDesc); if (target == CodeGenTarget::Unknown) { return SLANG_FAIL; diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 1f962d625..5bbc92e97 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -520,6 +520,10 @@ namespace Slang { return SourceLanguage::CUDA; } + case PassThroughMode::Tint: + { + return SourceLanguage::WGSL; + } case PassThroughMode::SpirvDis: { return SourceLanguage::SPIRV; @@ -555,6 +559,7 @@ namespace Slang { return PassThroughMode::None; } + case CodeGenTarget::WGSLSPIRVAssembly: case CodeGenTarget::SPIRVAssembly: case CodeGenTarget::SPIRV: { @@ -588,7 +593,10 @@ namespace Slang { return PassThroughMode::NVRTC; } - + case CodeGenTarget::WGSLSPIRV: + { + return PassThroughMode::Tint; + } default: break; } @@ -1010,6 +1018,7 @@ namespace Slang case CodeGenTarget::DXIL: return CodeGenTarget::HLSL; case CodeGenTarget::SPIRV: return CodeGenTarget::GLSL; case CodeGenTarget::MetalLib: return CodeGenTarget::Metal; + case CodeGenTarget::WGSLSPIRV: return CodeGenTarget::WGSL; default: break; } return CodeGenTarget::Unknown; @@ -1621,6 +1630,7 @@ namespace Slang case CodeGenTarget::DXBytecodeAssembly: return CodeGenTarget::DXBytecode; case CodeGenTarget::DXILAssembly: return CodeGenTarget::DXIL; case CodeGenTarget::SPIRVAssembly: return CodeGenTarget::SPIRV; + case CodeGenTarget::WGSLSPIRVAssembly: return CodeGenTarget::WGSLSPIRV; default: return CodeGenTarget::None; } } @@ -1635,6 +1645,7 @@ namespace Slang case CodeGenTarget::DXBytecodeAssembly: case CodeGenTarget::DXILAssembly: case CodeGenTarget::MetalLibAssembly: + case CodeGenTarget::WGSLSPIRVAssembly: { // First compile to an intermediate target for the corresponding binary format. const CodeGenTarget intermediateTarget = _getIntermediateTarget(target); @@ -1669,6 +1680,7 @@ namespace Slang case CodeGenTarget::HostExecutable: case CodeGenTarget::HostHostCallable: case CodeGenTarget::HostSharedLibrary: + case CodeGenTarget::WGSLSPIRV: SLANG_RETURN_ON_FAIL(emitWithDownstreamForEntryPoints(outArtifact)); return SLANG_OK; @@ -1701,6 +1713,7 @@ namespace Slang case CodeGenTarget::ShaderSharedLibrary: case CodeGenTarget::HostExecutable: case CodeGenTarget::HostSharedLibrary: + case CodeGenTarget::WGSLSPIRVAssembly: { SLANG_RETURN_ON_FAIL(_emitEntryPoints(outArtifact)); diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 7271c2e19..39d0df86b 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -97,6 +97,8 @@ namespace Slang MetalLib = SLANG_METAL_LIB, MetalLibAssembly = SLANG_METAL_LIB_ASM, WGSL = SLANG_WGSL, + WGSLSPIRVAssembly = SLANG_WGSL_SPIRV_ASM, + WGSLSPIRV = SLANG_WGSL_SPIRV, CountOf = SLANG_TARGET_COUNT_OF, }; @@ -1357,6 +1359,7 @@ namespace Slang LLVM = SLANG_PASS_THROUGH_LLVM, ///< LLVM 'compiler' SpirvOpt = SLANG_PASS_THROUGH_SPIRV_OPT, ///< pass thorugh spirv to spirv-opt MetalC = SLANG_PASS_THROUGH_METAL, + Tint = SLANG_PASS_THROUGH_TINT, ///< pass through spirv to Tint API CountOf = SLANG_PASS_THROUGH_COUNT_OF, }; void printDiagnosticArg(StringBuilder& sb, PassThroughMode val); diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 97ee2a595..c9319a13b 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -1317,6 +1317,8 @@ Result linkAndOptimizeIR( break; case CodeGenTarget::WGSL: + case CodeGenTarget::WGSLSPIRV: + case CodeGenTarget::WGSLSPIRVAssembly: { legalizeIRForWGSL(irModule, sink); } @@ -1637,6 +1639,8 @@ SlangResult CodeGenContext::emitEntryPointsSourceFromIR(ComPtr<IArtifact>& outAr lineDirectiveMode = LineDirectiveMode::GLSL; break; + case CodeGenTarget::WGSLSPIRVAssembly: + case CodeGenTarget::WGSLSPIRV: case CodeGenTarget::WGSL: // WGSL doesn't support line directives. // See https://github.com/gpuweb/gpuweb/issues/606. diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index b9a12f971..48c593889 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -931,8 +931,9 @@ SlangSourceLanguage findSourceLanguageFromPath(const String& path, Stage& outImp { ".c", SLANG_SOURCE_LANGUAGE_C, SLANG_STAGE_NONE }, { ".cpp", SLANG_SOURCE_LANGUAGE_CPP, SLANG_STAGE_NONE }, - { ".cu", SLANG_SOURCE_LANGUAGE_CUDA, SLANG_STAGE_NONE } + { ".cu", SLANG_SOURCE_LANGUAGE_CUDA, SLANG_STAGE_NONE }, + { ".wgsl", SLANG_SOURCE_LANGUAGE_WGSL, SLANG_STAGE_NONE }, }; for (Index i = 0; i < SLANG_COUNT_OF(entries); ++i) diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index 1fb8b57ab..2fe16188c 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -1950,6 +1950,8 @@ LayoutRulesFamilyImpl* getDefaultLayoutRulesFamilyForTarget(TargetRequest* targe return &kGLSLLayoutRulesFamilyImpl; case CodeGenTarget::WGSL: + case CodeGenTarget::WGSLSPIRV: + case CodeGenTarget::WGSLSPIRVAssembly: return &kWGSLLayoutRulesFamilyImpl; case CodeGenTarget::HostHostCallable: diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index d0fe28185..5fcf20e0a 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -260,8 +260,11 @@ void Session::_initCodeGenTransitionMap() map.addTransition(CodeGenTarget::HLSL, CodeGenTarget::DXIL, PassThroughMode::Dxc); map.addTransition(CodeGenTarget::GLSL, CodeGenTarget::SPIRV, PassThroughMode::Glslang); map.addTransition(CodeGenTarget::Metal, CodeGenTarget::MetalLib, PassThroughMode::MetalC); + map.addTransition(CodeGenTarget::WGSL, CodeGenTarget::WGSLSPIRV, PassThroughMode::Tint); // To assembly map.addTransition(CodeGenTarget::SPIRV, CodeGenTarget::SPIRVAssembly, PassThroughMode::Glslang); + // We use glslang to turn SPIR-V into SPIR-V assembly. + map.addTransition(CodeGenTarget::WGSLSPIRV, CodeGenTarget::WGSLSPIRVAssembly, PassThroughMode::Glslang); map.addTransition(CodeGenTarget::DXIL, CodeGenTarget::DXILAssembly, PassThroughMode::Dxc); map.addTransition(CodeGenTarget::DXBytecode, CodeGenTarget::DXBytecodeAssembly, PassThroughMode::Fxc); map.addTransition(CodeGenTarget::MetalLib, CodeGenTarget::MetalLibAssembly, PassThroughMode::MetalC); |
