substrate-lang 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/compiler/{checker.4dd4556dd421@0+0.wasm → checker.1d67e1d4e91a@0+0.wasm} +0 -0
- package/build/compiler/{expander.967ce443d379@0+0.wasm → expander.34110a31a949@0+0.wasm} +0 -0
- package/build/compiler/{main.4fc52f204d54@0+0.wasm → main.ca9b5089c24d@0+0.wasm} +0 -0
- package/build/compiler/program +4 -4
- package/build/compiler/{roots.cefd10e93684@0+0.wasm → roots.2f1ad1a79459@0+0.wasm} +0 -0
- package/build/sub/{build.459c5b9412bd@0+0.wasm → build.eef7dfa467ec@0+0.wasm} +0 -0
- package/build/sub/{common.1edc613607a0@0+0.wasm → common.7617940db2dc@0+0.wasm} +0 -0
- package/build/sub/deflate.23f7c4679260@0+0.wasm +0 -0
- package/build/sub/{doc.0775df5de6fe@0+0.wasm → doc.92d6d82d99c1@0+0.wasm} +0 -0
- package/build/sub/{doc.ef9965d5d402@0+0.wasm → doc.dab689b811ca@0+0.wasm} +0 -0
- package/build/sub/{fetch.96b2d10f025e@0+0.wasm → fetch.3367ff4f88c0@0+0.wasm} +0 -0
- package/build/sub/{files.ad0469fdf6fa@0+0.wasm → files.5ae9d3cebeca@0+0.wasm} +0 -0
- package/build/sub/gzip.16e372eda1cf@0+0.wasm +0 -0
- package/build/sub/{hash.660682e4f491@0+0.wasm → hash.c57c141b4862@0+0.wasm} +0 -0
- package/build/sub/{html.a23126eb949a@0+0.wasm → html.803f73c35c4a@0+0.wasm} +0 -0
- package/build/sub/{manifest.ef317480deb0@0+0.wasm → manifest.da52a88c7af7@0+0.wasm} +0 -0
- package/build/sub/{map.f455cca6a42a@0+0.wasm → map.5c8084999550@0+0.wasm} +0 -0
- package/build/sub/program +22 -22
- package/build/sub/{root.f10a4906f460@0+0.wasm → root.78253db36643@0+0.wasm} +0 -0
- package/build/sub/{roots.cefd10e93684@0+0.wasm → roots.2f1ad1a79459@0+0.wasm} +0 -0
- package/build/sub/sha256.a6c32b04d799@0+0.wasm +0 -0
- package/build/sub/site.47fd989be8fb@0+0.wasm +0 -0
- package/build/sub/site.c908b1f6db12@0+0.wasm +0 -0
- package/build/sub/{store.a24d7a25daa6@0+0.wasm → store.048c77bb124d@0+0.wasm} +0 -0
- package/build/sub/sub.a618f89f2ec8@0+0.wasm +0 -0
- package/build/sub/{test.9bd59c73f65e@0+0.wasm → test.b529bf52ba3e@0+0.wasm} +0 -0
- package/build/sub/{text.1bc90482bd43@0+0.wasm → text.b214933a4984@0+0.wasm} +0 -0
- package/build/sub/{upgrade.39ee449b00d5@0+0.wasm → upgrade.7ec5651ed2e9@0+0.wasm} +0 -0
- package/package.json +1 -1
- package/std/http/server.sub +7 -7
- package/std/http/static.sub +66 -30
- package/std/package/manifest.sub +9 -4
- package/std/package/site.sub +209 -15
- package/std/package.sub +4 -3
- package/std/test/browser.sub +20 -14
- package/std/test/build.sub +8 -6
- package/std/test/page/agent.mjs +8 -2
- package/std/web/canvas.sub +4 -4
- package/std/web/dom.sub +45 -11
- package/std/web/gpu-commands.sub +439 -0
- package/std/web/gpu.sub +17 -424
- package/std/web/patches.sub +53 -18
- package/substrate/VERSION +1 -1
- package/substrate/compiler/expander.sub +2 -3
- package/substrate/compiler/roots.sub +12 -5
- package/substrate/host/grants.mjs +3 -3
- package/substrate/host/node/net.mjs +17 -2
- package/substrate/host/node/worker.mjs +3 -1
- package/substrate/host/subhost.mjs +4 -1
- package/substrate/host/web/audio.mjs +18 -10
- package/substrate/host/web/audio.sub +9 -3
- package/substrate/host/web/dom.mjs +167 -66
- package/substrate/host/web/dom.sub +9 -27
- package/substrate/host/web/fs.mjs +3 -3
- package/substrate/host/web/gpu.mjs +65 -27
- package/substrate/host/web/gpu.sub +18 -4
- package/substrate/host/web/location.mjs +15 -1
- package/substrate/host/web/location.sub +11 -3
- package/substrate/host/web/start.mjs +11 -7
- package/substrate/host/web/subhost-web.mjs +54 -33
- package/substrate/host/web/worker-script.mjs +4 -4
- package/substrate/host/web/worker.mjs +4 -4
- package/substrate/host/worker.mjs +1 -1
- package/build/sub/site.1732b58ec0e8@0+0.wasm +0 -0
- package/build/sub/site.ae3913b0b0f4@0+0.wasm +0 -0
- package/build/sub/sub.2e3092140706@0+0.wasm +0 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
;; The commands of the host module "gpu", written into one buffer. gpu.sub sends them.
|
|
2
|
+
(provide gpu-surface! gpu-shader! gpu-render-pipeline! gpu-layout-item! gpu-target! gpu-vertex-buffer-layout! gpu-attribute!
|
|
3
|
+
gpu-compute-pipeline! gpu-buffer! gpu-texture! gpu-texture-file! gpu-sampler! gpu-layout! gpu-layout-entry!
|
|
4
|
+
gpu-bind-group! gpu-bind-buffer! gpu-bind-sampler! gpu-bind-texture! gpu-destroy!
|
|
5
|
+
gpu-write-buffer! gpu-write-texture! gpu-read-texture! gpu-read-buffer!
|
|
6
|
+
gpu-render-pass! gpu-pass-target! gpu-compute-pass! gpu-end-pass! gpu-pipeline! gpu-bind-group-set! gpu-offset!
|
|
7
|
+
gpu-vertex-buffer! gpu-index-buffer! gpu-draw! gpu-draw-indexed! gpu-dispatch! gpu-viewport! gpu-scissor!
|
|
8
|
+
gpu-commands gpu-commands-done! gpu-frame-alloc gpu-frame-copy
|
|
9
|
+
gpu-format-surface gpu-rgba8 gpu-bgra8 gpu-r8 gpu-rg8 gpu-rgba16f gpu-r32f gpu-rgba32f gpu-depth24 gpu-depth32f
|
|
10
|
+
gpu-f32 gpu-f32x2 gpu-f32x3 gpu-f32x4 gpu-u32 gpu-u32x2 gpu-u32x4 gpu-i32 gpu-unorm8x4 gpu-snorm8x4
|
|
11
|
+
gpu-f16x2 gpu-f16x4 gpu-u8x4 gpu-unorm16x2 gpu-unorm16x4
|
|
12
|
+
gpu-triangles gpu-triangle-strip gpu-lines gpu-line-strip gpu-points
|
|
13
|
+
gpu-cull-none gpu-cull-back gpu-cull-front gpu-ccw gpu-cw
|
|
14
|
+
gpu-blend-none gpu-blend-alpha gpu-blend-premultiplied gpu-blend-add
|
|
15
|
+
gpu-compare-none gpu-less gpu-less-equal gpu-greater gpu-greater-equal gpu-equal gpu-always gpu-never
|
|
16
|
+
gpu-vertex gpu-index gpu-uniform gpu-storage gpu-indirect gpu-sampled gpu-target gpu-storage-texture
|
|
17
|
+
gpu-nearest gpu-linear gpu-clamp gpu-repeat gpu-mirror
|
|
18
|
+
gpu-uniform-entry gpu-storage-entry gpu-read-only-entry gpu-dynamic-uniform-entry gpu-dynamic-storage-entry
|
|
19
|
+
gpu-dynamic-read-only-entry gpu-sampler-entry gpu-comparison-entry gpu-texture-entry gpu-depth-entry
|
|
20
|
+
gpu-storage-texture-entry gpu-texture-array-entry gpu-depth-array-entry gpu-in-vertex gpu-in-fragment gpu-in-compute
|
|
21
|
+
gpu-per-vertex gpu-per-instance gpu-on-surface gpu-on-texture gpu-keep gpu-clear gpu-u16-indexes gpu-u32-indexes
|
|
22
|
+
gpu-kind-surface gpu-kind-shader gpu-kind-pipeline gpu-kind-buffer gpu-kind-texture gpu-kind-sampler
|
|
23
|
+
gpu-kind-layout gpu-kind-bind-group)
|
|
24
|
+
|
|
25
|
+
;; ---- the codes ----
|
|
26
|
+
|
|
27
|
+
;; Each code is the number host/web/gpu.mjs gives it.
|
|
28
|
+
(const gpu-format-surface u32 0)
|
|
29
|
+
(const gpu-rgba8 u32 1)
|
|
30
|
+
(const gpu-bgra8 u32 2)
|
|
31
|
+
(const gpu-r8 u32 3)
|
|
32
|
+
(const gpu-rg8 u32 4)
|
|
33
|
+
(const gpu-rgba16f u32 5)
|
|
34
|
+
(const gpu-r32f u32 6)
|
|
35
|
+
(const gpu-rgba32f u32 7)
|
|
36
|
+
(const gpu-depth24 u32 8)
|
|
37
|
+
(const gpu-depth32f u32 9)
|
|
38
|
+
|
|
39
|
+
(const gpu-f32 u32 1)
|
|
40
|
+
(const gpu-f32x2 u32 2)
|
|
41
|
+
(const gpu-f32x3 u32 3)
|
|
42
|
+
(const gpu-f32x4 u32 4)
|
|
43
|
+
(const gpu-u32 u32 5)
|
|
44
|
+
(const gpu-u32x2 u32 6)
|
|
45
|
+
(const gpu-u32x4 u32 7)
|
|
46
|
+
(const gpu-i32 u32 8)
|
|
47
|
+
(const gpu-unorm8x4 u32 9)
|
|
48
|
+
(const gpu-snorm8x4 u32 10)
|
|
49
|
+
(const gpu-f16x2 u32 11)
|
|
50
|
+
(const gpu-f16x4 u32 12)
|
|
51
|
+
(const gpu-u8x4 u32 13)
|
|
52
|
+
(const gpu-unorm16x2 u32 14)
|
|
53
|
+
(const gpu-unorm16x4 u32 15)
|
|
54
|
+
|
|
55
|
+
(const gpu-triangles u32 1)
|
|
56
|
+
(const gpu-triangle-strip u32 2)
|
|
57
|
+
(const gpu-lines u32 3)
|
|
58
|
+
(const gpu-line-strip u32 4)
|
|
59
|
+
(const gpu-points u32 5)
|
|
60
|
+
|
|
61
|
+
(const gpu-cull-none u32 0)
|
|
62
|
+
(const gpu-cull-back u32 1)
|
|
63
|
+
(const gpu-cull-front u32 2)
|
|
64
|
+
(const gpu-ccw u32 0)
|
|
65
|
+
(const gpu-cw u32 1)
|
|
66
|
+
|
|
67
|
+
(const gpu-blend-none u32 0)
|
|
68
|
+
(const gpu-blend-alpha u32 1)
|
|
69
|
+
(const gpu-blend-premultiplied u32 2)
|
|
70
|
+
(const gpu-blend-add u32 3)
|
|
71
|
+
|
|
72
|
+
(const gpu-compare-none u32 0)
|
|
73
|
+
(const gpu-less u32 1)
|
|
74
|
+
(const gpu-less-equal u32 2)
|
|
75
|
+
(const gpu-greater u32 3)
|
|
76
|
+
(const gpu-greater-equal u32 4)
|
|
77
|
+
(const gpu-equal u32 5)
|
|
78
|
+
(const gpu-always u32 6)
|
|
79
|
+
(const gpu-never u32 7)
|
|
80
|
+
|
|
81
|
+
(const gpu-vertex u32 1)
|
|
82
|
+
(const gpu-index u32 2)
|
|
83
|
+
(const gpu-uniform u32 4)
|
|
84
|
+
(const gpu-storage u32 8)
|
|
85
|
+
(const gpu-indirect u32 16)
|
|
86
|
+
(const gpu-sampled u32 1)
|
|
87
|
+
(const gpu-target u32 2)
|
|
88
|
+
(const gpu-storage-texture u32 4)
|
|
89
|
+
|
|
90
|
+
(const gpu-nearest u32 0)
|
|
91
|
+
(const gpu-linear u32 1)
|
|
92
|
+
(const gpu-clamp u32 0)
|
|
93
|
+
(const gpu-repeat u32 1)
|
|
94
|
+
(const gpu-mirror u32 2)
|
|
95
|
+
|
|
96
|
+
(const gpu-uniform-entry u32 1)
|
|
97
|
+
(const gpu-storage-entry u32 2)
|
|
98
|
+
(const gpu-read-only-entry u32 3)
|
|
99
|
+
(const gpu-dynamic-uniform-entry u32 4)
|
|
100
|
+
(const gpu-dynamic-storage-entry u32 5)
|
|
101
|
+
(const gpu-dynamic-read-only-entry u32 6)
|
|
102
|
+
(const gpu-sampler-entry u32 7)
|
|
103
|
+
(const gpu-comparison-entry u32 8)
|
|
104
|
+
(const gpu-texture-entry u32 9)
|
|
105
|
+
(const gpu-depth-entry u32 10)
|
|
106
|
+
(const gpu-storage-texture-entry u32 11)
|
|
107
|
+
(const gpu-texture-array-entry u32 12)
|
|
108
|
+
(const gpu-depth-array-entry u32 13)
|
|
109
|
+
(const gpu-in-vertex u32 1)
|
|
110
|
+
(const gpu-in-fragment u32 2)
|
|
111
|
+
(const gpu-in-compute u32 4)
|
|
112
|
+
|
|
113
|
+
(const gpu-per-vertex u32 0)
|
|
114
|
+
(const gpu-per-instance u32 1)
|
|
115
|
+
(const gpu-on-surface u32 1)
|
|
116
|
+
(const gpu-on-texture u32 2)
|
|
117
|
+
(const gpu-keep u32 0)
|
|
118
|
+
(const gpu-clear u32 1)
|
|
119
|
+
(const gpu-u16-indexes u32 0)
|
|
120
|
+
(const gpu-u32-indexes u32 1)
|
|
121
|
+
|
|
122
|
+
(const gpu-kind-surface u32 1)
|
|
123
|
+
(const gpu-kind-shader u32 2)
|
|
124
|
+
(const gpu-kind-pipeline u32 3)
|
|
125
|
+
(const gpu-kind-buffer u32 4)
|
|
126
|
+
(const gpu-kind-texture u32 5)
|
|
127
|
+
(const gpu-kind-sampler u32 6)
|
|
128
|
+
(const gpu-kind-layout u32 7)
|
|
129
|
+
(const gpu-kind-bind-group u32 8)
|
|
130
|
+
|
|
131
|
+
;; ---- the buffer ----
|
|
132
|
+
|
|
133
|
+
(define commands buffer)
|
|
134
|
+
(define frame arena)
|
|
135
|
+
|
|
136
|
+
(define (gpu-commands) -> (ptr buffer)
|
|
137
|
+
(complete!)
|
|
138
|
+
(& commands))
|
|
139
|
+
|
|
140
|
+
(define (gpu-commands-done!)
|
|
141
|
+
(set! (-> commands length) 0)
|
|
142
|
+
(arena-free (& frame))
|
|
143
|
+
(expect-nothing!))
|
|
144
|
+
|
|
145
|
+
(define (gpu-frame-alloc [n u32]) -> (ptr void) (arena-alloc (& frame) n))
|
|
146
|
+
|
|
147
|
+
(define (gpu-frame-copy [p (ptr void)] [n u32]) -> (ptr void)
|
|
148
|
+
(let ([copy (gpu-frame-alloc n)])
|
|
149
|
+
(memcpy copy p n)
|
|
150
|
+
copy))
|
|
151
|
+
|
|
152
|
+
(define (words! [w (slice u32)]) (buffer-add! (& commands) (slice (cast (ptr u8) (-> w items)) (* 4 (-> w length)))))
|
|
153
|
+
|
|
154
|
+
(define (word! [w u32]) (words! (slice (array-of u32 w))))
|
|
155
|
+
|
|
156
|
+
(define (float! [x f64]) (buffer-add! (& commands) (slice (cast (ptr u8) (array-of f32 (cast f32 x))) 4)))
|
|
157
|
+
|
|
158
|
+
(define (text! [s string])
|
|
159
|
+
(let ([copy (cast (ptr u8) (gpu-frame-alloc (-> s length)))])
|
|
160
|
+
(memcpy copy (-> s bytes) (-> s length))
|
|
161
|
+
(words! (slice (array-of u32 (cast u32 copy) (-> s length))))))
|
|
162
|
+
|
|
163
|
+
;; ---- the items a command still expects ----
|
|
164
|
+
|
|
165
|
+
(define expected-layouts u32 0)
|
|
166
|
+
(define expected-targets u32 0)
|
|
167
|
+
(define expected-buffers u32 0)
|
|
168
|
+
(define expected-attributes u32 0)
|
|
169
|
+
(define expected-entries u32 0)
|
|
170
|
+
(define expected-bindings u32 0)
|
|
171
|
+
(define expected-pass-targets u32 0)
|
|
172
|
+
(define expected-offsets u32 0)
|
|
173
|
+
|
|
174
|
+
(define (complete!)
|
|
175
|
+
(when (or (> expected-layouts 0) (> expected-targets 0) (> expected-buffers 0) (> expected-attributes 0)
|
|
176
|
+
(> expected-entries 0) (> expected-bindings 0) (> expected-pass-targets 0) (> expected-offsets 0))
|
|
177
|
+
(host-trap "gpu: the last command is still waiting for its items (layouts, targets, attributes, entries or offsets)")))
|
|
178
|
+
|
|
179
|
+
(define (expect-nothing!)
|
|
180
|
+
(set! expected-layouts 0)
|
|
181
|
+
(set! expected-targets 0)
|
|
182
|
+
(set! expected-buffers 0)
|
|
183
|
+
(set! expected-attributes 0)
|
|
184
|
+
(set! expected-entries 0)
|
|
185
|
+
(set! expected-bindings 0)
|
|
186
|
+
(set! expected-pass-targets 0)
|
|
187
|
+
(set! expected-offsets 0))
|
|
188
|
+
|
|
189
|
+
(define (item! [expected (ptr u32)] [unexpected string])
|
|
190
|
+
(when (== (@ expected) 0) (host-trap unexpected))
|
|
191
|
+
(-= (@ expected) 1))
|
|
192
|
+
|
|
193
|
+
;; ---- numbers ----
|
|
194
|
+
|
|
195
|
+
(define next-surface u32 1)
|
|
196
|
+
(define next-shader u32 1)
|
|
197
|
+
(define next-pipeline u32 1)
|
|
198
|
+
(define next-buffer u32 1)
|
|
199
|
+
(define next-texture u32 1)
|
|
200
|
+
(define next-sampler u32 1)
|
|
201
|
+
(define next-layout u32 1)
|
|
202
|
+
(define next-bind-group u32 1)
|
|
203
|
+
|
|
204
|
+
(define (fresh! [next (ptr u32)]) -> u32
|
|
205
|
+
(let ([n (@ next)])
|
|
206
|
+
(+= (@ next) 1)
|
|
207
|
+
n))
|
|
208
|
+
|
|
209
|
+
;; ---- making resources ----
|
|
210
|
+
|
|
211
|
+
(define (gpu-surface! [node u32]) -> u32
|
|
212
|
+
(complete!)
|
|
213
|
+
(let ([id (fresh! (& next-surface))])
|
|
214
|
+
(words! (slice (array-of u32 1 id node)))
|
|
215
|
+
id))
|
|
216
|
+
|
|
217
|
+
(define (gpu-shader! [code string]) -> u32
|
|
218
|
+
(complete!)
|
|
219
|
+
(let ([id (fresh! (& next-shader))])
|
|
220
|
+
(words! (slice (array-of u32 2 id)))
|
|
221
|
+
(text! code)
|
|
222
|
+
id))
|
|
223
|
+
|
|
224
|
+
(define (gpu-render-pipeline! [shader u32] [vertex string] [fragment string] [topology u32] [cull u32] [front u32]
|
|
225
|
+
[blend u32] [depth-format u32] [depth-compare u32] [depth-write bool]
|
|
226
|
+
[layouts u32] [targets u32] [buffers u32]) -> u32
|
|
227
|
+
(complete!)
|
|
228
|
+
(let ([id (fresh! (& next-pipeline))])
|
|
229
|
+
(words! (slice (array-of u32 3 id shader)))
|
|
230
|
+
(text! vertex)
|
|
231
|
+
(text! fragment)
|
|
232
|
+
(words! (slice (array-of u32 topology cull front blend depth-format depth-compare depth-write layouts)))
|
|
233
|
+
(set! expected-layouts layouts)
|
|
234
|
+
(set! expected-targets targets)
|
|
235
|
+
(set! expected-buffers buffers)
|
|
236
|
+
(set! rendering #t)
|
|
237
|
+
(when (== layouts 0) (after-layouts!))
|
|
238
|
+
id))
|
|
239
|
+
|
|
240
|
+
(define rendering bool #f)
|
|
241
|
+
|
|
242
|
+
(define (after-layouts!)
|
|
243
|
+
(when rendering
|
|
244
|
+
(word! expected-targets)
|
|
245
|
+
(when (== expected-targets 0) (after-targets!))))
|
|
246
|
+
|
|
247
|
+
(define (after-targets!) (word! expected-buffers))
|
|
248
|
+
|
|
249
|
+
(define (gpu-layout-item! [layout u32])
|
|
250
|
+
(item! (& expected-layouts) "gpu: no layout is expected here")
|
|
251
|
+
(word! layout)
|
|
252
|
+
(when (== expected-layouts 0) (after-layouts!)))
|
|
253
|
+
|
|
254
|
+
(define (gpu-target! [format u32])
|
|
255
|
+
(item! (& expected-targets) "gpu: no target is expected here")
|
|
256
|
+
(word! format)
|
|
257
|
+
(when (== expected-targets 0) (after-targets!)))
|
|
258
|
+
|
|
259
|
+
(define (gpu-vertex-buffer-layout! [stride u32] [step u32] [attributes u32])
|
|
260
|
+
(when (> expected-attributes 0) (host-trap "gpu: the attributes of the last vertex buffer are not complete"))
|
|
261
|
+
(item! (& expected-buffers) "gpu: no vertex buffer layout is expected here")
|
|
262
|
+
(words! (slice (array-of u32 stride step attributes)))
|
|
263
|
+
(set! expected-attributes attributes))
|
|
264
|
+
|
|
265
|
+
(define (gpu-attribute! [location u32] [offset u32] [format u32])
|
|
266
|
+
(item! (& expected-attributes) "gpu: no attribute is expected here")
|
|
267
|
+
(words! (slice (array-of u32 location offset format))))
|
|
268
|
+
|
|
269
|
+
(define (gpu-compute-pipeline! [shader u32] [entry string] [layouts u32]) -> u32
|
|
270
|
+
(complete!)
|
|
271
|
+
(let ([id (fresh! (& next-pipeline))])
|
|
272
|
+
(words! (slice (array-of u32 4 id shader)))
|
|
273
|
+
(text! entry)
|
|
274
|
+
(word! layouts)
|
|
275
|
+
(set! expected-layouts layouts)
|
|
276
|
+
(set! rendering #f)
|
|
277
|
+
id))
|
|
278
|
+
|
|
279
|
+
(define (gpu-buffer! [size u32] [usage u32]) -> u32
|
|
280
|
+
(complete!)
|
|
281
|
+
(let ([id (fresh! (& next-buffer))])
|
|
282
|
+
(words! (slice (array-of u32 5 id size usage)))
|
|
283
|
+
id))
|
|
284
|
+
|
|
285
|
+
(define (gpu-texture! [width u32] [height u32] [layers u32] [mips u32] [format u32] [usage u32]) -> u32
|
|
286
|
+
(complete!)
|
|
287
|
+
(let ([id (fresh! (& next-texture))])
|
|
288
|
+
(words! (slice (array-of u32 6 id width height layers mips format usage)))
|
|
289
|
+
id))
|
|
290
|
+
|
|
291
|
+
(define (gpu-texture-file! [path string]) -> u32
|
|
292
|
+
(complete!)
|
|
293
|
+
(let ([id (fresh! (& next-texture))])
|
|
294
|
+
(words! (slice (array-of u32 7 id)))
|
|
295
|
+
(text! path)
|
|
296
|
+
id))
|
|
297
|
+
|
|
298
|
+
(define (gpu-sampler! [filter u32] [address u32] [compare u32]) -> u32
|
|
299
|
+
(complete!)
|
|
300
|
+
(let ([id (fresh! (& next-sampler))])
|
|
301
|
+
(words! (slice (array-of u32 8 id filter address compare)))
|
|
302
|
+
id))
|
|
303
|
+
|
|
304
|
+
(define (gpu-layout! [n u32]) -> u32
|
|
305
|
+
(complete!)
|
|
306
|
+
(let ([id (fresh! (& next-layout))])
|
|
307
|
+
(words! (slice (array-of u32 9 id n)))
|
|
308
|
+
(set! expected-entries n)
|
|
309
|
+
id))
|
|
310
|
+
|
|
311
|
+
(define (gpu-layout-entry! [binding u32] [visibility u32] [kind u32])
|
|
312
|
+
(item! (& expected-entries) "gpu: no layout entry is expected here")
|
|
313
|
+
(words! (slice (array-of u32 binding visibility kind))))
|
|
314
|
+
|
|
315
|
+
(define (gpu-bind-group! [layout u32] [pipeline u32] [group u32] [n u32]) -> u32
|
|
316
|
+
(complete!)
|
|
317
|
+
(let ([id (fresh! (& next-bind-group))])
|
|
318
|
+
(words! (slice (array-of u32 10 id layout pipeline group n)))
|
|
319
|
+
(set! expected-bindings n)
|
|
320
|
+
id))
|
|
321
|
+
|
|
322
|
+
(define (gpu-bind-buffer! [binding u32] [buffer u32] [offset u32] [size u32])
|
|
323
|
+
(item! (& expected-bindings) "gpu: no binding is expected here")
|
|
324
|
+
(words! (slice (array-of u32 binding 1 buffer offset size))))
|
|
325
|
+
|
|
326
|
+
(define (gpu-bind-sampler! [binding u32] [sampler u32])
|
|
327
|
+
(item! (& expected-bindings) "gpu: no binding is expected here")
|
|
328
|
+
(words! (slice (array-of u32 binding 2 sampler 0 0))))
|
|
329
|
+
|
|
330
|
+
(define (gpu-bind-texture! [binding u32] [texture u32])
|
|
331
|
+
(item! (& expected-bindings) "gpu: no binding is expected here")
|
|
332
|
+
(words! (slice (array-of u32 binding 3 texture 0 0))))
|
|
333
|
+
|
|
334
|
+
(define (gpu-destroy! [kind u32] [id u32])
|
|
335
|
+
(complete!)
|
|
336
|
+
(words! (slice (array-of u32 11 kind id))))
|
|
337
|
+
|
|
338
|
+
;; ---- writing and reading ----
|
|
339
|
+
|
|
340
|
+
(define (gpu-write-buffer! [buffer u32] [offset u32] [p (ptr void)] [n u32])
|
|
341
|
+
(complete!)
|
|
342
|
+
(words! (slice (array-of u32 12 buffer offset (cast u32 p) n))))
|
|
343
|
+
|
|
344
|
+
(define (gpu-write-texture! [texture u32] [mip u32] [layer u32] [x u32] [y u32] [w u32] [h u32] [p (ptr void)] [n u32])
|
|
345
|
+
(complete!)
|
|
346
|
+
(words! (slice (array-of u32 13 texture mip layer x y w h (cast u32 p) n))))
|
|
347
|
+
|
|
348
|
+
(define (gpu-read-texture! [texture u32] [mip u32] [layer u32] [x u32] [y u32] [w u32] [h u32])
|
|
349
|
+
(complete!)
|
|
350
|
+
(words! (slice (array-of u32 14 texture mip layer x y w h))))
|
|
351
|
+
|
|
352
|
+
(define (gpu-read-buffer! [buffer u32] [offset u32] [n u32])
|
|
353
|
+
(complete!)
|
|
354
|
+
(words! (slice (array-of u32 15 buffer offset n))))
|
|
355
|
+
|
|
356
|
+
;; ---- passes ----
|
|
357
|
+
|
|
358
|
+
(define (gpu-render-pass! [targets u32] [depth-texture u32] [depth-mip u32] [depth-layer u32] [depth-load u32] [depth-clear f64])
|
|
359
|
+
(complete!)
|
|
360
|
+
(words! (slice (array-of u32 16 targets)))
|
|
361
|
+
(set! expected-pass-targets targets)
|
|
362
|
+
(set! pending-depth-texture depth-texture)
|
|
363
|
+
(set! pending-depth-mip depth-mip)
|
|
364
|
+
(set! pending-depth-layer depth-layer)
|
|
365
|
+
(set! pending-depth-load depth-load)
|
|
366
|
+
(set! pending-depth-clear depth-clear)
|
|
367
|
+
(when (== targets 0) (depth!)))
|
|
368
|
+
|
|
369
|
+
(define pending-depth-texture u32 0)
|
|
370
|
+
(define pending-depth-mip u32 0)
|
|
371
|
+
(define pending-depth-layer u32 0)
|
|
372
|
+
(define pending-depth-load u32 0)
|
|
373
|
+
(define pending-depth-clear f64 0.0)
|
|
374
|
+
|
|
375
|
+
(define (depth!)
|
|
376
|
+
(words! (slice (array-of u32 pending-depth-texture pending-depth-mip pending-depth-layer pending-depth-load)))
|
|
377
|
+
(float! pending-depth-clear))
|
|
378
|
+
|
|
379
|
+
(define (gpu-pass-target! [kind u32] [id u32] [mip u32] [layer u32] [load u32] [r f64] [g f64] [b f64] [a f64])
|
|
380
|
+
(item! (& expected-pass-targets) "gpu: no pass target is expected here")
|
|
381
|
+
(words! (slice (array-of u32 kind id mip layer load)))
|
|
382
|
+
(float! r)
|
|
383
|
+
(float! g)
|
|
384
|
+
(float! b)
|
|
385
|
+
(float! a)
|
|
386
|
+
(when (== expected-pass-targets 0) (depth!)))
|
|
387
|
+
|
|
388
|
+
(define (gpu-compute-pass!)
|
|
389
|
+
(complete!)
|
|
390
|
+
(word! 17))
|
|
391
|
+
|
|
392
|
+
(define (gpu-end-pass!)
|
|
393
|
+
(complete!)
|
|
394
|
+
(word! 18))
|
|
395
|
+
|
|
396
|
+
(define (gpu-pipeline! [pipeline u32])
|
|
397
|
+
(complete!)
|
|
398
|
+
(words! (slice (array-of u32 19 pipeline))))
|
|
399
|
+
|
|
400
|
+
(define (gpu-bind-group-set! [group u32] [bind-group u32] [n u32])
|
|
401
|
+
(complete!)
|
|
402
|
+
(words! (slice (array-of u32 20 group bind-group n)))
|
|
403
|
+
(set! expected-offsets n))
|
|
404
|
+
|
|
405
|
+
(define (gpu-offset! [offset u32])
|
|
406
|
+
(item! (& expected-offsets) "gpu: no offset is expected here")
|
|
407
|
+
(word! offset))
|
|
408
|
+
|
|
409
|
+
(define (gpu-vertex-buffer! [slot u32] [buffer u32] [offset u32])
|
|
410
|
+
(complete!)
|
|
411
|
+
(words! (slice (array-of u32 21 slot buffer offset))))
|
|
412
|
+
|
|
413
|
+
(define (gpu-index-buffer! [buffer u32] [format u32] [offset u32])
|
|
414
|
+
(complete!)
|
|
415
|
+
(words! (slice (array-of u32 22 buffer format offset))))
|
|
416
|
+
|
|
417
|
+
(define (gpu-draw! [vertices u32] [instances u32] [first-vertex u32] [first-instance u32])
|
|
418
|
+
(complete!)
|
|
419
|
+
(words! (slice (array-of u32 23 vertices instances first-vertex first-instance))))
|
|
420
|
+
|
|
421
|
+
(define (gpu-draw-indexed! [indexes u32] [instances u32] [first-index u32] [base-vertex u32] [first-instance u32])
|
|
422
|
+
(complete!)
|
|
423
|
+
(words! (slice (array-of u32 24 indexes instances first-index base-vertex first-instance))))
|
|
424
|
+
|
|
425
|
+
(define (gpu-dispatch! [x u32] [y u32] [z u32])
|
|
426
|
+
(complete!)
|
|
427
|
+
(words! (slice (array-of u32 25 x y z))))
|
|
428
|
+
|
|
429
|
+
(define (gpu-viewport! [x f64] [y f64] [w f64] [h f64])
|
|
430
|
+
(complete!)
|
|
431
|
+
(word! 26)
|
|
432
|
+
(float! x)
|
|
433
|
+
(float! y)
|
|
434
|
+
(float! w)
|
|
435
|
+
(float! h))
|
|
436
|
+
|
|
437
|
+
(define (gpu-scissor! [x u32] [y u32] [w u32] [h u32])
|
|
438
|
+
(complete!)
|
|
439
|
+
(words! (slice (array-of u32 27 x y w h))))
|