diff options
| author | Yong He <yonghe@outlook.com> | 2024-01-19 18:02:40 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 18:02:40 -0800 |
| commit | fdc17a974970559d8ff76d52c3ce40aaa056d441 (patch) | |
| tree | a7b2264776982707b36f901ac50acd4e047fd2bd /source/slang/slang-ir-spirv-legalize.cpp | |
| parent | 84b214389cacde9f3c94d61b3d4ca6a927cecd04 (diff) | |
Add `-fspv-reflect` support. (#3464)
* Add `-fspv-reflect` support.
Closes #3462.
* Fix.
* Fix.
* Remove use of `SPV_GOOGLE_hlsl_functionality1`.
* Fix spirv validation error.
* Fix test.
* Update typename hints.
* Update commandline options doc.
* Remove superfluous empty lines.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-spirv-legalize.cpp')
| -rw-r--r-- | source/slang/slang-ir-spirv-legalize.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/slang/slang-ir-spirv-legalize.cpp b/source/slang/slang-ir-spirv-legalize.cpp index d5b24dd31..c4b0a471a 100644 --- a/source/slang/slang-ir-spirv-legalize.cpp +++ b/source/slang/slang-ir-spirv-legalize.cpp @@ -496,6 +496,21 @@ struct SPIRVLegalizationContext : public SourceEmitterBase void processGlobalParam(IRGlobalParam* inst) { + if (inst->getDataType()) + { + // Preserve the original type name as a decoration before we do any type lowering. + // This is needed to implement -fspv-reflect, which allows the compiler to output the + // original user-friendly type name of each shader parameter as a SPIRV decoration. + // + StringBuilder sb; + getTypeNameHint(sb, inst->getDataType()); + if (sb.getLength()) + { + IRBuilder builder(inst); + builder.addDecoration(inst, kIROp_UserTypeNameDecoration, builder.getStringValue(sb.produceString().getUnownedSlice())); + } + } + // If the param is a texture, infer its format. if (auto textureType = as<IRTextureTypeBase>(unwrapArray(inst->getDataType()))) { |
