Skip to content

Commit

Permalink
Capability System: Implicit capability upgrade warning/error (#4241)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ArielG-NV and csyonghe authored Jun 12, 2024
1 parent 7447fca commit 8813c61
Show file tree
Hide file tree
Showing 45 changed files with 1,116 additions and 775 deletions.
Binary file modified docs/command-line-slangc-reference.md
Binary file not shown.
1 change: 1 addition & 0 deletions slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ extern "C"
MatrixLayoutRow, // bool
ZeroInitialize, // bool
IgnoreCapabilities, // bool
RestrictiveCapabilityCheck, // bool
ModuleName, // stringValue0: module name.
Output,
Profile, // intValue0: profile
Expand Down
6 changes: 3 additions & 3 deletions source/core/slang-uint-set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void UIntSet::subtractWith(const UIntSet& set)

/* static */void UIntSet::calcUnion(UIntSet& outRs, const UIntSet& set1, const UIntSet& set2)
{
outRs.m_buffer.setCount(Math::Max(set1.m_buffer.getCount(), set2.m_buffer.getCount()));
outRs.resizeBackingBufferDirectly(Math::Max(set1.m_buffer.getCount(), set2.m_buffer.getCount()));
outRs.clear();
for (Index i = 0; i < set1.m_buffer.getCount(); i++)
outRs.m_buffer[i] |= set1.m_buffer[i];
Expand All @@ -117,15 +117,15 @@ void UIntSet::subtractWith(const UIntSet& set)
/* static */void UIntSet::calcIntersection(UIntSet& outRs, const UIntSet& set1, const UIntSet& set2)
{
const Index minCount = Math::Min(set1.m_buffer.getCount(), set2.m_buffer.getCount());
outRs.m_buffer.setCount(minCount);
outRs.resizeBackingBufferDirectly(minCount);

for (Index i = 0; i < minCount; i++)
outRs.m_buffer[i] = set1.m_buffer[i] & set2.m_buffer[i];
}

/* static */void UIntSet::calcSubtract(UIntSet& outRs, const UIntSet& set1, const UIntSet& set2)
{
outRs.m_buffer.setCount(set1.m_buffer.getCount());
outRs.resizeBackingBufferDirectly(set1.m_buffer.getCount());

const Index minCount = Math::Min(set1.m_buffer.getCount(), set2.m_buffer.getCount());
for (Index i = 0; i < minCount; i++)
Expand Down
6 changes: 3 additions & 3 deletions source/core/slang-uint-set.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ static inline Index bitscanForward(uint64_t in)
#else
uint32_t out;
// check for 0s in 0bit->31bit. If all 0's, check for 0s in 32bit->63bit
if (_BitScanForward((unsigned long*)&out, *(((uint32_t*)&in) + 1)))
if (_BitScanForward((unsigned long*)&out, *(((uint32_t*)&in))))
return Index(out);
_BitScanForward((unsigned long*)&out, *(((uint32_t*)&in)));
return Index(out);
_BitScanForward((unsigned long*)&out, *(((uint32_t*)&in)+1));
return Index(out)+32;
#endif// #ifdef _WIN64

#else
Expand Down
Loading

0 comments on commit 8813c61

Please sign in to comment.