From 509409ef11e3b1abd1d7e1bfb540bc172aa1a817 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Mon, 7 Oct 2024 20:16:19 +0300 Subject: 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 --- source/compiler-core/slang-artifact-desc-util.cpp | 5 + source/compiler-core/slang-artifact.h | 1 + .../slang-downstream-compiler-util.cpp | 2 + source/compiler-core/slang-glslang-compiler.cpp | 4 +- source/compiler-core/slang-tint-compiler.cpp | 164 +++++++++++++++++++++ source/compiler-core/slang-tint-compiler.h | 17 +++ source/core/slang-render-api-util.cpp | 5 + source/core/slang-render-api-util.h | 2 + source/core/slang-type-convert-util.cpp | 1 + source/core/slang-type-text-util.cpp | 3 + source/slang/slang-artifact-output-util.cpp | 4 +- source/slang/slang-compiler.cpp | 15 +- source/slang/slang-compiler.h | 3 + source/slang/slang-emit.cpp | 4 + source/slang/slang-options.cpp | 3 +- source/slang/slang-type-layout.cpp | 2 + source/slang/slang.cpp | 3 + 17 files changed, 233 insertions(+), 5 deletions(-) create mode 100644 source/compiler-core/slang-tint-compiler.cpp create mode 100644 source/compiler-core/slang-tint-compiler.h (limited to 'source') diff --git a/source/compiler-core/slang-artifact-desc-util.cpp b/source/compiler-core/slang-artifact-desc-util.cpp index 9794cc90e..ae7f84227 100644 --- a/source/compiler-core/slang-artifact-desc-util.cpp +++ b/source/compiler-core/slang-artifact-desc-util.cpp @@ -205,6 +205,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactKind, SLANG_ARTIFACT_KIND, SLANG_ARTIFACT_KIND_E x(PTX, KernelLike) \ x(CuBin, KernelLike) \ x(MetalAIR, KernelLike) \ + x(WGSL_SPIRV, KernelLike) \ x(CPULike, Base) \ x(UnknownCPU, CPULike) \ x(X86, CPULike) \ @@ -290,6 +291,8 @@ SLANG_HIERARCHICAL_ENUM(ArtifactStyle, SLANG_ARTIFACT_STYLE, SLANG_ARTIFACT_STYL case SLANG_METAL_LIB: return Desc::make(Kind::Executable, Payload::MetalAIR, Style::Kernel, 0); case SLANG_METAL_LIB_ASM: return Desc::make(Kind::Assembly, Payload::MetalAIR, Style::Kernel, 0); case SLANG_WGSL: return Desc::make(Kind::Source, Payload::WGSL, Style::Kernel, 0); + case SLANG_WGSL_SPIRV_ASM: return Desc::make(Kind::Assembly, Payload::WGSL_SPIRV, Style::Kernel, 0); + case SLANG_WGSL_SPIRV: return Desc::make(Kind::Executable, Payload::WGSL_SPIRV, Style::Kernel, 0); default: break; } @@ -346,6 +349,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactStyle, SLANG_ARTIFACT_STYLE, SLANG_ARTIFACT_STYL case Payload::DXBC: return SLANG_DXBC_ASM; case Payload::PTX: return SLANG_PTX; case Payload::MetalAIR: return SLANG_METAL_LIB_ASM; + case Payload::WGSL_SPIRV: return SLANG_WGSL_SPIRV_ASM; default: break; } } @@ -374,6 +378,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactStyle, SLANG_ARTIFACT_STYLE, SLANG_ARTIFACT_STYL case Payload::DXBC: return SLANG_DXBC; case Payload::PTX: return SLANG_PTX; case Payload::MetalAIR: return SLANG_METAL_LIB_ASM; + case Payload::WGSL_SPIRV: return SLANG_WGSL_SPIRV; default: break; } } diff --git a/source/compiler-core/slang-artifact.h b/source/compiler-core/slang-artifact.h index 6d65aafba..d3784ca0a 100644 --- a/source/compiler-core/slang-artifact.h +++ b/source/compiler-core/slang-artifact.h @@ -153,6 +153,7 @@ enum class ArtifactPayload : uint8_t PTX, ///< PTX. NOTE! PTX is a text format, but is handable to CUDA API. MetalAIR, ///< Metal AIR CuBin, ///< CUDA binary + WGSL_SPIRV, ///< SPIR-V derived via WebGPU shading language CPULike, ///< CPU code diff --git a/source/compiler-core/slang-downstream-compiler-util.cpp b/source/compiler-core/slang-downstream-compiler-util.cpp index 70063b772..bf4c7cc04 100644 --- a/source/compiler-core/slang-downstream-compiler-util.cpp +++ b/source/compiler-core/slang-downstream-compiler-util.cpp @@ -24,6 +24,7 @@ #include "slang-glslang-compiler.h" #include "slang-llvm-compiler.h" #include "slang-metal-compiler.h" +#include "slang-tint-compiler.h" namespace Slang { @@ -332,6 +333,7 @@ DownstreamCompilerMatchVersion DownstreamCompilerUtil::getCompiledVersion() outFuncs[int(SLANG_PASS_THROUGH_LLVM)] = &LLVMDownstreamCompilerUtil::locateCompilers; outFuncs[int(SLANG_PASS_THROUGH_SPIRV_DIS)] = &SpirvDisDownstreamCompilerUtil::locateCompilers; outFuncs[int(SLANG_PASS_THROUGH_METAL)] = &MetalDownstreamCompilerUtil::locateCompilers; + outFuncs[int(SLANG_PASS_THROUGH_TINT)] = &TintDownstreamCompilerUtil::locateCompilers; } static String _getParentPath(const String& path) diff --git a/source/compiler-core/slang-glslang-compiler.cpp b/source/compiler-core/slang-glslang-compiler.cpp index 9ef8e7fb4..54635873a 100644 --- a/source/compiler-core/slang-glslang-compiler.cpp +++ b/source/compiler-core/slang-glslang-compiler.cpp @@ -301,7 +301,9 @@ SlangResult GlslangDownstreamCompiler::validate(const uint32_t* contents, int co bool GlslangDownstreamCompiler::canConvert(const ArtifactDesc& from, const ArtifactDesc& to) { // Can only disassemble blobs that are SPIR-V - return ArtifactDescUtil::isDisassembly(from, to) && from.payload == ArtifactPayload::SPIRV; + return ArtifactDescUtil::isDisassembly(from, to) && ( + (from.payload == ArtifactPayload::SPIRV) || + (from.payload == ArtifactPayload::WGSL_SPIRV)); } SlangResult GlslangDownstreamCompiler::convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) diff --git a/source/compiler-core/slang-tint-compiler.cpp b/source/compiler-core/slang-tint-compiler.cpp new file mode 100644 index 000000000..6319ecf9f --- /dev/null +++ b/source/compiler-core/slang-tint-compiler.cpp @@ -0,0 +1,164 @@ +#include "slang-tint-compiler.h" + +#include "slang-artifact-associated-impl.h" + +#include "../../external/slang-tint-headers/slang-tint.h" + +namespace Slang +{ + + class TintDownstreamCompiler : public DownstreamCompilerBase + { + + public: + + // IDownstreamCompiler + virtual SLANG_NO_THROW SlangResult SLANG_MCALL compile( + const CompileOptions& options, IArtifact** outResult) SLANG_OVERRIDE; + + virtual SLANG_NO_THROW bool SLANG_MCALL canConvert( + const ArtifactDesc& from, const ArtifactDesc& to) SLANG_OVERRIDE; + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL convert( + IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) + SLANG_OVERRIDE; + + virtual SLANG_NO_THROW bool SLANG_MCALL isFileBased() SLANG_OVERRIDE + { + return false; + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getVersionString( + slang::IBlob** outVersionString) SLANG_OVERRIDE; + + SlangResult compile(IArtifact *const sourceArtifact, IArtifact** outArtifact); + + SlangResult init(ISlangSharedLibrary* library); + + protected: + + ComPtr m_sharedLibrary; + + private: + + tint_CompileFunc m_compile; + tint_FreeResultFunc m_freeResult; + }; + + SlangResult TintDownstreamCompiler::init(ISlangSharedLibrary* library) + { + tint_CompileFunc compile = + (tint_CompileFunc)library->findFuncByName("tint_compile"); + if (compile == nullptr) + { + return SLANG_FAIL; + } + + tint_FreeResultFunc freeResult = + (tint_FreeResultFunc)library->findFuncByName("tint_free_result"); + if (freeResult == nullptr) + { + return SLANG_FAIL; + } + + m_sharedLibrary = library; + m_desc = Desc(SLANG_PASS_THROUGH_TINT); + m_compile = compile; + m_freeResult = freeResult; + return SLANG_OK; + } + + SlangResult TintDownstreamCompilerUtil::locateCompilers( + const String& path, + ISlangSharedLibraryLoader* loader, + DownstreamCompilerSet* set) + { + ComPtr library; + SLANG_RETURN_ON_FAIL(DownstreamCompilerUtil::loadSharedLibrary( + path, loader, nullptr, "slang-tint", library)); + SLANG_ASSERT(library); + + ComPtr compiler = ComPtr( + new TintDownstreamCompiler()); + SLANG_RETURN_ON_FAIL(static_cast( + compiler.get())->init(library)); + + set->addCompiler(compiler); + return SLANG_OK; + } + + SlangResult TintDownstreamCompiler::compile( + const CompileOptions& options, IArtifact** outArtifact) + { + IArtifact * sourceArtifact = options.sourceArtifacts[0]; + return compile(sourceArtifact, outArtifact); + } + + SlangResult TintDownstreamCompiler::compile( + IArtifact *const sourceArtifact, IArtifact** outArtifact) + { + tint_CompileRequest req = {}; + + if (sourceArtifact == nullptr) + return SLANG_FAIL; + + ComPtr sourceBlob; + SLANG_RETURN_FALSE_ON_FAIL(sourceArtifact->loadBlob( + ArtifactKeep::Yes, sourceBlob.writeRef())); + + String wgslCode( + (char*)sourceBlob->getBufferPointer(), + (char*)sourceBlob->getBufferPointer() + sourceBlob->getBufferSize()); + req.wgslCode = wgslCode.begin(); + req.wgslCodeLength = wgslCode.getLength(); + + tint_CompileResult result = {}; + SLANG_DEFER(m_freeResult(&result)); + bool compileSucceeded = m_compile(&req, &result) == 0; + + ComPtr spirvBlob = RawBlob::create(result.buffer, result.bufferSize); + result.buffer = nullptr; + + ComPtr resultArtifact = ArtifactUtil::createArtifactForCompileTarget( + SlangCompileTarget::SLANG_WGSL_SPIRV); + auto diagnostics = ArtifactDiagnostics::create(); + diagnostics->setResult(compileSucceeded ? SLANG_OK : SLANG_FAIL); + ArtifactUtil::addAssociated(resultArtifact, diagnostics); + if (compileSucceeded) + { + resultArtifact->addRepresentationUnknown(spirvBlob); + } + else + { + diagnostics->setRaw(CharSlice(result.error)); + diagnostics->requireErrorDiagnostic(); + } + + *outArtifact = resultArtifact.detach(); + return SLANG_OK; + } + + bool TintDownstreamCompiler::canConvert( + const ArtifactDesc& from, const ArtifactDesc& to) + { + return (from.payload == ArtifactPayload::WGSL) && + (to.payload == ArtifactPayload::SPIRV); + } + + SlangResult TintDownstreamCompiler::convert( + IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) + { + if (!canConvert(from->getDesc(), to)) + return SLANG_FAIL; + return compile(from, outArtifact); + } + + SlangResult TintDownstreamCompiler::getVersionString( + slang::IBlob** /* outVersionString */) + { + // We just use Tint at whatever version is in our Dawn fork, so nobody should + // depend on the particular version at the moment. + return SLANG_FAIL; + } + +} diff --git a/source/compiler-core/slang-tint-compiler.h b/source/compiler-core/slang-tint-compiler.h new file mode 100644 index 000000000..d5e596d4d --- /dev/null +++ b/source/compiler-core/slang-tint-compiler.h @@ -0,0 +1,17 @@ +#pragma once + +#include "slang-downstream-compiler-util.h" +#include "../core/slang-platform.h" + +namespace Slang +{ + + struct TintDownstreamCompilerUtil + { + static SlangResult locateCompilers( + const String& path, + ISlangSharedLibraryLoader* loader, + DownstreamCompilerSet* set); + }; + +} diff --git a/source/core/slang-render-api-util.cpp b/source/core/slang-render-api-util.cpp index 0a303b665..797d82cd7 100644 --- a/source/core/slang-render-api-util.cpp +++ b/source/core/slang-render-api-util.cpp @@ -19,6 +19,7 @@ namespace Slang { { RenderApiType::Metal, "mtl,metal", ""}, { RenderApiType::CPU, "cpu", ""}, { RenderApiType::CUDA, "cuda", "cuda,ptx"}, + { RenderApiType::WebGPU, "wgpu,webgpu", "wgsl"}, }; static int _calcAvailableApis() @@ -265,6 +266,10 @@ static bool _canLoadSharedLibrary(const char* libName) { #if SLANG_WINDOWS_FAMILY case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1") || _canLoadSharedLibrary("vk_swiftshader"); + case RenderApiType::WebGPU: + return _canLoadSharedLibrary("webgpu_dawn") && + _canLoadSharedLibrary("dxcompiler") && + _canLoadSharedLibrary("dxil"); #elif SLANG_APPLE_FAMILY case RenderApiType::Vulkan: return true; case RenderApiType::Metal: return true; diff --git a/source/core/slang-render-api-util.h b/source/core/slang-render-api-util.h index 224fe6996..f1be930cc 100644 --- a/source/core/slang-render-api-util.h +++ b/source/core/slang-render-api-util.h @@ -17,6 +17,7 @@ enum class RenderApiType Metal, CPU, CUDA, + WebGPU, CountOf, }; @@ -31,6 +32,7 @@ struct RenderApiFlag Metal = 1 << int(RenderApiType::Metal), CPU = 1 << int(RenderApiType::CPU), CUDA = 1 << int(RenderApiType::CUDA), + WebGPU = 1 << int(RenderApiType::WebGPU), AllOf = (1 << int(RenderApiType::CountOf)) - 1 ///< All bits set }; }; diff --git a/source/core/slang-type-convert-util.cpp b/source/core/slang-type-convert-util.cpp index cb5b4d38b..12908f211 100644 --- a/source/core/slang-type-convert-util.cpp +++ b/source/core/slang-type-convert-util.cpp @@ -18,6 +18,7 @@ namespace Slang case SLANG_CPP_PYTORCH_BINDING:return SLANG_SOURCE_LANGUAGE_CPP; case SLANG_HOST_CPP_SOURCE: return SLANG_SOURCE_LANGUAGE_CPP; case SLANG_CUDA_SOURCE: return SLANG_SOURCE_LANGUAGE_CUDA; + case SLANG_WGSL: return SLANG_SOURCE_LANGUAGE_WGSL; default: break; } return SLANG_SOURCE_LANGUAGE_UNKNOWN; diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp index 9f9deb92c..f02325792 100644 --- a/source/core/slang-type-text-util.cpp +++ b/source/core/slang-type-text-util.cpp @@ -64,6 +64,8 @@ static const TypeTextUtil::CompileTargetInfo s_compileTargetInfos[] = { SLANG_METAL_LIB, "metallib", "metallib", "Metal Library Bytecode" }, { SLANG_METAL_LIB_ASM, "metallib-asm" "metallib-asm", "Metal Library Bytecode assembly" }, { SLANG_WGSL, "wgsl", "wgsl", "WebGPU shading language source" }, + { SLANG_WGSL_SPIRV_ASM, "wgsl-spirv-asm", "wgsl-spirv-asm,wgsl-spirv-assembly", "SPIR-V assembly via WebGPU shading language" }, + { SLANG_WGSL_SPIRV, "wgsl-spirv", "wgsl-spirv", "SPIR-V via WebGPU shading language" }, }; static const NamesDescriptionValue s_languageInfos[] = @@ -91,6 +93,7 @@ static const NamesDescriptionValue s_compilerInfos[] = { SLANG_PASS_THROUGH_LLVM, "llvm", "LLVM/Clang `slang-llvm`" }, { SLANG_PASS_THROUGH_SPIRV_OPT, "spirv-opt", "spirv-tools SPIRV optimizer" }, { SLANG_PASS_THROUGH_METAL, "metal", "Metal shader compiler" }, + { SLANG_PASS_THROUGH_TINT, "tint", "Tint compiler" }, }; static const NamesDescriptionValue s_archiveTypeInfos[] = 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& 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); -- cgit v1.2.3