diff options
author | Jaebaek Seo <jaebaek@google.com> | 2020-11-16 10:16:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 10:16:38 -0500 |
commit | 404e43281bed513ab74f054bfdee57accb527ac2 (patch) | |
tree | eddd635e95582db70fc65ed9ebfa4f02f8e28e1b | |
parent | 4d6fcf03895737bea3aacffde22cd983f1c8c492 (diff) | |
download | amber-404e43281bed513ab74f054bfdee57accb527ac2.tar.gz |
Updated DXC and SPIRV-Tools DEPS and add tests for debugger (#925)
I added tests/cases/debugger_hlsl_function_call.amber from Ben's Amber
repo. This change will make Amber successfully test debugging more
shaders.
-rw-r--r-- | DEPS | 6 | ||||
-rw-r--r-- | tests/cases/debugger_hlsl_basic_compute.amber | 3 | ||||
-rw-r--r-- | tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber | 102 | ||||
-rw-r--r-- | tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber | 128 | ||||
-rw-r--r-- | tests/cases/debugger_hlsl_function_call.amber | 212 | ||||
-rw-r--r-- | tests/cases/debugger_hlsl_shadowed_vars.amber | 6 | ||||
-rwxr-xr-x | tests/run_tests.py | 8 |
7 files changed, 456 insertions, 9 deletions
@@ -13,15 +13,15 @@ vars = { 'clspv_revision': '3a11614ee40907c6f9edd99bd7d23b123111e947', 'cppdap_revision': '1fd23dda91e01550be1a421de307e6fedb2035a9', 'cpplint_revision': '26470f9ccb354ff2f6d098f831271a1833701b28', - 'dxc_revision': 'c607bb3c032d9d50a60224e29a85f0a04b78acbf', + 'dxc_revision': 'a8d9780046cb64a1cea842fa6fc28a250e3e2c09', 'glslang_revision': '740ae9f60b009196662bad811924788cee56133a', 'googletest_revision': '3005672db1d05f2378f642b61faa96f85498befe', 'json_revision': '350ff4f7ced7c4117eae2fb93df02823c8021fcb', 'lodepng_revision': '7fdcc96a5e5864eee72911c3ca79b1d9f0d12292', 'shaderc_revision': '813ef3dc0d5e10bfdf836c651099fcb2203c24ae', 'spirv_headers_revision': '7845730cab6ebbdeb621e7349b7dc1a59c3377be', - 'spirv_tools_revision': 'df4198e50eaa705298167d3c0b3cb01ffd28a5ff', - 'swiftshader_revision': 'df17a76102dfabb3f1bd6e51449cece9f77b45e3', + 'spirv_tools_revision': 'a61d07a72763c1eb200de0a2c316703643a0d1d9', + 'swiftshader_revision': 'e1012cfc791ddbc6ce11e319831da7973b9a5b32', 'vulkan_headers_revision': '320af06cbdd29848e1d7100d9b8e4e517db1dfd5', 'vulkan_loader_revision': '2b0892e15bd83886476141c1f19801d2968efadf', 'vulkan_validationlayers_revision': '87b0951f8dbaf3d0562a073bc5dd580c4468a1a1', diff --git a/tests/cases/debugger_hlsl_basic_compute.amber b/tests/cases/debugger_hlsl_basic_compute.amber index 386bfb6..84db5df 100644 --- a/tests/cases/debugger_hlsl_basic_compute.amber +++ b/tests/cases/debugger_hlsl_basic_compute.amber @@ -39,8 +39,7 @@ END PIPELINE compute pipeline ATTACH shader SHADER_OPTIMIZATION shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END BIND BUFFER data AS storage DESCRIPTOR_SET 0 BINDING 0 END diff --git a/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber b/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber new file mode 100644 index 0000000..ccbbfa5 --- /dev/null +++ b/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber @@ -0,0 +1,102 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "vs.hlsl" +struct VS_OUTPUT { + float4 pos : SV_POSITION; + float4 color : COLOR; +}; + +VS_OUTPUT main(float4 pos : POSITION) { + VS_OUTPUT vout; + vout.pos = pos; + vout.color = float4(25.1 / 255.0, 50.1 / 255.0, 100.1 / 255.0, 1.0); + return vout; +} +END + +VIRTUAL_FILE "fs.hlsl" +float4 main(float4 color : COLOR) : SV_TARGET { + int r = color.r * 255; + int g = color.g * 255; + int b = color.b * 255; + int a = color.a * 255; + return color; +} +END + +SHADER vertex vtex_shader HLSL VIRTUAL_FILE "vs.hlsl" +SHADER fragment frag_shader HLSL VIRTUAL_FILE "fs.hlsl" + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +# Full frame +-128 -128 + 127 127 +-128 127 +-128 -128 + 127 127 + 127 -128 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics pipeline + FRAMEBUFFER_SIZE 32 32 + + ATTACH vtex_shader + SHADER_OPTIMIZATION vtex_shader + --legalize-hlsl + END + + ATTACH frag_shader + SHADER_OPTIMIZATION frag_shader + --legalize-hlsl + END + + VERTEX_DATA position_buf LOCATION 0 + + BIND BUFFER framebuffer AS color LOCATION 0 +END + +CLEAR pipeline + +DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + THREAD FRAGMENT_WINDOW_SPACE_POSITION 10 10 + EXPECT LOCATION "fs.hlsl" 2 " int r = color.r * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCATION "fs.hlsl" 3 " int g = color.g * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCATION "fs.hlsl" 4 " int b = color.b * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCAL "b" EQ 100 + EXPECT LOCATION "fs.hlsl" 5 " int a = color.a * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCAL "b" EQ 100 + EXPECT LOCAL "a" EQ 255 + EXPECT LOCATION "fs.hlsl" 7 "}" + CONTINUE + END +END + +EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 25 50 100 diff --git a/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber b/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber new file mode 100644 index 0000000..628646a --- /dev/null +++ b/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber @@ -0,0 +1,128 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "vs.hlsl" +struct VS_OUTPUT { + float4 pos : SV_POSITION; + float4 color : COLOR; +}; + +VS_OUTPUT main(float4 pos : POSITION, + float4 color : COLOR) { + VS_OUTPUT vout; + vout.pos = pos; + vout.color = color; + return vout; +} +END + +VIRTUAL_FILE "fs.hlsl" +float4 main(float4 color : COLOR) : SV_TARGET { + return color; +} +END + +SHADER vertex vtex_shader HLSL VIRTUAL_FILE "vs.hlsl" +SHADER fragment frag_shader HLSL VIRTUAL_FILE "fs.hlsl" + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +# Full frame +-128 -128 + 127 127 +-128 127 +-128 -128 + 127 127 + 127 -128 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 + + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics pipeline + FRAMEBUFFER_SIZE 32 32 + + ATTACH vtex_shader + SHADER_OPTIMIZATION vtex_shader + --legalize-hlsl + END + + ATTACH frag_shader + SHADER_OPTIMIZATION frag_shader + --legalize-hlsl + END + + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 + + BIND BUFFER framebuffer AS color LOCATION 0 +END + +CLEAR pipeline + +DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + THREAD VERTEX_INDEX 0 + EXPECT LOCATION "vs.hlsl" 9 " vout.pos = pos;" + EXPECT LOCAL "pos.x" EQ -1.000000 + EXPECT LOCAL "pos.y" EQ -1.000000 + EXPECT LOCAL "pos.z" EQ 0.000000 + EXPECT LOCAL "color.x" EQ 1.000000 + EXPECT LOCAL "color.y" EQ 0.000000 + EXPECT LOCAL "color.z" EQ 0.000000 + STEP_IN + EXPECT LOCAL "vout.pos.x" EQ -1.000000 + EXPECT LOCAL "vout.pos.y" EQ -1.000000 + EXPECT LOCAL "vout.pos.z" EQ 0.000000 + EXPECT LOCATION "vs.hlsl" 10 " vout.color = color;" + STEP_IN + EXPECT LOCAL "vout.color.x" EQ 1.000000 + EXPECT LOCAL "vout.color.y" EQ 0.000000 + EXPECT LOCAL "vout.color.z" EQ 0.000000 + EXPECT LOCATION "vs.hlsl" 12 "}" + CONTINUE + END +END + +EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 255 0 0 diff --git a/tests/cases/debugger_hlsl_function_call.amber b/tests/cases/debugger_hlsl_function_call.amber new file mode 100644 index 0000000..9504b03 --- /dev/null +++ b/tests/cases/debugger_hlsl_function_call.amber @@ -0,0 +1,212 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "compute.hlsl" + +[[vk::binding(0)]] +StructuredBuffer<int> data; + +int C(int x) +{ + int y = x*x; + return y; +} + +int B(int x) +{ + int y = x + 2; + return C(y) * 2; +} + +int A(int x) +{ + int y = B(x + 1); + int z = B(y) + B(y+1); + return x + y + z; +} + +[numthreads(1,1,1)] +void main() { + data[0] = A(data[0]); +} +END + +SHADER compute shader HLSL VIRTUAL_FILE "compute.hlsl" + +BUFFER data DATA_TYPE int32 DATA + 10 +END + +PIPELINE compute pipeline + ATTACH shader + SHADER_OPTIMIZATION shader + --legalize-hlsl + END + BIND BUFFER data AS storage DESCRIPTOR_SET 0 BINDING 0 +END + +DEBUG pipeline 1 1 1 + THREAD GLOBAL_INVOCATION_ID 0 0 0 + EXPECT CALLSTACK + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 26 " data[0] = A(data[0]);" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 18 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 18 "{" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 19 " int y = B(x + 1);" + EXPECT LOCAL "x" EQ 10 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 12 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 12 "{" + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 13 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 13 " int y = x + 2;" + EXPECT LOCAL "x" EQ 11 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 14 " return C(y) * 2;" + EXPECT LOCAL "x" EQ 11 + EXPECT LOCAL "y" EQ 13 + STEP_IN + + EXPECT CALLSTACK + "C" "compute.hlsl" 6 + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 6 "{" + STEP_IN + + EXPECT CALLSTACK + "C" "compute.hlsl" 7 + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 7 " int y = x*x;" + EXPECT LOCAL "x" EQ 13 + STEP_IN + + # TODO: Returns are non-steppable. Fix + # EXPECT LOCATION "compute.hlsl" 8 " return y;" + # EXPECT LOCAL "x" EQ 11 # TODO: "x" should be visible + # EXPECT LOCAL "y" EQ 0 + # STEP_IN + # EXPECT CALLSTACK + # "B" "compute.hlsl" 14 + # "A" "compute.hlsl" 19 + # "main" "compute.hlsl" 26 + # END + + EXPECT CALLSTACK + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 14 " return C(y) * 2;" + STEP_IN + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 19 " int y = B(x + 1);" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 20 " int z = B(y) + B(y+1);" + EXPECT LOCAL "y" EQ 338 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 12 + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 12 "{" + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 13 + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 13 " int y = x + 2;" + STEP_OUT + + EXPECT CALLSTACK + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 20 " int z = B(y) + B(y+1);" + EXPECT LOCAL "y" EQ 338 + STEP_OVER + STEP_OVER + + EXPECT CALLSTACK + "A" "compute.hlsl" 21 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 21 " return x + y + z;" + EXPECT LOCAL "y" EQ 338 + EXPECT LOCAL "z" EQ 463762 + STEP_OUT + + EXPECT CALLSTACK + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 26 " data[0] = A(data[0]);" + + CONTINUE + END +END + +EXPECT data IDX 0 EQ 464110 diff --git a/tests/cases/debugger_hlsl_shadowed_vars.amber b/tests/cases/debugger_hlsl_shadowed_vars.amber index 458e4d1..bf8a790 100644 --- a/tests/cases/debugger_hlsl_shadowed_vars.amber +++ b/tests/cases/debugger_hlsl_shadowed_vars.amber @@ -99,14 +99,12 @@ BUFFER framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics pipeline ATTACH vtex_shader SHADER_OPTIMIZATION vtex_shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END ATTACH frag_shader SHADER_OPTIMIZATION frag_shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END VERTEX_DATA position_buf LOCATION 0 diff --git a/tests/run_tests.py b/tests/run_tests.py index 8898491..08bf7ee 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -54,6 +54,10 @@ DEBUGGER_CASES = [ "debugger_hlsl_basic_vertex.amber", "debugger_hlsl_shadowed_vars.amber", "debugger_spirv_line_stepping.amber", + "debugger_hlsl_basic_fragment_with_legalization.amber", + "debugger_hlsl_basic_vertex_with_legalization.amber", + "debugger_hlsl_function_call.amber", + "debugger_hlsl_shadowed_vars.amber", ] SUPPRESSIONS_SWIFTSHADER = [ @@ -105,6 +109,10 @@ DXC_CASES = [ "debugger_hlsl_basic_fragment.amber", "debugger_hlsl_basic_vertex.amber", "debugger_hlsl_shadowed_vars.amber", + "debugger_hlsl_basic_fragment_with_legalization.amber", + "debugger_hlsl_basic_vertex_with_legalization.amber", + "debugger_hlsl_function_call.amber", + "debugger_hlsl_shadowed_vars.amber", ] SUPPRESSIONS_DAWN = [ |