summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-10-07 20:16:19 +0300
committerGitHub <noreply@github.com>2024-10-07 10:16:19 -0700
commit509409ef11e3b1abd1d7e1bfb540bc172aa1a817 (patch)
treea72725310c63b5224e76a79a4cb9b8ab9984cbc5 /source/core
parentff51c21ba217fe18bf22fec7bf822cde779b265d (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/core')
-rw-r--r--source/core/slang-render-api-util.cpp5
-rw-r--r--source/core/slang-render-api-util.h2
-rw-r--r--source/core/slang-type-convert-util.cpp1
-rw-r--r--source/core/slang-type-text-util.cpp3
4 files changed, 11 insertions, 0 deletions
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[] =