summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2025-05-21 21:11:01 -0700
committerGitHub <noreply@github.com>2025-05-22 04:11:01 +0000
commit27c6e9b01f7386263bde90e16812be46327015c2 (patch)
treea640d6882da0c9ee90ef64872b1b94c721039cdf /source/core
parent21346ded32be9091389ca53815c1ba56feff8a01 (diff)
Initial `dyn` keyword support & `-lang 2026` compiler option (#7172)
fixes: [#7143](https://github.com/shader-slang/slang/issues/7143) fixes: [#7146](https://github.com/shader-slang/slang/issues/7146) Goal of PR: * This PR is part of the larger #7115 refactor to how dynamic dispatch works. * The first step is to add the `-std <std-revision>` flag. * The second step is to provide basic `dyn` keyword support in AST. This does not include `varDecl` support since most of these interactions require `some` keyword support. Future PR(s) goal: * Support `some` keyword in AST. With this we will also implement all varDecl interactions between `dyn` and `some`. * Add IR support for `some` and `dyn`. Breakdown of PR: * most of the logic is in `validateDyn.*`. This was done so that in the future when we implement more features we will have an easy time removing/adding restrictions to `dyn` interfaces. Breaking changes: * As per spec (https://github.com/shader-slang/spec/pull/14/files), any type conforming to a `dyn` interface errors if member list contains one of the following: opaque type, non copyable type, or unsized type. * Due to the breaking change, the test `tests\compute\dynamic-dispatch-bindless-texture.slang` is incorrect. This has been fixed.
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-type-text-util.cpp16
-rw-r--r--source/core/slang-type-text-util.h5
2 files changed, 21 insertions, 0 deletions
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index 2261ed614..4797395b7 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -99,6 +99,12 @@ static const NamesDescriptionValue s_languageInfos[] = {
{SLANG_SOURCE_LANGUAGE_CUDA, "cu,cuda", "CUDA"},
};
+static const NamesDescriptionValue s_stdRevisionInfos[] = {
+ {SLANG_STD_REVISION_UNKNOWN, "unknown", "Unknown"},
+ {SLANG_STD_REVISION_2025, "2025,default", "Slang language rules for 2025 and older"},
+ {SLANG_STD_REVISION_2026, "2026", "Slang language rules for 2026 and newer"},
+};
+
static const NamesDescriptionValue s_compilerInfos[] = {
{SLANG_PASS_THROUGH_NONE, "none", "Unknown"},
{SLANG_PASS_THROUGH_FXC, "fxc", "FXC HLSL compiler"},
@@ -217,6 +223,11 @@ static const NamesDescriptionValue s_fileSystemTypes[] = {
return makeConstArrayView(s_languageInfos);
}
+/* static */ ConstArrayView<NamesDescriptionValue> TypeTextUtil::getStdRevisionInfos()
+{
+ return makeConstArrayView(s_stdRevisionInfos);
+}
+
/* static */ ConstArrayView<NamesDescriptionValue> TypeTextUtil::getCompilerInfos()
{
return makeConstArrayView(s_compilerInfos);
@@ -317,6 +328,11 @@ static const NamesDescriptionValue s_fileSystemTypes[] = {
return NameValueUtil::findValue(getLanguageInfos(), text, SLANG_SOURCE_LANGUAGE_UNKNOWN);
}
+/* static */ SlangStdRevision TypeTextUtil::findStdRevision(const UnownedStringSlice& text)
+{
+ return NameValueUtil::findValue(getStdRevisionInfos(), text, SLANG_STD_REVISION_UNKNOWN);
+}
+
/* static */ SlangPassThrough TypeTextUtil::findPassThrough(const UnownedStringSlice& slice)
{
return NameValueUtil::findValue(getCompilerInfos(), slice, SLANG_PASS_THROUGH_NONE);
diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h
index 730888254..bc136c3ab 100644
--- a/source/core/slang-type-text-util.h
+++ b/source/core/slang-type-text-util.h
@@ -33,6 +33,8 @@ struct TypeTextUtil
/// Get the language infos
static ConstArrayView<NamesDescriptionValue> getLanguageInfos();
+ /// Get the std revision infos
+ static ConstArrayView<NamesDescriptionValue> getStdRevisionInfos();
/// Get the compiler infos
static ConstArrayView<NamesDescriptionValue> getCompilerInfos();
/// Get the archive type infos
@@ -71,6 +73,9 @@ struct TypeTextUtil
/// Given a source language name returns a source language. Name here is distinct from extension
static SlangSourceLanguage findSourceLanguage(const UnownedStringSlice& text);
+ /// Given a std revision returns a std revision.
+ static SlangStdRevision findStdRevision(const UnownedStringSlice& text);
+
/// Given a name returns the pass through
static SlangPassThrough findPassThrough(const UnownedStringSlice& slice);
static SlangResult findPassThrough(