diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-05 13:00:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-05 13:00:32 -0700 |
| commit | e3e1cf2045f14837cfecb14e252c0e1083787b93 (patch) | |
| tree | 070f9a3a27796d6edf4f905a3bfbd43a73f06338 /tests | |
| parent | 3bb780724830ae830657a47e4eba008a4c0f4ff7 (diff) | |
| parent | 00db8212b3266dfc6f3b1fba2d0f1f0c6fe5ec95 (diff) | |
Merge pull request #1371 from csyonghe/loop_attrib
Emit [loop] attribute to output HLSL.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cross-compile/loop-attribs.slang | 19 | ||||
| -rw-r--r-- | tests/cross-compile/loop-attribs.slang.hlsl | 55 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/cross-compile/loop-attribs.slang b/tests/cross-compile/loop-attribs.slang new file mode 100644 index 000000000..4336698c0 --- /dev/null +++ b/tests/cross-compile/loop-attribs.slang @@ -0,0 +1,19 @@ +// loop-attribs.slang +// Test that loop attributes are correctly emitted to the resulting HLSL. + +//TEST:CROSS_COMPILE:-target dxil-assembly -entry main -stage fragment -profile sm_6_0 + +float4 main() : SV_Target +{ + float sum = 0.0f; + + [loop] + for (int i = 0; i < 100; i++) + sum += float(i); + + [unroll(10)] + for (int j = 0; j < 100; j++) + sum += float(j); + + return float4(sum, 0, 0, 0); +}
\ No newline at end of file diff --git a/tests/cross-compile/loop-attribs.slang.hlsl b/tests/cross-compile/loop-attribs.slang.hlsl new file mode 100644 index 000000000..5d53f51e0 --- /dev/null +++ b/tests/cross-compile/loop-attribs.slang.hlsl @@ -0,0 +1,55 @@ +#pragma pack_matrix(column_major) + +#line 6 "tests/cross-compile/loop-attribs.slang" +vector<float,4> main() : SV_TARGET +{ + int i_0; + float sum_0; + int j_0; + float sum_1; + i_0 = int(0); + sum_0 = 0.00000000000000000000; + [loop] + for(;;) + { + +#line 11 + if(i_0 < int(100)) + { + } + else + { + break; + } + float _S1 = sum_0 + (float) i_0; + +#line 11 + int _S2 = i_0 + (int) int(1); + i_0 = _S2; + sum_0 = _S1; + } + j_0 = int(0); + sum_1 = sum_0; + [unroll] + for(;;) + { + +#line 15 + if(j_0 < int(100)) + { + } + else + { + break; + } + float _S3 = sum_1 + (float) j_0; + +#line 15 + int _S4 = j_0 + (int) int(1); + j_0 = _S4; + sum_1 = _S3; + } + +#line 18 + return vector<float,4>(sum_1, (float) int(0), (float) int(0), (float) int(0)); +}
\ No newline at end of file |
