mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fec1f8e34d | ||
|
|
ae87faf3c0 | ||
|
|
d7820dd7d2 | ||
|
|
74f83fb932 | ||
|
|
a21c1711e6 | ||
|
|
d88cc94b96 | ||
|
|
16612469a4 | ||
|
|
a7787d2825 | ||
|
|
afd88799f3 | ||
|
|
15e3c7363f | ||
|
|
9c1aecd162 | ||
|
|
b764405165 | ||
|
|
7422121c9e | ||
|
|
a011760786 | ||
|
|
a46b27f946 | ||
|
|
bc57f753db | ||
|
|
07d3036f04 | ||
|
|
77271b9304 | ||
|
|
3a8bbd0da4 |
No files matched your search
@@ -56,7 +56,7 @@ jobs:
|
|||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
RUSTC_WRAPPER: /usr/bin/sccache
|
RUSTC_WRAPPER: /usr/bin/sccache
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
# sccache deletes the oldest files in its folder once past its size cap, so it gets a folder apart from rust-gpu's codegen backend and Binaryen
|
# sccache deletes the oldest files in its folder once past its size cap, so it gets a folder apart from Binaryen
|
||||||
SCCACHE_DIR: /var/lib/github-actions/.cache/sccache
|
SCCACHE_DIR: /var/lib/github-actions/.cache/sccache
|
||||||
# NOTICE: keep these tool versions in sync with the other jobs in this file, `.devcontainer/devcontainer.json`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
|
# NOTICE: keep these tool versions in sync with the other jobs in this file, `.devcontainer/devcontainer.json`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
|
||||||
WASM_BINDGEN_CLI_VERSION: "0.2.127"
|
WASM_BINDGEN_CLI_VERSION: "0.2.127"
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
RUSTC_WRAPPER: /usr/bin/sccache
|
RUSTC_WRAPPER: /usr/bin/sccache
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
# sccache deletes the oldest files in its folder once past its size cap, so it gets a folder apart from rust-gpu's codegen backend
|
# sccache deletes the oldest files in its folder once past its size cap, so it gets a folder of its own
|
||||||
SCCACHE_DIR: /var/lib/github-actions/.cache/sccache
|
SCCACHE_DIR: /var/lib/github-actions/.cache/sccache
|
||||||
steps:
|
steps:
|
||||||
- name: 📥 Clone repository
|
- name: 📥 Clone repository
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
name: "Provide Shaders"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
workflow_dispatch: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- name: 📥 Clone repository
|
|
||||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
|
||||||
|
|
||||||
- name: ❄ Install Nix
|
|
||||||
uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23
|
|
||||||
with:
|
|
||||||
extra-conf: |
|
|
||||||
extra-substituters = https://graphite.cachix.org https://graphite-dev.cachix.org
|
|
||||||
extra-trusted-public-keys = graphite.cachix.org-1:B7Il1yMpkquN/dXM+5GRmz+4Xmu2aaCS1GcWNfFhsOo= graphite-dev.cachix.org-1:RppXYpiV1qO2TYKTkXXGHsAEQDOB5G51b3VlrN9QmbI=
|
|
||||||
|
|
||||||
- name: 🏗 Build graphene raster nodes shaders
|
|
||||||
run: nix build .#graphite-raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl
|
|
||||||
|
|
||||||
- name: 📤 Upload graphene raster nodes shaders to artifacts repository
|
|
||||||
run: |
|
|
||||||
bash .github/workflows/scripts/artifact-upload.bash \
|
|
||||||
${{ vars.ARTIFACTS_REPO_OWNER }} \
|
|
||||||
${{ vars.ARTIFACTS_REPO_NAME }} \
|
|
||||||
${{ vars.ARTIFACTS_REPO_BRANCH }} \
|
|
||||||
rev/${{ github.sha }}/raster_nodes_shaders_entrypoint.wgsl \
|
|
||||||
raster_nodes_shaders_entrypoint.wgsl \
|
|
||||||
"${{ github.sha }} raster_nodes_shaders_entrypoint.wgsl" \
|
|
||||||
${{ secrets.ARTIFACTS_REPO_TOKEN }}
|
|
||||||
|
|
||||||
- name: 📤 Push shaders to dev Nix cache
|
|
||||||
env:
|
|
||||||
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN_DEV }}
|
|
||||||
NIX_CACHE_NAME: graphite-dev
|
|
||||||
run: |
|
|
||||||
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
|
|
||||||
nix build .#graphite-raster-nodes-shaders --no-link --print-out-paths | nix run nixpkgs#cachix -- push $NIX_CACHE_NAME
|
|
||||||
@@ -31,7 +31,6 @@ let
|
|||||||
|
|
||||||
deps = {
|
deps = {
|
||||||
crane = lib.call ./deps/crane.nix;
|
crane = lib.call ./deps/crane.nix;
|
||||||
rustGPU = lib.call ./deps/rust-gpu.nix;
|
|
||||||
cargoAbout = lib.call ./deps/cargo-about.nix;
|
cargoAbout = lib.call ./deps/cargo-about.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ in
|
|||||||
default = graphite;
|
default = graphite;
|
||||||
graphite = (lib.call ./pkgs/graphite.nix) { };
|
graphite = (lib.call ./pkgs/graphite.nix) { };
|
||||||
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
||||||
graphite-raster-nodes-shaders = lib.call ./pkgs/graphite-raster-nodes-shaders.nix;
|
|
||||||
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
||||||
graphite-bundle = (lib.call ./pkgs/graphite-bundle.nix) { };
|
graphite-bundle = (lib.call ./pkgs/graphite-bundle.nix) { };
|
||||||
graphite-bundle-dev = (lib.call ./pkgs/graphite-bundle.nix) { graphite = graphite-dev; };
|
graphite-bundle-dev = (lib.call ./pkgs/graphite-bundle.nix) { graphite = graphite-dev; };
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
toolchain = pkgs.rust-bin.nightly."2026-07-03".default.override {
|
|
||||||
extensions = [
|
|
||||||
"rust-src"
|
|
||||||
"rust-analyzer"
|
|
||||||
"clippy"
|
|
||||||
"cargo"
|
|
||||||
"rustc-dev"
|
|
||||||
"llvm-tools"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
cargo = pkgs.writeShellScriptBin "cargo" ''
|
|
||||||
#!${pkgs.lib.getExe pkgs.bash}
|
|
||||||
|
|
||||||
filtered_args=()
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
+nightly|+nightly-*) ;;
|
|
||||||
*) filtered_args+=("$arg") ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
exec ${toolchain}/bin/cargo ${"\${filtered_args[@]}"}
|
|
||||||
'';
|
|
||||||
rustc_codegen_spirv =
|
|
||||||
(pkgs.makeRustPlatform {
|
|
||||||
cargo = toolchain;
|
|
||||||
rustc = toolchain;
|
|
||||||
}).buildRustPackage
|
|
||||||
(finalAttrs: {
|
|
||||||
pname = "rustc_codegen_spirv";
|
|
||||||
version = "0.10.0";
|
|
||||||
src = pkgs.fetchCrate {
|
|
||||||
inherit (finalAttrs) pname version;
|
|
||||||
sha256 = "sha256-QluNI2TdJI0j2CBOeAbB9DfOv+8LqzWk7siZyT1WWLU=";
|
|
||||||
};
|
|
||||||
cargoHash = "sha256-vvviUccnip+j60Ml1vqLNJ49KyEF40VLUoV1TMALHMs=";
|
|
||||||
cargoBuildFlags = [
|
|
||||||
"-p"
|
|
||||||
"rustc_codegen_spirv"
|
|
||||||
"--features=use-compiled-tools"
|
|
||||||
"--no-default-features"
|
|
||||||
];
|
|
||||||
doCheck = false;
|
|
||||||
});
|
|
||||||
in
|
|
||||||
{
|
|
||||||
toolchain = toolchain;
|
|
||||||
env = {
|
|
||||||
RUST_GPU_PATH_OVERRIDE = "${cargo}/bin:${toolchain}/bin";
|
|
||||||
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
+6
-2
@@ -47,13 +47,17 @@ let
|
|||||||
# Plotting tools
|
# Plotting tools
|
||||||
pkgs.graphviz
|
pkgs.graphviz
|
||||||
];
|
];
|
||||||
|
libs = [
|
||||||
|
pkgs.vulkan-loader
|
||||||
|
];
|
||||||
|
env = {
|
||||||
|
VK_ADD_DRIVER_FILES = "${pkgs.mesa}/share/vulkan/icd.d/lvp_icd.${pkgs.stdenv.hostPlatform.uname.processor}.json";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
deps.rustGPU
|
|
||||||
(lib.optionalAttrs desktop (
|
(lib.optionalAttrs desktop (
|
||||||
{
|
{
|
||||||
libs = [
|
libs = [
|
||||||
pkgs.wayland
|
pkgs.wayland
|
||||||
pkgs.vulkan-loader
|
|
||||||
pkgs.libGL
|
pkgs.libGL
|
||||||
pkgs.libxkbcommon
|
pkgs.libxkbcommon
|
||||||
self.packages.${system}.graphite-cef
|
self.packages.${system}.graphite-cef
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
info,
|
|
||||||
deps,
|
|
||||||
self,
|
|
||||||
system,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
(deps.crane.lib.overrideToolchain (_: deps.rustGPU.toolchain)).buildPackage {
|
|
||||||
pname = "graphite-raster-nodes-shaders";
|
|
||||||
inherit (info) version src;
|
|
||||||
|
|
||||||
inherit (self.packages.${system}.graphite) cargoVendorDir cargoArtifacts;
|
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
env = deps.rustGPU.env;
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
cargo build -r -p raster-nodes-shaders
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
cp target/spirv-builder/spirv-unknown-naga-wgsl/release/deps/raster_nodes_shaders_entrypoint.wgsl $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
}
|
|
||||||
@@ -35,7 +35,6 @@ let
|
|||||||
inherit (deps.crane.lib.findCargoFiles (deps.crane.lib.cleanCargoSource info.src)) cargoConfigs;
|
inherit (deps.crane.lib.findCargoFiles (deps.crane.lib.cleanCargoSource info.src)) cargoConfigs;
|
||||||
cargoLockList = [
|
cargoLockList = [
|
||||||
"${info.src}/Cargo.lock"
|
"${info.src}/Cargo.lock"
|
||||||
"${deps.rustGPU.toolchain.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock"
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -97,7 +96,6 @@ deps.crane.lib.buildPackage (
|
|||||||
makeCacheWritable = true;
|
makeCacheWritable = true;
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
RASTER_NODES_SHADER_PATH = self.packages.${system}.graphite-raster-nodes-shaders;
|
|
||||||
GRAPHITE_GIT_COMMIT_HASH = self.rev or "unknown";
|
GRAPHITE_GIT_COMMIT_HASH = self.rev or "unknown";
|
||||||
GRAPHITE_GIT_COMMIT_DATE = self.lastModified or "unknown";
|
GRAPHITE_GIT_COMMIT_DATE = self.lastModified or "unknown";
|
||||||
CEF_PATH = "${self.packages.${system}.graphite-cef}/lib";
|
CEF_PATH = "${self.packages.${system}.graphite-cef}/lib";
|
||||||
|
|||||||
Generated
+42
-378
@@ -313,7 +313,6 @@ version = "2.13.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -336,7 +335,7 @@ name = "blending-nodes"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -378,7 +377,7 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"half",
|
"half",
|
||||||
@@ -396,7 +395,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@@ -488,29 +487,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo-gpu-install"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "668b4bd1b59810c4f907eeb36bb0f0a450c824219b2e599b9b8ef2b3ae056e94"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"cargo_metadata 0.21.0",
|
|
||||||
"directories",
|
|
||||||
"log",
|
|
||||||
"serde",
|
|
||||||
"spirv-builder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo-platform"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "84982c6c0ae343635a3a4ee6dedef965513735c8b183caa7289fa6e27399ebd4"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo-platform"
|
name = "cargo-platform"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@@ -550,37 +526,6 @@ dependencies = [
|
|||||||
"notify-debouncer-full",
|
"notify-debouncer-full",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo-util-schemas"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7dc1a6f7b5651af85774ae5a34b4e8be397d9cf4bc063b7e6dbd99a841837830"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"serde-untagged",
|
|
||||||
"serde-value",
|
|
||||||
"thiserror 2.0.18",
|
|
||||||
"toml 0.8.23",
|
|
||||||
"unicode-xid",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo_metadata"
|
|
||||||
version = "0.21.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5cfca2aaa699835ba88faf58a06342a314a950d2b9686165e038286c30316868"
|
|
||||||
dependencies = [
|
|
||||||
"camino",
|
|
||||||
"cargo-platform 0.2.0",
|
|
||||||
"cargo-util-schemas",
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"thiserror 2.0.18",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_metadata"
|
name = "cargo_metadata"
|
||||||
version = "0.23.1"
|
version = "0.23.1"
|
||||||
@@ -588,7 +533,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9"
|
checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"camino",
|
"camino",
|
||||||
"cargo-platform 0.3.3",
|
"cargo-platform",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -619,7 +564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "fb823e721b3ea203f4635e71532db2b010696c074518eb4f6154fd7f47fc6fcb"
|
checksum = "fb823e721b3ea203f4635e71532db2b010696c074518eb4f6154fd7f47fc6fcb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo_metadata 0.23.1",
|
"cargo_metadata",
|
||||||
"cef-dll-sys",
|
"cef-dll-sys",
|
||||||
"clap",
|
"clap",
|
||||||
"libloading 0.9.0",
|
"libloading 0.9.0",
|
||||||
@@ -781,8 +726,6 @@ version = "0.13.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
|
checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
|
||||||
"termcolor",
|
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -859,7 +802,7 @@ checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
|
|||||||
name = "control-protocol"
|
name = "control-protocol"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
@@ -948,17 +891,19 @@ dependencies = [
|
|||||||
"ctor",
|
"ctor",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
|
"half",
|
||||||
"image",
|
"image",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
"log",
|
"log",
|
||||||
"lyon_geom",
|
"lyon_geom",
|
||||||
"no-std-types",
|
|
||||||
"node-macro",
|
"node-macro",
|
||||||
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"num_enum",
|
||||||
"parley",
|
"parley",
|
||||||
"petgraph 0.7.1",
|
"petgraph",
|
||||||
"polycool",
|
"polycool",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
@@ -1226,15 +1171,6 @@ dependencies = [
|
|||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "directories"
|
|
||||||
version = "6.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "6.0.0"
|
version = "6.0.0"
|
||||||
@@ -1427,7 +1363,7 @@ name = "dyn-any"
|
|||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dyn-any-derive",
|
"dyn-any-derive",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1525,16 +1461,6 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "erased-serde"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"typeid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.3.13"
|
version = "0.3.13"
|
||||||
@@ -1580,15 +1506,6 @@ dependencies = [
|
|||||||
"regex-syntax 0.8.6",
|
"regex-syntax 0.8.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastnoise-lite"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3e5f3c3cc9081e5d0e18bcd50e80cd33cba47fc22f88a9da9c33ecd1c87ea5c0"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
@@ -1976,36 +1893,6 @@ dependencies = [
|
|||||||
"xml-rs",
|
"xml-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glam"
|
|
||||||
version = "0.30.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
"libm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glam"
|
|
||||||
version = "0.31.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "556f6b2ea90b8d15a74e0e7bb41671c9bdf38cd9f78c284d750b9ce58a2b5be7"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
"libm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glam"
|
|
||||||
version = "0.32.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f70749695b063ecbf6b62949ccccde2e733ec3ecbbd71d467dca4e5c6c97cca0"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
"libm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glam"
|
name = "glam"
|
||||||
version = "0.33.10"
|
version = "0.33.10"
|
||||||
@@ -2013,7 +1900,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "928452f9c953e142b2f0973e4bd5f34445fcaa8069556ea97a3c9d34d15a4cf8"
|
checksum = "928452f9c953e142b2f0973e4bd5f34445fcaa8069556ea97a3c9d34d15a4cf8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"libm",
|
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2066,7 +1952,7 @@ dependencies = [
|
|||||||
"core-types",
|
"core-types",
|
||||||
"criterion",
|
"criterion",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graph-craft",
|
"graph-craft",
|
||||||
"graphene-animation",
|
"graphene-animation",
|
||||||
"graphene-application-io",
|
"graphene-application-io",
|
||||||
@@ -2101,7 +1987,7 @@ name = "graphene-animation"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2114,7 +2000,7 @@ dependencies = [
|
|||||||
"blake3",
|
"blake3",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphene-resource",
|
"graphene-resource",
|
||||||
"log",
|
"log",
|
||||||
@@ -2131,7 +2017,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-application-io",
|
"graphene-application-io",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2169,7 +2055,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-animation",
|
"graphene-animation",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
@@ -2185,7 +2071,7 @@ dependencies = [
|
|||||||
name = "graphene-hash"
|
name = "graphene-hash"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash-derive",
|
"graphene-hash-derive",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
]
|
]
|
||||||
@@ -2220,7 +2106,7 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graph-craft",
|
"graph-craft",
|
||||||
"graphene-application-io",
|
"graphene-application-io",
|
||||||
"graphene-canvas-utils",
|
"graphene-canvas-utils",
|
||||||
@@ -2258,7 +2144,7 @@ dependencies = [
|
|||||||
"brush-types",
|
"brush-types",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -2274,7 +2160,7 @@ dependencies = [
|
|||||||
"brush-types",
|
"brush-types",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"raster-types",
|
"raster-types",
|
||||||
@@ -2295,7 +2181,7 @@ dependencies = [
|
|||||||
"dirs",
|
"dirs",
|
||||||
"fd-lock",
|
"fd-lock",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphite-desktop-ui",
|
"graphite-desktop-ui",
|
||||||
"graphite-desktop-wrapper",
|
"graphite-desktop-wrapper",
|
||||||
"interprocess",
|
"interprocess",
|
||||||
@@ -2420,7 +2306,7 @@ dependencies = [
|
|||||||
"dyn-any",
|
"dyn-any",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graph-craft",
|
"graph-craft",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphene-std",
|
"graphene-std",
|
||||||
@@ -3024,7 +2910,7 @@ dependencies = [
|
|||||||
"criterion",
|
"criterion",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graph-craft",
|
"graph-craft",
|
||||||
"graphene-animation",
|
"graphene-animation",
|
||||||
"graphene-core",
|
"graphene-core",
|
||||||
@@ -3302,7 +3188,7 @@ dependencies = [
|
|||||||
"ena",
|
"ena",
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"lalrpop-util",
|
"lalrpop-util",
|
||||||
"petgraph 0.7.1",
|
"petgraph",
|
||||||
"regex",
|
"regex",
|
||||||
"regex-syntax 0.8.6",
|
"regex-syntax 0.8.6",
|
||||||
"sha3",
|
"sha3",
|
||||||
@@ -3611,7 +3497,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-core",
|
"graphene-core",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"log",
|
"log",
|
||||||
@@ -3632,16 +3518,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "matrixmultiply"
|
|
||||||
version = "0.3.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"rawpointer",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.5"
|
version = "2.7.5"
|
||||||
@@ -3747,7 +3623,6 @@ dependencies = [
|
|||||||
"naga-types",
|
"naga-types",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"petgraph 0.8.2",
|
|
||||||
"rustc-hash 1.1.0",
|
"rustc-hash 1.1.0",
|
||||||
"spirv",
|
"spirv",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
@@ -3766,21 +3641,6 @@ dependencies = [
|
|||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ndarray"
|
|
||||||
version = "0.16.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841"
|
|
||||||
dependencies = [
|
|
||||||
"matrixmultiply",
|
|
||||||
"num-complex",
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
"portable-atomic",
|
|
||||||
"portable-atomic-util",
|
|
||||||
"rawpointer",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ndk"
|
name = "ndk"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@@ -3829,27 +3689,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "no-std-types"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
"core-types",
|
|
||||||
"dyn-any",
|
|
||||||
"glam 0.33.10",
|
|
||||||
"graphene-hash",
|
|
||||||
"half",
|
|
||||||
"log",
|
|
||||||
"node-macro",
|
|
||||||
"num-derive",
|
|
||||||
"num-traits",
|
|
||||||
"num_enum",
|
|
||||||
"serde",
|
|
||||||
"spirv-std",
|
|
||||||
"tsify",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "node-docs"
|
name = "node-docs"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
@@ -3869,7 +3708,6 @@ dependencies = [
|
|||||||
"convert_case 0.12.0",
|
"convert_case 0.12.0",
|
||||||
"core-types",
|
"core-types",
|
||||||
"indoc",
|
"indoc",
|
||||||
"no-std-types",
|
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro-error2",
|
"proc-macro-error2",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -3953,15 +3791,6 @@ dependencies = [
|
|||||||
"syn 2.0.106",
|
"syn 2.0.106",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-integer"
|
|
||||||
version = "0.1.46"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
@@ -4184,15 +4013,6 @@ dependencies = [
|
|||||||
"libredox",
|
"libredox",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ordered-float"
|
|
||||||
version = "2.10.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ordered-float"
|
name = "ordered-float"
|
||||||
version = "4.6.0"
|
version = "4.6.0"
|
||||||
@@ -4282,7 +4102,7 @@ name = "path-bool-nodes"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"linesweeper",
|
"linesweeper",
|
||||||
"log",
|
"log",
|
||||||
@@ -4327,17 +4147,6 @@ dependencies = [
|
|||||||
"indexmap",
|
"indexmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "petgraph"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca"
|
|
||||||
dependencies = [
|
|
||||||
"fixedbitset",
|
|
||||||
"hashbrown 0.15.5",
|
|
||||||
"indexmap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@@ -4598,7 +4407,7 @@ dependencies = [
|
|||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graph-craft",
|
"graph-craft",
|
||||||
"graphene-std",
|
"graphene-std",
|
||||||
"interpreted-executor",
|
"interpreted-executor",
|
||||||
@@ -4818,25 +4627,16 @@ dependencies = [
|
|||||||
"color",
|
"color",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"fastnoise-lite",
|
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-core",
|
"graphene-core",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphene-resource",
|
"graphene-resource",
|
||||||
"image",
|
|
||||||
"kurbo",
|
"kurbo",
|
||||||
"ndarray",
|
|
||||||
"no-std-types",
|
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"num-traits",
|
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"rand",
|
|
||||||
"rand_chacha",
|
|
||||||
"raster-nodes-shaders",
|
|
||||||
"raster-types",
|
"raster-types",
|
||||||
"serde",
|
"serde",
|
||||||
"spirv-std",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tsify",
|
"tsify",
|
||||||
"vector-types",
|
"vector-types",
|
||||||
@@ -4844,22 +4644,6 @@ dependencies = [
|
|||||||
"wgpu-executor",
|
"wgpu-executor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "raster-nodes-shaders"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"cargo-gpu-install",
|
|
||||||
"env_logger",
|
|
||||||
"log",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "raster-nodes-shaders-entrypoint"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"raster-nodes",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raster-types"
|
name = "raster-types"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
@@ -4868,7 +4652,7 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"image",
|
"image",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
@@ -4879,12 +4663,6 @@ dependencies = [
|
|||||||
"wgpu",
|
"wgpu",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "raw-string"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e0501e134c6905fee1f10fed25b0a7e1261bf676cffac9543a7d0730dec01af2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-handle"
|
name = "raw-window-handle"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
@@ -4903,12 +4681,6 @@ dependencies = [
|
|||||||
"objc2-quartz-core",
|
"objc2-quartz-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rawpointer"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.11.0"
|
version = "1.11.0"
|
||||||
@@ -5045,7 +4817,7 @@ dependencies = [
|
|||||||
"brush-types",
|
"brush-types",
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphene-resource",
|
"graphene-resource",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
@@ -5067,7 +4839,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-core",
|
"graphene-core",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
@@ -5197,16 +4969,6 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rspirv"
|
|
||||||
version = "0.13.0+sdk-1.4.341.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "091dca2e1d6fd3098417b5ec88e77e80d1ba5945750943419dc976858082c296"
|
|
||||||
dependencies = [
|
|
||||||
"rustc-hash 1.1.0",
|
|
||||||
"spirv",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.26"
|
version = "0.1.26"
|
||||||
@@ -5225,20 +4987,6 @@ version = "2.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_codegen_spirv-types"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d703f5624720c5b6012f4b88d6e6766f43ed50d80144eaffd6791c3270754cdc"
|
|
||||||
dependencies = [
|
|
||||||
"rspirv",
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"spirv",
|
|
||||||
"thiserror 2.0.18",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -5496,27 +5244,6 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde-untagged"
|
|
||||||
version = "0.1.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34836a629bcbc6f1afdf0907a744870039b1e14c0561cb26094fa683b158eff3"
|
|
||||||
dependencies = [
|
|
||||||
"erased-serde",
|
|
||||||
"serde",
|
|
||||||
"typeid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde-value"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
|
|
||||||
dependencies = [
|
|
||||||
"ordered-float 2.10.1",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde-wasm-bindgen"
|
name = "serde-wasm-bindgen"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
@@ -5784,7 +5511,7 @@ name = "snapping"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion",
|
"criterion",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -5825,62 +5552,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f"
|
checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.2",
|
"bitflags 2.13.2",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spirv-builder"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57fa119866f0311546e5309b18770b72141c25d185452c11a812be2c7b9d84e9"
|
|
||||||
dependencies = [
|
|
||||||
"cargo_metadata 0.21.0",
|
|
||||||
"log",
|
|
||||||
"memchr",
|
|
||||||
"raw-string",
|
|
||||||
"rustc_codegen_spirv-types",
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"thiserror 2.0.18",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spirv-std"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d98471765e294d4dd6289350e3633b5c5ba57bb382c3287d83e69ee737179e0"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.13.2",
|
|
||||||
"bytemuck",
|
|
||||||
"glam 0.30.10",
|
|
||||||
"glam 0.31.1",
|
|
||||||
"glam 0.32.1",
|
|
||||||
"glam 0.33.10",
|
|
||||||
"libm",
|
|
||||||
"num-traits",
|
|
||||||
"spirv-std-macros",
|
|
||||||
"spirv-std-types",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spirv-std-macros"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "13a6a0d063d4dd003e43818135b7aa4a30c41c48b5d0efe2cac02220448d4f19"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"spirv-std-types",
|
|
||||||
"syn 3.0.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spirv-std-types"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "655632248eaaa205cea4656bc73c8285cbd8109fc784010b24ea6bd0bab79ac1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -6099,15 +5772,6 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "termcolor"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "text-nodes"
|
name = "text-nodes"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
@@ -6116,7 +5780,7 @@ dependencies = [
|
|||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"fancy-regex",
|
"fancy-regex",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphene-resource",
|
"graphene-resource",
|
||||||
"ipsum",
|
"ipsum",
|
||||||
@@ -6521,7 +6185,7 @@ name = "transform-nodes"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core-types",
|
"core-types",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -6775,7 +6439,7 @@ dependencies = [
|
|||||||
"delaunator",
|
"delaunator",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-core",
|
"graphene-core",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"graphic-types",
|
"graphic-types",
|
||||||
@@ -6803,14 +6467,14 @@ dependencies = [
|
|||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"fixedbitset",
|
"fixedbitset",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-hash",
|
"graphene-hash",
|
||||||
"kurbo",
|
"kurbo",
|
||||||
"log",
|
"log",
|
||||||
"lyon_geom",
|
"lyon_geom",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"petgraph 0.7.1",
|
"petgraph",
|
||||||
"polycool",
|
"polycool",
|
||||||
"robust",
|
"robust",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
@@ -7100,7 +6764,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"control-protocol",
|
"control-protocol",
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.3",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"image",
|
"image",
|
||||||
"interprocess",
|
"interprocess",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -7208,7 +6872,6 @@ dependencies = [
|
|||||||
"hashbrown 0.17.1",
|
"hashbrown 0.17.1",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"naga",
|
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"portable-atomic",
|
"portable-atomic",
|
||||||
"profiling",
|
"profiling",
|
||||||
@@ -7303,8 +6966,9 @@ dependencies = [
|
|||||||
"core-types",
|
"core-types",
|
||||||
"dyn-any",
|
"dyn-any",
|
||||||
"futures",
|
"futures",
|
||||||
"glam 0.33.10",
|
"glam",
|
||||||
"graphene-application-io",
|
"graphene-application-io",
|
||||||
|
"half",
|
||||||
"log",
|
"log",
|
||||||
"node-macro",
|
"node-macro",
|
||||||
"raster-types",
|
"raster-types",
|
||||||
@@ -7349,7 +7013,7 @@ dependencies = [
|
|||||||
"objc2-metal",
|
"objc2-metal",
|
||||||
"objc2-quartz-core",
|
"objc2-quartz-core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ordered-float 4.6.0",
|
"ordered-float",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"portable-atomic",
|
"portable-atomic",
|
||||||
"portable-atomic-util",
|
"portable-atomic-util",
|
||||||
|
|||||||
+3
-13
@@ -22,8 +22,6 @@ members = [
|
|||||||
"node-graph/libraries/graphene-hash",
|
"node-graph/libraries/graphene-hash",
|
||||||
"node-graph/libraries/*",
|
"node-graph/libraries/*",
|
||||||
"node-graph/nodes/*",
|
"node-graph/nodes/*",
|
||||||
"node-graph/nodes/raster/shaders",
|
|
||||||
"node-graph/nodes/raster/shaders/entrypoint",
|
|
||||||
"node-graph/graph-craft",
|
"node-graph/graph-craft",
|
||||||
"node-graph/graphene-cli",
|
"node-graph/graphene-cli",
|
||||||
"node-graph/nodes/gstd",
|
"node-graph/nodes/gstd",
|
||||||
@@ -83,7 +81,6 @@ graphene-application-io = { path = "node-graph/libraries/application-io" }
|
|||||||
graphene-resource = { path = "node-graph/libraries/resources" }
|
graphene-resource = { path = "node-graph/libraries/resources" }
|
||||||
graphene-animation = { path = "node-graph/libraries/animation" }
|
graphene-animation = { path = "node-graph/libraries/animation" }
|
||||||
core-types = { path = "node-graph/libraries/core-types" }
|
core-types = { path = "node-graph/libraries/core-types" }
|
||||||
no-std-types = { path = "node-graph/libraries/no-std-types" }
|
|
||||||
raster-types = { path = "node-graph/libraries/raster-types" }
|
raster-types = { path = "node-graph/libraries/raster-types" }
|
||||||
vector-types = { path = "node-graph/libraries/vector-types" }
|
vector-types = { path = "node-graph/libraries/vector-types" }
|
||||||
graphic-types = { path = "node-graph/libraries/graphic-types" }
|
graphic-types = { path = "node-graph/libraries/graphic-types" }
|
||||||
@@ -155,7 +152,6 @@ wgpu = { version = "30.0", default-features = false, features = [
|
|||||||
"webgl",
|
"webgl",
|
||||||
# We don't have wgpu on multiple threads (yet) https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#wgpu-types-now-send-sync-on-wasm
|
# We don't have wgpu on multiple threads (yet) https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#wgpu-types-now-send-sync-on-wasm
|
||||||
"fragile-send-sync-non-atomic-wasm",
|
"fragile-send-sync-non-atomic-wasm",
|
||||||
"spirv",
|
|
||||||
"strict_asserts",
|
"strict_asserts",
|
||||||
] }
|
] }
|
||||||
once_cell = "1.13" # Remove and replace with `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>)
|
once_cell = "1.13" # Remove and replace with `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>)
|
||||||
@@ -197,7 +193,7 @@ color = "0.3"
|
|||||||
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
|
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
|
||||||
rand_chacha = "0.9"
|
rand_chacha = "0.9"
|
||||||
glam = { version = "0.33", default-features = false, features = [
|
glam = { version = "0.33", default-features = false, features = [
|
||||||
"nostd-libm",
|
"std",
|
||||||
"scalar-math",
|
"scalar-math",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"debug-glam-assert",
|
"debug-glam-assert",
|
||||||
@@ -223,7 +219,7 @@ pretty_assertions = "1.4"
|
|||||||
fern = { version = "0.7", features = ["colored"] }
|
fern = { version = "0.7", features = ["colored"] }
|
||||||
num_enum = { version = "0.7", default-features = false }
|
num_enum = { version = "0.7", default-features = false }
|
||||||
num-derive = "0.4"
|
num-derive = "0.4"
|
||||||
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
num-traits = "0.2"
|
||||||
tsify = { version = "0.5", default-features = false, features = ["js"] }
|
tsify = { version = "0.5", default-features = false, features = ["js"] }
|
||||||
syn = { version = "2.0", default-features = false, features = [
|
syn = { version = "2.0", default-features = false, features = [
|
||||||
"full",
|
"full",
|
||||||
@@ -257,10 +253,6 @@ open = "5.3"
|
|||||||
spin = "0.10"
|
spin = "0.10"
|
||||||
clap = "4.5"
|
clap = "4.5"
|
||||||
|
|
||||||
# Ensure these are kept in sync with .nix/deps/rust-gpu.nix
|
|
||||||
spirv-std = { version = "0.10.0", features = ["bytemuck"] }
|
|
||||||
cargo-gpu-install = { version = "0.10.0", default-features = false }
|
|
||||||
|
|
||||||
qrcodegen = "1.8"
|
qrcodegen = "1.8"
|
||||||
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
||||||
scraper = "0.25"
|
scraper = "0.25"
|
||||||
@@ -268,14 +260,12 @@ linesweeper = "0.4"
|
|||||||
smallvec = "1.13.2"
|
smallvec = "1.13.2"
|
||||||
zip = { version = "8", default-features = false }
|
zip = { version = "8", default-features = false }
|
||||||
|
|
||||||
[workspace.lints.rust]
|
[workspace.lints]
|
||||||
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 1
|
opt-level = 1
|
||||||
|
|
||||||
[profile.dev.package]
|
[profile.dev.package]
|
||||||
no-std-types = { opt-level = 1 }
|
|
||||||
core-types= { opt-level = 1 }
|
core-types= { opt-level = 1 }
|
||||||
interpreted-executor = { opt-level = 1 } # This is a mitigation for https://github.com/rustwasm/wasm-pack/issues/981 which is needed because the node_registry function is too large
|
interpreted-executor = { opt-level = 1 } # This is a mitigation for https://github.com/rustwasm/wasm-pack/issues/981 which is needed because the node_registry function is too large
|
||||||
graphite-proc-macros = { opt-level = 1 }
|
graphite-proc-macros = { opt-level = 1 }
|
||||||
|
|||||||
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[57904581517036791,{"inputs":[{"Node":{"node_id":9393309733761233513,"output_index":0}},{"Node":{"node_id":15300421479077882117,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[70804263053697201,{"inputs":[{"Node":{"node_id":13942787566051910019,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[3.410605131648481e-13,3.410605131648481e-13]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1268.999999999999,634.9999999999992]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[194878846429432339,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4],"remove":[],"delta":[[1,[671.7691453623979,420.00000000000006]],[2,[559.8076211353317,450.0000000000001]],[3,[410.5255888325765,410.0]],[4,[522.4871130596428,380.00000000000006]]]},"segments":{"add":[1,2,3,4],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4]],"end_point":[[1,2],[2,3],[3,4],[4,1]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]],"handle_end":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplicLine truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[57904581517036791,{"inputs":[{"Node":{"node_id":9393309733761233513,"output_index":0}},{"Node":{"node_id":15300421479077882117,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[70804263053697201,{"inputs":[{"Node":{"node_id":13942787566051910019,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[3.410605131648481e-13,3.410605131648481e-13]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1268.999999999999,634.9999999999992]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false}],[194878846429432339,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4],"remove":[],"delta":[[1,[671.7691453623979,420.00000000000006]],[2,[559.8076211353317,450.0000000000001]],[3,[410.5255888325765,410.0]],[4,[522.4871130596428,380.00000000000006]]]},"segments":{"add":[1,2,3,4],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4]],"end_point":[[1,2],[2,3],[3,4],[4,1]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]],"handle_end":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]]},"add_g1_continuous":[],"remove_g1_continuous":[],"path_breaks":[1]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[322234583139821148,{"inputs":[{"Node":{"node_id":6589978257209505606,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[-261.2435565297001,-70.0]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"trLine truncated
|
||||||
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[80924370013313595,{"inputs":[{"Node":{"node_id":6029481207635803402,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.06469504,"green":0.0,"blue":0.0755814,"alpha":1.0,"linear":true},{"red":0.016644126,"green":0.13212071,"blue":0.62523156,"alpha":1.0,"linear":true},{"red":1.0,"green":0.8708812,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.30054384,"green":0.8468733,"blue":0.8468733,"alpha":0.01,"linear":true}],"position":[0.0,0.12704918032786883,0.5,1.0],"midpoint":[0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":0.04631017,"green":0.0,"blue":0.0076861563,"alpha":1.0,"linear":true},{"red":0.83939683,"green":0.7249875,"blue":0.27055356,"alpha":1.0,"linear":true},{"red":0.025397457,"green":0.3485102,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.01102731,"green":0.09231063,"blue":0.09231063,"alpha":1.0,"linear":true}],"position":[0.0,0.3237704918032787,0.5655737704918032,0.8155737704918032,1.0],"midpoint":[0.5,0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4388711862172196665,{"inputs":[],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[6323350524796370485,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"Integer":0},"exposed":false}},{"Value":{"tagged_value":{"Number":35.0},"exposed":false}},{"Value":{"tagged_value":{"NoiseType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"DomainWarpType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}},{"Value":{"tagged_value":{"FractalType":"PingPong"},"exposed":false}},{"Value":{"tagged_value":{"Integer":3},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"Number":0.5},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"CellularDistanceFunction":"Hybrid"},"exposed":false}},{"Value":{"tagged_value":{"CellularReturnType":"CellValue"},"exposed":false}},{"Value":{"tagged_value":{"Number":1.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::NoisePatternNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[6565638614909771142,{"inputs":[{"Node":{"node_id":7624113397561636853,"output_index":0}},{"Node":{"node_id":80924370013313595,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"GeLine truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[80924370013313595,{"inputs":[{"Node":{"node_id":6029481207635803402,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.06469504,"green":0.0,"blue":0.0755814,"alpha":1.0,"linear":true},{"red":0.016644126,"green":0.13212071,"blue":0.62523156,"alpha":1.0,"linear":true},{"red":1.0,"green":0.8708812,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.30054384,"green":0.8468733,"blue":0.8468733,"alpha":0.01,"linear":true}],"position":[0.0,0.12704918032786883,0.5,1.0],"midpoint":[0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Scope":"raster_nodes::raster_kernel::RasterKernelPipelineNode"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":0.04631017,"green":0.0,"blue":0.0076861563,"alpha":1.0,"linear":true},{"red":0.83939683,"green":0.7249875,"blue":0.27055356,"alpha":1.0,"linear":true},{"red":0.025397457,"green":0.3485102,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.01102731,"green":0.09231063,"blue":0.09231063,"alpha":1.0,"linear":true}],"position":[0.0,0.3237704918032787,0.5655737704918032,0.8155737704918032,1.0],"midpoint":[0.5,0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Scope":"raster_nodes::raster_kernel::RasterKernelPipelineNode"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false}],[4388711862172196665,{"inputs":[{"Scope":"raster_nodes::raster_kernel::RasterKernelPipelineNode"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false}],[6323350524796370485,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"Integer":0},"exposed":false}},{"Value":{"tagged_value":{"Number":35.0},"exposed":false}},{"Value":{"tagged_value":{"NoiseType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"DomainWarpType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}},{"Value":{"tagged_value":{"FractalType":"PingPong"},"exposed":false}},{"Value":{"tagged_value":{"Integer":3},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"Number":0.5},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"CellularDistanceFunction":"Hybrid"},"exposed":false}},{"Value":{"tagged_value":{"CellularReturnType":"CellValue"},"exposed":false}},{"Value":{"tagged_value":{"Number":1.0},"exposed":false}},{"Scope":"raster_nodes::raster_kernel::RasterKernelPipelineNode"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::NoisePatternNode"}},"visible":true,"skip_deduplication":false}],[6565638614909771142,{"inputs":[{"Node":{"node_id":7624113397561636853,"output_index":0}},{"Node":{"node_id":80924370013313595,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}]Line truncated
|
||||||
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[57390435731316553,{"inputs":[{"Node":{"node_id":8460565235419043665,"output_index":0}},{"Node":{"node_id":13838011362258067867,"output_index":0}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[140396870212231820,{"inputs":[{"Node":{"node_id":18095952297474762348,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Intersect"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[294265135510952894,{"inputs":[{"Node":{"node_id":11264395591110193456,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.83076996,"green":0.32314324,"blue":0.027320892,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.6938719,"green":0.048171822,"blue":0.028426038,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[20.0,0.0,0.0,20.0,-10.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[392274448837115448,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::artboard::Artboard"}}}},"exposed":true}},{"Node":{"node_id":6787585796949551500,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1536.0,768.0]},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.8549927,"green":0.71569365,"blue":0.48514998,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"Generic":"T"}]},"import_index":1}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":2}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":3}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":4}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":5}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::artboard::CreateArtboardNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":1,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"List":{"Concrete":{"nameLine truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[57390435731316553,{"inputs":[{"Node":{"node_id":8460565235419043665,"output_index":0}},{"Node":{"node_id":13838011362258067867,"output_index":0}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false}],[140396870212231820,{"inputs":[{"Node":{"node_id":18095952297474762348,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Intersect"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false}],[294265135510952894,{"inputs":[{"Node":{"node_id":11264395591110193456,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.83076996,"green":0.32314324,"blue":0.027320892,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.6938719,"green":0.048171822,"blue":0.028426038,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[20.0,0.0,0.0,20.0,-10.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false}],[392274448837115448,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::artboard::Artboard"}}}},"exposed":true}},{"Node":{"node_id":6787585796949551500,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1536.0,768.0]},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.8549927,"green":0.71569365,"blue":0.48514998,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"Generic":"T"}]},"import_index":1}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":2}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":3}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":4}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":5}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::artboard::CreateArtboardNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":1,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[4,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"List":{"Concrete":{"name":"graphic_types::artboard::Artboard"}}}]},"import_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_dedLine truncated
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[239716716021064150,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":7711570794020903773,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1801066723091712434,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"red":0.036889445,"green":0.038204364,"blue":0.043735027,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Number":1744.31393592},"exposed":false}},{"Value":{"tagged_value":{"Number":63.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Number":4000.0},"exposed":false}},{"Value":{"tagged_value":{"Number":500.0},"exposed":false}},{"Value":{"tagged_value":{"BoxCorners":[0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"vector_nodes::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"red":0.9911022,"green":0.6514057,"blue":0.39157256,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[1.0,0.0,0.0,1.0,0.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2288754089236120499,{"inputs":[{"Node":{"node_id":1415828794531Line truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[239716716021064150,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":7711570794020903773,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[1801066723091712434,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"red":0.036889445,"green":0.038204364,"blue":0.043735027,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Number":1744.31393592},"exposed":false}},{"Value":{"tagged_value":{"Number":63.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Number":4000.0},"exposed":false}},{"Value":{"tagged_value":{"Number":500.0},"exposed":false}},{"Value":{"tagged_value":{"BoxCorners":[0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"vector_nodes::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"red":0.9911022,"green":0.6514057,"blue":0.39157256,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[1.0,0.0,0.0,1.0,0.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false}],[2288754089236120499,{"inputs":[{"Node":{"node_id":14158287945315818946,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"core_types::vector::SplineNode"}},"visible":true,"skip_deduplication":false}],[7828034197076821310,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":3}}],"call_argument":{"Concrete":{"name":"core::option::Option<Line truncated
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[169695252050218443,{"inputs":[{"Node":{"node_id":13907401402762847509,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.75,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.7734375,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Radial"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[31.55635094002563,-2.7755575615628914e-17,2.7755575615628914e-17,31.55635094002563,-0.225779263556106,34.981204988590605]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[655907162126315400,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11],"remove":[],"delta":[[1,[416.0,270.9999999999999]],[2,[587.0,291.9999999999999]],[3,[373.0,372.9999999999999]],[4,[484.0,446.9999999999999]],[5,[639.0,438.9999999999999]],[6,[495.0,533.9999999999999]],[7,[304.0,611.9999999999999]],[8,[475.0,671.9999999999999]],[9,[750.0,703.9999999999999]],[10,[455.0,824.9999999999999]],[11,[186.0,824.9999999999999]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]],[5,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[0.0,0.0]],[9,[0.0,0.0]],[10,[0.0,0.0]]],"handle_end":Line truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[169695252050218443,{"inputs":[{"Node":{"node_id":13907401402762847509,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.75,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.7734375,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Radial"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[31.55635094002563,-2.7755575615628914e-17,2.7755575615628914e-17,31.55635094002563,-0.225779263556106,34.981204988590605]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false}],[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[655907162126315400,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11],"remove":[],"delta":[[1,[416.0,270.9999999999999]],[2,[587.0,291.9999999999999]],[3,[373.0,372.9999999999999]],[4,[484.0,446.9999999999999]],[5,[639.0,438.9999999999999]],[6,[495.0,533.9999999999999]],[7,[304.0,611.9999999999999]],[8,[475.0,671.9999999999999]],[9,[750.0,703.9999999999999]],[10,[455.0,824.9999999999999]],[11,[186.0,824.9999999999999]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]],[5,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[0.0,0.0]],[9,[0.0,0.0]],[10,[0.0,0.0]]],"handle_end":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]],[5,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[0.0,0.0]],[9,[0.0,0.0]],[10,[0.0,0.0]]]},"add_g1_continuous":[],"remove_g1_continuous":[],"path_breaks":[1]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[Line truncated
|
||||||
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[1378578509112405,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5],"remove":[],"delta":[[1,[602.6886145404666,50.91906721536352]],[2,[599.5281207133061,50.3923182441701]],[3,[590.4855967078191,66.80932784636488]],[4,[594.6410608139003,75.57872275567746]],[5,[593.3924706599604,60.59564090839812]]]},"segments":{"add":[1,2,3,4,5],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,1]],"handle_primary":[[1,[0.0,0.0]],[2,[-1.843621399176982,0.5267489711934203]],[3,[1.9314128943758533,7.3257125438195345]],[4,[0.0,0.0]],[5,[1.248590153939972,-3.9798811156835896]]],"handle_end":[[1,[1.843621399176982,-0.5267489711934203]],[2,[-2.7532629181224593,-10.4429315732828]],[3,[0.0,0.0]],[4,[-1.704168058538812,5.432035686592322]],[5,[-4.379820149367788,0.9754610577655498]]]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[172538270105470471,{"inputs":[{"Node":{"node_id":9276497172451351253,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[2.170365521878466,0.0,0.0,2.170365521878466,604.9565968314213,108.54930650815425]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[314278016428495768,{"inputs":[{"Node":{"node_id":6282972142629473139,"output_index":0}},{"Node":{"node_id":5020096817747898028,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpLine truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[1378578509112405,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5],"remove":[],"delta":[[1,[602.6886145404666,50.91906721536352]],[2,[599.5281207133061,50.3923182441701]],[3,[590.4855967078191,66.80932784636488]],[4,[594.6410608139003,75.57872275567746]],[5,[593.3924706599604,60.59564090839812]]]},"segments":{"add":[1,2,3,4,5],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,1]],"handle_primary":[[1,[0.0,0.0]],[2,[-1.843621399176982,0.5267489711934203]],[3,[1.9314128943758533,7.3257125438195345]],[4,[0.0,0.0]],[5,[1.248590153939972,-3.9798811156835896]]],"handle_end":[[1,[1.843621399176982,-0.5267489711934203]],[2,[-2.7532629181224593,-10.4429315732828]],[3,[0.0,0.0]],[4,[-1.704168058538812,5.432035686592322]],[5,[-4.379820149367788,0.9754610577655498]]]},"add_g1_continuous":[],"remove_g1_continuous":[],"path_breaks":[1]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[172538270105470471,{"inputs":[{"Node":{"node_id":9276497172451351253,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[2.170365521878466,0.0,0.0,2.170365521878466,604.9565968314213,108.54930650815425]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false}],[314278016428495768,{"inputs":[{"Node":{"node_id":6282972142629473139,"output_index":0}},{"Node":{"node_id":5020096817747898028,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>Line truncated
|
||||||
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[74,{"inputs":[{"Node":{"node_id":75,"output_index":0}},{"Node":{"node_id":81,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[75,{"inputs":[{"Node":{"node_id":76,"output_index":0}},{"Node":{"node_id":161,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_Line truncated
|
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[74,{"inputs":[{"Node":{"node_id":75,"output_index":0}},{"Node":{"node_id":81,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[75,{"inputs":[{"Node":{"node_id":76,"output_index":0}},{"Node":{"node_id":161,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false}],[76,{"inputs":[{"Node":{"node_id":77,"output_index":0}},{"Node":{"node_id":16164610528699022118,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_dedupLine truncated
|
||||||
@@ -187,7 +187,7 @@ allow-git = []
|
|||||||
|
|
||||||
[sources.allow-org]
|
[sources.allow-org]
|
||||||
# 1 or more github.com organizations to allow git sources for
|
# 1 or more github.com organizations to allow git sources for
|
||||||
github = ["linebender", "Rust-GPU"]
|
github = ["linebender"]
|
||||||
# 1 or more gitlab.com organizations to allow git sources for
|
# 1 or more gitlab.com organizations to allow git sources for
|
||||||
#gitlab = [""]
|
#gitlab = [""]
|
||||||
# 1 or more bitbucket.org organizations to allow git sources for
|
# 1 or more bitbucket.org organizations to allow git sources for
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ publish.workspace = true
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
gpu = ["graphite-editor/gpu", "graphene-std/shader-nodes"]
|
gpu = ["graphite-editor/gpu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Local dependencies
|
# Local dependencies
|
||||||
|
|||||||
@@ -625,8 +625,6 @@ fn convert_input<M: NodeMetadataSource + ?Sized>(input: &GraphCraftNodeInput, pa
|
|||||||
index: (*import_index).try_into().map_err(|_| ConversionError::IndexOverflow(*import_index))?,
|
index: (*import_index).try_into().map_err(|_| ConversionError::IndexOverflow(*import_index))?,
|
||||||
},
|
},
|
||||||
GraphCraftNodeInput::Reflection(_) => NodeInput::Reflection,
|
GraphCraftNodeInput::Reflection(_) => NodeInput::Reflection,
|
||||||
// GPU-specific; not modeled in the Registry format.
|
|
||||||
GraphCraftNodeInput::Inline(_) => return Err(ConversionError::UnsupportedImplementation),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use graphene_std::raster::{
|
|||||||
AdjustmentChannel, CellularDistanceFunction, CellularReturnType, DesaturateMethod, DomainWarpType, FractalType, HueSaturationRange, NoiseType, RedGreenBlue, RelativeAbsolute,
|
AdjustmentChannel, CellularDistanceFunction, CellularReturnType, DesaturateMethod, DomainWarpType, FractalType, HueSaturationRange, NoiseType, RedGreenBlue, RelativeAbsolute,
|
||||||
SelectiveColorChoice, TonalRange,
|
SelectiveColorChoice, TonalRange,
|
||||||
};
|
};
|
||||||
use graphene_std::raster_types::{CPU, GPU, Raster};
|
use graphene_std::raster_types::{CPU, GPU, Raster, Storage};
|
||||||
use graphene_std::text::TextAlign;
|
use graphene_std::text::TextAlign;
|
||||||
use graphene_std::text_nodes::{StringCapitalization, TextDenomination};
|
use graphene_std::text_nodes::{StringCapitalization, TextDenomination};
|
||||||
use graphene_std::transfer_curve::TransferCurve;
|
use graphene_std::transfer_curve::TransferCurve;
|
||||||
@@ -944,9 +944,15 @@ impl TableItemLayout for Raster<GPU> {
|
|||||||
"Raster"
|
"Raster"
|
||||||
}
|
}
|
||||||
fn identifier(&self) -> String {
|
fn identifier(&self) -> String {
|
||||||
format!("Raster ({} x {})", self.data().width(), self.data().height())
|
let size = self.size();
|
||||||
|
format!("Raster ({} x {})", size.x, size.y)
|
||||||
}
|
}
|
||||||
fn value_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
fn value_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
|
if self.is_empty() {
|
||||||
|
let widgets = vec![TextLabel::new("Image has no area").widget_instance()];
|
||||||
|
return vec![LayoutGroup::row(widgets)];
|
||||||
|
}
|
||||||
|
|
||||||
let widgets = vec![TextLabel::new("This raster data is a texture on the GPU. It currently cannot be displayed here.").widget_instance()];
|
let widgets = vec![TextLabel::new("This raster data is a texture on the GPU. It currently cannot be displayed here.").widget_instance()];
|
||||||
vec![LayoutGroup::row(widgets)]
|
vec![LayoutGroup::row(widgets)]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -611,7 +611,10 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
NodeTemplate {
|
NodeTemplate {
|
||||||
inputs: vec![NodeInput::node(NodeId(0), 0)],
|
inputs: vec![
|
||||||
|
NodeInput::node(NodeId(0), 0),
|
||||||
|
NodeInput::scope(raster_nodes::raster_kernel::raster_kernel_pipeline::IDENTIFIER.as_str().to_string()),
|
||||||
|
],
|
||||||
implementation: NodeTemplateImplementation::ProtoNode(platform_application_io::bytes_to_image::IDENTIFIER),
|
implementation: NodeTemplateImplementation::ProtoNode(platform_application_io::bytes_to_image::IDENTIFIER),
|
||||||
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(7, 0)),
|
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(7, 0)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -1368,8 +1368,8 @@ fn type_choice_sections(offered: &[Type]) -> Vec<Vec<Type>> {
|
|||||||
vec![
|
vec![
|
||||||
concrete!(Graphic),
|
concrete!(Graphic),
|
||||||
concrete!(Vector),
|
concrete!(Vector),
|
||||||
concrete!(Raster<CPU>),
|
|
||||||
concrete!(Raster<GPU>),
|
concrete!(Raster<GPU>),
|
||||||
|
concrete!(Raster<CPU>),
|
||||||
concrete!(Color),
|
concrete!(Color),
|
||||||
concrete!(Gradient),
|
concrete!(Gradient),
|
||||||
concrete!(String),
|
concrete!(String),
|
||||||
|
|||||||
@@ -902,7 +902,7 @@ impl NodeNetworkInterface {
|
|||||||
let layer_output = NodeInput::node(layer.to_node(), 0);
|
let layer_output = NodeInput::node(layer.to_node(), 0);
|
||||||
|
|
||||||
match post_node_input {
|
match post_node_input {
|
||||||
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Inline(_) | NodeInput::Reflection(_) => {
|
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Reflection(_) => {
|
||||||
// First child in the stack: wire layer output to the post_node input
|
// First child in the stack: wire layer output to the post_node input
|
||||||
self.set_input_for_import(&post_node, layer_output, network_path);
|
self.set_input_for_import(&post_node, layer_output, network_path);
|
||||||
}
|
}
|
||||||
@@ -1031,7 +1031,7 @@ impl NodeNetworkInterface {
|
|||||||
if !inserting_into_stack {
|
if !inserting_into_stack {
|
||||||
match post_node_input {
|
match post_node_input {
|
||||||
// Create a new stack
|
// Create a new stack
|
||||||
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Inline(_) | NodeInput::Reflection(_) => {
|
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Reflection(_) => {
|
||||||
self.create_wire(&OutputConnector::primary_output(layer.to_node()), &post_node, network_path);
|
self.create_wire(&OutputConnector::primary_output(layer.to_node()), &post_node, network_path);
|
||||||
|
|
||||||
let final_layer_position = after_move_post_layer_position + IVec2::new(-LAYER_INDENT_OFFSET, STACK_VERTICAL_GAP);
|
let final_layer_position = after_move_post_layer_position + IVec2::new(-LAYER_INDENT_OFFSET, STACK_VERTICAL_GAP);
|
||||||
@@ -1057,7 +1057,7 @@ impl NodeNetworkInterface {
|
|||||||
} else {
|
} else {
|
||||||
match post_node_input {
|
match post_node_input {
|
||||||
// Move to the bottom of the stack
|
// Move to the bottom of the stack
|
||||||
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Inline(_) | NodeInput::Reflection(_) => {
|
NodeInput::Value { .. } | NodeInput::Scope(_) | NodeInput::Reflection(_) => {
|
||||||
let offset = after_move_post_layer_position - previous_layer_position + IVec2::new(0, STACK_VERTICAL_GAP + height_above_layer);
|
let offset = after_move_post_layer_position - previous_layer_position + IVec2::new(0, STACK_VERTICAL_GAP + height_above_layer);
|
||||||
self.shift_absolute_node_position(&layer.to_node(), offset, network_path);
|
self.shift_absolute_node_position(&layer.to_node(), offset, network_path);
|
||||||
self.create_wire(&OutputConnector::primary_output(layer.to_node()), &post_node, network_path);
|
self.create_wire(&OutputConnector::primary_output(layer.to_node()), &post_node, network_path);
|
||||||
|
|||||||
@@ -659,13 +659,13 @@ impl NodeNetworkInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A wire to or from the imports changed
|
// A wire to or from the imports changed
|
||||||
(NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. } | NodeInput::Import { .. }, NodeInput::Import { .. })
|
(NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Import { .. }, NodeInput::Import { .. })
|
||||||
| (NodeInput::Import { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. }) => {
|
| (NodeInput::Import { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. }) => {
|
||||||
self.unload_wire(input_connector, network_path);
|
self.unload_wire(input_connector, network_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A node was disconnected
|
// A node was disconnected
|
||||||
(NodeInput::Node { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. } | NodeInput::Import { .. }) => {
|
(NodeInput::Node { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Import { .. }) => {
|
||||||
self.unload_wire(input_connector, network_path);
|
self.unload_wire(input_connector, network_path);
|
||||||
|
|
||||||
if let Some((old_upstream_node_id, previous_position)) = disconnected_upstream
|
if let Some((old_upstream_node_id, previous_position)) = disconnected_upstream
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{DocumentNodeImplementation, InlineRust, NodeInput};
|
use graph_craft::document::{DocumentNodeImplementation, NodeInput};
|
||||||
use graph_craft::proto::{GraphErrorType, GraphErrors, Promotion};
|
use graph_craft::proto::{GraphErrorType, GraphErrors, Promotion};
|
||||||
use graph_craft::{ProtoNodeIdentifier, Type, concrete};
|
use graph_craft::{ProtoNodeIdentifier, Type, concrete};
|
||||||
use graphene_std::NodeIOTypes;
|
use graphene_std::NodeIOTypes;
|
||||||
@@ -257,7 +257,6 @@ impl NodeNetworkInterface {
|
|||||||
}
|
}
|
||||||
NodeInput::Scope(_) => TypeSource::Compiled(concrete!(())),
|
NodeInput::Scope(_) => TypeSource::Compiled(concrete!(())),
|
||||||
NodeInput::Reflection(document_node_metadata) => TypeSource::Compiled(document_node_metadata.ty()),
|
NodeInput::Reflection(document_node_metadata) => TypeSource::Compiled(document_node_metadata.ty()),
|
||||||
NodeInput::Inline(_) => TypeSource::Compiled(concrete!(InlineRust)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use graphene_std::ParameterRef;
|
|||||||
use graphene_std::ProtoNodeIdentifier;
|
use graphene_std::ProtoNodeIdentifier;
|
||||||
use graphene_std::extract_xy::XY;
|
use graphene_std::extract_xy::XY;
|
||||||
use graphene_std::raster::RedGreenBlueAlpha;
|
use graphene_std::raster::RedGreenBlueAlpha;
|
||||||
|
use graphene_std::raster_types::{CPU, GPU, Raster};
|
||||||
use graphene_std::text::{TextAlign, TypesettingConfig};
|
use graphene_std::text::{TextAlign, TypesettingConfig};
|
||||||
use graphene_std::transform::ScaleType;
|
use graphene_std::transform::ScaleType;
|
||||||
use graphene_std::uuid::NodeId;
|
use graphene_std::uuid::NodeId;
|
||||||
@@ -497,6 +498,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::BlackAndWhiteNode",
|
"graphene_raster_nodes::adjustments::BlackAndWhiteNode",
|
||||||
"graphene_core::raster::adjustments::BlackAndWhiteNode",
|
"graphene_core::raster::adjustments::BlackAndWhiteNode",
|
||||||
"graphene_core::raster::BlackAndWhiteNode",
|
"graphene_core::raster::BlackAndWhiteNode",
|
||||||
|
"raster_nodes::adjustments::black_and_white_shader_node::BlackAndWhiteShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -522,6 +524,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_core::raster::adjustments::BrightnessContrastNode",
|
"graphene_core::raster::adjustments::BrightnessContrastNode",
|
||||||
"graphene_raster_nodes::adjustments::brightness_contrast_classic",
|
"graphene_raster_nodes::adjustments::brightness_contrast_classic",
|
||||||
"graphene_raster_nodes::adjustments::BrightnessContrastClassicNode",
|
"graphene_raster_nodes::adjustments::BrightnessContrastClassicNode",
|
||||||
|
"raster_nodes::adjustments::brightness_contrast_shader_node::BrightnessContrastShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -530,8 +533,13 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::ChannelMixerNode",
|
"graphene_raster_nodes::adjustments::ChannelMixerNode",
|
||||||
"graphene_core::raster::adjustments::ChannelMixerNode",
|
"graphene_core::raster::adjustments::ChannelMixerNode",
|
||||||
"graphene_core::raster::ChannelMixerNode",
|
"graphene_core::raster::ChannelMixerNode",
|
||||||
|
"raster_nodes::adjustments::channel_mixer_shader_node::ChannelMixerShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
NodeReplacement {
|
||||||
|
node: graphene_std::raster_nodes::adjustments::color_balance::IDENTIFIER,
|
||||||
|
aliases: &["raster_nodes::adjustments::color_balance_shader_node::ColorBalanceShaderNodeNode"],
|
||||||
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::blending_nodes::color_overlay::IDENTIFIER,
|
node: graphene_std::raster_nodes::blending_nodes::color_overlay::IDENTIFIER,
|
||||||
aliases: &[
|
aliases: &[
|
||||||
@@ -541,6 +549,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_core::raster::adjustments::ColorOverlayNode",
|
"graphene_core::raster::adjustments::ColorOverlayNode",
|
||||||
"raster_nodes::generate_curves::ColorOverlayNode",
|
"raster_nodes::generate_curves::ColorOverlayNode",
|
||||||
"graphene_raster_nodes::blending_nodes::ColorOverlayNode",
|
"graphene_raster_nodes::blending_nodes::ColorOverlayNode",
|
||||||
|
"raster_nodes::blending_nodes::color_overlay_shader_node::ColorOverlayShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -561,6 +570,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::ExposureNode",
|
"graphene_raster_nodes::adjustments::ExposureNode",
|
||||||
"graphene_core::raster::adjustments::ExposureNode",
|
"graphene_core::raster::adjustments::ExposureNode",
|
||||||
"graphene_core::raster::ExposureNode",
|
"graphene_core::raster::ExposureNode",
|
||||||
|
"raster_nodes::adjustments::exposure_shader_node::ExposureShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -569,7 +579,11 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::adjustments::gamma_correction::IDENTIFIER,
|
node: graphene_std::raster_nodes::adjustments::gamma_correction::IDENTIFIER,
|
||||||
aliases: &["graphene_raster_nodes::adjustments::GammaCorrectionNode", "graphene_core::raster::adjustments::GammaCorrectionNode"],
|
aliases: &[
|
||||||
|
"graphene_raster_nodes::adjustments::GammaCorrectionNode",
|
||||||
|
"graphene_core::raster::adjustments::GammaCorrectionNode",
|
||||||
|
"raster_nodes::adjustments::gamma_correction_shader_node::GammaCorrectionShaderNodeNode",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::adjustments::gradient_map::IDENTIFIER,
|
node: graphene_std::raster_nodes::adjustments::gradient_map::IDENTIFIER,
|
||||||
@@ -588,6 +602,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::HueSaturationNode",
|
"graphene_raster_nodes::adjustments::HueSaturationNode",
|
||||||
"graphene_core::raster::adjustments::HueSaturationNode",
|
"graphene_core::raster::adjustments::HueSaturationNode",
|
||||||
"graphene_core::raster::HueSaturationNode",
|
"graphene_core::raster::HueSaturationNode",
|
||||||
|
"raster_nodes::adjustments::hue_saturation_shader_node::HueSaturationShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -613,6 +628,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_core::raster::adjustments::InvertNode",
|
"graphene_core::raster::adjustments::InvertNode",
|
||||||
"graphene_core::raster::InvertNode",
|
"graphene_core::raster::InvertNode",
|
||||||
"graphene_core::raster::InvertRGBNode",
|
"graphene_core::raster::InvertRGBNode",
|
||||||
|
"raster_nodes::adjustments::invert_shader_node::InvertShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -621,6 +637,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::LevelsNode",
|
"graphene_raster_nodes::adjustments::LevelsNode",
|
||||||
"graphene_core::raster::adjustments::LevelsNode",
|
"graphene_core::raster::adjustments::LevelsNode",
|
||||||
"graphene_core::raster::LevelsNode",
|
"graphene_core::raster::LevelsNode",
|
||||||
|
"raster_nodes::adjustments::levels_shader_node::LevelsShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -630,6 +647,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::LuminanceNode",
|
"graphene_raster_nodes::adjustments::LuminanceNode",
|
||||||
"graphene_core::raster::adjustments::LuminanceNode",
|
"graphene_core::raster::adjustments::LuminanceNode",
|
||||||
"graphene_core::raster::LuminanceNode",
|
"graphene_core::raster::LuminanceNode",
|
||||||
|
"raster_nodes::adjustments::desaturate_shader_node::DesaturateShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -638,6 +656,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::MakeOpaqueNode",
|
"graphene_raster_nodes::adjustments::MakeOpaqueNode",
|
||||||
"graphene_core::raster::adjustments::MakeOpaqueNode",
|
"graphene_core::raster::adjustments::MakeOpaqueNode",
|
||||||
"graphene_core::raster::ExtractOpaqueNode",
|
"graphene_core::raster::ExtractOpaqueNode",
|
||||||
|
"raster_nodes::adjustments::make_opaque_shader_node::MakeOpaqueShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -648,12 +667,17 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
node: graphene_std::raster_nodes::std_nodes::mask::IDENTIFIER,
|
node: graphene_std::raster_nodes::std_nodes::mask::IDENTIFIER,
|
||||||
aliases: &["graphene_raster_nodes::std_nodes::MaskNode", "graphene_std::raster::MaskNode", "graphene_std::raster::MaskImageNode"],
|
aliases: &["graphene_raster_nodes::std_nodes::MaskNode", "graphene_std::raster::MaskNode", "graphene_std::raster::MaskImageNode"],
|
||||||
},
|
},
|
||||||
|
NodeReplacement {
|
||||||
|
node: graphene_std::raster_nodes::adjustments::photo_filter::IDENTIFIER,
|
||||||
|
aliases: &["raster_nodes::adjustments::photo_filter_shader_node::PhotoFilterShaderNodeNode"],
|
||||||
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::adjustments::posterize::IDENTIFIER,
|
node: graphene_std::raster_nodes::adjustments::posterize::IDENTIFIER,
|
||||||
aliases: &[
|
aliases: &[
|
||||||
"graphene_raster_nodes::adjustments::PosterizeNode",
|
"graphene_raster_nodes::adjustments::PosterizeNode",
|
||||||
"graphene_core::raster::adjustments::PosterizeNode",
|
"graphene_core::raster::adjustments::PosterizeNode",
|
||||||
"graphene_core::raster::PosterizeNode",
|
"graphene_core::raster::PosterizeNode",
|
||||||
|
"raster_nodes::adjustments::posterize_shader_node::PosterizeShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -662,7 +686,11 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::adjustments::selective_color::IDENTIFIER,
|
node: graphene_std::raster_nodes::adjustments::selective_color::IDENTIFIER,
|
||||||
aliases: &["graphene_raster_nodes::adjustments::SelectiveColorNode", "graphene_core::raster::adjustments::SelectiveColorNode"],
|
aliases: &[
|
||||||
|
"graphene_raster_nodes::adjustments::SelectiveColorNode",
|
||||||
|
"graphene_core::raster::adjustments::SelectiveColorNode",
|
||||||
|
"raster_nodes::adjustments::selective_color_shader_node::SelectiveColorShaderNodeNode",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::raster_nodes::adjustments::threshold::IDENTIFIER,
|
node: graphene_std::raster_nodes::adjustments::threshold::IDENTIFIER,
|
||||||
@@ -670,6 +698,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::ThresholdNode",
|
"graphene_raster_nodes::adjustments::ThresholdNode",
|
||||||
"graphene_core::raster::adjustments::ThresholdNode",
|
"graphene_core::raster::adjustments::ThresholdNode",
|
||||||
"graphene_core::raster::ThresholdNode",
|
"graphene_core::raster::ThresholdNode",
|
||||||
|
"raster_nodes::adjustments::threshold_shader_node::ThresholdShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
@@ -678,6 +707,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
"graphene_raster_nodes::adjustments::VibranceNode",
|
"graphene_raster_nodes::adjustments::VibranceNode",
|
||||||
"graphene_core::raster::adjustments::VibranceNode",
|
"graphene_core::raster::adjustments::VibranceNode",
|
||||||
"graphene_core::raster::VibranceNode",
|
"graphene_core::raster::VibranceNode",
|
||||||
|
"raster_nodes::adjustments::vibrance_shader_node::VibranceShaderNodeNode",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// ================================
|
// ================================
|
||||||
@@ -1819,6 +1849,35 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
|||||||
.set_input(&InputConnector::node_at_index(node_id, index), NodeInput::value(TaggedValue::Integer(integer), exposed), &network_path);
|
.set_input(&InputConnector::node_at_index(node_id, index), NodeInput::value(TaggedValue::Integer(integer), exposed), &network_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cpu_raster_type_defaults: Vec<(NodeId, Vec<NodeId>, usize, Type, bool)> = document
|
||||||
|
.network_interface
|
||||||
|
.document_network()
|
||||||
|
.recursive_nodes()
|
||||||
|
.flat_map(|(node_id, node, path)| {
|
||||||
|
node.inputs
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(index, input)| {
|
||||||
|
let NodeInput::Value { tagged_value, exposed } = input else { return None };
|
||||||
|
let TaggedValue::TypeDefault(stored_type) = &**tagged_value else { return None };
|
||||||
|
let gpu_type = if *stored_type == item!(Raster<CPU>) {
|
||||||
|
item!(Raster<GPU>)
|
||||||
|
} else if *stored_type == list!(Raster<CPU>) {
|
||||||
|
list!(Raster<GPU>)
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
Some((*node_id, path.clone(), index, gpu_type, *exposed))
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
for (node_id, network_path, index, gpu_type, exposed) in cpu_raster_type_defaults {
|
||||||
|
document
|
||||||
|
.network_interface
|
||||||
|
.set_input(&InputConnector::node_at_index(node_id, index), NodeInput::type_default(gpu_type, exposed), &network_path);
|
||||||
|
}
|
||||||
|
|
||||||
// Bringing an old document up to date is not a set of edits on it, it is how the document arrives.
|
// Bringing an old document up to date is not a set of edits on it, it is how the document arrives.
|
||||||
// The upgrades run through the ordinary mutators, so the store records them; dropping what they
|
// The upgrades run through the ordinary mutators, so the store records them; dropping what they
|
||||||
// recorded leaves the opened document as the baseline rather than as a pile of changes to itself.
|
// recorded leaves the opened document as the baseline rather than as a pile of changes to itself.
|
||||||
@@ -3460,6 +3519,56 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let raster_kernel_pipeline = NodeInput::scope(graphene_std::raster_nodes::raster_kernel::raster_kernel_pipeline::IDENTIFIER.as_str().to_string());
|
||||||
|
let raster_kernel_nodes = {
|
||||||
|
use graphene_std::raster_nodes::adjustments::*;
|
||||||
|
[
|
||||||
|
desaturate::IDENTIFIER,
|
||||||
|
gamma_correction::IDENTIFIER,
|
||||||
|
make_opaque::IDENTIFIER,
|
||||||
|
brightness_contrast::IDENTIFIER,
|
||||||
|
levels::IDENTIFIER,
|
||||||
|
curves::IDENTIFIER,
|
||||||
|
black_and_white::IDENTIFIER,
|
||||||
|
hue_saturation::IDENTIFIER,
|
||||||
|
invert::IDENTIFIER,
|
||||||
|
threshold::IDENTIFIER,
|
||||||
|
gradient_map::IDENTIFIER,
|
||||||
|
vibrance::IDENTIFIER,
|
||||||
|
channel_mixer::IDENTIFIER,
|
||||||
|
selective_color::IDENTIFIER,
|
||||||
|
posterize::IDENTIFIER,
|
||||||
|
exposure::IDENTIFIER,
|
||||||
|
color_balance::IDENTIFIER,
|
||||||
|
photo_filter::IDENTIFIER,
|
||||||
|
color_lookup::IDENTIFIER,
|
||||||
|
image_to_channels::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::blending_nodes::color_overlay::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::channels_to_image::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::mask::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::extend_image_to_bounds::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::noise_pattern::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::mandelbrot::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::filter::median_filter::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::filter::blur::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::image_color_palette::image_color_palette::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::dehaze::dehaze::IDENTIFIER,
|
||||||
|
graphene_std::raster_nodes::std_nodes::image::IDENTIFIER,
|
||||||
|
graphene_std::platform_application_io::bytes_to_image::IDENTIFIER,
|
||||||
|
graphene_std::platform_application_io::image_to_bytes::IDENTIFIER,
|
||||||
|
graphene_std::platform_application_io::rasterize::IDENTIFIER,
|
||||||
|
]
|
||||||
|
};
|
||||||
|
if raster_kernel_nodes.iter().any(|identifier| reference == DefinitionIdentifier::ProtoNode(identifier.clone())) && !node.inputs.contains(&raster_kernel_pipeline) {
|
||||||
|
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
|
||||||
|
let value_inputs = node_template.inputs.iter().position(|input| *input == raster_kernel_pipeline)?;
|
||||||
|
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
|
||||||
|
|
||||||
|
for (index, input) in old_inputs.into_iter().take(value_inputs).enumerate() {
|
||||||
|
document.network_interface.set_input(&InputConnector::node_at_index(*node_id, index), input, network_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A value input stored as a List-form TypeDefault adopts the definition's current default when the connector's declared default has since changed (e.g. the connector was ranked down to Item).
|
// A value input stored as a List-form TypeDefault adopts the definition's current default when the connector's declared default has since changed (e.g. the connector was ranked down to Item).
|
||||||
// The red-slash no-paint choice shares that stored form but is a deliberate value, not a stale disconnect default, so it is exempt.
|
// The red-slash no-paint choice shares that stored form but is a deliberate value, not a stale disconnect default, so it is exempt.
|
||||||
if let Some(definition) = resolve_document_node_type(&reference) {
|
if let Some(definition) = resolve_document_node_type(&reference) {
|
||||||
@@ -3771,11 +3880,13 @@ fn migrate_removed_catalog_definitions(node_id: &NodeId, node: &DocumentNode, ne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Upload Texture node's old wrapper-network form maps onto its proto node form, which draws the executor from scope
|
// The removed Upload Texture node, in its proto node form or its old wrapper-network form, degrades to a passthrough of its content since rasters now load onto the GPU
|
||||||
if let Some(DefinitionIdentifier::Network(name)) = document.network_interface.reference(node_id, network_path)
|
if matches!(
|
||||||
&& name == "Upload Texture"
|
document.network_interface.reference(node_id, network_path),
|
||||||
|
Some(DefinitionIdentifier::ProtoNode(identifier)) if identifier.as_str().ends_with("::UploadTextureNode")
|
||||||
|
) || matches!(document.network_interface.reference(node_id, network_path), Some(DefinitionIdentifier::Network(name)) if name == "Upload Texture")
|
||||||
{
|
{
|
||||||
let mut node_template = resolve_proto_node_type(graphene_std::platform_application_io::upload_texture::IDENTIFIER)?.default_node_template();
|
let mut node_template = resolve_proto_node_type(graphene_std::ops::passthrough::IDENTIFIER)?.default_node_template();
|
||||||
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
|
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
|
||||||
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
|
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
|
||||||
if let Some(content) = old_inputs.first() {
|
if let Some(content) = old_inputs.first() {
|
||||||
@@ -3992,7 +4103,6 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn removed_definition_swap_targets_resolve() {
|
fn removed_definition_swap_targets_resolve() {
|
||||||
assert!(resolve_proto_node_type(graphene_std::ops::passthrough::IDENTIFIER).is_some());
|
assert!(resolve_proto_node_type(graphene_std::ops::passthrough::IDENTIFIER).is_some());
|
||||||
assert!(resolve_proto_node_type(graphene_std::platform_application_io::upload_texture::IDENTIFIER).is_some());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrating a Merge network's coercion nodes by alias would leave a reducer in the primary slot, so every alias must reset instead
|
// Migrating a Merge network's coercion nodes by alias would leave a reducer in the primary slot, so every alias must reset instead
|
||||||
@@ -4457,7 +4567,7 @@ mod tests {
|
|||||||
migrate(&mut document);
|
migrate(&mut document);
|
||||||
|
|
||||||
let image_node = &document.network_interface.document_network().nodes[&image_id];
|
let image_node = &document.network_interface.document_network().nodes[&image_id];
|
||||||
assert_eq!(image_node.inputs.len(), 2, "the image node should gain its placeholder primary input");
|
assert_eq!(image_node.inputs.len(), 3, "the image node should gain its placeholder primary input and pipeline scope input");
|
||||||
let migrated = &image_node.inputs[1];
|
let migrated = &image_node.inputs[1];
|
||||||
match legacy_input.as_value() {
|
match legacy_input.as_value() {
|
||||||
None => assert_eq!(migrated.as_node(), Some(upstream_id), "the wire should sit at input 1"),
|
None => assert_eq!(migrated.as_node(), Some(upstream_id), "the wire should sit at input 1"),
|
||||||
@@ -4492,6 +4602,49 @@ mod tests {
|
|||||||
assert!(matches!(migrated, NodeInput::Value { exposed: true, .. }), "the exposed flag should be kept");
|
assert!(matches!(migrated, NodeInput::Value { exposed: true, .. }), "the exposed flag should be kept");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cpu_raster_type_defaults_become_gpu_defaults() {
|
||||||
|
let node_id = NodeId(1);
|
||||||
|
let mut document = DocumentMessageHandler::default();
|
||||||
|
let mut blur_template = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::raster_nodes::filter::blur::IDENTIFIER))
|
||||||
|
.expect("the definition should exist")
|
||||||
|
.default_node_template();
|
||||||
|
blur_template.inputs[0] = NodeInput::type_default(item!(Raster<CPU>), true);
|
||||||
|
document.network_interface.insert_node(node_id, blur_template, &[]);
|
||||||
|
|
||||||
|
migrate(&mut document);
|
||||||
|
|
||||||
|
let migrated = &document.network_interface.document_network().nodes[&node_id].inputs[0];
|
||||||
|
assert_eq!(
|
||||||
|
migrated.as_value(),
|
||||||
|
Some(&TaggedValue::TypeDefault(item!(Raster<GPU>))),
|
||||||
|
"the CPU raster default should become the GPU raster default"
|
||||||
|
);
|
||||||
|
assert!(matches!(migrated, NodeInput::Value { exposed: true, .. }), "the exposed flag should be kept");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn upload_texture_becomes_passthrough() {
|
||||||
|
let node_id = NodeId(1);
|
||||||
|
let mut document = DocumentMessageHandler::default();
|
||||||
|
let mut template = resolve_proto_node_type(graphene_std::ops::passthrough::IDENTIFIER)
|
||||||
|
.expect("the definition should exist")
|
||||||
|
.default_node_template();
|
||||||
|
template.implementation = NodeTemplateImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_std::platform_application_io::UploadTextureNode"));
|
||||||
|
template.inputs = vec![
|
||||||
|
NodeInput::type_default(item!(Raster<GPU>), true),
|
||||||
|
NodeInput::scope("graphene_std::platform_application_io::WgpuExecutorNode"),
|
||||||
|
];
|
||||||
|
document.network_interface.insert_node(node_id, template, &[]);
|
||||||
|
|
||||||
|
migrate(&mut document);
|
||||||
|
|
||||||
|
let node = &document.network_interface.document_network().nodes[&node_id];
|
||||||
|
assert_eq!(node.implementation, DocumentNodeImplementation::ProtoNode(graphene_std::ops::passthrough::IDENTIFIER));
|
||||||
|
assert_eq!(node.inputs.len(), 1, "the executor scope input should be dropped");
|
||||||
|
assert_eq!(node.inputs[0].as_value(), Some(&TaggedValue::TypeDefault(item!(Raster<GPU>))), "the content should be kept");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_duplicate_node_replacements() {
|
fn test_no_duplicate_node_replacements() {
|
||||||
let mut hashmap = HashMap::<ProtoNodeIdentifier, u32>::new();
|
let mut hashmap = HashMap::<ProtoNodeIdentifier, u32>::new();
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ use crate::task::{Spawn, Task};
|
|||||||
use crate::test_utils::test_prelude::LayerNodeIdentifier;
|
use crate::test_utils::test_prelude::LayerNodeIdentifier;
|
||||||
use document_container::store::MemoryStore;
|
use document_container::store::MemoryStore;
|
||||||
use glam::{DVec2, UVec2};
|
use glam::{DVec2, UVec2};
|
||||||
use graph_craft::application_io::PlatformApplicationIo;
|
|
||||||
use graph_craft::application_io::resource::HashMapResourceStorage;
|
use graph_craft::application_io::resource::HashMapResourceStorage;
|
||||||
|
use graph_craft::application_io::{ApplicationIo, PlatformApplicationIo};
|
||||||
use graphene_std::raster::color::Color;
|
use graphene_std::raster::color::Color;
|
||||||
use graphene_std::uuid::NodeId;
|
use graphene_std::uuid::NodeId;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::{Arc, LazyLock};
|
||||||
|
|
||||||
/// A set of utility functions to make the writing of editor test more declarative
|
/// A set of utility functions to make the writing of editor test more declarative
|
||||||
pub struct EditorTestUtils {
|
pub struct EditorTestUtils {
|
||||||
@@ -42,7 +42,7 @@ impl EditorTestUtils {
|
|||||||
.with_resource_storage(Arc::new(HashMapResourceStorage::new()))
|
.with_resource_storage(Arc::new(HashMapResourceStorage::new()))
|
||||||
.with_document_store(Arc::new(MemoryStore::default())),
|
.with_document_store(Arc::new(MemoryStore::default())),
|
||||||
)
|
)
|
||||||
.with_runtime(RuntimeBuilder::new().with_wake(|| {}).with_application_io(PlatformApplicationIo::default()))
|
.with_runtime(RuntimeBuilder::new().with_wake(|| {}).with_application_io(gpu_application_io()))
|
||||||
.with_spawner(BlockingSpawner)
|
.with_spawner(BlockingSpawner)
|
||||||
.with_random_seed(0)
|
.with_random_seed(0)
|
||||||
.build();
|
.build();
|
||||||
@@ -459,6 +459,16 @@ fn init_test_logger() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates application IO with the GPU executor shared by every test in the process, since creating a device and its pipelines for each test is slow.
|
||||||
|
/// Panics if no adapter is found, since tests render on the GPU like the app does.
|
||||||
|
fn gpu_application_io() -> PlatformApplicationIo {
|
||||||
|
static GPU_EXECUTOR: LazyLock<Option<<PlatformApplicationIo as ApplicationIo>::Executor>> = LazyLock::new(|| futures::executor::block_on(PlatformApplicationIo::new()).gpu_executor().cloned());
|
||||||
|
let executor = GPU_EXECUTOR.clone().expect(
|
||||||
|
"Editor tests need a GPU adapter. Without a hardware GPU, install Mesa's lavapipe software Vulkan driver and point `VK_ADD_DRIVER_FILES` at its `lvp_icd.<arch>.json` (the Nix dev shell does this).",
|
||||||
|
);
|
||||||
|
PlatformApplicationIo::new_with_executor(executor)
|
||||||
|
}
|
||||||
|
|
||||||
/// Runs `operation`, returning its result along with the errors it logged.
|
/// Runs `operation`, returning its result along with the errors it logged.
|
||||||
pub fn capture_logged_errors<T>(operation: impl FnOnce() -> T) -> (T, Vec<String>) {
|
pub fn capture_logged_errors<T>(operation: impl FnOnce() -> T) -> (T, Vec<String>) {
|
||||||
init_test_logger();
|
init_test_logger();
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ publish.workspace = true
|
|||||||
readme = "./README.md"
|
readme = "./README.md"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["gpu", "shader-nodes", "web"]
|
default = ["gpu", "web"]
|
||||||
web = ["editor", "editor?/wasm"]
|
web = ["editor", "editor?/wasm"]
|
||||||
editor = ["dep:editor", "dep:graphene-std", "dep:graph-craft", "dep:spin", "dep:wgpu"]
|
editor = ["dep:editor", "dep:graphene-std", "dep:graph-craft", "dep:spin", "dep:wgpu"]
|
||||||
gpu = ["editor?/gpu"]
|
gpu = ["editor?/gpu"]
|
||||||
shader-nodes = ["graphene-std?/shader-nodes", "gpu"]
|
|
||||||
native = []
|
native = []
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|||||||
@@ -145,10 +145,6 @@ impl DocumentNode {
|
|||||||
|
|
||||||
let mut construction_args = ConstructionArgs::Nodes(vec![]);
|
let mut construction_args = ConstructionArgs::Nodes(vec![]);
|
||||||
|
|
||||||
// If we have one input of the type inline, set it as the construction args
|
|
||||||
if let &[NodeInput::Inline(ref inline)] = self.inputs.as_slice() {
|
|
||||||
construction_args = ConstructionArgs::Inline(inline.clone());
|
|
||||||
}
|
|
||||||
// If we have one input of the type inline, set it as the construction args
|
// If we have one input of the type inline, set it as the construction args
|
||||||
if let &[NodeInput::Value { ref tagged_value, .. }] = self.inputs.as_slice() {
|
if let &[NodeInput::Value { ref tagged_value, .. }] = self.inputs.as_slice() {
|
||||||
construction_args = ConstructionArgs::Value(tagged_value.clone());
|
construction_args = ConstructionArgs::Value(tagged_value.clone());
|
||||||
@@ -195,22 +191,6 @@ pub enum NodeInput {
|
|||||||
|
|
||||||
/// Input that is replaced at graph compilation with introspective metadata about this node's location.
|
/// Input that is replaced at graph compilation with introspective metadata about this node's location.
|
||||||
Reflection(DocumentNodeMetadata),
|
Reflection(DocumentNodeMetadata),
|
||||||
|
|
||||||
/// A Rust source code string. Allows us to insert literal Rust code. Only used for GPU compilation.
|
|
||||||
/// We can use this whenever we spin up Rustc. Sort of like inline assembly, but because our language is Rust, it acts as inline Rust.
|
|
||||||
Inline(InlineRust),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Hash, core_types::CacheHash, DynAny, serde::Serialize, serde::Deserialize)]
|
|
||||||
pub struct InlineRust {
|
|
||||||
pub expr: String,
|
|
||||||
pub ty: Type,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InlineRust {
|
|
||||||
pub fn new(expr: String, ty: Type) -> Self {
|
|
||||||
Self { expr, ty }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Hash, core_types::CacheHash, DynAny, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Hash, core_types::CacheHash, DynAny, serde::Serialize, serde::Deserialize)]
|
||||||
@@ -263,7 +243,6 @@ impl NodeInput {
|
|||||||
NodeInput::Node { .. } => true,
|
NodeInput::Node { .. } => true,
|
||||||
NodeInput::Value { exposed, .. } => *exposed,
|
NodeInput::Value { exposed, .. } => *exposed,
|
||||||
NodeInput::Import { .. } => true,
|
NodeInput::Import { .. } => true,
|
||||||
NodeInput::Inline(_) => false,
|
|
||||||
NodeInput::Scope(_) => false,
|
NodeInput::Scope(_) => false,
|
||||||
NodeInput::Reflection(_) => false,
|
NodeInput::Reflection(_) => false,
|
||||||
}
|
}
|
||||||
@@ -275,7 +254,6 @@ impl NodeInput {
|
|||||||
NodeInput::Value { tagged_value, .. } => tagged_value.ty(),
|
NodeInput::Value { tagged_value, .. } => tagged_value.ty(),
|
||||||
// Stored import types are normalized to their structural form once at document migration
|
// Stored import types are normalized to their structural form once at document migration
|
||||||
NodeInput::Import { import_type, .. } => import_type.clone(),
|
NodeInput::Import { import_type, .. } => import_type.clone(),
|
||||||
NodeInput::Inline(_) => panic!("ty() called on NodeInput::Inline"),
|
|
||||||
NodeInput::Scope(_) => panic!("ty() called on NodeInput::Scope"),
|
NodeInput::Scope(_) => panic!("ty() called on NodeInput::Scope"),
|
||||||
NodeInput::Reflection(_) => concrete!(Metadata),
|
NodeInput::Reflection(_) => concrete!(Metadata),
|
||||||
}
|
}
|
||||||
@@ -1199,7 +1177,6 @@ impl NodeNetwork {
|
|||||||
*import_index = parent_input_index;
|
*import_index = parent_input_index;
|
||||||
}
|
}
|
||||||
NodeInput::Value { .. } => unreachable!("Value inputs should have been replaced with value nodes"),
|
NodeInput::Value { .. } => unreachable!("Value inputs should have been replaced with value nodes"),
|
||||||
NodeInput::Inline(_) => (),
|
|
||||||
NodeInput::Scope(_) => unreachable!("Scope inputs should have been resolved by resolve_scope_inputs_recursive before flattening"),
|
NodeInput::Scope(_) => unreachable!("Scope inputs should have been resolved by resolve_scope_inputs_recursive before flattening"),
|
||||||
NodeInput::Reflection(_) => unreachable!("Reflection inputs should have been replaced with value nodes"),
|
NodeInput::Reflection(_) => unreachable!("Reflection inputs should have been replaced with value nodes"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub use glam::{DAffine2, DVec2, IVec2, UVec2};
|
|||||||
use graphene_animation::AnimationCurve;
|
use graphene_animation::AnimationCurve;
|
||||||
use graphene_application_io::resource::ResourceHash;
|
use graphene_application_io::resource::ResourceHash;
|
||||||
use graphene_application_io::resource::ResourceId;
|
use graphene_application_io::resource::ResourceId;
|
||||||
use graphic_types::raster_types::{CPU, Image, Raster};
|
use graphic_types::raster_types::{CPU, GPU, Image, Raster};
|
||||||
use graphic_types::vector_types::vector::misc::BoxCorners;
|
use graphic_types::vector_types::vector::misc::BoxCorners;
|
||||||
use graphic_types::vector_types::vector::style::DashPattern;
|
use graphic_types::vector_types::vector::style::DashPattern;
|
||||||
use graphic_types::vector_types::vector::style::{Gradient, GradientRamp};
|
use graphic_types::vector_types::vector::style::{Gradient, GradientRamp};
|
||||||
@@ -36,6 +36,7 @@ macro_rules! for_each_item_type_default {
|
|||||||
$action!(Vector);
|
$action!(Vector);
|
||||||
$action!(f64);
|
$action!(f64);
|
||||||
$action!(Raster<CPU>);
|
$action!(Raster<CPU>);
|
||||||
|
$action!(Raster<GPU>);
|
||||||
$action!(Graphic);
|
$action!(Graphic);
|
||||||
$action!(Color);
|
$action!(Color);
|
||||||
$action!(Gradient);
|
$action!(Gradient);
|
||||||
@@ -52,6 +53,7 @@ macro_rules! for_each_list_type_default {
|
|||||||
$action!(Graphic);
|
$action!(Graphic);
|
||||||
$action!(Artboard);
|
$action!(Artboard);
|
||||||
$action!(Raster<CPU>);
|
$action!(Raster<CPU>);
|
||||||
|
$action!(Raster<GPU>);
|
||||||
$action!(Vector);
|
$action!(Vector);
|
||||||
$action!(String);
|
$action!(String);
|
||||||
$action!(Color);
|
$action!(Color);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
use crate::document::value;
|
||||||
use crate::document::value::TaggedValue;
|
use crate::document::value::TaggedValue;
|
||||||
use crate::document::{InlineRust, value};
|
|
||||||
use crate::document::{NodeId, OriginalLocation};
|
use crate::document::{NodeId, OriginalLocation};
|
||||||
pub use core_types::registry::*;
|
pub use core_types::registry::*;
|
||||||
use core_types::*;
|
use core_types::*;
|
||||||
@@ -51,10 +51,6 @@ impl core::fmt::Display for ProtoNetwork {
|
|||||||
write_node(f, network, *id, indent + 1)?;
|
write_node(f, network, *id, indent + 1)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConstructionArgs::Inline(inline) => {
|
|
||||||
f.write_str(&"\t".repeat(indent + 1))?;
|
|
||||||
f.write_fmt(format_args!("Inline construction argument: {inline:?}"))?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
f.write_str(&"\t".repeat(indent))?;
|
f.write_str(&"\t".repeat(indent))?;
|
||||||
f.write_str("}\n")?;
|
f.write_str("}\n")?;
|
||||||
@@ -75,8 +71,6 @@ pub enum ConstructionArgs {
|
|||||||
/// The bool indicates whether to treat the node as lambda node.
|
/// The bool indicates whether to treat the node as lambda node.
|
||||||
// TODO: use a struct for clearer naming.
|
// TODO: use a struct for clearer naming.
|
||||||
Nodes(Vec<NodeId>),
|
Nodes(Vec<NodeId>),
|
||||||
/// Used for GPU computation to work around the limitations of rust-gpu.
|
|
||||||
Inline(InlineRust),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for ConstructionArgs {}
|
impl Eq for ConstructionArgs {}
|
||||||
@@ -109,7 +103,6 @@ impl CacheHash for ConstructionArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Value(value) => value.cache_hash(state),
|
Self::Value(value) => value.cache_hash(state),
|
||||||
Self::Inline(inline) => inline.hash(state),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +112,6 @@ impl ConstructionArgs {
|
|||||||
match self {
|
match self {
|
||||||
ConstructionArgs::Nodes(nodes) => nodes.iter().map(|n| format!("n{:0x}", n.0)).collect(),
|
ConstructionArgs::Nodes(nodes) => nodes.iter().map(|n| format!("n{:0x}", n.0)).collect(),
|
||||||
ConstructionArgs::Value(value) => vec![value.to_primitive_string()],
|
ConstructionArgs::Value(value) => vec![value.to_primitive_string()],
|
||||||
ConstructionArgs::Inline(inline) => vec![inline.expr.clone()],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +432,7 @@ impl ProtoNetwork {
|
|||||||
Some(id),
|
Some(id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ConstructionArgs::Value(_) | ConstructionArgs::Inline(_) => return (dependencies.extract.into(), Some(id)),
|
ConstructionArgs::Value(_) => return (dependencies.extract.into(), Some(id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Compute the dependencies for each branch and combine all of them
|
// Compute the dependencies for each branch and combine all of them
|
||||||
@@ -877,7 +869,6 @@ impl TypingContext {
|
|||||||
.map(|node| node.ty())
|
.map(|node| node.ty())
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<Type>, GraphErrors>>()?,
|
.collect::<Result<Vec<Type>, GraphErrors>>()?,
|
||||||
ConstructionArgs::Inline(ref inline) => vec![inline.ty.clone()],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the node input type from the proto node declaration
|
// Get the node input type from the proto node declaration
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ pub fn print(network: &ProtoNetwork, document: &Document, format: Format, upstre
|
|||||||
let arguments = match &node.proto.construction_args {
|
let arguments = match &node.proto.construction_args {
|
||||||
ConstructionArgs::Nodes(_) => format!("({})", node.inputs.iter().map(|&input| id(input)).collect::<Vec<_>>().join(", ")),
|
ConstructionArgs::Nodes(_) => format!("({})", node.inputs.iter().map(|&input| id(input)).collect::<Vec<_>>().join(", ")),
|
||||||
ConstructionArgs::Value(value) => format!("{{{}}}", summary(value, 80)),
|
ConstructionArgs::Value(value) => format!("{{{}}}", summary(value, 80)),
|
||||||
ConstructionArgs::Inline(inline) => format!("{{{}}}", inline.expr),
|
|
||||||
};
|
};
|
||||||
let shared = if node.origins.len() > 1 { "(shared)" } else { "" };
|
let shared = if node.origins.len() > 1 { "(shared)" } else { "" };
|
||||||
let provenance = [node.kind.tag(), &location(node.origins[0]), shared]
|
let provenance = [node.kind.tag(), &location(node.origins[0]), shared]
|
||||||
@@ -246,7 +245,6 @@ fn constant<'a>(nodes: &[Node<'a>], mut n: usize) -> Option<&'a TaggedValue> {
|
|||||||
match &nodes[n].proto.construction_args {
|
match &nodes[n].proto.construction_args {
|
||||||
ConstructionArgs::Value(value) => return Some(&**value),
|
ConstructionArgs::Value(value) => return Some(&**value),
|
||||||
ConstructionArgs::Nodes(_) => n = *nodes[n].inputs.first()?,
|
ConstructionArgs::Nodes(_) => n = *nodes[n].inputs.first()?,
|
||||||
ConstructionArgs::Inline(_) => return None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -503,7 +503,6 @@ impl BorrowTree {
|
|||||||
/// - Updates the source map using [`update_source_map`](BorrowTree::update_source_map) before inserting the node.
|
/// - Updates the source map using [`update_source_map`](BorrowTree::update_source_map) before inserting the node.
|
||||||
/// - Handles different types of construction arguments:
|
/// - Handles different types of construction arguments:
|
||||||
/// - `Value`: Creates a node from a `TaggedValue`, with special handling for `EditorApi` values.
|
/// - `Value`: Creates a node from a `TaggedValue`, with special handling for `EditorApi` values.
|
||||||
/// - `Inline`: Currently unimplemented. Only used for `rust-gpu` support.
|
|
||||||
/// - `Nodes`: Constructs a node using other nodes as dependencies.
|
/// - `Nodes`: Constructs a node using other nodes as dependencies.
|
||||||
/// - Uses the constructor function from the `typing_context` for `Nodes` construction arguments.
|
/// - Uses the constructor function from the `typing_context` for `Nodes` construction arguments.
|
||||||
/// - Returns an error if no constructor is found for the given node ID.
|
/// - Returns an error if no constructor is found for the given node ID.
|
||||||
@@ -518,7 +517,6 @@ impl BorrowTree {
|
|||||||
let node = ObservedNode::new(Box::new(upcasted) as TypeErasedBox<'_>);
|
let node = ObservedNode::new(Box::new(upcasted) as TypeErasedBox<'_>);
|
||||||
self.store_node(node, id, path.into(), Box::default());
|
self.store_node(node, id, path.into(), Box::default());
|
||||||
}
|
}
|
||||||
ConstructionArgs::Inline(_) => unimplemented!("Inline nodes are not supported yet"),
|
|
||||||
ConstructionArgs::Nodes(ids) => {
|
ConstructionArgs::Nodes(ids) => {
|
||||||
let ids = ids.to_vec();
|
let ids = ids.to_vec();
|
||||||
let mut construction_nodes = self.node_deps(&ids);
|
let mut construction_nodes = self.node_deps(&ids);
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<CPU>>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<CPU>>]),
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<GPU>>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<GPU>>]),
|
||||||
|
#[cfg(feature = "gpu")]
|
||||||
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<wgpu_executor::WgpuPipelineCache>]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Color>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Color>]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Gradient>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Gradient>]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<DashPattern>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<DashPattern>]),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use graph_craft::application_io::PlatformEditorApi;
|
use graph_craft::application_io::PlatformEditorApi;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeInput, NodeNetwork};
|
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, DocumentNodeMetadata, NodeInput, NodeNetwork};
|
||||||
use graph_craft::generic;
|
use graph_craft::generic;
|
||||||
use graph_craft::{concrete, item};
|
use graph_craft::{concrete, item};
|
||||||
use graphene_std::Context;
|
use graphene_std::Context;
|
||||||
@@ -27,7 +27,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
let render_node = DocumentNode {
|
let render_node = DocumentNode {
|
||||||
inputs: vec![NodeInput::node(NodeId(0), 0)],
|
inputs: vec![NodeInput::node(NodeId(0), 0)],
|
||||||
implementation: DocumentNodeImplementation::Network(NodeNetwork {
|
implementation: DocumentNodeImplementation::Network(NodeNetwork {
|
||||||
exports: vec![NodeInput::node(NodeId(5), 0)],
|
exports: vec![NodeInput::node(NodeId(6), 0)],
|
||||||
nodes: [
|
nodes: [
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
@@ -42,7 +42,23 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
inputs: vec![NodeInput::scope(graphene_std::platform_application_io::try_wgpu_executor::IDENTIFIER), NodeInput::node(NodeId(0), 0)],
|
inputs: vec![
|
||||||
|
NodeInput::scope(graphene_std::platform_application_io::try_wgpu_executor::IDENTIFIER),
|
||||||
|
NodeInput::node(NodeId(0), 0),
|
||||||
|
NodeInput::scope("runtime"),
|
||||||
|
NodeInput::Reflection(DocumentNodeMetadata::SourceId),
|
||||||
|
],
|
||||||
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_node::download_gpu_rasters::IDENTIFIER),
|
||||||
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
|
extract: ContextFeatures::VARARGS,
|
||||||
|
inject: ContextFeatures::empty(),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
DocumentNode {
|
||||||
|
call_argument: concrete!(Context),
|
||||||
|
inputs: vec![NodeInput::scope(graphene_std::platform_application_io::try_wgpu_executor::IDENTIFIER), NodeInput::node(NodeId(1), 0)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_node::render::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_node::render::IDENTIFIER),
|
||||||
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
||||||
@@ -53,7 +69,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
inputs: vec![NodeInput::scope(graphene_std::platform_application_io::try_wgpu_executor::IDENTIFIER), NodeInput::node(NodeId(1), 0)],
|
inputs: vec![NodeInput::scope(graphene_std::platform_application_io::try_wgpu_executor::IDENTIFIER), NodeInput::node(NodeId(2), 0)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_cache::render_output_cache::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_cache::render_output_cache::IDENTIFIER),
|
||||||
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
||||||
@@ -64,7 +80,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
inputs: vec![NodeInput::scope(graphene_std::render_pixel_preview::pixel_preview_pipeline::IDENTIFIER), NodeInput::node(NodeId(2), 0)],
|
inputs: vec![NodeInput::scope(graphene_std::render_pixel_preview::pixel_preview_pipeline::IDENTIFIER), NodeInput::node(NodeId(3), 0)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_pixel_preview::render_pixel_preview::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_pixel_preview::render_pixel_preview::IDENTIFIER),
|
||||||
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
extract: ContextFeatures::FOOTPRINT | ContextFeatures::VARARGS,
|
||||||
@@ -77,7 +93,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::scope(graphene_std::render_background::composite_background_pipeline::IDENTIFIER),
|
NodeInput::scope(graphene_std::render_background::composite_background_pipeline::IDENTIFIER),
|
||||||
NodeInput::node(NodeId(3), 0),
|
NodeInput::node(NodeId(4), 0),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_background::render_background::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_background::render_background::IDENTIFIER),
|
||||||
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
@@ -89,7 +105,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<PlatformE
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
call_argument: concrete!(Context),
|
call_argument: concrete!(Context),
|
||||||
inputs: vec![NodeInput::node(NodeId(4), 0)],
|
inputs: vec![NodeInput::node(NodeId(5), 0)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_node::create_context::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_node::create_context::IDENTIFIER),
|
||||||
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
compile_metadata: Some(graphene_std::NodeCompileMetadata {
|
||||||
// INDEX is never read; it forces a nullification and cache pair onto the `data` parameter's wire so the render cache keys on a stable context
|
// INDEX is never read; it forces a nullification and cache pair onto the `data` parameter's wire so the render cache keys on a stable context
|
||||||
|
|||||||
@@ -16,15 +16,13 @@ workspace = true
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde"]
|
default = ["serde"]
|
||||||
serde = ["dep:serde"]
|
serde = ["dep:serde", "glam/serde", "half/serde"]
|
||||||
nightly = []
|
|
||||||
type_id_logging = []
|
type_id_logging = []
|
||||||
dealloc_nodes = []
|
dealloc_nodes = []
|
||||||
wasm = ["tsify", "wasm-bindgen", "no-std-types/wasm"]
|
wasm = ["tsify", "wasm-bindgen"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Local dependencies
|
# Local dependencies
|
||||||
no-std-types = { workspace = true, features = ["std"] }
|
|
||||||
graphene-hash = { workspace = true, features = ["derive"] }
|
graphene-hash = { workspace = true, features = ["derive"] }
|
||||||
|
|
||||||
# Workspace dependencies
|
# Workspace dependencies
|
||||||
@@ -33,6 +31,9 @@ bitflags = { workspace = true }
|
|||||||
bytemuck = { workspace = true }
|
bytemuck = { workspace = true }
|
||||||
node-macro = { workspace = true }
|
node-macro = { workspace = true }
|
||||||
num-traits = { workspace = true }
|
num-traits = { workspace = true }
|
||||||
|
num-derive = { workspace = true }
|
||||||
|
num_enum = { workspace = true, features = ["std"] }
|
||||||
|
half = { workspace = true, features = ["std"] }
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
glam = { workspace = true }
|
glam = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
|||||||
+2
-5
@@ -1,13 +1,11 @@
|
|||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use core::fmt::Display;
|
use core::fmt::Display;
|
||||||
use node_macro::BufferStruct;
|
|
||||||
use num_enum::{FromPrimitive, IntoPrimitive};
|
use num_enum::{FromPrimitive, IntoPrimitive};
|
||||||
|
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
#[cfg_attr(feature = "std", derive(dyn_any::DynAny, serde::Serialize, serde::Deserialize))]
|
#[derive(dyn_any::DynAny, graphene_hash::CacheHash, Debug, Default, Clone, Copy, Eq, PartialEq, Hash, FromPrimitive, IntoPrimitive)]
|
||||||
#[cfg_attr(feature = "std", derive(graphene_hash::CacheHash))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, BufferStruct, FromPrimitive, IntoPrimitive)]
|
|
||||||
pub enum BlendMode {
|
pub enum BlendMode {
|
||||||
// Basic group
|
// Basic group
|
||||||
#[default]
|
#[default]
|
||||||
@@ -132,7 +130,6 @@ impl BlendMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Renders the blend mode CSS style declaration.
|
/// Renders the blend mode CSS style declaration.
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub fn render(&self) -> String {
|
pub fn render(&self) -> String {
|
||||||
format!(
|
format!(
|
||||||
r#" mix-blend-mode: {};"#,
|
r#" mix-blend-mode: {};"#,
|
||||||
File renamed without changes.
-3
@@ -3,8 +3,6 @@ use bytemuck::{Pod, Zeroable};
|
|||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use glam::DVec2;
|
use glam::DVec2;
|
||||||
use num_derive::*;
|
use num_derive::*;
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
pub trait Linear {
|
pub trait Linear {
|
||||||
fn from_f32(x: f32) -> Self;
|
fn from_f32(x: f32) -> Self;
|
||||||
@@ -88,7 +86,6 @@ pub trait SRGB: Rec709Primaries {}
|
|||||||
|
|
||||||
// TODO: Come up with a better name for this trait
|
// TODO: Come up with a better name for this trait
|
||||||
pub trait Pixel: Clone + Pod + Zeroable + Default {
|
pub trait Pixel: Clone + Pod + Zeroable + Default {
|
||||||
#[cfg(feature = "std")]
|
|
||||||
fn to_bytes(&self) -> Vec<u8> {
|
fn to_bytes(&self) -> Vec<u8> {
|
||||||
bytemuck::bytes_of(self).to_vec()
|
bytemuck::bytes_of(self).to_vec()
|
||||||
}
|
}
|
||||||
+9
-40
@@ -5,16 +5,10 @@ use bytemuck::{Pod, Zeroable};
|
|||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use glam::Vec4;
|
use glam::Vec4;
|
||||||
use half::f16;
|
use half::f16;
|
||||||
use node_macro::BufferStruct;
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use num_traits::Euclid;
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Default, Clone, Copy, PartialEq, Pod, Zeroable)]
|
#[derive(Default, Clone, Copy, PartialEq, Pod, Zeroable, Debug, dyn_any::DynAny)]
|
||||||
#[cfg_attr(not(target_arch = "spirv"), derive(Debug))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(feature = "std", derive(dyn_any::DynAny, serde::Serialize, serde::Deserialize))]
|
|
||||||
pub struct RGBA16F {
|
pub struct RGBA16F {
|
||||||
red: f16,
|
red: f16,
|
||||||
green: f16,
|
green: f16,
|
||||||
@@ -22,14 +16,6 @@ pub struct RGBA16F {
|
|||||||
alpha: f16,
|
alpha: f16,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// hack around half still masking out impl Debug for f16 on spirv
|
|
||||||
#[cfg(target_arch = "spirv")]
|
|
||||||
impl core::fmt::Debug for RGBA16F {
|
|
||||||
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Color> for RGBA16F {
|
impl From<Color> for RGBA16F {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from(c: Color) -> Self {
|
fn from(c: Color) -> Self {
|
||||||
@@ -96,9 +82,8 @@ impl Pixel for RGBA16F {}
|
|||||||
/// the linear-light [`Color`] type. Convert via [`From<SRGBA8> for Color`] and [`From<Color> for SRGBA8`].
|
/// the linear-light [`Color`] type. Convert via [`From<SRGBA8> for Color`] and [`From<Color> for SRGBA8`].
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(from_wasm_abi))]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(from_wasm_abi))]
|
||||||
#[cfg_attr(feature = "std", derive(dyn_any::DynAny, serde::Serialize, serde::Deserialize))]
|
#[derive(dyn_any::DynAny, graphene_hash::CacheHash, Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Pod, Zeroable)]
|
||||||
#[cfg_attr(feature = "std", derive(graphene_hash::CacheHash))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Pod, Zeroable)]
|
|
||||||
pub struct SRGBA8 {
|
pub struct SRGBA8 {
|
||||||
pub red: u8,
|
pub red: u8,
|
||||||
pub green: u8,
|
pub green: u8,
|
||||||
@@ -125,7 +110,6 @@ impl SRGBA8 {
|
|||||||
|
|
||||||
/// Parse `RRGGBB` or `RRGGBBAA` (with or without a leading `#`). Returns `None` for any other format.
|
/// Parse `RRGGBB` or `RRGGBBAA` (with or without a leading `#`). Returns `None` for any other format.
|
||||||
/// For full CSS Color 4 parsing (named colors, shorthand hex, `rgb(...)`, `hsl(...)`), parse in the caller and construct via [`Self::new`].
|
/// For full CSS Color 4 parsing (named colors, shorthand hex, `rgb(...)`, `hsl(...)`), parse in the caller and construct via [`Self::new`].
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub fn from_hex_str(hex: &str) -> Option<Self> {
|
pub fn from_hex_str(hex: &str) -> Option<Self> {
|
||||||
let hex = hex.trim().trim_start_matches('#');
|
let hex = hex.trim().trim_start_matches('#');
|
||||||
if hex.len() != 6 && hex.len() != 8 {
|
if hex.len() != 6 && hex.len() != 8 {
|
||||||
@@ -141,19 +125,16 @@ impl SRGBA8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// `rrggbb` (lowercase, no `#` prefix, alpha discarded). Use where alpha is specified separately, e.g. SVG `fill="#..." fill-opacity="..."`.
|
/// `rrggbb` (lowercase, no `#` prefix, alpha discarded). Use where alpha is specified separately, e.g. SVG `fill="#..." fill-opacity="..."`.
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub fn to_rgb_hex(self) -> String {
|
pub fn to_rgb_hex(self) -> String {
|
||||||
format!("{:02x}{:02x}{:02x}", self.red, self.green, self.blue)
|
format!("{:02x}{:02x}{:02x}", self.red, self.green, self.blue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `rrggbbaa` (lowercase, no `#` prefix).
|
/// `rrggbbaa` (lowercase, no `#` prefix).
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub fn to_rgba_hex(self) -> String {
|
pub fn to_rgba_hex(self) -> String {
|
||||||
format!("{:02x}{:02x}{:02x}{:02x}", self.red, self.green, self.blue, self.alpha)
|
format!("{:02x}{:02x}{:02x}{:02x}", self.red, self.green, self.blue, self.alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `#rrggbb` if fully opaque, `#rrggbbaa` otherwise. Suitable for direct insertion into a CSS property or SVG attribute.
|
/// `#rrggbb` if fully opaque, `#rrggbbaa` otherwise. Suitable for direct insertion into a CSS property or SVG attribute.
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub fn to_css_hex(self) -> String {
|
pub fn to_css_hex(self) -> String {
|
||||||
if self.alpha == 255 {
|
if self.alpha == 255 {
|
||||||
format!("#{}", self.to_rgb_hex())
|
format!("#{}", self.to_rgb_hex())
|
||||||
@@ -223,8 +204,8 @@ impl From<SRGBA8> for Color {
|
|||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
#[cfg_attr(feature = "std", derive(dyn_any::DynAny, serde::Serialize, serde::Deserialize))]
|
#[derive(dyn_any::DynAny, Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable)]
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable)]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct Luma(pub f32);
|
pub struct Luma(pub f32);
|
||||||
|
|
||||||
impl Luminance for Luma {
|
impl Luminance for Luma {
|
||||||
@@ -259,9 +240,7 @@ impl Pixel for Luma {}
|
|||||||
///
|
///
|
||||||
/// Anything crossing the Wasm/JS boundary must go through [`SRGBA8`] instead.
|
/// Anything crossing the Wasm/JS boundary must go through [`SRGBA8`] instead.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "std", derive(dyn_any::DynAny))]
|
#[derive(dyn_any::DynAny, graphene_hash::CacheHash, Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable)]
|
||||||
#[cfg_attr(feature = "std", derive(graphene_hash::CacheHash))]
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable, BufferStruct)]
|
|
||||||
pub struct Color {
|
pub struct Color {
|
||||||
red: f32,
|
red: f32,
|
||||||
green: f32,
|
green: f32,
|
||||||
@@ -273,7 +252,7 @@ pub struct Color {
|
|||||||
impl Eq for Color {}
|
impl Eq for Color {}
|
||||||
|
|
||||||
// TODO: Eventually remove this document upgrade code
|
// TODO: Eventually remove this document upgrade code
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "serde")]
|
||||||
impl serde::Serialize for Color {
|
impl serde::Serialize for Color {
|
||||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
use serde::ser::SerializeStruct;
|
use serde::ser::SerializeStruct;
|
||||||
@@ -290,7 +269,7 @@ impl serde::Serialize for Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Eventually remove this document upgrade code
|
// TODO: Eventually remove this document upgrade code
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de> serde::Deserialize<'de> for Color {
|
impl<'de> serde::Deserialize<'de> for Color {
|
||||||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||||
// Documents from before the linear-storage migration lack the `linear` marker and stored gamma-encoded floats; convert them on load.
|
// Documents from before the linear-storage migration lack the `linear` marker and stored gamma-encoded floats; convert them on load.
|
||||||
@@ -351,7 +330,6 @@ impl AlphaMut for Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pixel for Color {
|
impl Pixel for Color {
|
||||||
#[cfg(feature = "std")]
|
|
||||||
fn to_bytes(&self) -> Vec<u8> {
|
fn to_bytes(&self) -> Vec<u8> {
|
||||||
let SRGBA8 { red, green, blue, alpha } = (*self).into();
|
let SRGBA8 { red, green, blue, alpha } = (*self).into();
|
||||||
[red, green, blue, alpha].to_vec()
|
[red, green, blue, alpha].to_vec()
|
||||||
@@ -444,10 +422,7 @@ impl Color {
|
|||||||
lightness + saturation - lightness * saturation
|
lightness + saturation - lightness * saturation
|
||||||
};
|
};
|
||||||
let temp2 = 2. * lightness - temp1;
|
let temp2 = 2. * lightness - temp1;
|
||||||
#[cfg(feature = "std")]
|
|
||||||
let rem = |x: f32| x.rem_euclid(1.);
|
let rem = |x: f32| x.rem_euclid(1.);
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
let rem = |x: f32| x.rem_euclid(&1.);
|
|
||||||
|
|
||||||
let mut red = rem(hue + 1. / 3.);
|
let mut red = rem(hue + 1. / 3.);
|
||||||
let mut green = rem(hue);
|
let mut green = rem(hue);
|
||||||
@@ -823,10 +798,7 @@ impl Color {
|
|||||||
/// Convert this color to HSV coordinates (all between 0 and 1).
|
/// Convert this color to HSV coordinates (all between 0 and 1).
|
||||||
/// HSV is defined on sRGB display values, so this color's linear RGB is gamma-encoded before the HSV math.
|
/// HSV is defined on sRGB display values, so this color's linear RGB is gamma-encoded before the HSV math.
|
||||||
pub fn to_hsva(&self) -> [f32; 4] {
|
pub fn to_hsva(&self) -> [f32; 4] {
|
||||||
#[cfg(feature = "std")]
|
|
||||||
let rem = |x: f32, m: f32| x.rem_euclid(m);
|
let rem = |x: f32, m: f32| x.rem_euclid(m);
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
let rem = |x: f32, m: f32| x.rem_euclid(&m);
|
|
||||||
|
|
||||||
let [red, green, blue, alpha] = self.to_gamma_srgb_channels();
|
let [red, green, blue, alpha] = self.to_gamma_srgb_channels();
|
||||||
let max = red.max(green).max(blue);
|
let max = red.max(green).max(blue);
|
||||||
@@ -873,10 +845,7 @@ impl Color {
|
|||||||
} else {
|
} else {
|
||||||
4. + (red - green) / (max_channel - min_channel)
|
4. + (red - green) / (max_channel - min_channel)
|
||||||
} / 6.;
|
} / 6.;
|
||||||
#[cfg(feature = "std")]
|
|
||||||
let hue = hue.rem_euclid(1.);
|
let hue = hue.rem_euclid(1.);
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
let hue = hue.rem_euclid(&1.);
|
|
||||||
|
|
||||||
[hue, saturation, lightness, alpha]
|
[hue, saturation, lightness, alpha]
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
-3
@@ -3,9 +3,6 @@
|
|||||||
//! These work in `f32` at full precision. For round-trip-exact `u8` ⇄ `f32` conversion at the
|
//! These work in `f32` at full precision. For round-trip-exact `u8` ⇄ `f32` conversion at the
|
||||||
//! display byte boundary, use the lookup tables in [`super::discrete_srgb`] instead.
|
//! display byte boundary, use the lookup tables in [`super::discrete_srgb`] instead.
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use num_traits::float::Float;
|
|
||||||
|
|
||||||
/// Decode an sRGB gamma-encoded channel value to linear-light.
|
/// Decode an sRGB gamma-encoded channel value to linear-light.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn srgb_to_linear(channel: f32) -> f32 {
|
pub fn srgb_to_linear(channel: f32) -> f32 {
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
use crate::runtime::{Generations, SourceId};
|
use crate::runtime::{Generations, SourceId};
|
||||||
use crate::transform::Footprint;
|
use crate::transform::Footprint;
|
||||||
use glam::DVec2;
|
use glam::{DAffine2, DVec2};
|
||||||
pub use no_std_types::context::{ArcCtx, Ctx};
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
@@ -9,6 +8,15 @@ use std::hash::{Hash, Hasher};
|
|||||||
use std::panic::Location;
|
use std::panic::Location;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub trait Ctx: Clone + Send {}
|
||||||
|
|
||||||
|
impl<T: Ctx> Ctx for Option<T> {}
|
||||||
|
impl<T: Ctx + Sync> Ctx for &T {}
|
||||||
|
impl Ctx for () {}
|
||||||
|
|
||||||
|
pub trait ArcCtx: Send + Sync {}
|
||||||
|
impl<T: ArcCtx> Ctx for Arc<T> {}
|
||||||
|
|
||||||
// ==============
|
// ==============
|
||||||
// EXTRACT TRAITS
|
// EXTRACT TRAITS
|
||||||
// ==============
|
// ==============
|
||||||
@@ -764,6 +772,20 @@ impl OwnedContextImpl {
|
|||||||
self.footprint = Some(footprint);
|
self.footprint = Some(footprint);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
/// Replaces any footprint with [`Footprint::for_instances`] for content placed once per transform in `instance_transforms`.
|
||||||
|
pub fn with_instances_footprint(mut self, instance_transforms: impl IntoIterator<Item = DAffine2>) -> Self {
|
||||||
|
if let Some(footprint) = &self.footprint {
|
||||||
|
self.footprint = Some(footprint.for_instances(instance_transforms));
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
/// Replaces any footprint with its [`Footprint::probe`].
|
||||||
|
pub fn with_probe_footprint(mut self) -> Self {
|
||||||
|
if let Some(footprint) = &self.footprint {
|
||||||
|
self.footprint = Some(footprint.probe());
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
pub fn with_real_time(mut self, real_time: f64) -> Self {
|
pub fn with_real_time(mut self, real_time: f64) -> Self {
|
||||||
self.real_time = Some(real_time);
|
self.real_time = Some(real_time);
|
||||||
self
|
self
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
|
pub mod blending;
|
||||||
pub mod bounds;
|
pub mod bounds;
|
||||||
|
pub mod choice_type;
|
||||||
|
pub mod color;
|
||||||
pub mod consts;
|
pub mod consts;
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod generic;
|
pub mod generic;
|
||||||
@@ -34,11 +37,6 @@ pub use list::{
|
|||||||
ATTR_LETTER_TILT, ATTR_LINE_HEIGHT, ATTR_LOCATION, ATTR_MAX_HEIGHT, ATTR_MAX_WIDTH, ATTR_NAME, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_START, ATTR_TEXT_ALIGN, ATTR_TRANSFORM, ATTR_TYPE,
|
ATTR_LETTER_TILT, ATTR_LINE_HEIGHT, ATTR_LOCATION, ATTR_MAX_HEIGHT, ATTR_MAX_WIDTH, ATTR_NAME, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_START, ATTR_TEXT_ALIGN, ATTR_TRANSFORM, ATTR_TYPE,
|
||||||
};
|
};
|
||||||
pub use memo::MemoHash;
|
pub use memo::MemoHash;
|
||||||
pub use no_std_types::AsU32;
|
|
||||||
pub use no_std_types::blending;
|
|
||||||
pub use no_std_types::choice_type;
|
|
||||||
pub use no_std_types::color;
|
|
||||||
pub use no_std_types::shaders;
|
|
||||||
pub use num_traits;
|
pub use num_traits;
|
||||||
pub use poll::{Finality, Interrupt, LazyInput, NodeError, Poll, PollInput, Status};
|
pub use poll::{Finality, Interrupt, LazyInput, NodeError, Poll, PollInput, Status};
|
||||||
pub use runtime::{Generations, RuntimeHandle, SourceId};
|
pub use runtime::{Generations, RuntimeHandle, SourceId};
|
||||||
@@ -166,3 +164,12 @@ impl<P: NodeParameter> From<P> for ParameterRef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait AsU32 {
|
||||||
|
fn as_u32(&self) -> u32;
|
||||||
|
}
|
||||||
|
impl AsU32 for u32 {
|
||||||
|
fn as_u32(&self) -> u32 {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,8 +90,8 @@ struct LegacyTable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Eventually remove this document upgrade code
|
// TODO: Eventually remove this document upgrade code
|
||||||
pub fn migrate_to_color<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<no_std_types::color::Color, D::Error> {
|
pub fn migrate_to_color<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<crate::color::Color, D::Error> {
|
||||||
use no_std_types::color::Color;
|
use crate::color::Color;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
|
||||||
|
|||||||
@@ -179,6 +179,8 @@ impl Footprint {
|
|||||||
quality: RenderQuality::Full,
|
quality: RenderQuality::Full,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const MAX_UNION_RESOLUTION: u32 = 8192;
|
||||||
|
|
||||||
pub const BOUNDLESS: Self = Self {
|
pub const BOUNDLESS: Self = Self {
|
||||||
transform: DAffine2 {
|
transform: DAffine2 {
|
||||||
matrix2: DMat2::from_diagonal(DVec2::splat(f64::INFINITY)),
|
matrix2: DMat2::from_diagonal(DVec2::splat(f64::INFINITY)),
|
||||||
@@ -201,6 +203,61 @@ impl Footprint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The same view squeezed into a single pixel, for evaluating content only to learn where it's placed. A boundless footprint stays boundless.
|
||||||
|
pub fn probe(&self) -> Footprint {
|
||||||
|
if !self.transform.is_finite() {
|
||||||
|
return *self;
|
||||||
|
}
|
||||||
|
|
||||||
|
Footprint {
|
||||||
|
transform: DAffine2::from_scale(1. / self.resolution.max(UVec2::ONE).as_dvec2()) * self.transform,
|
||||||
|
resolution: UVec2::ONE,
|
||||||
|
..*self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The footprint for content shown once per transform in `instance_transforms`, covering what every instance shows of it. A boundless footprint stays boundless.
|
||||||
|
pub fn for_instances(&self, instance_transforms: impl IntoIterator<Item = DAffine2>) -> Footprint {
|
||||||
|
if !self.transform.is_finite() {
|
||||||
|
return *self;
|
||||||
|
}
|
||||||
|
|
||||||
|
let views = instance_transforms.into_iter().map(|instance_transform| Footprint {
|
||||||
|
transform: self.transform * instance_transform,
|
||||||
|
..*self
|
||||||
|
});
|
||||||
|
Self::union(views).unwrap_or(*self)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The footprint covering everything each of `views` shows of the content, axis-aligned in the content's space at the finest pixel density any of them needs.
|
||||||
|
/// Its density is lowered to keep each side within [`Self::MAX_UNION_RESOLUTION`]. `None` when no view has an invertible transform.
|
||||||
|
pub fn union(views: impl IntoIterator<Item = Footprint>) -> Option<Footprint> {
|
||||||
|
let mut bounds: Option<AxisAlignedBbox> = None;
|
||||||
|
let mut density = 0_f64;
|
||||||
|
let mut quality = RenderQuality::Full;
|
||||||
|
for view in views {
|
||||||
|
if view.transform.matrix2.determinant() == 0. {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let view_bounds = view.viewport_bounds_in_local_space();
|
||||||
|
bounds = Some(bounds.map_or(view_bounds.clone(), |bounds| bounds.union(&view_bounds)));
|
||||||
|
density = density.max(view.scale().max_element());
|
||||||
|
quality = view.quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
let bounds = bounds?;
|
||||||
|
let size = bounds.size();
|
||||||
|
let density = density.min(Self::MAX_UNION_RESOLUTION as f64 / size.max_element());
|
||||||
|
let resolution = (size * density).ceil().as_uvec2().max(UVec2::ONE);
|
||||||
|
|
||||||
|
Some(Footprint {
|
||||||
|
transform: DAffine2::from_scale(DVec2::splat(density)) * DAffine2::from_translation(-bounds.start),
|
||||||
|
resolution,
|
||||||
|
quality,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn scale(&self) -> DVec2 {
|
pub fn scale(&self) -> DVec2 {
|
||||||
self.transform.scale_magnitudes()
|
self.transform.scale_magnitudes()
|
||||||
}
|
}
|
||||||
@@ -253,3 +310,59 @@ impl ApplyTransform for DVec2 {
|
|||||||
*self = modification.transform_point2(*self);
|
*self = modification.transform_point2(*self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn view(width: u32, height: u32) -> Footprint {
|
||||||
|
Footprint {
|
||||||
|
resolution: UVec2::new(width, height),
|
||||||
|
..Footprint::DEFAULT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn instances_footprint_covers_every_instance() {
|
||||||
|
let footprint = view(100, 100).for_instances([DAffine2::IDENTITY, DAffine2::from_translation(DVec2::new(200., 0.))]);
|
||||||
|
|
||||||
|
let bounds = footprint.viewport_bounds_in_local_space();
|
||||||
|
assert!(bounds.start.abs_diff_eq(DVec2::new(-200., 0.), 1e-9), "{bounds:?}");
|
||||||
|
assert!(bounds.end.abs_diff_eq(DVec2::new(100., 100.), 1e-9), "{bounds:?}");
|
||||||
|
assert_eq!(footprint.resolution, UVec2::new(300, 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn instances_footprint_takes_the_finest_density() {
|
||||||
|
let footprint = view(100, 100).for_instances([DAffine2::IDENTITY, DAffine2::from_scale(DVec2::splat(4.))]);
|
||||||
|
|
||||||
|
assert!((footprint.scale().x - 4.).abs() < 1e-9);
|
||||||
|
assert_eq!(footprint.resolution, UVec2::new(400, 400));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn instances_footprint_caps_its_resolution() {
|
||||||
|
let footprint = view(1000, 1000).for_instances([DAffine2::IDENTITY, DAffine2::from_translation(DVec2::new(1e6, 0.))]);
|
||||||
|
|
||||||
|
assert!(footprint.resolution.max_element() <= Footprint::MAX_UNION_RESOLUTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn boundless_footprint_stays_boundless() {
|
||||||
|
assert_eq!(Footprint::BOUNDLESS.for_instances([DAffine2::from_translation(DVec2::ONE)]), Footprint::BOUNDLESS);
|
||||||
|
assert_eq!(Footprint::BOUNDLESS.probe(), Footprint::BOUNDLESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn probe_covers_the_same_view_in_one_pixel() {
|
||||||
|
let footprint = Footprint {
|
||||||
|
transform: DAffine2::from_scale(DVec2::splat(2.)),
|
||||||
|
..view(100, 50)
|
||||||
|
};
|
||||||
|
let probe = footprint.probe();
|
||||||
|
|
||||||
|
assert_eq!(probe.resolution, UVec2::ONE);
|
||||||
|
let (bounds, probe_bounds) = (footprint.viewport_bounds_in_local_space(), probe.viewport_bounds_in_local_space());
|
||||||
|
assert!(bounds.start.abs_diff_eq(probe_bounds.start, 1e-9) && bounds.end.abs_diff_eq(probe_bounds.end, 1e-9));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,11 +15,9 @@ publish.workspace = true
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
|
||||||
std = ["dep:kurbo"]
|
|
||||||
derive = ["graphene-hash-derive"]
|
derive = ["graphene-hash-derive"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
graphene-hash-derive = { path = "derive", optional = true }
|
graphene-hash-derive = { path = "derive", optional = true }
|
||||||
glam = { workspace = true }
|
glam = { workspace = true }
|
||||||
kurbo = { workspace = true, optional = true }
|
kurbo = { workspace = true }
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
extern crate std;
|
|
||||||
|
|
||||||
#[cfg(feature = "derive")]
|
#[cfg(feature = "derive")]
|
||||||
pub use graphene_hash_derive::CacheHash;
|
pub use graphene_hash_derive::CacheHash;
|
||||||
|
|
||||||
@@ -66,7 +61,6 @@ impl_via_hash! {
|
|||||||
glam::BVec2, glam::BVec3, glam::BVec4,
|
glam::BVec2, glam::BVec3, glam::BVec4,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl_via_hash! {
|
impl_via_hash! {
|
||||||
String,
|
String,
|
||||||
}
|
}
|
||||||
@@ -154,7 +148,6 @@ impl_glam_array! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// kurbo path types: hash each element's verb and point coordinates via to_bits().
|
// kurbo path types: hash each element's verb and point coordinates via to_bits().
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl CacheHash for kurbo::Point {
|
impl CacheHash for kurbo::Point {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
@@ -163,7 +156,6 @@ impl CacheHash for kurbo::Point {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl CacheHash for kurbo::PathEl {
|
impl CacheHash for kurbo::PathEl {
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
core::hash::Hash::hash(&core::mem::discriminant(self), state);
|
core::hash::Hash::hash(&core::mem::discriminant(self), state);
|
||||||
@@ -183,7 +175,6 @@ impl CacheHash for kurbo::PathEl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl CacheHash for kurbo::BezPath {
|
impl CacheHash for kurbo::BezPath {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
@@ -224,7 +215,6 @@ impl<T: CacheHash, const N: usize> CacheHash for [T; N] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<T: CacheHash> CacheHash for Vec<T> {
|
impl<T: CacheHash> CacheHash for Vec<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
@@ -232,7 +222,6 @@ impl<T: CacheHash> CacheHash for Vec<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<T: CacheHash> CacheHash for std::collections::BTreeSet<T> {
|
impl<T: CacheHash> CacheHash for std::collections::BTreeSet<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
@@ -243,7 +232,6 @@ impl<T: CacheHash> CacheHash for std::collections::BTreeSet<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<T: CacheHash + ?Sized> CacheHash for Box<T> {
|
impl<T: CacheHash + ?Sized> CacheHash for Box<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
@@ -251,7 +239,6 @@ impl<T: CacheHash + ?Sized> CacheHash for Box<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<T: CacheHash + ?Sized> CacheHash for std::sync::Arc<T> {
|
impl<T: CacheHash + ?Sized> CacheHash for std::sync::Arc<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
|||||||
@@ -360,6 +360,16 @@ impl TryFromGraphic for Raster<CPU> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFromGraphic for Raster<GPU> {
|
||||||
|
fn try_from_graphic(graphic: Graphic) -> Option<List<Self>> {
|
||||||
|
match graphic {
|
||||||
|
Graphic::RasterGPU(item) => Some(List::new_from_item(item)),
|
||||||
|
Graphic::RasterGPUList(list) => Some(list),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TryFromGraphic for Color {
|
impl TryFromGraphic for Color {
|
||||||
fn try_from_graphic(graphic: Graphic) -> Option<List<Self>> {
|
fn try_from_graphic(graphic: Graphic) -> Option<List<Self>> {
|
||||||
match graphic {
|
match graphic {
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "no-std-types"
|
|
||||||
description = "no_std types for Graphene (shader-compatible)"
|
|
||||||
version.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
readme.workspace = true
|
|
||||||
homepage.workspace = true
|
|
||||||
rust-version.workspace = true
|
|
||||||
publish.workspace = true
|
|
||||||
|
|
||||||
[features]
|
|
||||||
# any feature that
|
|
||||||
# * must be usable in shaders
|
|
||||||
# * but requires std
|
|
||||||
# * and should be on by default
|
|
||||||
# should be in this list instead of `[workspace.dependency]`
|
|
||||||
std = [
|
|
||||||
"dep:dyn-any",
|
|
||||||
"dep:graphene-hash",
|
|
||||||
"dep:serde",
|
|
||||||
"dep:log",
|
|
||||||
"glam/debug-glam-assert",
|
|
||||||
"glam/std",
|
|
||||||
"glam/serde",
|
|
||||||
"half/std",
|
|
||||||
"half/serde",
|
|
||||||
"num-traits/std",
|
|
||||||
"num_enum/std",
|
|
||||||
]
|
|
||||||
wasm = ["tsify", "wasm-bindgen"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
# Local dependencies
|
|
||||||
node-macro = { workspace = true }
|
|
||||||
|
|
||||||
# Local std dependencies
|
|
||||||
dyn-any = { workspace = true, optional = true }
|
|
||||||
graphene-hash = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
# Workspace dependencies
|
|
||||||
bytemuck = { workspace = true }
|
|
||||||
glam = { workspace = true }
|
|
||||||
half = { workspace = true, default-features = false }
|
|
||||||
num-derive = { workspace = true }
|
|
||||||
num-traits = { workspace = true }
|
|
||||||
num_enum = { workspace = true }
|
|
||||||
spirv-std = { workspace = true }
|
|
||||||
|
|
||||||
# Workspace std dependencies
|
|
||||||
serde = { workspace = true, optional = true }
|
|
||||||
log = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
# Workspace wasm dependencies
|
|
||||||
tsify = { workspace = true, optional = true }
|
|
||||||
wasm-bindgen = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
core-types = { workspace = true }
|
|
||||||
|
|
||||||
[lints.rust]
|
|
||||||
# the spirv target is not in the list of common cfgs so must be added manually
|
|
||||||
unexpected_cfgs = { level = "warn", check-cfg = [
|
|
||||||
'cfg(target_arch, values("spirv"))',
|
|
||||||
] }
|
|
||||||
|
|
||||||
[package.metadata.cargo-shear]
|
|
||||||
ignored = ["core-types"]
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
pub trait Ctx: Clone + Send {}
|
|
||||||
|
|
||||||
impl<T: Ctx> Ctx for Option<T> {}
|
|
||||||
impl<T: Ctx + Sync> Ctx for &T {}
|
|
||||||
impl Ctx for () {}
|
|
||||||
|
|
||||||
pub trait ArcCtx: Send + Sync {}
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<T: ArcCtx> Ctx for std::sync::Arc<T> {}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
|
||||||
|
|
||||||
pub mod blending;
|
|
||||||
pub mod choice_type;
|
|
||||||
pub mod color;
|
|
||||||
pub mod context;
|
|
||||||
pub mod list;
|
|
||||||
pub mod shaders;
|
|
||||||
|
|
||||||
pub use context::Ctx;
|
|
||||||
pub use glam;
|
|
||||||
|
|
||||||
pub trait AsU32 {
|
|
||||||
fn as_u32(&self) -> u32;
|
|
||||||
}
|
|
||||||
impl AsU32 for u32 {
|
|
||||||
fn as_u32(&self) -> u32 {
|
|
||||||
*self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
//! A zero-cost stand-in for `core_types::list::Item` used when node kernels are compiled for the GPU.
|
|
||||||
//!
|
|
||||||
//! Shader node kernels compile twice: under `std` against the real attribute-carrying `Item`, and under
|
|
||||||
//! `no_std` (SPIR-V) against this transparent wrapper, imported as `Item`. Only the element-access surface is
|
|
||||||
//! provided, since rust-gpu cannot allocate and attributes have no per-pixel meaning; attribute use fails the
|
|
||||||
//! shader build. It is named distinctly from `Item` so a search for the canonical type finds only that one.
|
|
||||||
|
|
||||||
/// A rank-0 wire value holding a single element, mirroring the element-access API of the real `Item`.
|
|
||||||
#[repr(transparent)]
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
|
||||||
pub struct ShaderItem<T> {
|
|
||||||
element: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> ShaderItem<T> {
|
|
||||||
/// Constructs an item with the given element.
|
|
||||||
pub fn new_from_element(element: T) -> Self {
|
|
||||||
Self { element }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a shared reference to this item's element.
|
|
||||||
pub fn element(&self) -> &T {
|
|
||||||
&self.element
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a mutable reference to this item's element.
|
|
||||||
pub fn element_mut(&mut self) -> &mut T {
|
|
||||||
&mut self.element
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Consumes this item and returns the owned element.
|
|
||||||
pub fn into_element(self) -> T {
|
|
||||||
self.element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> From<T> for ShaderItem<T> {
|
|
||||||
fn from(element: T) -> Self {
|
|
||||||
Self::new_from_element(element)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
use crate::shaders::buffer_struct::BufferStruct;
|
|
||||||
|
|
||||||
macro_rules! glam_array {
|
|
||||||
($t:ty, $a:ty) => {
|
|
||||||
unsafe impl BufferStruct for $t {
|
|
||||||
type Buffer = $a;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
<$t>::to_array(&from)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
<$t>::from_array(from)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! glam_cols_array {
|
|
||||||
($t:ty, $a:ty) => {
|
|
||||||
unsafe impl BufferStruct for $t {
|
|
||||||
type Buffer = $a;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
<$t>::to_cols_array(&from)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
<$t>::from_cols_array(&from)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
glam_array!(glam::Vec2, [f32; 2]);
|
|
||||||
glam_array!(glam::Vec3, [f32; 3]);
|
|
||||||
// glam_array!(Vec3A, [f32; 4]);
|
|
||||||
glam_array!(glam::Vec4, [f32; 4]);
|
|
||||||
glam_cols_array!(glam::Mat2, [f32; 4]);
|
|
||||||
glam_cols_array!(glam::Mat3, [f32; 9]);
|
|
||||||
// glam_cols_array!(Mat3A, [f32; 4]);
|
|
||||||
glam_cols_array!(glam::Mat4, [f32; 16]);
|
|
||||||
glam_cols_array!(glam::Affine2, [f32; 6]);
|
|
||||||
glam_cols_array!(glam::Affine3A, [f32; 12]);
|
|
||||||
|
|
||||||
glam_array!(glam::DVec2, [f64; 2]);
|
|
||||||
glam_array!(glam::DVec3, [f64; 3]);
|
|
||||||
glam_array!(glam::DVec4, [f64; 4]);
|
|
||||||
glam_cols_array!(glam::DMat2, [f64; 4]);
|
|
||||||
glam_cols_array!(glam::DMat3, [f64; 9]);
|
|
||||||
glam_cols_array!(glam::DMat4, [f64; 16]);
|
|
||||||
glam_cols_array!(glam::DAffine2, [f64; 6]);
|
|
||||||
glam_cols_array!(glam::DAffine3, [f64; 12]);
|
|
||||||
|
|
||||||
glam_array!(glam::I16Vec2, [i16; 2]);
|
|
||||||
glam_array!(glam::I16Vec3, [i16; 3]);
|
|
||||||
glam_array!(glam::I16Vec4, [i16; 4]);
|
|
||||||
|
|
||||||
glam_array!(glam::U16Vec2, [u16; 2]);
|
|
||||||
glam_array!(glam::U16Vec3, [u16; 3]);
|
|
||||||
glam_array!(glam::U16Vec4, [u16; 4]);
|
|
||||||
|
|
||||||
glam_array!(glam::IVec2, [i32; 2]);
|
|
||||||
glam_array!(glam::IVec3, [i32; 3]);
|
|
||||||
glam_array!(glam::IVec4, [i32; 4]);
|
|
||||||
|
|
||||||
glam_array!(glam::UVec2, [u32; 2]);
|
|
||||||
glam_array!(glam::UVec3, [u32; 3]);
|
|
||||||
glam_array!(glam::UVec4, [u32; 4]);
|
|
||||||
|
|
||||||
glam_array!(glam::I64Vec2, [i64; 2]);
|
|
||||||
glam_array!(glam::I64Vec3, [i64; 3]);
|
|
||||||
glam_array!(glam::I64Vec4, [i64; 4]);
|
|
||||||
|
|
||||||
glam_array!(glam::U64Vec2, [u64; 2]);
|
|
||||||
glam_array!(glam::U64Vec3, [u64; 3]);
|
|
||||||
glam_array!(glam::U64Vec4, [u64; 4]);
|
|
||||||
|
|
||||||
unsafe impl BufferStruct for glam::Vec3A {
|
|
||||||
type Buffer = [f32; 4];
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
glam::Vec4::to_array(&from.extend(0.))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
glam::Vec3A::from_vec4(glam::Vec4::from_array(from))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// do NOT use slices, otherwise spirv will fail to compile
|
|
||||||
unsafe impl BufferStruct for glam::Mat3A {
|
|
||||||
type Buffer = [f32; 12];
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
let a = from.to_cols_array();
|
|
||||||
[a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], 0., 0., 0.]
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
let a = from;
|
|
||||||
glam::Mat3A::from_cols_array(&[a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
//! I (@firestar99) copied this entire mod from one of my projects, as I haven't uploaded that lib to crates. Hopefully
|
|
||||||
//! rust-gpu improves and this entire thing becomes unnecessary in the future.
|
|
||||||
//!
|
|
||||||
//! https://github.com/Firestar99/nanite-at-home/tree/008dac8df656959c71efeddd2d3ddabcb801771c/rust-gpu-bindless/crates/buffer-content
|
|
||||||
|
|
||||||
use bytemuck::Pod;
|
|
||||||
|
|
||||||
mod glam;
|
|
||||||
mod primitive;
|
|
||||||
|
|
||||||
/// A BufferStruct is a "parallel representation" of the original struct with some fundamental types remapped. This
|
|
||||||
/// struct hierarchy represents how data is stored in GPU Buffers, where all types must be [`Pod`] to allow
|
|
||||||
/// transmuting them to `&[u8]` with [`bytemuck`].
|
|
||||||
///
|
|
||||||
/// Notable type remappings (original: buffer):
|
|
||||||
/// * bool: u32 of 0 or 1
|
|
||||||
/// * any repr(u32) enum: u32 with remapping via [`num_enum`]
|
|
||||||
///
|
|
||||||
/// By adding `#[derive(ShaderStruct)]` to your struct (or enum), a parallel `{name}Buffer` struct is created with all
|
|
||||||
/// the members of the original struct, but with their types using the associated remapped types as specified by this
|
|
||||||
/// trait.
|
|
||||||
///
|
|
||||||
/// # Origin
|
|
||||||
/// I (@firestar99) copied this entire mod from my [Nanite-at-home] project, specifically the [buffer-content] crate
|
|
||||||
/// and the [buffer_struct] proc macro. The variant here has quite some modifications, to both cleaned up some of the
|
|
||||||
/// mistakes my implementation has and to customize it a bit for graphite.
|
|
||||||
///
|
|
||||||
/// Hopefully rust-gpu improves to the point where this remapping becomes unnecessary.
|
|
||||||
///
|
|
||||||
/// [Nanite-at-home]: https://github.com/Firestar99/nanite-at-home
|
|
||||||
/// [buffer-content]: https://github.com/Firestar99/nanite-at-home/tree/008dac8df656959c71efeddd2d3ddabcb801771c/rust-gpu-bindless/crates/buffer-content
|
|
||||||
/// [buffer_struct]: https://github.com/Firestar99/nanite-at-home/blob/008dac8df656959c71efeddd2d3ddabcb801771c/rust-gpu-bindless/crates/macros/src/buffer_struct.rs
|
|
||||||
///
|
|
||||||
/// # Safety
|
|
||||||
/// The associated type Transfer must be the same on all targets. Writing followed by reading back a value must result
|
|
||||||
/// in the same value.
|
|
||||||
pub unsafe trait BufferStruct: Copy + Send + Sync + 'static {
|
|
||||||
type Buffer: Pod + Send + Sync;
|
|
||||||
|
|
||||||
fn write(from: Self) -> Self::Buffer;
|
|
||||||
|
|
||||||
fn read(from: Self::Buffer) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trait marking all [`BufferStruct`] whose read and write methods are identity. While [`BufferStruct`] only
|
|
||||||
/// requires `t == read(write(t))`, this trait additionally requires `t == read(t) == write(t)`. As this removes the
|
|
||||||
/// conversion requirement for writing to or reading from a buffer, one can acquire slices from buffers created of these
|
|
||||||
/// types.
|
|
||||||
///
|
|
||||||
/// Implementing this type is completely safe due to the [`Pod`] requirement.
|
|
||||||
pub trait BufferStructIdentity: Pod + Send + Sync {}
|
|
||||||
|
|
||||||
unsafe impl<T: BufferStructIdentity> BufferStruct for T {
|
|
||||||
type Buffer = Self;
|
|
||||||
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
from
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
from
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
use crate::shaders::buffer_struct::{BufferStruct, BufferStructIdentity};
|
|
||||||
use bytemuck::Pod;
|
|
||||||
use core::marker::PhantomData;
|
|
||||||
use core::num::Wrapping;
|
|
||||||
use spirv_std::arch::IndexUnchecked;
|
|
||||||
|
|
||||||
macro_rules! identity {
|
|
||||||
($t:ty) => {
|
|
||||||
impl BufferStructIdentity for $t {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
identity!(());
|
|
||||||
identity!(u8);
|
|
||||||
identity!(u16);
|
|
||||||
identity!(u32);
|
|
||||||
identity!(u64);
|
|
||||||
identity!(u128);
|
|
||||||
identity!(usize);
|
|
||||||
identity!(i8);
|
|
||||||
identity!(i16);
|
|
||||||
identity!(i32);
|
|
||||||
identity!(i64);
|
|
||||||
identity!(i128);
|
|
||||||
identity!(isize);
|
|
||||||
identity!(f32);
|
|
||||||
identity!(f64);
|
|
||||||
|
|
||||||
identity!(spirv_std::memory::Semantics);
|
|
||||||
identity!(spirv_std::ray_tracing::RayFlags);
|
|
||||||
identity!(spirv_std::indirect_command::DrawIndirectCommand);
|
|
||||||
identity!(spirv_std::indirect_command::DrawIndexedIndirectCommand);
|
|
||||||
identity!(spirv_std::indirect_command::DispatchIndirectCommand);
|
|
||||||
identity!(spirv_std::indirect_command::DrawMeshTasksIndirectCommandEXT);
|
|
||||||
identity!(spirv_std::indirect_command::TraceRaysIndirectCommandKHR);
|
|
||||||
// not pod
|
|
||||||
// identity!(spirv_std::indirect_command::TraceRaysIndirectCommand2KHR);
|
|
||||||
|
|
||||||
unsafe impl BufferStruct for bool {
|
|
||||||
type Buffer = u32;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
from as u32
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
from != 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<T: BufferStruct> BufferStruct for Wrapping<T>
|
|
||||||
where
|
|
||||||
// unfortunately has to be Pod, even though AnyBitPattern would be sufficient,
|
|
||||||
// due to bytemuck doing `impl<T: Pod> AnyBitPattern for T {}`
|
|
||||||
// see https://github.com/Lokathor/bytemuck/issues/164
|
|
||||||
T::Buffer: Pod,
|
|
||||||
{
|
|
||||||
type Buffer = Wrapping<T::Buffer>;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
Wrapping(T::write(from.0))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
Wrapping(T::read(from.0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<T: BufferStruct + 'static> BufferStruct for PhantomData<T> {
|
|
||||||
type Buffer = PhantomData<T>;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(_: Self) -> Self::Buffer {
|
|
||||||
PhantomData {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(_: Self::Buffer) -> Self {
|
|
||||||
PhantomData {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Potential problem: you can't impl this for an array of BufferStruct, as it'll conflict with this impl due to the
|
|
||||||
/// blanket impl on all BufferStructPlain types.
|
|
||||||
unsafe impl<T: BufferStruct, const N: usize> BufferStruct for [T; N]
|
|
||||||
where
|
|
||||||
// rust-gpu does not like `[T; N].map()` nor `core::array::from_fn()` nor transmuting arrays with a const generic
|
|
||||||
// length, so for now we need to require T: Default and T::Transfer: Default for all arrays.
|
|
||||||
T: Default,
|
|
||||||
// unfortunately has to be Pod, even though AnyBitPattern would be sufficient,
|
|
||||||
// due to bytemuck doing `impl<T: Pod> AnyBitPattern for T {}`
|
|
||||||
// see https://github.com/Lokathor/bytemuck/issues/164
|
|
||||||
T::Buffer: Pod + Default,
|
|
||||||
{
|
|
||||||
type Buffer = [T::Buffer; N];
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
unsafe {
|
|
||||||
let mut ret = [T::Buffer::default(); N];
|
|
||||||
for i in 0..N {
|
|
||||||
*ret.index_unchecked_mut(i) = T::write(*from.index_unchecked(i));
|
|
||||||
}
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
unsafe {
|
|
||||||
let mut ret = [T::default(); N];
|
|
||||||
for i in 0..N {
|
|
||||||
*ret.index_unchecked_mut(i) = T::read(*from.index_unchecked(i));
|
|
||||||
}
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn roundtrip_bool() {
|
|
||||||
for x in [false, true] {
|
|
||||||
assert_eq!(x, <bool as BufferStruct>::read(<bool as BufferStruct>::write(x)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
//! supporting infrastructure for shaders
|
|
||||||
|
|
||||||
pub mod buffer_struct;
|
|
||||||
|
|
||||||
pub mod __private {
|
|
||||||
pub use bytemuck;
|
|
||||||
pub use glam;
|
|
||||||
pub use num_enum;
|
|
||||||
pub use spirv_std;
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ pub mod raster_types;
|
|||||||
pub use image::Image;
|
pub use image::Image;
|
||||||
pub use raster_types::*;
|
pub use raster_types::*;
|
||||||
|
|
||||||
// Re-export color types from no-std-types
|
// Re-export color types from core-types
|
||||||
pub use core_types::color::*;
|
pub use core_types::color::*;
|
||||||
|
|
||||||
/// as to not yet rename all references
|
/// as to not yet rename all references
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ mod __private {
|
|||||||
|
|
||||||
pub trait Storage: __private::Sealed + Clone + Debug + 'static {
|
pub trait Storage: __private::Sealed + Clone + Debug + 'static {
|
||||||
fn is_empty(&self) -> bool;
|
fn is_empty(&self) -> bool;
|
||||||
|
/// The affine from the unit square of the pixels onto the region of the item's local space they cover, which the unit square is logically.
|
||||||
|
fn coverage(&self) -> DAffine2 {
|
||||||
|
DAffine2::IDENTITY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default)]
|
#[derive(Clone, Debug, PartialEq, Default)]
|
||||||
@@ -285,6 +289,7 @@ pub use gpu::{Texture, TextureWeakRef};
|
|||||||
mod gpu {
|
mod gpu {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::raster_types::__private::Sealed;
|
use crate::raster_types::__private::Sealed;
|
||||||
|
use glam::UVec2;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, DynAny)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, DynAny)]
|
||||||
@@ -349,15 +354,23 @@ mod gpu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
pub struct GPU {
|
pub struct GPU {
|
||||||
pub texture: Texture,
|
texture: Option<Texture>,
|
||||||
|
coverage: DAffine2,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::core::hash::Hash for GPU {
|
||||||
|
fn hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
self.texture.hash(state);
|
||||||
|
self.coverage.to_cols_array().map(f64::to_bits).hash(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl core_types::CacheHash for GPU {
|
impl core_types::CacheHash for GPU {
|
||||||
fn cache_hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
|
fn cache_hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
|
||||||
use ::core::hash::Hash;
|
use ::core::hash::Hash;
|
||||||
self.texture.hash(state);
|
self.hash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,17 +378,35 @@ mod gpu {
|
|||||||
|
|
||||||
impl Storage for Raster<GPU> {
|
impl Storage for Raster<GPU> {
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty(&self) -> bool {
|
||||||
self.texture.width() == 0 || self.texture.height() == 0
|
let size = self.size();
|
||||||
|
size.x == 0 || size.y == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn coverage(&self) -> DAffine2 {
|
||||||
|
self.coverage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Raster<GPU> {
|
impl Raster<GPU> {
|
||||||
pub fn new_gpu(texture: impl Into<Texture>) -> Self {
|
pub fn new_gpu(texture: impl Into<Texture>) -> Self {
|
||||||
Self::new(GPU { texture: texture.into() })
|
Self::new(GPU {
|
||||||
|
texture: Some(texture.into()),
|
||||||
|
coverage: DAffine2::IDENTITY,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &wgpu::Texture {
|
/// The same pixels covering the region of the item's local space that `coverage` maps the unit square onto.
|
||||||
&self.texture
|
pub fn with_coverage(mut self, coverage: DAffine2) -> Self {
|
||||||
|
self.coverage = coverage;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn texture(&self) -> Option<&Texture> {
|
||||||
|
self.texture.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn size(&self) -> UVec2 {
|
||||||
|
self.texture.as_ref().map_or(UVec2::ZERO, |texture| UVec2::new(texture.width(), texture.height()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,7 +416,7 @@ mod gpu {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::raster_types::__private::Sealed;
|
use crate::raster_types::__private::Sealed;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Hash, core_types::CacheHash)]
|
#[derive(Clone, Debug, Default, PartialEq, Hash, core_types::CacheHash)]
|
||||||
pub struct GPU;
|
pub struct GPU;
|
||||||
|
|
||||||
impl Sealed for Raster<GPU> {}
|
impl Sealed for Raster<GPU> {}
|
||||||
@@ -429,7 +460,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
let unit_rectangle = Quad::from_box([DVec2::ZERO, DVec2::ONE]);
|
let unit_rectangle = Quad::from_box([DVec2::ZERO, DVec2::ONE]);
|
||||||
RenderBoundingBox::Rectangle((transform * unit_rectangle).bounding_box())
|
let [start, end] = (transform * unit_rectangle).bounding_box();
|
||||||
|
let [covered_start, covered_end] = (transform * self.coverage() * unit_rectangle).bounding_box();
|
||||||
|
RenderBoundingBox::Rectangle([start.min(covered_start), end.max(covered_end)])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn thumbnail_bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
|
fn thumbnail_bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use core_types::{
|
|||||||
use dyn_any::DynAny;
|
use dyn_any::DynAny;
|
||||||
use glam::{DAffine2, DMat2, DVec2};
|
use glam::{DAffine2, DMat2, DVec2};
|
||||||
use graphene_resource::Resource;
|
use graphene_resource::Resource;
|
||||||
use graphic_types::raster_types::{CPU, GPU, Raster};
|
use graphic_types::raster_types::{CPU, GPU, Raster, Storage, Texture};
|
||||||
use graphic_types::vector_types::gradient::{Gradient, GradientForm};
|
use graphic_types::vector_types::gradient::{Gradient, GradientForm};
|
||||||
use graphic_types::vector_types::vector::click_target::{ClickTarget, FreePoint, TargetPath};
|
use graphic_types::vector_types::vector::click_target::{ClickTarget, FreePoint, TargetPath};
|
||||||
use graphic_types::vector_types::vector::misc::dvec2_to_point;
|
use graphic_types::vector_types::vector::misc::dvec2_to_point;
|
||||||
@@ -377,6 +377,9 @@ pub struct RenderParams {
|
|||||||
pub canvas_image_scale: f64,
|
pub canvas_image_scale: f64,
|
||||||
/// The nearest ancestor's appearance, cascading to items that lack their own.
|
/// The nearest ancestor's appearance, cascading to items that lack their own.
|
||||||
pub inherited_appearance: Option<Appearance>,
|
pub inherited_appearance: Option<Appearance>,
|
||||||
|
/// Downloaded images of GPU raster textures, which SVG output embeds in place of the textures it can't reference. GPU rasters without one are not drawn.
|
||||||
|
#[cache_hash(skip)]
|
||||||
|
pub gpu_raster_downloads: Arc<HashMap<Texture, Raster<CPU>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderParams {
|
impl RenderParams {
|
||||||
@@ -775,6 +778,9 @@ pub trait Render: BoundingBox {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Recursively collects the textures of the GPU rasters this content draws, including those painting its appearances, so SVG output can download them first.
|
||||||
|
fn collect_gpu_textures(&self, _textures: &mut Vec<Texture>) {}
|
||||||
|
|
||||||
fn new_ids_from_hash(&mut self, _reference: Option<NodeId>) {}
|
fn new_ids_from_hash(&mut self, _reference: Option<NodeId>) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,6 +1048,20 @@ fn add_graphic_item_outline_targets(item: ItemRef<'_, Graphic>, outlines: &mut V
|
|||||||
outlines.extend(new_outlines);
|
outlines.extend(new_outlines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Collects the textures of the GPU rasters painting an appearance's coverages.
|
||||||
|
fn collect_appearance_gpu_textures(appearance: Option<&Appearance>, textures: &mut Vec<Texture>) {
|
||||||
|
for paint in appearance.into_iter().flat_map(Appearance::covers_with_paints).filter_map(|(_, paint)| paint) {
|
||||||
|
paint.collect_gpu_textures(textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collects the textures of the GPU rasters painting the appearances of a list's items.
|
||||||
|
fn collect_list_appearance_gpu_textures<T>(list: &List<T>, textures: &mut Vec<Texture>) {
|
||||||
|
for appearance in list.iter_attribute_values::<Appearance>(ATTR_APPEARANCE).into_iter().flatten() {
|
||||||
|
collect_appearance_gpu_textures(Some(appearance), textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for Graphic {
|
impl Render for Graphic {
|
||||||
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
match self {
|
match self {
|
||||||
@@ -1049,14 +1069,14 @@ impl Render for Graphic {
|
|||||||
Graphic::Graphic(item) => render_graphic_item_svg(ItemRef::Item(item), false, &mut None, render, render_params),
|
Graphic::Graphic(item) => render_graphic_item_svg(ItemRef::Item(item), false, &mut None, render, render_params),
|
||||||
Graphic::Vector(item) => render_vector_item_svg(ItemRef::Item(item), false, &mut None, render, render_params),
|
Graphic::Vector(item) => render_vector_item_svg(ItemRef::Item(item), false, &mut None, render, render_params),
|
||||||
Graphic::RasterCPU(item) => render_raster_cpu_item_svg(ItemRef::Item(item), render, render_params),
|
Graphic::RasterCPU(item) => render_raster_cpu_item_svg(ItemRef::Item(item), render, render_params),
|
||||||
Graphic::RasterGPU(_) => (),
|
Graphic::RasterGPU(item) => render_raster_gpu_item_svg(ItemRef::Item(item), render, render_params),
|
||||||
Graphic::Color(item) => render_color_item_svg(ItemRef::Item(item), render, render_params),
|
Graphic::Color(item) => render_color_item_svg(ItemRef::Item(item), render, render_params),
|
||||||
Graphic::Gradient(item) => render_gradient_item_svg(ItemRef::Item(item), render, render_params),
|
Graphic::Gradient(item) => render_gradient_item_svg(ItemRef::Item(item), render, render_params),
|
||||||
Graphic::Text(item) => render_text_item_svg(ItemRef::Item(item), render, render_params),
|
Graphic::Text(item) => render_text_item_svg(ItemRef::Item(item), render, render_params),
|
||||||
Graphic::GraphicList(list) => list.render_svg(render, render_params),
|
Graphic::GraphicList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::VectorList(list) => list.render_svg(render, render_params),
|
Graphic::VectorList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::RasterCPUList(list) => list.render_svg(render, render_params),
|
Graphic::RasterCPUList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::RasterGPUList(_) => (),
|
Graphic::RasterGPUList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::ColorList(list) => list.render_svg(render, render_params),
|
Graphic::ColorList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::GradientList(list) => list.render_svg(render, render_params),
|
Graphic::GradientList(list) => list.render_svg(render, render_params),
|
||||||
Graphic::TextList(list) => list.render_svg(render, render_params),
|
Graphic::TextList(list) => list.render_svg(render, render_params),
|
||||||
@@ -1092,6 +1112,31 @@ impl Render for Graphic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_gpu_textures(&self, textures: &mut Vec<Texture>) {
|
||||||
|
match self {
|
||||||
|
Graphic::Graphic(item) => {
|
||||||
|
item.element().collect_gpu_textures(textures);
|
||||||
|
collect_appearance_gpu_textures(item.attribute(ATTR_APPEARANCE), textures);
|
||||||
|
}
|
||||||
|
Graphic::Vector(item) => collect_appearance_gpu_textures(item.attribute(ATTR_APPEARANCE), textures),
|
||||||
|
Graphic::RasterGPU(item) => collect_raster_gpu_texture(item.element(), textures),
|
||||||
|
Graphic::GraphicList(list) => list.collect_gpu_textures(textures),
|
||||||
|
Graphic::VectorList(list) => list.collect_gpu_textures(textures),
|
||||||
|
Graphic::RasterGPUList(list) => list.collect_gpu_textures(textures),
|
||||||
|
Graphic::None(_)
|
||||||
|
| Graphic::NoneList(_)
|
||||||
|
| Graphic::RasterCPU(_)
|
||||||
|
| Graphic::Color(_)
|
||||||
|
| Graphic::Gradient(_)
|
||||||
|
| Graphic::Text(_)
|
||||||
|
| Graphic::RasterCPUList(_)
|
||||||
|
| Graphic::ColorList(_)
|
||||||
|
| Graphic::GradientList(_)
|
||||||
|
| Graphic::TextList(_)
|
||||||
|
| Graphic::StrokeList(_) => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, element_id: Option<NodeId>, inherited_appearance: Option<&Appearance>) {
|
fn collect_metadata(&self, metadata: &mut RenderMetadata, footprint: Footprint, element_id: Option<NodeId>, inherited_appearance: Option<&Appearance>) {
|
||||||
if let Some(element_id) = element_id {
|
if let Some(element_id) = element_id {
|
||||||
// The footprint always lands; the transform (and for vectors the source layer) comes from the first item when one exists
|
// The footprint always lands; the transform (and for vectors the source layer) comes from the first item when one exists
|
||||||
@@ -1388,6 +1433,12 @@ impl Render for List<Artboard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_gpu_textures(&self, textures: &mut Vec<Texture>) {
|
||||||
|
for artboard in self.iter_element_values() {
|
||||||
|
artboard.as_graphic_list().collect_gpu_textures(textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn add_upstream_click_targets(&self, click_targets: &mut Vec<ClickTarget>, _inherited_appearance: Option<&Appearance>) {
|
fn add_upstream_click_targets(&self, click_targets: &mut Vec<ClickTarget>, _inherited_appearance: Option<&Appearance>) {
|
||||||
for index in 0..self.len() {
|
for index in 0..self.len() {
|
||||||
let dimensions: DVec2 = self.attribute_cloned_or_default(ATTR_DIMENSIONS, index);
|
let dimensions: DVec2 = self.attribute_cloned_or_default(ATTR_DIMENSIONS, index);
|
||||||
@@ -1439,6 +1490,13 @@ impl Render for List<Graphic> {
|
|||||||
self.iter_element_values().any(|element| element.contains_artboard())
|
self.iter_element_values().any(|element| element.contains_artboard())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_gpu_textures(&self, textures: &mut Vec<Texture>) {
|
||||||
|
for element in self.iter_element_values() {
|
||||||
|
element.collect_gpu_textures(textures);
|
||||||
|
}
|
||||||
|
collect_list_appearance_gpu_textures(self, textures);
|
||||||
|
}
|
||||||
|
|
||||||
fn new_ids_from_hash(&mut self, _reference: Option<NodeId>) {
|
fn new_ids_from_hash(&mut self, _reference: Option<NodeId>) {
|
||||||
let (elements, layers) = self.element_and_attribute_slices_mut::<NodeIdPath>(ATTR_EDITOR_LAYER_PATH);
|
let (elements, layers) = self.element_and_attribute_slices_mut::<NodeIdPath>(ATTR_EDITOR_LAYER_PATH);
|
||||||
for (element, layer) in elements.iter_mut().zip(layers.iter()) {
|
for (element, layer) in elements.iter_mut().zip(layers.iter()) {
|
||||||
@@ -2242,6 +2300,10 @@ impl Render for List<Vector> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_gpu_textures(&self, textures: &mut Vec<Texture>) {
|
||||||
|
collect_list_appearance_gpu_textures(self, textures);
|
||||||
|
}
|
||||||
|
|
||||||
fn new_ids_from_hash(&mut self, reference: Option<NodeId>) {
|
fn new_ids_from_hash(&mut self, reference: Option<NodeId>) {
|
||||||
for index in 0..self.len() {
|
for index in 0..self.len() {
|
||||||
edit_list_row_geometry(self, index, |vector, paths| vector.vector_new_ids_from_hash(paths, reference.map(|id| id.0).unwrap_or_default()));
|
edit_list_row_geometry(self, index, |vector, paths| vector.vector_new_ids_from_hash(paths, reference.map(|id| id.0).unwrap_or_default()));
|
||||||
@@ -2357,8 +2419,22 @@ fn canvas_image_id(buffer_id: u64, halvings: u32) -> u64 {
|
|||||||
/// Emits one item of CPU raster content as SVG, as a canvas placeholder or an embedded base64 image.
|
/// Emits one item of CPU raster content as SVG, as a canvas placeholder or an embedded base64 image.
|
||||||
fn render_raster_cpu_item_svg(item: ItemRef<'_, Raster<CPU>>, render: &mut SvgRender, render_params: &RenderParams) {
|
fn render_raster_cpu_item_svg(item: ItemRef<'_, Raster<CPU>>, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
let Some(image) = item.element() else { return };
|
let Some(image) = item.element() else { return };
|
||||||
|
render_raster_image_svg(item, image, image.coverage(), render, render_params);
|
||||||
|
}
|
||||||
|
|
||||||
let transform: DAffine2 = item.attribute_cloned_or_default(ATTR_TRANSFORM);
|
/// Emits one item of GPU raster content as SVG from its texture's downloaded image, exactly as CPU raster content.
|
||||||
|
fn render_raster_gpu_item_svg(item: ItemRef<'_, Raster<GPU>>, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
|
let Some(raster) = item.element() else { return };
|
||||||
|
let Some(image) = raster.texture().and_then(|texture| render_params.gpu_raster_downloads.get(texture)) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
render_raster_image_svg(item, image, raster.coverage(), render, render_params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Emits a raster image as SVG, placed by the attributes of the item it's drawn for and the `coverage` of its pixels within it, and styled by those attributes.
|
||||||
|
fn render_raster_image_svg<T>(item: ItemRef<'_, T>, image: &Raster<CPU>, coverage: DAffine2, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
|
let item_transform: DAffine2 = item.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||||
|
let transform = item_transform * coverage;
|
||||||
let blend_mode_attr: BlendMode = item.attribute_cloned_or_default(ATTR_BLEND_MODE);
|
let blend_mode_attr: BlendMode = item.attribute_cloned_or_default(ATTR_BLEND_MODE);
|
||||||
let opacity_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY, 1.);
|
let opacity_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY, 1.);
|
||||||
let opacity_fill_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY_FILL, 1.);
|
let opacity_fill_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY_FILL, 1.);
|
||||||
@@ -2547,8 +2623,10 @@ impl Render for List<Raster<CPU>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Render for List<Raster<GPU>> {
|
impl Render for List<Raster<GPU>> {
|
||||||
fn render_svg(&self, _render: &mut SvgRender, _render_params: &RenderParams) {
|
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
log::warn!("tried to render texture as an svg");
|
for index in 0..self.len() {
|
||||||
|
render_raster_gpu_item_svg(ItemRef::ListItem(self, index), render, render_params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_to_vello(&self, scene: &mut VelloSceneBuilder, transform: DAffine2, render_params: &RenderParams) {
|
fn render_to_vello(&self, scene: &mut VelloSceneBuilder, transform: DAffine2, render_params: &RenderParams) {
|
||||||
@@ -2566,11 +2644,26 @@ impl Render for List<Raster<GPU>> {
|
|||||||
add_unit_square_click_target(self.attribute_cloned_or_default(ATTR_TRANSFORM, index), click_targets);
|
add_unit_square_click_target(self.attribute_cloned_or_default(ATTR_TRANSFORM, index), click_targets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_gpu_textures(&self, textures: &mut Vec<Texture>) {
|
||||||
|
for raster in self.iter_element_values() {
|
||||||
|
collect_raster_gpu_texture(raster, textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collects a GPU raster's texture unless it's empty or already collected.
|
||||||
|
fn collect_raster_gpu_texture(raster: &Raster<GPU>, textures: &mut Vec<Texture>) {
|
||||||
|
if let Some(texture) = raster.texture()
|
||||||
|
&& !textures.contains(texture)
|
||||||
|
{
|
||||||
|
textures.push(texture.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draws one item of GPU raster content into the Vello scene.
|
/// Draws one item of GPU raster content into the Vello scene.
|
||||||
fn render_raster_gpu_item_to_vello(item: ItemRef<'_, Raster<GPU>>, scene: &mut VelloSceneBuilder, transform: DAffine2, render_params: &RenderParams) {
|
fn render_raster_gpu_item_to_vello(item: ItemRef<'_, Raster<GPU>>, scene: &mut VelloSceneBuilder, transform: DAffine2, render_params: &RenderParams) {
|
||||||
let Some(raster) = item.element() else { return };
|
let Some(texture) = item.element().and_then(|raster| raster.texture()) else { return };
|
||||||
let blend_mode_attr: BlendMode = item.attribute_cloned_or_default(ATTR_BLEND_MODE);
|
let blend_mode_attr: BlendMode = item.attribute_cloned_or_default(ATTR_BLEND_MODE);
|
||||||
let opacity_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY, 1.);
|
let opacity_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY, 1.);
|
||||||
let opacity_fill_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY_FILL, 1.);
|
let opacity_fill_attr: f64 = item.attribute_cloned_or(ATTR_OPACITY_FILL, 1.);
|
||||||
@@ -2610,12 +2703,13 @@ fn render_raster_gpu_item_to_vello(item: ItemRef<'_, Raster<GPU>>, scene: &mut V
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let width = raster.data().width();
|
let width = texture.width();
|
||||||
let height = raster.data().height();
|
let height = texture.height();
|
||||||
|
|
||||||
let sampler = peniko::ImageSampler::new().with_extend(peniko::Extend::Pad);
|
let sampler = peniko::ImageSampler::new().with_extend(peniko::Extend::Pad);
|
||||||
let image_transform = transform * transform_attribute * DAffine2::from_scale(1. / DVec2::new(width as f64, height as f64));
|
let coverage = item.element().map_or(DAffine2::IDENTITY, Storage::coverage);
|
||||||
scene.draw_texture(raster.texture.clone(), sampler, kurbo::Affine::new(image_transform.to_cols_array()));
|
let image_transform = transform * transform_attribute * coverage * DAffine2::from_scale(1. / DVec2::new(width as f64, height as f64));
|
||||||
|
scene.draw_texture(texture.clone(), sampler, kurbo::Affine::new(image_transform.to_cols_array()));
|
||||||
|
|
||||||
if layer {
|
if layer {
|
||||||
scene.pop_layer()
|
scene.pop_layer()
|
||||||
|
|||||||
@@ -32,3 +32,4 @@ log = { workspace = true }
|
|||||||
web-sys = { workspace = true }
|
web-sys = { workspace = true }
|
||||||
vello_gpu = { workspace = true }
|
vello_gpu = { workspace = true }
|
||||||
bytemuck = { workspace = true }
|
bytemuck = { workspace = true }
|
||||||
|
half = { workspace = true }
|
||||||
@@ -6,7 +6,6 @@ mod texture_cache;
|
|||||||
pub mod texture_conversion;
|
pub mod texture_conversion;
|
||||||
mod vello_render;
|
mod vello_render;
|
||||||
|
|
||||||
use crate::shader_runtime::ShaderRuntime;
|
|
||||||
use crate::texture_cache::TextureCache;
|
use crate::texture_cache::TextureCache;
|
||||||
use crate::vello_render::VelloRenderer;
|
use crate::vello_render::VelloRenderer;
|
||||||
pub use crate::vello_render::{MAX_LAYER_RENDER_SIZE, VelloCanvas};
|
pub use crate::vello_render::{MAX_LAYER_RENDER_SIZE, VelloCanvas};
|
||||||
@@ -26,6 +25,7 @@ pub use raster_types::Texture;
|
|||||||
pub use rendering::vello_scene_builder::VelloSceneBuilder;
|
pub use rendering::vello_scene_builder::VelloSceneBuilder;
|
||||||
pub use wgpu::Backends as WgpuBackends;
|
pub use wgpu::Backends as WgpuBackends;
|
||||||
pub use wgpu::Features as WgpuFeatures;
|
pub use wgpu::Features as WgpuFeatures;
|
||||||
|
pub use wgpu::TextureFormat as WgpuTextureFormat;
|
||||||
pub use wgpu_sync::CurrentSurfaceTexture as WgpuCurrentSurfaceTexture;
|
pub use wgpu_sync::CurrentSurfaceTexture as WgpuCurrentSurfaceTexture;
|
||||||
pub use wgpu_sync::Instance as WgpuInstance;
|
pub use wgpu_sync::Instance as WgpuInstance;
|
||||||
pub use wgpu_sync::Queue as WgpuQueue;
|
pub use wgpu_sync::Queue as WgpuQueue;
|
||||||
@@ -36,6 +36,11 @@ const TEXTURE_CACHE_SIZE: u64 = 1024 * 1024 * 1024; // 1GB
|
|||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
const TEXTURE_CACHE_SIZE: u64 = 512 * 1024 * 1024; // 512MB
|
const TEXTURE_CACHE_SIZE: u64 = 512 * 1024 * 1024; // 512MB
|
||||||
|
|
||||||
|
/// The preferred format of raster textures, holding linear-light straight-alpha values.
|
||||||
|
pub const RASTER_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba32Float;
|
||||||
|
/// The raster texture format on adapters that can't render to [`RASTER_FORMAT`], or when `GRAPHITE_RASTER_FORMAT=f16` forces it.
|
||||||
|
pub const FALLBACK_RASTER_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba16Float;
|
||||||
|
|
||||||
#[derive(dyn_any::DynAny, Clone)]
|
#[derive(dyn_any::DynAny, Clone)]
|
||||||
pub struct WgpuExecutor {
|
pub struct WgpuExecutor {
|
||||||
inner: Arc<WgpuExecutorInner>,
|
inner: Arc<WgpuExecutorInner>,
|
||||||
@@ -45,16 +50,21 @@ impl WgpuExecutor {
|
|||||||
pub fn context(&self) -> &WgpuContext {
|
pub fn context(&self) -> &WgpuContext {
|
||||||
&self.inner.context
|
&self.inner.context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The format of every raster texture this executor creates, either [`RASTER_FORMAT`] or [`FALLBACK_RASTER_FORMAT`].
|
||||||
|
pub fn raster_format(&self) -> wgpu::TextureFormat {
|
||||||
|
self.inner.raster_format
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(dyn_any::DynAny)]
|
#[derive(dyn_any::DynAny)]
|
||||||
pub struct WgpuExecutorInner {
|
pub struct WgpuExecutorInner {
|
||||||
context: WgpuContext,
|
context: WgpuContext,
|
||||||
texture_cache: std::sync::Mutex<TextureCache>,
|
texture_cache: std::sync::Mutex<TextureCache>,
|
||||||
|
raster_format: wgpu::TextureFormat,
|
||||||
vello_renderer: VelloRenderer,
|
vello_renderer: VelloRenderer,
|
||||||
/// The canvas the node graph renders documents on.
|
/// The canvas the node graph renders documents on.
|
||||||
document_canvas: Mutex<VelloCanvas>,
|
document_canvas: Mutex<VelloCanvas>,
|
||||||
shader_runtime: ShaderRuntime,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for WgpuExecutor {
|
impl std::fmt::Debug for WgpuExecutor {
|
||||||
@@ -73,12 +83,21 @@ impl WgpuExecutor {
|
|||||||
/// Renders the document scene `draw` draws, with its content placed by `view`, into a new texture of `size` with straight alpha.
|
/// Renders the document scene `draw` draws, with its content placed by `view`, into a new texture of `size` with straight alpha.
|
||||||
/// A render with more content than Vello GPU can hold calls `draw` again for each part it splits into.
|
/// A render with more content than Vello GPU can hold calls `draw` again for each part it splits into.
|
||||||
pub fn render_vello(&self, size: UVec2, view: DAffine2, draw: &mut dyn FnMut(&mut VelloSceneBuilder)) -> Result<Texture> {
|
pub fn render_vello(&self, size: UVec2, view: DAffine2, draw: &mut dyn FnMut(&mut VelloSceneBuilder)) -> Result<Texture> {
|
||||||
|
self.render_vello_with_format(size, view, draw, wgpu::TextureFormat::Rgba8Unorm)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Renders like [`Self::render_vello`], but into a new texture in [`Self::raster_format`] holding linear-light values, as a GPU raster's.
|
||||||
|
pub fn render_vello_raster(&self, size: UVec2, view: DAffine2, draw: &mut dyn FnMut(&mut VelloSceneBuilder)) -> Result<Texture> {
|
||||||
|
self.render_vello_with_format(size, view, draw, self.raster_format())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_vello_with_format(&self, size: UVec2, view: DAffine2, draw: &mut dyn FnMut(&mut VelloSceneBuilder), format: wgpu::TextureFormat) -> Result<Texture> {
|
||||||
let limit = self.context().device.limits().max_texture_dimension_2d;
|
let limit = self.context().device.limits().max_texture_dimension_2d;
|
||||||
if size.x > limit || size.y > limit {
|
if size.x > limit || size.y > limit {
|
||||||
anyhow::bail!("Render size {size} exceeds the GPU's texture size limit of {limit}");
|
anyhow::bail!("Render size {size} exceeds the GPU's texture size limit of {limit}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let texture = self.request_texture(size);
|
let texture = self.request_texture_with_format(size, format);
|
||||||
let view = vello_gpu::kurbo::Affine::new(view.to_cols_array());
|
let view = vello_gpu::kurbo::Affine::new(view.to_cols_array());
|
||||||
|
|
||||||
let mut canvas = self.inner.document_canvas.lock().unwrap_or_else(PoisonError::into_inner);
|
let mut canvas = self.inner.document_canvas.lock().unwrap_or_else(PoisonError::into_inner);
|
||||||
@@ -171,20 +190,32 @@ impl WgpuExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_context(context: WgpuContext) -> Option<Self> {
|
pub fn with_context(context: WgpuContext) -> Option<Self> {
|
||||||
let vello_renderer = VelloRenderer::new(&context.device);
|
let raster_format = choose_raster_format(&context.adapter);
|
||||||
|
let vello_renderer = VelloRenderer::new(&context.device, raster_format);
|
||||||
|
|
||||||
let texture_cache = TextureCache::new(TEXTURE_CACHE_SIZE);
|
let texture_cache = TextureCache::new(TEXTURE_CACHE_SIZE);
|
||||||
|
|
||||||
let shader_runtime = ShaderRuntime::default();
|
|
||||||
|
|
||||||
Some(Self {
|
Some(Self {
|
||||||
inner: Arc::new(WgpuExecutorInner {
|
inner: Arc::new(WgpuExecutorInner {
|
||||||
context,
|
context,
|
||||||
texture_cache: texture_cache.into(),
|
texture_cache: texture_cache.into(),
|
||||||
|
raster_format,
|
||||||
vello_renderer,
|
vello_renderer,
|
||||||
document_canvas: Mutex::default(),
|
document_canvas: Mutex::default(),
|
||||||
shader_runtime,
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn choose_raster_format(adapter: &wgpu::Adapter) -> wgpu::TextureFormat {
|
||||||
|
if std::env::var("GRAPHITE_RASTER_FORMAT").is_ok_and(|format| format == "f16") {
|
||||||
|
return FALLBACK_RASTER_FORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if adapter.get_texture_format_features(RASTER_FORMAT).allowed_usages.contains(wgpu::TextureUsages::RENDER_ATTACHMENT) {
|
||||||
|
RASTER_FORMAT
|
||||||
|
} else {
|
||||||
|
log::warn!("The GPU can't render to {RASTER_FORMAT:?}, so rasters fall back to {FALLBACK_RASTER_FORMAT:?}");
|
||||||
|
FALLBACK_RASTER_FORMAT
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,17 @@ impl PipelineCache {
|
|||||||
.unwrap_or_else(|| panic!("PipelineCache type mismatch: run::<{}>() but init used a different pipeline type", std::any::type_name::<P>(),));
|
.unwrap_or_else(|| panic!("PipelineCache type mismatch: run::<{}>() but init used a different pipeline type", std::any::type_name::<P>(),));
|
||||||
pipeline.run(executor, args)
|
pipeline.run(executor, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The executor the cache was initialized with, or `None` when no GPU is available.
|
||||||
|
pub fn executor(&self) -> Option<&WgpuExecutor> {
|
||||||
|
self.executor.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Runs the pipeline, or returns `None` when it was never initialized because no GPU is available.
|
||||||
|
pub fn try_run<P: Pipeline>(&self, args: &P::Args<'_>) -> Option<P::Out> {
|
||||||
|
self.executor.get()?;
|
||||||
|
Some(self.run::<P>(args))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for PipelineCache {
|
impl std::fmt::Debug for PipelineCache {
|
||||||
|
|||||||
@@ -1,10 +1 @@
|
|||||||
use crate::shader_runtime::per_pixel_adjust_runtime::PerPixelAdjustShaderRuntime;
|
pub mod raster_kernel_runtime;
|
||||||
|
|
||||||
pub mod per_pixel_adjust_runtime;
|
|
||||||
|
|
||||||
pub const FULLSCREEN_VERTEX_SHADER_NAME: &str = "fullscreen_vertex_fullscreen_vertex";
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct ShaderRuntime {
|
|
||||||
per_pixel_adjust: PerPixelAdjustShaderRuntime,
|
|
||||||
}
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
use crate::shader_runtime::FULLSCREEN_VERTEX_SHADER_NAME;
|
|
||||||
use crate::{Buffer, WgpuContext, WgpuExecutor};
|
|
||||||
use core_types::list::{Item, List};
|
|
||||||
use core_types::shaders::buffer_struct::BufferStruct;
|
|
||||||
use glam::UVec2;
|
|
||||||
use raster_types::{GPU, Raster};
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::sync::Mutex;
|
|
||||||
use wgpu::util::BufferInitDescriptor;
|
|
||||||
use wgpu::{
|
|
||||||
BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BufferBinding, BufferBindingType, BufferUsages, ColorTargetState, Face,
|
|
||||||
FragmentState, FrontFace, LoadOp, Operations, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor,
|
|
||||||
ShaderModuleDescriptor, ShaderSource, ShaderStages, StoreOp, TextureFormat, TextureSampleType, TextureViewDescriptor, TextureViewDimension, VertexState,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct PerPixelAdjustShaderRuntime {
|
|
||||||
// TODO: PerPixelAdjustGraphicsPipeline already contains the key as `name`
|
|
||||||
pipeline_cache: Mutex<HashMap<String, PerPixelAdjustGraphicsPipeline>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for PerPixelAdjustShaderRuntime {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PerPixelAdjustShaderRuntime {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
pipeline_cache: Mutex::new(HashMap::new()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WgpuExecutor {
|
|
||||||
pub fn run_per_pixel_adjust<T: BufferStruct>(&self, shaders: &Shaders<'_>, textures: List<Raster<GPU>>, args: Option<&T>) -> List<Raster<GPU>> {
|
|
||||||
let mut cache = self.inner.shader_runtime.per_pixel_adjust.pipeline_cache.lock().unwrap();
|
|
||||||
let pipeline = cache
|
|
||||||
.entry(shaders.fragment_shader_name.to_owned())
|
|
||||||
.or_insert_with(|| PerPixelAdjustGraphicsPipeline::new(self.context(), shaders));
|
|
||||||
|
|
||||||
let arg_buffer = args.map(|args| {
|
|
||||||
self.create_buffer_init(&BufferInitDescriptor {
|
|
||||||
label: Some(&format!("{} arg buffer", pipeline.name.as_str())),
|
|
||||||
usage: BufferUsages::STORAGE,
|
|
||||||
contents: bytemuck::bytes_of(&T::write(*args)),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
pipeline.dispatch(self, textures, arg_buffer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Shaders<'a> {
|
|
||||||
pub wgsl_shader: &'a str,
|
|
||||||
pub fragment_shader_name: &'a str,
|
|
||||||
pub has_uniform: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PerPixelAdjustGraphicsPipeline {
|
|
||||||
name: String,
|
|
||||||
has_uniform: bool,
|
|
||||||
pipeline: wgpu::RenderPipeline,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PerPixelAdjustGraphicsPipeline {
|
|
||||||
pub fn new(context: &WgpuContext, info: &Shaders) -> Self {
|
|
||||||
let device = &context.device;
|
|
||||||
let name = info.fragment_shader_name.to_owned();
|
|
||||||
|
|
||||||
let fragment_name = &name;
|
|
||||||
let fragment_name = &fragment_name[(fragment_name.find("::").unwrap() + 2)..];
|
|
||||||
let fragment_name = fragment_name.replace("::", "_");
|
|
||||||
let shader_module = device.create_shader_module(ShaderModuleDescriptor {
|
|
||||||
label: Some(&format!("PerPixelAdjust {name} wgsl shader")),
|
|
||||||
source: ShaderSource::Wgsl(Cow::Borrowed(info.wgsl_shader)),
|
|
||||||
});
|
|
||||||
|
|
||||||
let entries: &[_] = if info.has_uniform {
|
|
||||||
&[
|
|
||||||
BindGroupLayoutEntry {
|
|
||||||
binding: 0,
|
|
||||||
visibility: ShaderStages::FRAGMENT,
|
|
||||||
ty: BindingType::Buffer {
|
|
||||||
ty: BufferBindingType::Storage { read_only: true },
|
|
||||||
has_dynamic_offset: false,
|
|
||||||
min_binding_size: None,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
BindGroupLayoutEntry {
|
|
||||||
binding: 1,
|
|
||||||
visibility: ShaderStages::FRAGMENT,
|
|
||||||
ty: BindingType::Texture {
|
|
||||||
sample_type: TextureSampleType::Float { filterable: false },
|
|
||||||
view_dimension: TextureViewDimension::D2,
|
|
||||||
multisampled: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
&[BindGroupLayoutEntry {
|
|
||||||
binding: 0,
|
|
||||||
visibility: ShaderStages::FRAGMENT,
|
|
||||||
ty: BindingType::Texture {
|
|
||||||
sample_type: TextureSampleType::Float { filterable: false },
|
|
||||||
view_dimension: TextureViewDimension::D2,
|
|
||||||
multisampled: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
|
|
||||||
label: Some(&format!("PerPixelAdjust {name} PipelineLayout")),
|
|
||||||
bind_group_layouts: &[Some(&device.create_bind_group_layout(&BindGroupLayoutDescriptor {
|
|
||||||
label: Some(&format!("PerPixelAdjust {name} BindGroupLayout 0")),
|
|
||||||
entries,
|
|
||||||
}))],
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline = device.create_render_pipeline(&RenderPipelineDescriptor {
|
|
||||||
label: Some(&format!("PerPixelAdjust {name} Pipeline")),
|
|
||||||
layout: Some(&pipeline_layout),
|
|
||||||
vertex: VertexState {
|
|
||||||
module: &shader_module,
|
|
||||||
entry_point: Some(FULLSCREEN_VERTEX_SHADER_NAME),
|
|
||||||
compilation_options: Default::default(),
|
|
||||||
buffers: &[],
|
|
||||||
},
|
|
||||||
primitive: PrimitiveState {
|
|
||||||
topology: PrimitiveTopology::TriangleList,
|
|
||||||
strip_index_format: None,
|
|
||||||
front_face: FrontFace::Ccw,
|
|
||||||
cull_mode: Some(Face::Back),
|
|
||||||
unclipped_depth: false,
|
|
||||||
polygon_mode: PolygonMode::Fill,
|
|
||||||
conservative: false,
|
|
||||||
},
|
|
||||||
depth_stencil: None,
|
|
||||||
multisample: Default::default(),
|
|
||||||
multiview_mask: None,
|
|
||||||
fragment: Some(FragmentState {
|
|
||||||
module: &shader_module,
|
|
||||||
entry_point: Some(&fragment_name),
|
|
||||||
compilation_options: Default::default(),
|
|
||||||
targets: &[Some(ColorTargetState {
|
|
||||||
format: TextureFormat::Rgba8UnormSrgb,
|
|
||||||
blend: None,
|
|
||||||
write_mask: Default::default(),
|
|
||||||
})],
|
|
||||||
}),
|
|
||||||
cache: None,
|
|
||||||
});
|
|
||||||
Self {
|
|
||||||
pipeline,
|
|
||||||
name,
|
|
||||||
has_uniform: info.has_uniform,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dispatch(&self, executor: &WgpuExecutor, textures: List<Raster<GPU>>, arg_buffer: Option<Buffer>) -> List<Raster<GPU>> {
|
|
||||||
assert_eq!(self.has_uniform, arg_buffer.is_some());
|
|
||||||
let device = &executor.context().device;
|
|
||||||
let name = self.name.as_str();
|
|
||||||
|
|
||||||
let mut cmd = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
|
||||||
label: Some(&format!("{name} cmd encoder")),
|
|
||||||
});
|
|
||||||
let out = (0..textures.len())
|
|
||||||
.map(|index| {
|
|
||||||
let element = textures.element(index).unwrap();
|
|
||||||
let tex_in = &element.texture;
|
|
||||||
let view_in = tex_in.create_view(&TextureViewDescriptor::default());
|
|
||||||
let format = tex_in.format();
|
|
||||||
|
|
||||||
let entries: &[_] = if let Some(arg_buffer) = arg_buffer.as_ref() {
|
|
||||||
&[
|
|
||||||
BindGroupEntry {
|
|
||||||
binding: 0,
|
|
||||||
resource: BindingResource::Buffer(BufferBinding {
|
|
||||||
buffer: arg_buffer,
|
|
||||||
offset: 0,
|
|
||||||
size: None,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
BindGroupEntry {
|
|
||||||
binding: 1,
|
|
||||||
resource: BindingResource::TextureView(&view_in),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
&[BindGroupEntry {
|
|
||||||
binding: 0,
|
|
||||||
resource: BindingResource::TextureView(&view_in),
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
let bind_group = device.create_bind_group(&BindGroupDescriptor {
|
|
||||||
label: Some(&format!("{name} bind group")),
|
|
||||||
// `get_bind_group_layout` allocates unnecessary memory, we could create it manually to not do that
|
|
||||||
layout: &self.pipeline.get_bind_group_layout(0),
|
|
||||||
entries,
|
|
||||||
});
|
|
||||||
|
|
||||||
let tex_out = executor.request_texture_with_format(UVec2::new(tex_in.width(), tex_in.height()), format);
|
|
||||||
|
|
||||||
let view_out = tex_out.create_view(&TextureViewDescriptor::default());
|
|
||||||
let mut rp = cmd.begin_render_pass(&RenderPassDescriptor {
|
|
||||||
label: Some(&format!("{name} render pipeline")),
|
|
||||||
color_attachments: &[Some(RenderPassColorAttachment {
|
|
||||||
view: &view_out,
|
|
||||||
resolve_target: None,
|
|
||||||
ops: Operations {
|
|
||||||
// should be dont_care but wgpu doesn't expose that
|
|
||||||
load: LoadOp::Clear(wgpu::Color::BLACK),
|
|
||||||
store: StoreOp::Store,
|
|
||||||
},
|
|
||||||
depth_slice: None,
|
|
||||||
})],
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
rp.set_pipeline(&self.pipeline);
|
|
||||||
rp.set_bind_group(0, Some(&bind_group), &[]);
|
|
||||||
rp.draw(0..3, 0..1);
|
|
||||||
|
|
||||||
let attributes = textures.clone_item_attributes(index);
|
|
||||||
Item::from_parts(Raster::new_gpu(tex_out), attributes)
|
|
||||||
})
|
|
||||||
.collect::<List<_>>();
|
|
||||||
executor.context().queue.submit([cmd.finish()]);
|
|
||||||
out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@vertex
|
||||||
|
fn vertex(@builtin(vertex_index) index: u32) -> @builtin(position) vec4<f32> {
|
||||||
|
let corner = vec2<f32>(f32((index << 1u) & 2u), f32(index & 2u));
|
||||||
|
return vec4<f32>(corner * 2. - 1., 0., 1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
@fragment
|
||||||
|
fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
|
return kernel(vec2<i32>(position.xy));
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
@group(0) @binding(BINDING) var INPUT_texture: texture_2d<f32>;
|
||||||
|
|
||||||
|
fn INPUT_size() -> vec2<i32> {
|
||||||
|
return vec2<i32>(kernel_frame[PLACEMENT].zw);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn INPUT_load(coord: vec2<i32>) -> vec4<f32> {
|
||||||
|
return textureLoad(INPUT_texture, clamp(coord, vec2<i32>(0), INPUT_size() - 1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn INPUT_premultiplied(texel: vec2<i32>) -> vec4<f32> {
|
||||||
|
if any(texel < vec2<i32>(0)) || any(texel >= INPUT_size()) {
|
||||||
|
return vec4<f32>(0.);
|
||||||
|
}
|
||||||
|
let color = textureLoad(INPUT_texture, texel, 0);
|
||||||
|
return vec4<f32>(color.rgb * color.a, color.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn INPUT_at(coord: vec2<i32>) -> vec4<f32> {
|
||||||
|
let axes = kernel_frame[AXES];
|
||||||
|
let center = vec2<f32>(coord) + 0.5;
|
||||||
|
let texel = axes.xy * center.x + axes.zw * center.y + kernel_frame[PLACEMENT].xy - 0.5;
|
||||||
|
let base = floor(texel);
|
||||||
|
let t = texel - base;
|
||||||
|
let corner = vec2<i32>(base);
|
||||||
|
let top = mix(INPUT_premultiplied(corner), INPUT_premultiplied(corner + vec2<i32>(1, 0)), t.x);
|
||||||
|
let bottom = mix(INPUT_premultiplied(corner + vec2<i32>(0, 1)), INPUT_premultiplied(corner + vec2<i32>(1, 1)), t.x);
|
||||||
|
let premultiplied = mix(top, bottom, t.y);
|
||||||
|
if premultiplied.a <= 0. {
|
||||||
|
return vec4<f32>(0.);
|
||||||
|
}
|
||||||
|
return vec4<f32>(premultiplied.rgb / premultiplied.a, premultiplied.a);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fn INPUT_sample(texel: vec2<f32>) -> vec4<f32> {
|
||||||
|
return textureSampleLevel(INPUT_texture, raster_kernel_sampler, texel / vec2<f32>(INPUT_size()), 0.);
|
||||||
|
}
|
||||||
@@ -0,0 +1,390 @@
|
|||||||
|
use crate::{WgpuExecutor, WgpuPipeline};
|
||||||
|
use core_types::Color;
|
||||||
|
use glam::{DAffine2, UVec2};
|
||||||
|
use raster_types::{GPU, Raster};
|
||||||
|
use std::any::TypeId;
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::collections::{HashMap, VecDeque};
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
use std::sync::Mutex;
|
||||||
|
use wgpu::util::BufferInitDescriptor;
|
||||||
|
|
||||||
|
/// An input raster of a kernel, with the affine mapping output pixel coordinates to the input's texel coordinates.
|
||||||
|
pub struct RasterKernelInput<'a> {
|
||||||
|
pub raster: &'a Raster<GPU>,
|
||||||
|
pub output_to_texel: DAffine2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A lookup table of a kernel, bound as an `Rgba32Float` texture after its inputs.
|
||||||
|
pub enum RasterKernelLookup<'a> {
|
||||||
|
/// A `width x 1` 2D texture of at most 4096 entries.
|
||||||
|
Lut1d(&'a [Color]),
|
||||||
|
/// A `size x size x size` 3D texture, its entries ordered with x fastest, then y, then z.
|
||||||
|
Lut3d { size: u32, data: &'a [Color] },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RasterKernelLookup<'_> {
|
||||||
|
fn data(&self) -> &[Color] {
|
||||||
|
match self {
|
||||||
|
Self::Lut1d(data) | Self::Lut3d { data, .. } => data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extent(&self) -> wgpu::Extent3d {
|
||||||
|
match self {
|
||||||
|
Self::Lut1d(data) => wgpu::Extent3d {
|
||||||
|
width: data.len() as u32,
|
||||||
|
height: 1,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
Self::Lut3d { size, .. } => wgpu::Extent3d {
|
||||||
|
width: *size,
|
||||||
|
height: *size,
|
||||||
|
depth_or_array_layers: *size,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dimension(&self) -> (wgpu::TextureDimension, wgpu::TextureViewDimension) {
|
||||||
|
match self {
|
||||||
|
Self::Lut1d(_) => (wgpu::TextureDimension::D2, wgpu::TextureViewDimension::D2),
|
||||||
|
Self::Lut3d { .. } => (wgpu::TextureDimension::D3, wgpu::TextureViewDimension::D3),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn content_hash(&self) -> u64 {
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
let extent = self.extent();
|
||||||
|
(extent.width, extent.height, extent.depth_or_array_layers, matches!(self, Self::Lut3d { .. })).hash(&mut hasher);
|
||||||
|
bytemuck::cast_slice::<Color, u8>(self.data()).hash(&mut hasher);
|
||||||
|
hasher.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One run of a raster kernel, writing a texture of `output_size` in `output_format`.
|
||||||
|
///
|
||||||
|
/// `wgsl` must define `fn kernel(coord: vec2<i32>) -> vec4<f32>`, and reads its parameters from `uniform_params`, the 32-bit `params` packed into `vec4<u32>` slots.
|
||||||
|
/// It may call `output_size()` and, for each input `i`, `input_i_size()`, `input_i_load(coord)` reading the input's own texel clamped to its edge,
|
||||||
|
/// and `input_i_at(coord)` sampling the input bilinearly where the output pixel's center lies, transparent beyond the input.
|
||||||
|
/// With `filtered`, it may also call `input_i_sample(texel)`, sampling the input bilinearly at texel coordinates, whose texel centers lie at +0.5, clamped to its edge,
|
||||||
|
/// which requires every input to be in a filterable format such as `Rgba16Float` rather than [`crate::RASTER_FORMAT`].
|
||||||
|
/// It declares the texture of each of the `lookups` itself, the `k`th at binding `2 + inputs + k`.
|
||||||
|
/// An empty input reads as transparent with a size of zero, and an empty `output_size` gives the empty raster without running the kernel.
|
||||||
|
/// Every run of the same `kernel` must have the same number of inputs, the same kinds of lookups, and the same `filtered`.
|
||||||
|
pub struct RasterKernelArgs<'a> {
|
||||||
|
pub kernel: TypeId,
|
||||||
|
pub label: &'static str,
|
||||||
|
pub wgsl: fn() -> String,
|
||||||
|
pub params: Vec<u32>,
|
||||||
|
pub inputs: Vec<RasterKernelInput<'a>>,
|
||||||
|
pub lookups: Vec<RasterKernelLookup<'a>>,
|
||||||
|
pub filtered: bool,
|
||||||
|
pub output_size: UVec2,
|
||||||
|
pub output_format: wgpu::TextureFormat,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct KernelPipeline {
|
||||||
|
bind_group_layout: wgpu::BindGroupLayout,
|
||||||
|
pipeline: wgpu::RenderPipeline,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The number of lookup textures kept uploaded, the most recently used first, so a kernel run again with the same table skips the upload.
|
||||||
|
const LOOKUP_CACHE_SIZE: usize = 16;
|
||||||
|
|
||||||
|
pub struct RasterKernelRuntime {
|
||||||
|
pipelines: Mutex<HashMap<(TypeId, wgpu::TextureFormat), KernelPipeline>>,
|
||||||
|
lookups: Mutex<VecDeque<(u64, wgpu::Texture)>>,
|
||||||
|
sampler: wgpu::Sampler,
|
||||||
|
empty_input: wgpu::Texture,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RasterKernelRuntime {
|
||||||
|
fn lookup_texture(&self, executor: &WgpuExecutor, lookup: &RasterKernelLookup<'_>) -> wgpu::Texture {
|
||||||
|
let hash = lookup.content_hash();
|
||||||
|
let mut lookups = self.lookups.lock().unwrap();
|
||||||
|
if let Some(index) = lookups.iter().position(|(cached, _)| *cached == hash) {
|
||||||
|
let entry = lookups.remove(index).unwrap();
|
||||||
|
let texture = entry.1.clone();
|
||||||
|
lookups.push_front(entry);
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
let size = lookup.extent();
|
||||||
|
let texture = executor.context().device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some("raster_kernel_lookup"),
|
||||||
|
size,
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: lookup.dimension().0,
|
||||||
|
format: wgpu::TextureFormat::Rgba32Float,
|
||||||
|
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
||||||
|
view_formats: &[],
|
||||||
|
});
|
||||||
|
executor.context().queue.write_texture(
|
||||||
|
texture.as_image_copy(),
|
||||||
|
bytemuck::cast_slice(lookup.data()),
|
||||||
|
wgpu::TexelCopyBufferLayout {
|
||||||
|
offset: 0,
|
||||||
|
bytes_per_row: Some(16 * size.width),
|
||||||
|
rows_per_image: Some(size.height),
|
||||||
|
},
|
||||||
|
size,
|
||||||
|
);
|
||||||
|
lookups.push_front((hash, texture.clone()));
|
||||||
|
lookups.truncate(LOOKUP_CACHE_SIZE);
|
||||||
|
texture
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WgpuPipeline for RasterKernelRuntime {
|
||||||
|
type Args<'a> = RasterKernelArgs<'a>;
|
||||||
|
type Out = Raster<GPU>;
|
||||||
|
|
||||||
|
fn create(executor: &WgpuExecutor) -> Self {
|
||||||
|
let sampler = executor.context().device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
label: Some("raster_kernel_sampler"),
|
||||||
|
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||||
|
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||||
|
mag_filter: wgpu::FilterMode::Linear,
|
||||||
|
min_filter: wgpu::FilterMode::Linear,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
let empty_input = executor.context().device.create_texture(&wgpu::TextureDescriptor {
|
||||||
|
label: Some("raster_kernel_empty_input"),
|
||||||
|
size: wgpu::Extent3d {
|
||||||
|
width: 1,
|
||||||
|
height: 1,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: wgpu::TextureFormat::Rgba16Float,
|
||||||
|
usage: wgpu::TextureUsages::TEXTURE_BINDING,
|
||||||
|
view_formats: &[],
|
||||||
|
});
|
||||||
|
Self {
|
||||||
|
pipelines: Mutex::default(),
|
||||||
|
lookups: Mutex::default(),
|
||||||
|
sampler,
|
||||||
|
empty_input,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, executor: &WgpuExecutor, args: &RasterKernelArgs<'_>) -> Raster<GPU> {
|
||||||
|
if args.output_size.x == 0 || args.output_size.y == 0 {
|
||||||
|
return Raster::default();
|
||||||
|
}
|
||||||
|
|
||||||
|
let device = &executor.context().device;
|
||||||
|
let param_slots = slots(args.params.len());
|
||||||
|
|
||||||
|
let mut pipelines = self.pipelines.lock().unwrap();
|
||||||
|
let kernel_pipeline = pipelines.entry((args.kernel, args.output_format)).or_insert_with(|| create_pipeline(device, args, param_slots));
|
||||||
|
|
||||||
|
let mut params = args.params.clone();
|
||||||
|
params.resize(param_slots * 4, 0);
|
||||||
|
let params = executor.create_buffer_init(&BufferInitDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
contents: bytemuck::cast_slice(¶ms),
|
||||||
|
usage: wgpu::BufferUsages::UNIFORM,
|
||||||
|
});
|
||||||
|
let frame = executor.create_buffer_init(&BufferInitDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
contents: bytemuck::cast_slice(&frame_data(args)),
|
||||||
|
usage: wgpu::BufferUsages::UNIFORM,
|
||||||
|
});
|
||||||
|
|
||||||
|
let input_views = args
|
||||||
|
.inputs
|
||||||
|
.iter()
|
||||||
|
.map(|input| input.raster.texture().map_or(&self.empty_input, |texture| texture).create_view(&wgpu::TextureViewDescriptor::default()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let lookup_views = args
|
||||||
|
.lookups
|
||||||
|
.iter()
|
||||||
|
.map(|lookup| self.lookup_texture(executor, lookup).create_view(&wgpu::TextureViewDescriptor::default()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let mut entries = vec![
|
||||||
|
wgpu::BindGroupEntry {
|
||||||
|
binding: 0,
|
||||||
|
resource: params.as_entire_binding(),
|
||||||
|
},
|
||||||
|
wgpu::BindGroupEntry {
|
||||||
|
binding: 1,
|
||||||
|
resource: frame.as_entire_binding(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
entries.extend(input_views.iter().enumerate().map(|(index, view)| wgpu::BindGroupEntry {
|
||||||
|
binding: 2 + index as u32,
|
||||||
|
resource: wgpu::BindingResource::TextureView(view),
|
||||||
|
}));
|
||||||
|
entries.extend(lookup_views.iter().enumerate().map(|(index, view)| wgpu::BindGroupEntry {
|
||||||
|
binding: (2 + args.inputs.len() + index) as u32,
|
||||||
|
resource: wgpu::BindingResource::TextureView(view),
|
||||||
|
}));
|
||||||
|
if args.filtered {
|
||||||
|
entries.push(wgpu::BindGroupEntry {
|
||||||
|
binding: sampler_binding(args),
|
||||||
|
resource: wgpu::BindingResource::Sampler(&self.sampler),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
layout: &kernel_pipeline.bind_group_layout,
|
||||||
|
entries: &entries,
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = executor.request_texture_with_format(args.output_size, args.output_format);
|
||||||
|
let output_view = output.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
||||||
|
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some(args.label) });
|
||||||
|
{
|
||||||
|
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
|
view: &output_view,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
},
|
||||||
|
depth_slice: None,
|
||||||
|
})],
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
pass.set_pipeline(&kernel_pipeline.pipeline);
|
||||||
|
pass.set_bind_group(0, &bind_group, &[]);
|
||||||
|
pass.draw(0..3, 0..1);
|
||||||
|
}
|
||||||
|
executor.context().queue.submit([encoder.finish()]);
|
||||||
|
|
||||||
|
Raster::new_gpu(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_pipeline(device: &wgpu::Device, args: &RasterKernelArgs<'_>, param_slots: usize) -> KernelPipeline {
|
||||||
|
let uniform = |binding| wgpu::BindGroupLayoutEntry {
|
||||||
|
binding,
|
||||||
|
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Buffer {
|
||||||
|
ty: wgpu::BufferBindingType::Uniform,
|
||||||
|
has_dynamic_offset: false,
|
||||||
|
min_binding_size: None,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
};
|
||||||
|
let texture = |binding, view_dimension, filterable| wgpu::BindGroupLayoutEntry {
|
||||||
|
binding,
|
||||||
|
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Texture {
|
||||||
|
sample_type: wgpu::TextureSampleType::Float { filterable },
|
||||||
|
view_dimension,
|
||||||
|
multisampled: false,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
};
|
||||||
|
let mut entries = vec![uniform(0), uniform(1)];
|
||||||
|
entries.extend((0..args.inputs.len()).map(|index| texture(2 + index as u32, wgpu::TextureViewDimension::D2, args.filtered)));
|
||||||
|
entries.extend(
|
||||||
|
args.lookups
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(index, lookup)| texture((2 + args.inputs.len() + index) as u32, lookup.dimension().1, false)),
|
||||||
|
);
|
||||||
|
if args.filtered {
|
||||||
|
entries.push(wgpu::BindGroupLayoutEntry {
|
||||||
|
binding: sampler_binding(args),
|
||||||
|
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||||
|
count: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
entries: &entries,
|
||||||
|
});
|
||||||
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
bind_group_layouts: &[Some(&bind_group_layout)],
|
||||||
|
immediate_size: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
let source = format!("{}\n{}\n\n{}", bindings_wgsl(param_slots, args), (args.wgsl)(), include_str!("raster_kernel_entry.wgsl"));
|
||||||
|
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
source: wgpu::ShaderSource::Wgsl(source.into()),
|
||||||
|
});
|
||||||
|
|
||||||
|
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
|
label: Some(args.label),
|
||||||
|
layout: Some(&pipeline_layout),
|
||||||
|
vertex: wgpu::VertexState {
|
||||||
|
module: &module,
|
||||||
|
entry_point: Some("vertex"),
|
||||||
|
compilation_options: Default::default(),
|
||||||
|
buffers: &[],
|
||||||
|
},
|
||||||
|
fragment: Some(wgpu::FragmentState {
|
||||||
|
module: &module,
|
||||||
|
entry_point: Some("fragment"),
|
||||||
|
compilation_options: Default::default(),
|
||||||
|
targets: &[Some(args.output_format.into())],
|
||||||
|
}),
|
||||||
|
primitive: wgpu::PrimitiveState {
|
||||||
|
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
depth_stencil: None,
|
||||||
|
multisample: wgpu::MultisampleState::default(),
|
||||||
|
multiview_mask: None,
|
||||||
|
cache: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
KernelPipeline { bind_group_layout, pipeline }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The frame uniform: the output size, then for each input its affine's matrix columns, translation, and size.
|
||||||
|
fn frame_data(args: &RasterKernelArgs<'_>) -> Vec<f32> {
|
||||||
|
let mut data = vec![args.output_size.x as f32, args.output_size.y as f32, 0., 0.];
|
||||||
|
for input in &args.inputs {
|
||||||
|
let affine = input.output_to_texel;
|
||||||
|
let size = input.raster.size();
|
||||||
|
data.extend([affine.matrix2.x_axis.x, affine.matrix2.x_axis.y, affine.matrix2.y_axis.x, affine.matrix2.y_axis.y].map(|value| value as f32));
|
||||||
|
data.extend([affine.translation.x as f32, affine.translation.y as f32, size.x as f32, size.y as f32]);
|
||||||
|
}
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The binding of the sampler of a `filtered` kernel's inputs, after its lookups.
|
||||||
|
fn sampler_binding(args: &RasterKernelArgs<'_>) -> u32 {
|
||||||
|
(2 + args.inputs.len() + args.lookups.len()) as u32
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bindings_wgsl(param_slots: usize, args: &RasterKernelArgs<'_>) -> String {
|
||||||
|
let inputs = args.inputs.len();
|
||||||
|
let frame_slots = 1 + 2 * inputs;
|
||||||
|
let mut source = format!(
|
||||||
|
"@group(0) @binding(0) var<uniform> uniform_params: array<vec4<u32>, {param_slots}>;\n@group(0) @binding(1) var<uniform> kernel_frame: array<vec4<f32>, {frame_slots}>;\n\nfn output_size() -> vec2<i32> {{\n\treturn vec2<i32>(kernel_frame[0].xy);\n}}\n"
|
||||||
|
);
|
||||||
|
if args.filtered {
|
||||||
|
source += &format!("\n@group(0) @binding({}) var raster_kernel_sampler: sampler;\n", sampler_binding(args));
|
||||||
|
}
|
||||||
|
for index in 0..inputs {
|
||||||
|
let mut input = include_str!("raster_kernel_input.wgsl").to_string();
|
||||||
|
if args.filtered {
|
||||||
|
input += include_str!("raster_kernel_input_sample.wgsl");
|
||||||
|
}
|
||||||
|
source += &input
|
||||||
|
.replace("INPUT", &format!("input_{index}"))
|
||||||
|
.replace("BINDING", &(2 + index).to_string())
|
||||||
|
.replace("AXES", &(1 + 2 * index).to_string())
|
||||||
|
.replace("PLACEMENT", &(2 + 2 * index).to_string());
|
||||||
|
}
|
||||||
|
source
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `vec4<u32>` slot count holding `params` 32-bit values, at least one since WGSL arrays can't be empty.
|
||||||
|
fn slots(params: usize) -> usize {
|
||||||
|
params.div_ceil(4).max(1)
|
||||||
|
}
|
||||||
@@ -4,21 +4,32 @@ use core_types::color::SRGBA8;
|
|||||||
use core_types::list::{Item, List};
|
use core_types::list::{Item, List};
|
||||||
use core_types::ops::{Convert, ConvertAsync};
|
use core_types::ops::{Convert, ConvertAsync};
|
||||||
use core_types::transform::Footprint;
|
use core_types::transform::Footprint;
|
||||||
|
use half::f16;
|
||||||
use raster_types::Image;
|
use raster_types::Image;
|
||||||
use raster_types::{CPU, GPU, Raster, Texture};
|
use raster_types::{CPU, GPU, Raster, Storage};
|
||||||
use wgpu::{Extent3d, TextureFormat};
|
use wgpu::Extent3d;
|
||||||
|
|
||||||
/// Uploads CPU image data to a GPU texture
|
/// Uploads CPU image data to a GPU texture
|
||||||
fn upload_to_texture(executor: &WgpuExecutor, queue: &wgpu::Queue, image: &Raster<CPU>) -> Texture {
|
fn upload_to_texture(executor: &WgpuExecutor, queue: &wgpu::Queue, image: &Raster<CPU>) -> Raster<GPU> {
|
||||||
let rgba8_data: Vec<SRGBA8> = image.data.iter().map(|x| (*x).into()).collect();
|
if image.is_empty() {
|
||||||
|
return Raster::default();
|
||||||
|
}
|
||||||
|
|
||||||
let texture = executor.request_texture_with_format(glam::UVec2::new(image.width, image.height), TextureFormat::Rgba8UnormSrgb);
|
let format = executor.raster_format();
|
||||||
|
let texture = executor.request_texture_with_format(glam::UVec2::new(image.width, image.height), format);
|
||||||
|
let half_floats: Vec<[f16; 4]>;
|
||||||
|
let (bytes, bytes_per_pixel) = if format == crate::FALLBACK_RASTER_FORMAT {
|
||||||
|
half_floats = image.data.iter().map(|color| color.to_vec4().to_array().map(f16::from_f32)).collect();
|
||||||
|
(bytemuck::cast_slice(half_floats.as_slice()), 8)
|
||||||
|
} else {
|
||||||
|
(bytemuck::cast_slice(image.data.as_slice()), 16)
|
||||||
|
};
|
||||||
queue.write_texture(
|
queue.write_texture(
|
||||||
texture.as_image_copy(),
|
texture.as_image_copy(),
|
||||||
bytemuck::cast_slice(rgba8_data.as_slice()),
|
bytes,
|
||||||
wgpu::TexelCopyBufferLayout {
|
wgpu::TexelCopyBufferLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: Some(4 * image.width),
|
bytes_per_row: Some(bytes_per_pixel * image.width),
|
||||||
rows_per_image: Some(image.height),
|
rows_per_image: Some(image.height),
|
||||||
},
|
},
|
||||||
Extent3d {
|
Extent3d {
|
||||||
@@ -27,29 +38,35 @@ fn upload_to_texture(executor: &WgpuExecutor, queue: &wgpu::Queue, image: &Raste
|
|||||||
depth_or_array_layers: 1,
|
depth_or_array_layers: 1,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
texture
|
Raster::new_gpu(texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a Raster<GPU> texture to Raster<CPU> by downloading the underlying texture data.
|
/// Converts a Raster<GPU> texture to Raster<CPU> by downloading the underlying texture data.
|
||||||
///
|
///
|
||||||
/// Assumptions:
|
/// Assumptions:
|
||||||
/// - 2D texture, mip level 0
|
/// - 2D texture, mip level 0
|
||||||
/// - 4 bytes-per-pixel RGBA8
|
/// - 4 bytes-per-pixel RGBA8, or `RASTER_FORMAT` or `FALLBACK_RASTER_FORMAT`
|
||||||
/// - Texture has COPY_SRC usage
|
/// - Texture has COPY_SRC usage
|
||||||
struct RasterGpuToRasterCpuConverter {
|
struct RasterGpuToRasterCpuConverter {
|
||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
|
format: wgpu::TextureFormat,
|
||||||
unpadded_bytes_per_row: u32,
|
unpadded_bytes_per_row: u32,
|
||||||
padded_bytes_per_row: u32,
|
padded_bytes_per_row: u32,
|
||||||
_source: raster_types::Texture,
|
_source: raster_types::Texture,
|
||||||
}
|
}
|
||||||
impl RasterGpuToRasterCpuConverter {
|
impl RasterGpuToRasterCpuConverter {
|
||||||
fn new(executor: &WgpuExecutor, encoder: &mut wgpu::CommandEncoder, data_gpu: Raster<GPU>) -> Self {
|
fn new(executor: &WgpuExecutor, encoder: &mut wgpu::CommandEncoder, data_gpu: Raster<GPU>) -> Option<Self> {
|
||||||
let texture = data_gpu.data();
|
let texture = data_gpu.texture()?;
|
||||||
let width = texture.width();
|
let width = texture.width();
|
||||||
let height = texture.height();
|
let height = texture.height();
|
||||||
let bytes_per_pixel = 4; // RGBA8
|
let format = texture.format();
|
||||||
|
let bytes_per_pixel = match format {
|
||||||
|
crate::RASTER_FORMAT => 16,
|
||||||
|
crate::FALLBACK_RASTER_FORMAT => 8,
|
||||||
|
_ => 4,
|
||||||
|
};
|
||||||
let unpadded_bytes_per_row = width * bytes_per_pixel;
|
let unpadded_bytes_per_row = width * bytes_per_pixel;
|
||||||
let align = wgpu::COPY_BYTES_PER_ROW_ALIGNMENT;
|
let align = wgpu::COPY_BYTES_PER_ROW_ALIGNMENT;
|
||||||
let padded_bytes_per_row = unpadded_bytes_per_row.div_ceil(align) * align;
|
let padded_bytes_per_row = unpadded_bytes_per_row.div_ceil(align) * align;
|
||||||
@@ -84,15 +101,16 @@ impl RasterGpuToRasterCpuConverter {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Some(Self {
|
||||||
buffer,
|
buffer,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
format,
|
||||||
unpadded_bytes_per_row,
|
unpadded_bytes_per_row,
|
||||||
padded_bytes_per_row,
|
padded_bytes_per_row,
|
||||||
// Keep source texture alive
|
// Keep source texture alive
|
||||||
_source: data_gpu.texture.clone(),
|
_source: texture.clone(),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn convert(self, device: &wgpu::Device) -> Result<Raster<CPU>, wgpu::BufferAsyncError> {
|
async fn convert(self, device: &wgpu::Device) -> Result<Raster<CPU>, wgpu::BufferAsyncError> {
|
||||||
@@ -136,8 +154,20 @@ impl RasterGpuToRasterCpuConverter {
|
|||||||
for row in 0..self.height as usize {
|
for row in 0..self.height as usize {
|
||||||
let start = row * row_stride;
|
let start = row * row_stride;
|
||||||
let row_slice = &view[start..start + row_bytes];
|
let row_slice = &view[start..start + row_bytes];
|
||||||
for px in row_slice.chunks_exact(4) {
|
match self.format {
|
||||||
cpu_data.push(SRGBA8::new(px[0], px[1], px[2], px[3]).into());
|
crate::RASTER_FORMAT => cpu_data.extend(bytemuck::pod_collect_to_vec::<u8, Color>(row_slice)),
|
||||||
|
crate::FALLBACK_RASTER_FORMAT => {
|
||||||
|
let pixels = bytemuck::pod_collect_to_vec::<u8, [f16; 4]>(row_slice);
|
||||||
|
cpu_data.extend(pixels.iter().map(|pixel| {
|
||||||
|
let [red, green, blue, alpha] = pixel.map(f16::to_f32);
|
||||||
|
Color::from_rgbaf32_unchecked(red, green, blue, alpha)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
for px in row_slice.chunks_exact(4) {
|
||||||
|
cpu_data.push(SRGBA8::new(px[0], px[1], px[2], px[3]).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,9 +238,7 @@ impl Convert<List<Raster<GPU>>, WgpuExecutor> for List<Raster<CPU>> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|row| {
|
.map(|row| {
|
||||||
let (image, attributes) = row.into_parts();
|
let (image, attributes) = row.into_parts();
|
||||||
let texture = upload_to_texture(&executor, &queue, &image);
|
Item::from_parts(upload_to_texture(&executor, &queue, &image), attributes)
|
||||||
|
|
||||||
Item::from_parts(Raster::new_gpu(texture), attributes)
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -223,10 +251,10 @@ impl Convert<List<Raster<GPU>>, WgpuExecutor> for List<Raster<CPU>> {
|
|||||||
impl Convert<Raster<GPU>, WgpuExecutor> for Raster<CPU> {
|
impl Convert<Raster<GPU>, WgpuExecutor> for Raster<CPU> {
|
||||||
fn convert(self, _: Footprint, executor: WgpuExecutor) -> Raster<GPU> {
|
fn convert(self, _: Footprint, executor: WgpuExecutor) -> Raster<GPU> {
|
||||||
let queue = executor.context().queue.lock();
|
let queue = executor.context().queue.lock();
|
||||||
let texture = upload_to_texture(&executor, &queue, &self);
|
let raster = upload_to_texture(&executor, &queue, &self);
|
||||||
|
|
||||||
queue.submit([]);
|
queue.submit([]);
|
||||||
Raster::new_gpu(texture)
|
raster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +288,12 @@ impl ConvertAsync<List<Raster<CPU>>, WgpuExecutor> for List<Raster<GPU>> {
|
|||||||
|
|
||||||
let mut map_futures = Vec::new();
|
let mut map_futures = Vec::new();
|
||||||
for converter in converters {
|
for converter in converters {
|
||||||
map_futures.push(converter.convert(device));
|
map_futures.push(async move {
|
||||||
|
match converter {
|
||||||
|
Some(converter) => converter.convert(device).await,
|
||||||
|
None => Ok(Raster::default()),
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let map_results = futures::future::try_join_all(map_futures)
|
let map_results = futures::future::try_join_all(map_futures)
|
||||||
@@ -293,6 +326,7 @@ impl ConvertAsync<Raster<CPU>, WgpuExecutor> for Raster<GPU> {
|
|||||||
|
|
||||||
queue.submit([encoder.finish()]);
|
queue.submit([encoder.finish()]);
|
||||||
|
|
||||||
|
let Some(converter) = converter else { return Raster::default() };
|
||||||
converter.convert(device).await.expect("Failed to download texture data")
|
converter.convert(device).await.expect("Failed to download texture data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,16 @@ fn unpremultiply(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f3
|
|||||||
return vec4<f32>(color.rgb / color.a, color.a);
|
return vec4<f32>(color.rgb / color.a, color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@fragment
|
||||||
|
fn unpremultiply_to_linear(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
|
let color = textureLoad(source, vec2<i32>(position.xy), 0);
|
||||||
|
if color.a <= 0. {
|
||||||
|
return vec4<f32>(0.);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec4<f32>(srgb_to_linear(color.rgb / color.a), color.a);
|
||||||
|
}
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn premultiply(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
|
fn premultiply(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
var color = textureLoad(source, vec2<i32>(position.xy), 0);
|
var color = textureLoad(source, vec2<i32>(position.xy), 0);
|
||||||
@@ -44,3 +54,9 @@ fn linear_to_srgb(linear: vec3<f32>) -> vec3<f32> {
|
|||||||
let high = 1.055 * pow(linear, vec3<f32>(1. / 2.4)) - 0.055;
|
let high = 1.055 * pow(linear, vec3<f32>(1. / 2.4)) - 0.055;
|
||||||
return select(high, low, linear <= vec3<f32>(0.0031308));
|
return select(high, low, linear <= vec3<f32>(0.0031308));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn srgb_to_linear(srgb: vec3<f32>) -> vec3<f32> {
|
||||||
|
let low = srgb / 12.92;
|
||||||
|
let high = pow((srgb + 0.055) / 1.055, vec3<f32>(2.4));
|
||||||
|
return select(high, low, srgb <= vec3<f32>(0.04045));
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ pub struct VelloCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VelloRenderer {
|
impl VelloRenderer {
|
||||||
pub(crate) fn new(device: &wgpu::Device) -> Self {
|
pub(crate) fn new(device: &wgpu::Device, raster_format: wgpu::TextureFormat) -> Self {
|
||||||
let render_target_config = RenderTargetConfig {
|
let render_target_config = RenderTargetConfig {
|
||||||
format: TEXTURE_FORMAT,
|
format: TEXTURE_FORMAT,
|
||||||
width: 1,
|
width: 1,
|
||||||
@@ -59,11 +59,11 @@ impl VelloRenderer {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
gpu: Mutex::new(Renderer::new_with(device, &render_target_config, settings)),
|
gpu: Mutex::new(Renderer::new_with(device, &render_target_config, settings)),
|
||||||
alpha_conversion: AlphaConversion::new(device),
|
alpha_conversion: AlphaConversion::new(device, raster_format),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renders the scene `draw` draws on `canvas`, with its content placed by `view`, into `target` (an `Rgba8Unorm` texture of `size` with straight alpha).
|
/// Renders the scene `draw` draws on `canvas`, with its content placed by `view`, into `target`, a texture of `size` with straight alpha that is either `Rgba8Unorm` holding sRGB values or the executor's raster format holding linear-light values.
|
||||||
/// A render with more content than Vello GPU can hold calls `draw` again for each part it splits into.
|
/// A render with more content than Vello GPU can hold calls `draw` again for each part it splits into.
|
||||||
#[expect(clippy::too_many_arguments)]
|
#[expect(clippy::too_many_arguments)]
|
||||||
pub(crate) fn render(
|
pub(crate) fn render(
|
||||||
@@ -135,10 +135,12 @@ impl VelloRenderer {
|
|||||||
[(UVec2::ZERO, UVec2::new(size.x, top)), (UVec2::new(0, top), UVec2::new(size.x, size.y - top))]
|
[(UVec2::ZERO, UVec2::new(size.x, top)), (UVec2::new(0, top), UVec2::new(size.x, size.y - top))]
|
||||||
};
|
};
|
||||||
let halves = halves.map(|(offset, half_size)| {
|
let halves = halves.map(|(offset, half_size)| {
|
||||||
let half_target = create_texture(
|
// In the target's own format, so the half can be copied into it
|
||||||
|
let half_target = create_texture_with_format(
|
||||||
device,
|
device,
|
||||||
"vello_gpu_split_target",
|
"vello_gpu_split_target",
|
||||||
half_size,
|
half_size,
|
||||||
|
target.format(),
|
||||||
wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::COPY_DST,
|
wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::COPY_DST,
|
||||||
);
|
);
|
||||||
let half_view = Affine::translate((-(offset.x as f64), -(offset.y as f64))) * view;
|
let half_view = Affine::translate((-(offset.x as f64), -(offset.y as f64))) * view;
|
||||||
@@ -267,7 +269,7 @@ impl VelloRenderer {
|
|||||||
|
|
||||||
if rendered.is_ok() {
|
if rendered.is_ok() {
|
||||||
let target_view = target.create_view(&wgpu::TextureViewDescriptor::default());
|
let target_view = target.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
self.alpha_conversion.unpremultiply(device, &mut encoder, &premultiplied_view, &target_view);
|
self.alpha_conversion.unpremultiply(device, &mut encoder, &premultiplied_view, &target_view, target.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submitted even after a failure, since it also prepares the textures of the scene's images
|
// Submitted even after a failure, since it also prepares the textures of the scene's images
|
||||||
@@ -361,7 +363,8 @@ impl ImageTextures {
|
|||||||
|
|
||||||
if let SceneImage::Texture(source) = image {
|
if let SceneImage::Texture(source) = image {
|
||||||
let source_view = source.create_view(&wgpu::TextureViewDescriptor::default());
|
let source_view = source.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
alpha_conversion.premultiply(device, encoder, &source_view, source.format().is_srgb(), &view);
|
let loads_linear_light = source.format().is_srgb() || matches!(source.format(), crate::RASTER_FORMAT | crate::FALLBACK_RASTER_FORMAT);
|
||||||
|
alpha_conversion.premultiply(device, encoder, &source_view, loads_linear_light, &view);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(view)
|
Some(view)
|
||||||
@@ -482,6 +485,10 @@ fn clear_texture(encoder: &mut wgpu::CommandEncoder, view: &wgpu::TextureView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_texture(device: &wgpu::Device, label: &str, size: UVec2, usage: wgpu::TextureUsages) -> wgpu::Texture {
|
fn create_texture(device: &wgpu::Device, label: &str, size: UVec2, usage: wgpu::TextureUsages) -> wgpu::Texture {
|
||||||
|
create_texture_with_format(device, label, size, TEXTURE_FORMAT, usage)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_texture_with_format(device: &wgpu::Device, label: &str, size: UVec2, format: wgpu::TextureFormat, usage: wgpu::TextureUsages) -> wgpu::Texture {
|
||||||
device.create_texture(&wgpu::TextureDescriptor {
|
device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: Some(label),
|
label: Some(label),
|
||||||
size: wgpu::Extent3d {
|
size: wgpu::Extent3d {
|
||||||
@@ -492,7 +499,7 @@ fn create_texture(device: &wgpu::Device, label: &str, size: UVec2, usage: wgpu::
|
|||||||
mip_level_count: 1,
|
mip_level_count: 1,
|
||||||
sample_count: 1,
|
sample_count: 1,
|
||||||
dimension: wgpu::TextureDimension::D2,
|
dimension: wgpu::TextureDimension::D2,
|
||||||
format: TEXTURE_FORMAT,
|
format,
|
||||||
usage,
|
usage,
|
||||||
view_formats: &[],
|
view_formats: &[],
|
||||||
})
|
})
|
||||||
@@ -502,6 +509,8 @@ fn create_texture(device: &wgpu::Device, label: &str, size: UVec2, usage: wgpu::
|
|||||||
struct AlphaConversion {
|
struct AlphaConversion {
|
||||||
bind_group_layout: wgpu::BindGroupLayout,
|
bind_group_layout: wgpu::BindGroupLayout,
|
||||||
unpremultiply_pipeline: wgpu::RenderPipeline,
|
unpremultiply_pipeline: wgpu::RenderPipeline,
|
||||||
|
/// Unpremultiplies into a linear-light target in the executor's raster format.
|
||||||
|
unpremultiply_to_linear_pipeline: wgpu::RenderPipeline,
|
||||||
premultiply_pipeline: wgpu::RenderPipeline,
|
premultiply_pipeline: wgpu::RenderPipeline,
|
||||||
/// The parameters for a source whose format stores linear values.
|
/// The parameters for a source whose format stores linear values.
|
||||||
linear_source_parameters: wgpu::Buffer,
|
linear_source_parameters: wgpu::Buffer,
|
||||||
@@ -510,7 +519,7 @@ struct AlphaConversion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AlphaConversion {
|
impl AlphaConversion {
|
||||||
fn new(device: &wgpu::Device) -> Self {
|
fn new(device: &wgpu::Device, raster_format: wgpu::TextureFormat) -> Self {
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::include_wgsl!("vello_alpha.wgsl"));
|
let shader = device.create_shader_module(wgpu::include_wgsl!("vello_alpha.wgsl"));
|
||||||
@@ -546,7 +555,7 @@ impl AlphaConversion {
|
|||||||
immediate_size: 0,
|
immediate_size: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
let create_pipeline = |label: &str, entry_point: &str| {
|
let create_pipeline = |label: &str, entry_point: &str, format: wgpu::TextureFormat| {
|
||||||
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some(label),
|
label: Some(label),
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
@@ -561,7 +570,7 @@ impl AlphaConversion {
|
|||||||
entry_point: Some(entry_point),
|
entry_point: Some(entry_point),
|
||||||
compilation_options: Default::default(),
|
compilation_options: Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: TEXTURE_FORMAT,
|
format,
|
||||||
blend: None,
|
blend: None,
|
||||||
write_mask: wgpu::ColorWrites::ALL,
|
write_mask: wgpu::ColorWrites::ALL,
|
||||||
})],
|
})],
|
||||||
@@ -586,16 +595,22 @@ impl AlphaConversion {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
unpremultiply_pipeline: create_pipeline("vello_unpremultiply_pipeline", "unpremultiply"),
|
unpremultiply_pipeline: create_pipeline("vello_unpremultiply_pipeline", "unpremultiply", TEXTURE_FORMAT),
|
||||||
premultiply_pipeline: create_pipeline("vello_premultiply_pipeline", "premultiply"),
|
unpremultiply_to_linear_pipeline: create_pipeline("vello_unpremultiply_to_linear_pipeline", "unpremultiply_to_linear", raster_format),
|
||||||
|
premultiply_pipeline: create_pipeline("vello_premultiply_pipeline", "premultiply", TEXTURE_FORMAT),
|
||||||
linear_source_parameters: create_parameters("vello_alpha_linear_source", 0),
|
linear_source_parameters: create_parameters("vello_alpha_linear_source", 0),
|
||||||
srgb_source_parameters: create_parameters("vello_alpha_srgb_source", 1),
|
srgb_source_parameters: create_parameters("vello_alpha_srgb_source", 1),
|
||||||
bind_group_layout,
|
bind_group_layout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unpremultiply(&self, device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, source: &wgpu::TextureView, target: &wgpu::TextureView) {
|
fn unpremultiply(&self, device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, source: &wgpu::TextureView, target: &wgpu::TextureView, target_format: wgpu::TextureFormat) {
|
||||||
self.run(device, encoder, &self.unpremultiply_pipeline, &self.linear_source_parameters, source, target);
|
let pipeline = if target_format == TEXTURE_FORMAT {
|
||||||
|
&self.unpremultiply_pipeline
|
||||||
|
} else {
|
||||||
|
&self.unpremultiply_to_linear_pipeline
|
||||||
|
};
|
||||||
|
self.run(device, encoder, pipeline, &self.linear_source_parameters, source, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn premultiply(&self, device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, source: &wgpu::TextureView, source_is_srgb: bool, target: &wgpu::TextureView) {
|
fn premultiply(&self, device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, source: &wgpu::TextureView, source_is_srgb: bool, target: &wgpu::TextureView) {
|
||||||
|
|||||||
@@ -30,4 +30,3 @@ proc-macro-error2 = "2"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
core-types = { workspace = true }
|
core-types = { workspace = true }
|
||||||
no-std-types = { workspace = true }
|
|
||||||
@@ -1,263 +0,0 @@
|
|||||||
use crate::crate_ident::CrateIdent;
|
|
||||||
use proc_macro2::{Ident, Span, TokenStream};
|
|
||||||
use quote::{ToTokens, format_ident, quote};
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use syn::punctuated::Punctuated;
|
|
||||||
use syn::visit_mut::VisitMut;
|
|
||||||
use syn::{Fields, GenericParam, Generics, Item, ItemEnum, ItemStruct, Meta, MetaList, Path, PathSegment, Result, Token, TypeParam, TypeParamBound, visit_mut};
|
|
||||||
|
|
||||||
pub fn derive_buffer_struct(crate_ident: &CrateIdent, content: proc_macro::TokenStream) -> Result<TokenStream> {
|
|
||||||
let item = syn::parse::<Item>(content)?;
|
|
||||||
match &item {
|
|
||||||
Item::Enum(item) => derive_buffer_struct_enum(crate_ident, item),
|
|
||||||
Item::Struct(item) => derive_buffer_struct_struct(crate_ident, item),
|
|
||||||
_ => Err(syn::Error::new_spanned(&item, "Expected a struct or an enum")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn derive_buffer_struct_enum(crate_ident: &CrateIdent, item: &ItemEnum) -> Result<TokenStream> {
|
|
||||||
let gcore_shaders = crate_ident.gcore_shaders()?;
|
|
||||||
let mod_buffer_struct = quote!(#gcore_shaders::shaders::buffer_struct);
|
|
||||||
let reexport = quote!(#gcore_shaders::shaders::__private);
|
|
||||||
|
|
||||||
if !item.generics.params.is_empty() {
|
|
||||||
return Err(syn::Error::new_spanned(&item.generics, "enum must not have any generics"));
|
|
||||||
}
|
|
||||||
|
|
||||||
let enum_requirements_error = || {
|
|
||||||
syn::Error::new(
|
|
||||||
Span::call_site(),
|
|
||||||
"deriving `BufferStruct` on an enum requires `#[repr(u32)]` and `#[derive(num_enum::FromPrimitive, num_enum::IntoPrimitive)]`",
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let repr_path = Path::from(format_ident!("repr"));
|
|
||||||
let repr = item
|
|
||||||
.attrs
|
|
||||||
.iter()
|
|
||||||
.filter_map(|a| match &a.meta {
|
|
||||||
Meta::List(MetaList { path, tokens, .. }) if *path == repr_path => Some(tokens),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.next()
|
|
||||||
.ok_or_else(enum_requirements_error)?;
|
|
||||||
|
|
||||||
let ident = &item.ident;
|
|
||||||
Ok(quote! {
|
|
||||||
unsafe impl #mod_buffer_struct::BufferStruct for #ident
|
|
||||||
{
|
|
||||||
type Buffer = #repr;
|
|
||||||
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
<#repr as From<Self>>::from(from)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
<Self as #reexport::num_enum::FromPrimitive>::from_primitive(from)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see [`BufferStruct`] docs
|
|
||||||
///
|
|
||||||
/// This is also largely copied from my (@firestar99) project and adjusted
|
|
||||||
///
|
|
||||||
/// [`BufferStruct`]: `no_std_types::shaders::buffer_struct::BufferStruct`
|
|
||||||
pub fn derive_buffer_struct_struct(crate_ident: &CrateIdent, item: &ItemStruct) -> Result<TokenStream> {
|
|
||||||
let gcore_shaders = crate_ident.gcore_shaders()?;
|
|
||||||
let mod_buffer_struct = quote!(#gcore_shaders::shaders::buffer_struct);
|
|
||||||
let reexport = quote!(#gcore_shaders::shaders::__private);
|
|
||||||
|
|
||||||
let generics = item
|
|
||||||
.generics
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.filter_map(|g| match g {
|
|
||||||
GenericParam::Lifetime(_) => None,
|
|
||||||
GenericParam::Type(t) => Some(t.ident.clone()),
|
|
||||||
GenericParam::Const(c) => Some(c.ident.clone()),
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut members_buffer = Punctuated::<TokenStream, Token![,]>::new();
|
|
||||||
let mut write = Punctuated::<TokenStream, Token![,]>::new();
|
|
||||||
let mut read = Punctuated::<TokenStream, Token![,]>::new();
|
|
||||||
let mut gen_name_gen = GenericNameGen::new();
|
|
||||||
let mut gen_ref_tys = Vec::new();
|
|
||||||
let (members_buffer, write, read) = match &item.fields {
|
|
||||||
Fields::Named(named) => {
|
|
||||||
for f in &named.named {
|
|
||||||
let name = f.ident.as_ref().unwrap();
|
|
||||||
let mut ty = f.ty.clone();
|
|
||||||
let mut visitor = GenericsVisitor::new(&item.ident, &generics);
|
|
||||||
visit_mut::visit_type_mut(&mut visitor, &mut ty);
|
|
||||||
if visitor.found_generics {
|
|
||||||
gen_ref_tys.push(f.ty.clone());
|
|
||||||
let gen_ident = gen_name_gen.next();
|
|
||||||
members_buffer.push(quote!(#name: #gen_ident));
|
|
||||||
} else {
|
|
||||||
members_buffer.push(quote! {
|
|
||||||
#name: <#ty as #mod_buffer_struct::BufferStruct>::Buffer
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
write.push(quote! {
|
|
||||||
#name: <#ty as #mod_buffer_struct::BufferStruct>::write(from.#name)
|
|
||||||
});
|
|
||||||
read.push(quote! {
|
|
||||||
#name: <#ty as #mod_buffer_struct::BufferStruct>::read(from.#name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
(quote!({#members_buffer}), quote!(Self::Buffer {#write}), quote!(Self {#read}))
|
|
||||||
}
|
|
||||||
Fields::Unnamed(unnamed) => {
|
|
||||||
for (i, f) in unnamed.unnamed.iter().enumerate() {
|
|
||||||
let mut ty = f.ty.clone();
|
|
||||||
let mut visitor = GenericsVisitor::new(&item.ident, &generics);
|
|
||||||
visit_mut::visit_type_mut(&mut visitor, &mut ty);
|
|
||||||
if visitor.found_generics {
|
|
||||||
gen_ref_tys.push(f.ty.clone());
|
|
||||||
members_buffer.push(gen_name_gen.next().into_token_stream());
|
|
||||||
} else {
|
|
||||||
members_buffer.push(quote! {
|
|
||||||
<#ty as #mod_buffer_struct::BufferStruct>::Buffer
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let index = syn::Index::from(i);
|
|
||||||
write.push(quote! {
|
|
||||||
<#ty as #mod_buffer_struct::BufferStruct>::write(from.#index)
|
|
||||||
});
|
|
||||||
read.push(quote! {
|
|
||||||
<#ty as #mod_buffer_struct::BufferStruct>::read(from.#index)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
(quote!((#members_buffer);), quote!(Self::Buffer(#write)), quote!(Self(#read)))
|
|
||||||
}
|
|
||||||
Fields::Unit => (quote!(;), quote!(let _ = from; Self::Buffer {}), quote!(let _ = from; Self::Shader {})),
|
|
||||||
};
|
|
||||||
|
|
||||||
let generics_decl = &item.generics;
|
|
||||||
let generics_ref = decl_to_ref(item.generics.params.iter());
|
|
||||||
let generics_where = gen_ref_tys
|
|
||||||
.iter()
|
|
||||||
.map(|ty| quote!(#ty: #mod_buffer_struct::BufferStruct))
|
|
||||||
.collect::<Punctuated<TokenStream, Token![,]>>()
|
|
||||||
.into_token_stream();
|
|
||||||
|
|
||||||
let generics_decl_any = gen_name_gen.decl(quote! {
|
|
||||||
#reexport::bytemuck::Pod + Send + Sync
|
|
||||||
});
|
|
||||||
let generics_ref_buffer = gen_ref_tys
|
|
||||||
.iter()
|
|
||||||
.map(|ty| quote!(<#ty as #mod_buffer_struct::BufferStruct>::Buffer))
|
|
||||||
.collect::<Punctuated<TokenStream, Token![,]>>()
|
|
||||||
.into_token_stream();
|
|
||||||
|
|
||||||
let vis = &item.vis;
|
|
||||||
let ident = &item.ident;
|
|
||||||
let buffer_ident = format_ident!("{}Buffer", ident);
|
|
||||||
Ok(quote! {
|
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone, #reexport::bytemuck::Zeroable, #reexport::bytemuck::Pod)]
|
|
||||||
#vis struct #buffer_ident #generics_decl_any #members_buffer
|
|
||||||
|
|
||||||
unsafe impl #generics_decl #mod_buffer_struct::BufferStruct for #ident #generics_ref
|
|
||||||
where
|
|
||||||
#ident #generics_ref: Copy,
|
|
||||||
#generics_where
|
|
||||||
{
|
|
||||||
type Buffer = #buffer_ident <#generics_ref_buffer>;
|
|
||||||
|
|
||||||
fn write(from: Self) -> Self::Buffer {
|
|
||||||
#write
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read(from: Self::Buffer) -> Self {
|
|
||||||
#read
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
struct GenericsVisitor<'a> {
|
|
||||||
self_ident: &'a Ident,
|
|
||||||
generics: &'a HashSet<Ident>,
|
|
||||||
found_generics: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> GenericsVisitor<'a> {
|
|
||||||
pub fn new(self_ident: &'a Ident, generics: &'a HashSet<Ident>) -> Self {
|
|
||||||
Self {
|
|
||||||
self_ident,
|
|
||||||
generics,
|
|
||||||
found_generics: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl VisitMut for GenericsVisitor<'_> {
|
|
||||||
fn visit_ident_mut(&mut self, i: &mut Ident) {
|
|
||||||
if self.generics.contains(i) {
|
|
||||||
self.found_generics = true;
|
|
||||||
}
|
|
||||||
visit_mut::visit_ident_mut(self, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_path_segment_mut(&mut self, i: &mut PathSegment) {
|
|
||||||
if i.ident == "Self" {
|
|
||||||
i.ident = self.self_ident.clone();
|
|
||||||
}
|
|
||||||
visit_mut::visit_path_segment_mut(self, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct GenericNameGen(u32);
|
|
||||||
|
|
||||||
impl GenericNameGen {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn next(&mut self) -> Ident {
|
|
||||||
let i = self.0;
|
|
||||||
self.0 += 1;
|
|
||||||
format_ident!("T{}", i)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn decl(self, ty: TokenStream) -> Generics {
|
|
||||||
let params: Punctuated<GenericParam, Token![,]> = (0..self.0)
|
|
||||||
.map(|i| {
|
|
||||||
GenericParam::Type(TypeParam {
|
|
||||||
attrs: Vec::new(),
|
|
||||||
ident: format_ident!("T{}", i),
|
|
||||||
colon_token: Some(Default::default()),
|
|
||||||
bounds: Punctuated::from_iter([TypeParamBound::Verbatim(ty.clone())]),
|
|
||||||
eq_token: None,
|
|
||||||
default: None,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
if !params.is_empty() {
|
|
||||||
Generics {
|
|
||||||
lt_token: Some(Default::default()),
|
|
||||||
params,
|
|
||||||
gt_token: Some(Default::default()),
|
|
||||||
where_clause: None,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Generics::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decl_to_ref<'a>(generics: impl Iterator<Item = &'a GenericParam>) -> TokenStream {
|
|
||||||
let out = generics
|
|
||||||
.map(|generic| match generic {
|
|
||||||
GenericParam::Lifetime(l) => l.lifetime.to_token_stream(),
|
|
||||||
GenericParam::Type(t) => t.ident.to_token_stream(),
|
|
||||||
GenericParam::Const(c) => c.ident.to_token_stream(),
|
|
||||||
})
|
|
||||||
.collect::<Punctuated<TokenStream, Token![,]>>();
|
|
||||||
if out.is_empty() { TokenStream::new() } else { quote!(<#out>) }
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::parsing::*;
|
use crate::parsing::*;
|
||||||
use crate::shader_nodes::STD_FEATURE_GATE;
|
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use proc_macro2::TokenStream as TokenStream2;
|
use proc_macro2::TokenStream as TokenStream2;
|
||||||
use quote::{ToTokens, format_ident, quote, quote_spanned};
|
use quote::{ToTokens, format_ident, quote, quote_spanned};
|
||||||
@@ -174,15 +173,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
|||||||
value => value.regular().expect("a non-node field is a value field").ty.clone(),
|
value => value.regular().expect("a non-node field is a value field").ty.clone(),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let shader_field_types: Vec<_> = regular_fields
|
|
||||||
.iter()
|
|
||||||
.zip(field_types.iter())
|
|
||||||
.map(|(field, field_type)| match field.ty.regular() {
|
|
||||||
Some(regular) => regular.body_ty().clone(),
|
|
||||||
None => field_type.clone(),
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let has_shader_variant = regular_fields.iter().any(|field| field.ty.regular().is_some_and(|regular| regular.narrowed_body_ty.is_some()));
|
|
||||||
|
|
||||||
// Only regular fields have UI metadata (data fields are internal state)
|
// Only regular fields have UI metadata (data fields are internal state)
|
||||||
let widget_override: Vec<_> = regular_fields
|
let widget_override: Vec<_> = regular_fields
|
||||||
@@ -882,9 +872,8 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
|||||||
false => quote!(None),
|
false => quote!(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
let cfg = crate::shader_nodes::modify_cfg(attributes);
|
let cfg = attributes.cfg.as_ref().map(|cfg| quote!(#[cfg(#cfg)])).unwrap_or_default();
|
||||||
let node_input_accessor = generate_node_input_references(parsed, &field_idents, core_types, &identifier, &cfg);
|
let node_input_accessor = generate_node_input_references(parsed, &field_idents, core_types, &identifier, &cfg);
|
||||||
let ShaderTokens { shader_entry_point, gpu_node } = attributes.shader_node.as_ref().map(|n| n.codegen(crate_ident, parsed)).unwrap_or(Ok(ShaderTokens::default()))?;
|
|
||||||
|
|
||||||
let mapped_node_impl = match (&mapped_struct_where_clause, &mapped_eval_impl) {
|
let mapped_node_impl = match (&mapped_struct_where_clause, &mapped_eval_impl) {
|
||||||
(Some(mapped_where_clause), Some(mapped_eval)) => quote! {
|
(Some(mapped_where_clause), Some(mapped_eval)) => quote! {
|
||||||
@@ -992,28 +981,11 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let node_fn = |field_types: &[Type]| {
|
let node_fn = quote! {
|
||||||
quote! {
|
#(#description_doc_attrs)*
|
||||||
#(#description_doc_attrs)*
|
#[inline]
|
||||||
#[inline]
|
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
|
||||||
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
|
#vis #async_keyword fn #fn_name <#(#fn_generics,)*> (#input_ident: #input_type #(, #data_field_idents: #data_field_types)* #(, #field_idents: #field_types)*) -> #output_type #where_clause #body
|
||||||
#vis #async_keyword fn #fn_name <#(#fn_generics,)*> (#input_ident: #input_type #(, #data_field_idents: #data_field_types)* #(, #field_idents: #field_types)*) -> #output_type #where_clause #body
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// A shader node's fn is emitted twice from the one body: as declared, in f64, for the CPU, and with the f32 parameter
|
|
||||||
// counterparts for the shader build, which cannot represent a 64-bit float. The body casts to f32 only where it meets a Color channel.
|
|
||||||
let node_fn = if has_shader_variant {
|
|
||||||
let cpu_fn = node_fn(&field_types);
|
|
||||||
let shader_fn = node_fn(&shader_field_types);
|
|
||||||
quote! {
|
|
||||||
#[cfg(feature = #STD_FEATURE_GATE)]
|
|
||||||
#cpu_fn
|
|
||||||
|
|
||||||
#[cfg(not(feature = #STD_FEATURE_GATE))]
|
|
||||||
#shader_fn
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
node_fn(&field_types)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
@@ -1132,9 +1104,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#shader_entry_point
|
|
||||||
|
|
||||||
#gpu_node
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1476,7 +1445,6 @@ fn generate_register_node_impl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
use crate::crate_ident::CrateIdent;
|
use crate::crate_ident::CrateIdent;
|
||||||
use crate::shader_nodes::{ShaderCodegen, ShaderTokens};
|
|
||||||
use syn::visit_mut::VisitMut;
|
use syn::visit_mut::VisitMut;
|
||||||
use syn::{GenericArgument, Lifetime, Type};
|
use syn::{GenericArgument, Lifetime, Type};
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ use quote::{format_ident, quote};
|
|||||||
|
|
||||||
pub struct CrateIdent {
|
pub struct CrateIdent {
|
||||||
gcore: syn::Result<TokenStream>,
|
gcore: syn::Result<TokenStream>,
|
||||||
gcore_shaders: syn::Result<TokenStream>,
|
|
||||||
graphene_core: syn::Result<TokenStream>,
|
graphene_core: syn::Result<TokenStream>,
|
||||||
raster_types: syn::Result<TokenStream>,
|
|
||||||
wgpu_executor: syn::Result<TokenStream>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CrateIdent {
|
impl CrateIdent {
|
||||||
@@ -15,21 +12,9 @@ impl CrateIdent {
|
|||||||
self.gcore.as_ref().map_err(Clone::clone)
|
self.gcore.as_ref().map_err(Clone::clone)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gcore_shaders(&self) -> syn::Result<&TokenStream> {
|
|
||||||
self.gcore_shaders.as_ref().map_err(Clone::clone)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn graphene_core(&self) -> syn::Result<&TokenStream> {
|
pub fn graphene_core(&self) -> syn::Result<&TokenStream> {
|
||||||
self.graphene_core.as_ref().map_err(Clone::clone)
|
self.graphene_core.as_ref().map_err(Clone::clone)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn raster_types(&self) -> syn::Result<&TokenStream> {
|
|
||||||
self.raster_types.as_ref().map_err(Clone::clone)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn wgpu_executor(&self) -> syn::Result<&TokenStream> {
|
|
||||||
self.wgpu_executor.as_ref().map_err(Clone::clone)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CrateIdent {
|
impl Default for CrateIdent {
|
||||||
@@ -44,20 +29,11 @@ impl Default for CrateIdent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let gcore = find_crate("core-types");
|
let gcore = find_crate("core-types");
|
||||||
let gcore_shaders = find_crate("no-std-types").or_else(|eshaders| gcore.clone().map_err(|ecore| syn::Error::new(Span::call_site(), format!("{ecore}\n\nFallback: {eshaders}"))));
|
|
||||||
let graphene_core = find_crate("graphene-core").or_else(|ecore| {
|
let graphene_core = find_crate("graphene-core").or_else(|ecore| {
|
||||||
find_crate("graphene-std")
|
find_crate("graphene-std")
|
||||||
.map(|gstd| quote!(#gstd::graphene_core))
|
.map(|gstd| quote!(#gstd::graphene_core))
|
||||||
.map_err(|estd| syn::Error::new(Span::call_site(), format!("{ecore}\n\nFallback: {estd}")))
|
.map_err(|estd| syn::Error::new(Span::call_site(), format!("{ecore}\n\nFallback: {estd}")))
|
||||||
});
|
});
|
||||||
let raster_types = find_crate("raster-types");
|
Self { gcore, graphene_core }
|
||||||
let wgpu_executor = find_crate("wgpu-executor");
|
|
||||||
Self {
|
|
||||||
gcore,
|
|
||||||
gcore_shaders,
|
|
||||||
graphene_core,
|
|
||||||
raster_types,
|
|
||||||
wgpu_executor,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,12 +110,8 @@ fn derive_enum(enum_attributes: &[Attribute], name: Ident, input: syn::DataEnum)
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let crate_name = {
|
let crate_name = {
|
||||||
let crate_name = proc_macro_crate::crate_name("no-std-types").or_else(|_e| proc_macro_crate::crate_name("core-types")).map_err(|e| {
|
let crate_name = proc_macro_crate::crate_name("core-types")
|
||||||
syn::Error::new(
|
.map_err(|e| syn::Error::new(Span::call_site(), format!("Failed to find location of 'core-types'. Make sure it is imported as a dependency: {e}")))?;
|
||||||
Span::call_site(),
|
|
||||||
format!("Failed to find location of 'no-std-types' or 'core-types'. Make sure it is imported as a dependency: {e}"),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
match crate_name {
|
match crate_name {
|
||||||
proc_macro_crate::FoundCrate::Itself => quote!(crate),
|
proc_macro_crate::FoundCrate::Itself => quote!(crate),
|
||||||
proc_macro_crate::FoundCrate::Name(name) => {
|
proc_macro_crate::FoundCrate::Name(name) => {
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
use crate::crate_ident::CrateIdent;
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use proc_macro_error2::proc_macro_error;
|
use proc_macro_error2::proc_macro_error;
|
||||||
|
|
||||||
mod buffer_struct;
|
|
||||||
mod codegen;
|
mod codegen;
|
||||||
mod crate_ident;
|
mod crate_ident;
|
||||||
mod derive_choice_type;
|
mod derive_choice_type;
|
||||||
mod destructure;
|
mod destructure;
|
||||||
mod parsing;
|
mod parsing;
|
||||||
mod shader_nodes;
|
|
||||||
mod validation;
|
mod validation;
|
||||||
|
|
||||||
/// Used to create a node definition.
|
/// Used to create a node definition.
|
||||||
@@ -69,10 +66,3 @@ pub fn derive_destructure(input_item: TokenStream) -> TokenStream {
|
|||||||
pub fn derive_choice_type(input_item: TokenStream) -> TokenStream {
|
pub fn derive_choice_type(input_item: TokenStream) -> TokenStream {
|
||||||
derive_choice_type::derive_choice_type_impl(input_item.into()).unwrap_or_else(|err| err.to_compile_error()).into()
|
derive_choice_type::derive_choice_type_impl(input_item.into()).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Derive a struct to implement `ShaderStruct`, see that for docs.
|
|
||||||
#[proc_macro_derive(BufferStruct)]
|
|
||||||
pub fn derive_buffer_struct(input_item: TokenStream) -> TokenStream {
|
|
||||||
let crate_ident = CrateIdent::default();
|
|
||||||
TokenStream::from(buffer_struct::derive_buffer_struct(&crate_ident, input_item).unwrap_or_else(|err| err.to_compile_error()))
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ use syn::{
|
|||||||
|
|
||||||
use crate::codegen::generate_node_code;
|
use crate::codegen::generate_node_code;
|
||||||
use crate::crate_ident::CrateIdent;
|
use crate::crate_ident::CrateIdent;
|
||||||
use crate::shader_nodes::ShaderNodeType;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct Implementation {
|
pub(crate) struct Implementation {
|
||||||
@@ -66,8 +65,6 @@ pub(crate) struct NodeFnAttributes {
|
|||||||
pub(crate) inspector_string: Option<LitStr>,
|
pub(crate) inspector_string: Option<LitStr>,
|
||||||
/// whether to `#[cfg]` gate the node implementation, defaults to None
|
/// whether to `#[cfg]` gate the node implementation, defaults to None
|
||||||
pub(crate) cfg: Option<TokenStream2>,
|
pub(crate) cfg: Option<TokenStream2>,
|
||||||
/// if this node should get a gpu implementation, defaults to None
|
|
||||||
pub(crate) shader_node: Option<ShaderNodeType>,
|
|
||||||
/// Custom serialization function path (e.g., "my_module::custom_serialize")
|
/// Custom serialization function path (e.g., "my_module::custom_serialize")
|
||||||
pub(crate) serialize: Option<Path>,
|
pub(crate) serialize: Option<Path>,
|
||||||
pub(crate) flags: NodeFlags,
|
pub(crate) flags: NodeFlags,
|
||||||
@@ -164,8 +161,6 @@ impl ParsedField {
|
|||||||
number_hard_max: None,
|
number_hard_max: None,
|
||||||
number_mode_range: false,
|
number_mode_range: false,
|
||||||
implementations: Default::default(),
|
implementations: Default::default(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -251,14 +246,6 @@ impl ParsedFieldType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The element type `T` of a rank-0 `Item<T>` field, or `None` for any other shape.
|
|
||||||
pub fn item_element(&self) -> Option<&Type> {
|
|
||||||
match self {
|
|
||||||
ParsedFieldType::Item { element, .. } => Some(element),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The element type `T` of a whole-list `List<T>` field, or `None` for any other shape.
|
/// The element type `T` of a whole-list `List<T>` field, or `None` for any other shape.
|
||||||
pub fn list_element(&self) -> Option<&Type> {
|
pub fn list_element(&self) -> Option<&Type> {
|
||||||
match self {
|
match self {
|
||||||
@@ -382,17 +369,6 @@ pub struct RegularParsedField {
|
|||||||
/// Whether the number input renders as a draggable slider (the `#[range]` attribute) rather than the default increment field.
|
/// Whether the number input renders as a draggable slider (the `#[range]` attribute) rather than the default increment field.
|
||||||
pub number_mode_range: bool,
|
pub number_mode_range: bool,
|
||||||
pub implementations: Punctuated<Type, Comma>,
|
pub implementations: Punctuated<Type, Comma>,
|
||||||
pub gpu_image: bool,
|
|
||||||
/// Set for a shader node's `f64` or `i64` parameter: `ty` keeps the type it was declared with, which the graph and the
|
|
||||||
/// CPU fn use, while the shader build's fn variant and the GPU uniform take this `f32` or `i32` counterpart.
|
|
||||||
pub narrowed_body_ty: Option<Type>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RegularParsedField {
|
|
||||||
/// The type the shader build's fn variant is handed: the 32-bit counterpart of a shader node's declared `f64` or `i64`, otherwise `ty` itself.
|
|
||||||
pub fn body_ty(&self) -> &Type {
|
|
||||||
self.narrowed_body_ty.as_ref().unwrap_or(&self.ty)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// a param of `impl Node` with `#[implementation(in -> out)]`
|
/// a param of `impl Node` with `#[implementation(in -> out)]`
|
||||||
@@ -461,7 +437,6 @@ impl Parse for NodeFnAttributes {
|
|||||||
let mut path = None;
|
let mut path = None;
|
||||||
let mut inspector_string = None;
|
let mut inspector_string = None;
|
||||||
let mut cfg = None;
|
let mut cfg = None;
|
||||||
let mut shader_node = None;
|
|
||||||
let mut serialize = None;
|
let mut serialize = None;
|
||||||
let mut flags = NodeFlags::default();
|
let mut flags = NodeFlags::default();
|
||||||
let mut placeholder = None;
|
let mut placeholder = None;
|
||||||
@@ -564,17 +539,6 @@ impl Parse for NodeFnAttributes {
|
|||||||
let meta = meta.require_list()?;
|
let meta = meta.require_list()?;
|
||||||
cfg = Some(meta.tokens.clone());
|
cfg = Some(meta.tokens.clone());
|
||||||
}
|
}
|
||||||
// Reference to a specific shader definition struct that is used to run the logic of this node on the GPU.
|
|
||||||
//
|
|
||||||
// Example usage:
|
|
||||||
// #[node_macro::node(..., shader_node(PerPixelAdjust), ...)]
|
|
||||||
"shader_node" => {
|
|
||||||
if shader_node.is_some() {
|
|
||||||
return Err(Error::new_spanned(path, "Multiple 'shader_node' attributes are not allowed"));
|
|
||||||
}
|
|
||||||
let meta = meta.require_list()?;
|
|
||||||
shader_node = Some(syn::parse2(meta.tokens.to_token_stream())?);
|
|
||||||
}
|
|
||||||
// Function name for custom serialization of this node's data. This is only used by the Monitor node.
|
// Function name for custom serialization of this node's data. This is only used by the Monitor node.
|
||||||
//
|
//
|
||||||
// Example usage:
|
// Example usage:
|
||||||
@@ -635,7 +599,7 @@ impl Parse for NodeFnAttributes {
|
|||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
Unsupported attribute in `node`.
|
Unsupported attribute in `node`.
|
||||||
Supported attributes are 'category', 'name', 'icon', 'path', 'skip_impl', 'inspector', 'cfg', 'shader_node', 'serialize', 'memoize', 'footprint_invariant', 'forwards_input', 'inject_scope', 'placeholder', and 'no_partial'.
|
Supported attributes are 'category', 'name', 'icon', 'path', 'skip_impl', 'inspector', 'cfg', 'serialize', 'memoize', 'footprint_invariant', 'forwards_input', 'inject_scope', 'placeholder', and 'no_partial'.
|
||||||
Example usage:
|
Example usage:
|
||||||
#[node_macro::node(..., name("Test Node"), ...)]
|
#[node_macro::node(..., name("Test Node"), ...)]
|
||||||
"#
|
"#
|
||||||
@@ -665,7 +629,6 @@ impl Parse for NodeFnAttributes {
|
|||||||
path,
|
path,
|
||||||
inspector_string,
|
inspector_string,
|
||||||
cfg,
|
cfg,
|
||||||
shader_node,
|
|
||||||
serialize,
|
serialize,
|
||||||
flags,
|
flags,
|
||||||
placeholder,
|
placeholder,
|
||||||
@@ -693,10 +656,7 @@ pub(crate) fn parse_node_fn(attr: TokenStream2, item: TokenStream2) -> syn::Resu
|
|||||||
let fn_generics = input_fn.sig.generics.params.into_iter().collect();
|
let fn_generics = input_fn.sig.generics.params.into_iter().collect();
|
||||||
let is_async = input_fn.sig.asyncness.is_some();
|
let is_async = input_fn.sig.asyncness.is_some();
|
||||||
|
|
||||||
let (input, mut fields) = parse_inputs(&input_fn.sig.inputs)?;
|
let (input, fields) = parse_inputs(&input_fn.sig.inputs)?;
|
||||||
if matches!(attributes.shader_node, Some(ShaderNodeType::PerPixelAdjust(_))) {
|
|
||||||
narrow_shader_fields(&mut fields)?;
|
|
||||||
}
|
|
||||||
let output_type = parse_output(&input_fn.sig.output)?;
|
let output_type = parse_output(&input_fn.sig.output)?;
|
||||||
let output_element = peel_item(&output_payload(&output_type));
|
let output_element = peel_item(&output_payload(&output_type));
|
||||||
let where_clause = input_fn.sig.generics.where_clause;
|
let where_clause = input_fn.sig.generics.where_clause;
|
||||||
@@ -987,7 +947,6 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
|
|||||||
.map_err(|e| Error::new_spanned(attr, format!("Invalid `step` for argument '{ident}': {e}\nUSAGE EXAMPLE: #[step(2.)]")))
|
.map_err(|e| Error::new_spanned(attr, format!("Invalid `step` for argument '{ident}': {e}\nUSAGE EXAMPLE: #[step(2.)]")))
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
let gpu_image = extract_attribute(attrs, "gpu_image").is_some();
|
|
||||||
|
|
||||||
let (is_node, node_input_type, node_output_type) = parse_node_type(&ty);
|
let (is_node, node_input_type, node_output_type) = parse_node_type(&ty);
|
||||||
let description = attrs
|
let description = attrs
|
||||||
@@ -1087,8 +1046,6 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
|
|||||||
ty,
|
ty,
|
||||||
value_source,
|
value_source,
|
||||||
implementations,
|
implementations,
|
||||||
gpu_image,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
@@ -1126,69 +1083,6 @@ fn parse_node_type(ty: &Type) -> (bool, Option<Type>, Option<Type>) {
|
|||||||
(false, None, None)
|
(false, None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `PerPixelAdjust` shader node is declared with the catalog's `f64` and `i64` parameters, and its fn is emitted twice
|
|
||||||
/// from the one body: as declared for the CPU, and with the `f32` and `i32` counterparts recorded here for the shader
|
|
||||||
/// build, which cannot represent a 64-bit number. Declaring `f32` or `i32` directly is refused so the node's definition
|
|
||||||
/// only ever speaks the graph's types.
|
|
||||||
fn narrow_shader_fields(fields: &mut [ParsedField]) -> syn::Result<()> {
|
|
||||||
for field in fields.iter_mut() {
|
|
||||||
let Some(regular) = field.ty.regular() else { continue };
|
|
||||||
let declared = regular.ty.clone();
|
|
||||||
|
|
||||||
if peel_list(&declared).is_some() {
|
|
||||||
return Err(Error::new_spanned(
|
|
||||||
&declared,
|
|
||||||
"A per-pixel shader node cannot take a `List` parameter, since its values ride in a uniform buffer and the shader cannot allocate; declare an `Item` instead",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let element = peel_item(&declared).unwrap_or_else(|| declared.clone());
|
|
||||||
if is_primitive_type(&element, "f32") || is_primitive_type(&element, "i32") {
|
|
||||||
return Err(Error::new_spanned(
|
|
||||||
&declared,
|
|
||||||
"A shader node's parameters are declared as `f64` or `i64`, the graph's Number and Integer types; the macro narrows them to the `f32` or `i32` the shader computes with",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let counterpart: Type = if is_primitive_type(&element, "f64") {
|
|
||||||
parse_quote!(f32)
|
|
||||||
} else if is_primitive_type(&element, "i64") {
|
|
||||||
parse_quote!(i32)
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let body_ty = if peel_item(&declared).is_some() {
|
|
||||||
replace_wrapper_element(&declared, counterpart)
|
|
||||||
} else {
|
|
||||||
counterpart
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut regular = regular.clone();
|
|
||||||
regular.narrowed_body_ty = Some(body_ty);
|
|
||||||
field.ty = ParsedFieldType::classify(regular);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Swaps the element type inside a wrapper like `Item<T>`, keeping the wrapper's path as it was written.
|
|
||||||
fn replace_wrapper_element(ty: &Type, element: Type) -> Type {
|
|
||||||
let mut ty = ty.clone();
|
|
||||||
if let Type::Path(type_path) = &mut ty
|
|
||||||
&& let Some(segment) = type_path.path.segments.last_mut()
|
|
||||||
&& let syn::PathArguments::AngleBracketed(arguments) = &mut segment.arguments
|
|
||||||
&& let Some(syn::GenericArgument::Type(inner)) = arguments.args.first_mut()
|
|
||||||
{
|
|
||||||
*inner = element;
|
|
||||||
}
|
|
||||||
ty
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_primitive_type(ty: &Type, name: &str) -> bool {
|
|
||||||
let Type::Path(type_path) = ty else { return false };
|
|
||||||
type_path.path.segments.last().is_some_and(|segment| segment.ident == name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_integer_type(ty: &Type) -> bool {
|
fn is_integer_type(ty: &Type) -> bool {
|
||||||
let Type::Path(type_path) = ty else { return false };
|
let Type::Path(type_path) = ty else { return false };
|
||||||
let Some(segment) = type_path.path.segments.last() else { return false };
|
let Some(segment) = type_path.path.segments.last() else { return false };
|
||||||
@@ -1455,8 +1349,6 @@ mod tests {
|
|||||||
number_hard_max: None,
|
number_hard_max: None,
|
||||||
number_mode_range: false,
|
number_mode_range: false,
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -1542,8 +1434,6 @@ mod tests {
|
|||||||
number_hard_max: None,
|
number_hard_max: None,
|
||||||
number_mode_range: false,
|
number_mode_range: false,
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -1607,8 +1497,6 @@ mod tests {
|
|||||||
number_hard_max: None,
|
number_hard_max: None,
|
||||||
number_mode_range: false,
|
number_mode_range: false,
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -1675,8 +1563,6 @@ mod tests {
|
|||||||
p.push(parse_quote!(f64));
|
p.push(parse_quote!(f64));
|
||||||
p
|
p
|
||||||
},
|
},
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -1746,8 +1632,6 @@ mod tests {
|
|||||||
number_hard_max: Some(parse_quote!(500)),
|
number_hard_max: Some(parse_quote!(500)),
|
||||||
number_mode_range: true,
|
number_mode_range: true,
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -1824,8 +1708,6 @@ mod tests {
|
|||||||
number_hard_max: None,
|
number_hard_max: None,
|
||||||
number_mode_range: false,
|
number_mode_range: false,
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
}),
|
||||||
number_display_decimal_places: None,
|
number_display_decimal_places: None,
|
||||||
number_step: None,
|
number_step: None,
|
||||||
@@ -2003,56 +1885,6 @@ mod tests {
|
|||||||
assert_eq!(error.span().start(), problem_span.start());
|
assert_eq!(error.span().start(), problem_span.start());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_shader_node_parameters_narrow_for_the_body() {
|
|
||||||
let attr = quote!(category("Raster: Adjustment"), shader_node(PerPixelAdjust));
|
|
||||||
let input = quote!(
|
|
||||||
fn adjust<T: Adjust<Color>>(_: impl Ctx, #[gpu_image] image: Item<T>, amount: Item<f64>, scale: f64, steps: Item<i64>) -> Item<T> {
|
|
||||||
image
|
|
||||||
}
|
|
||||||
);
|
|
||||||
let parsed = parse_node_fn(attr.clone(), input).unwrap();
|
|
||||||
|
|
||||||
let types = |index: usize| {
|
|
||||||
let regular = parsed.fields[index].ty.regular().unwrap();
|
|
||||||
let body = regular.narrowed_body_ty.as_ref().map(|ty| ty.to_token_stream().to_string());
|
|
||||||
(regular.ty.to_token_stream().to_string(), body)
|
|
||||||
};
|
|
||||||
assert_eq!(types(0), ("Item < T >".to_string(), None), "the image parameter is left alone");
|
|
||||||
assert_eq!(
|
|
||||||
types(1),
|
|
||||||
("Item < f64 >".to_string(), Some("Item < f32 >".to_string())),
|
|
||||||
"an Item<f64> stays on the wire and reaches the body as Item<f32>"
|
|
||||||
);
|
|
||||||
assert_eq!(types(2), ("f64".to_string(), Some("f32".to_string())), "a bare f64 reaches the body as f32");
|
|
||||||
assert_eq!(
|
|
||||||
types(3),
|
|
||||||
("Item < i64 >".to_string(), Some("Item < i32 >".to_string())),
|
|
||||||
"an Item<i64> stays on the wire and reaches the body as Item<i32>"
|
|
||||||
);
|
|
||||||
|
|
||||||
let declared_f32 = quote!(
|
|
||||||
fn adjust<T: Adjust<Color>>(_: impl Ctx, #[gpu_image] image: Item<T>, amount: Item<f32>) -> Item<T> {
|
|
||||||
image
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(parse_node_fn(attr.clone(), declared_f32).is_err(), "a shader node must not declare f32 itself");
|
|
||||||
|
|
||||||
let declared_i32 = quote!(
|
|
||||||
fn adjust<T: Adjust<Color>>(_: impl Ctx, #[gpu_image] image: Item<T>, steps: Item<i32>) -> Item<T> {
|
|
||||||
image
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(parse_node_fn(attr.clone(), declared_i32).is_err(), "a shader node must not declare i32 itself");
|
|
||||||
|
|
||||||
let declared_list = quote!(
|
|
||||||
fn adjust<T: Adjust<Color>>(_: impl Ctx, #[gpu_image] image: Item<T>, amounts: List<f64>) -> Item<T> {
|
|
||||||
image
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert!(parse_node_fn(attr, declared_list).is_err(), "a uniform cannot carry a List");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_kernel_is_classified_by_its_declared_return_type() {
|
fn a_kernel_is_classified_by_its_declared_return_type() {
|
||||||
let payload: Type = parse_quote!(Item<u32>);
|
let payload: Type = parse_quote!(Item<u32>);
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
use crate::crate_ident::CrateIdent;
|
|
||||||
use crate::parsing::{NodeFnAttributes, ParsedNodeFn};
|
|
||||||
use crate::shader_nodes::per_pixel_adjust::PerPixelAdjust;
|
|
||||||
use proc_macro2::{Ident, TokenStream};
|
|
||||||
use quote::quote;
|
|
||||||
use strum::VariantNames;
|
|
||||||
use syn::parse::{Parse, ParseStream};
|
|
||||||
use syn::punctuated::Punctuated;
|
|
||||||
use syn::{Error, Token};
|
|
||||||
|
|
||||||
pub mod per_pixel_adjust;
|
|
||||||
|
|
||||||
pub const STD_FEATURE_GATE: &str = "std";
|
|
||||||
pub const SHADER_NODES_FEATURE_GATE: &str = "shader-nodes";
|
|
||||||
|
|
||||||
pub fn modify_cfg(attributes: &NodeFnAttributes) -> TokenStream {
|
|
||||||
let feature_gate = match &attributes.shader_node {
|
|
||||||
// shader node cfg is done on the mod
|
|
||||||
Some(ShaderNodeType::ShaderNode) => quote!(),
|
|
||||||
Some(_) => quote!(feature = #STD_FEATURE_GATE),
|
|
||||||
None => quote!(),
|
|
||||||
};
|
|
||||||
let cfgs: Punctuated<_, Token![,]> = match &attributes.cfg {
|
|
||||||
None => [&feature_gate].into_iter().collect(),
|
|
||||||
Some(cfg) => [cfg, &feature_gate].into_iter().collect(),
|
|
||||||
};
|
|
||||||
quote!(#[cfg(all(#cfgs))])
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, VariantNames)]
|
|
||||||
pub(crate) enum ShaderNodeType {
|
|
||||||
/// Marker for this node being in a gpu node crate, but not having a gpu implementation. This is distinct from not
|
|
||||||
/// declaring `shader_node` at all, as it will wrap the CPU node with a `#[cfg(feature = "std")]` feature gate.
|
|
||||||
None,
|
|
||||||
/// Marker for this node being a generated gpu node implementation, that should not emit anything to prevent
|
|
||||||
/// recursively generating more gpu nodes. But it still counts as a gpu node and will get the
|
|
||||||
/// `#[cfg(feature = "std")]` feature gate around it's impl.
|
|
||||||
ShaderNode,
|
|
||||||
/// A per-pixel color adjustment compiled to a fragment shader. Its parameters are declared `f64` and `i64` like the rest
|
|
||||||
/// of the catalog, and the fn is emitted a second time with their `f32` and `i32` counterparts for the shader build.
|
|
||||||
PerPixelAdjust(PerPixelAdjust),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for ShaderNodeType {
|
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
|
||||||
let ident: Ident = input.parse()?;
|
|
||||||
Ok(match ident.to_string().as_str() {
|
|
||||||
"None" => ShaderNodeType::None,
|
|
||||||
"PerPixelAdjust" => ShaderNodeType::PerPixelAdjust(PerPixelAdjust::parse(input)?),
|
|
||||||
_ => return Err(Error::new_spanned(&ident, format!("attr 'shader_node' must be one of {:?}", Self::VARIANTS))),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ShaderCodegen {
|
|
||||||
fn codegen(&self, crate_ident: &CrateIdent, parsed: &ParsedNodeFn) -> syn::Result<ShaderTokens>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShaderCodegen for ShaderNodeType {
|
|
||||||
fn codegen(&self, crate_ident: &CrateIdent, parsed: &ParsedNodeFn) -> syn::Result<ShaderTokens> {
|
|
||||||
match self {
|
|
||||||
ShaderNodeType::None | ShaderNodeType::ShaderNode => (),
|
|
||||||
_ => {
|
|
||||||
if parsed.is_async {
|
|
||||||
return Err(Error::new_spanned(&parsed.fn_name, "Shader nodes must not be async"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match self {
|
|
||||||
ShaderNodeType::None | ShaderNodeType::ShaderNode => Ok(ShaderTokens::default()),
|
|
||||||
ShaderNodeType::PerPixelAdjust(x) => x.codegen(crate_ident, parsed),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
|
||||||
pub struct ShaderTokens {
|
|
||||||
pub shader_entry_point: TokenStream,
|
|
||||||
pub gpu_node: TokenStream,
|
|
||||||
}
|
|
||||||
@@ -1,391 +0,0 @@
|
|||||||
use crate::crate_ident::CrateIdent;
|
|
||||||
use crate::parsing::{Input, NodeFnAttributes, ParsedField, ParsedFieldType, ParsedNodeFn, ParsedValueSource, RegularParsedField, peel_item};
|
|
||||||
use crate::shader_nodes::{SHADER_NODES_FEATURE_GATE, ShaderCodegen, ShaderNodeType, ShaderTokens};
|
|
||||||
use convert_case::{Case, Casing};
|
|
||||||
use proc_macro2::{Ident, Span, TokenStream};
|
|
||||||
use quote::{ToTokens, format_ident, quote};
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use syn::parse::{Parse, ParseStream};
|
|
||||||
use syn::punctuated::Punctuated;
|
|
||||||
use syn::{LitStr, PatIdent, Type, parse_quote};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct PerPixelAdjust {}
|
|
||||||
|
|
||||||
impl Parse for PerPixelAdjust {
|
|
||||||
fn parse(_input: ParseStream) -> syn::Result<Self> {
|
|
||||||
Ok(Self {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ShaderCodegen for PerPixelAdjust {
|
|
||||||
fn codegen(&self, crate_ident: &CrateIdent, parsed: &ParsedNodeFn) -> syn::Result<ShaderTokens> {
|
|
||||||
let fn_name = &parsed.fn_name;
|
|
||||||
|
|
||||||
let mut params;
|
|
||||||
let has_uniform;
|
|
||||||
{
|
|
||||||
// categorize params
|
|
||||||
params = parsed
|
|
||||||
.fields
|
|
||||||
.iter()
|
|
||||||
.map(|f| {
|
|
||||||
let ident = &f.pat_ident;
|
|
||||||
if let ParsedFieldType::Node { .. } = &f.ty {
|
|
||||||
return Err(syn::Error::new_spanned(ident, "PerPixelAdjust shader nodes cannot accept other nodes as generics"));
|
|
||||||
}
|
|
||||||
let regular = f.ty.regular().expect("a non-node shader field is a value field");
|
|
||||||
// Ranked connectors carry their bare element type in the uniform buffer and get rewrapped in the entry point
|
|
||||||
let element_ty = f.ty.item_element();
|
|
||||||
if regular.gpu_image {
|
|
||||||
Ok(Param {
|
|
||||||
ident: Cow::Owned(format_ident!("image_{}", &ident.ident)),
|
|
||||||
ty: quote!(Image2d),
|
|
||||||
item_wrapped: element_ty.is_some(),
|
|
||||||
narrowed: false,
|
|
||||||
param_type: ParamType::Image { binding: 0 },
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// The uniform holds the 32-bit types the shader computes with, so a parameter declared f64 or i64 takes its counterpart here
|
|
||||||
let body_ty = regular.body_ty();
|
|
||||||
Ok(Param {
|
|
||||||
ident: Cow::Borrowed(&ident.ident),
|
|
||||||
item_wrapped: element_ty.is_some(),
|
|
||||||
narrowed: regular.narrowed_body_ty.is_some(),
|
|
||||||
ty: peel_item(body_ty).unwrap_or_else(|| body_ty.clone()).to_token_stream(),
|
|
||||||
param_type: ParamType::Uniform,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<syn::Result<Vec<_>>>()?;
|
|
||||||
|
|
||||||
has_uniform = params.iter().any(|p| matches!(p.param_type, ParamType::Uniform));
|
|
||||||
|
|
||||||
// assign image bindings
|
|
||||||
// if an arg_buffer exists, bindings for images start at 1 to leave 0 for arg buffer
|
|
||||||
let mut binding_cnt = if has_uniform { 1 } else { 0 };
|
|
||||||
for p in params.iter_mut() {
|
|
||||||
match &mut p.param_type {
|
|
||||||
ParamType::Image { binding } => {
|
|
||||||
*binding = binding_cnt;
|
|
||||||
binding_cnt += 1;
|
|
||||||
}
|
|
||||||
ParamType::Uniform => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let entry_point_mod = format_ident!("{}_gpu", fn_name);
|
|
||||||
let entry_point_name_ident = format_ident!("ENTRY_POINT_NAME");
|
|
||||||
let entry_point_name = quote!(#entry_point_mod::#entry_point_name_ident);
|
|
||||||
let uniform_struct_ident = format_ident!("Uniform");
|
|
||||||
let uniform_struct = quote!(#entry_point_mod::#uniform_struct_ident);
|
|
||||||
let shader_node_mod = format_ident!("{}_shader_node", fn_name);
|
|
||||||
|
|
||||||
let codegen = PerPixelAdjustCodegen {
|
|
||||||
crate_ident,
|
|
||||||
parsed,
|
|
||||||
params,
|
|
||||||
has_uniform,
|
|
||||||
entry_point_mod,
|
|
||||||
entry_point_name_ident,
|
|
||||||
entry_point_name,
|
|
||||||
uniform_struct_ident,
|
|
||||||
uniform_struct,
|
|
||||||
shader_node_mod,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(ShaderTokens {
|
|
||||||
shader_entry_point: codegen.codegen_shader_entry_point()?,
|
|
||||||
gpu_node: codegen.codegen_gpu_node()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PerPixelAdjustCodegen<'a> {
|
|
||||||
crate_ident: &'a CrateIdent,
|
|
||||||
parsed: &'a ParsedNodeFn,
|
|
||||||
params: Vec<Param<'a>>,
|
|
||||||
has_uniform: bool,
|
|
||||||
entry_point_mod: Ident,
|
|
||||||
entry_point_name_ident: Ident,
|
|
||||||
entry_point_name: TokenStream,
|
|
||||||
uniform_struct_ident: Ident,
|
|
||||||
uniform_struct: TokenStream,
|
|
||||||
shader_node_mod: Ident,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PerPixelAdjustCodegen<'_> {
|
|
||||||
fn codegen_shader_entry_point(&self) -> syn::Result<TokenStream> {
|
|
||||||
let fn_name = &self.parsed.fn_name;
|
|
||||||
let gcore_shaders = self.crate_ident.gcore_shaders()?;
|
|
||||||
let reexport = quote!(#gcore_shaders::shaders::__private);
|
|
||||||
|
|
||||||
let uniform_members = self
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.filter_map(|Param { ident, ty, param_type, .. }| match param_type {
|
|
||||||
ParamType::Image { .. } => None,
|
|
||||||
ParamType::Uniform => Some(quote! {#ident: #ty}),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let uniform_struct_ident = &self.uniform_struct_ident;
|
|
||||||
let uniform_struct = parse_quote! {
|
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct #uniform_struct_ident {
|
|
||||||
#(pub #uniform_members),*
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let uniform_struct_shader_struct_derive = crate::buffer_struct::derive_buffer_struct_struct(self.crate_ident, &uniform_struct)?;
|
|
||||||
|
|
||||||
let image_params = self
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.filter_map(|Param { ident, ty, param_type, .. }| match param_type {
|
|
||||||
ParamType::Image { binding } => Some(quote! {#[spirv(descriptor_set = 0, binding = #binding)] #ident: &#ty}),
|
|
||||||
ParamType::Uniform => None,
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
// Ranked connectors compile against the no_std `Item` stand-in on the GPU, so wrapping and unwrapping here is free.
|
|
||||||
// A narrowed uniform casts to whichever width the fn variant being compiled takes: f32 for the shader, f64 on the CPU.
|
|
||||||
let call_args = self
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.map(|param| {
|
|
||||||
let Param {
|
|
||||||
ident,
|
|
||||||
param_type,
|
|
||||||
item_wrapped,
|
|
||||||
narrowed,
|
|
||||||
..
|
|
||||||
} = param;
|
|
||||||
let bare_value = match param_type {
|
|
||||||
ParamType::Image { .. } => quote!(Color::from_vec4(#ident.fetch_with(texel_coord, lod(0)))),
|
|
||||||
ParamType::Uniform if *narrowed => quote!(uniform.#ident as _),
|
|
||||||
ParamType::Uniform => quote!(uniform.#ident),
|
|
||||||
};
|
|
||||||
if *item_wrapped { quote!(Item::new_from_element(#bare_value)) } else { bare_value }
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let unwrap_result = self.parsed.output_element.as_ref().map(|_| quote!(.into_element()));
|
|
||||||
let context = quote!(());
|
|
||||||
|
|
||||||
let entry_point_mod = &self.entry_point_mod;
|
|
||||||
let entry_point_name = &self.entry_point_name_ident;
|
|
||||||
Ok(quote! {
|
|
||||||
pub mod #entry_point_mod {
|
|
||||||
use super::*;
|
|
||||||
use #gcore_shaders::color::Color;
|
|
||||||
use #reexport::glam::{Vec4, Vec4Swizzles};
|
|
||||||
use #reexport::spirv_std::spirv;
|
|
||||||
use #reexport::spirv_std::image::{Image2d, ImageWithMethods};
|
|
||||||
use #reexport::spirv_std::image::sample_with::lod;
|
|
||||||
|
|
||||||
pub const #entry_point_name: &str = core::concat!(core::module_path!(), "::entry_point");
|
|
||||||
|
|
||||||
#uniform_struct
|
|
||||||
#uniform_struct_shader_struct_derive
|
|
||||||
|
|
||||||
#[spirv(fragment)]
|
|
||||||
pub fn entry_point(
|
|
||||||
#[spirv(frag_coord)] frag_coord: Vec4,
|
|
||||||
color_out: &mut Vec4,
|
|
||||||
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] uniform: &UniformBuffer,
|
|
||||||
#(#image_params),*
|
|
||||||
) {
|
|
||||||
let uniform = <Uniform as #gcore_shaders::shaders::buffer_struct::BufferStruct>::read(*uniform);
|
|
||||||
let texel_coord = frag_coord.xy().as_uvec2();
|
|
||||||
let color: Color = #fn_name(#context, #(#call_args),*)#unwrap_result;
|
|
||||||
*color_out = color.to_vec4();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn codegen_gpu_node(&self) -> syn::Result<TokenStream> {
|
|
||||||
let gcore = self.crate_ident.gcore()?;
|
|
||||||
let raster_types = self.crate_ident.raster_types()?;
|
|
||||||
let wgpu_executor = self.crate_ident.wgpu_executor()?;
|
|
||||||
|
|
||||||
// adapt fields for gpu node
|
|
||||||
let raster_gpu: Type = parse_quote!(#gcore::list::List<#raster_types::Raster<#raster_types::GPU>>);
|
|
||||||
let mut fields = self
|
|
||||||
.parsed
|
|
||||||
.fields
|
|
||||||
.iter()
|
|
||||||
.map(|f| {
|
|
||||||
if let ParsedFieldType::Node { .. } = &f.ty {
|
|
||||||
return Err(syn::Error::new_spanned(&f.pat_ident, "PerPixelAdjust shader nodes cannot accept other nodes as generics"));
|
|
||||||
}
|
|
||||||
let regular = f.ty.regular().expect("a non-node shader field is a value field");
|
|
||||||
let pat_ident = PatIdent {
|
|
||||||
mutability: None,
|
|
||||||
by_ref: None,
|
|
||||||
..f.pat_ident.clone()
|
|
||||||
};
|
|
||||||
// A gpu_image parameter is fed the whole GPU raster list, so its wire is re-typed and re-classified
|
|
||||||
let ty = if regular.gpu_image {
|
|
||||||
ParsedFieldType::classify(RegularParsedField {
|
|
||||||
ty: raster_gpu.clone(),
|
|
||||||
implementations: Punctuated::default(),
|
|
||||||
..regular.clone()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ParsedFieldType::classify(RegularParsedField {
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
..regular.clone()
|
|
||||||
})
|
|
||||||
};
|
|
||||||
Ok(ParsedField { pat_ident, ty, ..f.clone() })
|
|
||||||
})
|
|
||||||
.collect::<syn::Result<Vec<_>>>()?;
|
|
||||||
|
|
||||||
// insert wgpu_executor field
|
|
||||||
let executor = format_ident!("__wgpu_executor");
|
|
||||||
fields.push(ParsedField {
|
|
||||||
pat_ident: PatIdent {
|
|
||||||
attrs: vec![],
|
|
||||||
by_ref: None,
|
|
||||||
mutability: None,
|
|
||||||
ident: parse_quote!(#executor),
|
|
||||||
subpat: None,
|
|
||||||
},
|
|
||||||
name: None,
|
|
||||||
description: "".to_string(),
|
|
||||||
widget_override: Default::default(),
|
|
||||||
ty: ParsedFieldType::classify(RegularParsedField {
|
|
||||||
ty: parse_quote!(#gcore::list::Item<WgpuExecutor>),
|
|
||||||
exposed: true,
|
|
||||||
value_source: ParsedValueSource::Scope(Box::new(parse_quote!("graphene_std::platform_application_io::WgpuExecutorNode"))),
|
|
||||||
number_soft_min: None,
|
|
||||||
number_soft_max: None,
|
|
||||||
number_hard_min: None,
|
|
||||||
number_hard_max: None,
|
|
||||||
number_mode_range: false,
|
|
||||||
implementations: Default::default(),
|
|
||||||
gpu_image: false,
|
|
||||||
narrowed_body_ty: None,
|
|
||||||
}),
|
|
||||||
number_display_decimal_places: None,
|
|
||||||
number_step: None,
|
|
||||||
unit: None,
|
|
||||||
multiline: false,
|
|
||||||
progression: false,
|
|
||||||
constant: false,
|
|
||||||
is_data_field: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// find exactly one gpu_image field, runtime doesn't support more than 1 atm
|
|
||||||
let gpu_image_field = {
|
|
||||||
let mut iter = fields.iter().filter(|f| f.ty.regular().is_some_and(|regular| regular.gpu_image));
|
|
||||||
match (iter.next(), iter.next()) {
|
|
||||||
(Some(v), None) => Ok(v),
|
|
||||||
(Some(_), Some(more)) => Err(syn::Error::new_spanned(&more.pat_ident, "No more than one parameter must be annotated with `#[gpu_image]`")),
|
|
||||||
(None, _) => Err(syn::Error::new_spanned(&self.parsed.fn_name, "At least one parameter must be annotated with `#[gpu_image]`")),
|
|
||||||
}?
|
|
||||||
};
|
|
||||||
let gpu_image = &gpu_image_field.pat_ident.ident;
|
|
||||||
|
|
||||||
// uniform buffer struct construction
|
|
||||||
let has_uniform = self.has_uniform;
|
|
||||||
let uniform_buffer = if has_uniform {
|
|
||||||
let uniform_struct = &self.uniform_struct;
|
|
||||||
let uniform_members = self
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.filter_map(|p| match p.param_type {
|
|
||||||
ParamType::Image { .. } => None,
|
|
||||||
ParamType::Uniform => {
|
|
||||||
let ident = p.ident.as_ref();
|
|
||||||
let value = if p.item_wrapped { quote!(#ident.into_element()) } else { quote!(#ident) };
|
|
||||||
// A parameter declared f64 or i64 narrows to the shader's 32-bit counterpart as it enters the uniform; an
|
|
||||||
// integer saturates rather than wrapping, matching how the float overflows to infinity instead of flipping
|
|
||||||
let ty = &p.ty;
|
|
||||||
Some(match (p.narrowed, ty.to_string().as_str()) {
|
|
||||||
(true, "i32") => quote!(#ident: (#value).clamp(i32::MIN as _, i32::MAX as _) as i32),
|
|
||||||
(true, _) => quote!(#ident: #value as #ty),
|
|
||||||
(false, _) => quote!(#ident: #value),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
quote!(Some(&super::#uniform_struct {
|
|
||||||
#(#uniform_members),*
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
// explicit generics placed here cause it's easier than explicitly writing `run_per_pixel_adjust::<()>`
|
|
||||||
quote!(Option::<&()>::None)
|
|
||||||
};
|
|
||||||
|
|
||||||
// node function body
|
|
||||||
let entry_point_name = &self.entry_point_name;
|
|
||||||
let body = quote! {
|
|
||||||
{
|
|
||||||
#executor.into_element().run_per_pixel_adjust(&::wgpu_executor::shader_runtime::per_pixel_adjust_runtime::Shaders {
|
|
||||||
wgsl_shader: crate::WGSL_SHADER,
|
|
||||||
fragment_shader_name: super::#entry_point_name,
|
|
||||||
has_uniform: #has_uniform,
|
|
||||||
}, #gpu_image, #uniform_buffer)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// call node codegen
|
|
||||||
let display_name = self.parsed.attributes.display_name.clone();
|
|
||||||
let display_name = display_name.unwrap_or_else(|| LitStr::new(&self.shader_node_mod.to_string().strip_suffix("_shader_node").unwrap().to_case(Case::Title), Span::call_site()));
|
|
||||||
let display_name = LitStr::new(&format!("{} GPU", display_name.value()), display_name.span());
|
|
||||||
let mut parsed_node_fn = ParsedNodeFn {
|
|
||||||
vis: self.parsed.vis.clone(),
|
|
||||||
attributes: NodeFnAttributes {
|
|
||||||
display_name: Some(display_name),
|
|
||||||
shader_node: Some(ShaderNodeType::ShaderNode),
|
|
||||||
..self.parsed.attributes.clone()
|
|
||||||
},
|
|
||||||
fn_name: self.shader_node_mod.clone(),
|
|
||||||
struct_name: format_ident!("{}", self.shader_node_mod.to_string().to_case(Case::Pascal)),
|
|
||||||
mod_name: self.shader_node_mod.clone(),
|
|
||||||
fn_generics: Vec::new(),
|
|
||||||
where_clause: None,
|
|
||||||
input: Input {
|
|
||||||
pat_ident: self.parsed.input.pat_ident.clone(),
|
|
||||||
ty: parse_quote!(impl #gcore::context::Ctx),
|
|
||||||
implementations: Default::default(),
|
|
||||||
context_features: self.parsed.input.context_features.clone(),
|
|
||||||
},
|
|
||||||
output_type: raster_gpu,
|
|
||||||
output_element: None,
|
|
||||||
is_async: false,
|
|
||||||
fields,
|
|
||||||
body,
|
|
||||||
description: self.parsed.description.clone(),
|
|
||||||
};
|
|
||||||
parsed_node_fn.replace_impl_trait_in_input();
|
|
||||||
let gpu_node_impl = crate::codegen::generate_node_code(self.crate_ident, &parsed_node_fn)?;
|
|
||||||
|
|
||||||
// wrap node in `mod #gpu_node_mod`
|
|
||||||
let shader_node_mod = &self.shader_node_mod;
|
|
||||||
Ok(quote! {
|
|
||||||
#[cfg(feature = #SHADER_NODES_FEATURE_GATE)]
|
|
||||||
mod #shader_node_mod {
|
|
||||||
use super::*;
|
|
||||||
use #wgpu_executor::WgpuExecutor;
|
|
||||||
|
|
||||||
#gpu_node_impl
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Param<'a> {
|
|
||||||
ident: Cow<'a, Ident>,
|
|
||||||
ty: TokenStream,
|
|
||||||
item_wrapped: bool,
|
|
||||||
/// Whether the parameter is declared `f64` or `i64` and narrows to the shader's 32-bit counterpart as it enters the uniform.
|
|
||||||
narrowed: bool,
|
|
||||||
param_type: ParamType,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ParamType {
|
|
||||||
Image { binding: u32 },
|
|
||||||
Uniform,
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ use vector_types::Gradient;
|
|||||||
fn blend_mode<T>(
|
fn blend_mode<T>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The content that will be composited when rendering.
|
/// The content that will be composited when rendering.
|
||||||
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, Gradient, String)]
|
#[implementations(Graphic, Vector, Raster<GPU>, Raster<CPU>, Color, Gradient, String)]
|
||||||
content: Item<T>,
|
content: Item<T>,
|
||||||
/// The choice of equation that controls how brightness and color blends between overlapping pixels.
|
/// The choice of equation that controls how brightness and color blends between overlapping pixels.
|
||||||
blend_mode: Item<BlendMode>,
|
blend_mode: Item<BlendMode>,
|
||||||
@@ -29,7 +29,7 @@ fn blend_mode<T>(
|
|||||||
fn opacity<T>(
|
fn opacity<T>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The content that will be composited when rendering.
|
/// The content that will be composited when rendering.
|
||||||
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, Gradient, String)]
|
#[implementations(Graphic, Vector, Raster<GPU>, Raster<CPU>, Color, Gradient, String)]
|
||||||
content: Item<T>,
|
content: Item<T>,
|
||||||
/// Whether the *Opacity* property is enabled, multiplying the existing opacity by the chosen percentage.
|
/// Whether the *Opacity* property is enabled, multiplying the existing opacity by the chosen percentage.
|
||||||
#[widget(ParsedWidgetOverride::Hidden)]
|
#[widget(ParsedWidgetOverride::Hidden)]
|
||||||
@@ -76,7 +76,7 @@ fn opacity<T>(
|
|||||||
fn clipping_mask<T>(
|
fn clipping_mask<T>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The content that will be composited when rendering.
|
/// The content that will be composited when rendering.
|
||||||
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, Gradient, String)]
|
#[implementations(Graphic, Vector, Raster<GPU>, Raster<CPU>, Color, Gradient, String)]
|
||||||
content: Item<T>,
|
content: Item<T>,
|
||||||
/// Whether the content inherits the alpha of the content beneath it.
|
/// Whether the content inherits the alpha of the content beneath it.
|
||||||
clip: Item<bool>,
|
clip: Item<bool>,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ pub(super) struct Convert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Convert {
|
impl Convert {
|
||||||
pub(super) fn new(device: &wgpu::Device) -> Self {
|
pub(super) fn new(device: &wgpu::Device, raster_format: wgpu::TextureFormat) -> Self {
|
||||||
let shader = device.create_shader_module(wgpu::include_wgsl!("convert.wgsl"));
|
let shader = device.create_shader_module(wgpu::include_wgsl!("convert.wgsl"));
|
||||||
let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
label: Some("basic_brush_convert_bind_group_layout"),
|
label: Some("basic_brush_convert_bind_group_layout"),
|
||||||
@@ -37,7 +37,7 @@ impl Convert {
|
|||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: Some("fs_main"),
|
entry_point: Some("fs_main"),
|
||||||
compilation_options: Default::default(),
|
compilation_options: Default::default(),
|
||||||
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
|
targets: &[Some(raster_format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<
|
|||||||
@group(0) @binding(0)
|
@group(0) @binding(0)
|
||||||
var t_composite: texture_2d<f32>;
|
var t_composite: texture_2d<f32>;
|
||||||
|
|
||||||
fn linear_to_srgb(channel: f32) -> f32 {
|
|
||||||
if (channel <= 0.0031308) {
|
|
||||||
return channel * 12.92;
|
|
||||||
}
|
|
||||||
return 1.055 * pow(channel, 1.0 / 2.4) - 0.055;
|
|
||||||
}
|
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn fs_main(@builtin(position) frag: vec4<f32>) -> @location(0) vec4<f32> {
|
fn fs_main(@builtin(position) frag: vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
let premultiplied = textureLoad(t_composite, vec2<i32>(frag.xy), 0);
|
let premultiplied = textureLoad(t_composite, vec2<i32>(frag.xy), 0);
|
||||||
@@ -33,5 +26,5 @@ fn fs_main(@builtin(position) frag: vec4<f32>) -> @location(0) vec4<f32> {
|
|||||||
if (premultiplied.a > 0.0) {
|
if (premultiplied.a > 0.0) {
|
||||||
straight = premultiplied.rgb / premultiplied.a;
|
straight = premultiplied.rgb / premultiplied.a;
|
||||||
}
|
}
|
||||||
return vec4<f32>(linear_to_srgb(straight.r), linear_to_srgb(straight.g), linear_to_srgb(straight.b), premultiplied.a);
|
return vec4<f32>(straight, premultiplied.a);
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ mod stroke;
|
|||||||
use brush_types::BrushCache;
|
use brush_types::BrushCache;
|
||||||
use core_types::list::{ATTR_COLOR, ATTR_DIAMETER, ATTR_FLOW, ATTR_HARDNESS, Item, List};
|
use core_types::list::{ATTR_COLOR, ATTR_DIAMETER, ATTR_FLOW, ATTR_HARDNESS, Item, List};
|
||||||
use core_types::{ATTR_TRANSFORM, Ctx, ExtractFootprint};
|
use core_types::{ATTR_TRANSFORM, Ctx, ExtractFootprint};
|
||||||
|
use glam::DAffine2;
|
||||||
use graphic_types::Graphic;
|
use graphic_types::Graphic;
|
||||||
use pipeline::{BasicBrushPipeline, BasicBrushPipelineArgs};
|
use pipeline::{BasicBrushPipeline, BasicBrushPipelineArgs};
|
||||||
use raster_types::{GPU, Raster};
|
use raster_types::{GPU, Raster};
|
||||||
@@ -52,16 +53,26 @@ fn basic_brush(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut logical_bounds = None;
|
||||||
|
for stroke in &strokes {
|
||||||
|
stroke::union(&mut logical_bounds, stroke::bounds(stroke, 1.));
|
||||||
|
}
|
||||||
|
let logical_transform = logical_bounds.as_ref().map_or(DAffine2::IDENTITY, |bounds| bounds.to_transform());
|
||||||
|
|
||||||
let args = BasicBrushPipelineArgs {
|
let args = BasicBrushPipelineArgs {
|
||||||
footprint: *ctx.footprint(),
|
footprint: *ctx.footprint(),
|
||||||
strokes: &strokes,
|
strokes: &strokes,
|
||||||
cache: &cache,
|
cache: &cache,
|
||||||
};
|
};
|
||||||
let Some((texture, transform)) = pipeline.run::<BasicBrushPipeline>(&args) else {
|
let Some((texture, transform)) = pipeline.run::<BasicBrushPipeline>(&args) else {
|
||||||
return List::new();
|
return if logical_bounds.is_some() {
|
||||||
|
List::new_from_item(Item::<Raster<GPU>>::default().with_attribute(ATTR_TRANSFORM, logical_transform))
|
||||||
|
} else {
|
||||||
|
List::new()
|
||||||
|
};
|
||||||
};
|
};
|
||||||
let raster = Raster::<GPU>::new_gpu(texture);
|
let raster = Raster::<GPU>::new_gpu(texture).with_coverage(logical_transform.inverse() * transform);
|
||||||
List::new_from_item(Item::new_from_element(raster).with_attribute(ATTR_TRANSFORM, transform))
|
List::new_from_item(Item::new_from_element(raster).with_attribute(ATTR_TRANSFORM, logical_transform))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category(""), inject_scope)]
|
#[node_macro::node(category(""), inject_scope)]
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ impl WgpuPipeline for BasicBrushPipeline {
|
|||||||
Self {
|
Self {
|
||||||
scatter: Scatter::new(device),
|
scatter: Scatter::new(device),
|
||||||
resolve: Resolve::new(device),
|
resolve: Resolve::new(device),
|
||||||
convert: Convert::new(device),
|
convert: Convert::new(device, executor.raster_format()),
|
||||||
kernels: KernelCache::default(),
|
kernels: KernelCache::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ pub(super) fn render(pipeline: &BasicBrushPipeline, executor: &WgpuExecutor, fra
|
|||||||
let updated = (!missing.is_empty()).then(|| executor.request_texture_with_format(crop.size, COMPOSITE_FORMAT));
|
let updated = (!missing.is_empty()).then(|| executor.request_texture_with_format(crop.size, COMPOSITE_FORMAT));
|
||||||
let composite = executor.request_texture_with_format(crop.size, COMPOSITE_FORMAT);
|
let composite = executor.request_texture_with_format(crop.size, COMPOSITE_FORMAT);
|
||||||
let scratch = Field::request(executor, region.size);
|
let scratch = Field::request(executor, region.size);
|
||||||
let output = executor.request_texture(crop.size);
|
let output = executor.request_texture_with_format(crop.size, executor.raster_format());
|
||||||
let mut recorder = Recorder::new(pipeline, executor, ®ion);
|
let mut recorder = Recorder::new(pipeline, executor, ®ion);
|
||||||
|
|
||||||
if let Some(updated) = &updated {
|
if let Some(updated) = &updated {
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ fn step_real_time<T>(
|
|||||||
Context -> Item<DVec2>,
|
Context -> Item<DVec2>,
|
||||||
Context -> Item<Vector>,
|
Context -> Item<Vector>,
|
||||||
Context -> Item<Graphic>,
|
Context -> Item<Graphic>,
|
||||||
Context -> Item<Raster<CPU>>,
|
|
||||||
Context -> Item<Raster<GPU>>,
|
Context -> Item<Raster<GPU>>,
|
||||||
|
Context -> Item<Raster<CPU>>,
|
||||||
Context -> Item<Color>,
|
Context -> Item<Color>,
|
||||||
Context -> Item<Gradient>,
|
Context -> Item<Gradient>,
|
||||||
Context -> Item<Artboard>,
|
Context -> Item<Artboard>,
|
||||||
@@ -95,8 +95,8 @@ fn step_real_time<T>(
|
|||||||
Context -> List<DVec2>,
|
Context -> List<DVec2>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Raster<CPU>>,
|
|
||||||
Context -> List<Raster<GPU>>,
|
Context -> List<Raster<GPU>>,
|
||||||
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
Context -> List<Artboard>,
|
Context -> List<Artboard>,
|
||||||
@@ -131,8 +131,8 @@ fn step_animation_time<T>(
|
|||||||
Context -> Item<DVec2>,
|
Context -> Item<DVec2>,
|
||||||
Context -> Item<Vector>,
|
Context -> Item<Vector>,
|
||||||
Context -> Item<Graphic>,
|
Context -> Item<Graphic>,
|
||||||
Context -> Item<Raster<CPU>>,
|
|
||||||
Context -> Item<Raster<GPU>>,
|
Context -> Item<Raster<GPU>>,
|
||||||
|
Context -> Item<Raster<CPU>>,
|
||||||
Context -> Item<Color>,
|
Context -> Item<Color>,
|
||||||
Context -> Item<Gradient>,
|
Context -> Item<Gradient>,
|
||||||
Context -> Item<Artboard>,
|
Context -> Item<Artboard>,
|
||||||
@@ -141,8 +141,8 @@ fn step_animation_time<T>(
|
|||||||
Context -> List<DVec2>,
|
Context -> List<DVec2>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Raster<CPU>>,
|
|
||||||
Context -> List<Raster<GPU>>,
|
Context -> List<Raster<GPU>>,
|
||||||
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
Context -> List<Artboard>,
|
Context -> List<Artboard>,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use core_types::{Ctx, ExtractIndex, ExtractPosition};
|
|||||||
use glam::DVec2;
|
use glam::DVec2;
|
||||||
use graphic_types::vector_types::Gradient;
|
use graphic_types::vector_types::Gradient;
|
||||||
use graphic_types::{Graphic, Vector};
|
use graphic_types::{Graphic, Vector};
|
||||||
use raster_types::{CPU, Raster};
|
use raster_types::{GPU, Raster};
|
||||||
|
|
||||||
#[node_macro::node(category("Data: Context"), icon("NodeReadContext"), path(graphene_core::vector))]
|
#[node_macro::node(category("Data: Context"), icon("NodeReadContext"), path(graphene_core::vector))]
|
||||||
fn read_graphic(ctx: impl Ctx + ExtractVarArgs) -> Item<Graphic> {
|
fn read_graphic(ctx: impl Ctx + ExtractVarArgs) -> Item<Graphic> {
|
||||||
@@ -23,7 +23,7 @@ fn read_vector(ctx: impl Ctx + ExtractVarArgs) -> Item<Vector> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Data: Context"), icon("NodeReadContext"), path(graphene_core::vector))]
|
#[node_macro::node(category("Data: Context"), icon("NodeReadContext"), path(graphene_core::vector))]
|
||||||
fn read_raster(ctx: impl Ctx + ExtractVarArgs) -> Item<Raster<CPU>> {
|
fn read_raster(ctx: impl Ctx + ExtractVarArgs) -> Item<Raster<GPU>> {
|
||||||
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
||||||
let var_arg = var_arg as &dyn std::any::Any;
|
let var_arg = var_arg as &dyn std::any::Any;
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ fn context_modification<T>(
|
|||||||
Context -> Item<DVec2>,
|
Context -> Item<DVec2>,
|
||||||
Context -> Item<Vector>,
|
Context -> Item<Vector>,
|
||||||
Context -> Item<Graphic>,
|
Context -> Item<Graphic>,
|
||||||
Context -> Item<Raster<CPU>>,
|
|
||||||
Context -> Item<Raster<GPU>>,
|
Context -> Item<Raster<GPU>>,
|
||||||
|
Context -> Item<Raster<CPU>>,
|
||||||
Context -> Item<Color>,
|
Context -> Item<Color>,
|
||||||
Context -> Item<Artboard>,
|
Context -> Item<Artboard>,
|
||||||
Context -> Item<Gradient>,
|
Context -> Item<Gradient>,
|
||||||
@@ -38,8 +38,8 @@ fn context_modification<T>(
|
|||||||
Context -> List<DVec2>,
|
Context -> List<DVec2>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Raster<CPU>>,
|
|
||||||
Context -> List<Raster<GPU>>,
|
Context -> List<Raster<GPU>>,
|
||||||
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Artboard>,
|
Context -> List<Artboard>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ fn create_artboard<T: IntoGraphicList>(
|
|||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
Context -> List<String>,
|
Context -> List<String>,
|
||||||
Context -> List<Raster<CPU>>,
|
|
||||||
Context -> List<Raster<GPU>>,
|
Context -> List<Raster<GPU>>,
|
||||||
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
Context -> Item<DAffine2>, // TODO: Remove this
|
Context -> Item<DAffine2>, // TODO: Remove this
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
use brush_types::Stroke;
|
use brush_types::Stroke;
|
||||||
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
use core_types::bounds::{BoundingBox, RenderBoundingBox};
|
||||||
use core_types::list::{AttributeValueDyn, Item, List, ListDyn, NodeIdPath};
|
use core_types::list::{AttributeValueDyn, Item, List, ListDyn, NodeIdPath};
|
||||||
use core_types::{ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_TRANSFORM, AnyHash, BlendMode, CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, Interrupt, OwnedContextImpl};
|
use core_types::{
|
||||||
|
ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_TRANSFORM, AnyHash, BlendMode, CacheHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, Interrupt, ModifyFootprint, OwnedContextImpl,
|
||||||
|
};
|
||||||
use glam::{DAffine2, DVec2};
|
use glam::{DAffine2, DVec2};
|
||||||
use graphic_types::graphic::{Graphic, IntoGraphicList, is_lone_anonymous_leaf};
|
use graphic_types::graphic::{Graphic, IntoGraphicList, is_lone_anonymous_leaf};
|
||||||
use graphic_types::{Artboard, Vector};
|
use graphic_types::{Artboard, Vector};
|
||||||
@@ -27,8 +29,8 @@ fn remove_at_index<T: graphic_types::graphic::OmitIndex + Clone + Default>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -61,6 +63,7 @@ fn item_at_index<T: Clone + Default + Send + Sync + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
|
List<Raster<GPU>>,
|
||||||
List<Raster<CPU>>,
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
@@ -98,8 +101,8 @@ fn filter<T: Send + Sync + Clone + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -131,8 +134,8 @@ fn reverse<T: Send + Sync + Clone + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -156,8 +159,8 @@ fn shift<T: Send + Sync + Clone + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -201,8 +204,8 @@ fn shuffle<T: Send + Sync + Clone + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -273,8 +276,8 @@ fn slice<T: Send + Sync + Clone + 'static>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -341,9 +344,9 @@ fn sort<T: ElementOrder + Clone + Send + Sync + 'static, U: ElementOrder + Send
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The list of data to reorder.
|
/// The list of data to reorder.
|
||||||
#[implementations(
|
#[implementations(
|
||||||
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<CPU>>, List<Raster<GPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<GPU>>, List<Raster<CPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
||||||
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<CPU>>, List<Raster<GPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<GPU>>, List<Raster<CPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
||||||
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<CPU>>, List<Raster<GPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
List<String>, List<bool>, List<f64>, List<i64>, List<DVec2>, List<DAffine2>, List<Vector>, List<Graphic>, List<Raster<GPU>>, List<Raster<CPU>>, List<Color>, List<Gradient>, List<Artboard>,
|
||||||
)]
|
)]
|
||||||
list: List<T>,
|
list: List<T>,
|
||||||
/// The optional list of orderable values, corresponding item-to-item with the input list, to sort by instead of the items' own values.
|
/// The optional list of orderable values, corresponding item-to-item with the input list, to sort by instead of the items' own values.
|
||||||
@@ -394,8 +397,8 @@ fn map<Item: AnyHash + Send + Sync + CacheHash + Clone>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -410,8 +413,8 @@ fn map<Item: AnyHash + Send + Sync + CacheHash + Clone>(
|
|||||||
Context -> List<DAffine2>,
|
Context -> List<DAffine2>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Raster<CPU>>,
|
|
||||||
Context -> List<Raster<GPU>>,
|
Context -> List<Raster<GPU>>,
|
||||||
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
Context -> List<Artboard>,
|
Context -> List<Artboard>,
|
||||||
@@ -432,18 +435,18 @@ fn map<Item: AnyHash + Send + Sync + CacheHash + Clone>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Graphic"), icon("NodeMirror"))]
|
#[node_macro::node(category("Graphic"), icon("NodeMirror"))]
|
||||||
fn mirror<T: BoundingBox + Send + Clone>(
|
fn mirror<T: BoundingBox + Send + Clone + 'static>(
|
||||||
_: impl Ctx,
|
ctx: impl Ctx + CloneVarArgs + ExtractAll + ModifyFootprint,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Graphic,
|
Context -> Item<Graphic>,
|
||||||
Vector,
|
Context -> Item<Vector>,
|
||||||
Raster<CPU>,
|
Context -> Item<Raster<GPU>>,
|
||||||
Raster<GPU>,
|
Context -> Item<Raster<CPU>>,
|
||||||
Color,
|
Context -> Item<Color>,
|
||||||
Gradient,
|
Context -> Item<Gradient>,
|
||||||
String,
|
Context -> Item<String>,
|
||||||
)]
|
)]
|
||||||
content: Item<T>,
|
content: impl Node<Context<'static>, Output = Item<T>>,
|
||||||
#[default(ReferencePoint::Center)] relative_to_bounds: Item<ReferencePoint>,
|
#[default(ReferencePoint::Center)] relative_to_bounds: Item<ReferencePoint>,
|
||||||
#[unit(" px")] offset: Item<f64>,
|
#[unit(" px")] offset: Item<f64>,
|
||||||
#[unit("°")]
|
#[unit("°")]
|
||||||
@@ -451,16 +454,45 @@ fn mirror<T: BoundingBox + Send + Clone>(
|
|||||||
#[soft(-90..90)]
|
#[soft(-90..90)]
|
||||||
angle: Item<f64>,
|
angle: Item<f64>,
|
||||||
#[default(true)] keep_original: Item<bool>,
|
#[default(true)] keep_original: Item<bool>,
|
||||||
) -> List<T> {
|
) -> Result<List<T>, Interrupt> {
|
||||||
let (relative_to_bounds, offset, angle, keep_original) = (relative_to_bounds.into_element(), offset.into_element(), angle.into_element(), keep_original.into_element());
|
let (relative_to_bounds, offset, angle, keep_original) = (relative_to_bounds.into_element(), offset.into_element(), angle.into_element(), keep_original.into_element());
|
||||||
|
|
||||||
|
let mut content_ctx = OwnedContextImpl::from(ctx.clone());
|
||||||
|
if ctx.try_footprint().is_some() {
|
||||||
|
let probe = content.eval(OwnedContextImpl::from(ctx.clone()).with_probe_footprint().into_context())?;
|
||||||
|
if let Some(reflected_transform) = mirror_reflection(&probe, relative_to_bounds, offset, angle) {
|
||||||
|
content_ctx = content_ctx.with_instances_footprint([DAffine2::IDENTITY, reflected_transform]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let content = content.eval(content_ctx.into_context())?;
|
||||||
|
|
||||||
|
let Some(reflected_transform) = mirror_reflection(&content, relative_to_bounds, offset, angle) else {
|
||||||
|
return Ok(List::new_from_item(content));
|
||||||
|
};
|
||||||
|
let item_transform: DAffine2 = content.attribute_cloned_or_default(ATTR_TRANSFORM);
|
||||||
|
|
||||||
|
let mut result_list = List::new();
|
||||||
|
|
||||||
|
if keep_original {
|
||||||
|
result_list.push(content.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the mirrored copy with the reflection composed onto its transform
|
||||||
|
let mut mirrored = content;
|
||||||
|
mirrored.set_attribute(ATTR_TRANSFORM, reflected_transform * item_transform);
|
||||||
|
result_list.push(mirrored);
|
||||||
|
|
||||||
|
Ok(result_list)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The reflection mirroring `content` across the line through its reference point at `angle`, or `None` without rectangular bounds to place it by.
|
||||||
|
fn mirror_reflection<T: BoundingBox>(content: &Item<T>, relative_to_bounds: ReferencePoint, offset: f64, angle: f64) -> Option<DAffine2> {
|
||||||
// Normalize the direction vector
|
// Normalize the direction vector
|
||||||
let normal = DVec2::from_angle(angle.to_radians());
|
let normal = DVec2::from_angle(angle.to_radians());
|
||||||
|
|
||||||
// The mirror reference may be based on the bounding box if an explicit reference point is chosen
|
// The mirror reference may be based on the bounding box if an explicit reference point is chosen
|
||||||
let item_transform: DAffine2 = content.attribute_cloned_or_default(ATTR_TRANSFORM);
|
|
||||||
let RenderBoundingBox::Rectangle(bounding_box) = content.bounding_box(DAffine2::IDENTITY, false) else {
|
let RenderBoundingBox::Rectangle(bounding_box) = content.bounding_box(DAffine2::IDENTITY, false) else {
|
||||||
return List::new_from_item(content);
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let reference_point_location = relative_to_bounds.point_in_bounding_box((bounding_box[0], bounding_box[1]).into());
|
let reference_point_location = relative_to_bounds.point_in_bounding_box((bounding_box[0], bounding_box[1]).into());
|
||||||
@@ -476,24 +508,11 @@ fn mirror<T: BoundingBox + Send + Clone>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Apply reflection around the reference point
|
// Apply reflection around the reference point
|
||||||
let reflected_transform = if let Some(mirror_reference_point) = mirror_reference_point {
|
Some(if let Some(mirror_reference_point) = mirror_reference_point {
|
||||||
DAffine2::from_translation(mirror_reference_point) * reflection * DAffine2::from_translation(-mirror_reference_point)
|
DAffine2::from_translation(mirror_reference_point) * reflection * DAffine2::from_translation(-mirror_reference_point)
|
||||||
} else {
|
} else {
|
||||||
reflection * DAffine2::from_translation(DVec2::from_angle(angle.to_radians()) * DVec2::splat(-offset))
|
reflection * DAffine2::from_translation(DVec2::from_angle(angle.to_radians()) * DVec2::splat(-offset))
|
||||||
};
|
})
|
||||||
|
|
||||||
let mut result_list = List::new();
|
|
||||||
|
|
||||||
if keep_original {
|
|
||||||
result_list.push(content.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the mirrored copy with the reflection composed onto its transform
|
|
||||||
let mut mirrored = content;
|
|
||||||
mirrored.set_attribute(ATTR_TRANSFORM, reflected_transform * item_transform);
|
|
||||||
result_list.push(mirrored);
|
|
||||||
|
|
||||||
result_list
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the path identifying the subgraph (network) that contains this proto node — i.e. the input `node_path`
|
/// Returns the path identifying the subgraph (network) that contains this proto node — i.e. the input `node_path`
|
||||||
@@ -528,8 +547,8 @@ fn write_attribute<T: AnyHash + Clone + Send + Sync + CacheHash>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -817,11 +836,11 @@ fn read_attribute_raster(
|
|||||||
/// The attribute name (key) to read.
|
/// The attribute name (key) to read.
|
||||||
#[constant]
|
#[constant]
|
||||||
name: Item<String>,
|
name: Item<String>,
|
||||||
) -> List<Raster<CPU>> {
|
) -> List<Raster<GPU>> {
|
||||||
let name = name.into_element();
|
let name = name.into_element();
|
||||||
let mut result = List::with_capacity(content.len());
|
let mut result = List::with_capacity(content.len());
|
||||||
for index in 0..content.len() {
|
for index in 0..content.len() {
|
||||||
let Some(value) = content.attribute::<Raster<CPU>>(&name, index) else { continue };
|
let Some(value) = content.attribute::<Raster<GPU>>(&name, index) else { continue };
|
||||||
result.push(Item::new_from_element(value.clone()));
|
result.push(Item::new_from_element(value.clone()));
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
@@ -841,8 +860,8 @@ fn extend<T: Send + Clone>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -860,8 +879,8 @@ fn extend<T: Send + Clone>(
|
|||||||
List<DAffine2>,
|
List<DAffine2>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<Artboard>,
|
List<Artboard>,
|
||||||
@@ -881,9 +900,9 @@ fn extend<T: Send + Clone>(
|
|||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn legacy_layer_extend<T: Send + Clone>(
|
fn legacy_layer_extend<T: Send + Clone>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(List<Artboard>, List<Graphic>, List<Vector>, List<String>, List<Raster<CPU>>, List<Raster<GPU>>, List<Color>, List<Gradient>)] base: List<T>,
|
#[implementations(List<Artboard>, List<Graphic>, List<Vector>, List<String>, List<Raster<GPU>>, List<Raster<CPU>>, List<Color>, List<Gradient>)] base: List<T>,
|
||||||
#[expose]
|
#[expose]
|
||||||
#[implementations(List<Artboard>, List<Graphic>, List<Vector>, List<String>, List<Raster<CPU>>, List<Raster<GPU>>, List<Color>, List<Gradient>)]
|
#[implementations(List<Artboard>, List<Graphic>, List<Vector>, List<String>, List<Raster<GPU>>, List<Raster<CPU>>, List<Color>, List<Gradient>)]
|
||||||
new: List<T>,
|
new: List<T>,
|
||||||
nested_node_path: Item<NodeIdPath>,
|
nested_node_path: Item<NodeIdPath>,
|
||||||
) -> List<T> {
|
) -> List<T> {
|
||||||
@@ -911,8 +930,8 @@ fn into_group<T: Into<Graphic>>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
List<Graphic>,
|
List<Graphic>,
|
||||||
List<Vector>,
|
List<Vector>,
|
||||||
List<Raster<CPU>>,
|
|
||||||
List<Raster<GPU>>,
|
List<Raster<GPU>>,
|
||||||
|
List<Raster<CPU>>,
|
||||||
List<Color>,
|
List<Color>,
|
||||||
List<Gradient>,
|
List<Gradient>,
|
||||||
List<String>,
|
List<String>,
|
||||||
@@ -1011,7 +1030,7 @@ pub fn flatten_vector(_: impl Ctx, content: List<Graphic>) -> List<Vector> {
|
|||||||
|
|
||||||
/// Converts a `Graphic[]` into a `Raster[]` by deeply flattening any raster content it contains, and discarding any non-raster content.
|
/// Converts a `Graphic[]` into a `Raster[]` by deeply flattening any raster content it contains, and discarding any non-raster content.
|
||||||
#[node_macro::node(category("Graphic"), icon("NodeFlattenRaster"))]
|
#[node_macro::node(category("Graphic"), icon("NodeFlattenRaster"))]
|
||||||
fn flatten_raster(_: impl Ctx, content: List<Graphic>) -> List<Raster<CPU>> {
|
fn flatten_raster(_: impl Ctx, content: List<Graphic>) -> List<Raster<GPU>> {
|
||||||
content.into_flattened_list()
|
content.into_flattened_list()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ wasm = [
|
|||||||
]
|
]
|
||||||
image-compare = []
|
image-compare = []
|
||||||
vello = ["gpu"]
|
vello = ["gpu"]
|
||||||
shader-nodes = ["raster-nodes/shader-nodes"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Local dependencies
|
# Local dependencies
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use core_types::ops::{Convert, ConvertAsync};
|
|||||||
use core_types::transform::Footprint;
|
use core_types::transform::Footprint;
|
||||||
use core_types::{ATTR_EDITOR_MERGED_LAYERS, ATTR_TRANSFORM};
|
use core_types::{ATTR_EDITOR_MERGED_LAYERS, ATTR_TRANSFORM};
|
||||||
use glam::{DAffine2, UVec2};
|
use glam::{DAffine2, UVec2};
|
||||||
|
use core_types::{Interrupt, NodeError};
|
||||||
pub use graph_craft::application_io::resource::{Resource, ResourceHash};
|
pub use graph_craft::application_io::resource::{Resource, ResourceHash};
|
||||||
pub use graph_craft::application_io::*;
|
pub use graph_craft::application_io::*;
|
||||||
pub use graph_craft::document::value::RenderOutputType;
|
pub use graph_craft::document::value::RenderOutputType;
|
||||||
@@ -13,7 +14,8 @@ pub use graph_craft::document::value::RenderOutputType;
|
|||||||
pub use graphene_canvas_utils as canvas_utils;
|
pub use graphene_canvas_utils as canvas_utils;
|
||||||
use graphic_types::Graphic;
|
use graphic_types::Graphic;
|
||||||
use graphic_types::raster_types::Image;
|
use graphic_types::raster_types::Image;
|
||||||
use graphic_types::raster_types::{CPU, GPU, Raster};
|
use graphic_types::raster_types::{GPU, Raster, Storage};
|
||||||
|
use raster_nodes::raster_kernel::raster_kernel_pipeline;
|
||||||
use rendering::{Render, RenderParams};
|
use rendering::{Render, RenderParams};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -171,10 +173,16 @@ fn string_to_bytes(_: impl Ctx, string: Item<String>) -> Item<Resource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Converts extracted raw RGBA pixel data from an input image. Each pixel becomes 4 sequential bytes. Useful for transmission over HTTP or writing to files.
|
/// Converts extracted raw RGBA pixel data from an input image. Each pixel becomes 4 sequential bytes. Useful for transmission over HTTP or writing to files.
|
||||||
#[node_macro::node(category("Data: I/O"), icon("NodeImageToBytes"), name("Image to Bytes"))]
|
#[node_macro::node(category("Data: I/O"), icon("NodeImageToBytes"), name("Image to Bytes"), placeholder = pending_image_bytes)]
|
||||||
fn image_to_bytes(_: impl Ctx, image: Item<Raster<CPU>>) -> Item<Resource> {
|
async fn image_to_bytes(_: impl Ctx, image: Item<Raster<GPU>>, #[scope(raster_kernel_pipeline::IDENTIFIER)] pipeline: Item<::wgpu_executor::WgpuPipelineCache>) -> Result<Item<Resource>, NodeError> {
|
||||||
|
let image = image.into_element();
|
||||||
|
if image.is_empty() {
|
||||||
|
return Ok(Item::new_from_element(Resource::empty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
let executor = pipeline.element().executor().cloned().ok_or_else(|| NodeError::new("A GPU is required to read a GPU raster"))?;
|
||||||
|
let image = image.convert(Footprint::DEFAULT, executor).await;
|
||||||
let bytes: Vec<u8> = image
|
let bytes: Vec<u8> = image
|
||||||
.element()
|
|
||||||
.data
|
.data
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|color| {
|
.flat_map(|color| {
|
||||||
@@ -183,7 +191,11 @@ fn image_to_bytes(_: impl Ctx, image: Item<Raster<CPU>>) -> Item<Resource> {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Item::new_from_element(Resource::new(bytes))
|
Ok(Item::new_from_element(Resource::new(bytes)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pending_image_bytes(_image: &Item<Raster<GPU>>, _pipeline: &Item<::wgpu_executor::WgpuPipelineCache>) -> Item<Resource> {
|
||||||
|
Item::new_from_element(Resource::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads binary from URLs and local asset paths.
|
/// Loads binary from URLs and local asset paths.
|
||||||
@@ -207,17 +219,18 @@ fn pending_resource(_primary: &(), _url: &Item<String>) -> Item<Resource> {
|
|||||||
/// Converts the raw byte data of an image file to a raster image.
|
/// Converts the raw byte data of an image file to a raster image.
|
||||||
///
|
///
|
||||||
/// Supports the formats: PNG, JPG, GIF, WEBP, TIFF, BMP, TGA, ICO, HDR, EXR.
|
/// Supports the formats: PNG, JPG, GIF, WEBP, TIFF, BMP, TGA, ICO, HDR, EXR.
|
||||||
#[node_macro::node(category("Data: I/O"), icon("NodeBytesToImage"), name("Bytes to Image"))]
|
#[node_macro::node(category("Data: I/O"), icon("NodeBytesToImage"), name("Bytes to Image"), memoize)]
|
||||||
fn bytes_to_image(_: impl Ctx, data: Item<Resource>) -> Item<Raster<CPU>> {
|
fn bytes_to_image(_: impl Ctx, data: Item<Resource>, #[scope(raster_kernel_pipeline::IDENTIFIER)] pipeline: Item<::wgpu_executor::WgpuPipelineCache>) -> Result<Item<Raster<GPU>>, Interrupt> {
|
||||||
let data = data.into_element();
|
let data = data.into_element();
|
||||||
let Some(image) = Image::from_encoded(data.as_ref()) else { return Item::default() };
|
let Some(image) = Image::from_encoded(data.as_ref()) else { return Ok(Item::default()) };
|
||||||
|
|
||||||
Item::new_from_element(Raster::new_cpu(image))
|
let executor = pipeline.element().executor().cloned().ok_or_else(|| NodeError::new("A GPU is required to load an image"))?;
|
||||||
|
Ok(Item::new_from_element(Raster::new_cpu(image).convert(Footprint::DEFAULT, executor)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renders a view of the input graphic within an area defined by the *Footprint*.
|
/// Renders a view of the input graphic within an area defined by the *Footprint*.
|
||||||
#[node_macro::node(category(""), placeholder = pending_raster)]
|
#[node_macro::node(category(""), placeholder = pending_raster)]
|
||||||
async fn rasterize(_: impl Ctx, data: List<Graphic>, footprint: Item<Footprint>, #[scope(try_wgpu_executor::IDENTIFIER)] executor: Item<Option<::wgpu_executor::WgpuExecutor>>) -> List<Raster<CPU>> {
|
async fn rasterize(_: impl Ctx, data: List<Graphic>, footprint: Item<Footprint>, #[scope(try_wgpu_executor::IDENTIFIER)] executor: Item<Option<::wgpu_executor::WgpuExecutor>>) -> List<Raster<GPU>> {
|
||||||
let Some(executor) = executor.into_element() else {
|
let Some(executor) = executor.into_element() else {
|
||||||
log::error!("Rasterizing requires a GPU executor");
|
log::error!("Rasterizing requires a GPU executor");
|
||||||
return List::new();
|
return List::new();
|
||||||
@@ -225,7 +238,7 @@ async fn rasterize(_: impl Ctx, data: List<Graphic>, footprint: Item<Footprint>,
|
|||||||
rasterize_with_vello(data, footprint.into_element(), executor).await
|
rasterize_with_vello(data, footprint.into_element(), executor).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn rasterize_with_vello(data: List<Graphic>, footprint: Footprint, executor: ::wgpu_executor::WgpuExecutor) -> List<Raster<CPU>> {
|
async fn rasterize_with_vello(data: List<Graphic>, footprint: Footprint, executor: ::wgpu_executor::WgpuExecutor) -> List<Raster<GPU>> {
|
||||||
let resolution = footprint.resolution;
|
let resolution = footprint.resolution;
|
||||||
if footprint.transform.matrix2.determinant() == 0. || resolution.cmpeq(UVec2::ZERO).any() {
|
if footprint.transform.matrix2.determinant() == 0. || resolution.cmpeq(UVec2::ZERO).any() {
|
||||||
log::trace!("Invalid footprint received for rasterization");
|
log::trace!("Invalid footprint received for rasterization");
|
||||||
@@ -235,28 +248,28 @@ async fn rasterize_with_vello(data: List<Graphic>, footprint: Footprint, executo
|
|||||||
let aabb = Bbox::from_transform(footprint.transform).to_axis_aligned_bbox();
|
let aabb = Bbox::from_transform(footprint.transform).to_axis_aligned_bbox();
|
||||||
let view = DAffine2::from_scale(resolution.as_dvec2() / aabb.size()) * DAffine2::from_translation(-aabb.start);
|
let view = DAffine2::from_scale(resolution.as_dvec2() / aabb.size()) * DAffine2::from_translation(-aabb.start);
|
||||||
let render_params = RenderParams {
|
let render_params = RenderParams {
|
||||||
footprint,
|
footprint: Footprint { transform: view, ..footprint },
|
||||||
|
render_output_type: rendering::RenderOutputType::Vello,
|
||||||
for_export: true,
|
for_export: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let texture = match executor.render_vello(resolution, view, &mut |scene| data.render_to_vello(scene, DAffine2::IDENTITY, &render_params)) {
|
let texture = match executor.render_vello_raster(resolution, view, &mut |scene| data.render_to_vello(scene, DAffine2::IDENTITY, &render_params)) {
|
||||||
Ok(texture) => texture,
|
Ok(texture) => texture,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
log::error!("Failed to rasterize: {error}");
|
log::error!("Failed to rasterize: {error}");
|
||||||
return List::new();
|
return List::new();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let raster = ConvertAsync::<Raster<CPU>, _>::convert(Raster::new_gpu(texture), Footprint::DEFAULT, executor).await;
|
|
||||||
|
|
||||||
// The input's layers stay reachable so the renderer can expose their click targets to the editor's tools
|
// The input's layers stay reachable so the renderer can expose their click targets to the editor's tools
|
||||||
List::new_from_item(
|
List::new_from_item(
|
||||||
Item::new_from_element(raster)
|
Item::new_from_element(Raster::new_gpu(texture))
|
||||||
.with_attribute(ATTR_TRANSFORM, footprint.transform)
|
.with_attribute(ATTR_TRANSFORM, footprint.transform)
|
||||||
.with_attribute(ATTR_EDITOR_MERGED_LAYERS, data),
|
.with_attribute(ATTR_EDITOR_MERGED_LAYERS, data),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pending_raster(_data: &List<Graphic>, _footprint: &Item<Footprint>, _executor: &Item<Option<::wgpu_executor::WgpuExecutor>>) -> List<Raster<CPU>> {
|
fn pending_raster(_data: &List<Graphic>, _footprint: &Item<Footprint>, _executor: &Item<Option<::wgpu_executor::WgpuExecutor>>) -> List<Raster<GPU>> {
|
||||||
List::new()
|
List::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,20 +327,12 @@ fn try_wgpu_executor(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: I
|
|||||||
Item::new_from_element(executor)
|
Item::new_from_element(executor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Uploads image data from CPU memory into a GPU texture so that GPU-based nodes can process it.
|
|
||||||
#[node_macro::node(category("Raster"), icon("NodeUploadTexture"), memoize)]
|
|
||||||
fn upload_texture(_: impl Ctx, content: Item<Raster<CPU>>, #[scope(wgpu_executor::IDENTIFIER)] executor: Item<::wgpu_executor::WgpuExecutor>) -> Item<Raster<GPU>> {
|
|
||||||
let executor = executor.into_element();
|
|
||||||
let (raster, attributes) = content.into_parts();
|
|
||||||
|
|
||||||
Item::from_parts(raster.convert(Footprint::DEFAULT, executor), attributes)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use core_types::Color;
|
use core_types::Color;
|
||||||
use glam::DVec2;
|
use glam::DVec2;
|
||||||
|
use graphic_types::raster_types::CPU;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn rasterize_renders_the_footprint_area_at_its_resolution() {
|
async fn rasterize_renders_the_footprint_area_at_its_resolution() {
|
||||||
@@ -341,9 +346,11 @@ mod tests {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let output = rasterize_with_vello(data, footprint, executor).await;
|
let output = rasterize_with_vello(data, footprint, executor.clone()).await;
|
||||||
|
|
||||||
let image = output.iter_element_values().next().expect("Rasterize should output one image").data();
|
let raster = output.iter_element_values().next().expect("Rasterize should output one image").clone();
|
||||||
|
let raster: Raster<CPU> = raster.convert(Footprint::DEFAULT, executor).await;
|
||||||
|
let image = raster.data();
|
||||||
assert_eq!((image.width, image.height), (4, 4));
|
assert_eq!((image.width, image.height), (4, 4));
|
||||||
for x in 0..4 {
|
for x in 0..4 {
|
||||||
let pixel = image.data[(4 + x) as usize];
|
let pixel = image.data[(4 + x) as usize];
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
use core_types::list::{Item, List};
|
use core_types::list::{Item, List};
|
||||||
|
use core_types::ops::ConvertAsync;
|
||||||
use core_types::transform::{Footprint, Transform};
|
use core_types::transform::{Footprint, Transform};
|
||||||
use core_types::{CloneVarArgs, ExtractAll, ExtractVarArgs};
|
use core_types::{CloneVarArgs, ExtractAll, ExtractVarArgs};
|
||||||
use core_types::{Color, Context, Ctx, ExtractFootprint, Interrupt, OwnedContextImpl, WasmNotSend};
|
use core_types::{Color, Context, Ctx, ExtractFootprint, Interrupt, OwnedContextImpl, WasmNotSend};
|
||||||
use graph_craft::document::value::{RenderOutput, RenderOutputType};
|
use graph_craft::document::value::{RenderOutput, RenderOutputType};
|
||||||
use graphene_application_io::{ExportFormat, RenderConfig};
|
use graphene_application_io::{ExportFormat, RenderConfig};
|
||||||
use graphic_types::raster_types::{CPU, Raster};
|
use graphic_types::raster_types::{CPU, GPU, Raster, Texture};
|
||||||
use graphic_types::{Artboard, Graphic, Vector};
|
use graphic_types::{Artboard, Graphic, Vector};
|
||||||
use rendering::vello_scene_builder::VelloSceneBuilder;
|
use rendering::vello_scene_builder::VelloSceneBuilder;
|
||||||
use rendering::{Render, RenderMetadata, RenderOutputType as RenderOutputTypeRequest, RenderParams, SvgRender, SvgRenderOutput};
|
use rendering::{Render, RenderMetadata, RenderOutputType as RenderOutputTypeRequest, RenderParams, SvgRender, SvgRenderOutput};
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use vector_types::Gradient;
|
use vector_types::Gradient;
|
||||||
use wgpu_executor::WgpuExecutor;
|
use wgpu_executor::WgpuExecutor;
|
||||||
|
|
||||||
#[derive(Clone, dyn_any::DynAny)]
|
|
||||||
pub enum RenderIntermediateType {
|
|
||||||
/// The content itself, drawn into a Vello scene at each render since the scene depends on the render's size and placement
|
|
||||||
Vello(Arc<dyn Render + Send + Sync>),
|
|
||||||
Svg(Arc<SvgRenderOutput>),
|
|
||||||
}
|
|
||||||
#[derive(Clone, dyn_any::DynAny)]
|
#[derive(Clone, dyn_any::DynAny)]
|
||||||
pub struct RenderIntermediate {
|
pub struct RenderIntermediate {
|
||||||
pub(crate) ty: RenderIntermediateType,
|
/// The content itself, drawn at each render since a Vello scene depends on the render's size and placement and SVG output on the GPU raster downloads
|
||||||
|
pub(crate) content: Arc<dyn Render + Send + Sync>,
|
||||||
|
/// Images of the content's GPU raster textures, downloaded only for SVG output, which can't reference textures
|
||||||
|
pub(crate) gpu_raster_downloads: Arc<HashMap<Texture, Raster<CPU>>>,
|
||||||
pub(crate) metadata: RenderMetadata,
|
pub(crate) metadata: RenderMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +30,7 @@ fn render_intermediate<T: 'static + Render + WasmNotSend + Send + Sync>(
|
|||||||
Context -> List<Artboard>,
|
Context -> List<Artboard>,
|
||||||
Context -> List<Graphic>,
|
Context -> List<Graphic>,
|
||||||
Context -> List<Vector>,
|
Context -> List<Vector>,
|
||||||
|
Context -> List<Raster<GPU>>,
|
||||||
Context -> List<Raster<CPU>>,
|
Context -> List<Raster<CPU>>,
|
||||||
Context -> List<Color>,
|
Context -> List<Color>,
|
||||||
Context -> List<Gradient>,
|
Context -> List<Gradient>,
|
||||||
@@ -38,38 +38,55 @@ fn render_intermediate<T: 'static + Render + WasmNotSend + Send + Sync>(
|
|||||||
)]
|
)]
|
||||||
data: impl Node<Context<'static>, Output = T>,
|
data: impl Node<Context<'static>, Output = T>,
|
||||||
) -> Result<Item<RenderIntermediate>, Interrupt> {
|
) -> Result<Item<RenderIntermediate>, Interrupt> {
|
||||||
let render_params = ctx
|
|
||||||
.vararg(0)
|
|
||||||
.expect("Did not find var args")
|
|
||||||
.downcast_ref::<RenderParams>()
|
|
||||||
.expect("Downcasting render params yielded invalid type");
|
|
||||||
|
|
||||||
let ctx = OwnedContextImpl::from(ctx.clone()).into_context();
|
let ctx = OwnedContextImpl::from(ctx.clone()).into_context();
|
||||||
let data = data.eval(ctx)?;
|
let data = data.eval(ctx)?;
|
||||||
|
|
||||||
let footprint = Footprint::default();
|
let footprint = Footprint::default();
|
||||||
let mut metadata = RenderMetadata::default();
|
let mut metadata = RenderMetadata::default();
|
||||||
data.collect_metadata(&mut metadata, footprint, None, None);
|
data.collect_metadata(&mut metadata, footprint, None, None);
|
||||||
let intermediate = match &render_params.render_output_type {
|
let intermediate = RenderIntermediate {
|
||||||
RenderOutputTypeRequest::Vello => RenderIntermediate {
|
content: Arc::new(data),
|
||||||
ty: RenderIntermediateType::Vello(Arc::new(data)),
|
gpu_raster_downloads: Arc::default(),
|
||||||
metadata,
|
metadata,
|
||||||
},
|
|
||||||
RenderOutputTypeRequest::Svg => {
|
|
||||||
let mut render = SvgRender::new();
|
|
||||||
|
|
||||||
data.render_svg(&mut render, render_params);
|
|
||||||
|
|
||||||
RenderIntermediate {
|
|
||||||
ty: RenderIntermediateType::Svg(Arc::new(render.into())),
|
|
||||||
metadata,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Item::new_from_element(intermediate))
|
Ok(Item::new_from_element(intermediate))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Downloads the content's GPU raster textures for SVG output to embed, leaving them undrawn without a GPU executor.
|
||||||
|
#[node_macro::node(category(""), placeholder = pending_gpu_raster_downloads)]
|
||||||
|
async fn download_gpu_rasters(
|
||||||
|
ctx: impl Ctx + ExtractVarArgs,
|
||||||
|
#[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Item<Option<WgpuExecutor>>,
|
||||||
|
mut data: Item<RenderIntermediate>,
|
||||||
|
) -> Item<RenderIntermediate> {
|
||||||
|
let render_output_type = ctx
|
||||||
|
.vararg(0)
|
||||||
|
.expect("Did not find var args")
|
||||||
|
.downcast_ref::<RenderParams>()
|
||||||
|
.expect("Downcasting render params yielded invalid type")
|
||||||
|
.render_output_type;
|
||||||
|
let (RenderOutputTypeRequest::Svg, Some(executor)) = (render_output_type, executor.into_element()) else {
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut textures = Vec::new();
|
||||||
|
data.element().content.collect_gpu_textures(&mut textures);
|
||||||
|
if textures.is_empty() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
let rasters: List<Raster<GPU>> = textures.iter().map(|texture| Item::new_from_element(Raster::new_gpu(texture.clone()))).collect();
|
||||||
|
let downloads = rasters.convert(Footprint::DEFAULT, executor).await;
|
||||||
|
|
||||||
|
data.element_mut().gpu_raster_downloads = Arc::new(textures.into_iter().zip(downloads.into_iter().map(Item::into_element)).collect());
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pending_gpu_raster_downloads(_executor: &Item<Option<WgpuExecutor>>, data: &Item<RenderIntermediate>) -> Item<RenderIntermediate> {
|
||||||
|
data.clone()
|
||||||
|
}
|
||||||
|
|
||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn render(
|
fn render(
|
||||||
ctx: impl Ctx + ExtractFootprint + ExtractVarArgs,
|
ctx: impl Ctx + ExtractFootprint + ExtractVarArgs,
|
||||||
@@ -82,18 +99,25 @@ fn render(
|
|||||||
.expect("Did not find var args")
|
.expect("Did not find var args")
|
||||||
.downcast_ref::<RenderParams>()
|
.downcast_ref::<RenderParams>()
|
||||||
.expect("Downcasting render params yielded invalid type");
|
.expect("Downcasting render params yielded invalid type");
|
||||||
let mut render_params = render_params.clone();
|
|
||||||
render_params.footprint = *footprint;
|
|
||||||
|
|
||||||
let RenderIntermediate { ty, mut metadata } = data.into_element();
|
let RenderIntermediate {
|
||||||
|
content,
|
||||||
|
gpu_raster_downloads,
|
||||||
|
mut metadata,
|
||||||
|
} = data.into_element();
|
||||||
metadata.apply_transform(footprint.transform);
|
metadata.apply_transform(footprint.transform);
|
||||||
|
|
||||||
let data = match (render_params.render_output_type, ty) {
|
let data = match render_params.render_output_type {
|
||||||
(RenderOutputTypeRequest::Svg, RenderIntermediateType::Svg(data)) => {
|
RenderOutputTypeRequest::Svg => {
|
||||||
|
let render_params = RenderParams {
|
||||||
|
gpu_raster_downloads,
|
||||||
|
..render_params.clone()
|
||||||
|
};
|
||||||
let logical_transform = glam::DAffine2::from_scale(glam::DVec2::splat(1.0 / render_params.scale)) * footprint.transform;
|
let logical_transform = glam::DAffine2::from_scale(glam::DVec2::splat(1.0 / render_params.scale)) * footprint.transform;
|
||||||
let logical_resolution = footprint.resolution.as_dvec2() / render_params.scale;
|
let logical_resolution = footprint.resolution.as_dvec2() / render_params.scale;
|
||||||
|
|
||||||
let mut render = SvgRender::from(data.as_ref());
|
let mut render = SvgRender::new();
|
||||||
|
content.render_svg(&mut render, &render_params);
|
||||||
render.wrap_with_transform(logical_transform, Some(logical_resolution));
|
render.wrap_with_transform(logical_transform, Some(logical_resolution));
|
||||||
|
|
||||||
let output = SvgRenderOutput::from(render);
|
let output = SvgRenderOutput::from(render);
|
||||||
@@ -104,10 +128,14 @@ fn render(
|
|||||||
image_data: output.image_data.into_iter().collect(),
|
image_data: output.image_data.into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(RenderOutputTypeRequest::Vello, RenderIntermediateType::Vello(data)) => {
|
RenderOutputTypeRequest::Vello => {
|
||||||
|
let render_params = RenderParams {
|
||||||
|
footprint: *footprint,
|
||||||
|
..render_params.clone()
|
||||||
|
};
|
||||||
let executor = executor.into_element().expect("GPU executor not available");
|
let executor = executor.into_element().expect("GPU executor not available");
|
||||||
|
|
||||||
let mut draw = |scene: &mut VelloSceneBuilder| data.render_to_vello(scene, Default::default(), &render_params);
|
let mut draw = |scene: &mut VelloSceneBuilder| content.render_to_vello(scene, Default::default(), &render_params);
|
||||||
let texture = match executor.render_vello(footprint.resolution, footprint.transform, &mut draw) {
|
let texture = match executor.render_vello(footprint.resolution, footprint.transform, &mut draw) {
|
||||||
Ok(texture) => texture,
|
Ok(texture) => texture,
|
||||||
// Leave the output transparent, at a size the GPU can hold, rather than taking down the editor
|
// Leave the output transparent, at a size the GPU can hold, rather than taking down the editor
|
||||||
@@ -121,7 +149,6 @@ fn render(
|
|||||||
};
|
};
|
||||||
RenderOutputType::Texture(texture)
|
RenderOutputType::Texture(texture)
|
||||||
}
|
}
|
||||||
_ => unreachable!("Render node did not receive its requested data type"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Item::new_from_element(RenderOutput { data, metadata })
|
Item::new_from_element(RenderOutput { data, metadata })
|
||||||
|
|||||||
@@ -1390,8 +1390,8 @@ fn switch<T: Send>(
|
|||||||
Context -> Item<DAffine2>,
|
Context -> Item<DAffine2>,
|
||||||
Context -> Item<Vector>,
|
Context -> Item<Vector>,
|
||||||
Context -> Item<Graphic>,
|
Context -> Item<Graphic>,
|
||||||
Context -> Item<Raster<CPU>>,
|
|
||||||
Context -> Item<Raster<GPU>>,
|
Context -> Item<Raster<GPU>>,
|
||||||
|
Context -> Item<Raster<CPU>>,
|
||||||
Context -> Item<Color>,
|
Context -> Item<Color>,
|
||||||
Context -> Item<Gradient>,
|
Context -> Item<Gradient>,
|
||||||
Context -> Item<Artboard>,
|
Context -> Item<Artboard>,
|
||||||
@@ -1403,8 +1403,8 @@ fn switch<T: Send>(
|
|||||||
Context -> Item<Bundle<DAffine2>>,
|
Context -> Item<Bundle<DAffine2>>,
|
||||||
Context -> Item<Bundle<Vector>>,
|
Context -> Item<Bundle<Vector>>,
|
||||||
Context -> Item<Bundle<Graphic>>,
|
Context -> Item<Bundle<Graphic>>,
|
||||||
Context -> Item<Bundle<Raster<CPU>>>,
|
|
||||||
Context -> Item<Bundle<Raster<GPU>>>,
|
Context -> Item<Bundle<Raster<GPU>>>,
|
||||||
|
Context -> Item<Bundle<Raster<CPU>>>,
|
||||||
Context -> Item<Bundle<Color>>,
|
Context -> Item<Bundle<Color>>,
|
||||||
Context -> Item<Bundle<Gradient>>,
|
Context -> Item<Bundle<Gradient>>,
|
||||||
Context -> Item<Bundle<Artboard>>,
|
Context -> Item<Bundle<Artboard>>,
|
||||||
@@ -1420,8 +1420,8 @@ fn switch<T: Send>(
|
|||||||
Context -> Item<DAffine2>,
|
Context -> Item<DAffine2>,
|
||||||
Context -> Item<Vector>,
|
Context -> Item<Vector>,
|
||||||
Context -> Item<Graphic>,
|
Context -> Item<Graphic>,
|
||||||
Context -> Item<Raster<CPU>>,
|
|
||||||
Context -> Item<Raster<GPU>>,
|
Context -> Item<Raster<GPU>>,
|
||||||
|
Context -> Item<Raster<CPU>>,
|
||||||
Context -> Item<Color>,
|
Context -> Item<Color>,
|
||||||
Context -> Item<Gradient>,
|
Context -> Item<Gradient>,
|
||||||
Context -> Item<Artboard>,
|
Context -> Item<Artboard>,
|
||||||
@@ -1433,8 +1433,8 @@ fn switch<T: Send>(
|
|||||||
Context -> Item<Bundle<DAffine2>>,
|
Context -> Item<Bundle<DAffine2>>,
|
||||||
Context -> Item<Bundle<Vector>>,
|
Context -> Item<Bundle<Vector>>,
|
||||||
Context -> Item<Bundle<Graphic>>,
|
Context -> Item<Bundle<Graphic>>,
|
||||||
Context -> Item<Bundle<Raster<CPU>>>,
|
|
||||||
Context -> Item<Bundle<Raster<GPU>>>,
|
Context -> Item<Bundle<Raster<GPU>>>,
|
||||||
|
Context -> Item<Bundle<Raster<CPU>>>,
|
||||||
Context -> Item<Bundle<Color>>,
|
Context -> Item<Bundle<Color>>,
|
||||||
Context -> Item<Bundle<Gradient>>,
|
Context -> Item<Bundle<Gradient>>,
|
||||||
Context -> Item<Bundle<Artboard>>,
|
Context -> Item<Bundle<Artboard>>,
|
||||||
|
|||||||
@@ -15,26 +15,8 @@ publish.workspace = true
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["serde"]
|
||||||
serde = ["dep:serde", "core-types?/serde", "raster-types?/serde", "vector-types?/serde"]
|
serde = ["dep:serde", "core-types/serde", "raster-types/serde", "vector-types/serde"]
|
||||||
shader-nodes = ["std", "dep:raster-nodes-shaders", "dep:wgpu-executor"]
|
|
||||||
std = [
|
|
||||||
"serde",
|
|
||||||
"dep:core-types",
|
|
||||||
"dep:graphene-core",
|
|
||||||
"dep:dyn-any",
|
|
||||||
"dep:graphene-resource",
|
|
||||||
"dep:graphene-hash",
|
|
||||||
"dep:raster-types",
|
|
||||||
"dep:vector-types",
|
|
||||||
"dep:image",
|
|
||||||
"dep:ndarray",
|
|
||||||
"dep:rand",
|
|
||||||
"dep:rand_chacha",
|
|
||||||
"dep:fastnoise-lite",
|
|
||||||
"dep:kurbo",
|
|
||||||
"dep:color",
|
|
||||||
]
|
|
||||||
wasm = [
|
wasm = [
|
||||||
"core-types/wasm",
|
"core-types/wasm",
|
||||||
"raster-types/wasm",
|
"raster-types/wasm",
|
||||||
@@ -45,36 +27,23 @@ wasm = [
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Local dependencies
|
# Local dependencies
|
||||||
no-std-types = { workspace = true }
|
|
||||||
node-macro = { workspace = true }
|
node-macro = { workspace = true }
|
||||||
|
dyn-any = { workspace = true }
|
||||||
# Local std dependencies
|
core-types = { workspace = true }
|
||||||
dyn-any = { workspace = true, optional = true }
|
graphene-core = { workspace = true }
|
||||||
core-types = { workspace = true, optional = true }
|
graphene-resource = { workspace = true }
|
||||||
graphene-core = { workspace = true, optional = true }
|
graphene-hash = { workspace = true }
|
||||||
graphene-resource = { workspace = true, optional = true }
|
raster-types = { workspace = true }
|
||||||
graphene-hash = { workspace = true, optional = true }
|
vector-types = { workspace = true }
|
||||||
raster-types = { workspace = true, optional = true }
|
wgpu-executor = { workspace = true }
|
||||||
vector-types = { workspace = true, optional = true }
|
|
||||||
wgpu-executor = { workspace = true, optional = true }
|
|
||||||
raster-nodes-shaders = { path = "./shaders", optional = true }
|
|
||||||
|
|
||||||
# Workspace dependencies
|
# Workspace dependencies
|
||||||
bytemuck = { workspace = true }
|
bytemuck = { workspace = true }
|
||||||
glam = { workspace = true }
|
glam = { workspace = true }
|
||||||
spirv-std = { workspace = true }
|
|
||||||
num-traits = { workspace = true }
|
|
||||||
num_enum = { workspace = true }
|
num_enum = { workspace = true }
|
||||||
|
|
||||||
# Workspace std dependencies
|
|
||||||
image = { workspace = true, optional = true }
|
|
||||||
ndarray = { workspace = true, optional = true }
|
|
||||||
rand = { workspace = true, optional = true }
|
|
||||||
rand_chacha = { workspace = true, optional = true }
|
|
||||||
fastnoise-lite = { workspace = true, optional = true }
|
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
kurbo = { workspace = true, optional = true }
|
kurbo = { workspace = true }
|
||||||
color = { workspace = true, optional = true }
|
color = { workspace = true }
|
||||||
|
|
||||||
# Workspace Wasm dependencies
|
# Workspace Wasm dependencies
|
||||||
tsify = { workspace = true, optional = true }
|
tsify = { workspace = true, optional = true }
|
||||||
|
|||||||
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user