From 65240d074b4ddec55e56962ebf8de46207bcf5fa Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:06:23 -0400 Subject: 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 --- source/slang/slang-compiler.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index f5b7ff428..428532658 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -361,7 +361,7 @@ namespace Slang return lookUp(UnownedTerminatedStringSlice(name)); } - List Profile::getCapabilityName() + CapabilitySet Profile::getCapabilityName() { List result; switch (getVersion()) @@ -378,7 +378,11 @@ namespace Slang default: break; } - return result; + + CapabilitySet resultSet = CapabilitySet(result); + for(auto i : this->additionalCapabilities) + resultSet.join(i); + return resultSet; } char const* Profile::getName() @@ -451,21 +455,21 @@ namespace Slang return Stage::Fragment; case CapabilityAtom::compute: return Stage::Compute; - case CapabilityAtom::mesh: + case CapabilityAtom::_mesh: return Stage::Mesh; - case CapabilityAtom::amplification: + case CapabilityAtom::_amplification: return Stage::Amplification; - case CapabilityAtom::anyhit: + case CapabilityAtom::_anyhit: return Stage::AnyHit; - case CapabilityAtom::closesthit: + case CapabilityAtom::_closesthit: return Stage::ClosestHit; - case CapabilityAtom::intersection: + case CapabilityAtom::_intersection: return Stage::Intersection; - case CapabilityAtom::raygen: + case CapabilityAtom::_raygen: return Stage::RayGeneration; - case CapabilityAtom::miss: + case CapabilityAtom::_miss: return Stage::Miss; - case CapabilityAtom::callable: + case CapabilityAtom::_callable: return Stage::Callable; default: SLANG_UNEXPECTED("unknown stage atom"); -- cgit v1.2.3