Skip to content

Commit

Permalink
Separate into separate packages
Browse files Browse the repository at this point in the history
  • Loading branch information
MendyBerger committed Oct 31, 2024
1 parent f554589 commit fad4b7b
Show file tree
Hide file tree
Showing 27 changed files with 724 additions and 529 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WASI WebGPU+
# WASI-GFX

A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API.

Expand All @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions build-docs.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions frame-buffer/deps.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[graphics-context]
path = "../graphics-context"
sha256 = "cf022dcf41c7e9f6d3ca8af2f80f523306472a5548d38199d57986fc75aafb7b"
sha512 = "b5cf0248f2cd1dbfbeb500b375e56fecbe8b1ac147b1aece73032543e696e0f7dad3da5aa99fbade290369a065059ae606def00d7d1aa94cde7f19ee03741479"
2 changes: 2 additions & 0 deletions frame-buffer/deps.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[graphics-context]
path = "../graphics-context"
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package wasi:webgpu;
package wasi:graphics-context;

world imports {
import graphics-context;
}

interface graphics-context {
resource context {
Expand Down
8 changes: 6 additions & 2 deletions wit/frame-buffer.wit → frame-buffer/frame-buffer.wit
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
85 changes: 85 additions & 0 deletions frame-buffer/imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<h1><a id="imports"></a>World imports</h1>
<ul>
<li>Imports:
<ul>
<li>interface <a href="#wasi_graphics_context_graphics_context"><code>wasi:graphics-context/graphics-context</code></a></li>
<li>interface <a href="#wasi_frame_buffer_frame_buffer"><code>wasi:frame-buffer/frame-buffer</code></a></li>
</ul>
</li>
</ul>
<h2><a id="wasi_graphics_context_graphics_context"></a>Import interface wasi:graphics-context/graphics-context</h2>
<hr />
<h3>Types</h3>
<h4><a id="context"></a><code>resource context</code></h4>
<h4><a id="abstract_buffer"></a><code>resource abstract-buffer</code></h4>
<hr />
<h3>Functions</h3>
<h4><a id="constructor_context"></a><code>[constructor]context: func</code></h4>
<h5>Return values</h5>
<ul>
<li><a id="constructor_context.0"></a> own&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h4><a id="method_context_get_current_buffer"></a><code>[method]context.get-current-buffer: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="method_context_get_current_buffer.self"></a><code>self</code>: borrow&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_context_get_current_buffer.0"></a> own&lt;<a href="#abstract_buffer"><a href="#abstract_buffer"><code>abstract-buffer</code></a></a>&gt;</li>
</ul>
<h4><a id="method_context_present"></a><code>[method]context.present: func</code></h4>
<p>TODO: might want to remove this.</p>
<h5>Params</h5>
<ul>
<li><a id="method_context_present.self"></a><code>self</code>: borrow&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h2><a id="wasi_frame_buffer_frame_buffer"></a>Import interface wasi:frame-buffer/frame-buffer</h2>
<hr />
<h3>Types</h3>
<h4><a id="context"></a><code>type context</code></h4>
<p><a href="#context"><a href="#context"><code>context</code></a></a></p>
<p>
#### <a id="abstract_buffer"></a>`type abstract-buffer`
[`abstract-buffer`](#abstract_buffer)
<p>
#### <a id="device"></a>`resource device`
<h4><a id="buffer"></a><code>resource buffer</code></h4>
<hr />
<h3>Functions</h3>
<h4><a id="constructor_device"></a><code>[constructor]device: func</code></h4>
<h5>Return values</h5>
<ul>
<li><a id="constructor_device.0"></a> own&lt;<a href="#device"><a href="#device"><code>device</code></a></a>&gt;</li>
</ul>
<h4><a id="method_device_connect_graphics_context"></a><code>[method]device.connect-graphics-context: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="method_device_connect_graphics_context.self"></a><code>self</code>: borrow&lt;<a href="#device"><a href="#device"><code>device</code></a></a>&gt;</li>
<li><a id="method_device_connect_graphics_context.context"></a><a href="#context"><code>context</code></a>: borrow&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h4><a id="static_buffer_from_graphics_buffer"></a><code>[static]buffer.from-graphics-buffer: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="static_buffer_from_graphics_buffer.buffer"></a><a href="#buffer"><code>buffer</code></a>: own&lt;<a href="#abstract_buffer"><a href="#abstract_buffer"><code>abstract-buffer</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="static_buffer_from_graphics_buffer.0"></a> own&lt;<a href="#buffer"><a href="#buffer"><code>buffer</code></a></a>&gt;</li>
</ul>
<h4><a id="method_buffer_get"></a><code>[method]buffer.get: func</code></h4>
<p>TODO: This should be replcated with something that doesn't require a copy.</p>
<h5>Params</h5>
<ul>
<li><a id="method_buffer_get.self"></a><code>self</code>: borrow&lt;<a href="#buffer"><a href="#buffer"><code>buffer</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_buffer_get.0"></a> list&lt;<code>u8</code>&gt;</li>
</ul>
<h4><a id="method_buffer_set"></a><code>[method]buffer.set: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="method_buffer_set.self"></a><code>self</code>: borrow&lt;<a href="#buffer"><a href="#buffer"><code>buffer</code></a></a>&gt;</li>
<li><a id="method_buffer_set.val"></a><code>val</code>: list&lt;<code>u8</code>&gt;</li>
</ul>
Empty file added graphics-context/deps.lock
Empty file.
Empty file added graphics-context/deps.toml
Empty file.
18 changes: 18 additions & 0 deletions graphics-context/graphics-context.wit
Original file line number Diff line number Diff line change
@@ -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 { }
}
35 changes: 35 additions & 0 deletions graphics-context/imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1><a id="imports"></a>World imports</h1>
<ul>
<li>Imports:
<ul>
<li>interface <a href="#wasi_graphics_context_graphics_context"><code>wasi:graphics-context/graphics-context</code></a></li>
</ul>
</li>
</ul>
<h2><a id="wasi_graphics_context_graphics_context"></a>Import interface wasi:graphics-context/graphics-context</h2>
<hr />
<h3>Types</h3>
<h4><a id="context"></a><code>resource context</code></h4>
<h4><a id="abstract_buffer"></a><code>resource abstract-buffer</code></h4>
<hr />
<h3>Functions</h3>
<h4><a id="constructor_context"></a><code>[constructor]context: func</code></h4>
<h5>Return values</h5>
<ul>
<li><a id="constructor_context.0"></a> own&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h4><a id="method_context_get_current_buffer"></a><code>[method]context.get-current-buffer: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="method_context_get_current_buffer.self"></a><code>self</code>: borrow&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_context_get_current_buffer.0"></a> own&lt;<a href="#abstract_buffer"><a href="#abstract_buffer"><code>abstract-buffer</code></a></a>&gt;</li>
</ul>
<h4><a id="method_context_present"></a><code>[method]context.present: func</code></h4>
<p>TODO: might want to remove this.</p>
<h5>Params</h5>
<ul>
<li><a id="method_context_present.self"></a><code>self</code>: borrow&lt;<a href="#context"><a href="#context"><code>context</code></a></a>&gt;</li>
</ul>
4 changes: 4 additions & 0 deletions install-wit-deps.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions wit/deps.lock → surface/deps.lock
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions wit/deps.toml → surface/deps.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
io = "https://github.com/WebAssembly/wasi-io/archive/fef02cddb4ac28dcde97bf11a4c7b856833a948f.tar.gz"

[graphics-context]
path = "../graphics-context"
18 changes: 18 additions & 0 deletions surface/deps/graphics-context/graphics-context.wit
Original file line number Diff line number Diff line change
@@ -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 { }
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fad4b7b

Please sign in to comment.