diff --git a/.gitattributes b/.gitattributes index 9d3b6f8..7b48404 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ **/shader/* linguist-language=glsl **/shader/gen/* linguist-generated - +piet-wgpu/shader/* linguist-language=wgsl diff --git a/Cargo.lock b/Cargo.lock index 2de38e1..bcfd743 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -906,6 +906,7 @@ dependencies = [ [[package]] name = "naga" version = "0.10.0" +source = "git+https://github.com/gfx-rs/naga?rev=ddcd5d3121150b2b1beee6e54e9125ff31aaa9a2#ddcd5d3121150b2b1beee6e54e9125ff31aaa9a2" dependencies = [ "bit-set", "bitflags", @@ -1274,7 +1275,7 @@ dependencies = [ ] [[package]] -name = "piet-twgsl" +name = "piet-wgsl" version = "0.1.0" dependencies = [ "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index 1d4503d..dc40744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,6 @@ members = [ ] [patch.crates-io] -naga = { path = "../../dl/naga" } +# Required for metal support to work on wgpu +# TODO: remove when wgpu is upgraded to 0.15 +naga = { git = "https://github.com/gfx-rs/naga", rev="ddcd5d3121150b2b1beee6e54e9125ff31aaa9a2" } diff --git a/piet-wgsl/.gitignore b/piet-wgsl/.gitignore deleted file mode 100644 index 28f0e82..0000000 --- a/piet-wgsl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -.ninja_deps -.ninja_log diff --git a/piet-wgsl/Cargo.toml b/piet-wgsl/Cargo.toml index 9e0150f..020ba92 100644 --- a/piet-wgsl/Cargo.toml +++ b/piet-wgsl/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "piet-twgsl" +name = "piet-wgsl" version = "0.1.0" authors = ["Raph Levien "] license = "MIT/Apache-2.0" diff --git a/piet-wgsl/shader/backdrop.twgsl b/piet-wgsl/shader/backdrop.twgsl index c85aa3d..1618ae4 100644 --- a/piet-wgsl/shader/backdrop.twgsl +++ b/piet-wgsl/shader/backdrop.twgsl @@ -20,10 +20,7 @@ struct Tile { segments: u32, } -struct Config { - width_in_tiles: u32, - height_in_tiles: u32, -} +{{> config}} @group(0) @binding(0) var config: Config; @@ -49,6 +46,7 @@ fn main( backdrop = tiles[ix].backdrop; } sh_backdrop[local_id.x] = backdrop; + // iterate log2(WG_SIZE) times for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) { workgroupBarrier(); if local_id.x >= (1u << i) { diff --git a/piet-wgsl/src/main.rs b/piet-wgsl/src/main.rs index 5e5ea55..95361cd 100644 --- a/piet-wgsl/src/main.rs +++ b/piet-wgsl/src/main.rs @@ -20,7 +20,6 @@ use std::{fs::File, io::BufWriter}; use engine::Engine; -use bytemuck; use render::render; use test_scene::dump_scene_info; use wgpu::{Device, Queue}; diff --git a/piet-wgsl/src/render.rs b/piet-wgsl/src/render.rs index 0672c49..3eec030 100644 --- a/piet-wgsl/src/render.rs +++ b/piet-wgsl/src/render.rs @@ -65,6 +65,7 @@ pub fn render(scene: &Scene, shaders: &Shaders) -> (Recording, BufProxy) { // TODO: more principled size calc let tiles_buf = BufProxy::new(4097 * 8); let segments_buf = BufProxy::new(256 * 24); + recording.clear_all(tiles_buf); recording.dispatch( shaders.path_coarse, (path_coarse_wgs, 1, 1), diff --git a/piet-wgsl/src/template.rs b/piet-wgsl/src/template.rs index fadafb8..3525298 100644 --- a/piet-wgsl/src/template.rs +++ b/piet-wgsl/src/template.rs @@ -25,7 +25,7 @@ impl ShaderTemplate { pub fn new() -> ShaderTemplate { let mut handlebars = Handlebars::new(); handlebars - .register_templates_directory("twgsl", "shader") + .register_templates_directory("twgsl", concat!(env!("CARGO_MANIFEST_DIR"), "/shader")) .unwrap(); handlebars.register_escape_fn(handlebars::no_escape); ShaderTemplate { handlebars }