summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-01-18 16:46:00 -0800
committerGitHub <noreply@github.com>2024-01-18 16:46:00 -0800
commitc5c1a25ab6d0e509e893d737a679ac47949df2f6 (patch)
treee60d4f96ae5105ef19c6b238a4d98467ff58975d /source/slang/slang-options.cpp
parent1a13842f7ece9f3c492a7017509b75eafa903bbf (diff)
Capability def parsing & codegen + disjoint sets (#3451)
* Capability def parsing & codegen + disjoint sets This change adds a capability definition file, and a code generator to produce C++ code that defines the capability enums and necessary data structures around the capabilities. Extends the existing CapabilitySet class to support expressing disjoint sets of capabilities. This sets up for the next change that will enhance our type checking with reasoning of capability requirements. * Fix cmake. * Fix warning. * Fix. * Fix isBetterForTarget to prefer less specialized option. * Fix. * Fix premake. * Fix intrinsic. * Fix vs sln file. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 9830fb18c..7c442a9d2 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -307,7 +307,7 @@ void initCommandOptions(CommandOptions& options)
"code accordingly.");
List<UnownedStringSlice> names;
- getCapabilityAtomNames(names);
+ getCapabilityNames(names);
// We'll just add to keep the list more simple...
options.addValue("spirv_1_{ 0,1,2,3,4,5 }", "minimum supported SPIR - V version");
@@ -315,11 +315,12 @@ void initCommandOptions(CommandOptions& options)
for (auto name : names)
{
if (name.startsWith("__") ||
- name.startsWith("spirv_1_"))
+ name.startsWith("spirv_1_") ||
+ name.startsWith("_"))
{
continue;
}
- else if (name.startsWith("GL_"))
+ else if (name.startsWith("GL_") || name.startsWith("SPV_") || name.startsWith("GLSL_"))
{
// We'll assume it is an extension..
StringBuilder buf;
@@ -764,7 +765,7 @@ struct OptionsParser
int targetID = -1;
FloatingPointMode floatingPointMode = FloatingPointMode::Default;
bool forceGLSLScalarLayout = false;
- List<CapabilityAtom> capabilityAtoms;
+ List<CapabilityName> capabilityAtoms;
// State for tracking command-line errors
bool conflictingProfilesSet = false;
@@ -796,7 +797,7 @@ struct OptionsParser
RawTarget* getCurrentTarget();
void setProfileVersion(RawTarget* rawTarget, ProfileVersion profileVersion);
- void addCapabilityAtom(RawTarget* rawTarget, CapabilityAtom atom);
+ void addCapabilityAtom(RawTarget* rawTarget, CapabilityName atom);
void setFloatingPointMode(RawTarget* rawTarget, FloatingPointMode mode);
@@ -1161,7 +1162,7 @@ void OptionsParser::setProfileVersion(RawTarget* rawTarget, ProfileVersion profi
rawTarget->profileVersion = profileVersion;
}
-void OptionsParser::addCapabilityAtom(RawTarget* rawTarget, CapabilityAtom atom)
+void OptionsParser::addCapabilityAtom(RawTarget* rawTarget, CapabilityName atom)
{
rawTarget->capabilityAtoms.add(atom);
}
@@ -1755,8 +1756,8 @@ SlangResult OptionsParser::_parseProfile(const CommandLineArg& arg)
for (Index i = 1; i < sliceCount; ++i)
{
UnownedStringSlice atomName = slices[i];
- CapabilityAtom atom = findCapabilityAtom(atomName);
- if (atom == CapabilityAtom::Invalid)
+ CapabilityName atom = findCapabilityName(atomName);
+ if (atom == CapabilityName::Invalid)
{
m_sink->diagnose(operand.loc, Diagnostics::unknownProfile, atomName);
return SLANG_FAIL;
@@ -2119,8 +2120,8 @@ SlangResult OptionsParser::_parse(
for (Index i = 0; i < sliceCount; ++i)
{
UnownedStringSlice atomName = slices[i];
- CapabilityAtom atom = findCapabilityAtom(atomName);
- if (atom == CapabilityAtom::Invalid)
+ CapabilityName atom = findCapabilityName(atomName);
+ if (atom == CapabilityName::Invalid)
{
m_sink->diagnose(operand.loc, Diagnostics::unknownProfile, atomName);
return SLANG_FAIL;