diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-02-07 13:41:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-07 13:41:43 -0800 |
| commit | 1fbc73d96fbc0a199d823dfb38fc8f02bf7ada0a (patch) | |
| tree | b4d894f1179a66219631539a95e422ba62988b04 /source/slang/ir.cpp | |
| parent | 662f43fff6721c6cd013a8f1b2639c2e29fe6be3 (diff) | |
Support __target_intrinsic modifiers in IR codegen (#401)
The standard library already has a bunch of these decorations, since they were added to support Slang->Vulkan codegen on the AST-to-AST path. This change makes the IR code generator able to exploit the modifiers so that we pick up a bunch of Vulkan support "for free" in the short term.
The basic change is in `lower-to-ir.cpp` where we copy over any `TargetIntrinsicModifier`s to become `IRTargetIntrinsicDecoration`s with the same information. We then need a bit of logic in `ir.cpp` to make sure we clone them as needed.
The core work of using the modifiers is in `emit.cpp`, where I basically just copy-pasted the existing logic that applied in the AST path (all the AST-related code there is dead, and we should clean it up soon).
The big change that comes with this logic is that when dealing with a member function, the numbering of the argument used in the intrinsic definition string changes, so that `$0` refers to the base object (whereas before the base object was looked up via the base expression of a `MemberExpr` used for the function). This requires a bunch of the definitions in the library to be updated; hopefully I caught them all.
For kicks, I've re-enabled a cross-compilation test just to confirm that we are generating valid SPIR-V for code that performs texture-fetch operations. I don't expect us to keep that test enabled as-is in the long term, though, because it would be much better to instead use render-test to do the same thing. Alas, beefing up the Vulkan support in render-test is an outstanding work item, and I didn't want to pollute this change with more work along those lines.
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index b965f908c..77aac3f5a 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3226,6 +3226,15 @@ namespace Slang } break; + case kIRDecorationOp_TargetIntrinsic: + { + auto originalDecoration = (IRTargetIntrinsicDecoration*)dd; + auto newDecoration = context->builder->addDecoration<IRTargetIntrinsicDecoration>(clonedValue); + newDecoration->targetName = originalDecoration->targetName; + newDecoration->definition = originalDecoration->definition; + } + break; + default: // Don't clone any decorations we don't understand. break; |
