From 6f1371a7870a7c371a77cfdee1daa5c32f0c5377 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:03:30 -0400 Subject: 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 --- source/slang/slang-compiler.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index e61c0f220..912e42572 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -11,6 +11,7 @@ #include "../core/slang-castable.h" #include "slang-check.h" +#include "slang-check-impl.h" #include "slang-compiler.h" #include "../compiler-core/slang-lexer.h" @@ -2505,24 +2506,8 @@ namespace Slang continue; Profile profile; - - auto entryPointAttr = funcDecl->findModifier(); - if (entryPointAttr) - { - // We've discovered a valid entry point. It is a function (possibly - // generic) that has a `[shader(...)]` attribute to mark it as an - // entry point. - // - // We will now register that entry point as an `EntryPoint` - // with an appropriately chosen profile. - // - // The profile will only include a stage, so that the profile "family" - // and "version" are left unspecified. Downstream code will need - // to be able to handle this case. - // - profile.setStage(entryPointAttr->stage); - } - else + bool resolvedStageOfProfileWithEntryPoint = resolveStageOfProfileWithEntryPoint(profile, getLinkage()->m_optionSet, targets, funcDecl, sink); + if(!resolvedStageOfProfileWithEntryPoint) { // If there isn't a [shader] attribute, look for a [numthreads] attribute // since that implicitly means a compute shader. We'll not do this when compiling for -- cgit v1.2.3