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 /tests/bindings | |
| 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 'tests/bindings')
| -rw-r--r-- | tests/bindings/glsl-parameter-blocks.slang | 2 | ||||
| -rw-r--r-- | tests/bindings/glsl-parameter-blocks.slang.glsl | 37 |
2 files changed, 23 insertions, 16 deletions
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. diff --git a/tests/bindings/glsl-parameter-blocks.slang.glsl b/tests/bindings/glsl-parameter-blocks.slang.glsl index 9956800f1..e34101983 100644 --- a/tests/bindings/glsl-parameter-blocks.slang.glsl +++ b/tests/bindings/glsl-parameter-blocks.slang.glsl @@ -1,37 +1,44 @@ //TEST_IGNORE_FILE: #version 450 core -struct Test +struct _ST04Test { vec4 a; }; layout(binding = 0, set = 1) -uniform gTest_S1 +uniform _S1 { - Test gTest; + _ST04Test _SV05gTestL0; }; layout(binding = 1, set = 1) -uniform texture2D gTest_t; +uniform texture2D _SV05gTestL1; layout(binding = 2, set = 1) -uniform sampler gTest_s; - -vec4 main_(vec2 uv) -{ - return gTest.a + texture(sampler2D(gTest_t, gTest_s), uv); -} +uniform sampler _SV05gTestL2; layout(location = 0) -in vec2 SLANG_in_uv; +in vec2 _S3; layout(location = 0) -out vec4 SLANG_out_main_result; +out vec4 _S2; void main() { - vec2 uv = SLANG_in_uv; - vec4 main_result = main_(uv); - SLANG_out_main_result = main_result; + vec2 _S4 = _S3; + + vec2 _S5 = _S4; + + vec4 _S6 = _SV05gTestL0.a; + + vec2 _S7 = _S5; + + + vec4 _S8 = texture(sampler2D(_SV05gTestL1, _SV05gTestL2), _S7); + + vec4 _S9 = _S6 + _S8; + _S2 = _S9; + + return; } |
