aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Clayton <bclayton@google.com>2020-10-12 14:29:33 +0100
committerGitHub <noreply@github.com>2020-10-12 09:29:33 -0400
commitdcc09a1feb3cc87929103b8777fd5a0c7384236f (patch)
tree4f34ed89adac56108c1bb77ce8b305eb856da2e2
parent42663e1137b5538a5c15dbee53c6aa8e07dd75eb (diff)
downloadamber-dcc09a1feb3cc87929103b8777fd5a0c7384236f.tar.gz
Debugger tests (#915)
-rw-r--r--DEPS4
-rwxr-xr-xkokoro/linux-clang-debug/build.sh3
-rwxr-xr-xkokoro/linux-clang-release/build.sh1
-rwxr-xr-xkokoro/linux-gcc-debug/build.sh3
-rwxr-xr-xkokoro/linux-gcc-release/build.sh5
-rwxr-xr-xkokoro/macos-clang-debug/build.sh4
-rwxr-xr-xkokoro/macos-clang-release/build.sh4
-rwxr-xr-xkokoro/scripts/linux/build-docker.sh3
-rw-r--r--src/vulkan/engine_vulkan_debugger.cc23
-rw-r--r--tests/cases/debugger_hlsl_basic_compute.amber73
-rw-r--r--tests/cases/debugger_hlsl_basic_fragment.amber104
-rw-r--r--tests/cases/debugger_hlsl_basic_vertex.amber130
-rw-r--r--tests/cases/debugger_hlsl_line_stepping.amber281
-rw-r--r--tests/cases/debugger_hlsl_shadowed_vars.amber179
-rw-r--r--tests/cases/debugger_spirv_line_stepping.amber4
-rwxr-xr-xtests/run_tests.py38
16 files changed, 556 insertions, 303 deletions
diff --git a/DEPS b/DEPS
index 22f11e0..8702bbb 100644
--- a/DEPS
+++ b/DEPS
@@ -13,7 +13,7 @@ vars = {
'clspv_revision': '86ce19c0130bd13a70862a50a9aa9676eba6548c',
'cppdap_revision': '1fd23dda91e01550be1a421de307e6fedb2035a9',
'cpplint_revision': '26470f9ccb354ff2f6d098f831271a1833701b28',
- 'dxc_revision': 'b0c029eebda9f8e212d1e447c5b1f8a969bb9db6',
+ 'dxc_revision': '56430de609119d7b7f8d743d97d78485a723f846',
'glslang_revision': '3ee5f2f1d3316e228916788b300d786bb574d337',
'googletest_revision': 'a781fe29bcf73003559a3583167fe3d647518464',
'json_revision': 'fbec662afab55019654e471b65a846a47a696722',
@@ -21,7 +21,7 @@ vars = {
'shaderc_revision': 'ba92b11e1fcaf4c38a64f84d643d6429175bf650',
'spirv_headers_revision': '3fdabd0da2932c276b25b9b4a988ba134eba1aa6',
'spirv_tools_revision': 'd91afd8de27a064f938a196fdea2ace234971faa',
- 'swiftshader_revision': 'cbb5a10e03fb655a3617988ff5d71bf37892761c',
+ 'swiftshader_revision': '51b03d58fb17b09120c886d5df36fb191d12fa8e',
'vulkan_headers_revision': '83825d55c7d522931124696ecb07ed48f2693e5c',
'vulkan_loader_revision': 'bfe4f378aee6a2825b8112429cd46529d936babf',
'vulkan_validationlayers_revision': 'c3215f8f89bde067386ff8358e0b30774691c8a5',
diff --git a/kokoro/linux-clang-debug/build.sh b/kokoro/linux-clang-debug/build.sh
index aa38676..c275425 100755
--- a/kokoro/linux-clang-debug/build.sh
+++ b/kokoro/linux-clang-debug/build.sh
@@ -18,4 +18,5 @@ set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG "clang-10.0.0" \
- -DAMBER_ENABLE_SWIFTSHADER=TRUE
+ -DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE
diff --git a/kokoro/linux-clang-release/build.sh b/kokoro/linux-clang-release/build.sh
index 79cb5fa..b537ef1 100755
--- a/kokoro/linux-clang-release/build.sh
+++ b/kokoro/linux-clang-release/build.sh
@@ -19,4 +19,5 @@ set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE "clang-10.0.0" \
-DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE \
-DAMBER_USE_DXC=TRUE
diff --git a/kokoro/linux-gcc-debug/build.sh b/kokoro/linux-gcc-debug/build.sh
index cf6f392..92463c1 100755
--- a/kokoro/linux-gcc-debug/build.sh
+++ b/kokoro/linux-gcc-debug/build.sh
@@ -18,4 +18,5 @@ set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
source $SCRIPT_DIR/../scripts/linux/build.sh DEBUG "gcc-9" \
- -DAMBER_ENABLE_SWIFTSHADER=TRUE
+ -DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE
diff --git a/kokoro/linux-gcc-release/build.sh b/kokoro/linux-gcc-release/build.sh
index 506b0c7..d428ffe 100755
--- a/kokoro/linux-gcc-release/build.sh
+++ b/kokoro/linux-gcc-release/build.sh
@@ -18,5 +18,6 @@ set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
source $SCRIPT_DIR/../scripts/linux/build.sh RELEASE "gcc-9" \
- -DAMBER_ENABLE_SWIFTSHADER=TRUE \
- -DAMBER_USE_DXC=TRUE
+ -DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE \
+ -DAMBER_USE_DXC=TRUE
diff --git a/kokoro/macos-clang-debug/build.sh b/kokoro/macos-clang-debug/build.sh
index ba45201..1fb25b8 100755
--- a/kokoro/macos-clang-debug/build.sh
+++ b/kokoro/macos-clang-debug/build.sh
@@ -17,4 +17,6 @@ set -e # fail on error
set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
-source $SCRIPT_DIR/../scripts/macos/build.sh DEBUG clang -DAMBER_ENABLE_SWIFTSHADER=TRUE
+source $SCRIPT_DIR/../scripts/macos/build.sh DEBUG clang \
+ -DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE
diff --git a/kokoro/macos-clang-release/build.sh b/kokoro/macos-clang-release/build.sh
index 90aff4e..372e9a0 100755
--- a/kokoro/macos-clang-release/build.sh
+++ b/kokoro/macos-clang-release/build.sh
@@ -17,4 +17,6 @@ set -e # fail on error
set -x # display commands
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
-source $SCRIPT_DIR/../scripts/macos/build.sh RELEASE clang -DAMBER_ENABLE_SWIFTSHADER=TRUE
+source $SCRIPT_DIR/../scripts/macos/build.sh RELEASE clang \
+ -DAMBER_ENABLE_SWIFTSHADER=TRUE \
+ -DAMBER_ENABLE_VK_DEBUGGING=TRUE
diff --git a/kokoro/scripts/linux/build-docker.sh b/kokoro/scripts/linux/build-docker.sh
index 06a6480..db89da3 100755
--- a/kokoro/scripts/linux/build-docker.sh
+++ b/kokoro/scripts/linux/build-docker.sh
@@ -78,6 +78,9 @@ if [[ "$EXTRA_CONFIG" =~ "ENABLE_SWIFTSHADER=TRUE" ]]; then
if [[ "$EXTRA_CONFIG" =~ "USE_DXC=TRUE" ]]; then
OPTS+=" --use-dxc"
fi
+ if [[ "$EXTRA_CONFIG" =~ "ENABLE_VK_DEBUGGING=TRUE" ]]; then
+ OPTS+=" --test-debugger"
+ fi
echo $(date): Starting integration tests..
export LD_LIBRARY_PATH=$ROOT_DIR/build/third_party/vulkan-loader/loader
diff --git a/src/vulkan/engine_vulkan_debugger.cc b/src/vulkan/engine_vulkan_debugger.cc
index 5309bca..9129b32 100644
--- a/src/vulkan/engine_vulkan_debugger.cc
+++ b/src/vulkan/engine_vulkan_debugger.cc
@@ -16,6 +16,8 @@
#if AMBER_ENABLE_VK_DEBUGGING
+#include <stdlib.h>
+
#include <chrono> // NOLINT(build/c++11)
#include <condition_variable> // NOLINT(build/c++11)
#include <fstream>
@@ -427,7 +429,7 @@ class Client {
private:
struct SourceCache {
- std::unordered_map<int, SourceLines> by_ref;
+ std::unordered_map<int64_t, SourceLines> by_ref;
std::unordered_map<std::string, SourceLines> by_path;
};
@@ -533,7 +535,7 @@ class Thread : public debug::Thread {
public:
Thread(VirtualFileStore* virtual_files,
std::shared_ptr<dap::Session> session,
- int threadId,
+ dap::integer threadId,
int lane,
std::shared_ptr<const debug::ThreadScript> script)
: virtual_files_(virtual_files),
@@ -816,10 +818,20 @@ class VkDebugger : public Engine::Debugger {
/// Connect establishes the connection to the shader debugger. Must be
/// called before any of the |debug::Events| methods.
Result Connect() {
+ auto port_str = getenv("VK_DEBUGGER_PORT");
+ if (!port_str) {
+ return Result("The environment variable VK_DEBUGGER_PORT was not set\n");
+ }
+ int port = atoi(port_str);
+ if (port == 0) {
+ return Result("Could not parse port number from VK_DEBUGGER_PORT ('" +
+ std::string(port_str) + "')");
+ }
+
constexpr int kMaxAttempts = 10;
// The socket might take a while to open - retry connecting.
for (int attempt = 0; attempt < kMaxAttempts; attempt++) {
- auto connection = dap::net::connect("localhost", 19020);
+ auto connection = dap::net::connect("localhost", port);
if (!connection) {
std::this_thread::sleep_for(std::chrono::seconds(1));
continue;
@@ -887,7 +899,8 @@ class VkDebugger : public Engine::Debugger {
return Result();
}
- return Result("Unable to connect to debugger");
+ return Result("Unable to connect to debugger on port " +
+ std::to_string(port));
}
// Flush checks that all breakpoints were hit, waits for all threads to
@@ -1117,7 +1130,7 @@ class VkDebugger : public Engine::Debugger {
std::shared_ptr<const debug::ThreadScript>,
InvocationKey::Hash>;
using ThreadVector = std::vector<std::unique_ptr<Thread>>;
- using ThreadMap = std::unordered_map<int, std::unique_ptr<Thread>>;
+ using ThreadMap = std::unordered_map<int64_t, std::unique_ptr<Thread>>;
VirtualFileStore* const virtual_files_;
std::shared_ptr<dap::Session> session_;
std::mutex threads_mutex_;
diff --git a/tests/cases/debugger_hlsl_basic_compute.amber b/tests/cases/debugger_hlsl_basic_compute.amber
new file mode 100644
index 0000000..386bfb6
--- /dev/null
+++ b/tests/cases/debugger_hlsl_basic_compute.amber
@@ -0,0 +1,73 @@
+#!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;
+
+[numthreads(1,1,1)]
+void main() {
+ int a = data[0];
+ int b = data[1];
+ int c = data[2];
+ int d = data[3];
+ data[0] = a + b + c + d;
+}
+END
+
+SHADER compute shader HLSL VIRTUAL_FILE "compute.hlsl"
+
+BUFFER data DATA_TYPE int32 DATA
+ 10 20 30 40
+END
+
+PIPELINE compute pipeline
+ ATTACH shader
+ SHADER_OPTIMIZATION shader
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ 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 LOCATION "compute.hlsl" 7 " int a = data[0];"
+ STEP_IN
+ EXPECT LOCATION "compute.hlsl" 8 " int b = data[1];"
+ EXPECT LOCAL "a" EQ 10
+ STEP_IN
+ EXPECT LOCATION "compute.hlsl" 9 " int c = data[2];"
+ EXPECT LOCAL "a" EQ 10
+ EXPECT LOCAL "b" EQ 20
+ STEP_IN
+ EXPECT LOCATION "compute.hlsl" 10 " int d = data[3];"
+ EXPECT LOCAL "a" EQ 10
+ EXPECT LOCAL "b" EQ 20
+ EXPECT LOCAL "c" EQ 30
+ STEP_IN
+ EXPECT LOCATION "compute.hlsl" 11 " data[0] = a + b + c + d;"
+ EXPECT LOCAL "a" EQ 10
+ EXPECT LOCAL "b" EQ 20
+ EXPECT LOCAL "c" EQ 30
+ EXPECT LOCAL "d" EQ 40
+ CONTINUE
+ END
+END
+
+EXPECT data IDX 0 EQ 100
diff --git a/tests/cases/debugger_hlsl_basic_fragment.amber b/tests/cases/debugger_hlsl_basic_fragment.amber
new file mode 100644
index 0000000..331a592
--- /dev/null
+++ b/tests/cases/debugger_hlsl_basic_fragment.amber
@@ -0,0 +1,104 @@
+#!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
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ END
+
+ ATTACH frag_shader
+ SHADER_OPTIMIZATION frag_shader
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ 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" 6 " return color;"
+ 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.amber b/tests/cases/debugger_hlsl_basic_vertex.amber
new file mode 100644
index 0000000..86d0381
--- /dev/null
+++ b/tests/cases/debugger_hlsl_basic_vertex.amber
@@ -0,0 +1,130 @@
+#!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
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ END
+
+ ATTACH frag_shader
+ SHADER_OPTIMIZATION frag_shader
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ 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" 11 " return vout;"
+ CONTINUE
+ END
+END
+
+EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 255 0 0
diff --git a/tests/cases/debugger_hlsl_line_stepping.amber b/tests/cases/debugger_hlsl_line_stepping.amber
deleted file mode 100644
index bc7b4c9..0000000
--- a/tests/cases/debugger_hlsl_line_stepping.amber
+++ /dev/null
@@ -1,281 +0,0 @@
-#!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 "vertex-shader.hlsl"
-/* 1*/ struct VS_OUTPUT {
-/* 2*/ float4 pos : SV_POSITION;
-/* 3*/ float4 color : COLOR;
-/* 4*/ };
-/* 5*/
-/* 6*/ VS_OUTPUT main(float4 pos : POSITION,
-/* 7*/ float4 color : COLOR) {
-/* 8*/ VS_OUTPUT vout;
-/* 9*/ vout.pos = pos;
-/*10*/ vout.color = color;
-/*11*/ return vout;
-/*12*/ }
-END
-
-SHADER vertex vtex_shader SPIRV-ASM
-; SPIR-V
-; Version: 1.0
-; Generator: Khronos SPIR-V Tools Assembler; 0
-; Bound: 28
-; Schema: 0
- OpCapability Shader
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %main "main" %pos %color %gl_Position %out_var_COLOR
- %src = OpString "vertex-shader.hlsl"
- OpName %out_var_COLOR "out.var.COLOR"
- OpName %main "main"
- OpName %VS_OUTPUT "VS_OUTPUT"
- OpMemberName %VS_OUTPUT 0 "pos"
- OpMemberName %VS_OUTPUT 1 "color"
- OpName %pos "pos"
- OpName %color "color"
- OpName %vout "vout"
- OpDecorate %gl_Position BuiltIn Position
- OpDecorate %pos Location 0
- OpDecorate %color Location 1
- OpDecorate %out_var_COLOR Location 0
- %int = OpTypeInt 32 1
- %int_0 = OpConstant %int 0
- %int_1 = OpConstant %int 1
- %float = OpTypeFloat 32
- %v4float = OpTypeVector %float 4
-%_ptr_Input_v4float = OpTypePointer Input %v4float
-%_ptr_Output_v4float = OpTypePointer Output %v4float
- %void = OpTypeVoid
- %16 = OpTypeFunction %void
-%_ptr_Function_v4float = OpTypePointer Function %v4float
- %VS_OUTPUT = OpTypeStruct %v4float %v4float
- %18 = OpTypeFunction %VS_OUTPUT %_ptr_Function_v4float %_ptr_Function_v4float
-%_ptr_Function_VS_OUTPUT = OpTypePointer Function %VS_OUTPUT
-
-; Compilation Unit
-%dbg_src = OpExtInst %void %DbgExt DebugSource %src
-%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
-
-; Type names
-%VS_OUTPUT_name = OpString "struct VS_OUTPUT"
-%float_name = OpString "float"
-%VS_OUTPUT_pos_name = OpString "pos"
-%VS_OUTPUT_color_name = OpString "color"
-%VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
-%main_name = OpString "main"
-%main_linkage_name = OpString "VS_OUTPUT_main_v4f_v4f"
-%pos_name = OpString "pos"
-%color_name = OpString "color"
-%vout_name = OpString "vout"
-
-; Type sizes in bit unit. For example, 128 means "128 bits"
-%int_32 = OpConstant %int 32
-%int_128 = OpConstant %int 128
-
-; Type information
-; %VS_OUTPUT_info and %VS_OUTPUT_pos_info have cycling reference
-%VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info
-%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
-%v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
-%VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %int_0 %int_128 FlagIsPublic
-%VS_OUTPUT_color_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_color_name %v4float_info %dbg_src 3 3 %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic
-%main_type = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %VS_OUTPUT_info %v4float_info %v4float_info
-
-; DebugExpression without any information
-%null_expr = OpExtInst %void %DbgExt DebugExpression
-
-; Function information
-%main_func = OpExtInst %void %DbgExt DebugFunction %main_name %main_type %dbg_src 6 1 %comp_unit %main_linkage_name FlagIsPublic 7 %src_main
-
-; Lexical scope for main
-%main_lex_scope = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 6 1 %main_func
-
-; Local variable information
-%pos_info = OpExtInst %void %DbgExt DebugLocalVariable %pos_name %v4float_info %dbg_src 6 16 %main_lex_scope FlagIsLocal 0
-%color_info = OpExtInst %void %DbgExt DebugLocalVariable %color_name %v4float_info %dbg_src 7 16 %main_lex_scope FlagIsLocal 1
-%vout_info = OpExtInst %void %DbgExt DebugLocalVariable %vout_name %VS_OUTPUT_info %dbg_src 8 3 %main_lex_scope FlagIsLocal
-
- %pos = OpVariable %_ptr_Input_v4float Input
-
-; Declaration of "float4 pos : POSITION" argument of main()
-%pos_decl = OpExtInst %void %DbgExt DebugDeclare %pos_info %pos %null_expr
-
- %color = OpVariable %_ptr_Input_v4float Input
-
-; Declaration of "float4 color : COLOR" argument of main()
-%color_decl = OpExtInst %void %DbgExt DebugDeclare %color_info %color %null_expr
-
-%gl_Position = OpVariable %_ptr_Output_v4float Output
-%out_var_COLOR = OpVariable %_ptr_Output_v4float Output
- %main = OpFunction %void None %16
- %20 = OpLabel
-
-; Start the scope of function "main()"
-%main_scope = OpExtInst %void %DbgExt DebugScope %main_lex_scope
-
- %vout = OpVariable %_ptr_Function_VS_OUTPUT Function
-
-; Declaration of "VS_OUTPUT vout" local variable in main()
-%vout_decl = OpExtInst %void %DbgExt DebugDeclare %vout_info %vout %null_expr
-
- OpLine %src 8 3
- %21 = OpLoad %v4float %pos
- %22 = OpAccessChain %_ptr_Function_v4float %vout %int_0
-
-; Tracking value of "float4 pos : SV_POSITION" member of "vout"
-%vout_pos_value = OpExtInst %void %DbgExt DebugValue %vout_info %22 %null_expr %int_0
-
- OpStore %22 %21
- OpLine %src 9 3
- %23 = OpLoad %v4float %color
- %24 = OpAccessChain %_ptr_Function_v4float %vout %int_1
-
-; Tracking value of "float4 color : COLOR" member of "vout"
-%vout_color_value = OpExtInst %void %DbgExt DebugValue %vout_info %24 %null_expr %int_1
-
- OpStore %24 %23
- OpLine %src 10 3
- %25 = OpLoad %VS_OUTPUT %vout
- %26 = OpCompositeExtract %v4float %25 0
- OpStore %gl_Position %26
- %27 = OpCompositeExtract %v4float %25 1
- OpStore %out_var_COLOR %27
- OpLine %src 11 3
- OpReturn
-
-; End the scope of function "main()"
-%main_scope_end = OpExtInst %void %DbgExt DebugNoScope
-
- OpFunctionEnd
-END
-
-SHADER fragment frag_shader SPIRV-ASM
-; SPIR-V
-; Version: 1.0
-; Generator: Khronos SPIR-V Tools Assembler; 0
-; Bound: 14
-; Schema: 0
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main" %color %out_var_SV_TARGET
- OpExecutionMode %main OriginUpperLeft
- OpDecorate %color Location 0
- OpDecorate %out_var_SV_TARGET Location 0
- %int = OpTypeInt 32 1
- %float = OpTypeFloat 32
- %v4float = OpTypeVector %float 4
-%_ptr_Input_v4float = OpTypePointer Input %v4float
-%_ptr_Output_v4float = OpTypePointer Output %v4float
- %void = OpTypeVoid
- %9 = OpTypeFunction %void
-%_ptr_Function_v4float = OpTypePointer Function %v4float
- %11 = OpTypeFunction %v4float %_ptr_Function_v4float
- %color = OpVariable %_ptr_Input_v4float Input
-%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output
- %main = OpFunction %void None %9
- %12 = OpLabel
- %13 = OpLoad %v4float %color
- OpStore %out_var_SV_TARGET %13
- OpReturn
- OpFunctionEnd
-END
-
-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
- ATTACH vtex_shader
- ATTACH frag_shader
-
- 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 2
- EXPECT CALLSTACK
- "main" "vertex-shader.hlsl" 8
- "VertexShader"
- END
- EXPECT LOCATION "vertex-shader.hlsl" 8 "/* 8*/ VS_OUTPUT vout;"
- EXPECT LOCAL "pos.x" EQ -1.007874
- 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 LOCATION "vertex-shader.hlsl" 9 "/* 9*/ vout.pos = pos;"
- STEP_IN
- EXPECT LOCAL "vout.pos.x" EQ -1.007874
- EXPECT LOCAL "vout.pos.y" EQ 1.000000
- EXPECT LOCAL "vout.pos.z" EQ 0.000000
- EXPECT LOCATION "vertex-shader.hlsl" 10 "/*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 "vertex-shader.hlsl" 11 "/*11*/ return vout;"
- CONTINUE
- END
-END
-
-EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGB 255 0 0
diff --git a/tests/cases/debugger_hlsl_shadowed_vars.amber b/tests/cases/debugger_hlsl_shadowed_vars.amber
new file mode 100644
index 0000000..458e4d1
--- /dev/null
+++ b/tests/cases/debugger_hlsl_shadowed_vars.amber
@@ -0,0 +1,179 @@
+#!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;
+};
+
+VS_OUTPUT main(float4 pos : POSITION,
+ float4 color : COLOR) {
+ float a = 1.0;
+ float b = 2.0;
+ float c = 3.0;
+ float x = a + b + c;
+ {
+ float a = 3.0;
+ float b = 4.0;
+ x += a + b + c;
+ {
+ float a = 6.0;
+ x += a + b + c;
+ }
+ x += a + b + c;
+ }
+ x += a + b + c;
+
+ VS_OUTPUT vout;
+ vout.pos = pos;
+ vout.pos.w += x * 0.000001;
+ return vout;
+}
+END
+
+VIRTUAL_FILE "fs.hlsl"
+float4 main() : SV_TARGET {
+ return float4(1.0, 1.0, 1.0, 1.0);
+}
+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
+ ATTACH vtex_shader
+ SHADER_OPTIMIZATION vtex_shader
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ END
+
+ ATTACH frag_shader
+ SHADER_OPTIMIZATION frag_shader
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
+ 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" 7 " float a = 1.0;"
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 8 " float b = 2.0;"
+ EXPECT LOCAL "a" EQ 1.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 9 " float c = 3.0;"
+ EXPECT LOCAL "a" EQ 1.000000
+ EXPECT LOCAL "b" EQ 2.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 10 " float x = a + b + c;"
+ EXPECT LOCAL "a" EQ 1.000000
+ EXPECT LOCAL "b" EQ 2.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 12 " float a = 3.0;"
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 6.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 13 " float b = 4.0;"
+ EXPECT LOCAL "a" EQ 3.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 6.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 14 " x += a + b + c;"
+ EXPECT LOCAL "a" EQ 3.000000
+ EXPECT LOCAL "b" EQ 4.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 6.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 16 " float a = 6.0;"
+ EXPECT LOCAL "b" EQ 4.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 16.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 17 " x += a + b + c;"
+ EXPECT LOCAL "a" EQ 6.000000
+ EXPECT LOCAL "b" EQ 4.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 16.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 19 " x += a + b + c;"
+ EXPECT LOCAL "a" EQ 3.000000
+ EXPECT LOCAL "b" EQ 4.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 29.000000
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 21 " x += a + b + c;"
+ EXPECT LOCAL "a" EQ 1.000000
+ EXPECT LOCAL "b" EQ 2.000000
+ EXPECT LOCAL "c" EQ 3.000000
+ EXPECT LOCAL "x" EQ 39.000000
+ STEP_IN
+ EXPECT LOCAL "x" EQ 45.000000
+ CONTINUE
+ END
+END
+
+EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGB 255 255 255
diff --git a/tests/cases/debugger_spirv_line_stepping.amber b/tests/cases/debugger_spirv_line_stepping.amber
index b672d6f..1d3e33b 100644
--- a/tests/cases/debugger_spirv_line_stepping.amber
+++ b/tests/cases/debugger_spirv_line_stepping.amber
@@ -90,7 +90,7 @@ END
DEBUG pipeline 1 1 1
THREAD GLOBAL_INVOCATION_ID 2 0 0
EXPECT CALLSTACK
- "ComputeShader" "ComputeShader0.spvasm" 20
+ "SPIR-V" "ComputeShader0.spvasm" 20
END
EXPECT LOCATION "ComputeShader0.spvasm" 20 "%5 = OpVariable %11 Uniform"
STEP_IN
@@ -113,7 +113,7 @@ DEBUG pipeline 1 1 1
EXPECT LOCATION "ComputeShader0.spvasm" 36 "OpStore %23 %22"
STEP_IN
EXPECT CALLSTACK
- "ComputeShader" "ComputeShader0.spvasm" 37
+ "SPIR-V" "ComputeShader0.spvasm" 37
END
EXPECT LOCATION "ComputeShader0.spvasm" 37 "OpReturn"
CONTINUE
diff --git a/tests/run_tests.py b/tests/run_tests.py
index a3acdda..8898491 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -48,9 +48,11 @@ SUPPRESSIONS = {
]
}
-SUPPRESSIONS_DEBUGGER = [
- # Debugger functionality is not ready for testing (yet)
- "debugger_hlsl_line_stepping.amber",
+DEBUGGER_CASES = [
+ "debugger_hlsl_basic_compute.amber",
+ "debugger_hlsl_basic_fragment.amber",
+ "debugger_hlsl_basic_vertex.amber",
+ "debugger_hlsl_shadowed_vars.amber",
"debugger_spirv_line_stepping.amber",
]
@@ -99,6 +101,10 @@ OPENCL_CASES = [
DXC_CASES = [
"draw_triangle_list_hlsl.amber",
"relative_includes_hlsl.amber",
+ "debugger_hlsl_basic_compute.amber",
+ "debugger_hlsl_basic_fragment.amber",
+ "debugger_hlsl_basic_vertex.amber",
+ "debugger_hlsl_shadowed_vars.amber",
]
SUPPRESSIONS_DAWN = [
@@ -169,13 +175,14 @@ SUPPRESSIONS_DAWN = [
class TestCase:
def __init__(self, input_path, parse_only, use_dawn, use_opencl, use_dxc,
- use_swiftshader):
+ use_swiftshader, test_debugger):
self.input_path = input_path
self.parse_only = parse_only
self.use_dawn = use_dawn
self.use_opencl = use_opencl
self.use_dxc = use_dxc
self.use_swiftshader = use_swiftshader
+ self.test_debugger = test_debugger
self.results = {}
@@ -203,7 +210,8 @@ class TestCase:
if not self.use_dxc and is_dxc_test:
return True
- if base in SUPPRESSIONS_DEBUGGER:
+ is_debugger_test = base in DEBUGGER_CASES
+ if not self.test_debugger and is_debugger_test:
return True
if system in SUPPRESSIONS.keys():
@@ -229,6 +237,17 @@ class TestRunner:
def RunTest(self, tc):
print("Testing {}".format(tc.GetInputPath()))
+ # Amber and SwiftShader both use the VK_DEBUGGER_PORT environment variable
+ # for specifying the Debug Adapter Protocol port number.
+ # This needs to be set before creating the Vulkan device.
+ # We remove this key from the enviroment if the test is not a debugger test
+ # so that full SPIR-V optimizations are preserved.
+ is_debugger_test = os.path.basename(tc.GetInputPath()) in DEBUGGER_CASES
+ if is_debugger_test:
+ os.environ["VK_DEBUGGER_PORT"] = "19020"
+ elif "VK_DEBUGGER_PORT" in os.environ:
+ del os.environ["VK_DEBUGGER_PORT"]
+
cmd = [self.options.test_prog_path, '-q']
if tc.IsParseOnly():
cmd += ['-p']
@@ -315,6 +334,9 @@ class TestRunner:
parser.add_option('--use-swiftshader',
action="store_true", default=False,
help='Tells test runner swiftshader is the device')
+ parser.add_option('--test-debugger',
+ action="store_true", default=False,
+ help='Include debugger tests')
self.options, self.args = parser.parse_args()
@@ -342,7 +364,8 @@ class TestRunner:
self.test_cases.append(TestCase(input_path, self.options.parse_only,
self.options.use_dawn, self.options.use_opencl,
- self.options.use_dxc, self.options.use_swiftshader))
+ self.options.use_dxc, self.options.use_swiftshader,
+ self.options.test_debugger))
else:
for file_dir, _, filename_list in os.walk(self.options.test_dir):
@@ -353,7 +376,8 @@ class TestRunner:
self.test_cases.append(
TestCase(input_path, self.options.parse_only,
self.options.use_dawn, self.options.use_opencl,
- self.options.use_dxc, self.options.use_swiftshader))
+ self.options.use_dxc, self.options.use_swiftshader,
+ self.options.test_debugger))
self.failures = []
self.suppressed = []