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 @@ +

World imports

+ +

Import interface wasi:graphics-context/graphics-context

+
+

Types

+

resource context

+

resource abstract-buffer

+
+

Functions

+

[constructor]context: func

+
Return values
+ +

[method]context.get-current-buffer: func

+
Params
+ +
Return values
+ +

[method]context.present: func

+

TODO: might want to remove this.

+
Params
+ +

Import interface wasi:frame-buffer/frame-buffer

+
+

Types

+

type context

+

context

+

+#### `type abstract-buffer` +[`abstract-buffer`](#abstract_buffer) +

+#### `resource device` +

resource buffer

+
+

Functions

+

[constructor]device: func

+
Return values
+ +

[method]device.connect-graphics-context: func

+
Params
+ +

[static]buffer.from-graphics-buffer: func

+
Params
+ +
Return values
+ +

[method]buffer.get: func

+

TODO: This should be replcated with something that doesn't require a copy.

+
Params
+ +
Return values
+ +

[method]buffer.set: func

+
Params
+ diff --git a/graphics-context/deps.lock b/graphics-context/deps.lock new file mode 100644 index 0000000..e69de29 diff --git a/graphics-context/deps.toml b/graphics-context/deps.toml new file mode 100644 index 0000000..e69de29 diff --git a/graphics-context/graphics-context.wit b/graphics-context/graphics-context.wit new file mode 100644 index 0000000..97e9950 --- /dev/null +++ b/graphics-context/graphics-context.wit @@ -0,0 +1,18 @@ +package wasi:graphics-context; + +world imports { + import graphics-context; +} + +interface graphics-context { + resource context { + constructor(); + + get-current-buffer: func() -> abstract-buffer; + + // TODO: might want to remove this. + present: func(); + } + + resource abstract-buffer { } +} diff --git a/graphics-context/imports.md b/graphics-context/imports.md new file mode 100644 index 0000000..8447a82 --- /dev/null +++ b/graphics-context/imports.md @@ -0,0 +1,35 @@ +

World imports

+ +

Import interface wasi:graphics-context/graphics-context

+
+

Types

+

resource context

+

resource abstract-buffer

+
+

Functions

+

[constructor]context: func

+
Return values
+ +

[method]context.get-current-buffer: func

+
Params
+ +
Return values
+ +

[method]context.present: func

+

TODO: might want to remove this.

+
Params
+ diff --git a/install-wit-deps.sh b/install-wit-deps.sh new file mode 100755 index 0000000..c43097e --- /dev/null +++ b/install-wit-deps.sh @@ -0,0 +1,4 @@ +wit-deps -m webgpu/deps.toml -l webgpu/deps.lock -d webgpu/deps +wit-deps -m surface/deps.toml -l surface/deps.lock -d surface/deps +wit-deps -m graphics-context/deps.toml -l graphics-context/deps.lock -d graphics-context/deps +wit-deps -m frame-buffer/deps.toml -l frame-buffer/deps.lock -d frame-buffer/deps diff --git a/wit/deps.lock b/surface/deps.lock similarity index 55% rename from wit/deps.lock rename to surface/deps.lock index 0b9daa6..0f15055 100644 --- a/wit/deps.lock +++ b/surface/deps.lock @@ -1,3 +1,8 @@ +[graphics-context] +path = "../graphics-context" +sha256 = "cf022dcf41c7e9f6d3ca8af2f80f523306472a5548d38199d57986fc75aafb7b" +sha512 = "b5cf0248f2cd1dbfbeb500b375e56fecbe8b1ac147b1aece73032543e696e0f7dad3da5aa99fbade290369a065059ae606def00d7d1aa94cde7f19ee03741479" + [io] url = "https://github.com/WebAssembly/wasi-io/archive/fef02cddb4ac28dcde97bf11a4c7b856833a948f.tar.gz" sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c" diff --git a/wit/deps.toml b/surface/deps.toml similarity index 67% rename from wit/deps.toml rename to surface/deps.toml index b2b6a43..db2d7f4 100644 --- a/wit/deps.toml +++ b/surface/deps.toml @@ -1 +1,4 @@ io = "https://github.com/WebAssembly/wasi-io/archive/fef02cddb4ac28dcde97bf11a4c7b856833a948f.tar.gz" + +[graphics-context] +path = "../graphics-context" diff --git a/surface/deps/graphics-context/graphics-context.wit b/surface/deps/graphics-context/graphics-context.wit new file mode 100644 index 0000000..97e9950 --- /dev/null +++ b/surface/deps/graphics-context/graphics-context.wit @@ -0,0 +1,18 @@ +package wasi:graphics-context; + +world imports { + import graphics-context; +} + +interface graphics-context { + resource context { + constructor(); + + get-current-buffer: func() -> abstract-buffer; + + // TODO: might want to remove this. + present: func(); + } + + resource abstract-buffer { } +} diff --git a/wit/deps/io/error.wit b/surface/deps/io/error.wit similarity index 100% rename from wit/deps/io/error.wit rename to surface/deps/io/error.wit diff --git a/wit/deps/io/poll.wit b/surface/deps/io/poll.wit similarity index 100% rename from wit/deps/io/poll.wit rename to surface/deps/io/poll.wit diff --git a/wit/deps/io/streams.wit b/surface/deps/io/streams.wit similarity index 100% rename from wit/deps/io/streams.wit rename to surface/deps/io/streams.wit diff --git a/wit/deps/io/world.wit b/surface/deps/io/world.wit similarity index 100% rename from wit/deps/io/world.wit rename to surface/deps/io/world.wit diff --git a/surface/imports.md b/surface/imports.md new file mode 100644 index 0000000..7917b05 --- /dev/null +++ b/surface/imports.md @@ -0,0 +1,477 @@ +

World imports

+ +

Import interface wasi:graphics-context/graphics-context

+
+

Types

+

resource context

+

resource abstract-buffer

+
+

Functions

+

[constructor]context: func

+
Return values
+ +

[method]context.get-current-buffer: func

+
Params
+ +
Return values
+ +

[method]context.present: func

+

TODO: might want to remove this.

+
Params
+ +

Import interface wasi:io/poll@0.2.0

+

A poll API intended to let users wait for I/O events on multiple handles +at once.

+
+

Types

+

resource pollable

+

pollable represents a single I/O event which may be ready, or not.

+

Functions

+

[method]pollable.ready: func

+

Return the readiness of a pollable. This function never blocks.

+

Returns true when the pollable is ready, and false otherwise.

+
Params
+ +
Return values
+ +

[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.

+
Params
+ +

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.

+
Params
+ +
Return values
+ +

Import interface wasi:surface/surface

+
+

Types

+

type context

+

context

+

+#### `type pollable` +[`pollable`](#pollable) +

+#### `record create-desc` +

Record Fields
+ +

resource surface

+

record resize-event

+
Record Fields
+ +

record frame-event

+
Record Fields
+ +

record pointer-event

+
Record Fields
+ +

enum key

+

corresponds with https://w3c.github.io/uievents-code/#code-value-tables +Unidentified is not included, use option<key> instead.

+
Enum Cases
+ +

record key-event

+
Record Fields
+ +
+

Functions

+

[constructor]surface: func

+
Params
+ +
Return values
+ +

[method]surface.connect-graphics-context: func

+
Params
+ +

[method]surface.height: func

+
Params
+ +
Return values
+ +

[method]surface.width: func

+
Params
+ +
Return values
+ +

[method]surface.request-set-size: func

+
Params
+ +

[method]surface.subscribe-resize: func

+
Params
+ +
Return values
+ +

[method]surface.get-resize: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-frame: func

+
Params
+ +
Return values
+ +

[method]surface.get-frame: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-pointer-up: func

+
Params
+ +
Return values
+ +

[method]surface.get-pointer-up: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-pointer-down: func

+
Params
+ +
Return values
+ +

[method]surface.get-pointer-down: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-pointer-move: func

+
Params
+ +
Return values
+ +

[method]surface.get-pointer-move: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-key-up: func

+
Params
+ +
Return values
+ +

[method]surface.get-key-up: func

+
Params
+ +
Return values
+ +

[method]surface.subscribe-key-down: func

+
Params
+ +
Return values
+ +

[method]surface.get-key-down: func

+
Params
+ +
Return values
+ diff --git a/wit/surface.wit b/surface/surface.wit similarity index 97% rename from wit/surface.wit rename to surface/surface.wit index caf2ff5..cd0e2fe 100644 --- a/wit/surface.wit +++ b/surface/surface.wit @@ -1,7 +1,11 @@ -package wasi:webgpu; +package wasi:surface; + +world imports { + import surface; +} interface surface { - use graphics-context.{context}; + use wasi:graphics-context/graphics-context.{context}; use wasi:io/poll@0.2.0.{pollable}; record create-desc { diff --git a/webgpu/deps.lock b/webgpu/deps.lock new file mode 100644 index 0000000..0f4fc66 --- /dev/null +++ b/webgpu/deps.lock @@ -0,0 +1,4 @@ +[graphics-context] +path = "../graphics-context" +sha256 = "cf022dcf41c7e9f6d3ca8af2f80f523306472a5548d38199d57986fc75aafb7b" +sha512 = "b5cf0248f2cd1dbfbeb500b375e56fecbe8b1ac147b1aece73032543e696e0f7dad3da5aa99fbade290369a065059ae606def00d7d1aa94cde7f19ee03741479" diff --git a/webgpu/deps.toml b/webgpu/deps.toml new file mode 100644 index 0000000..6a3e7e9 --- /dev/null +++ b/webgpu/deps.toml @@ -0,0 +1,2 @@ +[graphics-context] +path = "../graphics-context" diff --git a/webgpu/deps/graphics-context/graphics-context.wit b/webgpu/deps/graphics-context/graphics-context.wit new file mode 100644 index 0000000..97e9950 --- /dev/null +++ b/webgpu/deps/graphics-context/graphics-context.wit @@ -0,0 +1,18 @@ +package wasi:graphics-context; + +world imports { + import graphics-context; +} + +interface graphics-context { + resource context { + constructor(); + + get-current-buffer: func() -> abstract-buffer; + + // TODO: might want to remove this. + present: func(); + } + + resource abstract-buffer { } +} diff --git a/imports.md b/webgpu/imports.md similarity index 88% rename from imports.md rename to webgpu/imports.md index 81ac5a3..aa4c582 100644 --- a/imports.md +++ b/webgpu/imports.md @@ -2,15 +2,12 @@ -

Import interface wasi:webgpu/graphics-context

+

Import interface wasi:graphics-context/graphics-context


Types

resource context

@@ -720,7 +717,7 @@

record gpu-buffer-binding

Record Fields
@@ -755,7 +752,7 @@