aboutsummaryrefslogtreecommitdiff
path: root/tests/cases/debugger_hlsl_function_call.amber
blob: 9504b03694620ac72bdce03e33ae6a5d8da9cae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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