diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-07-10 16:24:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 13:24:12 -0700 |
| commit | a08ccfa50a06797dab60918b788570a520c45454 (patch) | |
| tree | 79e3b90b68c72229efdc6ed51f3f8e42788843bd /source/slang/slang-parameter-binding.cpp | |
| parent | 667e50498a226103278d0997528cc76979b2c4ef (diff) | |
Fixes to Metal Input parameters and Output value input/output semantics (#4536)
* initial change to test with CI for CPU/CUDA errors
* Fixes to Metal Input parameters and Output values
Note:
1. Flattening a struct is the process of making a struct have 0 struct/class members.
Changes:
1. Separated `legalizeSystemValueParameters`. This was done to make it easier to run `legalizeSystemValue` 1 system-value at a time to simplify logic. This change is optional and can be undone if not preferred.
2. Wrap everything inside a Metal legalization context. This was done since it simplifies a lot of logic and will be required for #4375
3. Created `convertSystemValueSemanticNameToEnum` and expanded the existing System-Value Enum system. This allows (sometimes) faster comparisons and helps prepare code for porting into `slang-ir-legalize-varying-params.cpp` (#4375)
4. Added a more dynamic `legalizeSystemValue` system so more than 2 types can be targeted for legalization. This is required to legalize `output`. There is still no preference for any converted type, the first valid type will be converted to.
5. Flatten all input(`flattenInputParameters`)/output(part of `wrapReturnValueInStruct`) structs and assign semantics accordingly.
6. Semantics when legalized have no specific logic other than to: 1. avoid overlapping semantics 2. Prefer assigning explicit semantics specified by a user.
7. Fixed some issue with incorrect output semantics if not a fragment stage (when there are not any assigned semantics)
* change metallib test to the correct metal test
* comment code & cleanup -- Did not address all review
Added comments for clarity + cleaned up some odd areas which were messy
* Add comment to `fixFieldSemanticsOfFlatStruct`
I found `fixFieldSemanticsOfFlatStruct` to still be confusing at a cursory glance. Added comments to make the function be more understandable.
* white space
* Address review comments
1. Fix semantic propegation.
2. Fix how we map struct fields of the flat struct to struct. This is specifically important for if reusing the same struct twice since struct member info is not unique per struct instance used.
* Fix semantic legalization by adding TreeMap
Add TreeMap to allow proper sorted-object data iteration.
* Fix some compile issues
* try to fix gcc compile error
* compile error
* fix logic bug in treeMap iterator next-semantic setter
* fix vsproject filters
* filter file syntax error
* remove need of a context to make copies stable
* Rename treemap to the more appropriate name of "treeset", adjust code comments accordingly.
* remove custom type `TreeSet` and use `std::set`
* remove TreeMap fully
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 6a1080b0e..046c35ef9 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -480,8 +480,8 @@ static bool isDigit(char c) return (c >= '0') && (c <= '9'); } -void splitNameAndIndex( - UnownedStringSlice const& text, +bool splitNameAndIndex( + UnownedStringSlice const& text, UnownedStringSlice& outName, UnownedStringSlice& outDigits) { @@ -489,14 +489,20 @@ void splitNameAndIndex( char const* digitsEnd = text.end(); char const* nameEnd = digitsEnd; + // ExplicitIndex is when a semantic has an index at the end of its name + // "SV_TARGET1" has an ExplicitIndex + // "SV_TARGET" does not have an ExplicitIndex + bool hasExplicitIndex = false; while( nameEnd != nameBegin && isDigit(*(nameEnd - 1)) ) { + hasExplicitIndex = true; nameEnd--; } char const* digitsBegin = nameEnd; outName = UnownedStringSlice(nameBegin, nameEnd); outDigits = UnownedStringSlice(digitsBegin, digitsEnd); + return hasExplicitIndex; } LayoutResourceKind findRegisterClassFromName(UnownedStringSlice const& registerClassName) |
