summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-07-18 11:03:30 -0400
committerGitHub <noreply@github.com>2024-07-18 11:03:30 -0400
commit6f1371a7870a7c371a77cfdee1daa5c32f0c5377 (patch)
tree70fa0962fa5f34ea4646a531c3969bbf7eb8d74b /source/slang/slang-options.cpp
parent494efd7254f28ec46aff84bb1c06fe582a743c1a (diff)
Adjust how `slang` and `slangc` uses a `profile` to manage the stage of an entry-point (#4670)
* Fixes #4656 Changes: 1. Setting a profile via slangc no-longer sets an entry-point target-stage, this is to allow slangc to follow how the SLANG-API works (else `main` is assumed to be the default entry-point) 2. If the stage specified by a profile is not equal to the stage specified by a entry-point, we throw a capability error. 3. Resolving the stage of an entry point was changed to function (mostly) equally for when 0 entry-points are specified versus to when there are 1 or more. 4. changed capabilitySet Iterator so it is invalid if backing data is nullptr (although this should never happen, it would stop crashes in the worst case). * remove the breaking change since it likely is going to be a lot more than just a simple change due to the implicit `main` and stage through `profile` code. * print out profile name with errors * use target's profile for printing * change logic to print warning in a different method (account for more cases) * set unknown stages
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 4670af9df..0f5a4b417 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -696,6 +696,7 @@ struct OptionsParser
RawTarget* getCurrentTarget();
void setProfileVersion(RawTarget* rawTarget, ProfileVersion profileVersion);
+ void setProfile(RawTarget* rawTarget, Profile profile);
void addCapabilityAtom(RawTarget* rawTarget, CapabilityName atom);
void setFloatingPointMode(RawTarget* rawTarget, FloatingPointMode mode);
@@ -1056,6 +1057,20 @@ void OptionsParser::setProfileVersion(RawTarget* rawTarget, ProfileVersion profi
rawTarget->optionSet.setProfileVersion(profileVersion);
}
+void OptionsParser::setProfile(RawTarget* rawTarget, Profile profile)
+{
+ if (rawTarget->optionSet.getProfile() != Profile::Unknown)
+ {
+ rawTarget->redundantProfileSet = true;
+
+ if (profile != rawTarget->optionSet.getProfile())
+ {
+ rawTarget->conflictingProfilesSet = true;
+ }
+ }
+ rawTarget->optionSet.setProfile(profile);
+}
+
void OptionsParser::addCapabilityAtom(RawTarget* rawTarget, CapabilityName atom)
{
CapabilitySet capSet(atom);
@@ -1592,10 +1607,8 @@ SlangResult OptionsParser::_parseProfile(const CommandLineArg& arg)
{
auto profile = Profile(profileID);
- setProfileVersion(getCurrentTarget(), profile.getVersion());
+ setProfile(this->getCurrentTarget(), profile);
- // A `-profile` option that also specifies a stage (e.g., `-profile vs_5_0`)
- // should be treated like a composite (e.g., `-profile sm_5_0 -stage vertex`)
auto stage = profile.getStage();
if (stage != Stage::Unknown)
{