Auto merge of #383 - pcwalton:webgl-fix, r=pcwalton
Fix WebGL, and add a simple example of WebGL usage
This commit is contained in:
commit
e04f1b7950
|
@ -202,6 +202,24 @@ dependencies = [
|
||||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "canvas-webgl-minimal"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pathfinder_canvas 0.5.0",
|
||||||
|
"pathfinder_color 0.5.0",
|
||||||
|
"pathfinder_content 0.5.0",
|
||||||
|
"pathfinder_geometry 0.5.1",
|
||||||
|
"pathfinder_gl 0.5.0",
|
||||||
|
"pathfinder_gpu 0.5.0",
|
||||||
|
"pathfinder_renderer 0.5.0",
|
||||||
|
"pathfinder_resources 0.5.0",
|
||||||
|
"pathfinder_webgl 0.1.0",
|
||||||
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen-test 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "canvas_glutin_minimal"
|
name = "canvas_glutin_minimal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -324,11 +342,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -460,6 +478,15 @@ dependencies = [
|
||||||
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console_error_panic_hook"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const-random"
|
name = "const-random"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
|
@ -1236,10 +1263,10 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.37"
|
version = "0.3.41"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1833,6 +1860,7 @@ dependencies = [
|
||||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"half 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"half 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"image 0.23.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"image 0.23.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"instant 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pathfinder_color 0.5.0",
|
"pathfinder_color 0.5.0",
|
||||||
"pathfinder_geometry 0.5.1",
|
"pathfinder_geometry 0.5.1",
|
||||||
|
@ -1992,14 +2020,14 @@ name = "pathfinder_webgl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"image 0.23.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"image 0.23.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"js-sys 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pathfinder_geometry 0.5.1",
|
"pathfinder_geometry 0.5.1",
|
||||||
"pathfinder_gpu 0.5.0",
|
"pathfinder_gpu 0.5.0",
|
||||||
"pathfinder_renderer 0.5.0",
|
"pathfinder_renderer 0.5.0",
|
||||||
"pathfinder_resources 0.5.0",
|
"pathfinder_resources 0.5.0",
|
||||||
"pathfinder_simd 0.5.0",
|
"pathfinder_simd 0.5.0",
|
||||||
"wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2058,7 +2086,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.10"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2093,7 +2121,7 @@ name = "quote"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2270,6 +2298,11 @@ dependencies = [
|
||||||
"winapi-util 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-util 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scoped-tls"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scoped_threadpool"
|
name = "scoped_threadpool"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
@ -2293,9 +2326,9 @@ name = "scroll_derive"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2344,9 +2377,9 @@ name = "serde_derive"
|
||||||
version = "1.0.106"
|
version = "1.0.106"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2590,10 +2623,10 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.17"
|
version = "1.0.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -2768,53 +2801,86 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.60"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen-macro 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.60"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen-shared 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-futures"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"js-sys 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.60"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen-macro-support 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.60"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen-backend 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen-shared 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.60"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-test"
|
||||||
|
version = "0.3.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"js-sys 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen-futures 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen-test-macro 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-test-macro"
|
||||||
|
version = "0.3.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-client"
|
name = "wayland-client"
|
||||||
version = "0.21.13"
|
version = "0.21.13"
|
||||||
|
@ -2938,8 +3004,8 @@ name = "web-sys"
|
||||||
version = "0.3.37"
|
version = "0.3.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"js-sys 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3130,6 +3196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum color-backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "65d13f1078cc63c791d0deba0dd43db37c9ec02b311f10bed10b577016f3a957"
|
"checksum color-backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "65d13f1078cc63c791d0deba0dd43db37c9ec02b311f10bed10b577016f3a957"
|
||||||
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
|
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
|
||||||
"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680"
|
"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680"
|
||||||
|
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||||
"checksum const-random 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a"
|
"checksum const-random 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a"
|
||||||
"checksum const-random-macro 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a"
|
"checksum const-random-macro 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a"
|
||||||
"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||||
|
@ -3211,7 +3278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum jni 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ba3cd65bd48a02c50381dc90678744e1cc9842d0c957bf5a4660618df10a0c2"
|
"checksum jni 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ba3cd65bd48a02c50381dc90678744e1cc9842d0c957bf5a4660618df10a0c2"
|
||||||
"checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
"checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||||
"checksum jpeg-decoder 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0256f0aec7352539102a9efbcb75543227b7ab1117e0f95450023af730128451"
|
"checksum jpeg-decoder 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0256f0aec7352539102a9efbcb75543227b7ab1117e0f95450023af730128451"
|
||||||
"checksum js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055"
|
"checksum js-sys 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)" = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916"
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||||
"checksum khronos 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c0711aaa80e6ba6eb1fa8978f1f46bfcb38ceb2f3f33f3736efbff39dac89f50"
|
"checksum khronos 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c0711aaa80e6ba6eb1fa8978f1f46bfcb38ceb2f3f33f3736efbff39dac89f50"
|
||||||
"checksum khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
"checksum khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
|
@ -3271,7 +3338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d"
|
"checksum pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d"
|
||||||
"checksum proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63"
|
"checksum proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63"
|
||||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||||
"checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
"checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||||
"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
"checksum quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
|
"checksum quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
|
||||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||||
|
@ -3297,6 +3364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum rusttype 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0"
|
"checksum rusttype 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0"
|
||||||
"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76"
|
"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76"
|
||||||
"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||||
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||||
"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
"checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1"
|
"checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1"
|
||||||
|
@ -3329,7 +3397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum swf-fixed 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6b212c20df50b382c442a4098d7d9f1c94f0b040f0f0a5d120fa3a82fa51e302"
|
"checksum swf-fixed 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6b212c20df50b382c442a4098d7d9f1c94f0b040f0f0a5d120fa3a82fa51e302"
|
||||||
"checksum swf-parser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "847c41c7add3a5a64524fa5883ba4f2ecaccb2e429df9a3d4ed17ad8e379c15f"
|
"checksum swf-parser 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "847c41c7add3a5a64524fa5883ba4f2ecaccb2e429df9a3d4ed17ad8e379c15f"
|
||||||
"checksum swf-types 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1c05702364986055179557b04f797fecbc0cd1ef12c07536edd254b085b3540"
|
"checksum swf-types 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1c05702364986055179557b04f797fecbc0cd1ef12c07536edd254b085b3540"
|
||||||
"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
"checksum syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
|
||||||
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
||||||
"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
|
"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
|
||||||
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||||
|
@ -3352,11 +3420,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
||||||
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||||
"checksum wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f"
|
"checksum wasm-bindgen 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
|
||||||
"checksum wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd"
|
"checksum wasm-bindgen-backend 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
|
||||||
"checksum wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4"
|
"checksum wasm-bindgen-futures 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dba48d66049d2a6cc8488702e7259ab7afc9043ad0dc5448444f46f2a453b362"
|
||||||
"checksum wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931"
|
"checksum wasm-bindgen-macro 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
|
||||||
"checksum wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639"
|
"checksum wasm-bindgen-macro-support 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
|
||||||
|
"checksum wasm-bindgen-shared 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
|
||||||
|
"checksum wasm-bindgen-test 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "8edfbb0918bc0e8207c38200c9462ba8d03d8276dd99bdca14c08281af61883f"
|
||||||
|
"checksum wasm-bindgen-test-macro 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "343d02640a91e4cd89d81dba8b9047991b4bf103657c1a2d18884808c83642fc"
|
||||||
"checksum wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713"
|
"checksum wayland-client 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713"
|
||||||
"checksum wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
|
"checksum wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)" = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
|
||||||
"checksum wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec"
|
"checksum wayland-commons 0.21.13 (registry+https://github.com/rust-lang/crates.io-index)" = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec"
|
||||||
|
|
|
@ -14,6 +14,7 @@ members = [
|
||||||
"examples/canvas_moire",
|
"examples/canvas_moire",
|
||||||
"examples/canvas_nanovg",
|
"examples/canvas_nanovg",
|
||||||
"examples/canvas_text",
|
"examples/canvas_text",
|
||||||
|
"examples/canvas_webgl_minimal",
|
||||||
"examples/lottie_basic",
|
"examples/lottie_basic",
|
||||||
"examples/swf_basic",
|
"examples/swf_basic",
|
||||||
"geometry",
|
"geometry",
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
[package]
|
||||||
|
name = "canvas-webgl-minimal"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Patrick Walton <pcwalton@mimiga.net>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.63"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_canvas]
|
||||||
|
path = "../../canvas"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_color]
|
||||||
|
path = "../../color"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_content]
|
||||||
|
path = "../../content"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_geometry]
|
||||||
|
path = "../../geometry"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_gl]
|
||||||
|
path = "../../gl"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_gpu]
|
||||||
|
path = "../../gpu"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_renderer]
|
||||||
|
path = "../../renderer"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_resources]
|
||||||
|
path = "../../resources"
|
||||||
|
|
||||||
|
[dependencies.pathfinder_webgl]
|
||||||
|
path = "../../webgl"
|
||||||
|
|
||||||
|
[dependencies.web-sys]
|
||||||
|
version = "0.3"
|
||||||
|
features = ["Window"]
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.13"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
# Tell `rustc` to optimize for small code size.
|
||||||
|
opt-level = "s"
|
|
@ -0,0 +1,69 @@
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<h1><code>wasm-pack-template</code></h1>
|
||||||
|
|
||||||
|
<strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
|
||||||
|
<span> | </span>
|
||||||
|
<a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
[**📚 Read this template tutorial! 📚**][template-docs]
|
||||||
|
|
||||||
|
This template is designed for compiling Rust libraries into WebAssembly and
|
||||||
|
publishing the resulting package to NPM.
|
||||||
|
|
||||||
|
Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
|
||||||
|
templates and usages of `wasm-pack`.
|
||||||
|
|
||||||
|
[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
|
||||||
|
[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html
|
||||||
|
|
||||||
|
## 🚴 Usage
|
||||||
|
|
||||||
|
### 🐑 Use `cargo generate` to Clone this Template
|
||||||
|
|
||||||
|
[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
|
||||||
|
cd my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🛠️ Build with `wasm-pack build`
|
||||||
|
|
||||||
|
```
|
||||||
|
wasm-pack build
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🔬 Test in Headless Browsers with `wasm-pack test`
|
||||||
|
|
||||||
|
```
|
||||||
|
wasm-pack test --headless --firefox
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🎁 Publish to NPM with `wasm-pack publish`
|
||||||
|
|
||||||
|
```
|
||||||
|
wasm-pack publish
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔋 Batteries Included
|
||||||
|
|
||||||
|
* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
|
||||||
|
between WebAssembly and JavaScript.
|
||||||
|
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
|
||||||
|
for logging panic messages to the developer console.
|
||||||
|
* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
|
||||||
|
for small code size.
|
|
@ -0,0 +1,86 @@
|
||||||
|
// pathfinder/examples/canvas_webgl_minimal/src/lib.rs
|
||||||
|
//
|
||||||
|
// Copyright © 2020 The Pathfinder Project Developers.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
use pathfinder_canvas::{Canvas, CanvasFontContext, Path2D};
|
||||||
|
use pathfinder_color::ColorF;
|
||||||
|
use pathfinder_geometry::rect::RectF;
|
||||||
|
use pathfinder_geometry::vector::{vec2f, vec2i};
|
||||||
|
use pathfinder_renderer::concurrent::executor::SequentialExecutor;
|
||||||
|
use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererMode, RendererOptions};
|
||||||
|
use pathfinder_renderer::gpu::renderer::Renderer;
|
||||||
|
use pathfinder_renderer::options::BuildOptions;
|
||||||
|
use pathfinder_resources::embedded::EmbeddedResourceLoader;
|
||||||
|
use pathfinder_webgl::WebGlDevice;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use web_sys::{self, HtmlCanvasElement, WebGl2RenderingContext};
|
||||||
|
|
||||||
|
mod utils;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
fn alert(s: &str);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn rust_main() {
|
||||||
|
utils::set_panic_hook();
|
||||||
|
|
||||||
|
let document = web_sys::window().unwrap().document().unwrap();
|
||||||
|
let canvas = document.get_element_by_id("c").unwrap();
|
||||||
|
let canvas: HtmlCanvasElement = canvas.dyn_into::<HtmlCanvasElement>().unwrap();
|
||||||
|
|
||||||
|
let context = canvas.get_context("webgl2")
|
||||||
|
.unwrap()
|
||||||
|
.unwrap()
|
||||||
|
.dyn_into::<WebGl2RenderingContext>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// Get the real size of the window, taking HiDPI into account.
|
||||||
|
let framebuffer_size = vec2i(canvas.width() as i32, canvas.height() as i32);
|
||||||
|
|
||||||
|
// Create a Pathfinder GL device.
|
||||||
|
let pathfinder_device = WebGlDevice::new(context);
|
||||||
|
|
||||||
|
// Create a Pathfinder renderer.
|
||||||
|
let mode = RendererMode::default_for_device(&pathfinder_device);
|
||||||
|
let options = RendererOptions {
|
||||||
|
dest: DestFramebuffer::full_window(framebuffer_size),
|
||||||
|
background_color: Some(ColorF::white()),
|
||||||
|
..RendererOptions::default()
|
||||||
|
};
|
||||||
|
let resource_loader = EmbeddedResourceLoader::new();
|
||||||
|
let mut renderer = Renderer::new(pathfinder_device, &resource_loader, mode, options);
|
||||||
|
|
||||||
|
// Make a canvas. We're going to draw a house.
|
||||||
|
let font_context = CanvasFontContext::from_system_source();
|
||||||
|
let mut canvas = Canvas::new(framebuffer_size.to_f32()).get_context_2d(font_context);
|
||||||
|
|
||||||
|
// Set line width.
|
||||||
|
canvas.set_line_width(10.0);
|
||||||
|
|
||||||
|
// Draw walls.
|
||||||
|
canvas.stroke_rect(RectF::new(vec2f(75.0, 140.0), vec2f(150.0, 110.0)));
|
||||||
|
|
||||||
|
// Draw door.
|
||||||
|
canvas.fill_rect(RectF::new(vec2f(130.0, 190.0), vec2f(40.0, 60.0)));
|
||||||
|
|
||||||
|
// Draw roof.
|
||||||
|
let mut path = Path2D::new();
|
||||||
|
path.move_to(vec2f(50.0, 140.0));
|
||||||
|
path.line_to(vec2f(150.0, 60.0));
|
||||||
|
path.line_to(vec2f(250.0, 140.0));
|
||||||
|
path.close_path();
|
||||||
|
canvas.stroke_path(path);
|
||||||
|
|
||||||
|
// Render the canvas to screen.
|
||||||
|
let mut scene = canvas.into_canvas().into_scene();
|
||||||
|
scene.build_and_render(&mut renderer, BuildOptions::default(), SequentialExecutor);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
pub fn set_panic_hook() {
|
||||||
|
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||||
|
// `set_panic_hook` function at least once during initialization, and then
|
||||||
|
// we will get better error messages if our code ever panics.
|
||||||
|
//
|
||||||
|
// For more details see
|
||||||
|
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||||
|
#[cfg(feature = "console_error_panic_hook")]
|
||||||
|
console_error_panic_hook::set_once();
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { spawn } = require("child_process");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
let folderName = '.';
|
||||||
|
|
||||||
|
if (process.argv.length >= 3) {
|
||||||
|
folderName = process.argv[2];
|
||||||
|
if (!fs.existsSync(folderName)) {
|
||||||
|
fs.mkdirSync(folderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]);
|
||||||
|
|
||||||
|
clone.on("close", code => {
|
||||||
|
if (code !== 0) {
|
||||||
|
console.error("cloning the template failed!")
|
||||||
|
process.exit(code);
|
||||||
|
} else {
|
||||||
|
console.log("🦀 Rust + 🕸 Wasm = ❤");
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,5 @@
|
||||||
|
language: node_js
|
||||||
|
node_js: "10"
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./node_modules/.bin/webpack
|
|
@ -0,0 +1,201 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,25 @@
|
||||||
|
Copyright (c) [year] [name]
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any
|
||||||
|
person obtaining a copy of this software and associated
|
||||||
|
documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without
|
||||||
|
limitation the rights to use, copy, modify, merge,
|
||||||
|
publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software
|
||||||
|
is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice
|
||||||
|
shall be included in all copies or substantial portions
|
||||||
|
of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||||
|
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||||
|
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||||
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,67 @@
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<h1><code>create-wasm-app</code></h1>
|
||||||
|
|
||||||
|
<strong>An <code>npm init</code> template for kick starting a project that uses NPM packages containing Rust-generated WebAssembly and bundles them with Webpack.</strong>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="https://travis-ci.org/rustwasm/create-wasm-app"><img src="https://img.shields.io/travis/rustwasm/create-wasm-app.svg?style=flat-square" alt="Build Status" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<a href="#usage">Usage</a>
|
||||||
|
<span> | </span>
|
||||||
|
<a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This template is designed for depending on NPM packages that contain
|
||||||
|
Rust-generated WebAssembly and using them to create a Website.
|
||||||
|
|
||||||
|
* Want to create an NPM package with Rust and WebAssembly? [Check out
|
||||||
|
`wasm-pack-template`.](https://github.com/rustwasm/wasm-pack-template)
|
||||||
|
* Want to make a monorepo-style Website without publishing to NPM? Check out
|
||||||
|
[`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template)
|
||||||
|
and/or
|
||||||
|
[`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template).
|
||||||
|
|
||||||
|
## 🚴 Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
npm init wasm-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔋 Batteries Included
|
||||||
|
|
||||||
|
- `.gitignore`: ignores `node_modules`
|
||||||
|
- `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you
|
||||||
|
- `README.md`: the file you are reading now!
|
||||||
|
- `index.html`: a bare bones html document that includes the webpack bundle
|
||||||
|
- `index.js`: example js file with a comment showing how to import and use a wasm pkg
|
||||||
|
- `package.json` and `package-lock.json`:
|
||||||
|
- pulls in devDependencies for using webpack:
|
||||||
|
- [`webpack`](https://www.npmjs.com/package/webpack)
|
||||||
|
- [`webpack-cli`](https://www.npmjs.com/package/webpack-cli)
|
||||||
|
- [`webpack-dev-server`](https://www.npmjs.com/package/webpack-dev-server)
|
||||||
|
- defines a `start` script to run `webpack-dev-server`
|
||||||
|
- `webpack.config.js`: configuration file for bundling your js with webpack
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Licensed under either of
|
||||||
|
|
||||||
|
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
at your option.
|
||||||
|
|
||||||
|
### Contribution
|
||||||
|
|
||||||
|
Unless you explicitly state otherwise, any contribution intentionally
|
||||||
|
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
||||||
|
license, shall be dual licensed as above, without any additional terms or
|
||||||
|
conditions.
|
|
@ -0,0 +1,5 @@
|
||||||
|
// A dependency graph that contains any wasm must all be imported
|
||||||
|
// asynchronously. This `bootstrap.js` file does the single async import, so
|
||||||
|
// that no one else needs to worry about it again.
|
||||||
|
import("./index.js")
|
||||||
|
.catch(e => console.error("Error importing `index.js`:", e, e.stack));
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Hello wasm-pack!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
|
||||||
|
<canvas id=c width=800 height=600></canvas>
|
||||||
|
<script src="./bootstrap.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,3 @@
|
||||||
|
import * as wasm from "canvas_webgl_minimal";
|
||||||
|
|
||||||
|
wasm.rust_main();
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"name": "create-wasm-app",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "create an app to consume rust-generated wasm packages",
|
||||||
|
"main": "index.js",
|
||||||
|
"bin": {
|
||||||
|
"create-wasm-app": ".bin/create-wasm-app.js"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --config webpack.config.js",
|
||||||
|
"start": "webpack-dev-server"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/rustwasm/create-wasm-app.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"webassembly",
|
||||||
|
"wasm",
|
||||||
|
"rust",
|
||||||
|
"webpack"
|
||||||
|
],
|
||||||
|
"author": "Ashley Williams <ashley666ashley@gmail.com>",
|
||||||
|
"license": "(MIT OR Apache-2.0)",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/rustwasm/create-wasm-app/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/rustwasm/create-wasm-app#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"hello-wasm-pack": "^0.1.0",
|
||||||
|
"webpack": "^4.29.3",
|
||||||
|
"webpack-cli": "^3.1.0",
|
||||||
|
"webpack-dev-server": "^3.1.5",
|
||||||
|
"copy-webpack-plugin": "^5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"canvas_webgl_minimal": "file:../pkg"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: "./bootstrap.js",
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
filename: "bootstrap.js",
|
||||||
|
},
|
||||||
|
mode: "development",
|
||||||
|
plugins: [
|
||||||
|
new CopyWebpackPlugin(['index.html'])
|
||||||
|
],
|
||||||
|
};
|
|
@ -19,6 +19,10 @@ version = "0.23"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["png"]
|
features = ["png"]
|
||||||
|
|
||||||
|
[dependencies.instant]
|
||||||
|
version = "0.1"
|
||||||
|
features = ["wasm-bindgen"]
|
||||||
|
|
||||||
[dependencies.pathfinder_color]
|
[dependencies.pathfinder_color]
|
||||||
path = "../color"
|
path = "../color"
|
||||||
version = "0.5"
|
version = "0.5"
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
//! GPU memory management.
|
//! GPU memory management.
|
||||||
|
|
||||||
use crate::{BufferData, BufferTarget, BufferUploadMode, Device, TextureFormat};
|
use crate::{BufferData, BufferTarget, BufferUploadMode, Device, TextureFormat};
|
||||||
|
use instant::Instant;
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use pathfinder_geometry::vector::Vector2I;
|
use pathfinder_geometry::vector::Vector2I;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
// Everything above 16 MB is allocated exactly.
|
// Everything above 16 MB is allocated exactly.
|
||||||
const MAX_BUFFER_SIZE_CLASS: u64 = 16 * 1024 * 1024;
|
const MAX_BUFFER_SIZE_CLASS: u64 = 16 * 1024 * 1024;
|
||||||
|
@ -32,11 +32,13 @@ const DECAY_TIME: f32 = 0.250;
|
||||||
const REUSE_TIME: f32 = 0.015;
|
const REUSE_TIME: f32 = 0.015;
|
||||||
|
|
||||||
pub struct GPUMemoryAllocator<D> where D: Device {
|
pub struct GPUMemoryAllocator<D> where D: Device {
|
||||||
buffers_in_use: FxHashMap<BufferID, BufferAllocation<D>>,
|
general_buffers_in_use: FxHashMap<GeneralBufferID, BufferAllocation<D>>,
|
||||||
|
index_buffers_in_use: FxHashMap<IndexBufferID, BufferAllocation<D>>,
|
||||||
textures_in_use: FxHashMap<TextureID, TextureAllocation<D>>,
|
textures_in_use: FxHashMap<TextureID, TextureAllocation<D>>,
|
||||||
framebuffers_in_use: FxHashMap<FramebufferID, FramebufferAllocation<D>>,
|
framebuffers_in_use: FxHashMap<FramebufferID, FramebufferAllocation<D>>,
|
||||||
free_objects: VecDeque<FreeObject<D>>,
|
free_objects: VecDeque<FreeObject<D>>,
|
||||||
next_buffer_id: BufferID,
|
next_general_buffer_id: GeneralBufferID,
|
||||||
|
next_index_buffer_id: IndexBufferID,
|
||||||
next_texture_id: TextureID,
|
next_texture_id: TextureID,
|
||||||
next_framebuffer_id: FramebufferID,
|
next_framebuffer_id: FramebufferID,
|
||||||
bytes_committed: u64,
|
bytes_committed: u64,
|
||||||
|
@ -67,7 +69,8 @@ struct FreeObject<D> where D: Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FreeObjectKind<D> where D: Device {
|
enum FreeObjectKind<D> where D: Device {
|
||||||
Buffer { id: BufferID, allocation: BufferAllocation<D> },
|
GeneralBuffer { id: GeneralBufferID, allocation: BufferAllocation<D> },
|
||||||
|
IndexBuffer { id: IndexBufferID, allocation: BufferAllocation<D> },
|
||||||
Texture { id: TextureID, allocation: TextureAllocation<D> },
|
Texture { id: TextureID, allocation: TextureAllocation<D> },
|
||||||
Framebuffer { id: FramebufferID, allocation: FramebufferAllocation<D> },
|
Framebuffer { id: FramebufferID, allocation: FramebufferAllocation<D> },
|
||||||
}
|
}
|
||||||
|
@ -79,8 +82,13 @@ pub struct TextureDescriptor {
|
||||||
format: TextureFormat,
|
format: TextureFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vertex or storage buffers.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct BufferID(pub u64);
|
pub struct GeneralBufferID(pub u64);
|
||||||
|
|
||||||
|
// Index buffers.
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct IndexBufferID(pub u64);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct TextureID(pub u64);
|
pub struct TextureID(pub u64);
|
||||||
|
@ -103,11 +111,13 @@ pub struct FramebufferTag(pub &'static str);
|
||||||
impl<D> GPUMemoryAllocator<D> where D: Device {
|
impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
pub fn new() -> GPUMemoryAllocator<D> {
|
pub fn new() -> GPUMemoryAllocator<D> {
|
||||||
GPUMemoryAllocator {
|
GPUMemoryAllocator {
|
||||||
buffers_in_use: FxHashMap::default(),
|
general_buffers_in_use: FxHashMap::default(),
|
||||||
|
index_buffers_in_use: FxHashMap::default(),
|
||||||
textures_in_use: FxHashMap::default(),
|
textures_in_use: FxHashMap::default(),
|
||||||
framebuffers_in_use: FxHashMap::default(),
|
framebuffers_in_use: FxHashMap::default(),
|
||||||
free_objects: VecDeque::new(),
|
free_objects: VecDeque::new(),
|
||||||
next_buffer_id: BufferID(0),
|
next_general_buffer_id: GeneralBufferID(0),
|
||||||
|
next_index_buffer_id: IndexBufferID(0),
|
||||||
next_texture_id: TextureID(0),
|
next_texture_id: TextureID(0),
|
||||||
next_framebuffer_id: FramebufferID(0),
|
next_framebuffer_id: FramebufferID(0),
|
||||||
bytes_committed: 0,
|
bytes_committed: 0,
|
||||||
|
@ -115,7 +125,8 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn allocate_buffer<T>(&mut self, device: &D, size: u64, tag: BufferTag) -> BufferID {
|
pub fn allocate_general_buffer<T>(&mut self, device: &D, size: u64, tag: BufferTag)
|
||||||
|
-> GeneralBufferID {
|
||||||
let mut byte_size = size * mem::size_of::<T>() as u64;
|
let mut byte_size = size * mem::size_of::<T>() as u64;
|
||||||
if byte_size < MAX_BUFFER_SIZE_CLASS {
|
if byte_size < MAX_BUFFER_SIZE_CLASS {
|
||||||
byte_size = byte_size.next_power_of_two();
|
byte_size = byte_size.next_power_of_two();
|
||||||
|
@ -127,14 +138,17 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
match self.free_objects[free_object_index] {
|
match self.free_objects[free_object_index] {
|
||||||
FreeObject {
|
FreeObject {
|
||||||
ref timestamp,
|
ref timestamp,
|
||||||
kind: FreeObjectKind::Buffer { ref allocation, .. },
|
kind: FreeObjectKind::GeneralBuffer { ref allocation, .. },
|
||||||
} if allocation.size == byte_size &&
|
} if allocation.size == byte_size &&
|
||||||
(now - *timestamp).as_secs_f32() >= REUSE_TIME => {}
|
(now - *timestamp).as_secs_f32() >= REUSE_TIME => {}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
}
|
}
|
||||||
|
|
||||||
let (id, mut allocation) = match self.free_objects.remove(free_object_index) {
|
let (id, mut allocation) = match self.free_objects.remove(free_object_index) {
|
||||||
Some(FreeObject { kind: FreeObjectKind::Buffer { id, allocation }, .. }) => {
|
Some(FreeObject {
|
||||||
|
kind: FreeObjectKind::GeneralBuffer { id, allocation },
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
(id, allocation)
|
(id, allocation)
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -142,7 +156,7 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
|
|
||||||
allocation.tag = tag;
|
allocation.tag = tag;
|
||||||
self.bytes_committed += allocation.size;
|
self.bytes_committed += allocation.size;
|
||||||
self.buffers_in_use.insert(id, allocation);
|
self.general_buffers_in_use.insert(id, allocation);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,17 +165,71 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
BufferData::Uninitialized(byte_size as usize),
|
BufferData::Uninitialized(byte_size as usize),
|
||||||
BufferTarget::Vertex);
|
BufferTarget::Vertex);
|
||||||
|
|
||||||
let id = self.next_buffer_id;
|
let id = self.next_general_buffer_id;
|
||||||
self.next_buffer_id.0 += 1;
|
self.next_general_buffer_id.0 += 1;
|
||||||
|
|
||||||
debug!("mapping buffer: {:?} {} ({}x{}) {:?}",
|
debug!("mapping general buffer: {:?} {} ({}x{}) {:?}",
|
||||||
id,
|
id,
|
||||||
byte_size,
|
byte_size,
|
||||||
size,
|
size,
|
||||||
mem::size_of::<T>(),
|
mem::size_of::<T>(),
|
||||||
tag);
|
tag);
|
||||||
|
|
||||||
self.buffers_in_use.insert(id, BufferAllocation { buffer, size: byte_size, tag });
|
self.general_buffers_in_use.insert(id, BufferAllocation { buffer, size: byte_size, tag });
|
||||||
|
self.bytes_allocated += byte_size;
|
||||||
|
self.bytes_committed += byte_size;
|
||||||
|
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn allocate_index_buffer<T>(&mut self, device: &D, size: u64, tag: BufferTag)
|
||||||
|
-> IndexBufferID {
|
||||||
|
let mut byte_size = size * mem::size_of::<T>() as u64;
|
||||||
|
if byte_size < MAX_BUFFER_SIZE_CLASS {
|
||||||
|
byte_size = byte_size.next_power_of_two();
|
||||||
|
}
|
||||||
|
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
|
for free_object_index in 0..self.free_objects.len() {
|
||||||
|
match self.free_objects[free_object_index] {
|
||||||
|
FreeObject {
|
||||||
|
ref timestamp,
|
||||||
|
kind: FreeObjectKind::IndexBuffer { ref allocation, .. },
|
||||||
|
} if allocation.size == byte_size &&
|
||||||
|
(now - *timestamp).as_secs_f32() >= REUSE_TIME => {}
|
||||||
|
_ => continue,
|
||||||
|
}
|
||||||
|
|
||||||
|
let (id, mut allocation) = match self.free_objects.remove(free_object_index) {
|
||||||
|
Some(FreeObject { kind: FreeObjectKind::IndexBuffer { id, allocation }, .. }) => {
|
||||||
|
(id, allocation)
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
allocation.tag = tag;
|
||||||
|
self.bytes_committed += allocation.size;
|
||||||
|
self.index_buffers_in_use.insert(id, allocation);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
let buffer = device.create_buffer(BufferUploadMode::Dynamic);
|
||||||
|
device.allocate_buffer::<u8>(&buffer,
|
||||||
|
BufferData::Uninitialized(byte_size as usize),
|
||||||
|
BufferTarget::Index);
|
||||||
|
|
||||||
|
let id = self.next_index_buffer_id;
|
||||||
|
self.next_index_buffer_id.0 += 1;
|
||||||
|
|
||||||
|
debug!("mapping index buffer: {:?} {} ({}x{}) {:?}",
|
||||||
|
id,
|
||||||
|
byte_size,
|
||||||
|
size,
|
||||||
|
mem::size_of::<T>(),
|
||||||
|
tag);
|
||||||
|
|
||||||
|
self.index_buffers_in_use.insert(id, BufferAllocation { buffer, size: byte_size, tag });
|
||||||
self.bytes_allocated += byte_size;
|
self.bytes_allocated += byte_size;
|
||||||
self.bytes_committed += byte_size;
|
self.bytes_committed += byte_size;
|
||||||
|
|
||||||
|
@ -277,8 +345,15 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
}
|
}
|
||||||
match self.free_objects.pop_front() {
|
match self.free_objects.pop_front() {
|
||||||
None => break,
|
None => break,
|
||||||
Some(FreeObject { kind: FreeObjectKind::Buffer { allocation, .. }, .. }) => {
|
Some(FreeObject {
|
||||||
debug!("purging buffer: {}", allocation.size);
|
kind: FreeObjectKind::GeneralBuffer { allocation, .. },
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
debug!("purging general buffer: {}", allocation.size);
|
||||||
|
self.bytes_allocated -= allocation.size;
|
||||||
|
}
|
||||||
|
Some(FreeObject { kind: FreeObjectKind::IndexBuffer { allocation, .. }, .. }) => {
|
||||||
|
debug!("purging index buffer: {}", allocation.size);
|
||||||
self.bytes_allocated -= allocation.size;
|
self.bytes_allocated -= allocation.size;
|
||||||
}
|
}
|
||||||
Some(FreeObject { kind: FreeObjectKind::Texture { allocation, .. }, .. }) => {
|
Some(FreeObject { kind: FreeObjectKind::Texture { allocation, .. }, .. }) => {
|
||||||
|
@ -293,14 +368,25 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_buffer(&mut self, id: BufferID) {
|
pub fn free_general_buffer(&mut self, id: GeneralBufferID) {
|
||||||
let allocation = self.buffers_in_use
|
let allocation = self.general_buffers_in_use
|
||||||
.remove(&id)
|
.remove(&id)
|
||||||
.expect("Attempted to free unallocated buffer!");
|
.expect("Attempted to free unallocated general buffer!");
|
||||||
self.bytes_committed -= allocation.size;
|
self.bytes_committed -= allocation.size;
|
||||||
self.free_objects.push_back(FreeObject {
|
self.free_objects.push_back(FreeObject {
|
||||||
timestamp: Instant::now(),
|
timestamp: Instant::now(),
|
||||||
kind: FreeObjectKind::Buffer { id, allocation },
|
kind: FreeObjectKind::GeneralBuffer { id, allocation },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn free_index_buffer(&mut self, id: IndexBufferID) {
|
||||||
|
let allocation = self.index_buffers_in_use
|
||||||
|
.remove(&id)
|
||||||
|
.expect("Attempted to free unallocated index buffer!");
|
||||||
|
self.bytes_committed -= allocation.size;
|
||||||
|
self.free_objects.push_back(FreeObject {
|
||||||
|
timestamp: Instant::now(),
|
||||||
|
kind: FreeObjectKind::IndexBuffer { id, allocation },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +414,12 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_buffer(&self, id: BufferID) -> &D::Buffer {
|
pub fn get_general_buffer(&self, id: GeneralBufferID) -> &D::Buffer {
|
||||||
&self.buffers_in_use[&id].buffer
|
&self.general_buffers_in_use[&id].buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_index_buffer(&self, id: IndexBufferID) -> &D::Buffer {
|
||||||
|
&self.index_buffers_in_use[&id].buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_texture(&self, id: TextureID) -> &D::Texture {
|
pub fn get_texture(&self, id: TextureID) -> &D::Texture {
|
||||||
|
@ -355,11 +445,19 @@ impl<D> GPUMemoryAllocator<D> where D: Device {
|
||||||
println!("GPU memory dump");
|
println!("GPU memory dump");
|
||||||
println!("---------------");
|
println!("---------------");
|
||||||
|
|
||||||
println!("Buffers:");
|
println!("General buffers:");
|
||||||
let mut ids: Vec<BufferID> = self.buffers_in_use.keys().cloned().collect();
|
let mut ids: Vec<GeneralBufferID> = self.general_buffers_in_use.keys().cloned().collect();
|
||||||
ids.sort();
|
ids.sort();
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let allocation = &self.buffers_in_use[&id];
|
let allocation = &self.general_buffers_in_use[&id];
|
||||||
|
println!("id {:?}: {:?} ({:?} B)", id, allocation.tag, allocation.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Index buffers:");
|
||||||
|
let mut ids: Vec<IndexBufferID> = self.index_buffers_in_use.keys().cloned().collect();
|
||||||
|
ids.sort();
|
||||||
|
for id in ids {
|
||||||
|
let allocation = &self.index_buffers_in_use[&id];
|
||||||
println!("id {:?}: {:?} ({:?} B)", id, allocation.tag, allocation.size);
|
println!("id {:?}: {:?} ({:?} B)", id, allocation.tag, allocation.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,10 @@ serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
smallvec = "1.2"
|
smallvec = "1.2"
|
||||||
vec_map = "0.8"
|
vec_map = "0.8"
|
||||||
instant = { version = "0.1.2", features = ["wasm-bindgen"] }
|
|
||||||
|
[dependencies.instant]
|
||||||
|
version = "0.1"
|
||||||
|
features = ["wasm-bindgen"]
|
||||||
|
|
||||||
[dependencies.pathfinder_color]
|
[dependencies.pathfinder_color]
|
||||||
path = "../color"
|
path = "../color"
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::gpu_data::{TileBatchTexture, TilePathInfoD3D11};
|
||||||
use byte_slice_cast::AsSliceOf;
|
use byte_slice_cast::AsSliceOf;
|
||||||
use pathfinder_geometry::transform2d::Transform2F;
|
use pathfinder_geometry::transform2d::Transform2F;
|
||||||
use pathfinder_geometry::vector::Vector2F;
|
use pathfinder_geometry::vector::Vector2F;
|
||||||
use pathfinder_gpu::allocator::{BufferID, BufferTag, GPUMemoryAllocator};
|
use pathfinder_gpu::allocator::{BufferTag, GeneralBufferID, GPUMemoryAllocator};
|
||||||
use pathfinder_gpu::{BufferTarget, ComputeDimensions, ComputeState, Device, ImageAccess};
|
use pathfinder_gpu::{BufferTarget, ComputeDimensions, ComputeState, Device, ImageAccess};
|
||||||
use pathfinder_gpu::{RenderTarget, UniformData};
|
use pathfinder_gpu::{RenderTarget, UniformData};
|
||||||
use pathfinder_resources::ResourceLoader;
|
use pathfinder_resources::ResourceLoader;
|
||||||
|
@ -62,22 +62,23 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
|
|
||||||
fn bound(&mut self,
|
fn bound(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
tile_count: u32,
|
tile_count: u32,
|
||||||
tile_path_info: &[TilePathInfoD3D11]) {
|
tile_path_info: &[TilePathInfoD3D11]) {
|
||||||
let bound_program = &self.programs.bound_program;
|
let bound_program = &self.programs.bound_program;
|
||||||
|
|
||||||
let path_info_buffer_id =
|
let path_info_buffer_id =
|
||||||
core.allocator.allocate_buffer::<TilePathInfoD3D11>(&core.device,
|
core.allocator
|
||||||
tile_path_info.len() as u64,
|
.allocate_general_buffer::<TilePathInfoD3D11>(&core.device,
|
||||||
BufferTag("TilePathInfoD3D11"));
|
tile_path_info.len() as u64,
|
||||||
let tile_path_info_buffer = core.allocator.get_buffer(path_info_buffer_id);
|
BufferTag("TilePathInfoD3D11"));
|
||||||
|
let tile_path_info_buffer = core.allocator.get_general_buffer(path_info_buffer_id);
|
||||||
core.device.upload_to_buffer(tile_path_info_buffer,
|
core.device.upload_to_buffer(tile_path_info_buffer,
|
||||||
0,
|
0,
|
||||||
tile_path_info,
|
tile_path_info,
|
||||||
BufferTarget::Storage);
|
BufferTarget::Storage);
|
||||||
|
|
||||||
let tiles_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
|
|
||||||
let timer_query = core.timer_query_cache.start_timing_draw_call(&core.device,
|
let timer_query = core.timer_query_cache.start_timing_draw_call(&core.device,
|
||||||
&core.options);
|
&core.options);
|
||||||
|
@ -105,7 +106,7 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
core.finish_timing_draw_call(&timer_query);
|
core.finish_timing_draw_call(&timer_query);
|
||||||
core.current_timer.as_mut().unwrap().push_query(TimeCategory::Other, timer_query);
|
core.current_timer.as_mut().unwrap().push_query(TimeCategory::Other, timer_query);
|
||||||
|
|
||||||
core.allocator.free_buffer(path_info_buffer_id);
|
core.allocator.free_general_buffer(path_info_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload_propagate_metadata(&mut self,
|
fn upload_propagate_metadata(&mut self,
|
||||||
|
@ -114,20 +115,21 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
backdrops: &[BackdropInfoD3D11])
|
backdrops: &[BackdropInfoD3D11])
|
||||||
-> PropagateMetadataBufferIDsD3D11 {
|
-> PropagateMetadataBufferIDsD3D11 {
|
||||||
let propagate_metadata_storage_id =
|
let propagate_metadata_storage_id =
|
||||||
core.allocator
|
core.allocator.allocate_general_buffer::<PropagateMetadataD3D11>(
|
||||||
.allocate_buffer::<PropagateMetadataD3D11>(&core.device,
|
&core.device,
|
||||||
propagate_metadata.len() as u64,
|
propagate_metadata.len() as u64,
|
||||||
BufferTag("PropagateMetadataD3D11"));
|
BufferTag("PropagateMetadataD3D11"));
|
||||||
let propagate_metadata_buffer = core.allocator.get_buffer(propagate_metadata_storage_id);
|
let propagate_metadata_buffer =
|
||||||
|
core.allocator.get_general_buffer(propagate_metadata_storage_id);
|
||||||
core.device.upload_to_buffer(propagate_metadata_buffer,
|
core.device.upload_to_buffer(propagate_metadata_buffer,
|
||||||
0,
|
0,
|
||||||
propagate_metadata,
|
propagate_metadata,
|
||||||
BufferTarget::Storage);
|
BufferTarget::Storage);
|
||||||
|
|
||||||
let backdrops_storage_id =
|
let backdrops_storage_id = core.allocator.allocate_general_buffer::<BackdropInfoD3D11>(
|
||||||
core.allocator.allocate_buffer::<BackdropInfoD3D11>(&core.device,
|
&core.device,
|
||||||
backdrops.len() as u64,
|
backdrops.len() as u64,
|
||||||
BufferTag("BackdropInfoD3D11"));
|
BufferTag("BackdropInfoD3D11"));
|
||||||
|
|
||||||
PropagateMetadataBufferIDsD3D11 {
|
PropagateMetadataBufferIDsD3D11 {
|
||||||
propagate_metadata: propagate_metadata_storage_id,
|
propagate_metadata: propagate_metadata_storage_id,
|
||||||
|
@ -137,9 +139,9 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
|
|
||||||
fn upload_initial_backdrops(&self,
|
fn upload_initial_backdrops(&self,
|
||||||
core: &RendererCore<D>,
|
core: &RendererCore<D>,
|
||||||
backdrops_buffer_id: BufferID,
|
backdrops_buffer_id: GeneralBufferID,
|
||||||
backdrops: &[BackdropInfoD3D11]) {
|
backdrops: &[BackdropInfoD3D11]) {
|
||||||
let backdrops_buffer = core.allocator.get_buffer(backdrops_buffer_id);
|
let backdrops_buffer = core.allocator.get_general_buffer(backdrops_buffer_id);
|
||||||
core.device.upload_to_buffer(backdrops_buffer, 0, backdrops, BufferTarget::Storage);
|
core.device.upload_to_buffer(backdrops_buffer, 0, backdrops, BufferTarget::Storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,28 +149,29 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
microlines_storage: &MicrolinesBufferIDsD3D11,
|
microlines_storage: &MicrolinesBufferIDsD3D11,
|
||||||
propagate_metadata_buffer_ids: &PropagateMetadataBufferIDsD3D11,
|
propagate_metadata_buffer_ids: &PropagateMetadataBufferIDsD3D11,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
z_buffer_id: BufferID)
|
z_buffer_id: GeneralBufferID)
|
||||||
-> Option<FillBufferInfoD3D11> {
|
-> Option<FillBufferInfoD3D11> {
|
||||||
let bin_program = &self.programs.bin_program;
|
let bin_program = &self.programs.bin_program;
|
||||||
|
|
||||||
let fill_vertex_buffer_id =
|
let fill_vertex_buffer_id =
|
||||||
core.allocator.allocate_buffer::<Fill>(&core.device,
|
core.allocator.allocate_general_buffer::<Fill>(&core.device,
|
||||||
self.allocated_fill_count as u64,
|
self.allocated_fill_count as u64,
|
||||||
BufferTag("Fill"));
|
BufferTag("Fill"));
|
||||||
|
|
||||||
let fill_vertex_buffer = core.allocator.get_buffer(fill_vertex_buffer_id);
|
let fill_vertex_buffer = core.allocator.get_general_buffer(fill_vertex_buffer_id);
|
||||||
let microlines_buffer = core.allocator.get_buffer(microlines_storage.buffer_id);
|
let microlines_buffer = core.allocator.get_general_buffer(microlines_storage.buffer_id);
|
||||||
let tiles_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
let propagate_metadata_buffer =
|
let propagate_metadata_buffer =
|
||||||
core.allocator.get_buffer(propagate_metadata_buffer_ids.propagate_metadata);
|
core.allocator.get_general_buffer(propagate_metadata_buffer_ids.propagate_metadata);
|
||||||
let backdrops_buffer = core.allocator.get_buffer(propagate_metadata_buffer_ids.backdrops);
|
let backdrops_buffer =
|
||||||
|
core.allocator.get_general_buffer(propagate_metadata_buffer_ids.backdrops);
|
||||||
|
|
||||||
// Upload fill indirect draw params to header of the Z-buffer.
|
// Upload fill indirect draw params to header of the Z-buffer.
|
||||||
//
|
//
|
||||||
// This is in the Z-buffer, not its own buffer, to work around the 8 SSBO limitation on
|
// This is in the Z-buffer, not its own buffer, to work around the 8 SSBO limitation on
|
||||||
// some drivers (#373).
|
// some drivers (#373).
|
||||||
let z_buffer = core.allocator.get_buffer(z_buffer_id);
|
let z_buffer = core.allocator.get_general_buffer(z_buffer_id);
|
||||||
let indirect_draw_params = [6, 0, 0, 0, 0, microlines_storage.count, 0, 0];
|
let indirect_draw_params = [6, 0, 0, 0, 0, microlines_storage.count, 0, 0];
|
||||||
core.device.upload_to_buffer::<u32>(&z_buffer,
|
core.device.upload_to_buffer::<u32>(&z_buffer,
|
||||||
0,
|
0,
|
||||||
|
@ -233,10 +236,10 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
self.scene_buffers.upload(&mut core.allocator, &core.device, draw_segments, clip_segments);
|
self.scene_buffers.upload(&mut core.allocator, &core.device, draw_segments, clip_segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_tiles(&mut self, core: &mut RendererCore<D>, tile_count: u32) -> BufferID {
|
fn allocate_tiles(&mut self, core: &mut RendererCore<D>, tile_count: u32) -> GeneralBufferID {
|
||||||
core.allocator.allocate_buffer::<TileD3D11>(&core.device,
|
core.allocator.allocate_general_buffer::<TileD3D11>(&core.device,
|
||||||
tile_count as u64,
|
tile_count as u64,
|
||||||
BufferTag("TileD3D11"))
|
BufferTag("TileD3D11"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dice_segments(&mut self,
|
fn dice_segments(&mut self,
|
||||||
|
@ -248,23 +251,24 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
-> Option<MicrolinesBufferIDsD3D11> {
|
-> Option<MicrolinesBufferIDsD3D11> {
|
||||||
let dice_program = &self.programs.dice_program;
|
let dice_program = &self.programs.dice_program;
|
||||||
|
|
||||||
let microlines_buffer_id =
|
let microlines_buffer_id = core.allocator.allocate_general_buffer::<MicrolineD3D11>(
|
||||||
core.allocator.allocate_buffer::<MicrolineD3D11>(&core.device,
|
&core.device,
|
||||||
self.allocated_microline_count as u64,
|
self.allocated_microline_count as u64,
|
||||||
BufferTag("MicrolineD3D11"));
|
BufferTag("MicrolineD3D11"));
|
||||||
let dice_metadata_buffer_id =
|
let dice_metadata_buffer_id = core.allocator.allocate_general_buffer::<DiceMetadataD3D11>(
|
||||||
core.allocator.allocate_buffer::<DiceMetadataD3D11>(&core.device,
|
&core.device,
|
||||||
dice_metadata.len() as u64,
|
dice_metadata.len() as u64,
|
||||||
BufferTag("DiceMetadataD3D11"));
|
BufferTag("DiceMetadataD3D11"));
|
||||||
let dice_indirect_draw_params_buffer_id =
|
let dice_indirect_draw_params_buffer_id = core.allocator.allocate_general_buffer::<u32>(
|
||||||
core.allocator.allocate_buffer::<u32>(&core.device,
|
&core.device,
|
||||||
8,
|
8,
|
||||||
BufferTag("DiceIndirectDrawParamsD3D11"));
|
BufferTag("DiceIndirectDrawParamsD3D11"));
|
||||||
|
|
||||||
let microlines_buffer = core.allocator.get_buffer(microlines_buffer_id);
|
let microlines_buffer = core.allocator.get_general_buffer(microlines_buffer_id);
|
||||||
let dice_metadata_storage_buffer = core.allocator.get_buffer(dice_metadata_buffer_id);
|
let dice_metadata_storage_buffer =
|
||||||
|
core.allocator.get_general_buffer(dice_metadata_buffer_id);
|
||||||
let dice_indirect_draw_params_buffer =
|
let dice_indirect_draw_params_buffer =
|
||||||
core.allocator.get_buffer(dice_indirect_draw_params_buffer_id);
|
core.allocator.get_general_buffer(dice_indirect_draw_params_buffer_id);
|
||||||
|
|
||||||
let scene_buffers = &self.scene_buffers;
|
let scene_buffers = &self.scene_buffers;
|
||||||
let scene_source_buffers = match path_source {
|
let scene_source_buffers = match path_source {
|
||||||
|
@ -278,11 +282,10 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
..
|
..
|
||||||
} = *scene_source_buffers;
|
} = *scene_source_buffers;
|
||||||
|
|
||||||
let points_buffer =
|
let points_buffer = core.allocator.get_general_buffer(
|
||||||
core.allocator.get_buffer(points_buffer_id.expect("Where's the points buffer?"));
|
points_buffer_id.expect("Where's the points buffer?"));
|
||||||
let point_indices_buffer =
|
let point_indices_buffer = core.allocator.get_general_buffer(
|
||||||
core.allocator
|
point_indices_buffer_id.expect("Where's the point indices buffer?"));
|
||||||
.get_buffer(point_indices_buffer_id.expect("Where's the point indices buffer?"));
|
|
||||||
|
|
||||||
core.device.upload_to_buffer(dice_indirect_draw_params_buffer,
|
core.device.upload_to_buffer(dice_indirect_draw_params_buffer,
|
||||||
0,
|
0,
|
||||||
|
@ -335,8 +338,8 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
let indirect_compute_params = core.device.recv_buffer(&indirect_compute_params_receiver);
|
let indirect_compute_params = core.device.recv_buffer(&indirect_compute_params_receiver);
|
||||||
let indirect_compute_params: &[u32] = indirect_compute_params.as_slice_of().unwrap();
|
let indirect_compute_params: &[u32] = indirect_compute_params.as_slice_of().unwrap();
|
||||||
|
|
||||||
core.allocator.free_buffer(dice_metadata_buffer_id);
|
core.allocator.free_general_buffer(dice_metadata_buffer_id);
|
||||||
core.allocator.free_buffer(dice_indirect_draw_params_buffer_id);
|
core.allocator.free_general_buffer(dice_indirect_draw_params_buffer_id);
|
||||||
|
|
||||||
let microline_count =
|
let microline_count =
|
||||||
indirect_compute_params[BIN_INDIRECT_DRAW_PARAMS_MICROLINE_COUNT_INDEX];
|
indirect_compute_params[BIN_INDIRECT_DRAW_PARAMS_MICROLINE_COUNT_INDEX];
|
||||||
|
@ -351,22 +354,22 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
fn draw_fills(&mut self,
|
fn draw_fills(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
fill_storage_info: &FillBufferInfoD3D11,
|
fill_storage_info: &FillBufferInfoD3D11,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
alpha_tiles_buffer_id: BufferID,
|
alpha_tiles_buffer_id: GeneralBufferID,
|
||||||
propagate_tiles_info: &PropagateTilesInfoD3D11) {
|
propagate_tiles_info: &PropagateTilesInfoD3D11) {
|
||||||
let &FillBufferInfoD3D11 { fill_vertex_buffer_id } = fill_storage_info;
|
let &FillBufferInfoD3D11 { fill_vertex_buffer_id } = fill_storage_info;
|
||||||
let &PropagateTilesInfoD3D11 { ref alpha_tile_range } = propagate_tiles_info;
|
let &PropagateTilesInfoD3D11 { ref alpha_tile_range } = propagate_tiles_info;
|
||||||
|
|
||||||
let fill_program = &self.programs.fill_program;
|
let fill_program = &self.programs.fill_program;
|
||||||
let fill_vertex_buffer = core.allocator.get_buffer(fill_vertex_buffer_id);
|
let fill_vertex_buffer = core.allocator.get_general_buffer(fill_vertex_buffer_id);
|
||||||
|
|
||||||
let mask_storage = core.mask_storage.as_ref().expect("Where's the mask storage?");
|
let mask_storage = core.mask_storage.as_ref().expect("Where's the mask storage?");
|
||||||
let mask_framebuffer_id = mask_storage.framebuffer_id;
|
let mask_framebuffer_id = mask_storage.framebuffer_id;
|
||||||
let mask_framebuffer = core.allocator.get_framebuffer(mask_framebuffer_id);
|
let mask_framebuffer = core.allocator.get_framebuffer(mask_framebuffer_id);
|
||||||
let image_texture = core.device.framebuffer_texture(mask_framebuffer);
|
let image_texture = core.device.framebuffer_texture(mask_framebuffer);
|
||||||
|
|
||||||
let tiles_d3d11_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_d3d11_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
let alpha_tiles_buffer = core.allocator.get_buffer(alpha_tiles_buffer_id);
|
let alpha_tiles_buffer = core.allocator.get_general_buffer(alpha_tiles_buffer_id);
|
||||||
|
|
||||||
let area_lut_texture = core.allocator.get_texture(core.area_lut_texture_id);
|
let area_lut_texture = core.allocator.get_texture(core.area_lut_texture_id);
|
||||||
|
|
||||||
|
@ -491,7 +494,7 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
let fill_buffer_info =
|
let fill_buffer_info =
|
||||||
fill_buffer_info.expect("Ran out of space for fills when binning!");
|
fill_buffer_info.expect("Ran out of space for fills when binning!");
|
||||||
|
|
||||||
core.allocator.free_buffer(microlines_storage.buffer_id);
|
core.allocator.free_general_buffer(microlines_storage.buffer_id);
|
||||||
|
|
||||||
// TODO(pcwalton): If we run out of space for alpha tile indices, propagate
|
// TODO(pcwalton): If we run out of space for alpha tile indices, propagate
|
||||||
// multiple times.
|
// multiple times.
|
||||||
|
@ -508,7 +511,7 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
&propagate_metadata_buffer_ids,
|
&propagate_metadata_buffer_ids,
|
||||||
clip_buffer_ids.as_ref());
|
clip_buffer_ids.as_ref());
|
||||||
|
|
||||||
core.allocator.free_buffer(propagate_metadata_buffer_ids.backdrops);
|
core.allocator.free_general_buffer(propagate_metadata_buffer_ids.backdrops);
|
||||||
|
|
||||||
// FIXME(pcwalton): Don't unconditionally pass true for copying here.
|
// FIXME(pcwalton): Don't unconditionally pass true for copying here.
|
||||||
core.reallocate_alpha_tile_pages_if_necessary(true);
|
core.reallocate_alpha_tile_pages_if_necessary(true);
|
||||||
|
@ -518,8 +521,8 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
alpha_tiles_buffer_id,
|
alpha_tiles_buffer_id,
|
||||||
&propagate_tiles_info);
|
&propagate_tiles_info);
|
||||||
|
|
||||||
core.allocator.free_buffer(fill_buffer_info.fill_vertex_buffer_id);
|
core.allocator.free_general_buffer(fill_buffer_info.fill_vertex_buffer_id);
|
||||||
core.allocator.free_buffer(alpha_tiles_buffer_id);
|
core.allocator.free_general_buffer(alpha_tiles_buffer_id);
|
||||||
|
|
||||||
// FIXME(pcwalton): This seems like the wrong place to do this...
|
// FIXME(pcwalton): This seems like the wrong place to do this...
|
||||||
self.sort_tiles(core, tiles_d3d11_buffer_id, first_tile_map_buffer_id, z_buffer_id);
|
self.sort_tiles(core, tiles_d3d11_buffer_id, first_tile_map_buffer_id, z_buffer_id);
|
||||||
|
@ -537,35 +540,36 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
fn propagate_tiles(&mut self,
|
fn propagate_tiles(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
column_count: u32,
|
column_count: u32,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
z_buffer_id: BufferID,
|
z_buffer_id: GeneralBufferID,
|
||||||
first_tile_map_buffer_id: BufferID,
|
first_tile_map_buffer_id: GeneralBufferID,
|
||||||
alpha_tiles_buffer_id: BufferID,
|
alpha_tiles_buffer_id: GeneralBufferID,
|
||||||
propagate_metadata_buffer_ids: &PropagateMetadataBufferIDsD3D11,
|
propagate_metadata_buffer_ids: &PropagateMetadataBufferIDsD3D11,
|
||||||
clip_buffer_ids: Option<&ClipBufferIDs>)
|
clip_buffer_ids: Option<&ClipBufferIDs>)
|
||||||
-> PropagateTilesInfoD3D11 {
|
-> PropagateTilesInfoD3D11 {
|
||||||
let propagate_program = &self.programs.propagate_program;
|
let propagate_program = &self.programs.propagate_program;
|
||||||
|
|
||||||
let tiles_d3d11_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_d3d11_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
let propagate_metadata_storage_buffer =
|
let propagate_metadata_storage_buffer =
|
||||||
core.allocator.get_buffer(propagate_metadata_buffer_ids.propagate_metadata);
|
core.allocator.get_general_buffer(propagate_metadata_buffer_ids.propagate_metadata);
|
||||||
let backdrops_storage_buffer =
|
let backdrops_storage_buffer =
|
||||||
core.allocator.get_buffer(propagate_metadata_buffer_ids.backdrops);
|
core.allocator.get_general_buffer(propagate_metadata_buffer_ids.backdrops);
|
||||||
|
|
||||||
// TODO(pcwalton): Zero out the Z-buffer on GPU?
|
// TODO(pcwalton): Zero out the Z-buffer on GPU?
|
||||||
let z_buffer = core.allocator.get_buffer(z_buffer_id);
|
let z_buffer = core.allocator.get_general_buffer(z_buffer_id);
|
||||||
let z_buffer_size = core.tile_size();
|
let z_buffer_size = core.tile_size();
|
||||||
let tile_area = z_buffer_size.area() as usize;
|
let tile_area = z_buffer_size.area() as usize;
|
||||||
core.device.upload_to_buffer(z_buffer, 0, &vec![0i32; tile_area], BufferTarget::Storage);
|
core.device.upload_to_buffer(z_buffer, 0, &vec![0i32; tile_area], BufferTarget::Storage);
|
||||||
|
|
||||||
// TODO(pcwalton): Initialize the first tiles buffer on GPU?
|
// TODO(pcwalton): Initialize the first tiles buffer on GPU?
|
||||||
let first_tile_map_storage_buffer = core.allocator.get_buffer(first_tile_map_buffer_id);
|
let first_tile_map_storage_buffer = core.allocator
|
||||||
|
.get_general_buffer(first_tile_map_buffer_id);
|
||||||
core.device.upload_to_buffer::<FirstTileD3D11>(&first_tile_map_storage_buffer,
|
core.device.upload_to_buffer::<FirstTileD3D11>(&first_tile_map_storage_buffer,
|
||||||
0,
|
0,
|
||||||
&vec![FirstTileD3D11::default(); tile_area],
|
&vec![FirstTileD3D11::default(); tile_area],
|
||||||
BufferTarget::Storage);
|
BufferTarget::Storage);
|
||||||
|
|
||||||
let alpha_tiles_storage_buffer = core.allocator.get_buffer(alpha_tiles_buffer_id);
|
let alpha_tiles_storage_buffer = core.allocator.get_general_buffer(alpha_tiles_buffer_id);
|
||||||
|
|
||||||
let mut storage_buffers = vec![
|
let mut storage_buffers = vec![
|
||||||
(&propagate_program.draw_metadata_storage_buffer, propagate_metadata_storage_buffer),
|
(&propagate_program.draw_metadata_storage_buffer, propagate_metadata_storage_buffer),
|
||||||
|
@ -580,8 +584,9 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
Some(clip_buffer_ids) => {
|
Some(clip_buffer_ids) => {
|
||||||
let clip_metadata_buffer_id =
|
let clip_metadata_buffer_id =
|
||||||
clip_buffer_ids.metadata.expect("Where's the clip metadata storage?");
|
clip_buffer_ids.metadata.expect("Where's the clip metadata storage?");
|
||||||
let clip_metadata_buffer = core.allocator.get_buffer(clip_metadata_buffer_id);
|
let clip_metadata_buffer = core.allocator
|
||||||
let clip_tile_buffer = core.allocator.get_buffer(clip_buffer_ids.tiles);
|
.get_general_buffer(clip_metadata_buffer_id);
|
||||||
|
let clip_tile_buffer = core.allocator.get_general_buffer(clip_buffer_ids.tiles);
|
||||||
storage_buffers.push((&propagate_program.clip_metadata_storage_buffer,
|
storage_buffers.push((&propagate_program.clip_metadata_storage_buffer,
|
||||||
clip_metadata_buffer));
|
clip_metadata_buffer));
|
||||||
storage_buffers.push((&propagate_program.clip_tiles_storage_buffer,
|
storage_buffers.push((&propagate_program.clip_tiles_storage_buffer,
|
||||||
|
@ -641,14 +646,14 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
|
|
||||||
fn sort_tiles(&mut self,
|
fn sort_tiles(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
first_tile_map_buffer_id: BufferID,
|
first_tile_map_buffer_id: GeneralBufferID,
|
||||||
z_buffer_id: BufferID) {
|
z_buffer_id: GeneralBufferID) {
|
||||||
let sort_program = &self.programs.sort_program;
|
let sort_program = &self.programs.sort_program;
|
||||||
|
|
||||||
let tiles_d3d11_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_d3d11_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
let first_tile_map_buffer = core.allocator.get_buffer(first_tile_map_buffer_id);
|
let first_tile_map_buffer = core.allocator.get_general_buffer(first_tile_map_buffer_id);
|
||||||
let z_buffer = core.allocator.get_buffer(z_buffer_id);
|
let z_buffer = core.allocator.get_general_buffer(z_buffer_id);
|
||||||
|
|
||||||
let tile_count = core.framebuffer_tile_size().area();
|
let tile_count = core.framebuffer_tile_size().area();
|
||||||
|
|
||||||
|
@ -677,30 +682,32 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
core.current_timer.as_mut().unwrap().push_query(TimeCategory::Other, timer_query);
|
core.current_timer.as_mut().unwrap().push_query(TimeCategory::Other, timer_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_first_tile_map(&mut self, core: &mut RendererCore<D>) -> BufferID {
|
fn allocate_first_tile_map(&mut self, core: &mut RendererCore<D>) -> GeneralBufferID {
|
||||||
core.allocator.allocate_buffer::<FirstTileD3D11>(&core.device,
|
core.allocator.allocate_general_buffer::<FirstTileD3D11>(&core.device,
|
||||||
core.tile_size().area() as u64,
|
core.tile_size().area() as u64,
|
||||||
BufferTag("FirstTileD3D11"))
|
BufferTag("FirstTileD3D11"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_alpha_tile_info(&mut self, core: &mut RendererCore<D>, index_count: u32)
|
fn allocate_alpha_tile_info(&mut self, core: &mut RendererCore<D>, index_count: u32)
|
||||||
-> BufferID {
|
-> GeneralBufferID {
|
||||||
core.allocator.allocate_buffer::<AlphaTileD3D11>(&core.device,
|
core.allocator.allocate_general_buffer::<AlphaTileD3D11>(&core.device,
|
||||||
index_count as u64,
|
index_count as u64,
|
||||||
BufferTag("AlphaTileD3D11"))
|
BufferTag("AlphaTileD3D11"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_z_buffer(&mut self, core: &mut RendererCore<D>) -> BufferID {
|
fn allocate_z_buffer(&mut self, core: &mut RendererCore<D>) -> GeneralBufferID {
|
||||||
// This includes the fill indirect draw params because some drivers limit the number of
|
// This includes the fill indirect draw params because some drivers limit the number of
|
||||||
// SSBOs to 8 (#373).
|
// SSBOs to 8 (#373).
|
||||||
let size = core.tile_size().area() as u64 + FILL_INDIRECT_DRAW_PARAMS_SIZE as u64;
|
let size = core.tile_size().area() as u64 + FILL_INDIRECT_DRAW_PARAMS_SIZE as u64;
|
||||||
core.allocator.allocate_buffer::<i32>( &core.device, size, BufferTag("ZBufferD3D11"))
|
core.allocator.allocate_general_buffer::<i32>(&core.device,
|
||||||
|
size,
|
||||||
|
BufferTag("ZBufferD3D11"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn draw_tiles(&mut self,
|
pub(crate) fn draw_tiles(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
first_tile_map_buffer_id: BufferID,
|
first_tile_map_buffer_id: GeneralBufferID,
|
||||||
color_texture_0: Option<TileBatchTexture>) {
|
color_texture_0: Option<TileBatchTexture>) {
|
||||||
let timer_query = core.timer_query_cache.start_timing_draw_call(&core.device,
|
let timer_query = core.timer_query_cache.start_timing_draw_call(&core.device,
|
||||||
&core.options);
|
&core.options);
|
||||||
|
@ -741,8 +748,9 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tiles_d3d11_buffer = core.allocator.get_buffer(tiles_d3d11_buffer_id);
|
let tiles_d3d11_buffer = core.allocator.get_general_buffer(tiles_d3d11_buffer_id);
|
||||||
let first_tile_map_storage_buffer = core.allocator.get_buffer(first_tile_map_buffer_id);
|
let first_tile_map_storage_buffer = core.allocator
|
||||||
|
.get_general_buffer(first_tile_map_buffer_id);
|
||||||
|
|
||||||
let framebuffer_tile_size = core.framebuffer_tile_size().0;
|
let framebuffer_tile_size = core.framebuffer_tile_size().0;
|
||||||
let compute_dimensions = ComputeDimensions {
|
let compute_dimensions = ComputeDimensions {
|
||||||
|
@ -775,10 +783,10 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
|
|
||||||
fn free_tile_batch_buffers(&mut self, core: &mut RendererCore<D>) {
|
fn free_tile_batch_buffers(&mut self, core: &mut RendererCore<D>) {
|
||||||
for (_, tile_batch_info) in self.tile_batch_info.drain() {
|
for (_, tile_batch_info) in self.tile_batch_info.drain() {
|
||||||
core.allocator.free_buffer(tile_batch_info.z_buffer_id);
|
core.allocator.free_general_buffer(tile_batch_info.z_buffer_id);
|
||||||
core.allocator.free_buffer(tile_batch_info.tiles_d3d11_buffer_id);
|
core.allocator.free_general_buffer(tile_batch_info.tiles_d3d11_buffer_id);
|
||||||
core.allocator.free_buffer(tile_batch_info.propagate_metadata_buffer_id);
|
core.allocator.free_general_buffer(tile_batch_info.propagate_metadata_buffer_id);
|
||||||
core.allocator.free_buffer(tile_batch_info.first_tile_map_buffer_id);
|
core.allocator.free_general_buffer(tile_batch_info.first_tile_map_buffer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,32 +796,32 @@ impl<D> RendererD3D11<D> where D: Device {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct TileBatchInfoD3D11 {
|
struct TileBatchInfoD3D11 {
|
||||||
tile_count: u32,
|
tile_count: u32,
|
||||||
z_buffer_id: BufferID,
|
z_buffer_id: GeneralBufferID,
|
||||||
tiles_d3d11_buffer_id: BufferID,
|
tiles_d3d11_buffer_id: GeneralBufferID,
|
||||||
propagate_metadata_buffer_id: BufferID,
|
propagate_metadata_buffer_id: GeneralBufferID,
|
||||||
first_tile_map_buffer_id: BufferID,
|
first_tile_map_buffer_id: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct FillBufferInfoD3D11 {
|
struct FillBufferInfoD3D11 {
|
||||||
fill_vertex_buffer_id: BufferID,
|
fill_vertex_buffer_id: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct PropagateMetadataBufferIDsD3D11 {
|
struct PropagateMetadataBufferIDsD3D11 {
|
||||||
propagate_metadata: BufferID,
|
propagate_metadata: GeneralBufferID,
|
||||||
backdrops: BufferID,
|
backdrops: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MicrolinesBufferIDsD3D11 {
|
struct MicrolinesBufferIDsD3D11 {
|
||||||
buffer_id: BufferID,
|
buffer_id: GeneralBufferID,
|
||||||
count: u32,
|
count: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct ClipBufferIDs {
|
struct ClipBufferIDs {
|
||||||
metadata: Option<BufferID>,
|
metadata: Option<GeneralBufferID>,
|
||||||
tiles: BufferID,
|
tiles: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SceneBuffers {
|
struct SceneBuffers {
|
||||||
|
@ -822,9 +830,9 @@ struct SceneBuffers {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SceneSourceBuffers {
|
struct SceneSourceBuffers {
|
||||||
points_buffer: Option<BufferID>,
|
points_buffer: Option<GeneralBufferID>,
|
||||||
points_capacity: u32,
|
points_capacity: u32,
|
||||||
point_indices_buffer: Option<BufferID>,
|
point_indices_buffer: Option<GeneralBufferID>,
|
||||||
point_indices_count: u32,
|
point_indices_count: u32,
|
||||||
point_indices_capacity: u32,
|
point_indices_capacity: u32,
|
||||||
}
|
}
|
||||||
|
@ -870,23 +878,24 @@ impl SceneSourceBuffers {
|
||||||
let needed_point_indices_capacity = (segments.indices.len() as u32).next_power_of_two();
|
let needed_point_indices_capacity = (segments.indices.len() as u32).next_power_of_two();
|
||||||
if self.points_capacity < needed_points_capacity {
|
if self.points_capacity < needed_points_capacity {
|
||||||
self.points_buffer =
|
self.points_buffer =
|
||||||
Some(allocator.allocate_buffer::<Vector2F>(device,
|
Some(allocator.allocate_general_buffer::<Vector2F>(device,
|
||||||
needed_points_capacity as u64,
|
needed_points_capacity as u64,
|
||||||
BufferTag("PointsD3D11")));
|
BufferTag("PointsD3D11")));
|
||||||
self.points_capacity = needed_points_capacity;
|
self.points_capacity = needed_points_capacity;
|
||||||
}
|
}
|
||||||
if self.point_indices_capacity < needed_point_indices_capacity {
|
if self.point_indices_capacity < needed_point_indices_capacity {
|
||||||
self.point_indices_buffer = Some(allocator.allocate_buffer::<SegmentIndicesD3D11>(
|
self.point_indices_buffer =
|
||||||
device,
|
Some(allocator.allocate_general_buffer::<SegmentIndicesD3D11>(
|
||||||
needed_point_indices_capacity as u64,
|
device,
|
||||||
BufferTag("PointIndicesD3D11")));
|
needed_point_indices_capacity as u64,
|
||||||
|
BufferTag("PointIndicesD3D11")));
|
||||||
self.point_indices_capacity = needed_point_indices_capacity;
|
self.point_indices_capacity = needed_point_indices_capacity;
|
||||||
}
|
}
|
||||||
device.upload_to_buffer(allocator.get_buffer(self.points_buffer.unwrap()),
|
device.upload_to_buffer(allocator.get_general_buffer(self.points_buffer.unwrap()),
|
||||||
0,
|
0,
|
||||||
&segments.points,
|
&segments.points,
|
||||||
BufferTarget::Storage);
|
BufferTarget::Storage);
|
||||||
device.upload_to_buffer(allocator.get_buffer(self.point_indices_buffer.unwrap()),
|
device.upload_to_buffer(allocator.get_general_buffer(self.point_indices_buffer.unwrap()),
|
||||||
0,
|
0,
|
||||||
&segments.indices,
|
&segments.indices,
|
||||||
BufferTarget::Storage);
|
BufferTarget::Storage);
|
||||||
|
|
|
@ -24,8 +24,8 @@ use pathfinder_content::effects::BlendMode;
|
||||||
use pathfinder_geometry::rect::RectI;
|
use pathfinder_geometry::rect::RectI;
|
||||||
use pathfinder_geometry::transform3d::Transform4F;
|
use pathfinder_geometry::transform3d::Transform4F;
|
||||||
use pathfinder_geometry::vector::{Vector2I, Vector4F, vec2i};
|
use pathfinder_geometry::vector::{Vector2I, Vector4F, vec2i};
|
||||||
use pathfinder_gpu::allocator::{BufferID, BufferTag, FramebufferID, FramebufferTag};
|
use pathfinder_gpu::allocator::{BufferTag, FramebufferID, FramebufferTag, GeneralBufferID};
|
||||||
use pathfinder_gpu::allocator::{TextureID, TextureTag};
|
use pathfinder_gpu::allocator::{IndexBufferID, TextureID, TextureTag};
|
||||||
use pathfinder_gpu::{BlendFactor, BlendState, BufferTarget, ClearOps, Device, Primitive};
|
use pathfinder_gpu::{BlendFactor, BlendState, BufferTarget, ClearOps, Device, Primitive};
|
||||||
use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, StencilFunc, StencilState};
|
use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, StencilFunc, StencilState};
|
||||||
use pathfinder_gpu::{TextureDataRef, TextureFormat, UniformData};
|
use pathfinder_gpu::{TextureDataRef, TextureFormat, UniformData};
|
||||||
|
@ -38,7 +38,7 @@ const MAX_FILLS_PER_BATCH: usize = 0x10000;
|
||||||
pub(crate) struct RendererD3D9<D> where D: Device {
|
pub(crate) struct RendererD3D9<D> where D: Device {
|
||||||
// Basic data
|
// Basic data
|
||||||
programs: ProgramsD3D9<D>,
|
programs: ProgramsD3D9<D>,
|
||||||
quads_vertex_indices_buffer_id: Option<BufferID>,
|
quads_vertex_indices_buffer_id: Option<IndexBufferID>,
|
||||||
quads_vertex_indices_length: usize,
|
quads_vertex_indices_length: usize,
|
||||||
|
|
||||||
// Fills.
|
// Fills.
|
||||||
|
@ -79,7 +79,7 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
if !batch.clips.is_empty() {
|
if !batch.clips.is_empty() {
|
||||||
let clip_buffer_info = self.upload_clip_tiles(core, &batch.clips);
|
let clip_buffer_info = self.upload_clip_tiles(core, &batch.clips);
|
||||||
self.clip_tiles(core, &clip_buffer_info);
|
self.clip_tiles(core, &clip_buffer_info);
|
||||||
core.allocator.free_buffer(clip_buffer_info.clip_buffer_id);
|
core.allocator.free_general_buffer(clip_buffer_info.clip_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let tile_buffer = self.upload_tiles(core, &batch.tiles);
|
let tile_buffer = self.upload_tiles(core, &batch.tiles);
|
||||||
|
@ -93,16 +93,16 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
z_buffer_texture_id);
|
z_buffer_texture_id);
|
||||||
|
|
||||||
core.allocator.free_texture(z_buffer_texture_id);
|
core.allocator.free_texture(z_buffer_texture_id);
|
||||||
core.allocator.free_buffer(tile_buffer.tile_vertex_buffer_id);
|
core.allocator.free_general_buffer(tile_buffer.tile_vertex_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload_tiles(&mut self, core: &mut RendererCore<D>, tiles: &[TileObjectPrimitive])
|
fn upload_tiles(&mut self, core: &mut RendererCore<D>, tiles: &[TileObjectPrimitive])
|
||||||
-> TileBufferD3D9 {
|
-> TileBufferD3D9 {
|
||||||
let tile_vertex_buffer_id =
|
let tile_vertex_buffer_id =
|
||||||
core.allocator.allocate_buffer::<TileObjectPrimitive>(&core.device,
|
core.allocator.allocate_general_buffer::<TileObjectPrimitive>(&core.device,
|
||||||
tiles.len() as u64,
|
tiles.len() as u64,
|
||||||
BufferTag("TileD3D9"));
|
BufferTag("TileD3D9"));
|
||||||
let tile_vertex_buffer = &core.allocator.get_buffer(tile_vertex_buffer_id);
|
let tile_vertex_buffer = &core.allocator.get_general_buffer(tile_vertex_buffer_id);
|
||||||
core.device.upload_to_buffer(tile_vertex_buffer, 0, tiles, BufferTarget::Vertex);
|
core.device.upload_to_buffer(tile_vertex_buffer, 0, tiles, BufferTarget::Vertex);
|
||||||
self.ensure_index_buffer(core, tiles.len());
|
self.ensure_index_buffer(core, tiles.len());
|
||||||
|
|
||||||
|
@ -126,14 +126,14 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(quads_vertex_indices_buffer_id) = self.quads_vertex_indices_buffer_id.take() {
|
if let Some(quads_vertex_indices_buffer_id) = self.quads_vertex_indices_buffer_id.take() {
|
||||||
core.allocator.free_buffer(quads_vertex_indices_buffer_id);
|
core.allocator.free_index_buffer(quads_vertex_indices_buffer_id);
|
||||||
}
|
}
|
||||||
let quads_vertex_indices_buffer_id =
|
let quads_vertex_indices_buffer_id =
|
||||||
core.allocator.allocate_buffer::<u32>(&core.device,
|
core.allocator.allocate_index_buffer::<u32>(&core.device,
|
||||||
indices.len() as u64,
|
indices.len() as u64,
|
||||||
BufferTag("QuadsVertexIndicesD3D9"));
|
BufferTag("QuadsVertexIndicesD3D9"));
|
||||||
let quads_vertex_indices_buffer =
|
let quads_vertex_indices_buffer =
|
||||||
core.allocator.get_buffer(quads_vertex_indices_buffer_id);
|
core.allocator.get_index_buffer(quads_vertex_indices_buffer_id);
|
||||||
core.device.upload_to_buffer(quads_vertex_indices_buffer,
|
core.device.upload_to_buffer(quads_vertex_indices_buffer,
|
||||||
0,
|
0,
|
||||||
&indices,
|
&indices,
|
||||||
|
@ -175,17 +175,18 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
|
|
||||||
let fill_storage_info = self.upload_buffered_fills(core);
|
let fill_storage_info = self.upload_buffered_fills(core);
|
||||||
self.draw_fills(core, fill_storage_info.fill_buffer_id, fill_storage_info.fill_count);
|
self.draw_fills(core, fill_storage_info.fill_buffer_id, fill_storage_info.fill_count);
|
||||||
core.allocator.free_buffer(fill_storage_info.fill_buffer_id);
|
core.allocator.free_general_buffer(fill_storage_info.fill_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload_buffered_fills(&mut self, core: &mut RendererCore<D>) -> FillBufferInfoD3D9 {
|
fn upload_buffered_fills(&mut self, core: &mut RendererCore<D>) -> FillBufferInfoD3D9 {
|
||||||
let buffered_fills = &mut self.buffered_fills;
|
let buffered_fills = &mut self.buffered_fills;
|
||||||
debug_assert!(!buffered_fills.is_empty());
|
debug_assert!(!buffered_fills.is_empty());
|
||||||
|
|
||||||
let fill_buffer_id = core.allocator.allocate_buffer::<Fill>(&core.device,
|
let fill_buffer_id = core.allocator
|
||||||
MAX_FILLS_PER_BATCH as u64,
|
.allocate_general_buffer::<Fill>(&core.device,
|
||||||
BufferTag("Fill"));
|
MAX_FILLS_PER_BATCH as u64,
|
||||||
let fill_vertex_buffer = core.allocator.get_buffer(fill_buffer_id);
|
BufferTag("Fill"));
|
||||||
|
let fill_vertex_buffer = core.allocator.get_general_buffer(fill_buffer_id);
|
||||||
debug_assert!(buffered_fills.len() <= u32::MAX as usize);
|
debug_assert!(buffered_fills.len() <= u32::MAX as usize);
|
||||||
core.device.upload_to_buffer(fill_vertex_buffer, 0, &buffered_fills, BufferTarget::Vertex);
|
core.device.upload_to_buffer(fill_vertex_buffer, 0, &buffered_fills, BufferTarget::Vertex);
|
||||||
|
|
||||||
|
@ -197,15 +198,15 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
|
|
||||||
fn draw_fills(&mut self,
|
fn draw_fills(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
fill_buffer_id: BufferID,
|
fill_buffer_id: GeneralBufferID,
|
||||||
fill_count: u32) {
|
fill_count: u32) {
|
||||||
let fill_raster_program = &self.programs.fill_program;
|
let fill_raster_program = &self.programs.fill_program;
|
||||||
|
|
||||||
let fill_vertex_buffer = core.allocator.get_buffer(fill_buffer_id);
|
let fill_vertex_buffer = core.allocator.get_general_buffer(fill_buffer_id);
|
||||||
let quad_vertex_positions_buffer = core.allocator
|
let quad_vertex_positions_buffer =
|
||||||
.get_buffer(core.quad_vertex_positions_buffer_id);
|
core.allocator.get_general_buffer(core.quad_vertex_positions_buffer_id);
|
||||||
let quad_vertex_indices_buffer = core.allocator
|
let quad_vertex_indices_buffer = core.allocator
|
||||||
.get_buffer(core.quad_vertex_indices_buffer_id);
|
.get_index_buffer(core.quad_vertex_indices_buffer_id);
|
||||||
|
|
||||||
let area_lut_texture = core.allocator.get_texture(core.area_lut_texture_id);
|
let area_lut_texture = core.allocator.get_texture(core.area_lut_texture_id);
|
||||||
|
|
||||||
|
@ -278,11 +279,12 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
let mask_texture = core.device.framebuffer_texture(mask_framebuffer);
|
let mask_texture = core.device.framebuffer_texture(mask_framebuffer);
|
||||||
let mask_texture_size = core.device.texture_size(&mask_texture);
|
let mask_texture_size = core.device.texture_size(&mask_texture);
|
||||||
|
|
||||||
let clip_vertex_buffer = core.allocator.get_buffer(clip_buffer_info.clip_buffer_id);
|
let clip_vertex_buffer = core.allocator
|
||||||
let quad_vertex_positions_buffer = core.allocator
|
.get_general_buffer(clip_buffer_info.clip_buffer_id);
|
||||||
.get_buffer(core.quad_vertex_positions_buffer_id);
|
let quad_vertex_positions_buffer =
|
||||||
|
core.allocator.get_general_buffer(core.quad_vertex_positions_buffer_id);
|
||||||
let quad_vertex_indices_buffer = core.allocator
|
let quad_vertex_indices_buffer = core.allocator
|
||||||
.get_buffer(core.quad_vertex_indices_buffer_id);
|
.get_index_buffer(core.quad_vertex_indices_buffer_id);
|
||||||
|
|
||||||
let tile_clip_copy_vertex_array =
|
let tile_clip_copy_vertex_array =
|
||||||
ClipTileCopyVertexArrayD3D9::new(&core.device,
|
ClipTileCopyVertexArrayD3D9::new(&core.device,
|
||||||
|
@ -372,10 +374,10 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
|
|
||||||
// Uploads clip tiles from CPU to GPU.
|
// Uploads clip tiles from CPU to GPU.
|
||||||
fn upload_clip_tiles(&mut self, core: &mut RendererCore<D>, clips: &[Clip]) -> ClipBufferInfo {
|
fn upload_clip_tiles(&mut self, core: &mut RendererCore<D>, clips: &[Clip]) -> ClipBufferInfo {
|
||||||
let clip_buffer_id = core.allocator.allocate_buffer::<Clip>(&core.device,
|
let clip_buffer_id = core.allocator.allocate_general_buffer::<Clip>(&core.device,
|
||||||
clips.len() as u64,
|
clips.len() as u64,
|
||||||
BufferTag("ClipD3D9"));
|
BufferTag("ClipD3D9"));
|
||||||
let clip_buffer = core.allocator.get_buffer(clip_buffer_id);
|
let clip_buffer = core.allocator.get_general_buffer(clip_buffer_id);
|
||||||
core.device.upload_to_buffer(clip_buffer, 0, clips, BufferTarget::Vertex);
|
core.device.upload_to_buffer(clip_buffer, 0, clips, BufferTarget::Vertex);
|
||||||
ClipBufferInfo { clip_buffer_id, clip_count: clips.len() as u32 }
|
ClipBufferInfo { clip_buffer_id, clip_count: clips.len() as u32 }
|
||||||
}
|
}
|
||||||
|
@ -383,7 +385,7 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
fn draw_tiles(&mut self,
|
fn draw_tiles(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
tile_count: u32,
|
tile_count: u32,
|
||||||
tile_vertex_buffer_id: BufferID,
|
tile_vertex_buffer_id: GeneralBufferID,
|
||||||
color_texture_0: Option<TileBatchTexture>,
|
color_texture_0: Option<TileBatchTexture>,
|
||||||
blend_mode: BlendMode,
|
blend_mode: BlendMode,
|
||||||
z_buffer_texture_id: TextureID) {
|
z_buffer_texture_id: TextureID) {
|
||||||
|
@ -408,11 +410,11 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
|
|
||||||
let tile_raster_program = &self.programs.tile_program;
|
let tile_raster_program = &self.programs.tile_program;
|
||||||
|
|
||||||
let tile_vertex_buffer = core.allocator.get_buffer(tile_vertex_buffer_id);
|
let tile_vertex_buffer = core.allocator.get_general_buffer(tile_vertex_buffer_id);
|
||||||
let quad_vertex_positions_buffer = core.allocator
|
let quad_vertex_positions_buffer =
|
||||||
.get_buffer(core.quad_vertex_positions_buffer_id);
|
core.allocator.get_general_buffer(core.quad_vertex_positions_buffer_id);
|
||||||
let quad_vertex_indices_buffer = core.allocator
|
let quad_vertex_indices_buffer = core.allocator
|
||||||
.get_buffer(core.quad_vertex_indices_buffer_id);
|
.get_index_buffer(core.quad_vertex_indices_buffer_id);
|
||||||
let dest_blend_framebuffer = core.allocator
|
let dest_blend_framebuffer = core.allocator
|
||||||
.get_framebuffer(self.dest_blend_framebuffer_id);
|
.get_framebuffer(self.dest_blend_framebuffer_id);
|
||||||
|
|
||||||
|
@ -467,7 +469,7 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
fn copy_alpha_tiles_to_dest_blend_texture(&mut self,
|
fn copy_alpha_tiles_to_dest_blend_texture(&mut self,
|
||||||
core: &mut RendererCore<D>,
|
core: &mut RendererCore<D>,
|
||||||
tile_count: u32,
|
tile_count: u32,
|
||||||
vertex_buffer_id: BufferID) {
|
vertex_buffer_id: GeneralBufferID) {
|
||||||
let draw_viewport = core.draw_viewport();
|
let draw_viewport = core.draw_viewport();
|
||||||
|
|
||||||
let mut textures = vec![];
|
let mut textures = vec![];
|
||||||
|
@ -491,8 +493,8 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
let quads_vertex_indices_buffer_id = self.quads_vertex_indices_buffer_id
|
let quads_vertex_indices_buffer_id = self.quads_vertex_indices_buffer_id
|
||||||
.expect("Where's the quads vertex buffer?");
|
.expect("Where's the quads vertex buffer?");
|
||||||
let quads_vertex_indices_buffer = core.allocator
|
let quads_vertex_indices_buffer = core.allocator
|
||||||
.get_buffer(quads_vertex_indices_buffer_id);
|
.get_index_buffer(quads_vertex_indices_buffer_id);
|
||||||
let vertex_buffer = core.allocator.get_buffer(vertex_buffer_id);
|
let vertex_buffer = core.allocator.get_general_buffer(vertex_buffer_id);
|
||||||
|
|
||||||
let tile_copy_vertex_array = CopyTileVertexArray::new(&core.device,
|
let tile_copy_vertex_array = CopyTileVertexArray::new(&core.device,
|
||||||
&self.programs.tile_copy_program,
|
&self.programs.tile_copy_program,
|
||||||
|
@ -556,21 +558,21 @@ impl<D> RendererD3D9<D> where D: Device {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct TileBatchInfoD3D9 {
|
pub(crate) struct TileBatchInfoD3D9 {
|
||||||
pub(crate) tile_count: u32,
|
pub(crate) tile_count: u32,
|
||||||
pub(crate) z_buffer_id: BufferID,
|
pub(crate) z_buffer_id: GeneralBufferID,
|
||||||
tile_vertex_buffer_id: BufferID,
|
tile_vertex_buffer_id: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct FillBufferInfoD3D9 {
|
struct FillBufferInfoD3D9 {
|
||||||
fill_buffer_id: BufferID,
|
fill_buffer_id: GeneralBufferID,
|
||||||
fill_count: u32,
|
fill_count: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TileBufferD3D9 {
|
struct TileBufferD3D9 {
|
||||||
tile_vertex_buffer_id: BufferID,
|
tile_vertex_buffer_id: GeneralBufferID,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ClipBufferInfo {
|
struct ClipBufferInfo {
|
||||||
clip_buffer_id: BufferID,
|
clip_buffer_id: GeneralBufferID,
|
||||||
clip_count: u32,
|
clip_count: u32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ use pathfinder_geometry::rect::{RectF, RectI};
|
||||||
use pathfinder_geometry::transform3d::Transform4F;
|
use pathfinder_geometry::transform3d::Transform4F;
|
||||||
use pathfinder_geometry::util;
|
use pathfinder_geometry::util;
|
||||||
use pathfinder_geometry::vector::{Vector2F, Vector2I, Vector4F, vec2f, vec2i};
|
use pathfinder_geometry::vector::{Vector2F, Vector2I, Vector4F, vec2f, vec2i};
|
||||||
use pathfinder_gpu::allocator::{BufferID, BufferTag, FramebufferID, FramebufferTag};
|
use pathfinder_gpu::allocator::{BufferTag, FramebufferID, FramebufferTag, GeneralBufferID};
|
||||||
use pathfinder_gpu::allocator::{GPUMemoryAllocator, TextureID, TextureTag};
|
use pathfinder_gpu::allocator::{GPUMemoryAllocator, IndexBufferID, TextureID, TextureTag};
|
||||||
use pathfinder_gpu::{BufferData, BufferTarget, ClearOps, DepthFunc, DepthState, Device, Primitive};
|
use pathfinder_gpu::{BufferData, BufferTarget, ClearOps, DepthFunc, DepthState, Device, Primitive};
|
||||||
use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, StencilFunc, StencilState};
|
use pathfinder_gpu::{RenderOptions, RenderState, RenderTarget, StencilFunc, StencilState};
|
||||||
use pathfinder_gpu::{TextureBinding, TextureDataRef, TextureFormat, UniformBinding, UniformData};
|
use pathfinder_gpu::{TextureBinding, TextureDataRef, TextureFormat, UniformBinding, UniformData};
|
||||||
|
@ -111,8 +111,8 @@ pub(crate) struct RendererCore<D> where D: Device {
|
||||||
pub(crate) vertex_arrays: VertexArraysCore<D>,
|
pub(crate) vertex_arrays: VertexArraysCore<D>,
|
||||||
|
|
||||||
// Read-only static core resources
|
// Read-only static core resources
|
||||||
pub(crate) quad_vertex_positions_buffer_id: BufferID,
|
pub(crate) quad_vertex_positions_buffer_id: GeneralBufferID,
|
||||||
pub(crate) quad_vertex_indices_buffer_id: BufferID,
|
pub(crate) quad_vertex_indices_buffer_id: IndexBufferID,
|
||||||
pub(crate) area_lut_texture_id: TextureID,
|
pub(crate) area_lut_texture_id: TextureID,
|
||||||
pub(crate) gamma_lut_texture_id: TextureID,
|
pub(crate) gamma_lut_texture_id: TextureID,
|
||||||
|
|
||||||
|
@ -154,18 +154,18 @@ impl<D> Renderer<D> where D: Device {
|
||||||
device.begin_commands();
|
device.begin_commands();
|
||||||
|
|
||||||
let quad_vertex_positions_buffer_id =
|
let quad_vertex_positions_buffer_id =
|
||||||
allocator.allocate_buffer::<u16>(&device,
|
allocator.allocate_general_buffer::<u16>(&device,
|
||||||
QUAD_VERTEX_POSITIONS.len() as u64,
|
QUAD_VERTEX_POSITIONS.len() as u64,
|
||||||
BufferTag("QuadVertexPositions"));
|
BufferTag("QuadVertexPositions"));
|
||||||
device.upload_to_buffer(allocator.get_buffer(quad_vertex_positions_buffer_id),
|
device.upload_to_buffer(allocator.get_general_buffer(quad_vertex_positions_buffer_id),
|
||||||
0,
|
0,
|
||||||
&QUAD_VERTEX_POSITIONS,
|
&QUAD_VERTEX_POSITIONS,
|
||||||
BufferTarget::Vertex);
|
BufferTarget::Vertex);
|
||||||
let quad_vertex_indices_buffer_id =
|
let quad_vertex_indices_buffer_id =
|
||||||
allocator.allocate_buffer::<u32>(&device,
|
allocator.allocate_index_buffer::<u32>(&device,
|
||||||
QUAD_VERTEX_INDICES.len() as u64,
|
QUAD_VERTEX_INDICES.len() as u64,
|
||||||
BufferTag("QuadVertexIndices"));
|
BufferTag("QuadVertexIndices"));
|
||||||
device.upload_to_buffer(allocator.get_buffer(quad_vertex_indices_buffer_id),
|
device.upload_to_buffer(allocator.get_index_buffer(quad_vertex_indices_buffer_id),
|
||||||
0,
|
0,
|
||||||
&QUAD_VERTEX_INDICES,
|
&QUAD_VERTEX_INDICES,
|
||||||
BufferTarget::Index);
|
BufferTarget::Index);
|
||||||
|
@ -206,8 +206,8 @@ impl<D> Renderer<D> where D: Device {
|
||||||
let core_vertex_arrays =
|
let core_vertex_arrays =
|
||||||
VertexArraysCore::new(&device,
|
VertexArraysCore::new(&device,
|
||||||
&core_programs,
|
&core_programs,
|
||||||
allocator.get_buffer(quad_vertex_positions_buffer_id),
|
allocator.get_general_buffer(quad_vertex_positions_buffer_id),
|
||||||
allocator.get_buffer(quad_vertex_indices_buffer_id));
|
allocator.get_index_buffer(quad_vertex_indices_buffer_id));
|
||||||
|
|
||||||
let mut core = RendererCore {
|
let mut core = RendererCore {
|
||||||
device,
|
device,
|
||||||
|
@ -508,12 +508,12 @@ impl<D> Renderer<D> where D: Device {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn quad_vertex_positions_buffer(&self) -> &D::Buffer {
|
pub fn quad_vertex_positions_buffer(&self) -> &D::Buffer {
|
||||||
self.core.allocator.get_buffer(self.core.quad_vertex_positions_buffer_id)
|
self.core.allocator.get_general_buffer(self.core.quad_vertex_positions_buffer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn quad_vertex_indices_buffer(&self) -> &D::Buffer {
|
pub fn quad_vertex_indices_buffer(&self) -> &D::Buffer {
|
||||||
self.core.allocator.get_buffer(self.core.quad_vertex_indices_buffer_id)
|
self.core.allocator.get_index_buffer(self.core.quad_vertex_indices_buffer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_pattern_texture_page(&mut self,
|
fn allocate_pattern_texture_page(&mut self,
|
||||||
|
@ -1146,11 +1146,13 @@ impl<D> Frame<D> where D: Device {
|
||||||
clear_program: &ClearProgram<D>,
|
clear_program: &ClearProgram<D>,
|
||||||
reprojection_program: &ReprojectionProgram<D>,
|
reprojection_program: &ReprojectionProgram<D>,
|
||||||
stencil_program: &StencilProgram<D>,
|
stencil_program: &StencilProgram<D>,
|
||||||
quad_vertex_positions_buffer_id: BufferID,
|
quad_vertex_positions_buffer_id: GeneralBufferID,
|
||||||
quad_vertex_indices_buffer_id: BufferID)
|
quad_vertex_indices_buffer_id: IndexBufferID)
|
||||||
-> Frame<D> {
|
-> Frame<D> {
|
||||||
let quad_vertex_positions_buffer = allocator.get_buffer(quad_vertex_positions_buffer_id);
|
let quad_vertex_positions_buffer =
|
||||||
let quad_vertex_indices_buffer = allocator.get_buffer(quad_vertex_indices_buffer_id);
|
allocator.get_general_buffer(quad_vertex_positions_buffer_id);
|
||||||
|
let quad_vertex_indices_buffer =
|
||||||
|
allocator.get_index_buffer(quad_vertex_indices_buffer_id);
|
||||||
|
|
||||||
let blit_vertex_array = BlitVertexArray::new(device,
|
let blit_vertex_array = BlitVertexArray::new(device,
|
||||||
&blit_program,
|
&blit_program,
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
use crate::builder::SceneBuilder;
|
use crate::builder::SceneBuilder;
|
||||||
use crate::concurrent::executor::Executor;
|
use crate::concurrent::executor::Executor;
|
||||||
use crate::gpu::options::RendererLevel;
|
use crate::gpu::options::RendererLevel;
|
||||||
|
use crate::gpu::renderer::Renderer;
|
||||||
|
use crate::gpu_data::RenderCommand;
|
||||||
use crate::options::{BuildOptions, PreparedBuildOptions};
|
use crate::options::{BuildOptions, PreparedBuildOptions};
|
||||||
use crate::options::{PreparedRenderTransform, RenderCommandListener};
|
use crate::options::{PreparedRenderTransform, RenderCommandListener};
|
||||||
use crate::paint::{MergedPaletteInfo, Paint, PaintId, PaintInfo, Palette};
|
use crate::paint::{MergedPaletteInfo, Paint, PaintId, PaintInfo, Palette};
|
||||||
|
@ -23,8 +25,11 @@ use pathfinder_content::render_target::RenderTargetId;
|
||||||
use pathfinder_geometry::rect::RectF;
|
use pathfinder_geometry::rect::RectF;
|
||||||
use pathfinder_geometry::transform2d::Transform2F;
|
use pathfinder_geometry::transform2d::Transform2F;
|
||||||
use pathfinder_geometry::vector::{Vector2I, vec2f};
|
use pathfinder_geometry::vector::{Vector2I, vec2f};
|
||||||
|
use pathfinder_gpu::Device;
|
||||||
|
use std::mem;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
use std::u64;
|
use std::u64;
|
||||||
|
|
||||||
static NEXT_SCENE_ID: AtomicUsize = AtomicUsize::new(0);
|
static NEXT_SCENE_ID: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
@ -289,6 +294,37 @@ impl Scene {
|
||||||
pub fn epoch(&self) -> SceneEpoch {
|
pub fn epoch(&self) -> SceneEpoch {
|
||||||
self.epoch
|
self.epoch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A convenience method to build a scene and accumulate commands into a vector.
|
||||||
|
pub fn build_into_vector<D, E>(&mut self,
|
||||||
|
renderer: &mut Renderer<D>,
|
||||||
|
build_options: BuildOptions,
|
||||||
|
executor: E)
|
||||||
|
-> Vec<RenderCommand>
|
||||||
|
where D: Device, E: Executor {
|
||||||
|
let commands = Arc::new(Mutex::new(vec![]));
|
||||||
|
let commands_for_listener = commands.clone();
|
||||||
|
let listener = RenderCommandListener::new(Box::new(move |command| {
|
||||||
|
commands_for_listener.lock().unwrap().push(command)
|
||||||
|
}));
|
||||||
|
let mut sink = SceneSink::new(listener, renderer.mode().level);
|
||||||
|
self.build(build_options, &mut sink, &executor);
|
||||||
|
let mut commands = commands.lock().unwrap();
|
||||||
|
mem::replace(&mut *commands, vec![])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A convenience method to build a scene and send the resulting commands to the given
|
||||||
|
/// renderer.
|
||||||
|
pub fn build_and_render<D, E>(&mut self,
|
||||||
|
renderer: &mut Renderer<D>,
|
||||||
|
build_options: BuildOptions,
|
||||||
|
executor: E)
|
||||||
|
where D: Device, E: Executor {
|
||||||
|
let commands = self.build_into_vector(renderer, build_options, executor);
|
||||||
|
renderer.begin_scene();
|
||||||
|
commands.into_iter().for_each(|command| renderer.render_command(&command));
|
||||||
|
renderer.end_scene();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SceneSink<'a> {
|
pub struct SceneSink<'a> {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
use crate::gpu_data::{TILE_CTRL_MASK_0_SHIFT, TILE_CTRL_MASK_EVEN_ODD};
|
use crate::gpu_data::{TILE_CTRL_MASK_0_SHIFT, TILE_CTRL_MASK_EVEN_ODD};
|
||||||
use crate::gpu_data::{TILE_CTRL_MASK_WINDING, TileObjectPrimitive};
|
use crate::gpu_data::{TILE_CTRL_MASK_WINDING, TileObjectPrimitive};
|
||||||
use crate::paint::PaintId;
|
use crate::paint::PaintId;
|
||||||
use crate::scene::ClipPathId;
|
|
||||||
use pathfinder_content::effects::BlendMode;
|
use pathfinder_content::effects::BlendMode;
|
||||||
use pathfinder_content::fill::FillRule;
|
use pathfinder_content::fill::FillRule;
|
||||||
use pathfinder_geometry::rect::{RectF, RectI};
|
use pathfinder_geometry::rect::{RectF, RectI};
|
||||||
|
|
|
@ -177,15 +177,15 @@ impl<D> UIPresenter<D> where D: Device {
|
||||||
color: ColorU,
|
color: ColorU,
|
||||||
filled: bool) {
|
filled: bool) {
|
||||||
let vertex_buffer_id =
|
let vertex_buffer_id =
|
||||||
allocator.allocate_buffer::<DebugSolidVertex>(device,
|
allocator.allocate_general_buffer::<DebugSolidVertex>(device,
|
||||||
vertex_data.len() as u64,
|
vertex_data.len() as u64,
|
||||||
BufferTag("SolidVertexDebug"));
|
BufferTag("SolidVertexDebug"));
|
||||||
let index_buffer_id = allocator.allocate_buffer::<u32>(device,
|
let index_buffer_id = allocator.allocate_index_buffer::<u32>(device,
|
||||||
index_data.len() as u64,
|
index_data.len() as u64,
|
||||||
BufferTag("SolidIndexDebug"));
|
BufferTag("SolidIndexDebug"));
|
||||||
{
|
{
|
||||||
let vertex_buffer = allocator.get_buffer(vertex_buffer_id);
|
let vertex_buffer = allocator.get_general_buffer(vertex_buffer_id);
|
||||||
let index_buffer = allocator.get_buffer(index_buffer_id);
|
let index_buffer = allocator.get_index_buffer(index_buffer_id);
|
||||||
device.upload_to_buffer(&vertex_buffer, 0, vertex_data, BufferTarget::Vertex);
|
device.upload_to_buffer(&vertex_buffer, 0, vertex_data, BufferTarget::Vertex);
|
||||||
device.upload_to_buffer(&index_buffer, 0, index_data, BufferTarget::Index);
|
device.upload_to_buffer(&index_buffer, 0, index_data, BufferTarget::Index);
|
||||||
let solid_vertex_array = DebugSolidVertexArray::new(device,
|
let solid_vertex_array = DebugSolidVertexArray::new(device,
|
||||||
|
@ -215,8 +215,8 @@ impl<D> UIPresenter<D> where D: Device {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator.free_buffer(index_buffer_id);
|
allocator.free_index_buffer(index_buffer_id);
|
||||||
allocator.free_buffer(vertex_buffer_id);
|
allocator.free_general_buffer(vertex_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_text(&self,
|
pub fn draw_text(&self,
|
||||||
|
@ -465,16 +465,17 @@ impl<D> UIPresenter<D> where D: Device {
|
||||||
index_data: &[u32],
|
index_data: &[u32],
|
||||||
texture: &D::Texture,
|
texture: &D::Texture,
|
||||||
color: ColorU) {
|
color: ColorU) {
|
||||||
let vertex_buffer_id =
|
let vertex_buffer_id = allocator.allocate_general_buffer::<DebugTextureVertex>(
|
||||||
allocator.allocate_buffer::<DebugTextureVertex>(device,
|
device,
|
||||||
vertex_data.len() as u64,
|
vertex_data.len() as u64,
|
||||||
BufferTag("TextureVertexDebug"));
|
BufferTag("TextureVertexDebug"));
|
||||||
let index_buffer_id = allocator.allocate_buffer::<u32>(device,
|
let index_buffer_id =
|
||||||
index_data.len() as u64,
|
allocator.allocate_index_buffer::<u32>(device,
|
||||||
BufferTag("TextureIndexDebug"));
|
index_data.len() as u64,
|
||||||
|
BufferTag("TextureIndexDebug"));
|
||||||
{
|
{
|
||||||
let vertex_buffer = allocator.get_buffer(vertex_buffer_id);
|
let vertex_buffer = allocator.get_general_buffer(vertex_buffer_id);
|
||||||
let index_buffer = allocator.get_buffer(index_buffer_id);
|
let index_buffer = allocator.get_index_buffer(index_buffer_id);
|
||||||
device.upload_to_buffer(&vertex_buffer, 0, vertex_data, BufferTarget::Vertex);
|
device.upload_to_buffer(&vertex_buffer, 0, vertex_data, BufferTarget::Vertex);
|
||||||
device.upload_to_buffer(&index_buffer, 0, index_data, BufferTarget::Index);
|
device.upload_to_buffer(&index_buffer, 0, index_data, BufferTarget::Index);
|
||||||
|
|
||||||
|
@ -506,8 +507,8 @@ impl<D> UIPresenter<D> where D: Device {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator.free_buffer(index_buffer_id);
|
allocator.free_index_buffer(index_buffer_id);
|
||||||
allocator.free_buffer(vertex_buffer_id);
|
allocator.free_general_buffer(vertex_buffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_button(&mut self,
|
pub fn draw_button(&mut self,
|
||||||
|
|
|
@ -375,11 +375,6 @@ impl WebGlDevice {
|
||||||
pos = end_index + 2;
|
pos = end_index + 2;
|
||||||
}
|
}
|
||||||
output.push_str(&source[pos..]);
|
output.push_str(&source[pos..]);
|
||||||
/*
|
|
||||||
for (line_nr, line) in output.lines().enumerate() {
|
|
||||||
debug!("{:3}: {}", line_nr + 1, line);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,6 +437,17 @@ impl Device for WebGlDevice {
|
||||||
type VertexArray = WebGlVertexArray;
|
type VertexArray = WebGlVertexArray;
|
||||||
type VertexAttr = WebGlVertexAttr;
|
type VertexAttr = WebGlVertexAttr;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn backend_name(&self) -> &'static str {
|
||||||
|
"WebGL"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn device_name(&self) -> String {
|
||||||
|
// TODO(pcwalton): Use `WEBGL_debug_renderer_info` if available.
|
||||||
|
"WebGL Device".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn feature_level(&self) -> FeatureLevel {
|
fn feature_level(&self) -> FeatureLevel {
|
||||||
FeatureLevel::D3D10
|
FeatureLevel::D3D10
|
||||||
|
|
Loading…
Reference in New Issue