summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-shader.cpp
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-08-28 15:06:23 -0400
committerGitHub <noreply@github.com>2024-08-28 12:06:23 -0700
commit65240d074b4ddec55e56962ebf8de46207bcf5fa (patch)
treefa887d3de8ab55c7498eae2d5bf61966818135a1 /source/slang/slang-check-shader.cpp
parent638e5fb000d4e242a91e8b653da4a72daec0efda (diff)
Allow capabilities to be used with `[shader("...")]` (#4928)
* Allow capabilities to be used with `[shader("...")]` Fixes: #4917 Changes: 1. Allow using capabilities instead of `Stage`s with `EntryPointAttribute`. 2. When resolving capabilities for an entrypoint+profile (per entrypoint) in `resolveStageOfProfileWithEntryPoint` add our `EntryPointAttribute` and resolved capability 3. Added tests and some capabilities related clean-up * fix a warning made by a mistake in syntax * change fineStageByName to assume it is passed a stage without a '_' * test with and without prefix '_' * cleanup some profiles and reprisentation to work better with 'Stage' and 'Profile' This use case is why we need to clean all profile-usage into `CapabilityName`s directly. * change how we compare * only change profiles * let all capabilities be resolved by 'shader' profile for now * fix warning checks I accidently broke * meshshading_internal to _meshshading --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-check-shader.cpp')
-rw-r--r--source/slang/slang-check-shader.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index 99205e522..3a1e4c7f6 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -557,7 +557,7 @@ namespace Slang
for (auto target : linkage->targets)
{
auto targetCaps = target->getTargetCaps();
- auto stageCapabilitySet = CapabilitySet(entryPoint->getProfile().getCapabilityName());
+ auto stageCapabilitySet = entryPoint->getProfile().getCapabilityName();
targetCaps.join(stageCapabilitySet);
if (targetCaps.isIncompatibleWith(entryPointFuncDecl->inferredCapabilityRequirements))
{
@@ -613,20 +613,23 @@ namespace Slang
if (auto entryPointAttr = entryPointFuncDecl->findModifier<EntryPointAttribute>())
{
auto entryPointProfileStage = entryPointProfile.getStage();
- // Ensure every target is specifying the same stage as an entry` point
+ auto entryPointStage = getStageFromAtom(entryPointAttr->capabilitySet.getTargetStage());
+
+ // Ensure every target is specifying the same stage as an entry-point
// if a profile+stage was set, else user will not be aware that their
// code is requiring `fragment` on a `vertex` shader
for (auto target : targets)
{
auto targetProfile = target->getOptionSet().getProfile();
auto profileStage = targetProfile.getStage();
- if (profileStage != Stage::Unknown && profileStage != entryPointAttr->stage)
- maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, entryPointAttr, Diagnostics::entryPointAndProfileAreIncompatible, entryPointFuncDecl, entryPointAttr->stage, targetProfile.getName());
+ if (profileStage != Stage::Unknown && profileStage != entryPointStage)
+ maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, entryPointAttr, Diagnostics::entryPointAndProfileAreIncompatible, entryPointFuncDecl, entryPointStage, targetProfile.getName());
}
if (entryPointProfileStage == Stage::Unknown)
- entryPointProfile.setStage(entryPointAttr->stage);
- else if (entryPointProfileStage != Stage::Unknown && entryPointProfileStage != entryPointAttr->stage)
- maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, entryPointFuncDecl, Diagnostics::specifiedStageDoesntMatchAttribute, entryPointFuncDecl->getName(), entryPointProfileStage, entryPointAttr->stage);
+ entryPointProfile = Profile(entryPointStage);
+ else if (entryPointProfileStage != Stage::Unknown && entryPointProfileStage != entryPointStage)
+ maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, entryPointFuncDecl, Diagnostics::specifiedStageDoesntMatchAttribute, entryPointFuncDecl->getName(), entryPointProfileStage, entryPointStage);
+ entryPointProfile.additionalCapabilities.add(entryPointAttr->capabilitySet);
return true;
}
return false;