From 1fbc73d96fbc0a199d823dfb38fc8f02bf7ada0a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 7 Feb 2018 13:41:43 -0800 Subject: 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. --- tests/bindings/glsl-parameter-blocks.slang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/bindings/glsl-parameter-blocks.slang') diff --git a/tests/bindings/glsl-parameter-blocks.slang b/tests/bindings/glsl-parameter-blocks.slang index 64e302d90..48eacbb0f 100644 --- a/tests/bindings/glsl-parameter-blocks.slang +++ b/tests/bindings/glsl-parameter-blocks.slang @@ -1,5 +1,5 @@ #version 450 core -//TEST_DISABLED:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly +//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly // Note: disabled because the translation of `Texture2D.Sample()` // requires handling of local variables with resource types in the IR. -- cgit v1.2.3