diff --git a/README.md b/README.md index cac8748..1b89595 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# WASI WebGPU+ +# WASI-GFX A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API. @@ -15,7 +15,7 @@ Phase 1 | | Linux | Window | MacOS | Android | Web | | -------- | ----- | ------ | ----- | ------- | --- | -| Wasmtime | ✅ | ✅ | ✅ | ✅ | | +| Wasmtime | ✅ | ✅ | ✅ | ✅ | | | Jco | | | | | ✅ | ## Table of Contents [if the explainer is longer than one printed page] diff --git a/build-docs.sh b/build-docs.sh new file mode 100755 index 0000000..09b020d --- /dev/null +++ b/build-docs.sh @@ -0,0 +1,4 @@ +wit-bindgen markdown --html-in-md ./graphics-context --out-dir ./graphics-context +wit-bindgen markdown --html-in-md ./surface --out-dir ./surface +wit-bindgen markdown --html-in-md ./webgpu --out-dir ./webgpu +wit-bindgen markdown --html-in-md ./frame-buffer --out-dir ./frame-buffer diff --git a/frame-buffer/deps.lock b/frame-buffer/deps.lock new file mode 100644 index 0000000..0f4fc66 --- /dev/null +++ b/frame-buffer/deps.lock @@ -0,0 +1,4 @@ +[graphics-context] +path = "../graphics-context" +sha256 = "cf022dcf41c7e9f6d3ca8af2f80f523306472a5548d38199d57986fc75aafb7b" +sha512 = "b5cf0248f2cd1dbfbeb500b375e56fecbe8b1ac147b1aece73032543e696e0f7dad3da5aa99fbade290369a065059ae606def00d7d1aa94cde7f19ee03741479" diff --git a/frame-buffer/deps.toml b/frame-buffer/deps.toml new file mode 100644 index 0000000..6a3e7e9 --- /dev/null +++ b/frame-buffer/deps.toml @@ -0,0 +1,2 @@ +[graphics-context] +path = "../graphics-context" diff --git a/wit/graphics-context.wit b/frame-buffer/deps/graphics-context/graphics-context.wit similarity index 74% rename from wit/graphics-context.wit rename to frame-buffer/deps/graphics-context/graphics-context.wit index 3718f39..97e9950 100644 --- a/wit/graphics-context.wit +++ b/frame-buffer/deps/graphics-context/graphics-context.wit @@ -1,4 +1,8 @@ -package wasi:webgpu; +package wasi:graphics-context; + +world imports { + import graphics-context; +} interface graphics-context { resource context { diff --git a/wit/frame-buffer.wit b/frame-buffer/frame-buffer.wit similarity index 72% rename from wit/frame-buffer.wit rename to frame-buffer/frame-buffer.wit index 3d1e316..17e1127 100644 --- a/wit/frame-buffer.wit +++ b/frame-buffer/frame-buffer.wit @@ -1,7 +1,11 @@ -package wasi:webgpu; +package wasi:frame-buffer; + +world imports { + import frame-buffer; +} interface frame-buffer { - use graphics-context.{context, abstract-buffer}; + use wasi:graphics-context/graphics-context.{context, abstract-buffer}; resource device { constructor(); diff --git a/frame-buffer/imports.md b/frame-buffer/imports.md new file mode 100644 index 0000000..4d37443 --- /dev/null +++ b/frame-buffer/imports.md @@ -0,0 +1,85 @@ +
wasi:graphics-context/graphics-context
wasi:frame-buffer/frame-buffer
resource context
resource abstract-buffer
[constructor]context: func
context
>[method]context.get-current-buffer: func
self
: borrow<context
>abstract-buffer
>[method]context.present: func
TODO: might want to remove this.
+self
: borrow<context
>type context
+#### `type abstract-buffer` +[`abstract-buffer`](#abstract_buffer) +
resource buffer
[constructor]device: func
device
>[method]device.connect-graphics-context: func
[static]buffer.from-graphics-buffer: func
buffer
: own<abstract-buffer
>buffer
>[method]buffer.get: func
TODO: This should be replcated with something that doesn't require a copy.
+self
: borrow<buffer
>[method]buffer.set: func
self
: borrow<buffer
>val
: list<u8
>wasi:graphics-context/graphics-context
resource context
resource abstract-buffer
[constructor]context: func
context
>[method]context.get-current-buffer: func
self
: borrow<context
>abstract-buffer
>[method]context.present: func
TODO: might want to remove this.
+self
: borrow<context
>wasi:graphics-context/graphics-context
wasi:io/poll@0.2.0
wasi:surface/surface
resource context
resource abstract-buffer
[constructor]context: func
context
>[method]context.get-current-buffer: func
self
: borrow<context
>abstract-buffer
>[method]context.present: func
TODO: might want to remove this.
+self
: borrow<context
>A poll API intended to let users wait for I/O events on multiple handles +at once.
+resource pollable
pollable
represents a single I/O event which may be ready, or not.[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
+Returns true
when the pollable is ready, and false
otherwise.
self
: borrow<pollable
>[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
+blocks until ready.
This function is equivalent to calling poll.poll
on a list
+containing only this pollable.
self
: borrow<pollable
>poll: func
Poll for completion on a set of pollables.
+This function takes a list of pollables, which identify I/O sources of +interest, and waits until one or more of the events is ready for I/O.
+The result list<u32>
contains one or more indices of handles in the
+argument list that is ready for I/O.
If the list contains more elements than can be indexed with a u32
+value, this function traps.
A timeout can be implemented by adding a pollable from the +wasi-clocks API to the list.
+This function does not return a result
; polling in itself does not
+do any I/O so it doesn't fail. If any of the I/O sources identified by
+the pollables has an error, it is indicated by marking the source as
+being reaedy for I/O.
in
: list<borrow<pollable
>>type context
+#### `type pollable` +[`pollable`](#pollable) +
resource surface
record resize-event
record frame-event
nothing
: bool
TODO: This field doesn't mean anything. +Can't have empty record. Would like to have a way around this. +
record pointer-event
enum key
corresponds with https://w3c.github.io/uievents-code/#code-value-tables
+Unidentified
is not included, use option<key>
instead.
backquote
backslash
bracket-left
bracket-right
comma
digit0
digit1
digit2
digit3
digit4
digit5
digit6
digit7
digit8
digit9
equal
intl-backslash
intl-ro
intl-yen
key-a
key-b
key-c
key-d
key-e
key-f
key-g
key-h
key-i
key-j
key-k
key-l
key-m
key-n
key-o
key-p
key-q
key-r
key-s
key-t
key-u
key-v
key-w
key-x
key-y
key-z
minus
period
quote
semicolon
slash
alt-left
alt-right
backspace
caps-lock
context-menu
control-left
control-right
enter
meta-left
meta-right
shift-left
shift-right
space
tab
convert
kana-mode
lang1
lang2
lang3
lang4
lang5
non-convert
delete
end
help
home
insert
page-down
page-up
arrow-down
arrow-left
arrow-right
arrow-up
num-lock
numpad0
numpad1
numpad2
numpad3
numpad4
numpad5
numpad6
numpad7
numpad8
numpad9
numpad-add
numpad-backspace
numpad-clear
numpad-clear-entry
numpad-comma
numpad-decimal
numpad-divide
numpad-enter
numpad-equal
numpad-hash
numpad-memory-add
numpad-memory-clear
numpad-memory-recall
numpad-memory-store
numpad-memory-subtract
numpad-multiply
numpad-paren-left
numpad-paren-right
numpad-star
numpad-subtract
escape
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
fn
fn-lock
print-screen
scroll-lock
pause
browser-back
browser-favorites
browser-forward
browser-home
browser-refresh
browser-search
browser-stop
eject
launch-app1
launch-app2
launch-mail
media-play-pause
media-select
media-stop
media-track-next
media-track-previous
power
sleep
audio-volume-down
audio-volume-mute
audio-volume-up
wake-up
hyper
super
turbo
abort
resume
suspend
again
copy
cut
find
open
paste
props
select
undo
hiragana
katakana
record key-event
key
: option<key
>text
: option<string
>alt-key
: bool
ctrl-key
: bool
meta-key
: bool
shift-key
: bool
[constructor]surface: func
desc
: create-desc
surface
>[method]surface.connect-graphics-context: func
[method]surface.height: func
self
: borrow<surface
>[method]surface.width: func
self
: borrow<surface
>[method]surface.request-set-size: func
self
: borrow<surface
>height
: option<u32
>width
: option<u32
>[method]surface.subscribe-resize: func
self
: borrow<surface
>pollable
>[method]surface.get-resize: func
self
: borrow<surface
>resize-event
>[method]surface.subscribe-frame: func
self
: borrow<surface
>pollable
>[method]surface.get-frame: func
self
: borrow<surface
>frame-event
>[method]surface.subscribe-pointer-up: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-up: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-pointer-down: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-down: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-pointer-move: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-move: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-key-up: func
self
: borrow<surface
>pollable
>[method]surface.get-key-up: func
self
: borrow<surface
>key-event
>[method]surface.subscribe-key-down: func
self
: borrow<surface
>pollable
>[method]surface.get-key-down: func
self
: borrow<surface
>key-event
>wasi:webgpu/graphics-context
wasi:graphics-context/graphics-context
wasi:webgpu/webgpu
wasi:io/poll@0.2.0
wasi:webgpu/surface
wasi:webgpu/frame-buffer
resource context
record gpu-buffer-binding
buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>offset
: option<gpu-size64
>size
: option<gpu-size64
>binding
: gpu-index32
visibility
: gpu-shader-stage-flags
buffer
: option<gpu-buffer-binding-layout
>buffer
: option<gpu-buffer-binding-layout
>sampler
: option<gpu-sampler-binding-layout
>texture
: option<gpu-texture-binding-layout
>storage-texture
: option<gpu-storage-texture-binding-layout
>record gpu-image-copy-buffer
buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>offset
: option<gpu-size64
>bytes-per-row
: option<gpu-size32
>rows-per-image
: option<gpu-size32
>record gpu-canvas-configuration
device
: borrow<gpu-device
>device
: borrow<gpu-device
>format
: gpu-texture-format
usage
: option<gpu-texture-usage-flags
>view-formats
: option<list<gpu-texture-format
>>self
: borrow<record-gpu-size64
>key
: string
key
: string
value
: gpu-size64
[method]record-gpu-size64.get: func
self
: borrow<record-gpu-size64
>key
: string
key
: string
self
: borrow<record-gpu-size64
>key
: string
key
: string
self
: borrow<record-gpu-size64
>key
: string
key
: string
[method]record-gpu-size64.keys: func
[static]gpu-texture.from-graphics-buffer: func
buffer
: own<abstract-buffer
>buffer
: own<abstract-buffer
>self
: borrow<record-gpu-pipeline-constant-value
>key
: string
key
: string
value
: gpu-pipeline-constant-value
[method]record-gpu-pipeline-constant-value.get: func
self
: borrow<record-gpu-pipeline-constant-value
>key
: string
key
: string
self
: borrow<record-gpu-pipeline-constant-value
>key
: string
key
: string
self
: borrow<record-gpu-pipeline-constant-value
>key
: string
key
: string
[method]record-gpu-pipeline-constant-value.keys: func
self
: borrow<gpu-command-encoder
>buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>offset
: option<gpu-size64
>size
: option<gpu-size64
>self
: borrow<gpu-render-pass-encoder
>buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>index-format
: gpu-index-format
offset
: option<gpu-size64
>size
: option<gpu-size64
>self
: borrow<gpu-render-pass-encoder
>slot
: gpu-index32
buffer
: option<borrow<gpu-buffer
>>buffer
: option<borrow<gpu-buffer
>>offset
: option<gpu-size64
>size
: option<gpu-size64
>self
: borrow<gpu-render-bundle-encoder
>buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>index-format
: gpu-index-format
offset
: option<gpu-size64
>size
: option<gpu-size64
>self
: borrow<gpu-render-bundle-encoder
>slot
: gpu-index32
buffer
: option<borrow<gpu-buffer
>>buffer
: option<borrow<gpu-buffer
>>offset
: option<gpu-size64
>size
: option<gpu-size64
>self
: borrow<gpu-queue
>buffer
: borrow<gpu-buffer
>buffer
: borrow<gpu-buffer
>buffer-offset
: gpu-size64
data-offset
: option<gpu-size64
>data
: list<u8
>self
: borrow<non-standard-buffer
>val
: list<u8
>A poll API intended to let users wait for I/O events on multiple handles -at once.
-resource pollable
pollable
represents a single I/O event which may be ready, or not.[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
-Returns true
when the pollable is ready, and false
otherwise.
self
: borrow<pollable
>[method]pollable.block: func
block
returns immediately if the pollable is ready, and otherwise
-blocks until ready.
This function is equivalent to calling poll.poll
on a list
-containing only this pollable.
self
: borrow<pollable
>poll: func
Poll for completion on a set of pollables.
-This function takes a list of pollables, which identify I/O sources of -interest, and waits until one or more of the events is ready for I/O.
-The result list<u32>
contains one or more indices of handles in the
-argument list that is ready for I/O.
If the list contains more elements than can be indexed with a u32
-value, this function traps.
A timeout can be implemented by adding a pollable from the -wasi-clocks API to the list.
-This function does not return a result
; polling in itself does not
-do any I/O so it doesn't fail. If any of the I/O sources identified by
-the pollables has an error, it is indicated by marking the source as
-being reaedy for I/O.
in
: list<borrow<pollable
>>type context
-#### `type pollable` -[`pollable`](#pollable) -
resource surface
record resize-event
record frame-event
nothing
: bool
TODO: This field doesn't mean anything. -Can't have empty record. Would like to have a way around this. -
record pointer-event
enum key
corresponds with https://w3c.github.io/uievents-code/#code-value-tables
-Unidentified
is not included, use option<key>
instead.
backquote
backslash
bracket-left
bracket-right
comma
digit0
digit1
digit2
digit3
digit4
digit5
digit6
digit7
digit8
digit9
equal
intl-backslash
intl-ro
intl-yen
key-a
key-b
key-c
key-d
key-e
key-f
key-g
key-h
key-i
key-j
key-k
key-l
key-m
key-n
key-o
key-p
key-q
key-r
key-s
key-t
key-u
key-v
key-w
key-x
key-y
key-z
minus
period
quote
semicolon
slash
alt-left
alt-right
backspace
caps-lock
context-menu
control-left
control-right
enter
meta-left
meta-right
shift-left
shift-right
space
tab
convert
kana-mode
lang1
lang2
lang3
lang4
lang5
non-convert
delete
end
help
home
insert
page-down
page-up
arrow-down
arrow-left
arrow-right
arrow-up
num-lock
numpad0
numpad1
numpad2
numpad3
numpad4
numpad5
numpad6
numpad7
numpad8
numpad9
numpad-add
numpad-backspace
numpad-clear
numpad-clear-entry
numpad-comma
numpad-decimal
numpad-divide
numpad-enter
numpad-equal
numpad-hash
numpad-memory-add
numpad-memory-clear
numpad-memory-recall
numpad-memory-store
numpad-memory-subtract
numpad-multiply
numpad-paren-left
numpad-paren-right
numpad-star
numpad-subtract
escape
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
fn
fn-lock
print-screen
scroll-lock
pause
browser-back
browser-favorites
browser-forward
browser-home
browser-refresh
browser-search
browser-stop
eject
launch-app1
launch-app2
launch-mail
media-play-pause
media-select
media-stop
media-track-next
media-track-previous
power
sleep
audio-volume-down
audio-volume-mute
audio-volume-up
wake-up
hyper
super
turbo
abort
resume
suspend
again
copy
cut
find
open
paste
props
select
undo
hiragana
katakana
record key-event
key
: option<key
>text
: option<string
>alt-key
: bool
ctrl-key
: bool
meta-key
: bool
shift-key
: bool
[constructor]surface: func
desc
: create-desc
surface
>[method]surface.connect-graphics-context: func
[method]surface.height: func
self
: borrow<surface
>[method]surface.width: func
self
: borrow<surface
>[method]surface.request-set-size: func
self
: borrow<surface
>height
: option<u32
>width
: option<u32
>[method]surface.subscribe-resize: func
self
: borrow<surface
>pollable
>[method]surface.get-resize: func
self
: borrow<surface
>resize-event
>[method]surface.subscribe-frame: func
self
: borrow<surface
>pollable
>[method]surface.get-frame: func
self
: borrow<surface
>frame-event
>[method]surface.subscribe-pointer-up: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-up: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-pointer-down: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-down: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-pointer-move: func
self
: borrow<surface
>pollable
>[method]surface.get-pointer-move: func
self
: borrow<surface
>pointer-event
>[method]surface.subscribe-key-up: func
self
: borrow<surface
>pollable
>[method]surface.get-key-up: func
self
: borrow<surface
>key-event
>[method]surface.subscribe-key-down: func
self
: borrow<surface
>pollable
>[method]surface.get-key-down: func
self
: borrow<surface
>key-event
>type context
-#### `type abstract-buffer` -[`abstract-buffer`](#abstract_buffer) -
resource buffer
[constructor]device: func
device
>[method]device.connect-graphics-context: func
[static]buffer.from-graphics-buffer: func
buffer
: own<abstract-buffer
>buffer
>[method]buffer.get: func
TODO: This should be replcated with something that doesn't require a copy.
-self
: borrow<buffer
>[method]buffer.set: func
self
: borrow<buffer
>val
: list<u8
>