aboutsummaryrefslogtreecommitdiff
path: root/loader/phys_dev_chain_gas.asm
blob: b3d195efad1ed85b97ebab72767dce0eea350295 (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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#
# Copyright (c) 2017 The Khronos Group Inc.
# Copyright (c) 2017 Valve Corporation
# Copyright (c) 2017 LunarG, Inc.
#
# 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
#
#     http://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.
#
# Author: Lenny Komow <lenny@lunarg.com>
#

# This code is used to pass on physical device extensions through the call chain. It must do this without creating a stack frame,
# because the actual parameters of the call are not known. Since the first parameter is known to be a VkPhysicalDevice, it can
# unwrap the physical device, overwriting the wrapped device, and then jump to the next function in the call chain

.intel_syntax noprefix
.include "gen_defines.asm"

.ifdef X86_64

.set PHYS_DEV_SIZE, 8
.set PHYS_DEV_UNWRAP_OFFSET, 16
.set PTR_SIZE, 8

.macro PhysDevExtTramp num
.global vkPhysDevExtTramp\num
vkPhysDevExtTramp\num:
    mov     rax, [rdi]
    mov     rdi, [rdi + PHYS_DEV_UNWRAP_OFFSET]
    jmp     [rax + (PHYS_DEV_DISP_OFFSET + (PTR_SIZE * \num))]
.endm

.else
# NOTE: The 32-bit code has not been properly tested, so it likely won't work

.set PHYS_DEV_SIZE, 4
.set PHYS_DEV_UNWRAP_OFFSET, 8
.set PTR_SIZE, 4

.macro PhysDevExtTramp num
.global vkPhysDevExtTramp\num
vkPhysDevExtTramp\num:
    mov     eax, [esp + PHYS_DEV_SIZE]                  # Load the wrapped VkPhysicalDevice into eax
    mov     ecx, [eax + PHYS_DEV_UNWRAP_OFFSET]         # Load the unwrapped VkPhysicalDevice into ecx
    mov     [esp + PHYS_DEV_SIZE], ecx                  # Overwrite the wrapped VkPhysicalDevice with the unwrapped one (on the stack)
    mov     eax, [eax]                                  # Dereference the wrapped VkPhysicalDevice to get the dispatch table in eax
    jmp     [eax + (PHYS_DEV_DISP_OFFSET + (PTR_SIZE * \num))] # Dereference the wrapped VkPhysicalDevice to get the dispatch table in eax
.endm

.endif

.text

    PhysDevExtTramp 0
    PhysDevExtTramp 1
    PhysDevExtTramp 2
    PhysDevExtTramp 3
    PhysDevExtTramp 4
    PhysDevExtTramp 5
    PhysDevExtTramp 6
    PhysDevExtTramp 7
    PhysDevExtTramp 8
    PhysDevExtTramp 9
    PhysDevExtTramp 10
    PhysDevExtTramp 11
    PhysDevExtTramp 12
    PhysDevExtTramp 13
    PhysDevExtTramp 14
    PhysDevExtTramp 15
    PhysDevExtTramp 16
    PhysDevExtTramp 17
    PhysDevExtTramp 18
    PhysDevExtTramp 19
    PhysDevExtTramp 20
    PhysDevExtTramp 21
    PhysDevExtTramp 22
    PhysDevExtTramp 23
    PhysDevExtTramp 24
    PhysDevExtTramp 25
    PhysDevExtTramp 26
    PhysDevExtTramp 27
    PhysDevExtTramp 28
    PhysDevExtTramp 29
    PhysDevExtTramp 30
    PhysDevExtTramp 31
    PhysDevExtTramp 32
    PhysDevExtTramp 33
    PhysDevExtTramp 34
    PhysDevExtTramp 35
    PhysDevExtTramp 36
    PhysDevExtTramp 37
    PhysDevExtTramp 38
    PhysDevExtTramp 39
    PhysDevExtTramp 40
    PhysDevExtTramp 41
    PhysDevExtTramp 42
    PhysDevExtTramp 43
    PhysDevExtTramp 44
    PhysDevExtTramp 45
    PhysDevExtTramp 46
    PhysDevExtTramp 47
    PhysDevExtTramp 48
    PhysDevExtTramp 49
    PhysDevExtTramp 50
    PhysDevExtTramp 51
    PhysDevExtTramp 52
    PhysDevExtTramp 53
    PhysDevExtTramp 54
    PhysDevExtTramp 55
    PhysDevExtTramp 56
    PhysDevExtTramp 57
    PhysDevExtTramp 58
    PhysDevExtTramp 59
    PhysDevExtTramp 60
    PhysDevExtTramp 61
    PhysDevExtTramp 62
    PhysDevExtTramp 63
    PhysDevExtTramp 64
    PhysDevExtTramp 65
    PhysDevExtTramp 66
    PhysDevExtTramp 67
    PhysDevExtTramp 68
    PhysDevExtTramp 69
    PhysDevExtTramp 70
    PhysDevExtTramp 71
    PhysDevExtTramp 72
    PhysDevExtTramp 73
    PhysDevExtTramp 74
    PhysDevExtTramp 75
    PhysDevExtTramp 76
    PhysDevExtTramp 77
    PhysDevExtTramp 78
    PhysDevExtTramp 79
    PhysDevExtTramp 80
    PhysDevExtTramp 81
    PhysDevExtTramp 82
    PhysDevExtTramp 83
    PhysDevExtTramp 84
    PhysDevExtTramp 85
    PhysDevExtTramp 86
    PhysDevExtTramp 87
    PhysDevExtTramp 88
    PhysDevExtTramp 89
    PhysDevExtTramp 90
    PhysDevExtTramp 91
    PhysDevExtTramp 92
    PhysDevExtTramp 93
    PhysDevExtTramp 94
    PhysDevExtTramp 95
    PhysDevExtTramp 96
    PhysDevExtTramp 97
    PhysDevExtTramp 98
    PhysDevExtTramp 99
    PhysDevExtTramp 100
    PhysDevExtTramp 101
    PhysDevExtTramp 102
    PhysDevExtTramp 103
    PhysDevExtTramp 104
    PhysDevExtTramp 105
    PhysDevExtTramp 106
    PhysDevExtTramp 107
    PhysDevExtTramp 108
    PhysDevExtTramp 109
    PhysDevExtTramp 110
    PhysDevExtTramp 111
    PhysDevExtTramp 112
    PhysDevExtTramp 113
    PhysDevExtTramp 114
    PhysDevExtTramp 115
    PhysDevExtTramp 116
    PhysDevExtTramp 117
    PhysDevExtTramp 118
    PhysDevExtTramp 119
    PhysDevExtTramp 120
    PhysDevExtTramp 121
    PhysDevExtTramp 122
    PhysDevExtTramp 123
    PhysDevExtTramp 124
    PhysDevExtTramp 125
    PhysDevExtTramp 126
    PhysDevExtTramp 127
    PhysDevExtTramp 128
    PhysDevExtTramp 129
    PhysDevExtTramp 130
    PhysDevExtTramp 131
    PhysDevExtTramp 132
    PhysDevExtTramp 133
    PhysDevExtTramp 134
    PhysDevExtTramp 135
    PhysDevExtTramp 136
    PhysDevExtTramp 137
    PhysDevExtTramp 138
    PhysDevExtTramp 139
    PhysDevExtTramp 140
    PhysDevExtTramp 141
    PhysDevExtTramp 142
    PhysDevExtTramp 143
    PhysDevExtTramp 144
    PhysDevExtTramp 145
    PhysDevExtTramp 146
    PhysDevExtTramp 147
    PhysDevExtTramp 148
    PhysDevExtTramp 149
    PhysDevExtTramp 150
    PhysDevExtTramp 151
    PhysDevExtTramp 152
    PhysDevExtTramp 153
    PhysDevExtTramp 154
    PhysDevExtTramp 155
    PhysDevExtTramp 156
    PhysDevExtTramp 157
    PhysDevExtTramp 158
    PhysDevExtTramp 159
    PhysDevExtTramp 160
    PhysDevExtTramp 161
    PhysDevExtTramp 162
    PhysDevExtTramp 163
    PhysDevExtTramp 164
    PhysDevExtTramp 165
    PhysDevExtTramp 166
    PhysDevExtTramp 167
    PhysDevExtTramp 168
    PhysDevExtTramp 169
    PhysDevExtTramp 170
    PhysDevExtTramp 171
    PhysDevExtTramp 172
    PhysDevExtTramp 173
    PhysDevExtTramp 174
    PhysDevExtTramp 175
    PhysDevExtTramp 176
    PhysDevExtTramp 177
    PhysDevExtTramp 178
    PhysDevExtTramp 179
    PhysDevExtTramp 180
    PhysDevExtTramp 181
    PhysDevExtTramp 182
    PhysDevExtTramp 183
    PhysDevExtTramp 184
    PhysDevExtTramp 185
    PhysDevExtTramp 186
    PhysDevExtTramp 187
    PhysDevExtTramp 188
    PhysDevExtTramp 189
    PhysDevExtTramp 190
    PhysDevExtTramp 191
    PhysDevExtTramp 192
    PhysDevExtTramp 193
    PhysDevExtTramp 194
    PhysDevExtTramp 195
    PhysDevExtTramp 196
    PhysDevExtTramp 197
    PhysDevExtTramp 198
    PhysDevExtTramp 199
    PhysDevExtTramp 200
    PhysDevExtTramp 201
    PhysDevExtTramp 202
    PhysDevExtTramp 203
    PhysDevExtTramp 204
    PhysDevExtTramp 205
    PhysDevExtTramp 206
    PhysDevExtTramp 207
    PhysDevExtTramp 208
    PhysDevExtTramp 209
    PhysDevExtTramp 210
    PhysDevExtTramp 211
    PhysDevExtTramp 212
    PhysDevExtTramp 213
    PhysDevExtTramp 214
    PhysDevExtTramp 215
    PhysDevExtTramp 216
    PhysDevExtTramp 217
    PhysDevExtTramp 218
    PhysDevExtTramp 219
    PhysDevExtTramp 220
    PhysDevExtTramp 221
    PhysDevExtTramp 222
    PhysDevExtTramp 223
    PhysDevExtTramp 224
    PhysDevExtTramp 225
    PhysDevExtTramp 226
    PhysDevExtTramp 227
    PhysDevExtTramp 228
    PhysDevExtTramp 229
    PhysDevExtTramp 230
    PhysDevExtTramp 231
    PhysDevExtTramp 232
    PhysDevExtTramp 233
    PhysDevExtTramp 234
    PhysDevExtTramp 235
    PhysDevExtTramp 236
    PhysDevExtTramp 237
    PhysDevExtTramp 238
    PhysDevExtTramp 239
    PhysDevExtTramp 240
    PhysDevExtTramp 241
    PhysDevExtTramp 242
    PhysDevExtTramp 243
    PhysDevExtTramp 244
    PhysDevExtTramp 245
    PhysDevExtTramp 246
    PhysDevExtTramp 247
    PhysDevExtTramp 248
    PhysDevExtTramp 249