diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-06-12 16:38:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 13:38:23 -0700 |
| commit | 8813c610562b1c30222ec3ef0734ef601d43b617 (patch) | |
| tree | b012aa178a52a0313ce9deab31006556a2637011 /source/slang/slang-check-decl.cpp | |
| parent | 7447fcafa71440336f553d6e0af21b12fc74d138 (diff) | |
Capability System: Implicit capability upgrade warning/error (#4241)
* capability upgrade warning/error
adjusted implementation + tests to support a warning/error if capabilities are implicitly upgraded and test accordingly.
* add glsl profile caps
* add GLSL and HLSL capabilities to the associated capability
* syntax error in capdef
* only error if user explicitly enables capabilities
1. changed testing infrastructure to not set a `profile` explicitly,
2. Added tests to be sure this works as intended with user API and with slangc command line
* Change capability atom definitions and how Slang manages them to fix errors
1. most `glsl_spirv` version atoms have been removed from `.capdef`, instead we will translate `spirv` version atoms into `glsl_spirv` since there is no point in writing the same code twice in `.capdef` files to define `spirv` versions.
2. add spirv version, and hlsl sm version (and equivlent) capability dependencies
3. removed some stage requirments which were set on objects, keep the wrapper capabilities. I am keeping the wrapper capabilities since I am unaware on if there are stage limitations (spec says code in practice does not work).
* check internal version instead of version profile (_spirv_1_5 vs. spirv_1_5)
* remove unused OpCapability. adjust SPIRV version'ing again for glsl_spirv
* apply workaround for glslang bug with rayquery usage
* ensure capabilities targetted by a profile and added together by a user are valid
* remove additions to `spirv_1_*` wrapper
* spirv_* -> glsl_spirv fix
* fix bug where incompatable profiles would cause invalid target caps
* try to avoid joining invalid capabilities
* fix the warning/error & printing
* run through tests to fix capability system and test mistakes
many mistakes were mesh shaders doing `-profile glsl_450+spirv_1_4`. This is not allowed for a few reasons
1. the test tooling does not handle arguments the same as `slangc`
2. glsl_450 core profile does not support mesh shaders, nor does spirv_1_4. sm_6_5 does work in this senario
* set some sm_4_1 intrinsics to sm_4_0
* replace `GLSL_` defs with `glsl_`
* swap the unsupported render-test syntax for working syntax
* set d3d11/d3d12 profile defaults
this is required since sm version changes compiled code & behavior
* adjusted nvapi capabilities with atomics + d3d11 set to use sm_5_0 as per default
* cleanup
* address review
* incorrect styling
* change `bitscanForward` to work as intended on 32 bit targets
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index f8f6d2dcb..74d08f8e5 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -10123,9 +10123,10 @@ namespace Slang // then the decl is using things that require conflicting set of capabilities, and we should diagnose an error. if (referencedDecl && decl) { - diagnoseCapabilityErrors( + maybeDiagnose( visitor->getSink(), visitor->getOptionSet(), + DiagnosticCategory::Capability, referenceLoc, Diagnostics::conflictingCapabilityDueToUseOfDecl, referencedDecl, @@ -10135,9 +10136,10 @@ namespace Slang } else if (decl) { - diagnoseCapabilityErrors( + maybeDiagnose( visitor->getSink(), visitor->getOptionSet(), + DiagnosticCategory::Capability, referenceLoc, Diagnostics::conflictingCapabilityDueToStatement, nodeCaps, @@ -10146,9 +10148,10 @@ namespace Slang } else { - diagnoseCapabilityErrors( + maybeDiagnose( visitor->getSink(), visitor->getOptionSet(), + DiagnosticCategory::Capability, referenceLoc, Diagnostics::conflictingCapabilityDueToStatementEnclosingFunc, nodeCaps, @@ -10251,7 +10254,7 @@ namespace Slang targetCap.join(bodyCap); if (targetCap.isInvalid()) { - diagnoseCapabilityErrors(Base::getSink(), outerContext.getOptionSet(), targetCase->body->loc, Diagnostics::conflictingCapabilityDueToStatement, bodyCap, "target_switch", oldCap); + maybeDiagnose(Base::getSink(), outerContext.getOptionSet(), DiagnosticCategory::Capability, targetCase->body->loc, Diagnostics::conflictingCapabilityDueToStatement, bodyCap, "target_switch", oldCap); } set.unionWith(targetCap); } @@ -10390,7 +10393,7 @@ namespace Slang auto stageCaps = CapabilitySet(Profile(entryPointAttr->stage).getCapabilityName()); if (declaredCaps.isIncompatibleWith(stageCaps)) { - diagnoseCapabilityErrors(getSink(), this->getOptionSet(), funcDecl->loc, Diagnostics::stageIsInCompatibleWithCapabilityDefinition, funcDecl, stageCaps, declaredCaps); + maybeDiagnose(getSink(), this->getOptionSet(), DiagnosticCategory::Capability, funcDecl->loc, Diagnostics::stageIsInCompatibleWithCapabilityDefinition, funcDecl, stageCaps, declaredCaps); } else { @@ -10604,7 +10607,7 @@ namespace Slang printedDecls.add(declToPrint); if (auto provenance = declToPrint->capabilityRequirementProvenance.tryGetValue(atomToFind)) { - diagnoseCapabilityErrors(sink, optionSet, provenance->referenceLoc, Diagnostics::seeUsingOf, provenance->referencedDecl); + maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, provenance->referenceLoc, Diagnostics::seeUsingOf, provenance->referencedDecl); declToPrint = provenance->referencedDecl; if (printedDecls.contains(declToPrint)) break; @@ -10625,7 +10628,7 @@ namespace Slang } if (declToPrint && !optionallyNeverPrintDecl) { - diagnoseCapabilityErrors(sink, optionSet, declToPrint->loc, Diagnostics::seeDefinitionOf, declToPrint); + maybeDiagnose(sink, optionSet, DiagnosticCategory::Capability, declToPrint->loc, Diagnostics::seeDefinitionOf, declToPrint); } } @@ -10654,7 +10657,7 @@ namespace Slang CapabilityAtom outFailedAtom{}; if (hasTargetAtom(failedAtomsInsideAvailableSet, outFailedAtom)) { - diagnoseCapabilityErrors(getSink(), this->getOptionSet(), decl->loc, Diagnostics::declHasDependenciesNotCompatibleOnTarget, decl, outFailedAtom); + maybeDiagnose(getSink(), this->getOptionSet(), DiagnosticCategory::Capability, decl->loc, Diagnostics::declHasDependenciesNotCompatibleOnTarget, decl, outFailedAtom); // Anything defined on a non-failed target atom may be the culprit to why we fail having a target capability. // Print out all possible culprits. @@ -10665,7 +10668,7 @@ namespace Slang for (auto atom : targetsNotUsedSet) { - CapabilityAtom formattedAtom = (CapabilityAtom)atom; + CapabilityAtom formattedAtom = asAtom(atom); diagnoseCapabilityProvenance(this->getOptionSet(), getSink(), decl, formattedAtom, true); } return; @@ -10688,8 +10691,8 @@ namespace Slang // can come from multiple referenced items in a function body. for (auto i : failedAtomsInsideAvailableSet) { - CapabilityAtom formattedAtom = (CapabilityAtom)i; - diagnoseCapabilityErrors(getSink(), this->getOptionSet(), decl->loc, diagnosticInfo, decl, formattedAtom); + CapabilityAtom formattedAtom = asAtom(i); + maybeDiagnose(getSink(), this->getOptionSet(), DiagnosticCategory::Capability, decl->loc, diagnosticInfo, decl, formattedAtom); // Print provenances. diagnoseCapabilityProvenance(this->getOptionSet(), getSink(), decl, formattedAtom); } |
